bb_basic.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. enum{
  2. BBTYPE_END=0,
  3. BBTYPE_INT=1,BBTYPE_FLOAT=2,
  4. BBTYPE_STRING=3,BBTYPE_CSTR=4,
  5. BBTYPE_OBJECT=5,BBTYPE_VECTOR=6
  6. };
  7. typedef int bbInt;
  8. typedef float bbFloat;
  9. typedef bbStringhandle *bbString;
  10. typedef bbObjectHandle *bbObject;
  11. typedef bbVectorHandle *bbVector;
  12. typedef const char * bbCStr;
  13. union bbValue{
  14. bbInt INT;
  15. bbFloat FLOAT;
  16. bbString STRING;
  17. bbObject OBJECT;
  18. bbVector VECTOR;
  19. bbCStr CSTR;
  20. };
  21. struct bbType{
  22. int id;
  23. bbType( int n ):id(n(){}
  24. };
  25. struct bbInstance{
  26. bbValue value;
  27. };
  28. struct bbHandle{
  29. bbInstance *instance;
  30. int ref_cnt;
  31. bbType *type;
  32. };
  33. struct bbEnviron{
  34. bbVector *variables;
  35. };
  36. struct bbIntType : public bbType{
  37. bbInt():bbType( BBTYPE_INT ){}
  38. };
  39. struct bbFloatType : public bbType{
  40. bbFloat():bbType( BBTYPE_FLOAT ){}
  41. };
  42. struct bbCStrType : public bbType{
  43. bbCStrType():bbType( BBTYPE_CSTR ){}
  44. };
  45. struct bbStringType : public bbType{
  46. bbStringType():bbType( BBTYPE_STRING ){}
  47. };
  48. struct bbVectorType : public bbType{
  49. bbType *element_type;
  50. bbVectorType( bbType *e ):bbType( BBTYPE_VECTOR ),element_type( e ){}
  51. }
  52. struct bbObjectType : public bbType{
  53. bbEnviron *environ;
  54. bbObject *first_used,*last_used;
  55. bbObject *first_free,*last_free;
  56. bbObjectType( bbEnviron *e ):bbType( BBTYPE_OBJECT ),environ( e ){}
  57. };
  58. struct bbStringHandle : public bbHandle{
  59. };
  60. struct bbObjectHandle : public bbHandle{
  61. bbObject *next,*prev;
  62. };
  63. struct bbVectorHandle : public bbHandle{
  64. };
  65. void assign( bbHandleVariable dest,bbHandle src );