koffi 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +6 -0
- package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.2/koffi_win32_x64.tar.gz +0 -0
- package/doc/templates/badges.html +3 -0
- package/package.json +2 -2
- package/src/abi_arm64.cc +35 -1
- package/src/abi_x64_win.cc +2 -8
- package/src/abi_x86.cc +1 -7
- package/src/ffi.hh +1 -1
- package/src/util.hh +6 -0
- package/test/raylib.js +37 -5
- package/vendor/libcc/libcc.cc +430 -196
- package/vendor/libcc/libcc.hh +1417 -1283
- package/vendor/raylib/BINDINGS.md +87 -70
- package/vendor/raylib/CHANGELOG +263 -50
- package/vendor/raylib/CMakeLists.txt +12 -0
- package/vendor/raylib/CMakeOptions.txt +8 -1
- package/vendor/raylib/CONVENTIONS.md +2 -3
- package/vendor/raylib/FAQ.md +137 -0
- package/vendor/raylib/HISTORY.md +62 -29
- package/vendor/raylib/LICENSE +1 -1
- package/vendor/raylib/README.md +22 -17
- package/vendor/raylib/ROADMAP.md +8 -7
- package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
- package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
- package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
- package/vendor/raylib/cmake/raylib-config.cmake +52 -49
- package/vendor/raylib/examples/CMakeLists.txt +14 -9
- package/vendor/raylib/examples/Makefile +112 -125
- package/vendor/raylib/examples/Makefile.Android +1 -1
- package/vendor/raylib/examples/Makefile.Web +145 -158
- package/vendor/raylib/examples/README.md +141 -141
- package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
- package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
- package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
- package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
- package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
- package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
- package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
- package/vendor/raylib/examples/build.zig +17 -6
- package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
- package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
- package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
- package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
- package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
- package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
- package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
- package/vendor/raylib/examples/core/core_basic_window.c +8 -3
- package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
- package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
- package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
- package/vendor/raylib/examples/core/core_drop_files.c +20 -12
- package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
- package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
- package/vendor/raylib/examples/core/core_input_keys.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
- package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
- package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
- package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
- package/vendor/raylib/examples/core/core_random_values.c +8 -3
- package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
- package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
- package/vendor/raylib/examples/core/core_split_screen.c +8 -3
- package/vendor/raylib/examples/core/core_storage_values.c +109 -3
- package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
- package/vendor/raylib/examples/core/core_window_flags.c +8 -3
- package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
- package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
- package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
- package/vendor/raylib/examples/core/core_world_screen.c +9 -4
- package/vendor/raylib/examples/examples_template.c +8 -3
- package/vendor/raylib/examples/models/models_animation.c +11 -7
- package/vendor/raylib/examples/models/models_billboard.c +9 -4
- package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
- package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
- package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
- package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
- package/vendor/raylib/examples/models/models_heightmap.c +9 -4
- package/vendor/raylib/examples/models/models_loading.c +21 -17
- package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
- package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
- package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
- package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
- package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
- package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
- package/vendor/raylib/examples/models/models_skybox.c +16 -12
- package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
- package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
- package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
- package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
- package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
- package/vendor/raylib/examples/others/easings_testbed.c +10 -8
- package/vendor/raylib/examples/others/easings_testbed.png +0 -0
- package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
- package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
- package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
- package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
- package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
- package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
- package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
- package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
- package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
- package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
- package/vendor/raylib/examples/shaders/rlights.h +14 -27
- package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
- package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
- package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
- package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
- package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
- package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
- package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
- package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
- package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
- package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
- package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
- package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
- package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
- package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
- package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
- package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
- package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
- package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
- package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
- package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
- package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
- package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
- package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
- package/vendor/raylib/examples/text/text_font_filters.c +14 -11
- package/vendor/raylib/examples/text/text_font_loading.c +9 -4
- package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
- package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
- package/vendor/raylib/examples/text/text_format_text.c +8 -3
- package/vendor/raylib/examples/text/text_input_box.c +8 -3
- package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
- package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
- package/vendor/raylib/examples/text/text_unicode.c +9 -7
- package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
- package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
- package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
- package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
- package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
- package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
- package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
- package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
- package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
- package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
- package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
- package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
- package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
- package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
- package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
- package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
- package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
- package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
- package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
- package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
- package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
- package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
- package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
- package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
- package/vendor/raylib/parser/LICENSE +1 -1
- package/vendor/raylib/parser/Makefile +28 -0
- package/vendor/raylib/parser/README.md +49 -5
- package/vendor/raylib/parser/output/raylib_api.json +10717 -0
- package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
- package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
- package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
- package/vendor/raylib/parser/raylib_parser.c +1174 -196
- package/vendor/raylib/projects/4coder/Makefile +2 -4
- package/vendor/raylib/projects/4coder/main.c +0 -1
- package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
- package/vendor/raylib/projects/CMake/README.md +27 -0
- package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
- package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
- package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
- package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
- package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
- package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
- package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
- package/vendor/raylib/projects/README.md +1 -1
- package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
- package/vendor/raylib/projects/VSCode/Makefile +8 -11
- package/vendor/raylib/projects/VSCode/main.c +53 -26
- package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
- package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
- package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
- package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
- package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
- package/vendor/raylib/src/CMakeLists.txt +6 -7
- package/vendor/raylib/src/Makefile +209 -103
- package/vendor/raylib/src/build.zig +56 -20
- package/vendor/raylib/src/config.h +32 -27
- package/vendor/raylib/src/external/cgltf.h +342 -104
- package/vendor/raylib/src/external/dr_wav.h +487 -225
- package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
- package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
- package/vendor/raylib/src/external/jar_xm.h +2 -1
- package/vendor/raylib/src/external/miniaudio.h +62251 -42061
- package/vendor/raylib/src/external/qoi.h +671 -0
- package/vendor/raylib/src/external/stb_vorbis.h +1 -1
- package/vendor/raylib/src/external/vox_loader.h +30 -25
- package/vendor/raylib/src/minshell.html +82 -0
- package/vendor/raylib/src/raudio.c +359 -201
- package/vendor/raylib/src/raylib.dll.rc +5 -5
- package/vendor/raylib/src/raylib.dll.rc.data +0 -0
- package/vendor/raylib/src/raylib.h +95 -63
- package/vendor/raylib/src/raylib.rc +5 -5
- package/vendor/raylib/src/raylib.rc.data +0 -0
- package/vendor/raylib/src/raymath.h +391 -133
- package/vendor/raylib/src/rcamera.h +32 -41
- package/vendor/raylib/src/rcore.c +775 -471
- package/vendor/raylib/src/rgestures.h +5 -5
- package/vendor/raylib/src/rglfw.c +3 -3
- package/vendor/raylib/src/rlgl.h +184 -144
- package/vendor/raylib/src/rmodels.c +207 -144
- package/vendor/raylib/src/rshapes.c +105 -47
- package/vendor/raylib/src/rtext.c +255 -38
- package/vendor/raylib/src/rtextures.c +167 -71
- package/vendor/raylib/src/shell.html +63 -63
- package/vendor/raylib/src/utils.c +49 -3
- package/vendor/raylib/src/utils.h +3 -3
- package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
- package/vendor/raylib/CONTRIBUTORS.md +0 -63
- package/vendor/raylib/SPONSORS.md +0 -68
- package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
- package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
- package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
- package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
- package/vendor/raylib/examples/models/rlights.h +0 -183
- package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
- package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
- package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
- package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
- package/vendor/raylib/examples/physics/physics_demo.c +0 -128
- package/vendor/raylib/examples/physics/physics_demo.png +0 -0
- package/vendor/raylib/examples/physics/physics_friction.c +0 -142
- package/vendor/raylib/examples/physics/physics_friction.png +0 -0
- package/vendor/raylib/examples/physics/physics_movement.c +0 -128
- package/vendor/raylib/examples/physics/physics_movement.png +0 -0
- package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
- package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
- package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
- package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
- package/vendor/raylib/parser/raylib_api.json +0 -6668
- package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
- package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
- package/vendor/raylib/src/extras/physac.h +0 -1977
- package/vendor/raylib/src/extras/rmem.h +0 -751
- package/vendor/raylib/src/raudio.h +0 -198
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
raylib API parser
|
|
4
4
|
|
|
5
|
-
This parser scans raylib.h to get API information about structs, enums and functions.
|
|
5
|
+
This parser scans raylib.h to get API information about defines, structs, aliases, enums, callbacks and functions.
|
|
6
6
|
All data is divided into pieces, usually as strings. The following types are used for data:
|
|
7
7
|
|
|
8
|
-
- struct
|
|
8
|
+
- struct DefineInfo
|
|
9
9
|
- struct StructInfo
|
|
10
|
+
- struct AliasInfo
|
|
10
11
|
- struct EnumInfo
|
|
12
|
+
- struct FunctionInfo
|
|
11
13
|
|
|
12
14
|
CONSTRAINTS:
|
|
13
15
|
|
|
@@ -45,7 +47,6 @@
|
|
|
45
47
|
OTHER NOTES:
|
|
46
48
|
|
|
47
49
|
- This parser could work with other C header files if mentioned constraints are followed.
|
|
48
|
-
|
|
49
50
|
- This parser does not require <string.h> library, all data is parsed directly from char buffers.
|
|
50
51
|
|
|
51
52
|
LICENSE: zlib/libpng
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
54
55
|
BSD-like license that allows static linking with closed source software:
|
|
55
56
|
|
|
56
|
-
Copyright (c) 2021 Ramon Santamaria (@raysan5)
|
|
57
|
+
Copyright (c) 2021-2022 Ramon Santamaria (@raysan5)
|
|
57
58
|
|
|
58
59
|
**********************************************************************************************/
|
|
59
60
|
|
|
@@ -62,67 +63,112 @@
|
|
|
62
63
|
#include <stdlib.h> // Required for: malloc(), calloc(), realloc(), free(), atoi(), strtol()
|
|
63
64
|
#include <stdio.h> // Required for: printf(), fopen(), fseek(), ftell(), fread(), fclose()
|
|
64
65
|
#include <stdbool.h> // Required for: bool
|
|
66
|
+
#include <ctype.h> // Required for: isdigit()
|
|
65
67
|
|
|
66
|
-
#define
|
|
68
|
+
#define MAX_DEFINES_TO_PARSE 2048 // Maximum number of defines to parse
|
|
67
69
|
#define MAX_STRUCTS_TO_PARSE 64 // Maximum number of structures to parse
|
|
70
|
+
#define MAX_ALIASES_TO_PARSE 64 // Maximum number of aliases to parse
|
|
68
71
|
#define MAX_ENUMS_TO_PARSE 64 // Maximum number of enums to parse
|
|
72
|
+
#define MAX_CALLBACKS_TO_PARSE 64 // Maximum number of callbacks to parse
|
|
73
|
+
#define MAX_FUNCS_TO_PARSE 512 // Maximum number of functions to parse
|
|
69
74
|
|
|
70
75
|
#define MAX_LINE_LENGTH 512 // Maximum length of one line (including comments)
|
|
71
|
-
#define MAX_STRUCT_LINE_LENGTH 2048 // Maximum length of one struct (multiple lines)
|
|
72
76
|
|
|
73
|
-
#define
|
|
74
|
-
#define MAX_STRUCT_FIELDS 32 // Maximum number of struct fields
|
|
77
|
+
#define MAX_STRUCT_FIELDS 64 // Maximum number of struct fields
|
|
75
78
|
#define MAX_ENUM_VALUES 512 // Maximum number of enum values
|
|
79
|
+
#define MAX_FUNCTION_PARAMETERS 12 // Maximum number of function parameters
|
|
76
80
|
|
|
77
81
|
//----------------------------------------------------------------------------------
|
|
78
82
|
// Types and Structures Definition
|
|
79
83
|
//----------------------------------------------------------------------------------
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
|
|
85
|
+
// Type of parsed define
|
|
86
|
+
typedef enum {
|
|
87
|
+
UNKNOWN = 0,
|
|
88
|
+
MACRO,
|
|
89
|
+
GUARD,
|
|
90
|
+
INT,
|
|
91
|
+
INT_MATH,
|
|
92
|
+
LONG,
|
|
93
|
+
LONG_MATH,
|
|
94
|
+
FLOAT,
|
|
95
|
+
FLOAT_MATH,
|
|
96
|
+
DOUBLE,
|
|
97
|
+
DOUBLE_MATH,
|
|
98
|
+
CHAR,
|
|
99
|
+
STRING,
|
|
100
|
+
COLOR
|
|
101
|
+
} DefineType;
|
|
102
|
+
|
|
103
|
+
// Define info data
|
|
104
|
+
typedef struct DefineInfo {
|
|
105
|
+
char name[64]; // Define name
|
|
106
|
+
int type; // Define type
|
|
107
|
+
char value[256]; // Define value
|
|
108
|
+
char desc[128]; // Define description
|
|
109
|
+
bool isHex; // Define is hex number (for types INT, LONG)
|
|
110
|
+
} DefineInfo;
|
|
90
111
|
|
|
91
112
|
// Struct info data
|
|
92
113
|
typedef struct StructInfo {
|
|
93
114
|
char name[64]; // Struct name
|
|
94
|
-
char desc[
|
|
115
|
+
char desc[128]; // Struct type description
|
|
95
116
|
int fieldCount; // Number of fields in the struct
|
|
96
117
|
char fieldType[MAX_STRUCT_FIELDS][64]; // Field type
|
|
97
118
|
char fieldName[MAX_STRUCT_FIELDS][64]; // Field name
|
|
98
119
|
char fieldDesc[MAX_STRUCT_FIELDS][128]; // Field description
|
|
99
120
|
} StructInfo;
|
|
100
121
|
|
|
122
|
+
// Alias info data
|
|
123
|
+
typedef struct AliasInfo {
|
|
124
|
+
char type[64]; // Alias type
|
|
125
|
+
char name[64]; // Alias name
|
|
126
|
+
char desc[128]; // Alias description
|
|
127
|
+
} AliasInfo;
|
|
128
|
+
|
|
101
129
|
// Enum info data
|
|
102
130
|
typedef struct EnumInfo {
|
|
103
131
|
char name[64]; // Enum name
|
|
104
|
-
char desc[
|
|
132
|
+
char desc[128]; // Enum description
|
|
105
133
|
int valueCount; // Number of values in enumerator
|
|
106
134
|
char valueName[MAX_ENUM_VALUES][64]; // Value name definition
|
|
107
135
|
int valueInteger[MAX_ENUM_VALUES]; // Value integer
|
|
108
|
-
char valueDesc[MAX_ENUM_VALUES][
|
|
136
|
+
char valueDesc[MAX_ENUM_VALUES][128]; // Value description
|
|
109
137
|
} EnumInfo;
|
|
110
138
|
|
|
139
|
+
// Function info data
|
|
140
|
+
typedef struct FunctionInfo {
|
|
141
|
+
char name[64]; // Function name
|
|
142
|
+
char desc[128]; // Function description (comment at the end)
|
|
143
|
+
char retType[32]; // Return value type
|
|
144
|
+
int paramCount; // Number of function parameters
|
|
145
|
+
char paramType[MAX_FUNCTION_PARAMETERS][32]; // Parameters type
|
|
146
|
+
char paramName[MAX_FUNCTION_PARAMETERS][32]; // Parameters name
|
|
147
|
+
char paramDesc[MAX_FUNCTION_PARAMETERS][128]; // Parameters description
|
|
148
|
+
} FunctionInfo;
|
|
149
|
+
|
|
111
150
|
// Output format for parsed data
|
|
112
|
-
typedef enum { DEFAULT = 0, JSON, XML } OutputFormat;
|
|
151
|
+
typedef enum { DEFAULT = 0, JSON, XML, LUA } OutputFormat;
|
|
113
152
|
|
|
114
153
|
//----------------------------------------------------------------------------------
|
|
115
154
|
// Global Variables Definition
|
|
116
155
|
//----------------------------------------------------------------------------------
|
|
117
|
-
static int
|
|
156
|
+
static int defineCount = 0;
|
|
118
157
|
static int structCount = 0;
|
|
158
|
+
static int aliasCount = 0;
|
|
119
159
|
static int enumCount = 0;
|
|
120
|
-
static
|
|
160
|
+
static int callbackCount = 0;
|
|
161
|
+
static int funcCount = 0;
|
|
162
|
+
static DefineInfo *defines = NULL;
|
|
121
163
|
static StructInfo *structs = NULL;
|
|
164
|
+
static AliasInfo *aliases = NULL;
|
|
122
165
|
static EnumInfo *enums = NULL;
|
|
123
|
-
static
|
|
166
|
+
static FunctionInfo *callbacks = NULL;
|
|
167
|
+
static FunctionInfo *funcs = NULL;
|
|
124
168
|
|
|
125
169
|
// Command line variables
|
|
170
|
+
static char apiDefine[32] = { 0 }; // Functions define (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)
|
|
171
|
+
static char truncAfter[32] = { 0 }; // Truncate marker (i.e. "RLGL IMPLEMENTATION" for rlgl.h)
|
|
126
172
|
static char inFileName[512] = { 0 }; // Input file name (required in case of provided through CLI)
|
|
127
173
|
static char outFileName[512] = { 0 }; // Output file name (required for file save/export)
|
|
128
174
|
static int outputFormat = DEFAULT;
|
|
@@ -136,21 +182,27 @@ static void ProcessCommandLine(int argc, char *argv[]); // Process command l
|
|
|
136
182
|
static char *LoadFileText(const char *fileName, int *length);
|
|
137
183
|
static char **GetTextLines(const char *buffer, int length, int *linesCount);
|
|
138
184
|
static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type, char *name);
|
|
185
|
+
static void GetDescription(const char *source, char *description);
|
|
186
|
+
static void MoveArraySize(char *name, char *type); // Move array size from name to type
|
|
139
187
|
static unsigned int TextLength(const char *text); // Get text length in bytes, check for \0 character
|
|
140
188
|
static bool IsTextEqual(const char *text1, const char *text2, unsigned int count);
|
|
189
|
+
static int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string
|
|
141
190
|
static void MemoryCopy(void *dest, const void *src, unsigned int count);
|
|
142
|
-
static char*
|
|
191
|
+
static char *EscapeBackslashes(char *text); // Replace '\' by "\\" when exporting to JSON and XML
|
|
192
|
+
static const char *StrDefineType(DefineType type); // Get string of define type
|
|
143
193
|
|
|
144
194
|
static void ExportParsedData(const char *fileName, int format); // Export parsed data in desired format
|
|
145
195
|
|
|
146
|
-
|
|
196
|
+
//----------------------------------------------------------------------------------
|
|
147
197
|
// Program main entry point
|
|
148
|
-
|
|
198
|
+
//----------------------------------------------------------------------------------
|
|
149
199
|
int main(int argc, char* argv[])
|
|
150
200
|
{
|
|
151
201
|
if (argc > 1) ProcessCommandLine(argc, argv);
|
|
152
202
|
|
|
153
203
|
if (inFileName[0] == '\0') MemoryCopy(inFileName, "../src/raylib.h\0", 16);
|
|
204
|
+
if (outFileName[0] == '\0') MemoryCopy(outFileName, "raylib_api.txt\0", 15);
|
|
205
|
+
if (apiDefine[0] == '\0') MemoryCopy(apiDefine, "RLAPI\0", 6);
|
|
154
206
|
|
|
155
207
|
int length = 0;
|
|
156
208
|
char *buffer = LoadFileText(inFileName, &length);
|
|
@@ -160,77 +212,101 @@ int main(int argc, char* argv[])
|
|
|
160
212
|
int linesCount = 0;
|
|
161
213
|
char **lines = GetTextLines(buffer, length, &linesCount);
|
|
162
214
|
|
|
163
|
-
//
|
|
164
|
-
|
|
215
|
+
// Truncate lines
|
|
216
|
+
if (truncAfter[0] != '\0')
|
|
217
|
+
{
|
|
218
|
+
int newCount = -1;
|
|
219
|
+
for (int i = 0; i < linesCount; i++)
|
|
220
|
+
{
|
|
221
|
+
if (newCount > -1) free(lines[i]);
|
|
222
|
+
else if (TextFindIndex(lines[i], truncAfter) > -1) newCount = i;
|
|
223
|
+
}
|
|
224
|
+
if (newCount > -1) linesCount = newCount;
|
|
225
|
+
printf("Number of truncated text lines: %i\n", linesCount);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Defines line indices
|
|
229
|
+
int *defineLines = (int *)malloc(MAX_DEFINES_TO_PARSE*sizeof(int));
|
|
165
230
|
|
|
166
|
-
// Structs
|
|
167
|
-
|
|
168
|
-
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char));
|
|
231
|
+
// Structs line indices
|
|
232
|
+
int *structLines = (int *)malloc(MAX_STRUCTS_TO_PARSE*sizeof(int));
|
|
169
233
|
|
|
170
|
-
//
|
|
234
|
+
// Aliases line indices
|
|
235
|
+
int *aliasLines = (int *)malloc(MAX_ALIASES_TO_PARSE*sizeof(int));
|
|
236
|
+
|
|
237
|
+
// Enums line indices
|
|
171
238
|
int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int));
|
|
172
239
|
|
|
240
|
+
// Callbacks line indices
|
|
241
|
+
int *callbackLines = (int *)malloc(MAX_CALLBACKS_TO_PARSE*sizeof(int));
|
|
242
|
+
|
|
243
|
+
// Function line indices
|
|
244
|
+
int *funcLines = (int *)malloc(MAX_FUNCS_TO_PARSE*sizeof(int));
|
|
245
|
+
|
|
173
246
|
// Prepare required lines for parsing
|
|
174
|
-
|
|
247
|
+
//----------------------------------------------------------------------------------
|
|
175
248
|
|
|
176
|
-
// Read
|
|
249
|
+
// Read define lines
|
|
177
250
|
for (int i = 0; i < linesCount; i++)
|
|
178
251
|
{
|
|
179
|
-
|
|
180
|
-
|
|
252
|
+
int j = 0;
|
|
253
|
+
while ((lines[i][j] == ' ') || (lines[i][j] == '\t')) j++; // skip spaces and tabs in the begining
|
|
254
|
+
// Read define line
|
|
255
|
+
if (IsTextEqual(lines[i]+j, "#define ", 8))
|
|
181
256
|
{
|
|
182
|
-
// Keep
|
|
183
|
-
|
|
184
|
-
|
|
257
|
+
// Keep the line position in the array of lines,
|
|
258
|
+
// so, we can scan that position and following lines
|
|
259
|
+
defineLines[defineCount] = i;
|
|
260
|
+
defineCount++;
|
|
185
261
|
}
|
|
186
262
|
}
|
|
187
263
|
|
|
188
|
-
// Read
|
|
189
|
-
|
|
190
|
-
for (int i = 0; i < length; i++)
|
|
264
|
+
// Read struct lines
|
|
265
|
+
for (int i = 0; i < linesCount; i++)
|
|
191
266
|
{
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
|
|
267
|
+
// Find structs
|
|
268
|
+
// starting with "typedef struct ... {" or "typedef struct ... ; \n struct ... {"
|
|
269
|
+
// ending with "} ... ;"
|
|
270
|
+
// i.e. excluding "typedef struct rAudioBuffer rAudioBuffer;" -> Typedef and forward declaration only
|
|
271
|
+
if (IsTextEqual(lines[i], "typedef struct", 14))
|
|
195
272
|
{
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// WARNING: Typedefs between types: typedef Vector4 Quaternion;
|
|
200
|
-
|
|
201
|
-
for (int c = 0; c < 128; c++)
|
|
273
|
+
bool validStruct = IsTextEqual(lines[i + 1], "struct", 6);
|
|
274
|
+
if (!validStruct)
|
|
202
275
|
{
|
|
203
|
-
|
|
204
|
-
{
|
|
205
|
-
validStruct = true;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
else if (buffer[i + c] == ';')
|
|
276
|
+
for (int c = 0; c < MAX_LINE_LENGTH; c++)
|
|
209
277
|
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
break;
|
|
278
|
+
char v = lines[i][c];
|
|
279
|
+
if (v == '{') validStruct = true;
|
|
280
|
+
if ((v == '{') || (v == ';') || (v == '\0')) break;
|
|
214
281
|
}
|
|
215
282
|
}
|
|
283
|
+
if (!validStruct) continue;
|
|
284
|
+
structLines[structCount] = i;
|
|
285
|
+
while (lines[i][0] != '}') i++;
|
|
286
|
+
while (lines[i][0] != '\0') i++;
|
|
287
|
+
structCount++;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
216
290
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
while (buffer[i + j] != '\n')
|
|
226
|
-
{
|
|
227
|
-
structLines[structCount][j] = buffer[i + j];
|
|
228
|
-
j++;
|
|
229
|
-
}
|
|
291
|
+
// Read alias lines
|
|
292
|
+
for (int i = 0; i < linesCount; i++)
|
|
293
|
+
{
|
|
294
|
+
// Find aliases (lines with "typedef ... ...;")
|
|
295
|
+
if (IsTextEqual(lines[i], "typedef", 7))
|
|
296
|
+
{
|
|
297
|
+
int spaceCount = 0;
|
|
298
|
+
bool validAlias = false;
|
|
230
299
|
|
|
231
|
-
|
|
232
|
-
|
|
300
|
+
for (int c = 0; c < MAX_LINE_LENGTH; c++)
|
|
301
|
+
{
|
|
302
|
+
char v = lines[i][c];
|
|
303
|
+
if (v == ' ') spaceCount++;
|
|
304
|
+
if ((v == ';') && (spaceCount == 2)) validAlias = true;
|
|
305
|
+
if ((v == ';') || (v == '(') || (v == '\0')) break;
|
|
233
306
|
}
|
|
307
|
+
if (!validAlias) continue;
|
|
308
|
+
aliasLines[aliasCount] = i;
|
|
309
|
+
aliasCount++;
|
|
234
310
|
}
|
|
235
311
|
}
|
|
236
312
|
|
|
@@ -238,7 +314,7 @@ int main(int argc, char* argv[])
|
|
|
238
314
|
for (int i = 0; i < linesCount; i++)
|
|
239
315
|
{
|
|
240
316
|
// Read enum line
|
|
241
|
-
if (IsTextEqual(lines[i], "typedef enum {", 14))
|
|
317
|
+
if (IsTextEqual(lines[i], "typedef enum {", 14) && (lines[i][TextLength(lines[i])-1] != ';')) // ignore inline enums
|
|
242
318
|
{
|
|
243
319
|
// Keep the line position in the array of lines,
|
|
244
320
|
// so, we can scan that position and following lines
|
|
@@ -247,56 +323,313 @@ int main(int argc, char* argv[])
|
|
|
247
323
|
}
|
|
248
324
|
}
|
|
249
325
|
|
|
250
|
-
//
|
|
326
|
+
// Read callback lines
|
|
327
|
+
for (int i = 0; i < linesCount; i++)
|
|
328
|
+
{
|
|
329
|
+
// Find callbacks (lines with "typedef ... (* ... )( ... );")
|
|
330
|
+
if (IsTextEqual(lines[i], "typedef", 7))
|
|
331
|
+
{
|
|
332
|
+
bool hasBeginning = false;
|
|
333
|
+
bool hasMiddle = false;
|
|
334
|
+
bool hasEnd = false;
|
|
335
|
+
|
|
336
|
+
for (int c = 0; c < MAX_LINE_LENGTH; c++)
|
|
337
|
+
{
|
|
338
|
+
if ((lines[i][c] == '(') && (lines[i][c + 1] == '*')) hasBeginning = true;
|
|
339
|
+
if ((lines[i][c] == ')') && (lines[i][c + 1] == '(')) hasMiddle = true;
|
|
340
|
+
if ((lines[i][c] == ')') && (lines[i][c + 1] == ';')) hasEnd = true;
|
|
341
|
+
if (hasEnd) break;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (hasBeginning && hasMiddle && hasEnd)
|
|
345
|
+
{
|
|
346
|
+
callbackLines[callbackCount] = i;
|
|
347
|
+
callbackCount++;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Read function lines
|
|
353
|
+
for (int i = 0; i < linesCount; i++)
|
|
354
|
+
{
|
|
355
|
+
// Read function line (starting with `define`, i.e. for raylib.h "RLAPI")
|
|
356
|
+
if (IsTextEqual(lines[i], apiDefine, TextLength(apiDefine)))
|
|
357
|
+
{
|
|
358
|
+
funcLines[funcCount] = i;
|
|
359
|
+
funcCount++;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// At this point we have all raylib defines, structs, aliases, enums, callbacks, functions lines data to start parsing
|
|
251
364
|
|
|
252
365
|
free(buffer); // Unload text buffer
|
|
253
366
|
|
|
254
367
|
// Parsing raylib data
|
|
255
|
-
|
|
368
|
+
//----------------------------------------------------------------------------------
|
|
369
|
+
|
|
370
|
+
// Define info data
|
|
371
|
+
defines = (DefineInfo *)calloc(MAX_DEFINES_TO_PARSE, sizeof(DefineInfo));
|
|
372
|
+
int defineIndex = 0;
|
|
373
|
+
|
|
374
|
+
for (int i = 0; i < defineCount; i++)
|
|
375
|
+
{
|
|
376
|
+
char *linePtr = lines[defineLines[i]];
|
|
377
|
+
int j = 0;
|
|
378
|
+
|
|
379
|
+
while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs in the begining
|
|
380
|
+
j += 8; // Skip "#define "
|
|
381
|
+
while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after "#define "
|
|
382
|
+
|
|
383
|
+
// Extract name
|
|
384
|
+
int defineNameStart = j;
|
|
385
|
+
int openBraces = 0;
|
|
386
|
+
while (linePtr[j] != '\0')
|
|
387
|
+
{
|
|
388
|
+
if (((linePtr[j] == ' ') || (linePtr[j] == '\t')) && (openBraces == 0)) break;
|
|
389
|
+
if (linePtr[j] == '(') openBraces++;
|
|
390
|
+
if (linePtr[j] == ')') openBraces--;
|
|
391
|
+
j++;
|
|
392
|
+
}
|
|
393
|
+
int defineNameEnd = j-1;
|
|
394
|
+
|
|
395
|
+
// Skip duplicates
|
|
396
|
+
unsigned int nameLen = defineNameEnd - defineNameStart + 1;
|
|
397
|
+
bool isDuplicate = false;
|
|
398
|
+
for (int k = 0; k < defineIndex; k++)
|
|
399
|
+
{
|
|
400
|
+
if ((nameLen == TextLength(defines[k].name)) && IsTextEqual(defines[k].name, &linePtr[defineNameStart], nameLen))
|
|
401
|
+
{
|
|
402
|
+
isDuplicate = true;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (isDuplicate) continue;
|
|
407
|
+
|
|
408
|
+
MemoryCopy(defines[defineIndex].name, &linePtr[defineNameStart], nameLen);
|
|
409
|
+
|
|
410
|
+
// Determine type
|
|
411
|
+
if (linePtr[defineNameEnd] == ')') defines[defineIndex].type = MACRO;
|
|
412
|
+
|
|
413
|
+
while ((linePtr[j] == ' ') || (linePtr[j] == '\t')) j++; // Skip spaces and tabs after name
|
|
414
|
+
|
|
415
|
+
int defineValueStart = j;
|
|
416
|
+
if ((linePtr[j] == '\0') || (linePtr[j] == '/')) defines[defineIndex].type = GUARD;
|
|
417
|
+
if (linePtr[j] == '"') defines[defineIndex].type = STRING;
|
|
418
|
+
else if (linePtr[j] == '\'') defines[defineIndex].type = CHAR;
|
|
419
|
+
else if (IsTextEqual(linePtr+j, "CLITERAL(Color)", 15)) defines[defineIndex].type = COLOR;
|
|
420
|
+
else if (isdigit(linePtr[j])) // Parsing numbers
|
|
421
|
+
{
|
|
422
|
+
bool isFloat = false, isNumber = true, isHex = false;
|
|
423
|
+
while ((linePtr[j] != ' ') && (linePtr[j] != '\t') && (linePtr[j] != '\0'))
|
|
424
|
+
{
|
|
425
|
+
char ch = linePtr[j];
|
|
426
|
+
if (ch == '.') isFloat = true;
|
|
427
|
+
if (ch == 'x') isHex = true;
|
|
428
|
+
if (!(isdigit(ch) ||
|
|
429
|
+
((ch >= 'a') && (ch <= 'f')) ||
|
|
430
|
+
((ch >= 'A') && (ch <= 'F')) ||
|
|
431
|
+
(ch == 'x') ||
|
|
432
|
+
(ch == 'L') ||
|
|
433
|
+
(ch == '.') ||
|
|
434
|
+
(ch == '+') ||
|
|
435
|
+
(ch == '-'))) isNumber = false;
|
|
436
|
+
j++;
|
|
437
|
+
}
|
|
438
|
+
if (isNumber)
|
|
439
|
+
{
|
|
440
|
+
if (isFloat)
|
|
441
|
+
{
|
|
442
|
+
defines[defineIndex].type = linePtr[j-1] == 'f' ? FLOAT : DOUBLE;
|
|
443
|
+
}
|
|
444
|
+
else
|
|
445
|
+
{
|
|
446
|
+
defines[defineIndex].type = linePtr[j-1] == 'L' ? LONG : INT;
|
|
447
|
+
defines[defineIndex].isHex = isHex;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Extracting value
|
|
453
|
+
while ((linePtr[j] != '\\') && (linePtr[j] != '\0') && !((linePtr[j] == '/') && (linePtr[j+1] == '/'))) j++;
|
|
454
|
+
int defineValueEnd = j-1;
|
|
455
|
+
while ((linePtr[defineValueEnd] == ' ') || (linePtr[defineValueEnd] == '\t')) defineValueEnd--; // Remove trailing spaces and tabs
|
|
456
|
+
if ((defines[defineIndex].type == LONG) || (defines[defineIndex].type == FLOAT)) defineValueEnd--; // Remove number postfix
|
|
457
|
+
int valueLen = defineValueEnd - defineValueStart + 1;
|
|
458
|
+
if (valueLen > 255) valueLen = 255;
|
|
459
|
+
|
|
460
|
+
if (valueLen > 0) MemoryCopy(defines[defineIndex].value, &linePtr[defineValueStart], valueLen);
|
|
461
|
+
|
|
462
|
+
// Extracting description
|
|
463
|
+
if ((linePtr[j] == '/') && linePtr[j + 1] == '/')
|
|
464
|
+
{
|
|
465
|
+
j += 2;
|
|
466
|
+
while (linePtr[j] == ' ') j++;
|
|
467
|
+
int commentStart = j;
|
|
468
|
+
while ((linePtr[j] != '\\') && (linePtr[j] != '\0')) j++;
|
|
469
|
+
int commentEnd = j-1;
|
|
470
|
+
int commentLen = commentEnd - commentStart + 1;
|
|
471
|
+
if (commentLen > 127) commentLen = 127;
|
|
472
|
+
|
|
473
|
+
MemoryCopy(defines[defineIndex].desc, &linePtr[commentStart], commentLen);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Parse defines of type UNKNOWN to find calculated numbers
|
|
477
|
+
if (defines[defineIndex].type == UNKNOWN)
|
|
478
|
+
{
|
|
479
|
+
int largestType = UNKNOWN;
|
|
480
|
+
bool isMath = true;
|
|
481
|
+
char *valuePtr = defines[defineIndex].value;
|
|
482
|
+
|
|
483
|
+
for (unsigned int c = 0; c < TextLength(valuePtr); c++)
|
|
484
|
+
{
|
|
485
|
+
char ch = valuePtr[c];
|
|
486
|
+
|
|
487
|
+
// Skip operators and whitespace
|
|
488
|
+
if ((ch == '(') ||
|
|
489
|
+
(ch == ')') ||
|
|
490
|
+
(ch == '+') ||
|
|
491
|
+
(ch == '-') ||
|
|
492
|
+
(ch == '*') ||
|
|
493
|
+
(ch == '/') ||
|
|
494
|
+
(ch == ' ') ||
|
|
495
|
+
(ch == '\t')) continue;
|
|
496
|
+
|
|
497
|
+
// Read number operand
|
|
498
|
+
else if (isdigit(ch))
|
|
499
|
+
{
|
|
500
|
+
bool isNumber = true, isFloat = false;
|
|
501
|
+
while (!((ch == '(') ||
|
|
502
|
+
(ch == ')') ||
|
|
503
|
+
(ch == '*') ||
|
|
504
|
+
(ch == '/') ||
|
|
505
|
+
(ch == ' ') ||
|
|
506
|
+
(ch == '\t') ||
|
|
507
|
+
(ch == '\0')))
|
|
508
|
+
{
|
|
509
|
+
if (ch == '.') isFloat = true;
|
|
510
|
+
if (!(isdigit(ch) ||
|
|
511
|
+
((ch >= 'a') && (ch <= 'f')) ||
|
|
512
|
+
((ch >= 'A') && (ch <= 'F')) ||
|
|
513
|
+
(ch == 'x') ||
|
|
514
|
+
(ch == 'L') ||
|
|
515
|
+
(ch == '.') ||
|
|
516
|
+
(ch == '+') ||
|
|
517
|
+
(ch == '-')))
|
|
518
|
+
{
|
|
519
|
+
isNumber = false;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
c++;
|
|
523
|
+
ch = valuePtr[c];
|
|
524
|
+
}
|
|
525
|
+
if (isNumber)
|
|
526
|
+
{
|
|
527
|
+
// Found a valid number -> update largestType
|
|
528
|
+
int numberType;
|
|
529
|
+
if (isFloat) numberType = valuePtr[c - 1] == 'f' ? FLOAT_MATH : DOUBLE_MATH;
|
|
530
|
+
else numberType = valuePtr[c - 1] == 'L' ? LONG_MATH : INT_MATH;
|
|
531
|
+
|
|
532
|
+
if (numberType > largestType) largestType = numberType;
|
|
533
|
+
}
|
|
534
|
+
else
|
|
535
|
+
{
|
|
536
|
+
isMath = false;
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
else // Read string operand
|
|
541
|
+
{
|
|
542
|
+
int operandStart = c;
|
|
543
|
+
while (!((ch == '\0') ||
|
|
544
|
+
(ch == ' ') ||
|
|
545
|
+
(ch == '(') ||
|
|
546
|
+
(ch == ')') ||
|
|
547
|
+
(ch == '+') ||
|
|
548
|
+
(ch == '-') ||
|
|
549
|
+
(ch == '*') ||
|
|
550
|
+
(ch == '/')))
|
|
551
|
+
{
|
|
552
|
+
c++;
|
|
553
|
+
ch = valuePtr[c];
|
|
554
|
+
}
|
|
555
|
+
int operandEnd = c;
|
|
556
|
+
int operandLength = operandEnd - operandStart;
|
|
557
|
+
|
|
558
|
+
// Search previous defines for operand
|
|
559
|
+
bool foundOperand = false;
|
|
560
|
+
for (int previousDefineIndex = 0; previousDefineIndex < defineIndex; previousDefineIndex++)
|
|
561
|
+
{
|
|
562
|
+
if (IsTextEqual(defines[previousDefineIndex].name, &valuePtr[operandStart], operandLength))
|
|
563
|
+
{
|
|
564
|
+
if ((defines[previousDefineIndex].type >= INT) && (defines[previousDefineIndex].type <= DOUBLE_MATH))
|
|
565
|
+
{
|
|
566
|
+
// Found operand and it's a number -> update largestType
|
|
567
|
+
if (defines[previousDefineIndex].type > largestType) largestType = defines[previousDefineIndex].type;
|
|
568
|
+
foundOperand = true;
|
|
569
|
+
}
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (!foundOperand)
|
|
574
|
+
{
|
|
575
|
+
isMath = false;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (isMath)
|
|
582
|
+
{
|
|
583
|
+
// Define is a calculated number -> update type
|
|
584
|
+
if (largestType == INT) largestType = INT_MATH;
|
|
585
|
+
else if (largestType == LONG) largestType = LONG_MATH;
|
|
586
|
+
else if (largestType == FLOAT) largestType = FLOAT_MATH;
|
|
587
|
+
else if (largestType == DOUBLE) largestType = DOUBLE_MATH;
|
|
588
|
+
defines[defineIndex].type = largestType;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
defineIndex++;
|
|
593
|
+
}
|
|
594
|
+
defineCount = defineIndex;
|
|
595
|
+
free(defineLines);
|
|
256
596
|
|
|
257
597
|
// Structs info data
|
|
258
598
|
structs = (StructInfo *)calloc(MAX_STRUCTS_TO_PARSE, sizeof(StructInfo));
|
|
259
599
|
|
|
260
600
|
for (int i = 0; i < structCount; i++)
|
|
261
601
|
{
|
|
262
|
-
|
|
602
|
+
char **linesPtr = &lines[structLines[i]];
|
|
603
|
+
|
|
604
|
+
// Parse struct description
|
|
605
|
+
GetDescription(linesPtr[-1], structs[i].desc);
|
|
263
606
|
|
|
264
607
|
// Get struct name: typedef struct name {
|
|
265
|
-
|
|
608
|
+
const int TDS_LEN = 15; // length of "typedef struct "
|
|
609
|
+
for (int c = TDS_LEN; c < 64 + TDS_LEN; c++)
|
|
266
610
|
{
|
|
267
|
-
if (
|
|
611
|
+
if ((linesPtr[0][c] == '{') || (linesPtr[0][c] == ' '))
|
|
268
612
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
MemoryCopy(structs[i].name, &
|
|
613
|
+
int nameLen = c - TDS_LEN;
|
|
614
|
+
while (linesPtr[0][TDS_LEN + nameLen - 1] == ' ') nameLen--;
|
|
615
|
+
MemoryCopy(structs[i].name, &linesPtr[0][TDS_LEN], nameLen);
|
|
272
616
|
break;
|
|
273
617
|
}
|
|
274
618
|
}
|
|
275
619
|
|
|
276
620
|
// Get struct fields and count them -> fields finish with ;
|
|
277
|
-
int
|
|
278
|
-
while (
|
|
621
|
+
int l = 1;
|
|
622
|
+
while (linesPtr[l][0] != '}')
|
|
279
623
|
{
|
|
280
624
|
// WARNING: Some structs have empty spaces and comments -> OK, processed
|
|
281
|
-
|
|
282
|
-
int fieldStart = 0;
|
|
283
|
-
if ((structLines[i][structLineOffset + j] != ' ') && (structLines[i][structLineOffset + j] != '\n')) fieldStart = structLineOffset + j;
|
|
284
|
-
|
|
285
|
-
if (fieldStart != 0)
|
|
625
|
+
if ((linesPtr[l][0] != ' ') && (linesPtr[l][0] != '\0'))
|
|
286
626
|
{
|
|
287
627
|
// Scan one field line
|
|
288
|
-
|
|
628
|
+
char *fieldLine = linesPtr[l];
|
|
289
629
|
int fieldEndPos = 0;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
while (structLines[i][structLineOffset + j] != '\n')
|
|
293
|
-
{
|
|
294
|
-
if (structLines[i][structLineOffset + j] == ';') fieldEndPos = c;
|
|
295
|
-
fieldLine[c] = structLines[i][structLineOffset + j];
|
|
296
|
-
c++; j++;
|
|
297
|
-
}
|
|
630
|
+
while (fieldLine[fieldEndPos] != ';') fieldEndPos++;
|
|
298
631
|
|
|
299
|
-
if (fieldLine[0] != '/')
|
|
632
|
+
if ((fieldLine[0] != '/') && !IsTextEqual(fieldLine, "struct", 6)) // Field line is not a comment and not a struct declaration
|
|
300
633
|
{
|
|
301
634
|
//printf("Struct field: %s_\n", fieldLine); // OK!
|
|
302
635
|
|
|
@@ -304,35 +637,172 @@ int main(int argc, char* argv[])
|
|
|
304
637
|
GetDataTypeAndName(fieldLine, fieldEndPos, structs[i].fieldType[structs[i].fieldCount], structs[i].fieldName[structs[i].fieldCount]);
|
|
305
638
|
|
|
306
639
|
// Get the field description
|
|
307
|
-
|
|
308
|
-
int descStart = fieldEndPos;
|
|
309
|
-
while ((fieldLine[descStart] != '/') && (fieldLine[descStart] != '\0')) descStart++;
|
|
640
|
+
GetDescription(&fieldLine[fieldEndPos], structs[i].fieldDesc[structs[i].fieldCount]);
|
|
310
641
|
|
|
311
|
-
|
|
312
|
-
|
|
642
|
+
structs[i].fieldCount++;
|
|
643
|
+
|
|
644
|
+
// Split field names containing multiple fields (like Matrix)
|
|
645
|
+
int additionalFields = 0;
|
|
646
|
+
int originalIndex = structs[i].fieldCount - 1;
|
|
647
|
+
for (unsigned int c = 0; c < TextLength(structs[i].fieldName[originalIndex]); c++)
|
|
648
|
+
{
|
|
649
|
+
if (structs[i].fieldName[originalIndex][c] == ',') additionalFields++;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (additionalFields > 0)
|
|
313
653
|
{
|
|
314
|
-
|
|
315
|
-
|
|
654
|
+
int originalLength = -1;
|
|
655
|
+
int lastStart;
|
|
656
|
+
for (unsigned int c = 0; c < TextLength(structs[i].fieldName[originalIndex]) + 1; c++)
|
|
657
|
+
{
|
|
658
|
+
char v = structs[i].fieldName[originalIndex][c];
|
|
659
|
+
bool isEndOfString = (v == '\0');
|
|
660
|
+
if ((v == ',') || isEndOfString)
|
|
661
|
+
{
|
|
662
|
+
if (originalLength == -1)
|
|
663
|
+
{
|
|
664
|
+
// Save length of original field name
|
|
665
|
+
// Don't truncate yet, still needed for copying
|
|
666
|
+
originalLength = c;
|
|
667
|
+
}
|
|
668
|
+
else
|
|
669
|
+
{
|
|
670
|
+
// Copy field data from original field
|
|
671
|
+
int nameLength = c - lastStart;
|
|
672
|
+
MemoryCopy(structs[i].fieldName[structs[i].fieldCount], &structs[i].fieldName[originalIndex][lastStart], nameLength);
|
|
673
|
+
MemoryCopy(structs[i].fieldType[structs[i].fieldCount], &structs[i].fieldType[originalIndex][0], TextLength(structs[i].fieldType[originalIndex]));
|
|
674
|
+
MemoryCopy(structs[i].fieldDesc[structs[i].fieldCount], &structs[i].fieldDesc[originalIndex][0], TextLength(structs[i].fieldDesc[originalIndex]));
|
|
675
|
+
structs[i].fieldCount++;
|
|
676
|
+
}
|
|
677
|
+
if (!isEndOfString)
|
|
678
|
+
{
|
|
679
|
+
// Skip comma and spaces
|
|
680
|
+
c++;
|
|
681
|
+
while (structs[i].fieldName[originalIndex][c] == ' ') c++;
|
|
682
|
+
|
|
683
|
+
// Save position for next field
|
|
684
|
+
lastStart = c;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// Set length of original field to truncate the first field name
|
|
689
|
+
structs[i].fieldName[originalIndex][originalLength] = '\0';
|
|
316
690
|
}
|
|
317
691
|
|
|
318
|
-
|
|
692
|
+
// Split field types containing multiple fields (like MemNode)
|
|
693
|
+
additionalFields = 0;
|
|
694
|
+
originalIndex = structs[i].fieldCount - 1;
|
|
695
|
+
for (unsigned int c = 0; c < TextLength(structs[i].fieldType[originalIndex]); c++)
|
|
696
|
+
{
|
|
697
|
+
if (structs[i].fieldType[originalIndex][c] == ',') additionalFields++;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (additionalFields > 0)
|
|
701
|
+
{
|
|
702
|
+
// Copy original name to last additional field
|
|
703
|
+
structs[i].fieldCount += additionalFields;
|
|
704
|
+
MemoryCopy(structs[i].fieldName[originalIndex + additionalFields], &structs[i].fieldName[originalIndex][0], TextLength(structs[i].fieldName[originalIndex]));
|
|
705
|
+
|
|
706
|
+
// Copy names from type to additional fields
|
|
707
|
+
int fieldsRemaining = additionalFields;
|
|
708
|
+
int nameStart = -1;
|
|
709
|
+
int nameEnd = -1;
|
|
710
|
+
for (int k = TextLength(structs[i].fieldType[originalIndex]); k > 0; k--)
|
|
711
|
+
{
|
|
712
|
+
char v = structs[i].fieldType[originalIndex][k];
|
|
713
|
+
if ((v == '*') || (v == ' ') || (v == ','))
|
|
714
|
+
{
|
|
715
|
+
if (nameEnd != -1) {
|
|
716
|
+
// Don't copy to last additional field
|
|
717
|
+
if (fieldsRemaining != additionalFields)
|
|
718
|
+
{
|
|
719
|
+
nameStart = k + 1;
|
|
720
|
+
MemoryCopy(structs[i].fieldName[originalIndex + fieldsRemaining], &structs[i].fieldType[originalIndex][nameStart], nameEnd - nameStart + 1);
|
|
721
|
+
}
|
|
722
|
+
nameEnd = -1;
|
|
723
|
+
fieldsRemaining--;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
else if (nameEnd == -1) nameEnd = k;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// Truncate original field type
|
|
730
|
+
int fieldTypeLength = nameStart;
|
|
731
|
+
structs[i].fieldType[originalIndex][fieldTypeLength] = '\0';
|
|
732
|
+
|
|
733
|
+
// Set field type and description of additional fields
|
|
734
|
+
for (int j = 1; j <= additionalFields; j++)
|
|
735
|
+
{
|
|
736
|
+
MemoryCopy(structs[i].fieldType[originalIndex + j], &structs[i].fieldType[originalIndex][0], fieldTypeLength);
|
|
737
|
+
MemoryCopy(structs[i].fieldDesc[originalIndex + j], &structs[i].fieldDesc[originalIndex][0], TextLength(structs[i].fieldDesc[originalIndex]));
|
|
738
|
+
}
|
|
739
|
+
}
|
|
319
740
|
}
|
|
320
741
|
}
|
|
321
742
|
|
|
322
|
-
|
|
743
|
+
l++;
|
|
323
744
|
}
|
|
324
745
|
|
|
746
|
+
// Move array sizes from name to type
|
|
747
|
+
for (int j = 0; j < structs[i].fieldCount; j++)
|
|
748
|
+
{
|
|
749
|
+
MoveArraySize(structs[i].fieldName[j], structs[i].fieldType[j]);
|
|
750
|
+
}
|
|
325
751
|
}
|
|
326
|
-
|
|
327
|
-
for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) free(structLines[i]);
|
|
328
752
|
free(structLines);
|
|
329
753
|
|
|
754
|
+
// Alias info data
|
|
755
|
+
aliases = (AliasInfo *)calloc(MAX_ALIASES_TO_PARSE, sizeof(AliasInfo));
|
|
756
|
+
|
|
757
|
+
for (int i = 0; i < aliasCount; i++)
|
|
758
|
+
{
|
|
759
|
+
// Description from previous line
|
|
760
|
+
GetDescription(lines[aliasLines[i] - 1], aliases[i].desc);
|
|
761
|
+
|
|
762
|
+
char *linePtr = lines[aliasLines[i]];
|
|
763
|
+
|
|
764
|
+
// Skip "typedef "
|
|
765
|
+
int c = 8;
|
|
766
|
+
|
|
767
|
+
// Type
|
|
768
|
+
int typeStart = c;
|
|
769
|
+
while(linePtr[c] != ' ') c++;
|
|
770
|
+
int typeLen = c - typeStart;
|
|
771
|
+
MemoryCopy(aliases[i].type, &linePtr[typeStart], typeLen);
|
|
772
|
+
|
|
773
|
+
// Skip space
|
|
774
|
+
c++;
|
|
775
|
+
|
|
776
|
+
// Name
|
|
777
|
+
int nameStart = c;
|
|
778
|
+
while(linePtr[c] != ';') c++;
|
|
779
|
+
int nameLen = c - nameStart;
|
|
780
|
+
MemoryCopy(aliases[i].name, &linePtr[nameStart], nameLen);
|
|
781
|
+
|
|
782
|
+
// Description
|
|
783
|
+
GetDescription(&linePtr[c], aliases[i].desc);
|
|
784
|
+
}
|
|
785
|
+
free(aliasLines);
|
|
786
|
+
|
|
330
787
|
// Enum info data
|
|
331
788
|
enums = (EnumInfo *)calloc(MAX_ENUMS_TO_PARSE, sizeof(EnumInfo));
|
|
332
789
|
|
|
333
790
|
for (int i = 0; i < enumCount; i++)
|
|
334
791
|
{
|
|
335
|
-
|
|
792
|
+
|
|
793
|
+
// Parse enum description
|
|
794
|
+
// NOTE: This is not necessarily from the line immediately before,
|
|
795
|
+
// some of the enums have extra lines between the "description"
|
|
796
|
+
// and the typedef enum
|
|
797
|
+
for (int j = enumLines[i] - 1; j > 0; j--)
|
|
798
|
+
{
|
|
799
|
+
char *linePtr = lines[j];
|
|
800
|
+
if ((linePtr[0] != '/') || (linePtr[2] != ' '))
|
|
801
|
+
{
|
|
802
|
+
GetDescription(&lines[j + 1][0], enums[i].desc);
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
336
806
|
|
|
337
807
|
for (int j = 1; j < MAX_ENUM_VALUES*2; j++) // Maximum number of lines following enum first line
|
|
338
808
|
{
|
|
@@ -352,7 +822,11 @@ int main(int argc, char* argv[])
|
|
|
352
822
|
while ((linePtr[c] != ',') &&
|
|
353
823
|
(linePtr[c] != ' ') &&
|
|
354
824
|
(linePtr[c] != '=') &&
|
|
355
|
-
(linePtr[c] != '\0'))
|
|
825
|
+
(linePtr[c] != '\0'))
|
|
826
|
+
{
|
|
827
|
+
enums[i].valueName[enums[i].valueCount][c] = linePtr[c];
|
|
828
|
+
c++;
|
|
829
|
+
}
|
|
356
830
|
|
|
357
831
|
// After the name we can have:
|
|
358
832
|
// '=' -> value is provided
|
|
@@ -367,9 +841,13 @@ int main(int argc, char* argv[])
|
|
|
367
841
|
// '=' -> value is provided
|
|
368
842
|
// ' ' -> value is equal to previous + 1, there could be a description if not '\0'
|
|
369
843
|
bool foundValue = false;
|
|
370
|
-
while (linePtr[c] != '\0')
|
|
844
|
+
while ((linePtr[c] != '\0') && (linePtr[c] != '/'))
|
|
371
845
|
{
|
|
372
|
-
if (linePtr[c] == '=')
|
|
846
|
+
if (linePtr[c] == '=')
|
|
847
|
+
{
|
|
848
|
+
foundValue = true;
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
373
851
|
c++;
|
|
374
852
|
}
|
|
375
853
|
|
|
@@ -377,51 +855,115 @@ int main(int argc, char* argv[])
|
|
|
377
855
|
{
|
|
378
856
|
if (linePtr[c + 1] == ' ') c += 2;
|
|
379
857
|
else c++;
|
|
380
|
-
|
|
858
|
+
|
|
381
859
|
// Parse integer value
|
|
382
860
|
int n = 0;
|
|
383
861
|
char integer[16] = { 0 };
|
|
384
|
-
|
|
862
|
+
|
|
385
863
|
while ((linePtr[c] != ',') && (linePtr[c] != ' ') && (linePtr[c] != '\0'))
|
|
386
864
|
{
|
|
387
865
|
integer[n] = linePtr[c];
|
|
388
866
|
c++; n++;
|
|
389
867
|
}
|
|
390
|
-
|
|
868
|
+
|
|
391
869
|
if (integer[1] == 'x') enums[i].valueInteger[enums[i].valueCount] = (int)strtol(integer, NULL, 16);
|
|
392
870
|
else enums[i].valueInteger[enums[i].valueCount] = atoi(integer);
|
|
393
871
|
}
|
|
394
872
|
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
|
395
|
-
|
|
396
|
-
// TODO: Parse value description if any
|
|
397
873
|
}
|
|
398
874
|
else enums[i].valueInteger[enums[i].valueCount] = (enums[i].valueInteger[enums[i].valueCount - 1] + 1);
|
|
399
875
|
|
|
876
|
+
// Parse value description
|
|
877
|
+
GetDescription(&linePtr[c], enums[i].valueDesc[enums[i].valueCount]);
|
|
878
|
+
|
|
400
879
|
enums[i].valueCount++;
|
|
401
880
|
}
|
|
402
881
|
else if (linePtr[0] == '}')
|
|
403
882
|
{
|
|
404
883
|
// Get enum name from typedef
|
|
405
884
|
int c = 0;
|
|
406
|
-
while (linePtr[2 + c] != ';')
|
|
885
|
+
while (linePtr[2 + c] != ';')
|
|
886
|
+
{
|
|
887
|
+
enums[i].name[c] = linePtr[2 + c];
|
|
888
|
+
c++;
|
|
889
|
+
}
|
|
407
890
|
|
|
408
891
|
break; // Enum ended, break for() loop
|
|
409
892
|
}
|
|
410
893
|
}
|
|
411
894
|
}
|
|
895
|
+
free(enumLines);
|
|
896
|
+
|
|
897
|
+
// Callback info data
|
|
898
|
+
callbacks = (FunctionInfo *)calloc(MAX_CALLBACKS_TO_PARSE, sizeof(FunctionInfo));
|
|
899
|
+
|
|
900
|
+
for (int i = 0; i < callbackCount; i++)
|
|
901
|
+
{
|
|
902
|
+
char *linePtr = lines[callbackLines[i]];
|
|
903
|
+
|
|
904
|
+
// Skip "typedef "
|
|
905
|
+
unsigned int c = 8;
|
|
906
|
+
|
|
907
|
+
// Return type
|
|
908
|
+
int retTypeStart = c;
|
|
909
|
+
while(linePtr[c] != '(') c++;
|
|
910
|
+
int retTypeLen = c - retTypeStart;
|
|
911
|
+
while(linePtr[retTypeStart + retTypeLen - 1] == ' ') retTypeLen--;
|
|
912
|
+
MemoryCopy(callbacks[i].retType, &linePtr[retTypeStart], retTypeLen);
|
|
913
|
+
|
|
914
|
+
// Skip "(*"
|
|
915
|
+
c += 2;
|
|
916
|
+
|
|
917
|
+
// Name
|
|
918
|
+
int nameStart = c;
|
|
919
|
+
while(linePtr[c] != ')') c++;
|
|
920
|
+
int nameLen = c - nameStart;
|
|
921
|
+
MemoryCopy(callbacks[i].name, &linePtr[nameStart], nameLen);
|
|
922
|
+
|
|
923
|
+
// Skip ")("
|
|
924
|
+
c += 2;
|
|
925
|
+
|
|
926
|
+
// Params
|
|
927
|
+
int paramStart = c;
|
|
928
|
+
for (; c < MAX_LINE_LENGTH; c++)
|
|
929
|
+
{
|
|
930
|
+
if ((linePtr[c] == ',') || (linePtr[c] == ')'))
|
|
931
|
+
{
|
|
932
|
+
// Get parameter type + name, extract info
|
|
933
|
+
int paramLen = c - paramStart;
|
|
934
|
+
GetDataTypeAndName(&linePtr[paramStart], paramLen, callbacks[i].paramType[callbacks[i].paramCount], callbacks[i].paramName[callbacks[i].paramCount]);
|
|
935
|
+
callbacks[i].paramCount++;
|
|
936
|
+
paramStart = c + 1;
|
|
937
|
+
while(linePtr[paramStart] == ' ') paramStart++;
|
|
938
|
+
}
|
|
939
|
+
if (linePtr[c] == ')') break;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// Description
|
|
943
|
+
GetDescription(&linePtr[c], callbacks[i].desc);
|
|
944
|
+
|
|
945
|
+
// Move array sizes from name to type
|
|
946
|
+
for (int j = 0; j < callbacks[i].paramCount; j++)
|
|
947
|
+
{
|
|
948
|
+
MoveArraySize(callbacks[i].paramName[j], callbacks[i].paramType[j]);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
free(callbackLines);
|
|
412
952
|
|
|
413
953
|
// Functions info data
|
|
414
954
|
funcs = (FunctionInfo *)calloc(MAX_FUNCS_TO_PARSE, sizeof(FunctionInfo));
|
|
415
955
|
|
|
416
956
|
for (int i = 0; i < funcCount; i++)
|
|
417
957
|
{
|
|
958
|
+
char *linePtr = lines[funcLines[i]];
|
|
959
|
+
|
|
418
960
|
int funcParamsStart = 0;
|
|
419
961
|
int funcEnd = 0;
|
|
420
962
|
|
|
421
963
|
// Get return type and function name from func line
|
|
422
|
-
for (int c = 0; (c < MAX_LINE_LENGTH) && (
|
|
964
|
+
for (int c = 0; (c < MAX_LINE_LENGTH) && (linePtr[c] != '\n'); c++)
|
|
423
965
|
{
|
|
424
|
-
if (
|
|
966
|
+
if (linePtr[c] == '(') // Starts function parameters
|
|
425
967
|
{
|
|
426
968
|
funcParamsStart = c + 1;
|
|
427
969
|
|
|
@@ -429,7 +971,7 @@ int main(int argc, char* argv[])
|
|
|
429
971
|
char funcRetTypeName[128] = { 0 };
|
|
430
972
|
int dc = TextLength(apiDefine) + 1;
|
|
431
973
|
int funcRetTypeNameLen = c - dc; // Substract `define` ("RLAPI " for raylib.h)
|
|
432
|
-
MemoryCopy(funcRetTypeName, &
|
|
974
|
+
MemoryCopy(funcRetTypeName, &linePtr[dc], funcRetTypeNameLen);
|
|
433
975
|
|
|
434
976
|
GetDataTypeAndName(funcRetTypeName, funcRetTypeNameLen, funcs[i].retType, funcs[i].name);
|
|
435
977
|
break;
|
|
@@ -439,30 +981,30 @@ int main(int argc, char* argv[])
|
|
|
439
981
|
// Get parameters from func line
|
|
440
982
|
for (int c = funcParamsStart; c < MAX_LINE_LENGTH; c++)
|
|
441
983
|
{
|
|
442
|
-
if (
|
|
984
|
+
if (linePtr[c] == ',') // Starts function parameters
|
|
443
985
|
{
|
|
444
986
|
// Get parameter type + name, extract info
|
|
445
987
|
char funcParamTypeName[128] = { 0 };
|
|
446
988
|
int funcParamTypeNameLen = c - funcParamsStart;
|
|
447
|
-
MemoryCopy(funcParamTypeName, &
|
|
989
|
+
MemoryCopy(funcParamTypeName, &linePtr[funcParamsStart], funcParamTypeNameLen);
|
|
448
990
|
|
|
449
991
|
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
|
450
992
|
|
|
451
993
|
funcParamsStart = c + 1;
|
|
452
|
-
if (
|
|
994
|
+
if (linePtr[c + 1] == ' ') funcParamsStart += 1;
|
|
453
995
|
funcs[i].paramCount++; // Move to next parameter
|
|
454
996
|
}
|
|
455
|
-
else if (
|
|
997
|
+
else if (linePtr[c] == ')')
|
|
456
998
|
{
|
|
457
999
|
funcEnd = c + 2;
|
|
458
1000
|
|
|
459
1001
|
// Check if previous word is void
|
|
460
|
-
if ((
|
|
1002
|
+
if ((linePtr[c - 4] == 'v') && (linePtr[c - 3] == 'o') && (linePtr[c - 2] == 'i') && (linePtr[c - 1] == 'd')) break;
|
|
461
1003
|
|
|
462
1004
|
// Get parameter type + name, extract info
|
|
463
1005
|
char funcParamTypeName[128] = { 0 };
|
|
464
1006
|
int funcParamTypeNameLen = c - funcParamsStart;
|
|
465
|
-
MemoryCopy(funcParamTypeName, &
|
|
1007
|
+
MemoryCopy(funcParamTypeName, &linePtr[funcParamsStart], funcParamTypeNameLen);
|
|
466
1008
|
|
|
467
1009
|
GetDataTypeAndName(funcParamTypeName, funcParamTypeNameLen, funcs[i].paramType[funcs[i].paramCount], funcs[i].paramName[funcs[i].paramCount]);
|
|
468
1010
|
|
|
@@ -472,45 +1014,50 @@ int main(int argc, char* argv[])
|
|
|
472
1014
|
}
|
|
473
1015
|
|
|
474
1016
|
// Get function description
|
|
475
|
-
|
|
1017
|
+
GetDescription(&linePtr[funcEnd], funcs[i].desc);
|
|
1018
|
+
|
|
1019
|
+
// Move array sizes from name to type
|
|
1020
|
+
for (int j = 0; j < funcs[i].paramCount; j++)
|
|
476
1021
|
{
|
|
477
|
-
|
|
478
|
-
{
|
|
479
|
-
MemoryCopy(funcs[i].desc, &funcLines[i][c], 127); // WARNING: Size could be too long for funcLines[i][c]?
|
|
480
|
-
break;
|
|
481
|
-
}
|
|
1022
|
+
MoveArraySize(funcs[i].paramName[j], funcs[i].paramType[j]);
|
|
482
1023
|
}
|
|
483
1024
|
}
|
|
1025
|
+
free(funcLines);
|
|
484
1026
|
|
|
485
1027
|
for (int i = 0; i < linesCount; i++) free(lines[i]);
|
|
486
1028
|
free(lines);
|
|
487
|
-
free(funcLines);
|
|
488
1029
|
|
|
489
1030
|
// At this point, all raylib data has been parsed!
|
|
490
|
-
|
|
491
|
-
//
|
|
492
|
-
//
|
|
493
|
-
//
|
|
494
|
-
|
|
495
|
-
//
|
|
496
|
-
|
|
1031
|
+
//----------------------------------------------------------------------------------
|
|
1032
|
+
// defines[] -> We have all the defines decomposed into pieces for further analysis
|
|
1033
|
+
// structs[] -> We have all the structs decomposed into pieces for further analysis
|
|
1034
|
+
// aliases[] -> We have all the aliases decomposed into pieces for further analysis
|
|
1035
|
+
// enums[] -> We have all the enums decomposed into pieces for further analysis
|
|
1036
|
+
// callbacks[] -> We have all the callbacks decomposed into pieces for further analysis
|
|
1037
|
+
// funcs[] -> We have all the functions decomposed into pieces for further analysis
|
|
497
1038
|
|
|
498
1039
|
printf("\nInput file: %s", inFileName);
|
|
499
1040
|
printf("\nOutput file: %s", outFileName);
|
|
500
1041
|
if (outputFormat == DEFAULT) printf("\nOutput format: DEFAULT\n\n");
|
|
501
1042
|
else if (outputFormat == JSON) printf("\nOutput format: JSON\n\n");
|
|
502
1043
|
else if (outputFormat == XML) printf("\nOutput format: XML\n\n");
|
|
1044
|
+
else if (outputFormat == LUA) printf("\nOutput format: LUA\n\n");
|
|
1045
|
+
else if (outputFormat == CODE) printf("\nOutput format: CODE\n\n");
|
|
503
1046
|
|
|
504
1047
|
ExportParsedData(outFileName, outputFormat);
|
|
505
1048
|
|
|
506
|
-
free(
|
|
1049
|
+
free(defines);
|
|
507
1050
|
free(structs);
|
|
1051
|
+
free(aliases);
|
|
508
1052
|
free(enums);
|
|
1053
|
+
free(callbacks);
|
|
1054
|
+
free(funcs);
|
|
509
1055
|
}
|
|
510
1056
|
|
|
511
1057
|
//----------------------------------------------------------------------------------
|
|
512
1058
|
// Module Functions Definition
|
|
513
1059
|
//----------------------------------------------------------------------------------
|
|
1060
|
+
|
|
514
1061
|
// Show command line usage info
|
|
515
1062
|
static void ShowCommandLineInfo(void)
|
|
516
1063
|
{
|
|
@@ -520,24 +1067,26 @@ static void ShowCommandLineInfo(void)
|
|
|
520
1067
|
printf("// //\n");
|
|
521
1068
|
printf("// more info and bugs-report: github.com/raysan5/raylib/parser //\n");
|
|
522
1069
|
printf("// //\n");
|
|
523
|
-
printf("// Copyright (c) 2021 Ramon Santamaria (@raysan5)
|
|
1070
|
+
printf("// Copyright (c) 2021-2022 Ramon Santamaria (@raysan5) //\n");
|
|
524
1071
|
printf("// //\n");
|
|
525
1072
|
printf("//////////////////////////////////////////////////////////////////////////////////\n\n");
|
|
526
1073
|
|
|
527
1074
|
printf("USAGE:\n\n");
|
|
528
|
-
printf(" > raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]
|
|
1075
|
+
printf(" > raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]\n");
|
|
529
1076
|
|
|
530
1077
|
printf("\nOPTIONS:\n\n");
|
|
531
1078
|
printf(" -h, --help : Show tool version and command line usage help\n\n");
|
|
532
1079
|
printf(" -i, --input <filename.h> : Define input header file to parse.\n");
|
|
533
1080
|
printf(" NOTE: If not specified, defaults to: raylib.h\n\n");
|
|
534
1081
|
printf(" -o, --output <filename.ext> : Define output file and format.\n");
|
|
535
|
-
printf(" Supported extensions: .txt, .json, .xml, .h\n");
|
|
1082
|
+
printf(" Supported extensions: .txt, .json, .xml, .lua, .h\n");
|
|
536
1083
|
printf(" NOTE: If not specified, defaults to: raylib_api.txt\n\n");
|
|
537
1084
|
printf(" -f, --format <type> : Define output format for parser data.\n");
|
|
538
|
-
printf(" Supported types: DEFAULT, JSON, XML\n\n");
|
|
539
|
-
printf(" -d, --define <DEF> : Define functions
|
|
540
|
-
printf(" NOTE: If
|
|
1085
|
+
printf(" Supported types: DEFAULT, JSON, XML, LUA, CODE\n\n");
|
|
1086
|
+
printf(" -d, --define <DEF> : Define functions specifiers (i.e. RLAPI for raylib.h, RMDEF for raymath.h, etc.)\n");
|
|
1087
|
+
printf(" NOTE: If no specifier defined, defaults to: RLAPI\n\n");
|
|
1088
|
+
printf(" -t, --truncate <after> : Define string to truncate input after (i.e. \"RLGL IMPLEMENTATION\" for rlgl.h)\n");
|
|
1089
|
+
printf(" NOTE: If not specified, the full input file is parsed.\n\n");
|
|
541
1090
|
|
|
542
1091
|
printf("\nEXAMPLES:\n\n");
|
|
543
1092
|
printf(" > raylib_parser --input raylib.h --output api.json\n");
|
|
@@ -557,6 +1106,7 @@ static void ProcessCommandLine(int argc, char *argv[])
|
|
|
557
1106
|
{
|
|
558
1107
|
// Show info
|
|
559
1108
|
ShowCommandLineInfo();
|
|
1109
|
+
exit(0);
|
|
560
1110
|
}
|
|
561
1111
|
else if (IsTextEqual(argv[i], "-i", 2) || IsTextEqual(argv[i], "--input", 7))
|
|
562
1112
|
{
|
|
@@ -584,6 +1134,8 @@ static void ProcessCommandLine(int argc, char *argv[])
|
|
|
584
1134
|
if (IsTextEqual(argv[i + 1], "DEFAULT\0", 8)) outputFormat = DEFAULT;
|
|
585
1135
|
else if (IsTextEqual(argv[i + 1], "JSON\0", 5)) outputFormat = JSON;
|
|
586
1136
|
else if (IsTextEqual(argv[i + 1], "XML\0", 4)) outputFormat = XML;
|
|
1137
|
+
else if (IsTextEqual(argv[i + 1], "LUA\0", 4)) outputFormat = LUA;
|
|
1138
|
+
else if (IsTextEqual(argv[i + 1], "CODE\0", 4)) outputFormat = CODE;
|
|
587
1139
|
}
|
|
588
1140
|
else printf("WARNING: No format parameters provided\n");
|
|
589
1141
|
}
|
|
@@ -597,6 +1149,15 @@ static void ProcessCommandLine(int argc, char *argv[])
|
|
|
597
1149
|
}
|
|
598
1150
|
else printf("WARNING: No define key provided\n");
|
|
599
1151
|
}
|
|
1152
|
+
else if (IsTextEqual(argv[i], "-t", 2) || IsTextEqual(argv[i], "--truncate", 10))
|
|
1153
|
+
{
|
|
1154
|
+
if (((i + 1) < argc) && (argv[i + 1][0] != '-'))
|
|
1155
|
+
{
|
|
1156
|
+
MemoryCopy(truncAfter, argv[i + 1], TextLength(argv[i + 1])); // Read truncate marker
|
|
1157
|
+
truncAfter[TextLength(argv[i + 1])] = '\0';
|
|
1158
|
+
i++;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
600
1161
|
}
|
|
601
1162
|
}
|
|
602
1163
|
|
|
@@ -687,7 +1248,7 @@ static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type
|
|
|
687
1248
|
{
|
|
688
1249
|
for (int k = typeNameLen; k > 0; k--)
|
|
689
1250
|
{
|
|
690
|
-
if (typeName[k] == ' ' && typeName[k - 1] != ',')
|
|
1251
|
+
if ((typeName[k] == ' ') && (typeName[k - 1] != ','))
|
|
691
1252
|
{
|
|
692
1253
|
// Function name starts at this point (and ret type finishes at this point)
|
|
693
1254
|
MemoryCopy(type, typeName, k);
|
|
@@ -700,6 +1261,50 @@ static void GetDataTypeAndName(const char *typeName, int typeNameLen, char *type
|
|
|
700
1261
|
MemoryCopy(name, typeName + k + 1, typeNameLen - k - 1);
|
|
701
1262
|
break;
|
|
702
1263
|
}
|
|
1264
|
+
else if ((typeName[k] == '.') && (typeNameLen == 3)) // Handle varargs ...);
|
|
1265
|
+
{
|
|
1266
|
+
MemoryCopy(type, "...", 3);
|
|
1267
|
+
MemoryCopy(name, "args", 4);
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// Get comment from a line, do nothing if no comment in line
|
|
1274
|
+
static void GetDescription(const char *line, char *description)
|
|
1275
|
+
{
|
|
1276
|
+
int c = 0;
|
|
1277
|
+
int descStart = -1;
|
|
1278
|
+
int lastSlash = -2;
|
|
1279
|
+
bool isValid = false;
|
|
1280
|
+
while (line[c] != '\0')
|
|
1281
|
+
{
|
|
1282
|
+
if (isValid && (descStart == -1) && (line[c] != ' ')) descStart = c;
|
|
1283
|
+
else if (line[c] == '/')
|
|
1284
|
+
{
|
|
1285
|
+
if (lastSlash == c - 1) isValid = true;
|
|
1286
|
+
lastSlash = c;
|
|
1287
|
+
}
|
|
1288
|
+
c++;
|
|
1289
|
+
}
|
|
1290
|
+
if (descStart != -1) MemoryCopy(description, &line[descStart], c - descStart);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// Move array size from name to type
|
|
1294
|
+
static void MoveArraySize(char *name, char *type)
|
|
1295
|
+
{
|
|
1296
|
+
int nameLength = TextLength(name);
|
|
1297
|
+
if (name[nameLength - 1] == ']')
|
|
1298
|
+
{
|
|
1299
|
+
for (int k = nameLength; k > 0; k--)
|
|
1300
|
+
{
|
|
1301
|
+
if (name[k] == '[')
|
|
1302
|
+
{
|
|
1303
|
+
int sizeLength = nameLength - k;
|
|
1304
|
+
MemoryCopy(&type[TextLength(type)], &name[k], sizeLength);
|
|
1305
|
+
name[k] = '\0';
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
703
1308
|
}
|
|
704
1309
|
}
|
|
705
1310
|
|
|
@@ -713,6 +1318,37 @@ static unsigned int TextLength(const char *text)
|
|
|
713
1318
|
return length;
|
|
714
1319
|
}
|
|
715
1320
|
|
|
1321
|
+
// Compare two text strings, requires number of characters to compare
|
|
1322
|
+
static bool IsTextEqual(const char *text1, const char *text2, unsigned int count)
|
|
1323
|
+
{
|
|
1324
|
+
bool result = true;
|
|
1325
|
+
|
|
1326
|
+
for (unsigned int i = 0; i < count; i++)
|
|
1327
|
+
{
|
|
1328
|
+
if (text1[i] != text2[i])
|
|
1329
|
+
{
|
|
1330
|
+
result = false;
|
|
1331
|
+
break;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
return result;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// Find first text occurrence within a string
|
|
1339
|
+
int TextFindIndex(const char *text, const char *find)
|
|
1340
|
+
{
|
|
1341
|
+
int textLen = TextLength(text);
|
|
1342
|
+
int findLen = TextLength(find);
|
|
1343
|
+
|
|
1344
|
+
for (int i = 0; i <= textLen - findLen; i++)
|
|
1345
|
+
{
|
|
1346
|
+
if (IsTextEqual(&text[i], find, findLen)) return i;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
return -1;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
716
1352
|
// Custom memcpy() to avoid <string.h>
|
|
717
1353
|
static void MemoryCopy(void *dest, const void *src, unsigned int count)
|
|
718
1354
|
{
|
|
@@ -722,30 +1358,50 @@ static void MemoryCopy(void *dest, const void *src, unsigned int count)
|
|
|
722
1358
|
for (unsigned int i = 0; i < count; i++) destPtr[i] = srcPtr[i];
|
|
723
1359
|
}
|
|
724
1360
|
|
|
725
|
-
//
|
|
726
|
-
static
|
|
1361
|
+
// Escape backslashes in a string, writing the escaped string into a static buffer
|
|
1362
|
+
static char *EscapeBackslashes(char *text)
|
|
727
1363
|
{
|
|
728
|
-
|
|
1364
|
+
static char buffer[256] = { 0 };
|
|
729
1365
|
|
|
730
|
-
|
|
1366
|
+
int count = 0;
|
|
1367
|
+
|
|
1368
|
+
for (int i = 0; (text[i] != '\0') && (i < 255); i++, count++)
|
|
731
1369
|
{
|
|
732
|
-
|
|
1370
|
+
buffer[count] = text[i];
|
|
1371
|
+
|
|
1372
|
+
if (text[i] == '\\')
|
|
733
1373
|
{
|
|
734
|
-
|
|
735
|
-
|
|
1374
|
+
buffer[count + 1] = '\\';
|
|
1375
|
+
count++;
|
|
736
1376
|
}
|
|
737
1377
|
}
|
|
738
1378
|
|
|
739
|
-
|
|
1379
|
+
buffer[count] = '\0';
|
|
1380
|
+
|
|
1381
|
+
return buffer;
|
|
740
1382
|
}
|
|
741
1383
|
|
|
742
|
-
//
|
|
743
|
-
static char*
|
|
1384
|
+
// Get string of define type
|
|
1385
|
+
static const char *StrDefineType(DefineType type)
|
|
744
1386
|
{
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1387
|
+
switch (type)
|
|
1388
|
+
{
|
|
1389
|
+
case UNKNOWN: return "UNKNOWN";
|
|
1390
|
+
case GUARD: return "GUARD";
|
|
1391
|
+
case MACRO: return "MACRO";
|
|
1392
|
+
case INT: return "INT";
|
|
1393
|
+
case INT_MATH: return "INT_MATH";
|
|
1394
|
+
case LONG: return "LONG";
|
|
1395
|
+
case LONG_MATH: return "LONG_MATH";
|
|
1396
|
+
case FLOAT: return "FLOAT";
|
|
1397
|
+
case FLOAT_MATH: return "FLOAT_MATH";
|
|
1398
|
+
case DOUBLE: return "DOUBLE";
|
|
1399
|
+
case DOUBLE_MATH: return "DOUBLE_MATH";
|
|
1400
|
+
case CHAR: return "CHAR";
|
|
1401
|
+
case STRING: return "STRING";
|
|
1402
|
+
case COLOR: return "COLOR";
|
|
1403
|
+
}
|
|
1404
|
+
return "";
|
|
749
1405
|
}
|
|
750
1406
|
|
|
751
1407
|
/*
|
|
@@ -809,14 +1465,40 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
809
1465
|
{
|
|
810
1466
|
case DEFAULT:
|
|
811
1467
|
{
|
|
1468
|
+
// Print defines info
|
|
1469
|
+
fprintf(outFile, "\nDefines found: %i\n\n", defineCount);
|
|
1470
|
+
for (int i = 0; i < defineCount; i++)
|
|
1471
|
+
{
|
|
1472
|
+
fprintf(outFile, "Define %03i: %s\n", i + 1, defines[i].name);
|
|
1473
|
+
fprintf(outFile, " Name: %s\n", defines[i].name);
|
|
1474
|
+
fprintf(outFile, " Type: %s\n", StrDefineType(defines[i].type));
|
|
1475
|
+
fprintf(outFile, " Value: %s\n", defines[i].value);
|
|
1476
|
+
fprintf(outFile, " Description: %s\n", defines[i].desc);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
812
1479
|
// Print structs info
|
|
813
1480
|
fprintf(outFile, "\nStructures found: %i\n\n", structCount);
|
|
814
1481
|
for (int i = 0; i < structCount; i++)
|
|
815
1482
|
{
|
|
816
1483
|
fprintf(outFile, "Struct %02i: %s (%i fields)\n", i + 1, structs[i].name, structs[i].fieldCount);
|
|
817
1484
|
fprintf(outFile, " Name: %s\n", structs[i].name);
|
|
818
|
-
fprintf(outFile, " Description: %s\n", structs[i].desc
|
|
819
|
-
for (int f = 0; f < structs[i].fieldCount; f++)
|
|
1485
|
+
fprintf(outFile, " Description: %s\n", structs[i].desc);
|
|
1486
|
+
for (int f = 0; f < structs[i].fieldCount; f++)
|
|
1487
|
+
{
|
|
1488
|
+
fprintf(outFile, " Field[%i]: %s %s ", f + 1, structs[i].fieldType[f], structs[i].fieldName[f]);
|
|
1489
|
+
if (structs[i].fieldDesc[f][0]) fprintf(outFile, "// %s\n", structs[i].fieldDesc[f]);
|
|
1490
|
+
else fprintf(outFile, "\n");
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// Print aliases info
|
|
1495
|
+
fprintf(outFile, "\nAliases found: %i\n\n", aliasCount);
|
|
1496
|
+
for (int i = 0; i < aliasCount; i++)
|
|
1497
|
+
{
|
|
1498
|
+
fprintf(outFile, "Alias %03i: %s\n", i + 1, aliases[i].name);
|
|
1499
|
+
fprintf(outFile, " Type: %s\n", aliases[i].type);
|
|
1500
|
+
fprintf(outFile, " Name: %s\n", aliases[i].name);
|
|
1501
|
+
fprintf(outFile, " Description: %s\n", aliases[i].desc);
|
|
820
1502
|
}
|
|
821
1503
|
|
|
822
1504
|
// Print enums info
|
|
@@ -825,10 +1507,22 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
825
1507
|
{
|
|
826
1508
|
fprintf(outFile, "Enum %02i: %s (%i values)\n", i + 1, enums[i].name, enums[i].valueCount);
|
|
827
1509
|
fprintf(outFile, " Name: %s\n", enums[i].name);
|
|
828
|
-
fprintf(outFile, "
|
|
1510
|
+
fprintf(outFile, " Description: %s\n", enums[i].desc);
|
|
829
1511
|
for (int e = 0; e < enums[i].valueCount; e++) fprintf(outFile, " Value[%s]: %i\n", enums[i].valueName[e], enums[i].valueInteger[e]);
|
|
830
1512
|
}
|
|
831
1513
|
|
|
1514
|
+
// Print callbacks info
|
|
1515
|
+
fprintf(outFile, "\nCallbacks found: %i\n\n", callbackCount);
|
|
1516
|
+
for (int i = 0; i < callbackCount; i++)
|
|
1517
|
+
{
|
|
1518
|
+
fprintf(outFile, "Callback %03i: %s() (%i input parameters)\n", i + 1, callbacks[i].name, callbacks[i].paramCount);
|
|
1519
|
+
fprintf(outFile, " Name: %s\n", callbacks[i].name);
|
|
1520
|
+
fprintf(outFile, " Return type: %s\n", callbacks[i].retType);
|
|
1521
|
+
fprintf(outFile, " Description: %s\n", callbacks[i].desc);
|
|
1522
|
+
for (int p = 0; p < callbacks[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, callbacks[i].paramName[p], callbacks[i].paramType[p]);
|
|
1523
|
+
if (callbacks[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
|
|
1524
|
+
}
|
|
1525
|
+
|
|
832
1526
|
// Print functions info
|
|
833
1527
|
fprintf(outFile, "\nFunctions found: %i\n\n", funcCount);
|
|
834
1528
|
for (int i = 0; i < funcCount; i++)
|
|
@@ -836,7 +1530,7 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
836
1530
|
fprintf(outFile, "Function %03i: %s() (%i input parameters)\n", i + 1, funcs[i].name, funcs[i].paramCount);
|
|
837
1531
|
fprintf(outFile, " Name: %s\n", funcs[i].name);
|
|
838
1532
|
fprintf(outFile, " Return type: %s\n", funcs[i].retType);
|
|
839
|
-
fprintf(outFile, " Description: %s\n", funcs[i].desc
|
|
1533
|
+
fprintf(outFile, " Description: %s\n", funcs[i].desc);
|
|
840
1534
|
for (int p = 0; p < funcs[i].paramCount; p++) fprintf(outFile, " Param[%i]: %s (type: %s)\n", p + 1, funcs[i].paramName[p], funcs[i].paramType[p]);
|
|
841
1535
|
if (funcs[i].paramCount == 0) fprintf(outFile, " No input parameters\n");
|
|
842
1536
|
}
|
|
@@ -845,20 +1539,51 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
845
1539
|
{
|
|
846
1540
|
fprintf(outFile, "{\n");
|
|
847
1541
|
|
|
1542
|
+
// Print defines info
|
|
1543
|
+
fprintf(outFile, " \"defines\": [\n");
|
|
1544
|
+
for (int i = 0; i < defineCount; i++)
|
|
1545
|
+
{
|
|
1546
|
+
fprintf(outFile, " {\n");
|
|
1547
|
+
fprintf(outFile, " \"name\": \"%s\",\n", defines[i].name);
|
|
1548
|
+
fprintf(outFile, " \"type\": \"%s\",\n", StrDefineType(defines[i].type));
|
|
1549
|
+
if (defines[i].isHex) // INT or LONG
|
|
1550
|
+
{
|
|
1551
|
+
fprintf(outFile, " \"value\": %ld,\n", strtol(defines[i].value, NULL, 16));
|
|
1552
|
+
}
|
|
1553
|
+
else if ((defines[i].type == INT) ||
|
|
1554
|
+
(defines[i].type == LONG) ||
|
|
1555
|
+
(defines[i].type == FLOAT) ||
|
|
1556
|
+
(defines[i].type == DOUBLE) ||
|
|
1557
|
+
(defines[i].type == STRING))
|
|
1558
|
+
{
|
|
1559
|
+
fprintf(outFile, " \"value\": %s,\n", defines[i].value);
|
|
1560
|
+
}
|
|
1561
|
+
else
|
|
1562
|
+
{
|
|
1563
|
+
fprintf(outFile, " \"value\": \"%s\",\n", defines[i].value);
|
|
1564
|
+
}
|
|
1565
|
+
fprintf(outFile, " \"description\": \"%s\"\n", defines[i].desc);
|
|
1566
|
+
fprintf(outFile, " }");
|
|
1567
|
+
|
|
1568
|
+
if (i < defineCount - 1) fprintf(outFile, ",\n");
|
|
1569
|
+
else fprintf(outFile, "\n");
|
|
1570
|
+
}
|
|
1571
|
+
fprintf(outFile, " ],\n");
|
|
1572
|
+
|
|
848
1573
|
// Print structs info
|
|
849
1574
|
fprintf(outFile, " \"structs\": [\n");
|
|
850
1575
|
for (int i = 0; i < structCount; i++)
|
|
851
1576
|
{
|
|
852
1577
|
fprintf(outFile, " {\n");
|
|
853
1578
|
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].name);
|
|
854
|
-
fprintf(outFile, " \"description\": \"%s\",\n", structs[i].desc);
|
|
1579
|
+
fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(structs[i].desc));
|
|
855
1580
|
fprintf(outFile, " \"fields\": [\n");
|
|
856
1581
|
for (int f = 0; f < structs[i].fieldCount; f++)
|
|
857
1582
|
{
|
|
858
1583
|
fprintf(outFile, " {\n");
|
|
859
|
-
fprintf(outFile, " \"
|
|
860
|
-
fprintf(outFile, " \"
|
|
861
|
-
fprintf(outFile, " \"description\": \"%s\"\n", structs[i].fieldDesc[f]
|
|
1584
|
+
fprintf(outFile, " \"type\": \"%s\",\n", structs[i].fieldType[f]);
|
|
1585
|
+
fprintf(outFile, " \"name\": \"%s\",\n", structs[i].fieldName[f]);
|
|
1586
|
+
fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f]));
|
|
862
1587
|
fprintf(outFile, " }");
|
|
863
1588
|
if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n");
|
|
864
1589
|
else fprintf(outFile, "\n");
|
|
@@ -870,20 +1595,35 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
870
1595
|
}
|
|
871
1596
|
fprintf(outFile, " ],\n");
|
|
872
1597
|
|
|
1598
|
+
// Print aliases info
|
|
1599
|
+
fprintf(outFile, " \"aliases\": [\n");
|
|
1600
|
+
for (int i = 0; i < aliasCount; i++)
|
|
1601
|
+
{
|
|
1602
|
+
fprintf(outFile, " {\n");
|
|
1603
|
+
fprintf(outFile, " \"type\": \"%s\",\n", aliases[i].type);
|
|
1604
|
+
fprintf(outFile, " \"name\": \"%s\",\n", aliases[i].name);
|
|
1605
|
+
fprintf(outFile, " \"description\": \"%s\"\n", aliases[i].desc);
|
|
1606
|
+
fprintf(outFile, " }");
|
|
1607
|
+
|
|
1608
|
+
if (i < aliasCount - 1) fprintf(outFile, ",\n");
|
|
1609
|
+
else fprintf(outFile, "\n");
|
|
1610
|
+
}
|
|
1611
|
+
fprintf(outFile, " ],\n");
|
|
1612
|
+
|
|
873
1613
|
// Print enums info
|
|
874
1614
|
fprintf(outFile, " \"enums\": [\n");
|
|
875
1615
|
for (int i = 0; i < enumCount; i++)
|
|
876
1616
|
{
|
|
877
1617
|
fprintf(outFile, " {\n");
|
|
878
1618
|
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].name);
|
|
879
|
-
fprintf(outFile, " \"description\": \"%s\",\n", enums[i].desc
|
|
1619
|
+
fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(enums[i].desc));
|
|
880
1620
|
fprintf(outFile, " \"values\": [\n");
|
|
881
1621
|
for (int e = 0; e < enums[i].valueCount; e++)
|
|
882
1622
|
{
|
|
883
1623
|
fprintf(outFile, " {\n");
|
|
884
|
-
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].valueName[e])
|
|
885
|
-
fprintf(outFile, " \"value\": %i,\n", enums[i].valueInteger[e])
|
|
886
|
-
fprintf(outFile, " \"description\": \"%s\"\n", enums[i].valueDesc[e]
|
|
1624
|
+
fprintf(outFile, " \"name\": \"%s\",\n", enums[i].valueName[e]);
|
|
1625
|
+
fprintf(outFile, " \"value\": %i,\n", enums[i].valueInteger[e]);
|
|
1626
|
+
fprintf(outFile, " \"description\": \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e]));
|
|
887
1627
|
fprintf(outFile, " }");
|
|
888
1628
|
if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n");
|
|
889
1629
|
else fprintf(outFile, "\n");
|
|
@@ -895,26 +1635,60 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
895
1635
|
}
|
|
896
1636
|
fprintf(outFile, " ],\n");
|
|
897
1637
|
|
|
1638
|
+
// Print callbacks info
|
|
1639
|
+
fprintf(outFile, " \"callbacks\": [\n");
|
|
1640
|
+
for (int i = 0; i < callbackCount; i++)
|
|
1641
|
+
{
|
|
1642
|
+
fprintf(outFile, " {\n");
|
|
1643
|
+
fprintf(outFile, " \"name\": \"%s\",\n", callbacks[i].name);
|
|
1644
|
+
fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(callbacks[i].desc));
|
|
1645
|
+
fprintf(outFile, " \"returnType\": \"%s\"", callbacks[i].retType);
|
|
1646
|
+
|
|
1647
|
+
if (callbacks[i].paramCount == 0) fprintf(outFile, "\n");
|
|
1648
|
+
else
|
|
1649
|
+
{
|
|
1650
|
+
fprintf(outFile, ",\n \"params\": [\n");
|
|
1651
|
+
for (int p = 0; p < callbacks[i].paramCount; p++)
|
|
1652
|
+
{
|
|
1653
|
+
fprintf(outFile, " {\n");
|
|
1654
|
+
fprintf(outFile, " \"type\": \"%s\",\n", callbacks[i].paramType[p]);
|
|
1655
|
+
fprintf(outFile, " \"name\": \"%s\"\n", callbacks[i].paramName[p]);
|
|
1656
|
+
fprintf(outFile, " }");
|
|
1657
|
+
if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n");
|
|
1658
|
+
else fprintf(outFile, "\n");
|
|
1659
|
+
}
|
|
1660
|
+
fprintf(outFile, " ]\n");
|
|
1661
|
+
}
|
|
1662
|
+
fprintf(outFile, " }");
|
|
1663
|
+
|
|
1664
|
+
if (i < callbackCount - 1) fprintf(outFile, ",\n");
|
|
1665
|
+
else fprintf(outFile, "\n");
|
|
1666
|
+
}
|
|
1667
|
+
fprintf(outFile, " ],\n");
|
|
1668
|
+
|
|
898
1669
|
// Print functions info
|
|
899
1670
|
fprintf(outFile, " \"functions\": [\n");
|
|
900
1671
|
for (int i = 0; i < funcCount; i++)
|
|
901
1672
|
{
|
|
902
1673
|
fprintf(outFile, " {\n");
|
|
903
1674
|
fprintf(outFile, " \"name\": \"%s\",\n", funcs[i].name);
|
|
904
|
-
fprintf(outFile, " \"description\": \"%s\",\n",
|
|
1675
|
+
fprintf(outFile, " \"description\": \"%s\",\n", EscapeBackslashes(funcs[i].desc));
|
|
905
1676
|
fprintf(outFile, " \"returnType\": \"%s\"", funcs[i].retType);
|
|
906
1677
|
|
|
907
1678
|
if (funcs[i].paramCount == 0) fprintf(outFile, "\n");
|
|
908
1679
|
else
|
|
909
1680
|
{
|
|
910
|
-
fprintf(outFile, ",\n \"params\":
|
|
1681
|
+
fprintf(outFile, ",\n \"params\": [\n");
|
|
911
1682
|
for (int p = 0; p < funcs[i].paramCount; p++)
|
|
912
1683
|
{
|
|
913
|
-
fprintf(outFile, " \"
|
|
1684
|
+
fprintf(outFile, " {\n");
|
|
1685
|
+
fprintf(outFile, " \"type\": \"%s\",\n", funcs[i].paramType[p]);
|
|
1686
|
+
fprintf(outFile, " \"name\": \"%s\"\n", funcs[i].paramName[p]);
|
|
1687
|
+
fprintf(outFile, " }");
|
|
914
1688
|
if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n");
|
|
915
1689
|
else fprintf(outFile, "\n");
|
|
916
1690
|
}
|
|
917
|
-
fprintf(outFile, "
|
|
1691
|
+
fprintf(outFile, " ]\n");
|
|
918
1692
|
}
|
|
919
1693
|
fprintf(outFile, " }");
|
|
920
1694
|
|
|
@@ -930,18 +1704,30 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
930
1704
|
/*
|
|
931
1705
|
<?xml version="1.0" encoding="Windows-1252" ?>
|
|
932
1706
|
<raylibAPI>
|
|
1707
|
+
<Defines count="">
|
|
1708
|
+
<Define name="" type="" value="" desc="" />
|
|
1709
|
+
</Defines>
|
|
933
1710
|
<Structs count="">
|
|
934
1711
|
<Struct name="" fieldCount="" desc="">
|
|
935
|
-
<Field type="" name="" desc=""
|
|
936
|
-
<Field type="" name="" desc=""
|
|
1712
|
+
<Field type="" name="" desc="" />
|
|
1713
|
+
<Field type="" name="" desc="" />
|
|
937
1714
|
</Struct>
|
|
938
1715
|
<Structs>
|
|
1716
|
+
<Aliases count="">
|
|
1717
|
+
<Alias type="" name="" desc="" />
|
|
1718
|
+
</Aliases>
|
|
939
1719
|
<Enums count="">
|
|
940
1720
|
<Enum name="" valueCount="" desc="">
|
|
941
|
-
<Value name="" integer="" desc=""
|
|
942
|
-
<Value name="" integer="" desc=""
|
|
1721
|
+
<Value name="" integer="" desc="" />
|
|
1722
|
+
<Value name="" integer="" desc="" />
|
|
943
1723
|
</Enum>
|
|
944
1724
|
</Enums>
|
|
1725
|
+
<Callbacks count="">
|
|
1726
|
+
<Callback name="" retType="" paramCount="" desc="">
|
|
1727
|
+
<Param type="" name="" desc="" />
|
|
1728
|
+
<Param type="" name="" desc="" />
|
|
1729
|
+
</Callback>
|
|
1730
|
+
</Callbacks>
|
|
945
1731
|
<Functions count="">
|
|
946
1732
|
<Function name="" retType="" paramCount="" desc="">
|
|
947
1733
|
<Param type="" name="" desc="" />
|
|
@@ -954,40 +1740,78 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
954
1740
|
fprintf(outFile, "<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>\n");
|
|
955
1741
|
fprintf(outFile, "<raylibAPI>\n");
|
|
956
1742
|
|
|
1743
|
+
// Print defines info
|
|
1744
|
+
fprintf(outFile, " <Defines count=\"%i\">\n", defineCount);
|
|
1745
|
+
for (int i = 0; i < defineCount; i++)
|
|
1746
|
+
{
|
|
1747
|
+
fprintf(outFile, " <Define name=\"%s\" type=\"%s\" ", defines[i].name, StrDefineType(defines[i].type));
|
|
1748
|
+
if (defines[i].type == STRING)
|
|
1749
|
+
{
|
|
1750
|
+
fprintf(outFile, "value=%s", defines[i].value);
|
|
1751
|
+
}
|
|
1752
|
+
else
|
|
1753
|
+
{
|
|
1754
|
+
fprintf(outFile, "value=\"%s\"", defines[i].value);
|
|
1755
|
+
}
|
|
1756
|
+
fprintf(outFile, " desc=\"%s\" />\n", defines[i].desc);
|
|
1757
|
+
}
|
|
1758
|
+
fprintf(outFile, " </Defines>\n");
|
|
1759
|
+
|
|
957
1760
|
// Print structs info
|
|
958
1761
|
fprintf(outFile, " <Structs count=\"%i\">\n", structCount);
|
|
959
1762
|
for (int i = 0; i < structCount; i++)
|
|
960
1763
|
{
|
|
961
|
-
fprintf(outFile, " <Struct name=\"%s\" fieldCount=\"%i\" desc=\"%s\">\n", structs[i].name, structs[i].fieldCount, structs[i].desc
|
|
1764
|
+
fprintf(outFile, " <Struct name=\"%s\" fieldCount=\"%i\" desc=\"%s\">\n", structs[i].name, structs[i].fieldCount, structs[i].desc);
|
|
962
1765
|
for (int f = 0; f < structs[i].fieldCount; f++)
|
|
963
1766
|
{
|
|
964
|
-
fprintf(outFile, " <Field type=\"%s\" name=\"%s\" desc=\"%s\" />\n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]
|
|
1767
|
+
fprintf(outFile, " <Field type=\"%s\" name=\"%s\" desc=\"%s\" />\n", structs[i].fieldType[f], structs[i].fieldName[f], structs[i].fieldDesc[f]);
|
|
965
1768
|
}
|
|
966
1769
|
fprintf(outFile, " </Struct>\n");
|
|
967
1770
|
}
|
|
968
1771
|
fprintf(outFile, " </Structs>\n");
|
|
969
1772
|
|
|
1773
|
+
// Print aliases info
|
|
1774
|
+
fprintf(outFile, " <Aliases count=\"%i\">\n", aliasCount);
|
|
1775
|
+
for (int i = 0; i < aliasCount; i++)
|
|
1776
|
+
{
|
|
1777
|
+
fprintf(outFile, " <Alias type=\"%s\" name=\"%s\" desc=\"%s\" />\n", aliases[i].name, aliases[i].type, aliases[i].desc);
|
|
1778
|
+
}
|
|
1779
|
+
fprintf(outFile, " </Aliases>\n");
|
|
1780
|
+
|
|
970
1781
|
// Print enums info
|
|
971
1782
|
fprintf(outFile, " <Enums count=\"%i\">\n", enumCount);
|
|
972
1783
|
for (int i = 0; i < enumCount; i++)
|
|
973
1784
|
{
|
|
974
|
-
fprintf(outFile, " <Enum name=\"%s\" valueCount=\"%i\" desc=\"%s\">\n", enums[i].name, enums[i].valueCount, enums[i].desc
|
|
1785
|
+
fprintf(outFile, " <Enum name=\"%s\" valueCount=\"%i\" desc=\"%s\">\n", enums[i].name, enums[i].valueCount, enums[i].desc);
|
|
975
1786
|
for (int v = 0; v < enums[i].valueCount; v++)
|
|
976
1787
|
{
|
|
977
|
-
fprintf(outFile, " <Value name=\"%s\" integer=\"%i\" desc=\"%s\" />\n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v]
|
|
1788
|
+
fprintf(outFile, " <Value name=\"%s\" integer=\"%i\" desc=\"%s\" />\n", enums[i].valueName[v], enums[i].valueInteger[v], enums[i].valueDesc[v]);
|
|
978
1789
|
}
|
|
979
1790
|
fprintf(outFile, " </Enum>\n");
|
|
980
1791
|
}
|
|
981
1792
|
fprintf(outFile, " </Enums>\n");
|
|
982
1793
|
|
|
1794
|
+
// Print callbacks info
|
|
1795
|
+
fprintf(outFile, " <Callbacks count=\"%i\">\n", callbackCount);
|
|
1796
|
+
for (int i = 0; i < callbackCount; i++)
|
|
1797
|
+
{
|
|
1798
|
+
fprintf(outFile, " <Callback name=\"%s\" retType=\"%s\" paramCount=\"%i\" desc=\"%s\">\n", callbacks[i].name, callbacks[i].retType, callbacks[i].paramCount, callbacks[i].desc);
|
|
1799
|
+
for (int p = 0; p < callbacks[i].paramCount; p++)
|
|
1800
|
+
{
|
|
1801
|
+
fprintf(outFile, " <Param type=\"%s\" name=\"%s\" desc=\"%s\" />\n", callbacks[i].paramType[p], callbacks[i].paramName[p], callbacks[i].paramDesc[p]);
|
|
1802
|
+
}
|
|
1803
|
+
fprintf(outFile, " </Callback>\n");
|
|
1804
|
+
}
|
|
1805
|
+
fprintf(outFile, " </Callbacks>\n");
|
|
1806
|
+
|
|
983
1807
|
// Print functions info
|
|
984
1808
|
fprintf(outFile, " <Functions count=\"%i\">\n", funcCount);
|
|
985
1809
|
for (int i = 0; i < funcCount; i++)
|
|
986
1810
|
{
|
|
987
|
-
fprintf(outFile, " <Function name=\"%s\" retType=\"%s\" paramCount=\"%i\" desc=\"%s\">\n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc
|
|
1811
|
+
fprintf(outFile, " <Function name=\"%s\" retType=\"%s\" paramCount=\"%i\" desc=\"%s\">\n", funcs[i].name, funcs[i].retType, funcs[i].paramCount, funcs[i].desc);
|
|
988
1812
|
for (int p = 0; p < funcs[i].paramCount; p++)
|
|
989
1813
|
{
|
|
990
|
-
fprintf(outFile, " <Param type=\"%s\" name=\"%s\" desc=\"%s\" />\n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p]
|
|
1814
|
+
fprintf(outFile, " <Param type=\"%s\" name=\"%s\" desc=\"%s\" />\n", funcs[i].paramType[p], funcs[i].paramName[p], funcs[i].paramDesc[p]);
|
|
991
1815
|
}
|
|
992
1816
|
fprintf(outFile, " </Function>\n");
|
|
993
1817
|
}
|
|
@@ -996,6 +1820,160 @@ static void ExportParsedData(const char *fileName, int format)
|
|
|
996
1820
|
fprintf(outFile, "</raylibAPI>\n");
|
|
997
1821
|
|
|
998
1822
|
} break;
|
|
1823
|
+
case LUA:
|
|
1824
|
+
{
|
|
1825
|
+
fprintf(outFile, "return {\n");
|
|
1826
|
+
|
|
1827
|
+
// Print defines info
|
|
1828
|
+
fprintf(outFile, " defines = {\n");
|
|
1829
|
+
for (int i = 0; i < defineCount; i++)
|
|
1830
|
+
{
|
|
1831
|
+
fprintf(outFile, " {\n");
|
|
1832
|
+
fprintf(outFile, " name = \"%s\",\n", defines[i].name);
|
|
1833
|
+
fprintf(outFile, " type = \"%s\",\n", StrDefineType(defines[i].type));
|
|
1834
|
+
if ((defines[i].type == INT) ||
|
|
1835
|
+
(defines[i].type == LONG) ||
|
|
1836
|
+
(defines[i].type == FLOAT) ||
|
|
1837
|
+
(defines[i].type == DOUBLE) ||
|
|
1838
|
+
(defines[i].type == STRING))
|
|
1839
|
+
{
|
|
1840
|
+
fprintf(outFile, " value = %s,\n", defines[i].value);
|
|
1841
|
+
}
|
|
1842
|
+
else
|
|
1843
|
+
{
|
|
1844
|
+
fprintf(outFile, " value = \"%s\",\n", defines[i].value);
|
|
1845
|
+
}
|
|
1846
|
+
fprintf(outFile, " description = \"%s\"\n", defines[i].desc);
|
|
1847
|
+
fprintf(outFile, " }");
|
|
1848
|
+
|
|
1849
|
+
if (i < defineCount - 1) fprintf(outFile, ",\n");
|
|
1850
|
+
else fprintf(outFile, "\n");
|
|
1851
|
+
}
|
|
1852
|
+
fprintf(outFile, " },\n");
|
|
1853
|
+
|
|
1854
|
+
// Print structs info
|
|
1855
|
+
fprintf(outFile, " structs = {\n");
|
|
1856
|
+
for (int i = 0; i < structCount; i++)
|
|
1857
|
+
{
|
|
1858
|
+
fprintf(outFile, " {\n");
|
|
1859
|
+
fprintf(outFile, " name = \"%s\",\n", structs[i].name);
|
|
1860
|
+
fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(structs[i].desc));
|
|
1861
|
+
fprintf(outFile, " fields = {\n");
|
|
1862
|
+
for (int f = 0; f < structs[i].fieldCount; f++)
|
|
1863
|
+
{
|
|
1864
|
+
fprintf(outFile, " {\n");
|
|
1865
|
+
fprintf(outFile, " type = \"%s\",\n", structs[i].fieldType[f]);
|
|
1866
|
+
fprintf(outFile, " name = \"%s\",\n", structs[i].fieldName[f]);
|
|
1867
|
+
fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(structs[i].fieldDesc[f]));
|
|
1868
|
+
fprintf(outFile, " }");
|
|
1869
|
+
if (f < structs[i].fieldCount - 1) fprintf(outFile, ",\n");
|
|
1870
|
+
else fprintf(outFile, "\n");
|
|
1871
|
+
}
|
|
1872
|
+
fprintf(outFile, " }\n");
|
|
1873
|
+
fprintf(outFile, " }");
|
|
1874
|
+
if (i < structCount - 1) fprintf(outFile, ",\n");
|
|
1875
|
+
else fprintf(outFile, "\n");
|
|
1876
|
+
}
|
|
1877
|
+
fprintf(outFile, " },\n");
|
|
1878
|
+
|
|
1879
|
+
// Print aliases info
|
|
1880
|
+
fprintf(outFile, " aliases = {\n");
|
|
1881
|
+
for (int i = 0; i < aliasCount; i++)
|
|
1882
|
+
{
|
|
1883
|
+
fprintf(outFile, " {\n");
|
|
1884
|
+
fprintf(outFile, " type = \"%s\",\n", aliases[i].type);
|
|
1885
|
+
fprintf(outFile, " name = \"%s\",\n", aliases[i].name);
|
|
1886
|
+
fprintf(outFile, " description = \"%s\"\n", aliases[i].desc);
|
|
1887
|
+
fprintf(outFile, " }");
|
|
1888
|
+
|
|
1889
|
+
if (i < aliasCount - 1) fprintf(outFile, ",\n");
|
|
1890
|
+
else fprintf(outFile, "\n");
|
|
1891
|
+
}
|
|
1892
|
+
fprintf(outFile, " },\n");
|
|
1893
|
+
|
|
1894
|
+
// Print enums info
|
|
1895
|
+
fprintf(outFile, " enums = {\n");
|
|
1896
|
+
for (int i = 0; i < enumCount; i++)
|
|
1897
|
+
{
|
|
1898
|
+
fprintf(outFile, " {\n");
|
|
1899
|
+
fprintf(outFile, " name = \"%s\",\n", enums[i].name);
|
|
1900
|
+
fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(enums[i].desc));
|
|
1901
|
+
fprintf(outFile, " values = {\n");
|
|
1902
|
+
for (int e = 0; e < enums[i].valueCount; e++)
|
|
1903
|
+
{
|
|
1904
|
+
fprintf(outFile, " {\n");
|
|
1905
|
+
fprintf(outFile, " name = \"%s\",\n", enums[i].valueName[e]);
|
|
1906
|
+
fprintf(outFile, " value = %i,\n", enums[i].valueInteger[e]);
|
|
1907
|
+
fprintf(outFile, " description = \"%s\"\n", EscapeBackslashes(enums[i].valueDesc[e]));
|
|
1908
|
+
fprintf(outFile, " }");
|
|
1909
|
+
if (e < enums[i].valueCount - 1) fprintf(outFile, ",\n");
|
|
1910
|
+
else fprintf(outFile, "\n");
|
|
1911
|
+
}
|
|
1912
|
+
fprintf(outFile, " }\n");
|
|
1913
|
+
fprintf(outFile, " }");
|
|
1914
|
+
if (i < enumCount - 1) fprintf(outFile, ",\n");
|
|
1915
|
+
else fprintf(outFile, "\n");
|
|
1916
|
+
}
|
|
1917
|
+
fprintf(outFile, " },\n");
|
|
1918
|
+
|
|
1919
|
+
// Print callbacks info
|
|
1920
|
+
fprintf(outFile, " callbacks = {\n");
|
|
1921
|
+
for (int i = 0; i < callbackCount; i++)
|
|
1922
|
+
{
|
|
1923
|
+
fprintf(outFile, " {\n");
|
|
1924
|
+
fprintf(outFile, " name = \"%s\",\n", callbacks[i].name);
|
|
1925
|
+
fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(callbacks[i].desc));
|
|
1926
|
+
fprintf(outFile, " returnType = \"%s\"", callbacks[i].retType);
|
|
1927
|
+
|
|
1928
|
+
if (callbacks[i].paramCount == 0) fprintf(outFile, "\n");
|
|
1929
|
+
else
|
|
1930
|
+
{
|
|
1931
|
+
fprintf(outFile, ",\n params = {\n");
|
|
1932
|
+
for (int p = 0; p < callbacks[i].paramCount; p++)
|
|
1933
|
+
{
|
|
1934
|
+
fprintf(outFile, " {type = \"%s\", name = \"%s\"}", callbacks[i].paramType[p], callbacks[i].paramName[p]);
|
|
1935
|
+
if (p < callbacks[i].paramCount - 1) fprintf(outFile, ",\n");
|
|
1936
|
+
else fprintf(outFile, "\n");
|
|
1937
|
+
}
|
|
1938
|
+
fprintf(outFile, " }\n");
|
|
1939
|
+
}
|
|
1940
|
+
fprintf(outFile, " }");
|
|
1941
|
+
|
|
1942
|
+
if (i < callbackCount - 1) fprintf(outFile, ",\n");
|
|
1943
|
+
else fprintf(outFile, "\n");
|
|
1944
|
+
}
|
|
1945
|
+
fprintf(outFile, " },\n");
|
|
1946
|
+
|
|
1947
|
+
// Print functions info
|
|
1948
|
+
fprintf(outFile, " functions = {\n");
|
|
1949
|
+
for (int i = 0; i < funcCount; i++)
|
|
1950
|
+
{
|
|
1951
|
+
fprintf(outFile, " {\n");
|
|
1952
|
+
fprintf(outFile, " name = \"%s\",\n", funcs[i].name);
|
|
1953
|
+
fprintf(outFile, " description = \"%s\",\n", EscapeBackslashes(funcs[i].desc));
|
|
1954
|
+
fprintf(outFile, " returnType = \"%s\"", funcs[i].retType);
|
|
1955
|
+
|
|
1956
|
+
if (funcs[i].paramCount == 0) fprintf(outFile, "\n");
|
|
1957
|
+
else
|
|
1958
|
+
{
|
|
1959
|
+
fprintf(outFile, ",\n params = {\n");
|
|
1960
|
+
for (int p = 0; p < funcs[i].paramCount; p++)
|
|
1961
|
+
{
|
|
1962
|
+
fprintf(outFile, " {type = \"%s\", name = \"%s\"}", funcs[i].paramType[p], funcs[i].paramName[p]);
|
|
1963
|
+
if (p < funcs[i].paramCount - 1) fprintf(outFile, ",\n");
|
|
1964
|
+
else fprintf(outFile, "\n");
|
|
1965
|
+
}
|
|
1966
|
+
fprintf(outFile, " }\n");
|
|
1967
|
+
}
|
|
1968
|
+
fprintf(outFile, " }");
|
|
1969
|
+
|
|
1970
|
+
if (i < funcCount - 1) fprintf(outFile, ",\n");
|
|
1971
|
+
else fprintf(outFile, "\n");
|
|
1972
|
+
}
|
|
1973
|
+
fprintf(outFile, " }\n");
|
|
1974
|
+
fprintf(outFile, "}\n");
|
|
1975
|
+
} break;
|
|
1976
|
+
case CODE:
|
|
999
1977
|
default: break;
|
|
1000
1978
|
}
|
|
1001
1979
|
|