1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Update the module registration code to include the virtual machine as a function argument.

This commit is contained in:
Sandu Liviu Catalin
2016-07-19 21:13:56 +03:00
parent 5cc8cfffa9
commit cac237c3cb
8 changed files with 55 additions and 55 deletions

View File

@ -16,19 +16,19 @@ namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Register the module API under the obtained virtual machine.
*/
static bool RegisterAPI()
static bool RegisterAPI(HSQUIRRELVM vm)
{
// Make sure there's a valid virtual machine before proceeding
if (!DefaultVM::Get())
if (!vm)
{
OutputError("%s: Cannot register API without a valid virtual machine", SQXML_NAME);
// Registration failed
return false;
}
Table xmlns(DefaultVM::Get());
Table xmlns(vm);
xmlns.Bind(_SC("ParseResult"), Class< ParseResult >(DefaultVM::Get(), _SC("SqXmlParseResult"))
xmlns.Bind(_SC("ParseResult"), Class< ParseResult >(vm, _SC("SqXmlParseResult"))
// Constructors
.Ctor()
.Ctor< const ParseResult & >()
@ -48,7 +48,7 @@ static bool RegisterAPI()
.Func(_SC("Check"), &ParseResult::Check)
);
xmlns.Bind(_SC("Attribute"), Class< Attribute >(DefaultVM::Get(), _SC("SqXmlAttribute"))
xmlns.Bind(_SC("Attribute"), Class< Attribute >(vm, _SC("SqXmlAttribute"))
// Constructors
.Ctor()
.Ctor< const Attribute & >()
@ -93,7 +93,7 @@ static bool RegisterAPI()
.Func(_SC("SetBool"), &Attribute::ApplyBool)
);
xmlns.Bind(_SC("Text"), Class< Text >(DefaultVM::Get(), _SC("SqXmlText"))
xmlns.Bind(_SC("Text"), Class< Text >(vm, _SC("SqXmlText"))
// Constructors
.Ctor()
.Ctor< const Text & >()
@ -133,7 +133,7 @@ static bool RegisterAPI()
.Func(_SC("SetBool"), &Text::ApplyBool)
);
xmlns.Bind(_SC("Node"), Class< Node >(DefaultVM::Get(), _SC("SqXmlNode"))
xmlns.Bind(_SC("Node"), Class< Node >(vm, _SC("SqXmlNode"))
// Constructors
.Ctor()
.Ctor< const Node & >()
@ -209,7 +209,7 @@ static bool RegisterAPI()
.Func(_SC("FindElemByPath"), &Node::FindElemByPath)
);
xmlns.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(DefaultVM::Get(), _SC("SqXmlDocument"))
xmlns.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqXmlDocument"))
// Constructors
.Ctor()
// Core Meta-methods
@ -234,9 +234,9 @@ static bool RegisterAPI()
.Overload< void (Document::*)(CSStr, CSStr, Uint32, Int32) >(_SC("SaveFile"), &Document::SaveFile)
);
RootTable(DefaultVM::Get()).Bind(_SC("SqXml"), xmlns);
RootTable(vm).Bind(_SC("SqXml"), xmlns);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlNodeType"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlNodeType"), Enumeration(vm)
.Const(_SC("Null"), static_cast< Int32 >(node_null))
.Const(_SC("Document"), static_cast< Int32 >(node_document))
.Const(_SC("Element"), static_cast< Int32 >(node_element))
@ -248,7 +248,7 @@ static bool RegisterAPI()
.Const(_SC("Doctype"), static_cast< Int32 >(node_doctype))
);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlParse"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlParse"), Enumeration(vm)
.Const(_SC("Minimal"), static_cast< Int32 >(parse_minimal))
.Const(_SC("Default"), static_cast< Int32 >(parse_default))
.Const(_SC("Full"), static_cast< Int32 >(parse_full))
@ -268,7 +268,7 @@ static bool RegisterAPI()
.Const(_SC("EmbedPCData"), static_cast< Int32 >(parse_embed_pcdata))
);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlEncoding"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlEncoding"), Enumeration(vm)
.Const(_SC("Auto"), static_cast< Int32 >(encoding_auto))
.Const(_SC("Utf8"), static_cast< Int32 >(encoding_utf8))
.Const(_SC("Utf16LE"), static_cast< Int32 >(encoding_utf16_le))
@ -281,7 +281,7 @@ static bool RegisterAPI()
.Const(_SC("Latin1"), static_cast< Int32 >(encoding_latin1))
);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlFormat"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlFormat"), Enumeration(vm)
.Const(_SC("Indent"), static_cast< Int32 >(format_indent))
.Const(_SC("WriteBOM"), static_cast< Int32 >(format_write_bom))
.Const(_SC("Raw"), static_cast< Int32 >(format_raw))
@ -292,7 +292,7 @@ static bool RegisterAPI()
.Const(_SC("Default"), static_cast< Int32 >(format_default))
);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlParseStatus"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlParseStatus"), Enumeration(vm)
.Const(_SC("Ok"), static_cast< Int32 >(status_ok))
.Const(_SC("FileNotFound"), static_cast< Int32 >(status_file_not_found))
.Const(_SC("IOError"), static_cast< Int32 >(status_io_error))
@ -312,7 +312,7 @@ static bool RegisterAPI()
.Const(_SC("NoDocumentElement"), static_cast< Int32 >(status_no_document_element))
);
ConstTable(DefaultVM::Get()).Enum(_SC("SqXmlXpathValueType"), Enumeration(DefaultVM::Get())
ConstTable(vm).Enum(_SC("SqXmlXpathValueType"), Enumeration(vm)
.Const(_SC("None"), static_cast< Int32 >(xpath_type_none))
.Const(_SC("NodeSet"), static_cast< Int32 >(xpath_type_node_set))
.Const(_SC("Number"), static_cast< Int32 >(xpath_type_number))
@ -351,7 +351,7 @@ static bool OnSquirrelLoad()
NullObject() = Object();
NullFunction() = Function();
// Register the module API
if (RegisterAPI())
if (RegisterAPI(DefaultVM::Get()))
{
OutputMessage("Registered: %s", SQXML_NAME);
}