Merge to XFA: Fix ALL the include guards.
[pdfium.git] / fpdfsdk / include / javascript / JS_Define.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4  
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_
9
10 #include "../jsapi/fxjs_v8.h"
11 #include "resource.h"
12 #include "JS_Object.h"
13 #include "JS_Value.h"
14
15 struct JSConstSpec
16 {
17         const wchar_t* pName;
18         double number;
19         const wchar_t* string;
20         FX_BYTE t; //0:double 1:str
21 };
22
23 struct JSPropertySpec
24 {
25         const wchar_t* pName;
26         v8::AccessorGetterCallback pPropGet;
27         v8::AccessorSetterCallback pPropPut;
28 };
29
30 struct JSMethodSpec
31 {
32         const wchar_t* pName;
33         v8::FunctionCallback pMethodCall;
34 };
35
36 /* ====================================== PUBLIC DEFINE SPEC ============================================== */
37 #define JS_WIDESTRING(widestring) L###widestring
38
39 #define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class_Consts[] = {
40 #define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_name), pValue, L"", 0},
41 #define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_name), 0, JS_WIDESTRING(pValue), 1},
42 #define END_JS_STATIC_CONST() {0, 0, 0, 0}};
43
44 #define BEGIN_JS_STATIC_PROP(js_class_name) JSPropertySpec js_class_name::JS_Class_Properties[] = {
45 #define JS_STATIC_PROP_ENTRY(prop_name) {JS_WIDESTRING(prop_name), get_##prop_name##_static, set_##prop_name##_static},
46 #define END_JS_STATIC_PROP() {0, 0, 0}};
47
48 #define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Class_Methods[] = {
49 #define JS_STATIC_METHOD_ENTRY(method_name) {JS_WIDESTRING(method_name), method_name##_static},
50 #define END_JS_STATIC_METHOD() {0, 0}};
51
52 /* ======================================== PROP CALLBACK ============================================ */
53
54 template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)>
55 void JSPropGetter(const char* prop_name_string,
56                   const char* class_name_string,
57                   v8::Local<v8::String> property,
58                   const v8::PropertyCallbackInfo<v8::Value>& info) {
59   v8::Isolate* isolate = info.GetIsolate();
60   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
61   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
62   CJS_PropValue value(isolate);
63   value.StartGetting();
64   CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());
65   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
66   CFX_WideString sError;
67   if (!(pObj->*M)(pRuntimeContext, value, sError)) {
68     JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError));
69     return;
70   }
71   info.GetReturnValue().Set((v8::Local<v8::Value>)value);
72 }
73
74 template <class C, FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)>
75 void JSPropSetter(const char* prop_name_string,
76                   const char* class_name_string,
77                   v8::Local<v8::String> property,
78                   v8::Local<v8::Value> value,
79                   const v8::PropertyCallbackInfo<void>& info) {
80   v8::Isolate* isolate = info.GetIsolate();
81   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
82   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
83   CJS_PropValue propValue(CJS_Value(isolate, value, VT_unknown));
84   propValue.StartSetting();
85   CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());
86   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
87   CFX_WideString sError;
88   if (!(pObj->*M)(pRuntimeContext, propValue, sError)) {
89     JS_Error(isolate, JSFormatErrorString(class_name_string, prop_name_string, sError));
90   }
91 }
92
93 #define JS_STATIC_PROP(prop_name, class_name) \
94   static void get_##prop_name##_static( \
95       v8::Local<v8::String> property, \
96       const v8::PropertyCallbackInfo<v8::Value>& info) { \
97     JSPropGetter<class_name, &class_name::prop_name>( \
98         #prop_name, #class_name, property, info); \
99   } \
100   static void set_##prop_name##_static( \
101       v8::Local<v8::String> property, \
102       v8::Local<v8::Value> value, \
103       const v8::PropertyCallbackInfo<void>& info) { \
104     JSPropSetter<class_name, &class_name::prop_name>( \
105         #prop_name, #class_name, property, value, info); \
106   }
107
108 /* ========================================= METHOD CALLBACK =========================================== */
109
110 template <class C, FX_BOOL (C::*M)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
111 void JSMethod(const char* method_name_string,
112               const char* class_name_string,
113               const v8::FunctionCallbackInfo<v8::Value>& info) {
114   v8::Isolate* isolate = info.GetIsolate();
115   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
116   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
117   CJS_Parameters parameters;
118   for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) {
119     parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));
120   }
121   CJS_Value valueRes(isolate);
122   CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder());
123   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
124   CFX_WideString sError;
125   if (!(pObj->*M)(pRuntimeContext, parameters, valueRes, sError)) {
126     JS_Error(isolate, JSFormatErrorString(class_name_string, method_name_string, sError));
127     return;
128   }
129   info.GetReturnValue().Set(valueRes.ToV8Value());
130 }
131
132 #define JS_STATIC_METHOD(method_name, class_name) \
133   static void method_name##_static( \
134       const v8::FunctionCallbackInfo<v8::Value>& info) {    \
135     JSMethod<class_name, &class_name::method_name>( \
136         #method_name, #class_name, info); \
137   }
138
139 #define JS_SPECIAL_STATIC_METHOD(method_name, class_alternate, class_name) \
140   static void method_name##_static( \
141       const v8::FunctionCallbackInfo<v8::Value>& info) {    \
142     JSMethod<class_alternate, &class_alternate::method_name>( \
143         #method_name, #class_name, info); \
144   }
145
146 /* ===================================== JS CLASS =============================================== */
147
148 #define DECLARE_JS_CLASS(js_class_name) \
149         static void JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global);\
150         static void JSDestructor(JSFXObject obj);\
151         static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
152         static JSConstSpec JS_Class_Consts[];\
153         static JSPropertySpec JS_Class_Properties[];\
154         static JSMethodSpec     JS_Class_Methods[];\
155         static const wchar_t* m_pClassName
156
157 #define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
158 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
159 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject global)\
160 {\
161         CJS_Object* pObj = FX_NEW js_class_name(obj);\
162         pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\
163         JS_SetPrivate(NULL,obj,(void*)pObj); \
164         pObj->InitInstance(cc);\
165 }\
166 \
167 void js_class_name::JSDestructor(JSFXObject obj) \
168 {\
169         js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\
170         ASSERT(pObj != NULL);\
171         pObj->ExitInstance();\
172         delete pObj;\
173 }\
174 \
175 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
176 {\
177         int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor, 0);\
178         if (nObjDefnID >= 0)\
179         {\
180                 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; j<szj; j++)\
181                 {\
182                         if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_Properties[j].pName, JS_Class_Properties[j].pPropGet, JS_Class_Properties[j].pPropPut) < 0) return -1;\
183                 }\
184                 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1; k<szk; k++)\
185                 {\
186                         if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName, JS_Class_Methods[k].pMethodCall) < 0) return -1;\
187                 }\
188                 return nObjDefnID;\
189         }\
190         return -1;\
191 }
192
193 #define IMPLEMENT_JS_CLASS(js_class_name, class_name) IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name)
194
195 /* ======================================== CONST CLASS ============================================ */
196
197 #define DECLARE_JS_CLASS_CONST() \
198         static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
199         static JSConstSpec JS_Class_Consts[];\
200         static const wchar_t* m_pClassName
201
202 #define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
203 const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
204 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
205 {\
206         int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, NULL, NULL, 0);\
207         if (nObjDefnID >=0)\
208         {\
209                 for (int i=0, sz=sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1; i<sz; i++)\
210                 {\
211                         if (JS_Class_Consts[i].t == 0)\
212                         {\
213                                 if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_Class_Consts[i].pName, JS_NewNumber(pRuntime,JS_Class_Consts[i].number)) < 0) return -1;\
214                         }\
215                         else\
216                         {\
217                         if (JS_DefineObjConst(pRuntime, nObjDefnID, JS_Class_Consts[i].pName, JS_NewString(pRuntime,JS_Class_Consts[i].string)) < 0) return -1;\
218                         }\
219                 }\
220                 return nObjDefnID;\
221         }\
222         return -1;\
223 }
224
225 /* ===================================== SPECIAL JS CLASS =============================================== */
226
227 template <class Alt>
228 void JSSpecialPropQuery(const char *, v8::Local<v8::String> property,const v8::PropertyCallbackInfo<v8::Integer>& info) {
229   v8::Isolate* isolate = info.GetIsolate();
230   v8::String::Utf8Value utf8_value(property);
231   CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
232   CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
233   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
234   FX_BOOL bRet = pObj->QueryProperty(propname.c_str());
235   info.GetReturnValue().Set(bRet ? 4 : 0);
236 }
237
238 template <class Alt>
239 void JSSpecialPropGet(const char* class_name,
240                       v8::Local<v8::String> property,
241                       const v8::PropertyCallbackInfo<v8::Value>& info) {
242   v8::Isolate* isolate = info.GetIsolate();
243   v8::Local<v8::Context> context = isolate->GetCurrentContext();
244   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
245   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
246   CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
247   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
248   v8::String::Utf8Value utf8_value(property);
249   CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
250   CFX_WideString sError;
251   CJS_PropValue value(isolate);
252   value.StartGetting();
253   if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), value, sError)) {
254       JS_Error(isolate, JSFormatErrorString(class_name, "GetProperty", sError));
255       return;
256   }
257   info.GetReturnValue().Set((v8::Local<v8::Value>)value);
258 }
259
260 template <class Alt>
261 void JSSpecialPropPut(const char* class_name,
262                       v8::Local<v8::String> property,
263                       v8::Local<v8::Value> value,
264                       const v8::PropertyCallbackInfo<v8::Value>& info) {
265   v8::Isolate* isolate = info.GetIsolate();
266   v8::Local<v8::Context> context = isolate->GetCurrentContext();
267   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
268   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
269   CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
270   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
271   v8::String::Utf8Value utf8_value(property);
272   CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
273   CFX_WideString sError;
274   CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));
275   PropValue.StartSetting();
276   if (!pObj->DoProperty(pRuntimeContext, propname.c_str(), PropValue, sError)) {
277       JS_Error(isolate, JSFormatErrorString(class_name, "PutProperty", sError));
278   }
279 }
280
281 template <class Alt>
282 void JSSpecialPropDel(const char* class_name,
283                       v8::Local<v8::String> property,
284                       const v8::PropertyCallbackInfo<v8::Boolean>& info) {
285   v8::Isolate* isolate = info.GetIsolate();
286   v8::Local<v8::Context> context = isolate->GetCurrentContext();
287   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
288   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
289   CJS_Object* pJSObj = reinterpret_cast<CJS_Object*>(JS_GetPrivate(isolate, info.Holder()));
290   Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
291   v8::String::Utf8Value utf8_value(property);
292   CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());
293   CFX_WideString sError;
294   if (!pObj->DelProperty(pRuntimeContext, propname.c_str(), sError)) {
295     CFX_ByteString cbName;
296     cbName.Format("%s.%s", class_name, "DelProperty");
297     // Probably a missing call to JS_Error().
298   }
299 }
300
301 #define DECLARE_SPECIAL_JS_CLASS(js_class_name) \
302         static void JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject global);\
303         static void JSDestructor(JSFXObject obj);\
304         static JSConstSpec JS_Class_Consts[];\
305         static JSPropertySpec JS_Class_Properties[];\
306         static JSMethodSpec     JS_Class_Methods[];\
307         static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\
308         static const wchar_t* m_pClassName;\
309         static void queryprop_##js_class_name##_static(v8::Local<v8::String> property,const v8::PropertyCallbackInfo<v8::Integer>& info);\
310         static void getprop_##js_class_name##_static(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info);\
311         static void putprop_##js_class_name##_static(v8::Local<v8::String> property,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info);\
312         static void delprop_##js_class_name##_static(v8::Local<v8::String> property,const v8::PropertyCallbackInfo<v8::Boolean>& info)
313
314 #define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \
315 const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\
316 void js_class_name::queryprop_##js_class_name##_static(v8::Local<v8::String> property,const v8::PropertyCallbackInfo<v8::Integer>& info) { \
317   JSSpecialPropQuery<class_alternate>(#class_name, property, info);     \
318 }\
319 void js_class_name::getprop_##js_class_name##_static(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { \
320   JSSpecialPropGet<class_alternate>(#class_name, property, info); \
321 }                                                                       \
322 void js_class_name::putprop_##js_class_name##_static(v8::Local<v8::String> property,v8::Local<v8::Value> value,const v8::PropertyCallbackInfo<v8::Value>& info) {\
323   JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \
324 }\
325 void js_class_name::delprop_##js_class_name##_static(v8::Local<v8::String> property,const v8::PropertyCallbackInfo<v8::Boolean>& info) { \
326   JSSpecialPropDel<class_alternate>(#class_name, property, info); \
327 } \
328 void js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject  obj,JSFXObject  global)\
329 {\
330         CJS_Object* pObj = FX_NEW js_class_name(obj);\
331         pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\
332         JS_SetPrivate(NULL,obj, (void*)pObj); \
333         pObj->InitInstance(cc);\
334 }\
335 \
336 void js_class_name::JSDestructor(JSFXObject obj) \
337 {\
338         js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\
339         ASSERT(pObj != NULL);\
340         pObj->ExitInstance();\
341         delete pObj;\
342 }\
343 \
344 int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\
345 {\
346 \
347         int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor, 0);\
348 \
349         if (nObjDefnID >= 0)\
350         {\
351                 for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; j<szj; j++)\
352                 {\
353                         if (JS_DefineObjProperty(pRuntime, nObjDefnID, JS_Class_Properties[j].pName, JS_Class_Properties[j].pPropGet,JS_Class_Properties[j].pPropPut)<0)return -1;\
354                 }\
355 \
356                 for (int k=0, szk=sizeof(JS_Class_Methods)/sizeof(JSMethodSpec)-1; k<szk; k++)\
357                 {\
358                         if (JS_DefineObjMethod(pRuntime, nObjDefnID,JS_Class_Methods[k].pName,JS_Class_Methods[k].pMethodCall)<0)return -1;\
359                 }\
360                 if (JS_DefineObjAllProperties(pRuntime, nObjDefnID, js_class_name::queryprop_##js_class_name##_static, js_class_name::getprop_##js_class_name##_static,js_class_name::putprop_##js_class_name##_static,js_class_name::delprop_##js_class_name##_static)<0) return -1;\
361 \
362                 return nObjDefnID;\
363         }\
364 \
365         return -1;\
366 }
367
368 /* ======================================== GLOBAL METHODS ============================================ */
369
370 template <FX_BOOL (*F)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
371 void JSGlobalFunc(const char *func_name_string,
372                   const v8::FunctionCallbackInfo<v8::Value>& info) {
373   v8::Isolate* isolate = info.GetIsolate();
374   IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);
375   IFXJS_Context* pRuntimeContext = pRuntime->GetCurrentContext();
376   CJS_Parameters parameters;
377   for (unsigned int i = 0; i<(unsigned int)info.Length(); i++) {
378     parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));
379   }
380   CJS_Value valueRes(isolate);
381   CFX_WideString sError;
382   if (!(*F)(pRuntimeContext, parameters, valueRes, sError)) {
383     JS_Error(isolate, JSFormatErrorString(func_name_string, nullptr, sError));
384     return;
385   }
386   info.GetReturnValue().Set(valueRes.ToV8Value());
387 }
388
389 #define JS_STATIC_GLOBAL_FUN(fun_name) \
390   static void fun_name##_static(const v8::FunctionCallbackInfo<v8::Value>& info) { \
391     JSGlobalFunc<fun_name>(#fun_name, info); \
392   }
393
394 #define JS_STATIC_DECLARE_GLOBAL_FUN() \
395 static JSMethodSpec     global_methods[]; \
396 static int Init(IJS_Runtime* pRuntime)
397
398 #define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \
399 JSMethodSpec js_class_name::global_methods[] = {
400
401 #define JS_STATIC_GLOBAL_FUN_ENTRY(method_name) JS_STATIC_METHOD_ENTRY(method_name)
402
403 #define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD()
404
405 #define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
406 int js_class_name::Init(IJS_Runtime* pRuntime)\
407 {\
408         for (int i=0, sz=sizeof(js_class_name::global_methods)/sizeof(JSMethodSpec)-1; i<sz; i++)\
409         {\
410                 if (JS_DefineGlobalMethod(pRuntime,\
411                                 js_class_name::global_methods[i].pName,\
412                                 js_class_name::global_methods[i].pMethodCall\
413                                 ) < 0\
414                         )return -1;\
415         }\
416         return 0;\
417 }
418
419 /* ======================================== GLOBAL CONSTS ============================================ */
420 #define DEFINE_GLOBAL_CONST(pRuntime, const_name , const_value)\
421 if (JS_DefineGlobalConst(pRuntime,JS_WIDESTRING(const_name),JS_NewString(pRuntime,JS_WIDESTRING(const_value)))) return -1
422
423 /* ======================================== GLOBAL ARRAYS ============================================ */
424
425 #define DEFINE_GLOBAL_ARRAY(pRuntime)\
426 int size = FX_ArraySize(ArrayContent);\
427 \
428 CJS_Array array(pRuntime);\
429 for (int i=0; i<size; i++) array.SetElement(i,CJS_Value(pRuntime,ArrayContent[i]));\
430 \
431 CJS_PropValue prop(pRuntime);\
432 prop << array;\
433 if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToV8Value()) < 0)\
434         return -1
435
436 /* ============================================================ */
437
438 #define VALUE_NAME_STRING               L"string"
439 #define VALUE_NAME_NUMBER               L"number"
440 #define VALUE_NAME_BOOLEAN              L"boolean"
441 #define VALUE_NAME_DATE                 L"date"
442 #define VALUE_NAME_OBJECT               L"object"
443 #define VALUE_NAME_FXOBJ                L"fxobj"
444 #define VALUE_NAME_NULL                 L"null"
445 #define VALUE_NAME_UNDEFINED    L"undefined"
446
447 FXJSVALUETYPE GET_VALUE_TYPE(v8::Local<v8::Value> p);
448
449 #endif  // FPDFSDK_INCLUDE_JAVASCRIPT_JS_DEFINE_H_