summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/fxjs_v8.cpp21
-rw-r--r--fxjs/fxjs_v8_embeddertest.cpp3
-rw-r--r--fxjs/include/fxjs_v8.h15
3 files changed, 26 insertions, 13 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index d161af6281..92207fdd47 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -596,7 +596,7 @@ v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
.ToLocalChecked();
}
-v8::Local<v8::Value> FXJS_GetObjectElement(
+v8::Local<v8::Value> FXJS_GetObjectProperty(
v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
const CFX_WideString& wsPropertyName) {
@@ -610,14 +610,23 @@ v8::Local<v8::Value> FXJS_GetObjectElement(
return val;
}
-v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj) {
+std::vector<CFX_WideString> FXJS_GetObjectPropertyNames(
+ v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj) {
if (pObj.IsEmpty())
- return v8::Local<v8::Array>();
+ return std::vector<CFX_WideString>();
+
v8::Local<v8::Array> val;
if (!pObj->GetPropertyNames(pIsolate->GetCurrentContext()).ToLocal(&val))
- return v8::Local<v8::Array>();
- return val;
+ return std::vector<CFX_WideString>();
+
+ std::vector<CFX_WideString> result;
+ for (uint32_t i = 0; i < val->Length(); ++i) {
+ result.push_back(FXJS_ToString(
+ pIsolate, val->Get(pIsolate->GetCurrentContext(), i).ToLocalChecked()));
+ }
+
+ return result;
}
void FXJS_PutObjectString(v8::Isolate* pIsolate,
diff --git a/fxjs/fxjs_v8_embeddertest.cpp b/fxjs/fxjs_v8_embeddertest.cpp
index b33ddca32d..71b004c144 100644
--- a/fxjs/fxjs_v8_embeddertest.cpp
+++ b/fxjs/fxjs_v8_embeddertest.cpp
@@ -26,7 +26,8 @@ class FXJSV8EmbedderTest : public JSEmbedderTest {
}
void CheckAssignmentInCurrentContext(double expected) {
v8::Local<v8::Object> This = FXJS_GetThisObj(isolate());
- v8::Local<v8::Value> fred = FXJS_GetObjectElement(isolate(), This, L"fred");
+ v8::Local<v8::Value> fred =
+ FXJS_GetObjectProperty(isolate(), This, L"fred");
EXPECT_TRUE(fred->IsNumber());
EXPECT_EQ(expected, fred->ToNumber(isolate()->GetCurrentContext())
.ToLocalChecked()
diff --git a/fxjs/include/fxjs_v8.h b/fxjs/include/fxjs_v8.h
index cd4d7c4dab..5e12b082be 100644
--- a/fxjs/include/fxjs_v8.h
+++ b/fxjs/include/fxjs_v8.h
@@ -211,16 +211,19 @@ void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message);
v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
const CFX_WideString& wsPropertyName);
-v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj,
- const CFX_WideString& PropertyName);
-v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
- v8::Local<v8::Object> pObj);
+
+std::vector<CFX_WideString> FXJS_GetObjectPropertyNames(
+ v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj);
+v8::Local<v8::Value> FXJS_GetObjectProperty(v8::Isolate* pIsolate,
+ v8::Local<v8::Object> pObj,
+ const CFX_WideString& PropertyName);
+
+unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate,
v8::Local<v8::Array> pArray,
unsigned index);
-unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
void FXJS_PutObjectString(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
const CFX_WideString& wsPropertyName,