/usr/include/codeblocks/scripting/sqplus/SquirrelObject.h is in codeblocks-dev 10.05-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | #ifndef _SQUIRREL_OBJECT_H_
#define _SQUIRREL_OBJECT_H_
class SquirrelObject
{
friend class SquirrelVM;
public:
SquirrelObject();
virtual ~SquirrelObject();
SquirrelObject(const SquirrelObject &o);
SquirrelObject(HSQOBJECT o);
SquirrelObject & operator =(const SquirrelObject &o);
SquirrelObject & operator =(SQInteger n);
void AttachToStackObject(SQInteger idx);
void Reset(void); // Release (any) reference and reset _o.
SquirrelObject Clone();
BOOL SetValue(const SquirrelObject &key,const SquirrelObject &val);
BOOL SetValue(SQInteger key,const SquirrelObject &val);
BOOL SetValue(INT key,bool b); // Compiler treats SQBool as INT.
BOOL SetValue(INT key,INT n);
BOOL SetValue(INT key,FLOAT f);
BOOL SetValue(INT key,const SQChar *s);
BOOL SetValue(const SQChar *key,const SquirrelObject &val);
BOOL SetValue(const SQChar *key,bool b);
BOOL SetValue(const SQChar *key,INT n);
BOOL SetValue(const SQChar *key,FLOAT f);
BOOL SetValue(const SQChar *key,const SQChar *s);
BOOL SetUserPointer(const SQChar * key,SQUserPointer up);
SQUserPointer GetUserPointer(const SQChar * key);
BOOL SetUserPointer(INT key,SQUserPointer up);
SQUserPointer GetUserPointer(INT key);
BOOL NewUserData(const SQChar * key,INT size,SQUserPointer * typetag=0);
BOOL GetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag=0);
BOOL RawGetUserData(const SQChar * key,SQUserPointer * data,SQUserPointer * typetag=0);
// === BEGIN Arrays ===
BOOL ArrayResize(INT newSize);
BOOL ArrayExtend(INT amount);
BOOL ArrayReverse(void);
SquirrelObject ArrayPop(SQBool returnPoppedVal=SQTrue);
void ArrayAppend(const SquirrelObject &o);
template<typename T>
BOOL ArrayAppend(T item);
// === END Arrays ===
BOOL SetInstanceUP(SQUserPointer up);
BOOL IsNull() const;
SQInteger IsNumeric() const;
SQInteger Len() const;
BOOL SetDelegate(SquirrelObject &obj);
SquirrelObject GetDelegate();
const SQChar* ToString();
bool ToBool();
SQInteger ToInteger();
SQFloat ToFloat();
SQUserPointer GetInstanceUP(SQUserPointer tag) const;
SquirrelObject GetValue(const SQChar *key) const;
BOOL Exists(const SQChar *key) const;
FLOAT GetFloat(const SQChar *key) const;
INT GetInt(const SQChar *key) const;
const SQChar *GetString(const SQChar *key) const;
bool GetBool(const SQChar *key) const;
SquirrelObject GetValue(INT key) const;
FLOAT GetFloat(INT key) const;
INT GetInt(INT key) const;
const SQChar *GetString(INT key) const;
bool GetBool(INT key) const;
SquirrelObject GetAttributes(const SQChar *key = NULL);
SQObjectType GetType();
HSQOBJECT & GetObjectHandle(){return _o;}
BOOL BeginIteration();
BOOL Next(SquirrelObject &key,SquirrelObject &value);
void EndIteration();
BOOL GetTypeTag(SQUserPointer * typeTag);
// === Get the type name of item/object through string key in a table or class. Returns NULL if the type name is not set (not an SqPlus registered type).
const SQChar * GetTypeName(const SQChar * key);
// === Get the type name of item/object through INT key in a table or class. Returns NULL if the type name is not set (not an SqPlus registered type).
const SQChar * GetTypeName(INT key);
// === Get the type name of this object, else return NULL if not an SqPlus registered type.
const SQChar * GetTypeName(void);
private:
BOOL GetSlot(const SQChar *name) const;
BOOL RawGetSlot(const SQChar *name) const;
BOOL GetSlot(INT key) const;
HSQOBJECT _o;
};
struct StackHandler {
StackHandler(HSQUIRRELVM v) {
_top = sq_gettop(v);
this->v = v;
}
SQFloat GetFloat(SQInteger idx) {
SQFloat x = 0.0f;
if(idx > 0 && idx <= _top) {
sq_getfloat(v,idx,&x);
}
return x;
}
SQInteger GetInt(SQInteger idx) {
SQInteger x = 0;
if(idx > 0 && idx <= _top) {
sq_getinteger(v,idx,&x);
}
return x;
}
HSQOBJECT GetObjectHandle(SQInteger idx) {
HSQOBJECT x;
if(idx > 0 && idx <= _top) {
sq_resetobject(&x);
sq_getstackobj(v,idx,&x);
}
return x;
}
const SQChar *GetString(SQInteger idx)
{
const SQChar *x = NULL;
if(idx > 0 && idx <= _top) {
sq_getstring(v,idx,&x);
}
return x;
}
SQUserPointer GetUserPointer(SQInteger idx)
{
SQUserPointer x = 0;
if(idx > 0 && idx <= _top) {
sq_getuserpointer(v,idx,&x);
}
return x;
}
SQUserPointer GetInstanceUp(SQInteger idx,SQUserPointer tag)
{
SQUserPointer self;
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer*)&self,tag)))
return NULL;
return self;
}
SQUserPointer GetUserData(SQInteger idx,SQUserPointer tag=0)
{
SQUserPointer otag;
SQUserPointer up;
if(idx > 0 && idx <= _top) {
if(SQ_SUCCEEDED(sq_getuserdata(v,idx,&up,&otag))) {
if(tag == otag)
return up;
}
}
return NULL;
}
BOOL GetBool(SQInteger idx)
{
SQBool ret;
if(idx > 0 && idx <= _top) {
if(SQ_SUCCEEDED(sq_getbool(v,idx,&ret)))
return ret;
}
return FALSE;
}
SQInteger GetType(SQInteger idx)
{
if(idx > 0 && idx <= _top) {
return sq_gettype(v,idx);
}
return -1;
}
SQInteger GetParamCount() {
return _top;
}
SQInteger Return(const SQChar *s)
{
sq_pushstring(v,s,-1);
return 1;
}
SQInteger Return(FLOAT f)
{
sq_pushfloat(v,f);
return 1;
}
SQInteger Return(INT i)
{
sq_pushinteger(v,i);
return 1;
}
SQInteger Return(bool b)
{
sq_pushbool(v,b);
return 1;
}
SQInteger Return(SQUserPointer p) {
sq_pushuserpointer(v,p);
return 1;
}
SQInteger Return(SquirrelObject &o)
{
sq_pushobject(v,o.GetObjectHandle());
return 1;
}
SQInteger Return() { return 0; }
SQInteger ThrowError(const SQChar *error) {
return sq_throwerror(v,error);
}
HSQUIRRELVM GetVMPtr() { return v; }
private:
SQInteger _top;
HSQUIRRELVM v;
};
#endif //_SQUIRREL_OBJECT_H_
|