Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/libadblockplus/JsValue.java

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.libadblockplus;
19
20 import java.util.List;
21
22 import com.github.rjeschke.neetutils.dispose.Disposable;
23 import com.github.rjeschke.neetutils.dispose.Disposer;
24
25 public class JsValue implements Disposable
26 {
27 private final Disposer disposer;
28 protected final long ptr;
29
30 static
31 {
32 System.loadLibrary("adblockplus-jni");
33 registerNatives();
34 }
35
36 protected JsValue(final long ptr)
37 {
38 this.ptr = ptr;
39 this.disposer = new Disposer(this, new DisposeWrapper(ptr));
40 }
41
42 @Override
43 public void dispose()
44 {
45 this.disposer.dispose();
46 }
47
48 public boolean isUndefined()
49 {
50 return isUndefined(this.ptr);
51 }
52
53 public boolean isNull()
54 {
55 return isNull(this.ptr);
56 }
57
58 public boolean isString()
59 {
60 return isString(this.ptr);
61 }
62
63 public boolean isNumber()
64 {
65 return isNumber(this.ptr);
66 }
67
68 public boolean isBoolean()
69 {
70 return isBoolean(this.ptr);
71 }
72
73 public boolean isObject()
74 {
75 return isObject(this.ptr);
76 }
77
78 public boolean isArray()
79 {
80 return isArray(this.ptr);
81 }
82
83 public boolean isFunction()
84 {
85 return isFunction(this.ptr);
86 }
87
88 public String asString()
89 {
90 return asString(this.ptr);
91 }
92
93 public long asLong()
94 {
95 return asLong(this.ptr);
96 }
97
98 public boolean asBoolean()
99 {
100 return asBoolean(this.ptr);
101 }
102
103 public boolean isValid()
104 {
105 return isValid(this.ptr);
106 }
107
108 public List<JsValue> asList()
109 {
110 return asList(this.ptr);
111 }
112
113 @Override
114 public String toString()
115 {
116 return asString(this.ptr);
117 }
118
119 private final static class DisposeWrapper implements Disposable
120 {
121 private final long ptr;
122
123 public DisposeWrapper(final long ptr)
124 {
125 this.ptr = ptr;
126 }
127
128 @Override
129 public void dispose()
130 {
131 dtor(this.ptr);
132 }
133 }
134
135 private final static native void registerNatives();
136
137 private final static native boolean isUndefined(long ptr);
138
139 private final static native boolean isNull(long ptr);
140
141 private final static native boolean isString(long ptr);
142
143 private final static native boolean isNumber(long ptr);
144
145 private final static native boolean isBoolean(long ptr);
146
147 private final static native boolean isObject(long ptr);
148
149 private final static native boolean isArray(long ptr);
150
151 private final static native boolean isFunction(long ptr);
152
153 private final static native String asString(long ptr);
154
155 private final static native long asLong(long ptr);
156
157 private final static native boolean asBoolean(long ptr);
158
159 private final static native boolean isValid(long ptr);
160
161 private final static native List<JsValue> asList(long ptr);
162
163 private final static native void dtor(long ptr);
164 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/libadblockplus/JsEngine.java ('k') | src/org/adblockplus/libadblockplus/LogSystem.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld