My favorites | Sign in
v8
Project Home Downloads Wiki Issues Source Code Search
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 195 attachment: jav8.i (9.6 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
%include "stl.i"
%include "util/stdint_mod.i"
%include "std_string.i"
%include "various.i"
%include "typemaps.i"
%include "cpointer.i"
%javaconst(0);
%include "enumsimple.swg"

//Expose goodies in proxy classes
%typemap(javabody) SWIGTYPE %{
private long swigCPtr;
protected boolean swigCMemOwn;

public $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}

public static long getCPtr($javaclassname obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

public long getCPtr() {
return swigCPtr;
}
%}

//And in type wrappers
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
private long swigCPtr;

public $javaclassname(long cPtr, boolean bFutureUse) {
swigCPtr = cPtr;
}

protected $javaclassname() {
swigCPtr = 0;
}

public static long getCPtr($javaclassname obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

public long getCPtr() {
return swigCPtr;
}
%}

%typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "import org.cretz.jav8.JaV8Pointable;"
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "JaV8Pointable"

%module(directors="1") JaV8
%{
#define USING_V8_SHARED 1
#include "v8.h"
using namespace v8;
%}

//Nested classes: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nested_classes
//#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS

%rename (V8ContextScope) v8::Context::Scope;
//Private
//%rename (V8HandleScopeData) v8::HandleScope::Data;
%rename (V8StringAsciiValue) v8::String::AsciiValue;
%rename (V8StringExternalAsciiStringResource) v8::String::ExternalAsciiStringResource;
%rename (V8StringExternalStringResource) v8::String::ExternalStringResource;
%rename (V8StringExternalStringResourceBase) v8::String::ExternalStringResourceBase;
%rename (V8StringUtf8Value) v8::String::Utf8Value;
%rename (V8StringValue) v8::String::Value;

namespace v8 {
namespace Context {
class Scope {
public:
inline Scope(Handle<Context> context) : context_(context) {
context_->Enter();
}
inline ~Scope() { context_->Exit(); }
private:
Handle<Context> context_;
};
}
/* Private
namespace HandleScope {
class Data {
public:
int extensions;
internal::Object** next;
internal::Object** limit;
inline void Initialize() {
extensions = -1;
next = limit = NULL;
}
};
}
*/
namespace String {
class AsciiValue {
public:
explicit AsciiValue(Handle<v8::Value> obj);
~AsciiValue();
char* operator*() { return str_; }
const char* operator*() const { return str_; }
int length() const { return length_; }
private:
char* str_;
int length_;

// Disallow copying and assigning.
AsciiValue(const AsciiValue&);
void operator=(const AsciiValue&);
};
class ExternalStringResourceBase {
public:
virtual ~ExternalStringResourceBase() {}
protected:
ExternalStringResourceBase() {}
private:
// Disallow copying and assigning.
ExternalStringResourceBase(const ExternalStringResourceBase&){}
void operator=(const ExternalStringResourceBase&){}
};
class ExternalAsciiStringResource : public ExternalStringResourceBase {
public:
/**
* Override the destructor to manage the life cycle of the underlying
* buffer.
*/
virtual ~ExternalAsciiStringResource() {}
/** The string data from the underlying buffer.*/
virtual const char* data() const = 0;
/** The number of ascii characters in the string.*/
virtual size_t length() const = 0;
protected:
ExternalAsciiStringResource() {}
};
class ExternalStringResource : public ExternalStringResourceBase {
public:
/**
* Override the destructor to manage the life cycle of the underlying
* buffer.
*/
virtual ~ExternalStringResource() {}
/** The string data from the underlying buffer.*/
virtual const uint16_t* data() const = 0;
/** The length of the string. That is, the number of two-byte characters.*/
virtual size_t length() const = 0;
protected:
ExternalStringResource() {}
};
class Utf8Value {
public:
explicit Utf8Value(Handle<v8::Value> obj);
~Utf8Value();
char* operator*() { return str_; }
const char* operator*() const { return str_; }
int length() const { return length_; }
private:
char* str_;
int length_;

// Disallow copying and assigning.
Utf8Value(const Utf8Value&);
void operator=(const Utf8Value&);
};
class Value {
public:
explicit Value(Handle<v8::Value> obj);
~Value();
uint16_t* operator*() { return str_; }
const uint16_t* operator*() const { return str_; }
int length() const { return length_; }
private:
uint16_t* str_;
int length_;

// Disallow copying and assigning.
Value(const Value&);
void operator=(const Value&);
};
}
}

//Classes
%rename (V8AccessControl) v8::AccessControl;
%rename (V8AccessorInfo) v8::AccessorInfo;
%rename (V8AccessType) v8::AccessType;
%rename (V8Arguments) v8::Arguments;
%rename (V8Array) v8::Array;
%rename (V8Boolean) v8::Boolean;
%rename (V8Context) v8::Context;
%rename (V8Data) v8::Data;
%rename (V8Date) v8::Date;
%rename (V8DeclareExtension) v8::DeclareExtension;
%rename (V8Exception) v8::Exception;
%rename (V8Extension) v8::Extension;
%rename (V8ExtensionConfiguration) v8::ExtensionConfiguration;
%rename (V8External) v8::External;
%rename (V8ExternalArrayType) v8::ExternalArrayType;
%rename (V8Function) v8::Function;
%rename (V8FunctionTemplate) v8::FunctionTemplate;
%rename (V8HandleScope) v8::HandleScope;
%ignore ~HandleScope;
%rename (V8HeapStatistics) v8::HeapStatistics;
%rename (V8Int32) v8::Int32;
%rename (V8Integer) v8::Integer;
//%rename (V8Internals) v8::internal::Internals;
%ignore v8::internal::Internals;
%rename (V8Locker) v8::Locker;
%rename (V8Message) v8::Message;
%rename (V8Number) v8::Number;
%rename (V8Object) v8::Object;
%rename (V8ObjectTemplate) v8::ObjectTemplate;
%rename (V8Primitive) v8::Primitive;
%rename (V8ProfileModules) v8::ProfilerModules;
%rename (V8PropertyAttribute) v8::PropertyAttribute;
%rename (V8ResourceConstraints) v8::ResourceConstraints;
%rename (V8Script) v8::Script;
%rename (V8ScriptData) v8::ScriptData;
%rename (V8ScriptOrigin) v8::ScriptOrigin;
%rename (V8Signature) v8::Signature;
%rename (V8String) v8::String;
%rename (V8Template) v8::Template;
%rename (V8TryCatch) v8::TryCatch;
%rename (V8TypeSwitch) v8::TypeSwitch;
%rename (V8Uint32) v8::Uint32;
%rename (V8Unblocker) v8::Unlocker;
%rename (V8Value) v8::Value;

//Ambiguities
%rename (NewArray) v8::Array::New;
%rename (Int32Value) v8::Int32::Value;
%rename (IntegerValue) v8::Integer::Value;
%rename (Uint32Value) v8::Uint32::Value;
%rename (ArrayCast) v8::Array::Cast;
%rename (FunctionCast) v8::Function::Cast;
%rename (ObjectCast) v8::Object::Cast;
%rename (HandleCast) v8::Handle::Cast;
%rename (LocalCast) v8::Local::Cast;

//String arrays
%apply char **STRING_ARRAY { char** argv };
%apply char **STRING_ARRAY { char** deps };
%apply char **STRING_ARRAY { char** names };
//TODO: string return values

//Pointers
%pointer_class(int, V8IntPointer);
//%pointer_class(int32_t, V8Int32Pointer);
//%pointer_class(uint_t, V8UIntPointer);
//%pointer_class(uint16_t, V8UShortPointer);

//Include
%include "v8.h"

//Inlines
%inline %{
v8::HandleScope GlobalHandleScope;
%}

//Templates
%template (V8HandleArray) v8::Handle<v8::Array>;
%template (V8HandleBoolean) v8::Handle<v8::Boolean>;
%template (V8HandleContext) v8::Handle<v8::Context>;
%template (V8HandleData) v8::Handle<v8::Data>;
%template (V8HandleExternal) v8::Handle<v8::External>;
%template (V8HandleFunction) v8::Handle<v8::Function>;
%template (V8HandleFunctionTemplate) v8::Handle<v8::FunctionTemplate>;
%template (V8HandleInt32) v8::Handle<v8::Int32>;
%template (V8HandleInteger) v8::Handle<v8::Integer>;
%template (V8HandleMessage) v8::Handle<v8::Message>;
%template (V8HandleNumber) v8::Handle<v8::Number>;
%template (V8HandleObject) v8::Handle<v8::Object>;
%template (V8HandleObjectTemplate) v8::Handle<v8::ObjectTemplate>;
%template (V8HandlePrimitive) v8::Handle<v8::Primitive>;
%template (V8HandleScript) v8::Handle<v8::Script>;
%template (V8HandleSignature) v8::Handle<v8::Signature>;
%template (V8HandleString) v8::Handle<v8::String>;
%template (V8HandleTypeSwitch) v8::Handle<v8::TypeSwitch>;
%template (V8HandleUint32) v8::Handle<v8::Uint32>;
%template (V8HandleValue) v8::Handle<v8::Value>;
%template (V8LocalArray) v8::Local<v8::Array>;
%template (V8LocalBoolean) v8::Local<v8::Boolean>;
%template (V8LocalContext) v8::Local<v8::Context>;
%template (V8LocalExternal) v8::Local<v8::External>;
%template (V8LocalFunction) v8::Local<v8::Function>;
%template (V8LocalFunctionTemplate) v8::Local<v8::FunctionTemplate>;
%template (V8LocalInt32) v8::Local<v8::Int32>;
%template (V8LocalInteger) v8::Local<v8::Integer>;
%template (V8LocalMessage) v8::Local<v8::Message>;
%template (V8LocalNumber) v8::Local<v8::Number>;
%template (V8LocalObject) v8::Local<v8::Object>;
%template (V8LocalObjectTemplate) v8::Local<v8::ObjectTemplate>;
%template (V8LocalScript) v8::Local<v8::Script>;
%template (V8LocalSignature) v8::Local<v8::Signature>;
%template (V8LocalString) v8::Local<v8::String>;
%template (V8LocalTypeSwitch) v8::Local<v8::TypeSwitch>;
%template (V8LocalUint32) v8::Local<v8::Uint32>;
%template (V8LocalValue) v8::Local<v8::Value>;
%template (V8PersistentContext) v8::Persistent<v8::Context>;
%template (V8PersistentValue) v8::Persistent<v8::Value>;
Powered by Google Project Hosting