summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_arguments.cpp11
-rw-r--r--fxjs/cfxjse_arguments.h9
-rw-r--r--fxjs/cfxjse_class.h7
-rw-r--r--fxjs/cfxjse_context.cpp2
4 files changed, 19 insertions, 10 deletions
diff --git a/fxjs/cfxjse_arguments.cpp b/fxjs/cfxjse_arguments.cpp
index f406ba34de..363f39ce11 100644
--- a/fxjs/cfxjse_arguments.cpp
+++ b/fxjs/cfxjse_arguments.cpp
@@ -10,6 +10,13 @@
#include "fxjs/cfxjse_value.h"
#include "third_party/base/ptr_util.h"
+CFXJSE_Arguments::CFXJSE_Arguments(
+ const v8::FunctionCallbackInfo<v8::Value>* pInfo,
+ CFXJSE_Value* pRetValue)
+ : m_pInfo(pInfo), m_pRetValue(pRetValue) {}
+
+CFXJSE_Arguments::~CFXJSE_Arguments() {}
+
int32_t CFXJSE_Arguments::GetLength() const {
return m_pInfo->Length();
}
@@ -47,6 +54,6 @@ CFXJSE_HostObject* CFXJSE_Arguments::GetObject(int32_t index,
return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
}
-CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
- return m_pRetValue;
+CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() const {
+ return m_pRetValue.Get();
}
diff --git a/fxjs/cfxjse_arguments.h b/fxjs/cfxjse_arguments.h
index beaf1525bb..9317d70898 100644
--- a/fxjs/cfxjse_arguments.h
+++ b/fxjs/cfxjse_arguments.h
@@ -9,14 +9,15 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fxjs/cfxjse_class.h"
#include "fxjs/fxjse.h"
class CFXJSE_Arguments {
public:
CFXJSE_Arguments(const v8::FunctionCallbackInfo<v8::Value>* pInfo,
- CFXJSE_Value* pRetValue)
- : m_pInfo(pInfo), m_pRetValue(pRetValue) {}
+ CFXJSE_Value* pRetValue);
+ ~CFXJSE_Arguments();
int32_t GetLength() const;
std::unique_ptr<CFXJSE_Value> GetValue(int32_t index) const;
@@ -26,11 +27,11 @@ class CFXJSE_Arguments {
CFX_ByteString GetUTF8String(int32_t index) const;
CFXJSE_HostObject* GetObject(int32_t index,
CFXJSE_Class* pClass = nullptr) const;
- CFXJSE_Value* GetReturnValue();
+ CFXJSE_Value* GetReturnValue() const;
private:
const v8::FunctionCallbackInfo<v8::Value>* m_pInfo;
- CFXJSE_Value* m_pRetValue;
+ CFX_UnownedPtr<CFXJSE_Value> m_pRetValue;
};
#endif // FXJS_CFXJSE_ARGUMENTS_H_
diff --git a/fxjs/cfxjse_class.h b/fxjs/cfxjse_class.h
index 04354941fa..c3a5c84777 100644
--- a/fxjs/cfxjse_class.h
+++ b/fxjs/cfxjse_class.h
@@ -7,6 +7,7 @@
#ifndef FXJS_CFXJSE_CLASS_H_
#define FXJS_CFXJSE_CLASS_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fxjs/fxjse.h"
#include "v8/include/v8.h"
@@ -27,13 +28,13 @@ class CFXJSE_Class {
explicit CFXJSE_Class(CFXJSE_Context* lpContext);
~CFXJSE_Class();
- CFXJSE_Context* GetContext() const { return m_pContext; }
+ CFXJSE_Context* GetContext() const { return m_pContext.Get(); }
v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
protected:
CFX_ByteString m_szClassName;
- const FXJSE_CLASS_DESCRIPTOR* m_lpClassDefinition;
- CFXJSE_Context* m_pContext;
+ CFX_UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_lpClassDefinition;
+ CFX_UnownedPtr<CFXJSE_Context> m_pContext;
v8::Global<v8::FunctionTemplate> m_hTemplate;
friend class CFXJSE_Context;
friend class CFXJSE_Value;
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp
index 8696cee42f..40882bac56 100644
--- a/fxjs/cfxjse_context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -68,7 +68,7 @@ class CFXJSE_ScopeUtil_IsolateHandleContext {
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
- CFXJSE_Context* m_context;
+ CFX_UnownedPtr<CFXJSE_Context> m_context;
CFXJSE_ScopeUtil_IsolateHandle m_parent;
v8::Context::Scope m_cscope;
};