Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: fxjs/cfxjse_class.cpp

Issue 2136213002: Rename fxjse/ to fxjs/ update files to match class names. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add todo Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fxjs/cfxjse_arguments.cpp ('k') | fxjs/cfxjse_context.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fxjs/cfxjse_class.cpp
diff --git a/fxjse/class.cpp b/fxjs/cfxjse_class.cpp
similarity index 41%
rename from fxjse/class.cpp
rename to fxjs/cfxjse_class.cpp
index a4ed0916bde108be040cddb17f0ad9f187a418ed..de22af7681798e933f06017f2524c04c184cca3f 100644
--- a/fxjse/class.cpp
+++ b/fxjs/cfxjse_class.cpp
@@ -1,36 +1,24 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fxjse/include/cfxjse_class.h"
-
-#include "fxjse/context.h"
-#include "fxjse/include/cfxjse_arguments.h"
-#include "fxjse/include/cfxjse_value.h"
-#include "fxjse/scope_inline.h"
-
-static void FXJSE_V8ConstructorCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info);
-static void FXJSE_V8FunctionCallback_Wrapper(
- const v8::FunctionCallbackInfo<v8::Value>& info);
-static void FXJSE_V8GetterCallback_Wrapper(
- v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
-static void FXJSE_V8SetterCallback_Wrapper(
- v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info);
+#include "fxjs/include/cfxjse_class.h"
+
+#include "fxjs/include/cfxjse_context.h"
+#include "fxjs/include/cfxjse_value.h"
+
+namespace {
-static void FXJSE_V8FunctionCallback_Wrapper(
+void V8FunctionCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
const FXJSE_FUNCTION_DESCRIPTOR* lpFunctionInfo =
static_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpFunctionInfo) {
+ if (!lpFunctionInfo)
return;
- }
+
CFX_ByteStringC szFunctionName(lpFunctionInfo->name);
std::unique_ptr<CFXJSE_Value> lpThisValue(
new CFXJSE_Value(info.GetIsolate()));
@@ -38,19 +26,18 @@ static void FXJSE_V8FunctionCallback_Wrapper(
std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
CFXJSE_Arguments impl(&info, lpRetValue.get());
lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty()) {
+ if (!lpRetValue->DirectGetValue().IsEmpty())
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
- }
}
-static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper(
+void V8ClassGlobalConstructorCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
static_cast<FXJSE_CLASS_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpClassDefinition) {
+ if (!lpClassDefinition)
return;
- }
+
CFX_ByteStringC szFunctionName(lpClassDefinition->name);
std::unique_ptr<CFXJSE_Value> lpThisValue(
new CFXJSE_Value(info.GetIsolate()));
@@ -58,20 +45,18 @@ static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper(
std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
CFXJSE_Arguments impl(&info, lpRetValue.get());
lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl);
- if (!lpRetValue->DirectGetValue().IsEmpty()) {
+ if (!lpRetValue->DirectGetValue().IsEmpty())
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
- }
}
-static void FXJSE_V8GetterCallback_Wrapper(
- v8::Local<v8::String> property,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
+void V8GetterCallback_Wrapper(v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpPropertyInfo) {
+ if (!lpPropertyInfo)
return;
- }
+
CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
std::unique_ptr<CFXJSE_Value> lpThisValue(
new CFXJSE_Value(info.GetIsolate()));
@@ -82,16 +67,15 @@ static void FXJSE_V8GetterCallback_Wrapper(
info.GetReturnValue().Set(lpPropValue->DirectGetValue());
}
-static void FXJSE_V8SetterCallback_Wrapper(
- v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info) {
+void V8SetterCallback_Wrapper(v8::Local<v8::String> property,
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<void>& info) {
const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo =
static_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpPropertyInfo) {
+ if (!lpPropertyInfo)
return;
- }
+
CFX_ByteStringC szPropertyName(lpPropertyInfo->name);
std::unique_ptr<CFXJSE_Value> lpThisValue(
new CFXJSE_Value(info.GetIsolate()));
@@ -102,108 +86,250 @@ static void FXJSE_V8SetterCallback_Wrapper(
lpPropertyInfo->setProc(lpThisValue.get(), szPropertyName, lpPropValue.get());
}
-static void FXJSE_V8ConstructorCallback_Wrapper(
+void V8ConstructorCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- if (!info.IsConstructCall()) {
+ if (!info.IsConstructCall())
return;
- }
+
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition =
static_cast<FXJSE_CLASS_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpClassDefinition) {
+ if (!lpClassDefinition)
return;
- }
+
ASSERT(info.This()->InternalFieldCount());
- info.This()->SetAlignedPointerInInternalField(0, NULL);
+ info.This()->SetAlignedPointerInInternalField(0, nullptr);
}
-v8::Isolate* CFXJSE_Arguments::GetRuntime() const {
- return m_pRetValue->GetIsolate();
+void Context_GlobalObjToString(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ if (!lpClass)
+ return;
+
+ if (info.This() == info.Holder() && lpClass->name) {
+ CFX_ByteString szStringVal;
+ szStringVal.Format("[object %s]", lpClass->name);
+ info.GetReturnValue().Set(v8::String::NewFromUtf8(
+ info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString,
+ szStringVal.GetLength()));
+ return;
+ }
+ v8::Local<v8::String> local_str =
+ info.This()
+ ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext())
+ .FromMaybe(v8::Local<v8::String>());
+ info.GetReturnValue().Set(local_str);
}
-int32_t CFXJSE_Arguments::GetLength() const {
- return m_pInfo->Length();
+void DynPropGetterAdapter_MethodCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
+ FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ hCallBackInfo->GetAlignedPointerFromInternalField(0));
+ v8::Local<v8::String> hPropName =
+ hCallBackInfo->GetInternalField(1).As<v8::String>();
+ ASSERT(lpClass && !hPropName.IsEmpty());
+ v8::String::Utf8Value szPropName(hPropName);
+ CFX_ByteStringC szFxPropName = *szPropName;
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(info.This());
+ std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
+ if (!lpRetValue->DirectGetValue().IsEmpty())
+ info.GetReturnValue().Set(lpRetValue->DirectGetValue());
}
-std::unique_ptr<CFXJSE_Value> CFXJSE_Arguments::GetValue(int32_t index) const {
- std::unique_ptr<CFXJSE_Value> lpArgValue(
- new CFXJSE_Value(v8::Isolate::GetCurrent()));
- lpArgValue->ForceSetValue((*m_pInfo)[index]);
- return lpArgValue;
+void DynPropGetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* pValue) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType == FXJSE_ClassPropType_Property) {
+ if (lpClass->dynPropGetter)
+ lpClass->dynPropGetter(pObject, szPropName, pValue);
+ } else if (nPropType == FXJSE_ClassPropType_Method) {
+ if (lpClass->dynMethodCall && pValue) {
+ v8::Isolate* pIsolate = pValue->GetIsolate();
+ v8::HandleScope hscope(pIsolate);
+ v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate =
+ v8::ObjectTemplate::New(pIsolate);
+ hCallBackInfoTemplate->SetInternalFieldCount(2);
+ v8::Local<v8::Object> hCallBackInfo =
+ hCallBackInfoTemplate->NewInstance();
+ hCallBackInfo->SetAlignedPointerInInternalField(
+ 0, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClass));
+ hCallBackInfo->SetInternalField(
+ 1, v8::String::NewFromUtf8(
+ pIsolate, reinterpret_cast<const char*>(szPropName.raw_str()),
+ v8::String::kNormalString, szPropName.GetLength()));
+ pValue->ForceSetValue(
+ v8::Function::New(pValue->GetIsolate()->GetCurrentContext(),
+ DynPropGetterAdapter_MethodCallback, hCallBackInfo,
+ 0, v8::ConstructorBehavior::kThrow)
+ .ToLocalChecked());
+ }
+ }
}
-FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const {
- return (*m_pInfo)[index]->BooleanValue();
+void DynPropSetterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName,
+ CFXJSE_Value* pValue) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType != FXJSE_ClassPropType_Method) {
+ if (lpClass->dynPropSetter)
+ lpClass->dynPropSetter(pObject, szPropName, pValue);
+ }
}
-int32_t CFXJSE_Arguments::GetInt32(int32_t index) const {
- return static_cast<int32_t>((*m_pInfo)[index]->NumberValue());
+FX_BOOL DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, TRUE);
+ return nPropType != FXJSE_ClassPropType_None;
}
-FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const {
- return static_cast<FX_FLOAT>((*m_pInfo)[index]->NumberValue());
+FX_BOOL DynPropDeleterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass,
+ CFXJSE_Value* pObject,
+ const CFX_ByteStringC& szPropName) {
+ ASSERT(lpClass);
+ int32_t nPropType =
+ lpClass->dynPropTypeGetter == nullptr
+ ? FXJSE_ClassPropType_Property
+ : lpClass->dynPropTypeGetter(pObject, szPropName, FALSE);
+ if (nPropType != FXJSE_ClassPropType_Method) {
+ if (lpClass->dynPropDeleter)
+ return lpClass->dynPropDeleter(pObject, szPropName);
+ return nPropType == FXJSE_ClassPropType_Property ? FALSE : TRUE;
+ }
+ return FALSE;
}
-CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const {
- v8::Local<v8::String> hString = (*m_pInfo)[index]->ToString();
- v8::String::Utf8Value szStringVal(hString);
- return CFX_ByteString(*szStringVal);
+void NamedPropertyQueryCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Integer>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::HandleScope scope(pIsolate);
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ if (DynPropQueryAdapter(lpClass, lpThisValue.get(), szFxPropName)) {
+ info.GetReturnValue().Set(v8::DontDelete);
+ return;
+ }
+ const int32_t iV8Absent = 64;
+ info.GetReturnValue().Set(iV8Absent);
}
-CFXJSE_HostObject* CFXJSE_Arguments::GetObject(int32_t index,
- CFXJSE_Class* pClass) const {
- v8::Local<v8::Value> hValue = (*m_pInfo)[index];
- ASSERT(!hValue.IsEmpty());
- if (!hValue->IsObject())
- return nullptr;
- return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
+void NamedPropertyDeleterCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::HandleScope scope(pIsolate);
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ info.GetReturnValue().Set(
+ !!DynPropDeleterAdapter(lpClass, lpThisValue.get(), szFxPropName));
}
-CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
- return m_pRetValue;
+void NamedPropertyGetterCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+ std::unique_ptr<CFXJSE_Value> lpNewValue(new CFXJSE_Value(info.GetIsolate()));
+ DynPropGetterAdapter(lpClass, lpThisValue.get(), szFxPropName,
+ lpNewValue.get());
+ info.GetReturnValue().Set(lpNewValue->DirectGetValue());
}
-static void FXJSE_Context_GlobalObjToString(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
+void NamedPropertySetterCallback(
+ v8::Local<v8::Name> property,
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
info.Data().As<v8::External>()->Value());
- if (!lpClass) {
- return;
- }
- if (info.This() == info.Holder() && lpClass->name) {
- CFX_ByteString szStringVal;
- szStringVal.Format("[object %s]", lpClass->name);
- info.GetReturnValue().Set(v8::String::NewFromUtf8(
- info.GetIsolate(), szStringVal.c_str(), v8::String::kNormalString,
- szStringVal.GetLength()));
- } else {
- v8::Local<v8::String> local_str =
- info.This()
- ->ObjectProtoToString(info.GetIsolate()->GetCurrentContext())
- .FromMaybe(v8::Local<v8::String>());
- info.GetReturnValue().Set(local_str);
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ std::unique_ptr<CFXJSE_Value> lpThisValue(
+ new CFXJSE_Value(info.GetIsolate()));
+ lpThisValue->ForceSetValue(thisObject);
+
+ CFXJSE_Value* lpNewValue = new CFXJSE_Value(info.GetIsolate());
+ lpNewValue->ForceSetValue(value);
+ DynPropSetterAdapter(lpClass, lpThisValue.get(), szFxPropName, lpNewValue);
+ info.GetReturnValue().Set(value);
+}
+
+void NamedPropertyEnumeratorCallback(
+ const v8::PropertyCallbackInfo<v8::Array>& info) {
+ const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
+ info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum);
+ for (int i = 0; i < lpClass->propNum; i++) {
+ newArray->Set(
+ i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name));
}
+ info.GetReturnValue().Set(newArray);
}
+} // namespace
+
+// static
CFXJSE_Class* CFXJSE_Class::Create(
CFXJSE_Context* lpContext,
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition,
FX_BOOL bIsJSGlobal) {
- if (!lpContext || !lpClassDefinition) {
- return NULL;
- }
+ if (!lpContext || !lpClassDefinition)
+ return nullptr;
+
CFXJSE_Class* pClass =
GetClassFromContext(lpContext, lpClassDefinition->name);
- if (pClass) {
+ if (pClass)
return pClass;
- }
+
v8::Isolate* pIsolate = lpContext->m_pIsolate;
pClass = new CFXJSE_Class(lpContext);
pClass->m_szClassName = lpClassDefinition->name;
pClass->m_lpClassDefinition = lpClassDefinition;
CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New(
- pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper,
+ pIsolate, bIsJSGlobal ? 0 : V8ConstructorCallback_Wrapper,
v8::External::New(
pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
hFunctionTemplate->SetClassName(
@@ -218,12 +344,10 @@ CFXJSE_Class* CFXJSE_Class::Create(
hObjectTemplate->SetNativeDataProperty(
v8::String::NewFromUtf8(pIsolate,
lpClassDefinition->properties[i].name),
- lpClassDefinition->properties[i].getProc
- ? FXJSE_V8GetterCallback_Wrapper
- : NULL,
- lpClassDefinition->properties[i].setProc
- ? FXJSE_V8SetterCallback_Wrapper
- : NULL,
+ lpClassDefinition->properties[i].getProc ? V8GetterCallback_Wrapper
+ : nullptr,
+ lpClassDefinition->properties[i].setProc ? V8SetterCallback_Wrapper
+ : nullptr,
v8::External::New(pIsolate, const_cast<FXJSE_PROPERTY_DESCRIPTOR*>(
lpClassDefinition->properties + i)),
static_cast<v8::PropertyAttribute>(v8::DontDelete));
@@ -232,7 +356,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
if (lpClassDefinition->methNum) {
for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8FunctionCallback_Wrapper,
+ pIsolate, V8FunctionCallback_Wrapper,
v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION_DESCRIPTOR*>(
lpClassDefinition->methods + i)));
fun->RemovePrototype();
@@ -247,7 +371,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
hObjectTemplate->Set(
v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper,
+ pIsolate, V8ClassGlobalConstructorCallback_Wrapper,
v8::External::New(pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(
lpClassDefinition))),
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
@@ -257,7 +381,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
FXJSE_GetGlobalObjectFromContext(hLocalContext)
->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name),
v8::Function::New(
- pIsolate, FXJSE_V8ClassGlobalConstructorCallback_Wrapper,
+ pIsolate, V8ClassGlobalConstructorCallback_Wrapper,
v8::External::New(pIsolate,
const_cast<FXJSE_CLASS_DESCRIPTOR*>(
lpClassDefinition))));
@@ -265,7 +389,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
}
if (bIsJSGlobal) {
v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
- pIsolate, FXJSE_Context_GlobalObjToString,
+ pIsolate, Context_GlobalObjToString,
v8::External::New(
pIsolate, const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)));
fun->RemovePrototype();
@@ -276,11 +400,7 @@ CFXJSE_Class* CFXJSE_Class::Create(
return pClass;
}
-CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext)
- : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
-
-CFXJSE_Class::~CFXJSE_Class() {}
-
+// static
CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext,
const CFX_ByteStringC& szName) {
for (const auto& pClass : pContext->m_rgClasses) {
@@ -289,3 +409,25 @@ CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext,
}
return nullptr;
}
+
+// static
+void CFXJSE_Class::SetUpNamedPropHandler(
+ v8::Isolate* pIsolate,
+ v8::Local<v8::ObjectTemplate>& hObjectTemplate,
+ const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition) {
+ v8::NamedPropertyHandlerConfiguration configuration(
+ lpClassDefinition->dynPropGetter ? NamedPropertyGetterCallback : 0,
+ lpClassDefinition->dynPropSetter ? NamedPropertySetterCallback : 0,
+ lpClassDefinition->dynPropTypeGetter ? NamedPropertyQueryCallback : 0,
+ lpClassDefinition->dynPropDeleter ? NamedPropertyDeleterCallback : 0,
+ NamedPropertyEnumeratorCallback,
+ v8::External::New(pIsolate,
+ const_cast<FXJSE_CLASS_DESCRIPTOR*>(lpClassDefinition)),
+ v8::PropertyHandlerFlags::kNonMasking);
+ hObjectTemplate->SetHandler(configuration);
+}
+
+CFXJSE_Class::CFXJSE_Class(CFXJSE_Context* lpContext)
+ : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
+
+CFXJSE_Class::~CFXJSE_Class() {}
« no previous file with comments | « fxjs/cfxjse_arguments.cpp ('k') | fxjs/cfxjse_context.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698