-
Notifications
You must be signed in to change notification settings - Fork 9
/
ScriptObject.cpp
62 lines (49 loc) · 1.18 KB
/
ScriptObject.cpp
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
#include <cstdio>
#include "ScriptObject.h"
#include "ScriptType.h"
namespace cdc {
ScriptObject::ScriptObject(ScriptType *scriptType) :
GCObject(),
scriptType(scriptType),
m_instance(nullptr)
{
ConstructInstance(); // HACK
}
void ScriptObject::ConstructInstance() {
// HACK
m_instance = (uint8_t*) new char;
m_instance[0] = 0;
}
void ScriptObject::DestructInstance() {
// HACK
delete m_instance;
m_instance = nullptr;
}
Function *ScriptObject::GetFunction(int32_t state, int32_t vtIndex) {
return scriptType->GetVFunction(state, vtIndex);
}
void ScriptObject::CallFunction(Function *func, int32_t numArgs, DataValue *args, void *retVal) {
if (!func || !m_instance)
return;
if (func->flags & Function::Flags::NATIVE) {
func->nativeFunc(this, numArgs, args, retVal);
return;
}
// TODO
}
ScriptObject::~ScriptObject() {
// TODO
DestructInstance(); // HACK
}
void ScriptObject::MarkChildren() {
// TODO
}
void ScriptObject::Finalize() {
// TODO
}
const char* ScriptObject::GetGCName() {
static char scriptobject_string_buffer[32];
sprintf(scriptobject_string_buffer, "Script: %d", (int)scriptType->blob->m_name.nocaseStr.m_id);
return scriptobject_string_buffer;
}
}