46 // ---------------------------------------------------------------------------- |
46 // ---------------------------------------------------------------------------- |
47 // |
47 // |
48 DeviceLiwResult::DeviceLiwResult( JSValue* proto) |
48 DeviceLiwResult::DeviceLiwResult( JSValue* proto) |
49 : JSObject(proto) |
49 : JSObject(proto) |
50 { |
50 { |
51 m_privateData = new DeviceLiwResultPrivate(); |
51 m_valid = EFalse; |
52 if (!m_privateData) |
52 m_privateData = new DeviceLiwResultPrivate(this); |
53 m_valid = false; |
53 if ( m_privateData ) |
54 else |
54 m_valid = ETrue; |
55 { |
|
56 m_valid = true; |
|
57 // protect this object |
|
58 KJS::Collector::protect(this); |
|
59 } |
|
60 } |
55 } |
61 |
56 |
62 // ---------------------------------------------------------------------------- |
57 // ---------------------------------------------------------------------------- |
63 // DeviceLiwResult::~DeviceLiwResult |
58 // DeviceLiwResult::~DeviceLiwResult |
64 // |
59 // |
65 // ---------------------------------------------------------------------------- |
60 // ---------------------------------------------------------------------------- |
66 // |
61 // |
67 DeviceLiwResult::~DeviceLiwResult() |
62 DeviceLiwResult::~DeviceLiwResult() |
68 { |
63 { |
69 // only can be called by garbage collection after the |
64 Close(); |
70 // DeviceLiwResult::Close() was called |
|
71 } |
65 } |
72 |
66 |
73 // ---------------------------------------------------------------------------- |
67 // ---------------------------------------------------------------------------- |
74 // DeviceLiwResult::Close |
68 // DeviceLiwResult::Close |
75 // |
69 // |
76 // ---------------------------------------------------------------------------- |
70 // ---------------------------------------------------------------------------- |
77 void DeviceLiwResult::Close( ExecState* exec, bool unmark ) |
71 void DeviceLiwResult::Close() |
78 { |
72 { |
79 |
|
80 // avoid double close |
|
81 if(!m_valid) |
73 if(!m_valid) |
82 { |
|
83 if(unmark) |
|
84 { |
|
85 // unprotect this to allow the garbage collection to release this jsobject |
|
86 KJS::Collector::unprotect(this); |
|
87 } |
|
88 return; |
74 return; |
89 } |
75 |
90 |
76 m_valid = EFalse; |
91 // close thDeviceLiwIterable |
|
92 if ( exec ) |
|
93 { |
|
94 PropertyNameArray propertyNames; |
|
95 this->getPropertyNames( exec, propertyNames ); |
|
96 unsigned size = static_cast<unsigned>(propertyNames.size()); |
|
97 |
|
98 for (unsigned i = 0; i < size; i++) |
|
99 { |
|
100 JSValue * jsvalue = this->get( exec, propertyNames[i] ); |
|
101 if(jsvalue->isObject()) |
|
102 { |
|
103 JSObject * prop = jsvalue->toObject( exec ); |
|
104 if (prop && prop->inherits( &DeviceLiwIterable::info )) |
|
105 { |
|
106 (static_cast<DeviceLiwIterable*>(prop))->Close(exec, true); |
|
107 } |
|
108 } |
|
109 } |
|
110 } |
|
111 |
|
112 delete m_privateData; |
77 delete m_privateData; |
113 m_privateData = NULL; |
78 m_privateData = NULL; |
114 m_valid = false; |
|
115 |
|
116 if(unmark) |
|
117 { |
|
118 // unprotect this to allow the garbage collection to release this jsobject |
|
119 KJS::Collector::unprotect(this); |
|
120 } |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------------------------------- |
|
124 // DeviceLiwResult::QuickClose |
|
125 // |
|
126 // ---------------------------------------------------------------------------- |
|
127 void DeviceLiwResult::quickClose() |
|
128 { |
|
129 if(!m_valid) |
|
130 return |
|
131 |
|
132 delete m_privateData; |
|
133 m_privateData = NULL; |
|
134 m_valid = false; |
|
135 |
|
136 // unprotect this to allow the garbage collection to release this jsobject |
|
137 KJS::Collector::unprotect(this); |
|
138 } |
79 } |
139 |
80 |
140 // ---------------------------------------------------------------------------- |
81 // ---------------------------------------------------------------------------- |
141 // DeviceLiwResult::toString |
82 // DeviceLiwResult::toString |
142 // |
83 // |
236 |
177 |
237 // --------------------------------------------------------------------------- |
178 // --------------------------------------------------------------------------- |
238 // DeviceLiwIterablePrivate constructor |
179 // DeviceLiwIterablePrivate constructor |
239 // |
180 // |
240 // --------------------------------------------------------------------------- |
181 // --------------------------------------------------------------------------- |
241 DeviceLiwResultPrivate::DeviceLiwResultPrivate() |
182 DeviceLiwResultPrivate::DeviceLiwResultPrivate(DeviceLiwResult* jsobj) |
242 { |
183 { |
243 // currently, do nothing |
184 m_jsobj = jsobj; |
244 } |
185 } |
245 |
186 |
246 // --------------------------------------------------------------------------- |
187 // --------------------------------------------------------------------------- |
247 // DeviceLiwMapPrivate::Close |
188 // DeviceLiwMapPrivate::Close |
248 // |
189 // |
249 // --------------------------------------------------------------------------- |
190 // --------------------------------------------------------------------------- |
250 void DeviceLiwResultPrivate::Close() |
191 DeviceLiwResultPrivate::~DeviceLiwResultPrivate() |
251 { |
192 { |
252 // currently, do nothing |
193 // invalid the DeviceLiwResult |
|
194 if (m_jsobj) |
|
195 m_jsobj->m_valid = EFalse; |
253 } |
196 } |
254 |
197 |
255 // ---------------------------------------------------------------------------- |
198 // ---------------------------------------------------------------------------- |
256 // DeviceLiwResultFunc::DeviceLiwResultFunc |
199 // DeviceLiwResultFunc::DeviceLiwResultFunc |
257 // |
200 // |