1
1
#include " BBContext.h"
2
+
2
3
#include " BBPatchCollection.h"
3
4
#include " BBPatch.h"
5
+ #include " BBIndexSet.h"
6
+
4
7
#include " BBCore.h"
5
8
6
9
#include < stdexcept>
11
14
BB::Context::Context ()
12
15
: m_class_context(NULL ),
13
16
m_class_patch(NULL ),
14
- m_class_patch_collection(NULL )
17
+ m_class_patch_collection(NULL ),
18
+ m_class_index_set(NULL )
15
19
{
16
20
JSObjectRef object;
17
21
@@ -23,6 +27,7 @@ BB::Context::Context()
23
27
24
28
this ->patchClass ();
25
29
this ->patchCollectionClass ();
30
+ this ->indexSetClass ();
26
31
}
27
32
28
33
BB::Context::~Context ()
@@ -33,6 +38,8 @@ BB::Context::~Context()
33
38
JSClassRelease (this ->m_class_patch );
34
39
if (this ->m_class_patch_collection != NULL )
35
40
JSClassRelease (this ->m_class_patch_collection );
41
+ if (this ->m_class_index_set != NULL )
42
+ JSClassRelease (this ->m_class_index_set );
36
43
37
44
JSGlobalContextRelease (this ->m_context );
38
45
}
@@ -80,6 +87,10 @@ std::string BB::Context::getString(JSValueRef value) const throw(BB::Exception)
80
87
return &buffer[0 ];
81
88
}
82
89
90
+ #pragma mark -
91
+ #pragma mark JS Class Definitions
92
+ #pragma mark -
93
+
83
94
JSClassRef BB::Context::patchClass ()
84
95
{
85
96
if (this ->m_class_patch == NULL )
@@ -89,7 +100,7 @@ JSClassRef BB::Context::patchClass()
89
100
90
101
this ->m_class_patch = JSClassCreate (&BB::Patch::Definition);
91
102
92
- constructor_string = JSStringCreateWithUTF8CString (" Patch" );
103
+ constructor_string = JSStringCreateWithUTF8CString (BB:: Patch::Definition. className );
93
104
constructor = JSObjectMakeConstructor (this ->m_context , NULL ,
94
105
BB::Patch::Constructor);
95
106
global = JSContextGetGlobalObject (this ->m_context );
@@ -113,7 +124,7 @@ JSClassRef BB::Context::patchCollectionClass()
113
124
114
125
this ->m_class_patch_collection = JSClassCreate (&BB::PatchCollection::Definition);
115
126
116
- constructor_string = JSStringCreateWithUTF8CString (" PatchCollection" );
127
+ constructor_string = JSStringCreateWithUTF8CString (BB:: PatchCollection::Definition. className );
117
128
constructor = JSObjectMakeConstructor (this ->m_context , NULL ,
118
129
BB::PatchCollection::Constructor);
119
130
global = JSContextGetGlobalObject (this ->m_context );
@@ -128,6 +139,30 @@ JSClassRef BB::Context::patchCollectionClass()
128
139
return this ->m_class_patch_collection ;
129
140
}
130
141
142
+ JSClassRef BB::Context::indexSetClass ()
143
+ {
144
+ if (this ->m_class_index_set == NULL )
145
+ {
146
+ JSObjectRef constructor, global;
147
+ JSStringRef constructor_string;
148
+
149
+ this ->m_class_index_set = JSClassCreate (&BB::IndexSet::Definition);
150
+
151
+ constructor_string = JSStringCreateWithUTF8CString (BB::IndexSet::Definition.className );
152
+ constructor = JSObjectMakeConstructor (this ->m_context , NULL ,
153
+ BB::IndexSet::Constructor);
154
+ global = JSContextGetGlobalObject (this ->m_context );
155
+ JSObjectSetProperty (this ->m_context , global,
156
+ constructor_string, constructor,
157
+ kJSPropertyAttributeReadOnly |
158
+ kJSPropertyAttributeDontEnum |
159
+ kJSPropertyAttributeDontDelete ,
160
+ NULL );
161
+ JSStringRelease (constructor_string);
162
+ }
163
+ return this ->m_class_index_set ;
164
+ }
165
+
131
166
#pragma mark -
132
167
#pragma mark Evaluate Scripts
133
168
0 commit comments