summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxjse/cfxjse_arguments.h8
-rw-r--r--xfa/fxjse/class.cpp52
-rw-r--r--xfa/fxjse/class.h18
-rw-r--r--xfa/fxjse/dynprop.cpp5
4 files changed, 32 insertions, 51 deletions
diff --git a/xfa/fxjse/cfxjse_arguments.h b/xfa/fxjse/cfxjse_arguments.h
index 48a3bfff8f..3028d39def 100644
--- a/xfa/fxjse/cfxjse_arguments.h
+++ b/xfa/fxjse/cfxjse_arguments.h
@@ -11,6 +11,10 @@
class CFXJSE_Arguments {
public:
+ CFXJSE_Arguments(const v8::FunctionCallbackInfo<v8::Value>* pInfo,
+ CFXJSE_Value* pRetValue)
+ : m_pInfo(pInfo), m_pRetValue(pRetValue) {}
+
v8::Isolate* GetRuntime() const;
int32_t GetLength() const;
std::unique_ptr<CFXJSE_Value> GetValue(int32_t index) const;
@@ -20,6 +24,10 @@ class CFXJSE_Arguments {
CFX_ByteString GetUTF8String(int32_t index) const;
void* GetObject(int32_t index, CFXJSE_Class* pClass = nullptr) const;
CFXJSE_Value* GetReturnValue();
+
+ private:
+ const v8::FunctionCallbackInfo<v8::Value>* m_pInfo;
+ CFXJSE_Value* m_pRetValue;
};
#endif // XFA_FXJSE_CFXJSE_ARGUMENTS_H_
diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp
index bb6f0e1fe4..e7e061b5a3 100644
--- a/xfa/fxjse/class.cpp
+++ b/xfa/fxjse/class.cpp
@@ -42,9 +42,8 @@ static void FXJSE_V8FunctionCallback_Wrapper(
new CFXJSE_Value(info.GetIsolate()));
lpThisValue->ForceSetValue(info.This());
std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_ArgumentsImpl impl = {&info, lpRetValue.get()};
- lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName,
- reinterpret_cast<CFXJSE_Arguments&>(impl));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpFunctionInfo->callbackProc(lpThisValue.get(), szFunctionName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty()) {
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
}
@@ -63,9 +62,8 @@ static void FXJSE_V8ClassGlobalConstructorCallback_Wrapper(
new CFXJSE_Value(info.GetIsolate()));
lpThisValue->ForceSetValue(info.This());
std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_ArgumentsImpl impl = {&info, lpRetValue.get()};
- lpClassDefinition->constructor(lpThisValue.get(), szFunctionName,
- reinterpret_cast<CFXJSE_Arguments&>(impl));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty()) {
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
}
@@ -123,68 +121,50 @@ static void FXJSE_V8ConstructorCallback_Wrapper(
}
v8::Isolate* CFXJSE_Arguments::GetRuntime() const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return lpArguments->m_pRetValue->GetIsolate();
+ return m_pRetValue->GetIsolate();
}
int32_t CFXJSE_Arguments::GetLength() const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return lpArguments->m_pInfo->Length();
+ return m_pInfo->Length();
}
std::unique_ptr<CFXJSE_Value> CFXJSE_Arguments::GetValue(int32_t index) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
std::unique_ptr<CFXJSE_Value> lpArgValue(
new CFXJSE_Value(v8::Isolate::GetCurrent()));
- lpArgValue->ForceSetValue((*lpArguments->m_pInfo)[index]);
+ lpArgValue->ForceSetValue((*m_pInfo)[index]);
return lpArgValue;
}
FX_BOOL CFXJSE_Arguments::GetBoolean(int32_t index) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return (*lpArguments->m_pInfo)[index]->BooleanValue();
+ return (*m_pInfo)[index]->BooleanValue();
}
int32_t CFXJSE_Arguments::GetInt32(int32_t index) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return static_cast<int32_t>((*lpArguments->m_pInfo)[index]->NumberValue());
+ return static_cast<int32_t>((*m_pInfo)[index]->NumberValue());
}
FX_FLOAT CFXJSE_Arguments::GetFloat(int32_t index) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return static_cast<FX_FLOAT>((*lpArguments->m_pInfo)[index]->NumberValue());
+ return static_cast<FX_FLOAT>((*m_pInfo)[index]->NumberValue());
}
CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- v8::Local<v8::String> hString = (*lpArguments->m_pInfo)[index]->ToString();
+ v8::Local<v8::String> hString = (*m_pInfo)[index]->ToString();
v8::String::Utf8Value szStringVal(hString);
return CFX_ByteString(*szStringVal);
}
void* CFXJSE_Arguments::GetObject(int32_t index, CFXJSE_Class* pClass) const {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- v8::Local<v8::Value> hValue = (*lpArguments->m_pInfo)[index];
+ v8::Local<v8::Value> hValue = (*m_pInfo)[index];
ASSERT(!hValue.IsEmpty());
- if (!hValue->IsObject()) {
- return NULL;
- }
+ if (!hValue->IsObject())
+ return nullptr;
return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
}
CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
- const CFXJSE_ArgumentsImpl* lpArguments =
- reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this);
- return lpArguments->m_pRetValue;
+ return m_pRetValue;
}
+
static void FXJSE_Context_GlobalObjToString(
const v8::FunctionCallbackInfo<v8::Value>& info) {
const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast<FXJSE_CLASS_DESCRIPTOR*>(
diff --git a/xfa/fxjse/class.h b/xfa/fxjse/class.h
index 344adf4a47..a28d36801e 100644
--- a/xfa/fxjse/class.h
+++ b/xfa/fxjse/class.h
@@ -15,14 +15,6 @@ class CFXJSE_Context;
class CFXJSE_Value;
class CFXJSE_Class {
- protected:
- CFXJSE_Class(CFXJSE_Context* lpContext)
- : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
-
- public:
- inline CFXJSE_Context* GetContext() { return m_pContext; }
- inline v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
-
public:
static CFXJSE_Class* Create(CFXJSE_Context* pContext,
const FXJSE_CLASS_DESCRIPTOR* lpClassDefintion,
@@ -34,7 +26,13 @@ class CFXJSE_Class {
v8::Local<v8::ObjectTemplate>& hObjectTemplate,
const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition);
+ CFXJSE_Context* GetContext() { return m_pContext; }
+ v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
+
protected:
+ explicit CFXJSE_Class(CFXJSE_Context* lpContext)
+ : m_lpClassDefinition(nullptr), m_pContext(lpContext) {}
+
CFX_ByteString m_szClassName;
const FXJSE_CLASS_DESCRIPTOR* m_lpClassDefinition;
CFXJSE_Context* m_pContext;
@@ -42,9 +40,5 @@ class CFXJSE_Class {
friend class CFXJSE_Context;
friend class CFXJSE_Value;
};
-struct CFXJSE_ArgumentsImpl {
- const v8::FunctionCallbackInfo<v8::Value>* m_pInfo;
- CFXJSE_Value* m_pRetValue;
-};
#endif // XFA_FXJSE_CLASS_H_
diff --git a/xfa/fxjse/dynprop.cpp b/xfa/fxjse/dynprop.cpp
index 6e98d824e3..946fe42c1b 100644
--- a/xfa/fxjse/dynprop.cpp
+++ b/xfa/fxjse/dynprop.cpp
@@ -22,9 +22,8 @@ static void FXJSE_DynPropGetterAdapter_MethodCallback(
new CFXJSE_Value(info.GetIsolate()));
lpThisValue->ForceSetValue(info.This());
std::unique_ptr<CFXJSE_Value> lpRetValue(new CFXJSE_Value(info.GetIsolate()));
- CFXJSE_ArgumentsImpl impl = {&info, lpRetValue.get()};
- lpClass->dynMethodCall(lpThisValue.get(), szFxPropName,
- reinterpret_cast<CFXJSE_Arguments&>(impl));
+ CFXJSE_Arguments impl(&info, lpRetValue.get());
+ lpClass->dynMethodCall(lpThisValue.get(), szFxPropName, impl);
if (!lpRetValue->DirectGetValue().IsEmpty()) {
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
}