14d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann// Copyright 2014 PDFium Authors. All rights reserved.
24d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann// Use of this source code is governed by a BSD-style license that can be
34d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann// found in the LICENSE file.
44d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
54d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
64d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
74d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#ifndef FXJS_FXJSE_H_
84d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#define FXJS_FXJSE_H_
94d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
104d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#include "core/fxcrt/fx_string.h"
114d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#include "core/fxcrt/fx_system.h"
124d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#include "v8/include/v8.h"
134d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
144d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannclass CFXJSE_Arguments;
154d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannclass CFXJSE_Value;
164d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
174d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann// C++ object which can be wrapped by CFXJSE_value.
184d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannclass CFXJSE_HostObject {
194d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann public:
204d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  virtual ~CFXJSE_HostObject() {}
214d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann};
224d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
234d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmanntypedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis,
244d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                   const CFX_ByteStringC& szFuncName,
254d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                   CFXJSE_Arguments& args);
264d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmanntypedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject,
274d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                   const CFX_ByteStringC& szPropName,
284d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                   CFXJSE_Value* pValue);
294d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmanntypedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject,
304d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                        const CFX_ByteStringC& szPropName,
314d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                        bool bQueryIn);
324d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmanntypedef bool (*FXJSE_PropDeleter)(CFXJSE_Value* pObject,
334d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann                                  const CFX_ByteStringC& szPropName);
344d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
354d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannenum FXJSE_ClassPropTypes {
364d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_ClassPropType_None,
374d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_ClassPropType_Property,
384d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_ClassPropType_Method
394d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann};
404d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
414d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannstruct FXJSE_FUNCTION_DESCRIPTOR {
424d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  const FX_CHAR* name;
434d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_FuncCallback callbackProc;
444d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann};
454d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
464d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannstruct FXJSE_PROPERTY_DESCRIPTOR {
474d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  const FX_CHAR* name;
484d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropAccessor getProc;
494d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropAccessor setProc;
504d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann};
514d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
524d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannstruct FXJSE_CLASS_DESCRIPTOR {
534d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  const FX_CHAR* name;
544d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_FuncCallback constructor;
554d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  const FXJSE_PROPERTY_DESCRIPTOR* properties;
564d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  const FXJSE_FUNCTION_DESCRIPTOR* methods;
574d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  int32_t propNum;
584d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  int32_t methNum;
594d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropTypeGetter dynPropTypeGetter;
604d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropAccessor dynPropGetter;
614d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropAccessor dynPropSetter;
624d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_PropDeleter dynPropDeleter;
634d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann  FXJSE_FuncCallback dynMethodCall;
644d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann};
654d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
664d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannvoid FXJSE_Initialize();
674d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannvoid FXJSE_Finalize();
684d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
694d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannv8::Isolate* FXJSE_Runtime_Create_Own();
704d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannvoid FXJSE_Runtime_Release(v8::Isolate* pIsolate);
714d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
724d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmannvoid FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message);
734d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann
744d3acf4ec42bf6e838f9060103aff98fbf170794Philip P. Moltmann#endif  // FXJS_FXJSE_H_
75