mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 20:27:13 +01:00
Update the module registration code to include the virtual machine as a function argument.
This commit is contained in:
parent
5cc8cfffa9
commit
cac237c3cb
@ -25,23 +25,23 @@ extern void Register_Constants(Table & ircns);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* 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", SQIRC_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
Table ircns(DefaultVM::Get());
|
||||
Table ircns(vm);
|
||||
|
||||
Register_Common(ircns);
|
||||
Register_Session(ircns);
|
||||
Register_Constants(ircns);
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SqIRC"), ircns);
|
||||
RootTable(vm).Bind(_SC("SqIRC"), ircns);
|
||||
|
||||
// Registration was successful
|
||||
return true;
|
||||
@ -74,7 +74,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQIRC_NAME);
|
||||
}
|
||||
|
@ -17,26 +17,26 @@ extern void Register_JValue(Table & jns);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* 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", SQJSON_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
Table jns(DefaultVM::Get());
|
||||
Table jns(vm);
|
||||
|
||||
Register_Common(jns);
|
||||
Register_JArray(jns);
|
||||
Register_JObject(jns);
|
||||
Register_JValue(jns);
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SqJSON"), jns);
|
||||
RootTable(vm).Bind(_SC("SqJSON"), jns);
|
||||
|
||||
Sqrat::ConstTable(DefaultVM::Get())
|
||||
Sqrat::ConstTable(vm)
|
||||
.Const(_SC("JSON_OBJECT"), JSON_OBJECT)
|
||||
.Const(_SC("JSON_ARRAY"), JSON_ARRAY)
|
||||
.Const(_SC("JSON_STRING"), JSON_STRING)
|
||||
@ -77,7 +77,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQJSON_NAME);
|
||||
}
|
||||
|
@ -13,19 +13,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", SQMG_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
Table mgns(DefaultVM::Get());
|
||||
Table mgns(vm);
|
||||
|
||||
mgns.Bind(_SC("Manager"), Class< Manager >(DefaultVM::Get(), _SC("SqMgManager"))
|
||||
mgns.Bind(_SC("Manager"), Class< Manager >(vm, _SC("SqMgManager"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Manager & >()
|
||||
@ -44,7 +44,7 @@ static bool RegisterAPI()
|
||||
.Overload< Connection (Manager::*)(CSStr, Uint32) const >(_SC("Connect"), &Manager::Connect)
|
||||
);
|
||||
|
||||
mgns.Bind(_SC("Connection"), Class< Connection >(DefaultVM::Get(), _SC("SqMgConnection"))
|
||||
mgns.Bind(_SC("Connection"), Class< Connection >(vm, _SC("SqMgConnection"))
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Connection & >()
|
||||
@ -58,9 +58,9 @@ static bool RegisterAPI()
|
||||
//.Func(_SC("Check"), &Connection::Check)
|
||||
);
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SqMg"), mgns);
|
||||
RootTable(vm).Bind(_SC("SqMg"), mgns);
|
||||
|
||||
ConstTable(DefaultVM::Get()).Enum(_SC("EMgF"), Enumeration(DefaultVM::Get())
|
||||
ConstTable(vm).Enum(_SC("EMgF"), Enumeration(vm)
|
||||
.Const(_SC("LISTENING"), MG_F_LISTENING)
|
||||
.Const(_SC("UDP"), MG_F_UDP)
|
||||
.Const(_SC("RESOLVING"), MG_F_RESOLVING)
|
||||
@ -81,7 +81,7 @@ static bool RegisterAPI()
|
||||
.Const(_SC("USER_6"), MG_F_USER_6)
|
||||
);
|
||||
|
||||
ConstTable(DefaultVM::Get()).Enum(_SC("MgEv"), Enumeration(DefaultVM::Get())
|
||||
ConstTable(vm).Enum(_SC("MgEv"), Enumeration(vm)
|
||||
.Const(_SC("UNKNOWN"), static_cast< Int32 >(MGEV_UNKNOWN))
|
||||
.Const(_SC("POLL"), static_cast< Int32 >(MGCE_POLL))
|
||||
.Const(_SC("ACCEPT"), static_cast< Int32 >(MGCE_ACCEPT))
|
||||
@ -160,7 +160,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQMG_NAME);
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ 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", SQMMDB_NAME);
|
||||
// Registration failed
|
||||
@ -52,7 +52,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQMMDB_NAME);
|
||||
}
|
||||
|
@ -17,24 +17,24 @@ extern void Register_Statement(Table & sqlns);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* 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", SQMYSQL_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
Table sqlns(DefaultVM::Get());
|
||||
Table sqlns(vm);
|
||||
|
||||
Register_Account(sqlns);
|
||||
Register_Connection(sqlns);
|
||||
Register_ResultSet(sqlns);
|
||||
Register_Statement(sqlns);
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SqMySQL"), sqlns);
|
||||
RootTable(vm).Bind(_SC("SqMySQL"), sqlns);
|
||||
|
||||
// Registration was successful
|
||||
return true;
|
||||
@ -67,7 +67,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQMYSQL_NAME);
|
||||
}
|
||||
|
@ -11,18 +11,18 @@ 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", SQSAMPLE_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SampleType"),
|
||||
Class< SampleType >(DefaultVM::Get(), _SC("SampleType"))
|
||||
RootTable(vm).Bind(_SC("SampleType"),
|
||||
Class< SampleType >(vm, _SC("SampleType"))
|
||||
.Ctor()
|
||||
.Ctor< int >()
|
||||
.Var(_SC("MyNum"), &SampleType::mMyNum)
|
||||
@ -30,7 +30,7 @@ static bool RegisterAPI()
|
||||
.Func(_SC("SampleMethod"), &SampleType::SampleMethod)
|
||||
);
|
||||
|
||||
RootTable(DefaultVM::Get()).Func(_SC("SampleFunction"), &SampleFunction);
|
||||
RootTable(vm).Func(_SC("SampleFunction"), &SampleFunction);
|
||||
|
||||
// Registration was successful
|
||||
return true;
|
||||
@ -63,7 +63,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQSAMPLE_NAME);
|
||||
}
|
||||
|
@ -20,17 +20,17 @@ extern void Register_Transaction(Table & sqlns);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* 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", SQSQLITE_NAME);
|
||||
// Registration failed
|
||||
return false;
|
||||
}
|
||||
|
||||
Table sqlns(DefaultVM::Get());
|
||||
Table sqlns(vm);
|
||||
|
||||
Register_Constants(sqlns);
|
||||
Register_Common(sqlns);
|
||||
@ -40,7 +40,7 @@ static bool RegisterAPI()
|
||||
Register_Column(sqlns);
|
||||
Register_Transaction(sqlns);
|
||||
|
||||
RootTable(DefaultVM::Get()).Bind(_SC("SQLite"), sqlns);
|
||||
RootTable(vm).Bind(_SC("SQLite"), sqlns);
|
||||
|
||||
// Registration was successful
|
||||
return true;
|
||||
@ -73,7 +73,7 @@ static bool OnSquirrelLoad()
|
||||
NullObject() = Object();
|
||||
NullFunction() = Function();
|
||||
// Register the module API
|
||||
if (RegisterAPI())
|
||||
if (RegisterAPI(DefaultVM::Get()))
|
||||
{
|
||||
OutputMessage("Registered: %s", SQSQLITE_NAME);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user