diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2012-09-06 15:10:26 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2012-09-18 14:59:55 +0100 |
commit | e6ed164c3935160d3d42aa15017abe2863bbdaac (patch) | |
tree | f8f3c4dd1b61b55d41c7300a1e3c2b67f58671f5 /pdf/pdf_jsimp_v8.cpp | |
parent | c06c3f6183eb6e7955749c060abe99e0b91ea1f7 (diff) | |
download | mupdf-e6ed164c3935160d3d42aa15017abe2863bbdaac.tar.xz |
Forms: support property access in the javascript engine
Diffstat (limited to 'pdf/pdf_jsimp_v8.cpp')
-rw-r--r-- | pdf/pdf_jsimp_v8.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pdf/pdf_jsimp_v8.cpp b/pdf/pdf_jsimp_v8.cpp index 78a14eac..47fab860 100644 --- a/pdf/pdf_jsimp_v8.cpp +++ b/pdf/pdf_jsimp_v8.cpp @@ -411,17 +411,23 @@ extern "C" const char *pdf_jsimp_to_number_cpp(pdf_jsimp *imp, pdf_jsimp_obj *ob extern "C" const char *pdf_jsimp_array_len_cpp(pdf_jsimp *imp, pdf_jsimp_obj *obj, int *len) { - Local<Value> val = reinterpret_cast<PDFJSImpObject *>(obj)->toValue()->ToObject(); - Local<Array> arr = Local<Array>::Cast(val); + Local<Object> jsobj = reinterpret_cast<PDFJSImpObject *>(obj)->toValue()->ToObject(); + Local<Array> arr = Local<Array>::Cast(jsobj); *len = arr->Length(); return NULL; } extern "C" const char *pdf_jsimp_array_item_cpp(pdf_jsimp *imp, pdf_jsimp_obj *obj, int i, pdf_jsimp_obj **item) { - Local<Value> val = reinterpret_cast<PDFJSImpObject *>(obj)->toValue()->ToObject(); - Local<Array> arr = Local<Array>::Cast(val); - *item = reinterpret_cast<pdf_jsimp_obj *>(new PDFJSImpObject(arr->Get(Number::New(i)))); + Local<Object> jsobj = reinterpret_cast<PDFJSImpObject *>(obj)->toValue()->ToObject(); + *item = reinterpret_cast<pdf_jsimp_obj *>(new PDFJSImpObject(jsobj->Get(Number::New(i)))); + return NULL; +} + +extern "C" const char *pdf_jsimp_property_cpp(pdf_jsimp *imp, pdf_jsimp_obj *obj, char *prop, pdf_jsimp_obj **pobj) +{ + Local<Object> jsobj = reinterpret_cast<PDFJSImpObject *>(obj)->toValue()->ToObject(); + *pobj = reinterpret_cast<pdf_jsimp_obj *>(new PDFJSImpObject(jsobj->Get(String::New(prop)))); return NULL; } |