Add global deepcopy() function in scripts, to do a structured clone of objects.
Remove an unused include. This was SVN commit r9506.
This commit is contained in:
parent
ff7cc75055
commit
b741feafb1
@ -22,7 +22,6 @@
|
||||
#include "lib/regex.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/file/io/io.h"
|
||||
#include "lib/tex/tex.h"
|
||||
#include "maths/MD5.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
@ -348,6 +348,22 @@ JSBool error(JSContext* cx, uintN argc, jsval* vp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool deepcopy(JSContext* cx, uintN argc, jsval* vp)
|
||||
{
|
||||
if (argc < 1)
|
||||
{
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsval ret;
|
||||
if (!JS_StructuredClone(cx, JS_ARGV(cx, vp)[0], &ret))
|
||||
return JS_FALSE;
|
||||
|
||||
JS_SET_RVAL(cx, vp, ret);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool ProfileStart(JSContext* cx, uintN argc, jsval* vp)
|
||||
{
|
||||
if (CProfileManager::IsInitialised() && ThreadUtil::IsMainThread())
|
||||
@ -461,6 +477,7 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const sh
|
||||
JS_DefineFunction(m_cx, m_glob, "log", ::logmsg, 1, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(m_cx, m_glob, "warn", ::warn, 1, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(m_cx, m_glob, "error", ::error, 1, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(m_cx, m_glob, "deepcopy", ::deepcopy, 1, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
Register("ProfileStart", ::ProfileStart, 1);
|
||||
Register("ProfileStop", ::ProfileStop, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user