The Sol Programming Language!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cdata.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef CDATA_H
  2. #define CDATA_H
  3. #include "sol.h"
  4. typedef enum {
  5. SOL_MT_INT,
  6. SOL_MT_INT8,
  7. SOL_MT_INT16,
  8. SOL_MT_INT32,
  9. SOL_MT_INT64,
  10. SOL_MT_UINT,
  11. SOL_MT_UINT8,
  12. SOL_MT_UINT16,
  13. SOL_MT_UINT32,
  14. // SOL_MT_UINT64, TODO: Not yet supported
  15. SOL_MT_FLOAT,
  16. SOL_MT_DOUBLE,
  17. SOL_MT_CHAR,
  18. SOL_MT_CSTR,
  19. SOL_MT_CFUNC,
  20. SOL_MT_PTR // Don't use this in add_member--use add_pointer
  21. } sol_memtype_t;
  22. typedef enum {
  23. SOL_CS_MEMBER,
  24. SOL_CS_CFUNC
  25. } sol_spec_t;
  26. typedef struct {
  27. sol_spec_t type;
  28. union {
  29. struct {
  30. sol_memtype_t memtype;
  31. int offset;
  32. sol_object_t *specs;
  33. };
  34. sol_cfunc_t cfunc;
  35. };
  36. } sol_memspec_t;
  37. typedef struct {
  38. void *data;
  39. sol_object_t *specs;
  40. } sol_cstruct_t;
  41. sol_object_t *sol_new_cstruct_specs(sol_state_t *);
  42. void sol_cstruct_add_member(sol_state_t *, sol_object_t *, sol_object_t *, sol_memtype_t, int);
  43. void sol_cstruct_add_member_name(sol_state_t *, sol_object_t *, char *, sol_memtype_t, int);
  44. void sol_cstruct_add_pointer(sol_state_t *, sol_object_t *, sol_object_t *, sol_object_t *, int);
  45. void sol_cstruct_add_pointer_name(sol_state_t *, sol_object_t *, char *, sol_object_t *, int);
  46. void sol_cstruct_add_func(sol_state_t *, sol_object_t *, sol_object_t *, sol_cfunc_t);
  47. void sol_cstruct_add_func_name(sol_state_t *, sol_object_t *, char *, sol_cfunc_t);
  48. sol_object_t *sol_new_cstruct(sol_state_t *, void *, sol_object_t *);
  49. extern sol_ops_t sol_cstruct_spec_ops;
  50. extern sol_ops_t sol_cstruct_ops;
  51. sol_object_t *sol_f_cstruct_index(sol_state_t *, sol_object_t *);
  52. sol_object_t *sol_f_cstruct_setindex(sol_state_t *, sol_object_t *);
  53. #endif