Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

107 rader
4.2 KiB

3 år sedan
2 år sedan
2 år sedan
2 år sedan
2 år sedan
11 månader sedan
2 år sedan
2 år sedan
2 år sedan
  1. # raylib parser
  2. This parser scans [`raylib.h`](../src/raylib.h) to get information about `defines`, `structs`, `enums` and `functions`.
  3. All data is separated into parts, usually as strings. The following types are used for data:
  4. - `struct DefineInfo`
  5. - `struct FunctionInfo`
  6. - `struct StructInfo`
  7. - `struct EnumInfo`
  8. Check `raylib_parser.c` for details about those structs.
  9. ## Command Line
  10. ```
  11. //////////////////////////////////////////////////////////////////////////////////
  12. // //
  13. // raylib API parser //
  14. // //
  15. // more info and bugs-report: github.com/raysan5/raylib/parser //
  16. // //
  17. // Copyright (c) 2021-2024 Ramon Santamaria (@raysan5) //
  18. // //
  19. //////////////////////////////////////////////////////////////////////////////////
  20. USAGE:
  21. > raylib_parser [--help] [--input <filename.h>] [--output <filename.ext>] [--format <type>]
  22. OPTIONS:
  23. -h, --help : Show tool version and command line usage help
  24. -i, --input <filename.h> : Define input header file to parse.
  25. NOTE: If not specified, defaults to: raylib.h
  26. -o, --output <filename.ext> : Define output file and format.
  27. Supported extensions: .txt, .json, .xml, .h
  28. NOTE: If not specified, defaults to: raylib_api.txt
  29. -f, --format <type> : Define output format for parser data.
  30. Supported types: DEFAULT, JSON, XML, LUA
  31. -d, --define <DEF> : Define functions specifiers (i.e. RLAPI for raylib.h, RMAPI for raymath.h, etc.)
  32. NOTE: If no specifier defined, defaults to: RLAPI
  33. -t, --truncate <after> : Define string to truncate input after (i.e. "RLGL IMPLEMENTATION" for rlgl.h)
  34. NOTE: If not specified, the full input file is parsed.
  35. EXAMPLES:
  36. > raylib_parser --input raylib.h --output api.json
  37. Process <raylib.h> to generate <api.json>
  38. > raylib_parser --output raylib_data.info --format XML
  39. Process <raylib.h> to generate <raylib_data.info> as XML text data
  40. > raylib_parser --input raymath.h --output raymath_data.info --format XML --define RMAPI
  41. Process <raymath.h> to generate <raymath_data.info> as XML text data
  42. ```
  43. ## Constraints
  44. This parser is specifically designed to work with raylib.h, so, it has some constraints:
  45. - Functions are expected as a single line with the following structure:
  46. ```
  47. <retType> <name>(<paramType[0]> <paramName[0]>, <paramType[1]> <paramName[1]>); <desc>
  48. ```
  49. Be careful with functions broken into several lines, it breaks the process!
  50. - Structures are expected as several lines with the following form:
  51. ```
  52. <desc>
  53. typedef struct <name> {
  54. <fieldType[0]> <fieldName[0]>; <fieldDesc[0]>
  55. <fieldType[1]> <fieldName[1]>; <fieldDesc[1]>
  56. <fieldType[2]> <fieldName[2]>; <fieldDesc[2]>
  57. } <name>;
  58. ```
  59. - Enums are expected as several lines with the following form:
  60. ```
  61. <desc>
  62. typedef enum {
  63. <valueName[0]> = <valueInteger[0]>, <valueDesc[0]>
  64. <valueName[1]>,
  65. <valueName[2]>, <valueDesc[2]>
  66. <valueName[3]> <valueDesc[3]>
  67. } <name>;
  68. ```
  69. _NOTE: For enums, multiple options are supported:_
  70. - If value is not provided, (<valueInteger[i -1]> + 1) is assigned
  71. - Value description can be provided or not
  72. ## Additional notes
  73. This parser _could_ work with other C header files if mentioned constraints are followed.
  74. This parser **does not require `<string.h>` library**, all data is parsed directly from char buffers.
  75. ### LICENSE: zlib/libpng
  76. raylib-parser is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.