vn/code/vn_platform.md

3.0 KiB

@table(Name, NameLower, NameCaps, Type, Arguments) platform_functions: { { Reserve reserve RESERVE void * u64 Size } { Release release RELEASE void void *Pointer } { Commit commit COMMIT void void *Pointer, u64 Size } { Decommit decommit DECOMMIT void void *Pointer, u64 Size } { OpenFile open_file OPEN_FILE platform_file_handle string Path, platform_access_flags FileAccess } { CloseFile close_file CLOSE_FILE void platform_file_handle Handle } { ReadFile read_file READ_FILE void platform_file_handle Handle, void *Dest, u64 Offset, u64 Size } { WriteFile write_file WRITE_FILE void platform_file_handle Handle, void *Source, u64 Offset, u64 Size } { GetFileSize get_file_size GET_FILE_SIZE u64 platform_file_handle Handle } { SetCursor set_cursor SET_CURSOR void platform_cursor Cursor } { ToggleFullscreen toggle_fullscreen TOGGLE_FULLSCREEN void void } { ShowMessage show_message SHOW_MESSAGE void string Message, platform_message_type Type } { BeginFileIter begin_file_iter BEGIN_FILE_ITER platform_file_iter * memory_arena *Arena, string Path } { AdvanceFileIter advance_file_iter ADVANCE_FILE_ITER b32 memory_arena *Arena, platform_file_iter *Iter, platform_file_info *OutInfo } { EndFileIter end_file_iter END_FILE_ITER void platform_file_iter *Iter } }

@table_gen { @expand(platform_functions s) #define PLATFORM_$(s.NameCaps)(name) $(s.Type) name($(s.Arguments)) }

@table_gen { @expand(platform_functions s) typedef PLATFORM_$(s.NameCaps)(platform_$(s.NameLower)); }

@table_gen { struct platform_api { @expand(platform_functions s) platform_$(s.NameLower) *$(s.Name); }; }

@table_gen { #define RegisterPlatformFunctions(PlatformName)\\ @expand(platform_functions s) Platform.$(s.Name) = PlatformName##_$(s.Name);\\ }