1 // Copyright 2017 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 FXJS_CJX_DEFINE_H_
8 #define FXJS_CJX_DEFINE_H_
9
10 #include <vector>
11
12 #include "fxjs/cjs_return.h"
13 #include "fxjs/cjs_v8.h"
14
15 template <class C,
16 CJS_Return (C::*M)(CJS_V8* runtime,
17 const std::vector<v8::Local<v8::Value>>& params)>
JSMethod(C * node,CJS_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)18 CJS_Return JSMethod(C* node,
19 CJS_V8* runtime,
20 const std::vector<v8::Local<v8::Value>>& params) {
21 return (node->*M)(runtime, params);
22 }
23
24 #define JS_METHOD(method_name, class_name) \
25 static CJS_Return method_name##_static( \
26 CJX_Object* node, CJS_V8* runtime, \
27 const std::vector<v8::Local<v8::Value>>& params) { \
28 return JSMethod<class_name, &class_name::method_name>( \
29 static_cast<class_name*>(node), runtime, params); \
30 } \
31 CJS_Return method_name(CJS_V8* runtime, \
32 const std::vector<v8::Local<v8::Value>>& params)
33
34 #define JS_PROP(prop_name) \
35 void prop_name(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute)
36
37 #endif // FXJS_CJX_DEFINE_H_
38