Permalink
Browse files

sandbox, refactor: simplified parameter passing.

  • Loading branch information...
xicilion committed Aug 14, 2018
1 parent ab407ce commit 9db5774ba308cbadba9469ac30613a67952f334a
View
@@ -130,7 +130,7 @@ class SandBox : public SandBox_base {
public:
virtual result_t run(Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count)
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args)
{
return CHECK_ERROR(Runtime::setError("SandBox: Invalid file format."));
}
@@ -144,19 +144,6 @@ class SandBox : public SandBox_base {
return "extloader_p_" + extname;
}
class CustomExtLoader : public SandBox::ExtLoader {
public:
CustomExtLoader(exlib::string t_extname)
: ExtLoader(t_extname.c_str())
{
}
public:
virtual result_t run(SandBox::Context* ctx, Buffer_base* src,
exlib::string name, exlib::string arg_names,
v8::Local<v8::Value>* args, int32_t args_count);
};
public:
virtual result_t custom_resolveId(exlib::string& id, v8::Local<v8::Value>& retVal);
@@ -14,6 +14,7 @@
#include "LruCache.h"
#include "Buffer.h"
#include "options.h"
#include "loaders/loaders.h"
namespace fibjs {
@@ -63,6 +63,6 @@ result_t SandBox::ExtLoader::run_module(Context* ctx, Buffer_base* src, exlib::s
arg_names.append("){", 2);
return run(ctx, src, name, arg_names.c_str(), args.data(), (int32_t)args.size());
return run(ctx, src, name, arg_names.c_str(), args);
}
}
@@ -15,10 +15,8 @@
namespace fibjs {
result_t SandBox::CustomExtLoader::run(SandBox::Context* ctx, Buffer_base* src,
exlib::string name, exlib::string arg_names,
v8::Local<v8::Value>* args,
int32_t args_count)
result_t CustomExtLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args)
{
Isolate* isolate = ctx->m_sb->holder();
@@ -14,7 +14,7 @@
namespace fibjs {
result_t JsLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count)
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args)
{
Isolate* isolate = ctx->m_sb->holder();
@@ -68,7 +68,7 @@ result_t JsLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string na
args[0] = soname;
args[1] = isolate->NewString(pname);
v8::Local<v8::Object> glob = isolate->context()->Global();
v = func->Call(glob, args_count, args);
v = func->Call(glob, (int32_t)args.size(), args.data());
if (v.IsEmpty())
return CALL_E_JAVASCRIPT;
@@ -16,7 +16,7 @@
namespace fibjs {
result_t JscLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count)
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args)
{
result_t hr;
@@ -93,7 +93,7 @@ result_t JscLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string n
args[0] = soname;
args[1] = isolate->NewString(pname);
v8::Local<v8::Object> glob = isolate->context()->Global();
v = func->Call(glob, args_count, args);
v = func->Call(glob, (int32_t)args.size(), args.data());
if (v.IsEmpty())
return CALL_E_JAVASCRIPT;
@@ -12,7 +12,7 @@
namespace fibjs {
result_t JsonLoader::run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count)
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args)
{
exlib::string strScript;
v8::Local<v8::Value> v;
@@ -21,7 +21,7 @@ class JsLoader : public SandBox::ExtLoader {
public:
virtual result_t run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count);
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args);
};
class JscLoader : public SandBox::ExtLoader {
@@ -33,7 +33,7 @@ class JscLoader : public SandBox::ExtLoader {
public:
virtual result_t run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count);
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args);
};
class JsonLoader : public SandBox::ExtLoader {
@@ -45,7 +45,19 @@ class JsonLoader : public SandBox::ExtLoader {
public:
virtual result_t run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, v8::Local<v8::Value>* args, int32_t args_count);
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args);
};
class CustomExtLoader : public SandBox::ExtLoader {
public:
CustomExtLoader(exlib::string t_extname)
: ExtLoader(t_extname.c_str())
{
}
public:
virtual result_t run(SandBox::Context* ctx, Buffer_base* src, exlib::string name,
exlib::string arg_names, std::vector<v8::Local<v8::Value>>& args);
};
} /* namespace fibjs */

0 comments on commit 9db5774

Please sign in to comment.