Other function type support

This commit is contained in:
Federico Cecchetto 2021-10-02 01:08:04 +02:00
parent a921efb007
commit b461a6ab3c
4 changed files with 21 additions and 7 deletions

View File

@ -943,10 +943,11 @@ namespace game
}; };
struct HashTable; struct HashTable;
struct cclosure;
union HksValue union HksValue
{ {
void* cClosure; cclosure* cClosure;
void* closure; void* closure;
UserData* userData; UserData* userData;
HashTable* table; HashTable* table;
@ -1114,5 +1115,15 @@ namespace game
unsigned int m_arraySize; unsigned int m_arraySize;
Node* m_freeNode; Node* m_freeNode;
}; };
struct cclosure : ChunkHeader
{
lua_function m_function;
HashTable* m_env;
__int16 m_numUpvalues;
__int16 m_flags;
InternString* m_name;
HksObject m_upvalues[1];
};
} }
} }

View File

@ -85,8 +85,9 @@ namespace ui_scripting
* Function * Function
**************************************************************/ **************************************************************/
function::function(void* ptr_) function::function(game::hks::cclosure* ptr_, game::hks::HksObjectType type_)
: ptr(ptr_) : ptr(ptr_)
, type(type_)
{ {
} }

View File

@ -41,10 +41,11 @@ namespace ui_scripting
class function class function
{ {
public: public:
function(void*); function(game::hks::cclosure*, game::hks::HksObjectType);
arguments call(const arguments& arguments) const; arguments call(const arguments& arguments) const;
void* ptr; game::hks::cclosure* ptr;
game::hks::HksObjectType type;
}; };
} }

View File

@ -89,7 +89,7 @@ namespace ui_scripting
value::value(const function& value) value::value(const function& value)
{ {
this->value_.t = game::hks::TIFUNCTION; this->value_.t = value.type;
this->value_.v.ptr = value.ptr; this->value_.v.ptr = value.ptr;
} }
@ -259,13 +259,14 @@ namespace ui_scripting
template <> template <>
bool value::is<function>() const bool value::is<function>() const
{ {
return this->get_raw().t == game::hks::TIFUNCTION; return this->get_raw().t == game::hks::TIFUNCTION
|| this->get_raw().t == game::hks::TCFUNCTION;
} }
template <> template <>
function value::get() const function value::get() const
{ {
return this->get_raw().v.ptr; return {this->get_raw().v.cClosure, this->get_raw().t};
} }
/*************************************************************** /***************************************************************