PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
jscript.h
Go to the documentation of this file.
1 /*
2  * v8script.h
3  *
4  * Interface library for V8 Javascript interpreter
5  *
6  * Portable Tools Library
7  *
8  * Copyright (C) 2012 by Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Tools Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): Craig Southeren
25  */
26 
27 #ifndef PTLIB_V8SCRIPT_H
28 #define PTLIB_V8SCRIPT_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <ptlib.h>
35 
36 #if P_V8
37 
38 #include <ptclib/script.h>
39 #include <ptclib/vartype.h>
40 
41 
43 
46 class PJavaScript : public PScriptLanguage
47 {
48  PCLASSINFO(PJavaScript, PScriptLanguage)
49 
50  public:
55  PJavaScript();
56 
58  ~PJavaScript();
60 
63  static PString LanguageName();
65 
67  virtual PString GetLanguageName() const;
68 
70  virtual bool IsInitialised() const;
71 
74  virtual bool LoadFile(
75  const PFilePath & filename
76  );
77 
80  virtual bool LoadText(
81  const PString & text
82  );
83 
90  virtual bool Run(
91  const char * script = NULL
92  );
93 
94 
98  virtual bool CreateComposite(
99  const PString & name
100  );
101 
105  virtual bool GetVar(
106  const PString & name,
107  PVarType & var
108  );
109 
113  virtual bool SetVar(
114  const PString & name,
115  const PVarType & var
116  );
117 
121  bool GetBoolean(
122  const PString & name
123  );
124 
128  bool SetBoolean(
129  const PString & name,
130  bool value
131  );
132 
136  int GetInteger(
137  const PString & name
138  );
139 
143  bool SetInteger(
144  const PString & name,
145  int value
146  );
147 
151  double GetNumber(
152  const PString & name
153  );
154 
158  bool SetNumber(
159  const PString & name,
160  double value
161  );
162 
166  PString GetString(
167  const PString & name
168  );
169 
173  bool SetString(
174  const PString & name,
175  const char * value
176  );
177 
180  virtual bool ReleaseVariable(
181  const PString & name
182  );
183 
210  bool Call(
211  const PString & name,
212  const char * sigString = NULL,
213  ...
214  );
215  bool Call(
216  const PString & name,
217  Signature & signature
218  );
219 
220 
224  bool SetFunction(
225  const PString & name,
226  const FunctionNotifier & func
227  );
229 
230  protected:
231  struct Private;
232  Private * m_private;
233  PString m_resultText;
234 };
235 
236 
237 #endif // P_V8
238 
239 #endif // PTLIB_V8SCRIPT_H
240 
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
The character string class.
Definition: pstring.h:108
A wrapper around a scripting language instance.
Definition: script.h:43