aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/scriptjson.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/scriptjson.cpp')
-rw-r--r--NorthstarDLL/scriptjson.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/NorthstarDLL/scriptjson.cpp b/NorthstarDLL/scriptjson.cpp
index a9767615..8efad7b4 100644
--- a/NorthstarDLL/scriptjson.cpp
+++ b/NorthstarDLL/scriptjson.cpp
@@ -208,8 +208,12 @@ template <ScriptContext context> void EncodeJSONArray(
}
}
-// table function DecodeJSON( string json, bool fatalParseErrors = false )
-template <ScriptContext context> SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm)
+ADD_SQFUNC(
+ "table",
+ DecodeJSON,
+ "string json, bool fatalParseErrors = false",
+ "converts a json string to a squirrel table",
+ ScriptContext::UI | ScriptContext::CLIENT | ScriptContext::SERVER)
{
const char* pJson = g_pSquirrel<context>->getstring(sqvm, 1);
const bool bFatalParseErrors = g_pSquirrel<context>->getbool(sqvm, 2);
@@ -236,8 +240,12 @@ template <ScriptContext context> SQRESULT SQ_DecodeJSON(HSquirrelVM* sqvm)
DecodeJsonTable<context>(sqvm, (rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<SourceAllocator>>*)&doc);
}
-// string function EncodeJSON( table data )
-template <ScriptContext context> SQRESULT SQ_EncodeJSON(HSquirrelVM* sqvm)
+ADD_SQFUNC(
+ "string",
+ EncodeJSON,
+ "table data",
+ "converts a squirrel table to a json string",
+ ScriptContext::UI | ScriptContext::CLIENT | ScriptContext::SERVER)
{
rapidjson_document doc;
doc.SetObject();
@@ -255,28 +263,3 @@ template <ScriptContext context> SQRESULT SQ_EncodeJSON(HSquirrelVM* sqvm)
g_pSquirrel<context>->pushstring(sqvm, pJsonString, -1);
return SQRESULT_NOTNULL;
}
-
-ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientScriptJSON, ClientSquirrel, (CModule module))
-{
- g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration(
- "table",
- "DecodeJSON",
- "string json, bool fatalParseErrors = false",
- "converts a json string to a squirrel table",
- SQ_DecodeJSON<ScriptContext::CLIENT>);
- g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration(
- "string", "EncodeJSON", "table data", "converts a squirrel table to a json string", SQ_EncodeJSON<ScriptContext::CLIENT>);
-
- g_pSquirrel<ScriptContext::UI>->AddFuncRegistration(
- "table", "DecodeJSON", "string json", "converts a json string to a squirrel table", SQ_DecodeJSON<ScriptContext::UI>);
- g_pSquirrel<ScriptContext::UI>->AddFuncRegistration(
- "string", "EncodeJSON", "table data", "converts a squirrel table to a json string", SQ_EncodeJSON<ScriptContext::UI>);
-}
-
-ON_DLL_LOAD_RELIESON("server.dll", ServerScriptJSON, ServerSquirrel, (CModule module))
-{
- g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration(
- "table", "DecodeJSON", "string json", "converts a json string to a squirrel table", SQ_DecodeJSON<ScriptContext::SERVER>);
- g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration(
- "string", "EncodeJSON", "table data", "converts a squirrel table to a json string", SQ_EncodeJSON<ScriptContext::SERVER>);
-}