Employ some variadic macros to make some of the C++ -> JS function calling code nicer.

Template-ize CallFunctionVoid.
Changes CallFunction parameter order to make template parameter
deduction with
variadic parameters work nicely.

Reviewed By: Itms, wraitii, Yves
Differential Revision: https://code.wildfiregames.com/D77
This was SVN commit r19183.
This commit is contained in:
leper
2017-01-28 23:37:15 +00:00
parent fd5bd8e301
commit 6ae2db53db
11 changed files with 158 additions and 258 deletions
+1 -9
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2016 Wildfire Games.
/* Copyright (C) 2017 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -562,14 +562,6 @@ JSObject* ScriptInterface::CreateCustomObject(const std::string& typeName) const
return JS_NewObjectWithGivenProto(m->m_cx, it->second.m_Class, prototype);
}
bool ScriptInterface::CallFunctionVoid(JS::HandleValue val, const char* name)
{
JSAutoRequest rq(m->m_cx);
JS::RootedValue jsRet(m->m_cx);
return CallFunction_(val, name, JS::HandleValueArray::empty(), &jsRet);
}
bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::HandleValueArray argv, JS::MutableHandleValue ret) const
{
JSAutoRequest rq(m->m_cx);