Kawe Mazidjatari 1c32339305 Squirrel: reverse more squirrel types and structures
This patch removes a lot of old code. Context is now exclusively grabbed from the CSquirrelVM instance. This patch also comes with a few new types: SQArray and SQTable!

The implementation also allows pushing Vector3D's on the stack, but these are handled slightly differently.. The largest field in tagSQObjectValue is 8 bytes, Vector3D is 12 bytes unaligned, but the tagSQObjectValue field in the tagSQObject struct is aligned to a 8 byte boundary while the field prior is only 4 bytes, Vector3D starts right after the type field in the tagSQObject (at the padding) to keep the whole structure the same size, therefore a new field has been added in between the padding (_pad) with a simple Vector3D accessor.

Also added a hook to allow registering proper script enums.
2024-04-05 18:31:06 +02:00

31 lines
623 B
C++

/* see copyright notice in squirrel.h */
#ifndef _SQARRAY_H_
#define _SQARRAY_H_
struct SQArray : public CHAINABLE_OBJ
{
public:
bool Get(const SQInteger nidx, SQObjectPtr& val)
{
if (nidx >= 0 && nidx < (SQInteger)_values.size()) {
SQObjectPtr& o = _values[nidx];
val = _realval(o);
return true;
}
else return false;
}
bool Set(const SQInteger nidx, const SQObjectPtr& val)
{
if (nidx >= 0 && nidx < (SQInteger)_values.size()) {
_values[nidx] = val;
return true;
}
else return false;
}
SQInteger Size() const { return _values.size(); }
SQObjectPtrVec _values;
};
#endif //_SQARRAY_H_