Merge pull request #24 from ReDucTor/vscript/isvalid

Adding IsValid to vscript
This commit is contained in:
Blixibon 2020-06-21 10:08:59 -05:00 committed by GitHub
commit d2ef54f1aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1067,6 +1067,14 @@ SQInteger tostring_stub(HSQUIRRELVM vm)
return 1; return 1;
} }
SQInteger IsValid_stub(HSQUIRRELVM vm)
{
ClassInstanceData* classInstanceData = nullptr;
sq_getinstanceup(vm, 1, (SQUserPointer*)&classInstanceData, 0);
sq_pushbool(vm, classInstanceData != nullptr);
return 1;
}
struct SquirrelSafeCheck struct SquirrelSafeCheck
{ {
SquirrelSafeCheck(HSQUIRRELVM vm, int outputCount = 0) : SquirrelSafeCheck(HSQUIRRELVM vm, int outputCount = 0) :
@ -1719,6 +1727,10 @@ bool SquirrelVM::RegisterClass(ScriptClassDesc_t* pClassDesc)
sq_newclosure(vm_, tostring_stub, 0); sq_newclosure(vm_, tostring_stub, 0);
sq_newslot(vm_, -3, SQFalse); sq_newslot(vm_, -3, SQFalse);
sq_pushstring(vm_, "IsValid", -1);
sq_newclosure(vm_, IsValid_stub, 0);
sq_newslot(vm_, -3, SQFalse);
for (int i = 0; i < pClassDesc->m_FunctionBindings.Count(); ++i) for (int i = 0; i < pClassDesc->m_FunctionBindings.Count(); ++i)
{ {
@ -3022,4 +3034,4 @@ bool SquirrelVM::RaiseException(const char* pszExceptionText)
IScriptVM* makeSquirrelVM() IScriptVM* makeSquirrelVM()
{ {
return new SquirrelVM; return new SquirrelVM;
} }