Skip to content

Commit

Permalink
core, refactor: define kObjectPrototype to refer to the prototype of …
Browse files Browse the repository at this point in the history
…a common object.
  • Loading branch information
xicilion committed May 29, 2023
1 parent e35d929 commit f0a90ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion fibjs/include/utils.h
Expand Up @@ -187,6 +187,8 @@ typedef int32_t result_t;

#define STREAM_BUFF_SIZE 65536

const int32_t kObjectPrototype = 0;

#if 0
#define V8_SCOPE(isolate) v8::EscapableHandleScope handle_scope(isolate)
#define V8_RETURN(v) handle_scope.Escape(v)
Expand Down Expand Up @@ -875,7 +877,7 @@ inline bool IsJSObject(v8::Local<v8::Value> v)

v8::Local<v8::Object> o = v8::Local<v8::Object>::Cast(v);
v8::Local<v8::Context> _context = o->GetCreationContextChecked();
JSValue proto = _context->GetEmbedderData(1);
JSValue proto = _context->GetEmbedderData(kObjectPrototype);
if (!proto->Equals(_context, o->GetPrototype()).FromMaybe(false))
return false;

Expand Down
2 changes: 1 addition & 1 deletion fibjs/src/base/Isolate.cpp
Expand Up @@ -244,7 +244,7 @@ void Isolate::init()
if (g_cov && m_id == 1)
beginCoverage(m_isolate);

_context->SetEmbedderData(1, v8::Object::New(m_isolate)->GetPrototype());
_context->SetEmbedderData(kObjectPrototype, v8::Object::New(m_isolate)->GetPrototype());

static const char* skips[] = { "Master", "argv", "__filename", "__dirname", NULL };
global_base::class_info().Attach(this, _context->Global(), skips);
Expand Down
2 changes: 1 addition & 1 deletion fibjs/src/sandbox/SandBox.cpp
Expand Up @@ -84,7 +84,7 @@ void SandBox::initGlobal(v8::Local<v8::Object> global)
v8::Local<v8::Context> _context = v8::Context::New(isolate->m_isolate);
v8::Context::Scope context_scope(_context);

_context->SetEmbedderData(1, v8::Object::New(isolate->m_isolate)->GetPrototype());
_context->SetEmbedderData(kObjectPrototype, v8::Object::New(isolate->m_isolate)->GetPrototype());
_context->SetSecurityToken(_token);

v8::Local<v8::Object> _global = _context->Global();
Expand Down

0 comments on commit f0a90ea

Please sign in to comment.