diff --git a/parser/raylib_api.json b/parser/raylib_api.json index f0f415ad7..d7c64d26f 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 6d632d02c..ba5086f2d 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 54f42b181..a01f9fa25 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 47bc9de7b..ac37142e7 100644 --- a/parser/raylib_api.xml +++ b/parser/raylib_api.xml @@ -1,59 +1,59 @@ - + - + - + - + - + - + - + - + - + - + @@ -61,14 +61,14 @@ - + - + @@ -76,20 +76,20 @@ - + - + - + @@ -106,30 +106,30 @@ - + - + - + - + - + - + @@ -140,51 +140,51 @@ - + - + - + - + - + - + - + - + - + @@ -196,7 +196,7 @@ - + diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index 994b0d003..a4171f807 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] == '{') + char v = lines[i][c]; + if (v == '{') validStruct = true; + if (v == '{' || v == ';' || v == '\0') { - validStruct = true; - break; - } - else if (buffer[i + c] == ';') - { - // 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