Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 174 lines (124 sloc) 6.018 kb
68eecea @samshull added isProxy, changed Enumeration of properties, added, updated and cha...
samshull authored
1 /**
2 *
3 *
4 *
5 * @author Sam Shull <http://samshull.blogspot.com/>
6 * @version 0.1
7 *
8 * @copyright Copyright (c) 2009 Sam Shull <http://samshull.blogspot.com/>
9 * @license <http://www.opensource.org/licenses/mit-license.html>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * THE SOFTWARE.
28 *
29 *
30 * CHANGES:
31 */
32
33 #ifndef NODE_PROXY_H // NOLINT
34 #define NODE_PROXY_H
35
36
37 #include <v8.h>
38 #include <node.h>
39 #include <node_version.h>
40
41 //#include <stdlib.h>
42 //#include <string.h>
43 //#include <unistd.h>
44
45 #include <string>
46
47
48 // Only for fixing some cpplint.py errors:
49 // Lines should be <= 80 characters long
50 // [whitespace/line_length] [2]
51 // Lines should very rarely be longer than 100 characters
52 // [whitespace/line_length] [4]
53 #define THREXC(str) ThrowException(Exception::Error(String::New(str)))
54 #define THREXCW(str) ThrowException(Exception::Error(str))
55 #define THR_TYPE_ERROR(str) ThrowException(Exception::TypeError(String::New(str)))
459a545 @samshull Better backwards compatibility with node
samshull authored
56 #define PROXY_NODE_PSYMBOL(s) Persistent<String>::New(String::NewSymbol(s))
68eecea @samshull added isProxy, changed Enumeration of properties, added, updated and cha...
samshull authored
57
58 //had to redefine NODE_VERSION_AT_LEAST here because of missing parenthesis
ed60643 @samshull initial commit
samshull authored
59 #define PROXY_NODE_VERSION_AT_LEAST(major, minor, patch) \
60 (( (major) < NODE_MAJOR_VERSION) \
61 || ((major) == NODE_MAJOR_VERSION && (minor) < NODE_MINOR_VERSION) \
68eecea @samshull added isProxy, changed Enumeration of properties, added, updated and cha...
samshull authored
62 || ((major) == NODE_MAJOR_VERSION && (minor) == NODE_MINOR_VERSION && (patch) <= NODE_PATCH_VERSION))
63
64 using namespace std;
65 using namespace v8;
66
67 class NodeProxy {
68 public:
69 static Persistent<String> getOwnPropertyDescriptor;
70 static Persistent<String> getPropertyDescriptor;
71 static Persistent<String> defineProperty;
72 static Persistent<String> getOwnPropertyNames;
73 static Persistent<String> delete_;
74 static Persistent<String> enumerate;
75 static Persistent<String> fix;
76
77 static Persistent<String> get;
78 static Persistent<String> set;
79 static Persistent<String> has;
80 static Persistent<String> hasOwn;
81 static Persistent<String> enumerateOwn;
82
83 static Persistent<String> callTrap;
84 static Persistent<String> constructorTrap;
85
86 static Persistent<String> value;
87 static Persistent<String> writable;
88 static Persistent<String> enumerable;
89 static Persistent<String> configurable;
90
91 static Persistent<String> name;
92
93 static Persistent<String> trapping;
94 static Persistent<String> sealed;
95 static Persistent<String> frozen;
96 static Persistent<String> extensible;
97
98 static Persistent<String> seal;
99 static Persistent<String> freeze;
100 static Persistent<String> preventExtensions;
101
102 static Persistent<String> isTrapping;
103 static Persistent<String> isSealed;
104 static Persistent<String> isFrozen;
105 static Persistent<String> isExtensible;
106 static Persistent<String> isProxy;
107
108 static Persistent<String> hidden;
109 static Persistent<String> hiddenPrivate;
110
111 static void Init(Handle<Object> target);
112
113 protected:
114
115 NodeProxy();
116
117 ~NodeProxy();
9a38dcc @samshull add PropertyDescriptor check
samshull authored
118
119 static Handle<Integer> GetPropertyAttributeFromPropertyDescriptor(Local<Object> pd);
120
121 static Local<Value> CorrectPropertyDescriptor(Local<Object> pd);
68eecea @samshull added isProxy, changed Enumeration of properties, added, updated and cha...
samshull authored
122
123 static Handle<Value> ValidateProxyHandler(Local<Object> handler);
124
125 static Handle<Value> Clone(const Arguments& args);
126
127 static Handle<Value> Hidden(const Arguments& args);
128
129 static Handle<Value> Create(const Arguments& args);
130
1aa3046 added isProxy and setProtoype functions
Samuel Shull authored
131 static Handle<Value> SetPrototype(const Arguments& args);
132
68eecea @samshull added isProxy, changed Enumeration of properties, added, updated and cha...
samshull authored
133 static Handle<Value> CreateFunction(const Arguments& args);
134
135 static Handle<Value> Freeze(const Arguments& args);
136
137 static Handle<Value> IsLocked(const Arguments& args);
138
139 static Handle<Value> IsProxy(const Arguments& args);
140
141 static Handle<Value> GetOwnPropertyDescriptor(const Arguments& args);
142
143 static Handle<Value> DefineProperty(const Arguments& args);
144
145 static Handle<Value> DefineProperties(const Arguments& args);
146
147 static Handle<Value> New(const Arguments& args);
148
149 static Handle<Value> GetNamedProperty(Local<String> name, const AccessorInfo &info);
150
151 static Handle<Value> SetNamedProperty(Local<String> name, Local<Value> value, const AccessorInfo &info);
152
153 static Handle<Boolean> QueryNamedProperty(Local<String> name, const AccessorInfo &info);
154
155 static Handle<Integer> QueryNamedPropertyInteger(Local<String> name, const AccessorInfo &info);
156
157 static Handle<Boolean> DeleteNamedProperty(Local<String> name, const AccessorInfo &info);
158
159 static Handle<Array> EnumerateNamedProperties(const AccessorInfo &info);
160
161 static Handle<Value> GetIndexedProperty(uint32_t index, const AccessorInfo &info);
162
163 static Handle<Value> SetIndexedProperty(uint32_t index, Local<Value> value, const AccessorInfo &info);
164
165 static Handle<Boolean> QueryIndexedProperty(uint32_t index, const AccessorInfo &info);
166
167 static Handle<Integer> QueryIndexedPropertyInteger(uint32_t index, const AccessorInfo &info);
168
169 static Handle<Boolean> DeleteIndexedProperty(uint32_t index, const AccessorInfo &info);
170 };
171
172 extern "C" void init(Handle<Object> target);
173
ed60643 @samshull initial commit
samshull authored
174 #endif // NODE_CLASSTEMPLATE_H // NOLINT
Something went wrong with that request. Please try again.