basic.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef BASIC_H
  2. #define BASIC_H
  3. #include <string>
  4. enum{
  5. BBTYPE_END=0,
  6. BBTYPE_INT=1,BBTYPE_FLT=2,
  7. BBTYPE_STR=3,BBTYPE_CSTR=4,
  8. BBTYPE_OBJ=5,BBTYPE_VEC=6
  9. };
  10. #pragma pack( push,1 )
  11. struct BBObj;
  12. struct BBStr;
  13. struct BBType;
  14. struct BBObjType;
  15. struct BBVecType;
  16. union BBField;
  17. struct BBArray;
  18. struct BBObj{
  19. BBField *fields;
  20. BBObj *next,*prev;
  21. BBObjType *type;
  22. int ref_cnt;
  23. };
  24. struct BBType{
  25. int type;
  26. BBType( int n ):type(n){}
  27. };
  28. struct BBObjType : public BBType{
  29. BBObj used,free;
  30. int fieldCnt;
  31. BBType *fieldTypes[1];
  32. };
  33. struct BBVecType : public BBType{
  34. int size;
  35. BBType *elementType;
  36. };
  37. union BBField{
  38. int INT;
  39. float FLT;
  40. BBStr *STR;
  41. char *CSTR;
  42. BBObj *OBJ;
  43. void *VEC;
  44. };
  45. struct BBArray{
  46. void *data;
  47. int elementType,dims,scales[1];
  48. };
  49. struct BBStr : public std::string{
  50. BBStr *next,*prev;
  51. BBStr();
  52. BBStr( const char *s );
  53. BBStr( const char *s,int n );
  54. BBStr( const BBStr &s );
  55. BBStr( const std::string &s );
  56. BBStr &operator=( const char *s );
  57. BBStr &operator=( const BBStr &s );
  58. BBStr &operator=( const std::string &s );
  59. ~BBStr();
  60. void *operator new( size_t size );
  61. void operator delete( void *q );
  62. void *operator new( size_t size,const char *file,int line ){ return operator new( size ); }
  63. void operator delete( void *q,const char *file,int line ){ operator delete( q ); }
  64. };
  65. struct BBData{
  66. int fieldType;
  67. BBField field;
  68. };
  69. #pragma pack( pop )
  70. void basic_link();
  71. extern BBType _bbIntType;
  72. extern BBType _bbFltType;
  73. extern BBType _bbStrType;
  74. extern BBType _bbCStrType;
  75. BBStr * _bbStrLoad( BBStr **var );
  76. void _bbStrRelease( BBStr *str );
  77. void _bbStrStore( BBStr **var,BBStr *str );
  78. int _bbStrCompare( BBStr *lhs,BBStr *rhs );
  79. BBStr * _bbStrConcat( BBStr *s1,BBStr *s2 );
  80. int _bbStrToInt( BBStr *s );
  81. BBStr * _bbStrFromInt( int n );
  82. float _bbStrToFloat( BBStr *s );
  83. BBStr * _bbStrFromFloat( float n );
  84. BBStr * _bbStrConst( const char *s );
  85. void _bbDimArray( BBArray *array );
  86. void _bbUndimArray( BBArray *array );
  87. void _bbArrayBoundsEx();
  88. void * _bbVecAlloc( BBVecType *type );
  89. void _bbVecFree( void *vec,BBVecType *type );
  90. void _bbVecBoundsEx();
  91. BBObj * _bbObjNew( BBObjType *t );
  92. void _bbObjDelete( BBObj *obj );
  93. void _bbObjDeleteEach( BBObjType *type );
  94. void _bbObjRelease( BBObj *obj );
  95. void _bbObjStore( BBObj **var,BBObj *obj );
  96. BBObj * _bbObjNext( BBObj *obj );
  97. BBObj * _bbObjPrev( BBObj *obj );
  98. BBObj * _bbObjFirst( BBObjType *t );
  99. BBObj * _bbObjLast( BBObjType *t );
  100. void _bbObjInsBefore( BBObj *o1,BBObj *o2 );
  101. void _bbObjInsAfter( BBObj *o1,BBObj *o2 );
  102. int _bbObjEachFirst( BBObj **var,BBObjType *type );
  103. int _bbObjEachNext( BBObj **var );
  104. int _bbObjCompare( BBObj *o1,BBObj *o2 );
  105. BBStr * _bbObjToStr( BBObj *obj );
  106. int _bbObjToHandle( BBObj *obj );
  107. BBObj * _bbObjFromHandle( int handle,BBObjType *type );
  108. void _bbNullObjEx();
  109. void _bbRestore( BBData *data );
  110. int _bbReadInt();
  111. float _bbReadFloat();
  112. BBStr * _bbReadStr();
  113. int _bbAbs( int n );
  114. int _bbSgn( int n );
  115. int _bbMod( int x,int y );
  116. float _bbFAbs( float n );
  117. float _bbFSgn( float n );
  118. float _bbFMod( float x,float y );
  119. float _bbFPow( float x,float y );
  120. void bbRuntimeStats();
  121. #endif