diff options
| author | Benedek Szilvasy <[email protected]> | 2021-12-16 15:34:55 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-16 16:34:55 +0100 |
| commit | 51c929ef21be82a1fae1744f110e82896afd3d7c (patch) | |
| tree | b82b235dc767b22e1462d452c7e61408192c7b26 /parser | |
| parent | 60b1f297837b17d66c9c0cf5e7b30713ea752d8b (diff) | |
| download | raylib-51c929ef21be82a1fae1744f110e82896afd3d7c.tar.gz raylib-51c929ef21be82a1fae1744f110e82896afd3d7c.zip | |
Parse struct descriptions (#2214)
* Update struct parser to parse from lines buffer
* Parse struct description
* Fix erroneous comment
Diffstat (limited to 'parser')
| -rw-r--r-- | parser/raylib_api.json | 62 | ||||
| -rw-r--r-- | parser/raylib_api.lua | 62 | ||||
| -rw-r--r-- | parser/raylib_api.txt | 62 | ||||
| -rw-r--r-- | parser/raylib_api.xml | 62 | ||||
| -rw-r--r-- | parser/raylib_parser.c | 96 |
5 files changed, 158 insertions, 186 deletions
diff --git a/parser/raylib_api.json b/parser/raylib_api.json index f0f415ad..d7c64d26 100644 --- a/parser/raylib_api.json +++ b/parser/raylib_api.json @@ -2,7 +2,7 @@ "structs": [ { "name": "Vector2", - "description": "", + "description": "Vector2, 2 components", "fields": [ { "name": "x", @@ -18,7 +18,7 @@ }, { "name": "Vector3", - "description": "", + "description": "Vector3, 3 components", "fields": [ { "name": "x", @@ -39,7 +39,7 @@ }, { "name": "Vector4", - "description": "", + "description": "Vector4, 4 components", "fields": [ { "name": "x", @@ -65,7 +65,7 @@ }, { "name": "Matrix", - "description": "", + "description": "Matrix, 4x4 components, column major, OpenGL style, right handed", "fields": [ { "name": "m0, m4, m8, m12", @@ -91,7 +91,7 @@ }, { "name": "Color", - "description": "", + "description": "Color, 4 components, R8G8B8A8 (32bit)", "fields": [ { "name": "r", @@ -117,7 +117,7 @@ }, { "name": "Rectangle", - "description": "", + "description": "Rectangle, 4 components", "fields": [ { "name": "x", @@ -143,7 +143,7 @@ }, { "name": "Image", - "description": "", + "description": "Image, pixel data stored in CPU memory (RAM)", "fields": [ { "name": "data", @@ -174,7 +174,7 @@ }, { "name": "Texture", - "description": "", + "description": "Texture, tex data stored in GPU memory (VRAM)", "fields": [ { "name": "id", @@ -205,7 +205,7 @@ }, { "name": "RenderTexture", - "description": "", + "description": "RenderTexture, fbo for texture rendering", "fields": [ { "name": "id", @@ -226,7 +226,7 @@ }, { "name": "NPatchInfo", - "description": "", + "description": "NPatchInfo, n-patch layout info", "fields": [ { "name": "source", @@ -262,7 +262,7 @@ }, { "name": "GlyphInfo", - "description": "", + "description": "GlyphInfo, font characters glyphs info", "fields": [ { "name": "value", @@ -293,7 +293,7 @@ }, { "name": "Font", - "description": "", + "description": "Font, font texture and GlyphInfo array data", "fields": [ { "name": "baseSize", @@ -329,7 +329,7 @@ }, { "name": "Camera3D", - "description": "", + "description": "Camera, defines position/orientation in 3d space", "fields": [ { "name": "position", @@ -360,7 +360,7 @@ }, { "name": "Camera2D", - "description": "", + "description": "Camera2D, defines position/orientation in 2d space", "fields": [ { "name": "offset", @@ -386,7 +386,7 @@ }, { "name": "Mesh", - "description": "", + "description": "Mesh, vertex data and vao/vbo", "fields": [ { "name": "vertexCount", @@ -467,7 +467,7 @@ }, { "name": "Shader", - "description": "", + "description": "Shader", "fields": [ { "name": "id", @@ -483,7 +483,7 @@ }, { "name": "MaterialMap", - "description": "", + "description": "MaterialMap", "fields": [ { "name": "texture", @@ -504,7 +504,7 @@ }, { "name": "Material", - "description": "", + "description": "Material, includes shader and maps", "fields": [ { "name": "shader", @@ -525,7 +525,7 @@ }, { "name": "Transform", - "description": "", + "description": "Transform, vectex transformation data", "fields": [ { "name": "translation", @@ -546,7 +546,7 @@ }, { "name": "BoneInfo", - "description": "", + "description": "Bone, skeletal animation bone", "fields": [ { "name": "name[32]", @@ -562,7 +562,7 @@ }, { "name": "Model", - "description": "", + "description": "Model, meshes, materials and animation data", "fields": [ { "name": "transform", @@ -613,7 +613,7 @@ }, { "name": "ModelAnimation", - "description": "", + "description": "ModelAnimation", "fields": [ { "name": "boneCount", @@ -639,7 +639,7 @@ }, { "name": "Ray", - "description": "", + "description": "Ray, ray for raycasting", "fields": [ { "name": "position", @@ -655,7 +655,7 @@ }, { "name": "RayCollision", - "description": "", + "description": "RayCollision, ray hit information", "fields": [ { "name": "hit", @@ -681,7 +681,7 @@ }, { "name": "BoundingBox", - "description": "", + "description": "BoundingBox", "fields": [ { "name": "min", @@ -697,7 +697,7 @@ }, { "name": "Wave", - "description": "", + "description": "Wave, audio wave data", "fields": [ { "name": "frameCount", @@ -728,7 +728,7 @@ }, { "name": "AudioStream", - "description": "", + "description": "AudioStream, custom audio stream", "fields": [ { "name": "buffer", @@ -754,7 +754,7 @@ }, { "name": "Sound", - "description": "", + "description": "Sound", "fields": [ { "name": "stream", @@ -770,7 +770,7 @@ }, { "name": "Music", - "description": "", + "description": "Music, audio stream, anything longer than ~10 seconds should be streamed", "fields": [ { "name": "stream", @@ -801,7 +801,7 @@ }, { "name": "VrDeviceInfo", - "description": "", + "description": "VrDeviceInfo, Head-Mounted-Display device parameters", "fields": [ { "name": "hResolution", @@ -857,7 +857,7 @@ }, { "name": "VrStereoConfig", - "description": "", + "description": "VrStereoConfig, VR stereo rendering configuration for simulator", "fields": [ { "name": "projection[2]", diff --git a/parser/raylib_api.lua b/parser/raylib_api.lua index 6d632d02..ba5086f2 100644 --- a/parser/raylib_api.lua +++ b/parser/raylib_api.lua @@ -2,7 +2,7 @@ return { structs = { { name = "Vector2", - description = "", + description = "Vector2, 2 components", fields = { { name = "x", @@ -18,7 +18,7 @@ return { }, { name = "Vector3", - description = "", + description = "Vector3, 3 components", fields = { { name = "x", @@ -39,7 +39,7 @@ return { }, { name = "Vector4", - description = "", + description = "Vector4, 4 components", fields = { { name = "x", @@ -65,7 +65,7 @@ return { }, { name = "Matrix", - description = "", + description = "Matrix, 4x4 components, column major, OpenGL style, right handed", fields = { { name = "m0, m4, m8, m12", @@ -91,7 +91,7 @@ return { }, { name = "Color", - description = "", + description = "Color, 4 components, R8G8B8A8 (32bit)", fields = { { name = "r", @@ -117,7 +117,7 @@ return { }, { name = "Rectangle", - description = "", + description = "Rectangle, 4 components", fields = { { name = "x", @@ -143,7 +143,7 @@ return { }, { name = "Image", - description = "", + description = "Image, pixel data stored in CPU memory (RAM)", fields = { { name = "data", @@ -174,7 +174,7 @@ return { }, { name = "Texture", - description = "", + description = "Texture, tex data stored in GPU memory (VRAM)", fields = { { name = "id", @@ -205,7 +205,7 @@ return { }, { name = "RenderTexture", - description = "", + description = "RenderTexture, fbo for texture rendering", fields = { { name = "id", @@ -226,7 +226,7 @@ return { }, { name = "NPatchInfo", - description = "", + description = "NPatchInfo, n-patch layout info", fields = { { name = "source", @@ -262,7 +262,7 @@ return { }, { name = "GlyphInfo", - description = "", + description = "GlyphInfo, font characters glyphs info", fields = { { name = "value", @@ -293,7 +293,7 @@ return { }, { name = "Font", - description = "", + description = "Font, font texture and GlyphInfo array data", fields = { { name = "baseSize", @@ -329,7 +329,7 @@ return { }, { name = "Camera3D", - description = "", + description = "Camera, defines position/orientation in 3d space", fields = { { name = "position", @@ -360,7 +360,7 @@ return { }, { name = "Camera2D", - description = "", + description = "Camera2D, defines position/orientation in 2d space", fields = { { name = "offset", @@ -386,7 +386,7 @@ return { }, { name = "Mesh", - description = "", + description = "Mesh, vertex data and vao/vbo", fields = { { name = "vertexCount", @@ -467,7 +467,7 @@ return { }, { name = "Shader", - description = "", + description = "Shader", fields = { { name = "id", @@ -483,7 +483,7 @@ return { }, { name = "MaterialMap", - description = "", + description = "MaterialMap", fields = { { name = "texture", @@ -504,7 +504,7 @@ return { }, { name = "Material", - description = "", + description = "Material, includes shader and maps", fields = { { name = "shader", @@ -525,7 +525,7 @@ return { }, { name = "Transform", - description = "", + description = "Transform, vectex transformation data", fields = { { name = "translation", @@ -546,7 +546,7 @@ return { }, { name = "BoneInfo", - description = "", + description = "Bone, skeletal animation bone", fields = { { name = "name[32]", @@ -562,7 +562,7 @@ return { }, { name = "Model", - description = "", + description = "Model, meshes, materials and animation data", fields = { { name = "transform", @@ -613,7 +613,7 @@ return { }, { name = "ModelAnimation", - description = "", + description = "ModelAnimation", fields = { { name = "boneCount", @@ -639,7 +639,7 @@ return { }, { name = "Ray", - description = "", + description = "Ray, ray for raycasting", fields = { { name = "position", @@ -655,7 +655,7 @@ return { }, { name = "RayCollision", - description = "", + description = "RayCollision, ray hit information", fields = { { name = "hit", @@ -681,7 +681,7 @@ return { }, { name = "BoundingBox", - description = "", + description = "BoundingBox", fields = { { name = "min", @@ -697,7 +697,7 @@ return { }, { name = "Wave", - description = "", + description = "Wave, audio wave data", fields = { { name = "frameCount", @@ -728,7 +728,7 @@ return { }, { name = "AudioStream", - description = "", + description = "AudioStream, custom audio stream", fields = { { name = "buffer", @@ -754,7 +754,7 @@ return { }, { name = "Sound", - description = "", + description = "Sound", fields = { { name = "stream", @@ -770,7 +770,7 @@ return { }, { name = "Music", - description = "", + description = "Music, audio stream, anything longer than ~10 seconds should be streamed", fields = { { name = "stream", @@ -801,7 +801,7 @@ return { }, { name = "VrDeviceInfo", - description = "", + description = "VrDeviceInfo, Head-Mounted-Display device parameters", fields = { { name = "hResolution", @@ -857,7 +857,7 @@ return { }, { name = "VrStereoConfig", - description = "", + description = "VrStereoConfig, VR stereo rendering configuration for simulator", fields = { { name = "projection[2]", diff --git a/parser/raylib_api.txt b/parser/raylib_api.txt index 54f42b18..a01f9fa2 100644 --- a/parser/raylib_api.txt +++ b/parser/raylib_api.txt @@ -3,46 +3,46 @@ Structures found: 31 Struct 01: Vector2 (2 fields) Name: Vector2 - Description: + Description: Vector2, 2 components Field[1]: float x // Vector x component Field[2]: float y // Vector y component Struct 02: Vector3 (3 fields) Name: Vector3 - Description: + Description: Vector3, 3 components Field[1]: float x // Vector x component Field[2]: float y // Vector y component Field[3]: float z // Vector z component Struct 03: Vector4 (4 fields) Name: Vector4 - Description: + Description: Vector4, 4 components Field[1]: float x // Vector x component Field[2]: float y // Vector y component Field[3]: float z // Vector z component Field[4]: float w // Vector w component Struct 04: Matrix (4 fields) Name: Matrix - Description: + Description: Matrix, 4x4 components, column major, OpenGL style, right handed Field[1]: float m0, m4, m8, m12 // Matrix first row (4 components) Field[2]: float m1, m5, m9, m13 // Matrix second row (4 components) Field[3]: float m2, m6, m10, m14 // Matrix third row (4 components) Field[4]: float m3, m7, m11, m15 // Matrix fourth row (4 components) Struct 05: Color (4 fields) Name: Color - Description: + Description: Color, 4 components, R8G8B8A8 (32bit) Field[1]: unsigned char r // Color red value Field[2]: unsigned char g // Color green value Field[3]: unsigned char b // Color blue value Field[4]: unsigned char a // Color alpha value Struct 06: Rectangle (4 fields) Name: Rectangle - Description: + Description: Rectangle, 4 components Field[1]: float x // Rectangle top-left corner position x Field[2]: float y // Rectangle top-left corner position y Field[3]: float width // Rectangle width Field[4]: float height // Rectangle height Struct 07: Image (5 fields) Name: Image - Description: + Description: Image, pixel data stored in CPU memory (RAM) Field[1]: void * data // Image raw data Field[2]: int width // Image base width Field[3]: int height // Image base height @@ -50,7 +50,7 @@ Struct 07: Image (5 fields) Field[5]: int format // Data format (PixelFormat type) Struct 08: Texture (5 fields) Name: Texture - Description: + Description: Texture, tex data stored in GPU memory (VRAM) Field[1]: unsigned int id // OpenGL texture id Field[2]: int width // Texture base width Field[3]: int height // Texture base height @@ -58,13 +58,13 @@ Struct 08: Texture (5 fields) Field[5]: int format // Data format (PixelFormat type) Struct 09: RenderTexture (3 fields) Name: RenderTexture - Description: + Description: RenderTexture, fbo for texture rendering Field[1]: unsigned int id // OpenGL framebuffer object id Field[2]: Texture texture // Color buffer attachment texture Field[3]: Texture depth // Depth buffer attachment texture Struct 10: NPatchInfo (6 fields) Name: NPatchInfo - Description: + Description: NPatchInfo, n-patch layout info Field[1]: Rectangle source // Texture source rectangle Field[2]: int left // Left border offset Field[3]: int top // Top border offset @@ -73,7 +73,7 @@ Struct 10: NPatchInfo (6 fields) Field[6]: int layout // Layout of the n-patch: 3x3, 1x3 or 3x1 Struct 11: GlyphInfo (5 fields) Name: GlyphInfo - Description: + Description: GlyphInfo, font characters glyphs info Field[1]: int value // Character value (Unicode) Field[2]: int offsetX // Character offset X when drawing Field[3]: int offsetY // Character offset Y when drawing @@ -81,7 +81,7 @@ Struct 11: GlyphInfo (5 fields) Field[5]: Image image // Character image data Struct 12: Font (6 fields) Name: Font - Description: + Description: Font, font texture and GlyphInfo array data Field[1]: int baseSize // Base size (default chars height) Field[2]: int glyphCount // Number of glyph characters Field[3]: int glyphPadding // Padding around the glyph characters @@ -90,7 +90,7 @@ Struct 12: Font (6 fields) Field[6]: GlyphInfo * glyphs // Glyphs info data Struct 13: Camera3D (5 fields) Name: Camera3D - Description: + Description: Camera, defines position/orientation in 3d space Field[1]: Vector3 position // Camera position Field[2]: Vector3 target // Camera target it looks-at Field[3]: Vector3 up // Camera up vector (rotation over its axis) @@ -98,14 +98,14 @@ Struct 13: Camera3D (5 fields) Field[5]: int projection // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC Struct 14: Camera2D (4 fields) Name: Camera2D - Description: + Description: Camera2D, defines position/orientation in 2d space Field[1]: Vector2 offset // Camera offset (displacement from target) Field[2]: Vector2 target // Camera target (rotation and zoom origin) Field[3]: float rotation // Camera rotation in degrees Field[4]: float zoom // Camera zoom (scaling), should be 1.0f by default Struct 15: Mesh (15 fields) Name: Mesh - Description: + Description: Mesh, vertex data and vao/vbo Field[1]: int vertexCount // Number of vertices stored in arrays Field[2]: int triangleCount // Number of triangles stored (indexed or not) Field[3]: float * vertices // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) @@ -123,35 +123,35 @@ Struct 15: Mesh (15 fields) Field[15]: unsigned int * vboId // OpenGL Vertex Buffer Objects id (default vertex data) Struct 16: Shader (2 fields) Name: Shader - Description: + Description: Shader Field[1]: unsigned int id // Shader program id Field[2]: int * locs // Shader locations array (RL_MAX_SHADER_LOCATIONS) Struct 17: MaterialMap (3 fields) Name: MaterialMap - Description: + Description: MaterialMap Field[1]: Texture2D texture // Material map texture Field[2]: Color color // Material map color Field[3]: float value // Material map value Struct 18: Material (3 fields) Name: Material - Description: + Description: Material, includes shader and maps Field[1]: Shader shader // Material shader Field[2]: MaterialMap * maps // Material maps array (MAX_MATERIAL_MAPS) Field[3]: float params[4] // Material generic parameters (if required) Struct 19: Transform (3 fields) Name: Transform - Description: + Description: Transform, vectex transformation data Field[1]: Vector3 translation // Translation Field[2]: Quaternion rotation // Rotation Field[3]: Vector3 scale // Scale Struct 20: BoneInfo (2 fields) Name: BoneInfo - Description: + Description: Bone, skeletal animation bone Field[1]: char name[32] // Bone name Field[2]: int parent // Bone parent Struct 21: Model (9 fields) Name: Model - Description: + Description: Model, meshes, materials and animation data Field[1]: Matrix transform // Local transform matrix Field[2]: int meshCount // Number of meshes Field[3]: int materialCount // Number of materials @@ -163,31 +163,31 @@ Struct 21: Model (9 fields) Field[9]: Transform * bindPose // Bones base transformation (pose) Struct 22: ModelAnimation (4 fields) Name: ModelAnimation - Description: + Description: ModelAnimation Field[1]: int boneCount // Number of bones Field[2]: int frameCount // Number of animation frames Field[3]: BoneInfo * bones // Bones information (skeleton) Field[4]: Transform ** framePoses // Poses array by frame Struct 23: Ray (2 fields) Name: Ray - Description: + Description: Ray, ray for raycasting Field[1]: Vector3 position // Ray position (origin) Field[2]: Vector3 direction // Ray direction Struct 24: RayCollision (4 fields) Name: RayCollision - Description: + Description: RayCollision, ray hit information Field[1]: bool hit // Did the ray hit something? Field[2]: float distance // Distance to nearest hit Field[3]: Vector3 point // Point of nearest hit Field[4]: Vector3 normal // Surface normal of hit Struct 25: BoundingBox (2 fields) Name: BoundingBox - Description: + Description: BoundingBox Field[1]: Vector3 min // Minimum vertex box-corner Field[2]: Vector3 max // Maximum vertex box-corner Struct 26: Wave (5 fields) Name: Wave - Description: + Description: Wave, audio wave data Field[1]: unsigned int frameCount // Total number of frames (considering channels) Field[2]: unsigned int sampleRate // Frequency (samples per second) Field[3]: unsigned int sampleSize // Bit depth (bits per sample): 8, 16, 32 (24 not supported) @@ -195,19 +195,19 @@ Struct 26: Wave (5 fields) Field[5]: void * data // Buffer data pointer Struct 27: AudioStream (4 fields) Name: AudioStream - Description: + Description: AudioStream, custom audio stream Field[1]: rAudioBuffer * buffer // Pointer to internal data used by the audio system Field[2]: unsigned int sampleRate // Frequency (samples per second) Field[3]: unsigned int sampleSize // Bit depth (bits per sample): 8, 16, 32 (24 not supported) Field[4]: unsigned int channels // Number of channels (1-mono, 2-stereo, ...) Struct 28: Sound (2 fields) Name: Sound - Description: + Description: Sound Field[1]: AudioStream stream // Audio stream Field[2]: unsigned int frameCount // Total number of frames (considering channels) Struct 29: Music (5 fields) Name: Music - Description: + Description: Music, audio stream, anything longer than ~10 seconds should be streamed Field[1]: AudioStream stream // Audio stream Field[2]: unsigned int frameCount // Total number of frames (considering channels) Field[3]: bool looping // Music looping enable @@ -215,7 +215,7 @@ Struct 29: Music (5 fields) Field[5]: void * ctxData // Audio context data, depends on type Struct 30: VrDeviceInfo (10 fields) Name: VrDeviceInfo - Description: + Description: VrDeviceInfo, Head-Mounted-Display device parameters Field[1]: int hResolution // Horizontal resolution in pixels Field[2]: int vResolution // Vertical resolution in pixels Field[3]: float hScreenSize // Horizontal size in meters @@ -228,7 +228,7 @@ Struct 30: VrDeviceInfo (10 fields) Field[10]: float chromaAbCorrection[4] // Chromatic aberration correction parameters Struct 31: VrStereoConfig (8 fields) Name: VrStereoConfig - Description: + Description: VrStereoConfig, VR stereo rendering configuration for simulator Field[1]: Matrix projection[2] // VR projection matrices (per eye) Field[2]: Matrix viewOffset[2] // VR view offset matrices (per eye) Field[3]: float leftLensCenter[2] // VR left lens center diff --git a/parser/raylib_api.xml b/parser/raylib_api.xml index 47bc9de7..ac37142e 100644 --- a/parser/raylib_api.xml +++ b/parser/raylib_api.xml @@ -1,59 +1,59 @@ <?xml version="1.0" encoding="Windows-1252" ?> <raylibAPI> <Structs count="31"> - <Struct name="Vector2" fieldCount="2" desc=""> + <Struct name="Vector2" fieldCount="2" desc="Vector2, 2 components"> <Field type="float" name="x" desc="Vector x component" /> <Field type="float" name="y" desc="Vector y component" /> </Struct> - <Struct name="Vector3" fieldCount="3" desc=""> + <Struct name="Vector3" fieldCount="3" desc="Vector3, 3 components"> <Field type="float" name="x" desc="Vector x component" /> <Field type="float" name="y" desc="Vector y component" /> <Field type="float" name="z" desc="Vector z component" /> </Struct> - <Struct name="Vector4" fieldCount="4" desc=""> + <Struct name="Vector4" fieldCount="4" desc="Vector4, 4 components"> <Field type="float" name="x" desc="Vector x component" /> <Field type="float" name="y" desc="Vector y component" /> <Field type="float" name="z" desc="Vector z component" /> <Field type="float" name="w" desc="Vector w component" /> </Struct> - <Struct name="Matrix" fieldCount="4" desc=""> + <Struct name="Matrix" fieldCount="4" desc="Matrix, 4x4 components, column major, OpenGL style, right handed"> <Field type="float" name="m0, m4, m8, m12" desc="Matrix first row (4 components)" /> <Field type="float" name="m1, m5, m9, m13" desc="Matrix second row (4 components)" /> <Field type="float" name="m2, m6, m10, m14" desc="Matrix third row (4 components)" /> <Field type="float" name="m3, m7, m11, m15" desc="Matrix fourth row (4 components)" /> </Struct> - <Struct name="Color" fieldCount="4" desc=""> + <Struct name="Color" fieldCount="4" desc="Color, 4 components, R8G8B8A8 (32bit)"> <Field type="unsigned char" name="r" desc="Color red value" /> <Field type="unsigned char" name="g" desc="Color green value" /> <Field type="unsigned char" name="b" desc="Color blue value" /> <Field type="unsigned char" name="a" desc="Color alpha value" /> </Struct> - <Struct name="Rectangle" fieldCount="4" desc=""> + <Struct name="Rectangle" fieldCount="4" desc="Rectangle, 4 components"> <Field type="float" name="x" desc="Rectangle top-left corner position x" /> <Field type="float" name="y" desc="Rectangle top-left corner position y" /> <Field type="float" name="width" desc="Rectangle width" /> <Field type="float" name="height" desc="Rectangle height" /> </Struct> - <Struct name="Image" fieldCount="5" desc=""> + <Struct name="Image" fieldCount="5" desc="Image, pixel data stored in CPU memory (RAM)"> <Field type="void *" name="data" desc="Image raw data" /> <Field type="int" name="width" desc="Image base width" /> <Field type="int" name="height" desc="Image base height" /> <Field type="int" name="mipmaps" desc="Mipmap levels, 1 by default" /> <Field type="int" name="format" desc="Data format (PixelFormat type)" /> </Struct> - <Struct name="Texture" fieldCount="5" desc=""> + <Struct name="Texture" fieldCount="5" desc="Texture, tex data stored in GPU memory (VRAM)"> <Field type="unsigned int" name="id" desc="OpenGL texture id" /> <Field type="int" name="width" desc="Texture base width" /> <Field type="int" name="height" desc="Texture base height" /> <Field type="int" name="mipmaps" desc="Mipmap levels, 1 by default" /> <Field type="int" name="format" desc="Data format (PixelFormat type)" /> </Struct> - <Struct name="RenderTexture" fieldCount="3" desc=""> + <Struct name="RenderTexture" fieldCount="3" desc="RenderTexture, fbo for texture rendering"> <Field type="unsigned int" name="id" desc="OpenGL framebuffer object id" /> <Field type="Texture" name="texture" desc="Color buffer attachment texture" /> <Field type="Texture" name="depth" desc="Depth buffer attachment texture" /> </Struct> - <Struct name="NPatchInfo" fieldCount="6" desc=""> + <Struct name="NPatchInfo" fieldCount="6" desc="NPatchInfo, n-patch layout info"> <Field type="Rectangle" name="source" desc="Texture source rectangle" /> <Field type="int" name="left" desc="Left border offset" /> <Field type="int" name="top" desc="Top border offset" /> @@ -61,14 +61,14 @@ <Field type="int" name="bottom" desc="Bottom border offset" /> <Field type="int" name="layout" desc="Layout of the n-patch: 3x3, 1x3 or 3x1" /> </Struct> - <Struct name="GlyphInfo" fieldCount="5" desc=""> + <Struct name="GlyphInfo" fieldCount="5" desc="GlyphInfo, font characters glyphs info"> <Field type="int" name="value" desc="Character value (Unicode)" /> <Field type="int" name="offsetX" desc="Character offset X when drawing" /> <Field type="int" name="offsetY" desc="Character offset Y when drawing" /> <Field type="int" name="advanceX" desc="Character advance position X" /> <Field type="Image" name="image" desc="Character image data" /> </Struct> - <Struct name="Font" fieldCount="6" desc=""> + <Struct name="Font" fieldCount="6" desc="Font, font texture and GlyphInfo array data"> <Field type="int" name="baseSize" desc="Base size (default chars height)" /> <Field type="int" name="glyphCount" desc="Number of glyph characters" /> <Field type="int" name="glyphPadding" desc="Padding around the glyph characters" /> @@ -76,20 +76,20 @@ <Field type="Rectangle *" name="recs" desc="Rectangles in texture for the glyphs" /> <Field type="GlyphInfo *" name="glyphs" desc="Glyphs info data" /> </Struct> - <Struct name="Camera3D" fieldCount="5" desc=""> + <Struct name="Camera3D" fieldCount="5" desc="Camera, defines position/orientation in 3d space"> <Field type="Vector3" name="position" desc="Camera position" /> <Field type="Vector3" name="target" desc="Camera target it looks-at" /> <Field type="Vector3" name="up" desc="Camera up vector (rotation over its axis)" /> <Field type="float" name="fovy" desc="Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic" /> <Field type="int" name="projection" desc="Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC" /> </Struct> - <Struct name="Camera2D" fieldCount="4" desc=""> + <Struct name="Camera2D" fieldCount="4" desc="Camera2D, defines position/orientation in 2d space"> <Field type="Vector2" name="offset" desc="Camera offset (displacement from target)" /> <Field type="Vector2" name="target" desc="Camera target (rotation and zoom origin)" /> <Field type="float" name="rotation" desc="Camera rotation in degrees" /> <Field type="float" name="zoom" desc="Camera zoom (scaling), should be 1.0f by default" /> </Struct> - <Struct name="Mesh" fieldCount="15" desc=""> + <Struct name="Mesh" fieldCount="15" desc="Mesh, vertex data and vao/vbo"> <Field type="int" name="vertexCount" desc="Number of vertices stored in arrays" /> <Field type="int" name="triangleCount" desc="Number of triangles stored (indexed or not)" /> <Field type="float *" name="vertices" desc="Vertex position (XYZ - 3 components per vertex) (shader-location = 0)" /> @@ -106,30 +106,30 @@ <Field type="unsigned int" name="vaoId" desc="OpenGL Vertex Array Object id" /> <Field type="unsigned int *" name="vboId" desc="OpenGL Vertex Buffer Objects id (default vertex data)" /> </Struct> - <Struct name="Shader" fieldCount="2" desc=""> + <Struct name="Shader" fieldCount="2" desc="Shader"> <Field type="unsigned int" name="id" desc="Shader program id" /> <Field type="int *" name="locs" desc="Shader locations array (RL_MAX_SHADER_LOCATIONS)" /> </Struct> - <Struct name="MaterialMap" fieldCount="3" desc=""> + <Struct name="MaterialMap" fieldCount="3" desc="MaterialMap"> <Field type="Texture2D" name="texture" desc="Material map texture" /> <Field type="Color" name="color" desc="Material map color" /> <Field type="float" name="value" desc="Material map value" /> </Struct> - <Struct name="Material" fieldCount="3" desc=""> + <Struct name="Material" fieldCount="3" desc="Material, includes shader and maps"> <Field type="Shader" name="shader" desc="Material shader" /> <Field type="MaterialMap *" name="maps" desc="Material maps array (MAX_MATERIAL_MAPS)" /> <Field type="float" name="params[4]" desc="Material generic parameters (if required)" /> </Struct> - <Struct name="Transform" fieldCount="3" desc=""> + <Struct name="Transform" fieldCount="3" desc="Transform, vectex transformation data"> <Field type="Vector3" name="translation" desc="Translation" /> <Field type="Quaternion" name="rotation" desc="Rotation" /> <Field type="Vector3" name="scale" desc="Scale" /> </Struct> - <Struct name="BoneInfo" fieldCount="2" desc=""> + <Struct name="BoneInfo" fieldCount="2" desc="Bone, skeletal animation bone"> <Field type="char" name="name[32]" desc="Bone name" /> <Field type="int" name="parent" desc="Bone parent" /> </Struct> - <Struct name="Model" fieldCount="9" desc=""> + <Struct name="Model" fieldCount="9" desc="Model, meshes, materials and animation data"> <Field type="Matrix" name="transform" desc="Local transform matrix" /> <Field type="int" name="meshCount" desc="Number of meshes" /> <Field type="int" name="materialCount" desc="Number of materials" /> @@ -140,51 +140,51 @@ <Field type="BoneInfo *" name="bones" desc="Bones information (skeleton)" /> <Field type="Transform *" name="bindPose" desc="Bones base transformation (pose)" /> </Struct> - <Struct name="ModelAnimation" fieldCount="4" desc=""> + <Struct name="ModelAnimation" fieldCount="4" desc="ModelAnimation"> <Field type="int" name="boneCount" desc="Number of bones" /> <Field type="int" name="frameCount" desc="Number of animation frames" /> <Field type="BoneInfo *" name="bones" desc="Bones information (skeleton)" /> <Field type="Transform **" name="framePoses" desc="Poses array by frame" /> </Struct> - <Struct name="Ray" fieldCount="2" desc=""> + <Struct name="Ray" fieldCount="2" desc="Ray, ray for raycasting"> <Field type="Vector3" name="position" desc="Ray position (origin)" /> <Field type="Vector3" name="direction" desc="Ray direction" /> </Struct> - <Struct name="RayCollision" fieldCount="4" desc=""> + <Struct name="RayCollision" fieldCount="4" desc="RayCollision, ray hit information"> <Field type="bool" name="hit" desc="Did the ray hit something?" /> <Field type="float" name="distance" desc="Distance to nearest hit" /> <Field type="Vector3" name="point" desc="Point of nearest hit" /> <Field type="Vector3" name="normal" desc="Surface normal of hit" /> </Struct> - <Struct name="BoundingBox" fieldCount="2" desc=""> + <Struct name="BoundingBox" fieldCount="2" desc="BoundingBox"> <Field type="Vector3" name="min" desc="Minimum vertex box-corner" /> <Field type="Vector3" name="max" desc="Maximum vertex box-corner" /> </Struct> - <Struct name="Wave" fieldCount="5" desc=""> + <Struct name="Wave" fieldCount="5" desc="Wave, audio wave data"> <Field type="unsigned int" name="frameCount" desc="Total number of frames (considering channels)" /> <Field type="unsigned int" name="sampleRate" desc="Frequency (samples per second)" /> <Field type="unsigned int" name="sampleSize" desc="Bit depth (bits per sample): 8, 16, 32 (24 not supported)" /> <Field type="unsigned int" name="channels" desc="Number of channels (1-mono, 2-stereo, ...)" /> <Field type="void *" name="data" desc="Buffer data pointer" /> </Struct> - <Struct name="AudioStream" fieldCount="4" desc=""> + <Struct name="AudioStream" fieldCount="4" desc="AudioStream, custom audio stream"> <Field type="rAudioBuffer *" name="buffer" desc="Pointer to internal data used by the audio system" /> <Field type="unsigned int" name="sampleRate" desc="Frequency (samples per second)" /> <Field type="unsigned int" name="sampleSize" desc="Bit depth (bits per sample): 8, 16, 32 (24 not supported)" /> <Field type="unsigned int" name="channels" desc="Number of channels (1-mono, 2-stereo, ...)" /> </Struct> - <Struct name="Sound" fieldCount="2" desc=""> + <Struct name="Sound" fieldCount="2" desc="Sound"> <Field type="AudioStream" name="stream" desc="Audio stream" /> <Field type="unsigned int" name="frameCount" desc="Total number of frames (considering channels)" /> </Struct> - <Struct name="Music" fieldCount="5" desc=""> + <Struct name="Music" fieldCount="5" desc="Music, audio stream, anything longer than ~10 seconds should be streamed"> <Field type="AudioStream" name="stream" desc="Audio stream" /> <Field type="unsigned int" name="frameCount" desc="Total number of frames (considering channels)" /> <Field type="bool" name="looping" desc="Music looping enable" /> <Field type="int" name="ctxType" desc="Type of music context (audio filetype)" /> <Field type="void *" name="ctxData" desc="Audio context data, depends on type" /> </Struct> - <Struct name="VrDeviceInfo" fieldCount="10" desc=""> + <Struct name="VrDeviceInfo" fieldCount="10" desc="VrDeviceInfo, Head-Mounted-Display device parameters"> <Field type="int" name="hResolution" desc="Horizontal resolution in pixels" /> <Field type="int" name="vResolution" desc="Vertical resolution in pixels" /> <Field type="float" name="hScreenSize" desc="Horizontal size in meters" /> @@ -196,7 +196,7 @@ <Field type="float" name="lensDistortionValues[4]" desc="Lens distortion constant parameters" /> <Field type="float" name="chromaAbCorrection[4]" desc="Chromatic aberration correction parameters" /> </Struct> - <Struct name="VrStereoConfig" fieldCount="8" desc=""> + <Struct name="VrStereoConfig" fieldCount="8" desc="VrStereoConfig, VR stereo rendering configuration for simulator"> <Field type="Matrix" name="projection[2]" desc="VR projection matrices (per eye)" /> <Field type="Matrix" name="viewOffset[2]" desc="VR view offset matrices (per eye)" /> <Field type="float" name="leftLensCenter[2]" desc="VR left lens center" /> diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index 994b0d00..a4171f80 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -91,7 +91,7 @@ typedef struct FunctionInfo { // Struct info data typedef struct StructInfo { char name[64]; // Struct name - char desc[64]; // Struct type description + char desc[128]; // Struct type description int fieldCount; // Number of fields in the struct char fieldType[MAX_STRUCT_FIELDS][64]; // Field type char fieldName[MAX_STRUCT_FIELDS][64]; // Field name @@ -101,7 +101,7 @@ typedef struct StructInfo { // Enum info data typedef struct EnumInfo { char name[64]; // Enum name - char desc[64]; // Enum description + char desc[128]; // Enum description int valueCount; // Number of values in enumerator char valueName[MAX_ENUM_VALUES][64]; // Value name definition int valueInteger[MAX_ENUM_VALUES]; // Value integer @@ -164,8 +164,7 @@ int main(int argc, char* argv[]) char **funcLines = (char **)malloc(MAX_FUNCS_TO_PARSE*sizeof(char *)); // Structs data (multiple lines), selected from "buffer" - char **structLines = (char **)malloc(MAX_STRUCTS_TO_PARSE*sizeof(char *)); - for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) structLines[i] = (char *)calloc(MAX_STRUCT_LINE_LENGTH, sizeof(char)); + int *structLines = (int *)malloc(MAX_STRUCTS_TO_PARSE*sizeof(int)); // Enums lines pointers, selected from buffer "lines" int *enumLines = (int *)malloc(MAX_ENUMS_TO_PARSE*sizeof(int)); @@ -185,52 +184,34 @@ int main(int argc, char* argv[]) } } - // Read structs data (multiple lines, read directly from buffer) - // TODO: Parse structs data from "lines" instead of "buffer" -> Easier to get struct definition and description - for (int i = 0; i < length; i++) + // Read struct lines + for (int i = 0; i < linesCount; i++) { - // Read struct data (starting with "typedef struct", ending with '} ... ;') - // NOTE: We read it directly from buffer - if (IsTextEqual(buffer + i, "typedef struct", 14)) + // Find structs (starting with "typedef struct ... {", ending with '} ... ;') + if (IsTextEqual(lines[i], "typedef struct", 14)) { int j = 0; bool validStruct = false; // WARNING: Typedefs between types: typedef Vector4 Quaternion; + // (maybe we could export these too?) - for (int c = 0; c < 128; c++) + for (int c = 0; c < MAX_LINE_LENGTH; c++) { - if (buffer[i + c] == '{') - { - validStruct = true; - break; - } - else if (buffer[i + c] == ';') + char v = lines[i][c]; + if (v == '{') validStruct = true; + if (v == '{' || v == ';' || v == '\0') { - // Not valid struct: + // Not valid struct if it ends without '{': // i.e typedef struct rAudioBuffer rAudioBuffer; -> Typedef and forward declaration - i += c; break; } } - - if (validStruct) - { - while (buffer[i + j] != '}') - { - structLines[structCount][j] = buffer[i + j]; - j++; - } - - while (buffer[i + j] != '\n') - { - structLines[structCount][j] = buffer[i + j]; - j++; - } - - i += j; - structCount++; - } + if (!validStruct) continue; + structLines[structCount] = i; + while (lines[i][0] != '}') i++; + while (lines[i][0] != '\0') i++; + structCount++; } } @@ -259,44 +240,36 @@ int main(int argc, char* argv[]) for (int i = 0; i < structCount; i++) { - int structLineOffset = 0; + char **linesPtr = &lines[structLines[i]]; - // TODO: Get struct description + // Parse struct description + if (linesPtr[-1][0] == '/') + { + MemoryCopy(structs[i].desc, linesPtr[-1], TextLength(linesPtr[-1])); + } // Get struct name: typedef struct name { - for (int c = 15; c < 64 + 15; c++) + const int TDS_LEN = 15; // length of "typedef struct " + for (int c = TDS_LEN; c < 64 + TDS_LEN; c++) { - if (structLines[i][c] == '{') + if (linesPtr[0][c] == '{') { - structLineOffset = c + 2; - - MemoryCopy(structs[i].name, &structLines[i][15], c - 15 - 1); + MemoryCopy(structs[i].name, &linesPtr[0][TDS_LEN], c - TDS_LEN - 1); break; } } // Get struct fields and count them -> fields finish with ; - int j = 0; - while (structLines[i][structLineOffset + j] != '}') + int l = 1; + while (linesPtr[l][0] != '}') { // WARNING: Some structs have empty spaces and comments -> OK, processed - - int fieldStart = 0; - if ((structLines[i][structLineOffset + j] != ' ') && (structLines[i][structLineOffset + j] != '\n')) fieldStart = structLineOffset + j; - - if (fieldStart != 0) + if ((linesPtr[l][0] != ' ') && (linesPtr[l][0] != '\0')) { // Scan one field line - int c = 0; + char *fieldLine = linesPtr[l]; int fieldEndPos = 0; - char fieldLine[256] = { 0 }; - - while (structLines[i][structLineOffset + j] != '\n') - { - if (structLines[i][structLineOffset + j] == ';') fieldEndPos = c; - fieldLine[c] = structLines[i][structLineOffset + j]; - c++; j++; - } + while (fieldLine[fieldEndPos] != ';') fieldEndPos++; if (fieldLine[0] != '/') // Field line is not a comment { @@ -321,12 +294,11 @@ int main(int argc, char* argv[]) } } - j++; + l++; } } - for (int i = 0; i < MAX_STRUCTS_TO_PARSE; i++) free(structLines[i]); free(structLines); // Enum info data |
