2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include <SecurityExceptions.h>
17 #include <CommonsJavaScript/Converter.h>
18 #include <GlobalContextManager.h>
19 #include <ArgumentValidator.h>
20 #include <PlatformException.h>
21 #include <JSWebAPIErrorFactory.h>
24 #include <MultiCallbackUserData.h>
25 #include <boost/shared_ptr.hpp>
30 #include "TimeTracer.h"
31 #include "JSRefImplManager.h"
32 #include "RefImplManager.h"
36 #include "NestedValue.h"
37 #include "JSNestedValue.h"
40 using namespace WrtDeviceApis::CommonsJavaScript;
41 using namespace WrtDeviceApis::Commons;
42 using namespace DeviceAPI::Common;
48 JSClassRef JSRefImplManager::m_jsClassRef = NULL;
50 JSClassDefinition JSRefImplManager::m_jsClassInfo = {
51 0, // current (and only) version is 0
52 kJSClassAttributeNone, //attributes
53 "RefImplManager", //class name
55 JSRefImplManager::m_property, //static values
56 JSRefImplManager::m_function, // static functions
57 JSRefImplManager::initialize, // initialize
58 JSRefImplManager::finalize, //finalize
60 JSRefImplManager::getNormalProperty, //getProperty
61 JSRefImplManager::setNormalProperty, //setProperty
62 NULL, //deleteProperty
63 NULL, //getPropertyNames
64 NULL, // callAsConstructor
70 JSStaticValue JSRefImplManager::m_property[] = {
71 { "Number", getReadOnlyNumber, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
72 { "Sub", getReadOnlySub, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
78 JSStaticFunction JSRefImplManager::m_function[] = {
79 { "syncToSync", JSRefImplManager::syncToSync, kJSPropertyAttributeNone },
80 { "syncToAsync", JSRefImplManager::syncToAsync, kJSPropertyAttributeNone },
81 { "asyncToAsync", JSRefImplManager::asyncToAsync, kJSPropertyAttributeNone },
82 { "addListener", JSRefImplManager::addListener, kJSPropertyAttributeNone },
83 { "removeListener", JSRefImplManager::removeListener, kJSPropertyAttributeNone },
84 { "fire", JSRefImplManager::fire, kJSPropertyAttributeNone },
85 { "argtest", JSRefImplManager::argtest, kJSPropertyAttributeNone },
86 { "arraytest", JSRefImplManager::arraytest, kJSPropertyAttributeNone },
87 { "isSuper", JSRefImplManager::isSuper, kJSPropertyAttributeNone },
88 { "isSub", JSRefImplManager::isSub, kJSPropertyAttributeNone },
89 { "setCallback", JSRefImplManager::setCallback, kJSPropertyAttributeNone },
90 { "unsetCallback", JSRefImplManager::unsetCallback, kJSPropertyAttributeNone },
91 { "fireCallback", JSRefImplManager::fireCallback, kJSPropertyAttributeNone },
92 { "callbackObjectTest", JSRefImplManager::callbackObjectTest, kJSPropertyAttributeNone },
93 { "updateNumber", JSRefImplManager::updateNumber, kJSPropertyAttributeNone },
94 { "updateSub", JSRefImplManager::updateSub, kJSPropertyAttributeNone },
98 const JSClassRef JSRefImplManager::getClassRef()
101 m_jsClassRef = JSClassCreate(&m_jsClassInfo);
106 const JSClassDefinition* JSRefImplManager::getClassInfo()
108 return &m_jsClassInfo;
111 void JSRefImplManager::initialize(JSContextRef ctx, JSObjectRef object)
116 void JSRefImplManager::finalize(JSObjectRef object)
118 TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"RefImpl");
119 TIME_TRACER_RELEASE();
123 JSValueRef JSRefImplManager::getReadOnlyNumber(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
124 return RefImplManager::getInstance()->mLocalProperty.getProperty(context,propertyName);
127 JSValueRef JSRefImplManager::getReadOnlySub(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
128 return RefImplManager::getInstance()->mLocalProperty.getProperty(context,propertyName);
131 JSValueRef JSRefImplManager::getNormalProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
132 string name = JSUtil::JSStringToString(context, propertyName);
133 if( name == "Number" )
137 return RefImplManager::getInstance()->mLocalProperty.getProperty(context,propertyName);
140 bool JSRefImplManager::setNormalProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception){
141 string name = JSUtil::JSStringToString(context, propertyName);
142 if( name == "Number" )
146 return RefImplManager::getInstance()->mLocalProperty.setProperty(context,propertyName, value);
149 JSValueRef JSRefImplManager::syncToSync(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
150 TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
152 Converter convert(ctx);
153 ArgumentValidator validator(ctx, argumentCount, arguments);
155 int a = validator.toLong(0);
156 int b = validator.toLong(1);
157 int result = RefImplManager::getInstance()->syncToSync(a,b);
158 TIME_TRACER_ITEM_END(__FUNCTION__, 1);
159 return convert.toJSValueRef(result);
160 }catch( const TypeMismatchException& err ){
161 return JSWebAPIErrorFactory::postException(ctx, exception, err);
162 }catch( const BasePlatformException& err){
163 return JSWebAPIErrorFactory::postException(ctx, exception, err);
164 }catch( const ConversionException& err){
165 return JSWebAPIErrorFactory::postException(ctx, exception, "TypeMismatchError" , "can't convert to int");
167 return JSValueMakeUndefined(ctx);
170 JSValueRef JSRefImplManager::syncToAsync(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
171 TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
173 ArgumentValidator validator(ctx, argumentCount, arguments);
175 int a = validator.toLong(0);
176 int b = validator.toLong(1);
177 RefCallbackUserData *callback = new RefCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(ctx),a,b);
178 callback->setSuccessCallback(validator.toFunction(2));
179 callback->setErrorCallback(validator.toFunction(3, true));
181 RefImplManager::getInstance()->syncToAsync(callback);
183 }catch( const TypeMismatchException& err ){
184 return JSWebAPIErrorFactory::postException(ctx, exception, err);
185 }catch( const BasePlatformException& err){
186 return JSWebAPIErrorFactory::postException(ctx, exception, err);
188 TIME_TRACER_ITEM_END(__FUNCTION__, 1);
189 TIME_TRACER_EXPORT_REPORT();
190 TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"RefImpl");
191 return JSValueMakeUndefined(ctx);
195 JSValueRef JSRefImplManager::asyncToAsync(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
197 ArgumentValidator validator(ctx, argumentCount, arguments);
198 int a = validator.toLong(0);
199 int b = validator.toLong(1);
200 RefCallbackUserData *callback = new RefCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(ctx),a,b);
201 callback->setSuccessCallback(validator.toFunction(2));
202 callback->setErrorCallback(validator.toFunction(3, true));
204 RefImplManager::getInstance()->asyncToAsync(callback);
206 }catch( const TypeMismatchException& err ){
207 return JSWebAPIErrorFactory::postException(ctx, exception, err);
208 }catch( const BasePlatformException& err){
209 return JSWebAPIErrorFactory::postException(ctx, exception, err);
212 return JSValueMakeUndefined(ctx);
216 JSValueRef JSRefImplManager::argtest(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
218 ArgumentValidator validator(ctx, argumentCount, arguments);
219 string tocheck = validator.toString(0);
221 if( validator.isOmitted(0) || validator.isNull(0)){
222 printf("argument is omitted\n");
225 if( tocheck == "Boolean"){
226 bool value = validator.toBool(1);
227 printf("arg[1] = %d\n", value);
228 return JSUtil::toJSValueRef(ctx, value);
230 else if( tocheck == "Long"){
231 long value = validator.toLong(1);
232 printf("arg[1] = %ld\n", value);
233 return JSUtil::toJSValueRef(ctx, value);
235 else if( tocheck == "ULong"){
236 unsigned long value = validator.toULong(1);
237 printf("arg[1] = %lu\n", value);
238 return JSUtil::toJSValueRef(ctx, value);
240 else if( tocheck == "ULongLong"){
241 unsigned long long value = validator.toULongLong(1);
242 printf("arg[1] = %llu\n", value);
243 return JSUtil::toJSValueRef(ctx, value);
245 else if( tocheck == "Byte"){
246 signed char value = (int)validator.toByte(1);
247 printf("arg[1] = %d\n", value);
248 return JSUtil::toJSValueRef(ctx, value);
250 else if( tocheck == "Octet"){
251 unsigned char value = (int)validator.toOctet(1);
252 printf("arg[1] = %d\n", value);
253 return JSUtil::toJSValueRef(ctx, value);
255 else if( tocheck == "String"){
256 string value = validator.toString(1);
257 printf("arg[1] = %s\n", value.c_str());
258 return JSUtil::toJSValueRef(ctx, value);
259 }else if( tocheck == "Object"){
260 JSObjectRef value = validator.toObject(1);
261 printf("arg[1] = %p\n", value);
263 }else if( tocheck == "Date"){
264 time_t value = validator.toTimeT(1);
265 printf("arg[1] = %ld\n", value);
266 return JSUtil::makeDateObject(ctx, value);
267 }else if( tocheck == "Double" ){
268 double value = validator.toDouble(1);
269 printf("arg[1] = %f\n", value);
270 return JSUtil::toJSValueRef(ctx, value);
271 }else if( tocheck == "Function"){
272 JSObjectRef value = validator.toFunction(1);
273 printf("arg[1] = %p\n", value);
275 }else if( tocheck == "Array"){
276 JSObjectRef value = validator.toArrayObject(1);
277 printf("arg[1] = %p\n", value);
280 printf("usage: argtest([Long|String|Object|Date|Double|Function], ...)\n");
281 return JSUtil::toJSValueRef(ctx, "usage: argtest([Long|String|Object|Date|Double|Function], ...)");
283 }catch( const TypeMismatchException& err ){
284 printf("TypeMismatch exception %s : %s\n", err.getName().c_str(), err.getMessage().c_str());
285 return JSWebAPIErrorFactory::postException(ctx, exception, err);
287 return JSValueMakeUndefined(ctx);
290 JSValueRef makeJSBool(JSContextRef ctx, bool v){
291 return JSUtil::toJSValueRef(ctx, v);
294 JSValueRef makeNestedValue(JSContextRef ctx, boost::shared_ptr < NestedValue > native){
295 return JSNestedValue::makeJSObject(ctx, native);
298 JSValueRef JSRefImplManager::arraytest(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
300 ArgumentValidator validator(ctx, argumentCount, arguments);
301 string type = validator.toString(0);
302 JSObjectRef jsArray = validator.toArrayObject(1, true);
303 if( type == "String" && jsArray != NULL){
304 JSStringArray receivedArray(ctx, jsArray);
306 // basic getting test
307 for( unsigned int i = 0 ; i < receivedArray.size() ; i++){
308 string element = receivedArray[i];
309 printf("received array[%d] = %s\n", i, element.c_str());
312 // JSArray to JSArray Copy test
313 JSStringArray copyTest(ctx);
314 copyTest = receivedArray;
316 for( unsigned int i = 0 ; i < copyTest.size() ; i++){
317 string element = copyTest[i];
318 printf("copyTest array[%d] = %s\n", i, element.c_str());
321 // to Native Vector converting test
322 vector<string> tmp = receivedArray;
323 for( unsigned int i = 0 ; i < tmp.size() ; i++){
324 printf("to Native Vector [%d] = %s\n", i, tmp[i].c_str());
331 aa.push_back("three");
332 JSStringArray newArray(ctx);
334 for( unsigned int i = 0 ; i < newArray.size() ; i++){
335 string element = newArray[i];
336 printf("Copy from Vector[%d] = %s\n", i, element.c_str());
340 newArray[newArray.size()] = "last";
341 newArray[0] = "zero";
342 printf("Modification test\n");
343 printf("except:zero,two,three,last\n");
347 else if( type == "Long" && jsArray != NULL ){
348 JSLongArray receivedArray(ctx, jsArray);
351 for( unsigned int i = 0 ; i < receivedArray.size() ; i++){
352 long v = receivedArray[i];
353 printf("received array[%d] = %d\n", i, v );
356 // JSArray to JSArray Copy test
357 JSLongArray copyTest(ctx);
358 copyTest = receivedArray;
360 for( unsigned int i = 0 ; i < copyTest.size() ; i++){
361 long v = copyTest[i];
362 printf("copyTest array[%d] = %d\n", i, v);
365 // to Native Vector converting test
366 vector<long> tmp = receivedArray;
367 for( unsigned int i = 0 ; i < tmp.size() ; i++){
368 printf("to Native Vector [%d] = %d\n", i, tmp[i]);
376 JSLongArray newArray(ctx);
378 for( unsigned int i = 0 ; i < newArray.size() ; i++){
379 long v = newArray[i];
380 printf("Copy from Vector[%d] = %d\n", i, v);
384 newArray[newArray.size()] = 99;
386 printf("Modification test\n");
387 printf("except:0,2,3,99\n");
391 else if( type == "Boolean" && jsArray != NULL ){
392 JSArray<bool> receivedArray(ctx, jsArray, JSUtil::JSValueToBoolean, makeJSBool);
395 for( unsigned int i = 0 ; i < receivedArray.size() ; i++){
396 printf("received array[%d] = %s\n", i, receivedArray[i] ? "true" : "false" );
399 // JSArray to JSArray Copy test
400 JSArray<bool> copyTest(ctx, JSUtil::JSValueToBoolean, makeJSBool);
401 copyTest = receivedArray;
403 for( unsigned int i = 0 ; i < copyTest.size() ; i++){
404 printf("copyTest array[%d] = %s\n", i, copyTest[i] ? "true" : "false" );
407 // to Native Vector converting test
408 vector<bool> tmp = receivedArray;
409 for( unsigned int i = 0 ; i < tmp.size() ; i++){
410 printf("to Native Vector[%d] = %s\n", i, tmp[i] ? "true" : "false" );
418 JSArray<bool> newArray(ctx, JSUtil::JSValueToBoolean, makeJSBool);
420 for( unsigned int i = 0 ; i < newArray.size() ; i++){
421 printf("Copy from Vector[%d] = %s\n", i, newArray[i] ? "true" : "false" );
425 newArray[newArray.size()] = true;
427 printf("Modification test\n");
428 printf("except:false,false,true,false\n");
432 else if( type == "NestedValue" && jsArray != NULL ){
433 JSArray<boost::shared_ptr<NestedValue>> receivedArray(ctx, jsArray, JSNestedValue::getNative, makeNestedValue);
434 for( unsigned int i = 0 ; i< receivedArray.size() ; i++){
435 boost::shared_ptr<NestedValue> ptr = receivedArray[i];
438 JSArray<boost::shared_ptr<NestedValue>> newArray(ctx, JSNestedValue::getNative, makeNestedValue);
439 newArray = receivedArray;
440 newArray[0] = boost::shared_ptr<NestedValue>(new NestedValue(0, "newAdded!"));
441 for( unsigned int i = 0 ; i< newArray.size() ; i++){
442 boost::shared_ptr<NestedValue> ptr = newArray[i];
448 printf("usage: arraytest([Long|String|Boolean], array)\n");
449 return JSUtil::toJSValueRef(ctx, "usage: arraytest([Long|String|Boolean], array)");
451 return JSValueMakeUndefined(ctx);
452 }catch( const TypeMismatchException& err ){
453 printf("TypeMismatch exception %s : %s\n", err.getName().c_str(), err.getMessage().c_str());
454 return JSWebAPIErrorFactory::postException(ctx, exception, err);
455 }catch( const BasePlatformException& err){
456 printf("exception %s : %s\n", err.getName().c_str(), err.getMessage().c_str());
457 return JSWebAPIErrorFactory::postException(ctx, exception, err);
459 return JSValueMakeUndefined(ctx);
463 JSValueRef JSRefImplManager::addListener(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
465 ArgumentValidator validator(ctx, argumentCount, arguments);
466 JSObjectRef fun = validator.toFunction(0);
467 boost::shared_ptr<CallbackUserData> callback(new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(ctx)));
468 callback->setSuccessCallback(fun);
469 long id = RefImplManager::getInstance()->addListener(callback);
470 return JSUtil::toJSValueRef(ctx, id);
471 }catch( const BasePlatformException& err){
472 return JSWebAPIErrorFactory::postException(ctx, exception, err);
474 return JSValueMakeUndefined(ctx);
477 JSValueRef JSRefImplManager::removeListener(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
479 ArgumentValidator validator(ctx, argumentCount, arguments);
480 int id = validator.toLong(0);
481 RefImplManager::getInstance()->removeListener(id);
482 }catch( const BasePlatformException& err){
483 return JSWebAPIErrorFactory::postException(ctx, exception, err);
485 return JSValueMakeUndefined(ctx);
488 JSValueRef JSRefImplManager::fire(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
489 RefImplManager::getInstance()->fireListener();
490 return JSValueMakeUndefined(ctx);
495 JSValueRef JSRefImplManager::isSuper(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
497 ArgumentValidator validator(ctx, argumentCount, arguments);
498 JSObjectRef test = validator.toObject(0);
499 if( JSValueIsObjectOfClass(ctx, test, JSSuper::getClassRef()) )
500 return JSUtil::toJSValueRef(ctx, true);
502 return JSUtil::toJSValueRef(ctx, false);
503 }catch( const BasePlatformException& err){
504 printf("exception %s %s\n", err.getName().c_str(), err.getMessage().c_str());
505 return JSWebAPIErrorFactory::postException(ctx, exception, err);
507 return JSValueMakeUndefined(ctx);
510 JSValueRef JSRefImplManager::isSub(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
512 ArgumentValidator validator(ctx, argumentCount, arguments);
513 JSObjectRef test = validator.toObject(0);
514 if( JSValueIsObjectOfClass(ctx, test, JSSub::getClassRef()) )
515 return JSUtil::toJSValueRef(ctx, true);
517 return JSUtil::toJSValueRef(ctx, false);
518 }catch( const BasePlatformException& err){
519 printf("exception %s %s\n", err.getName().c_str(), err.getMessage().c_str());
520 return JSWebAPIErrorFactory::postException(ctx, exception, err);
522 return JSValueMakeUndefined(ctx);
525 JSValueRef JSRefImplManager::setCallback(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
527 ArgumentValidator validator(ctx, argumentCount, arguments);
528 JSObjectRef jsCallbackObj = validator.toObject(0);
529 boost::shared_ptr<MultiCallbackUserData> callback(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(ctx), jsCallbackObj));
530 RefImplManager::getInstance()->setCallbackObject(GlobalContextManager::getInstance()->getGlobalContext(ctx), callback);
531 }catch( const BasePlatformException& err){
532 return JSWebAPIErrorFactory::postException(ctx, exception, err);
534 return JSValueMakeUndefined(ctx);
536 JSValueRef JSRefImplManager::unsetCallback(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
537 RefImplManager::getInstance()->unsetCallbackObject(GlobalContextManager::getInstance()->getGlobalContext(ctx));
538 return JSValueMakeUndefined(ctx);
540 JSValueRef JSRefImplManager::fireCallback(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
542 ArgumentValidator validator(ctx, argumentCount, arguments);
543 string functionName= validator.toString(0);
544 RefImplManager::getInstance()->namedCallbackFire(GlobalContextManager::getInstance()->getGlobalContext(ctx), functionName.c_str());
545 }catch( const BasePlatformException& err){
546 return JSWebAPIErrorFactory::postException(ctx, exception, err);
548 return JSValueMakeUndefined(ctx);
551 JSValueRef JSRefImplManager::callbackObjectTest(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
553 printf("validator.toCallbackObject(0, true, \"fun1\", \"fun2\", \"fun3\", NULL);\n");
554 ArgumentValidator validator(ctx, argumentCount, arguments);
555 JSObjectRef obj = validator.toCallbackObject(0, true, "fun1", "fun2", "fun3", NULL);
556 printf("returnd obj = %p\n", obj);
557 }catch( const BasePlatformException& err){
558 printf("exception %s %s\n", err.getName().c_str(), err.getMessage().c_str());
561 printf("validator.toCallbackObject(0, false, \"fun1\", \"fun2\", \"fun3\", NULL);\n");
562 ArgumentValidator validator(ctx, argumentCount, arguments);
563 JSObjectRef obj = validator.toCallbackObject(0, false, "fun1", "fun2", "fun3", NULL);
564 printf("returnd obj = %p\n", obj);
565 }catch( const BasePlatformException& err){
566 printf("exception %s %s\n", err.getName().c_str(), err.getMessage().c_str());
569 return JSValueMakeUndefined(ctx);
572 JSValueRef JSRefImplManager::updateNumber(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
574 ArgumentValidator validator(ctx, argumentCount, arguments);
575 int readonlyValue= validator.toLong(0);
576 RefImplManager::getInstance()->mLocalProperty.setProperty(ctx, "Number", (double)readonlyValue);
577 }catch( const BasePlatformException& err){
578 return JSWebAPIErrorFactory::postException(ctx, exception, err);
580 return JSValueMakeUndefined(ctx);
583 JSValueRef JSRefImplManager::updateSub(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
585 ArgumentValidator validator(ctx, argumentCount, arguments);
586 JSObjectRef o = validator.toObject(0, JSSub::getClassRef());
587 RefImplManager::getInstance()->mLocalProperty.setProperty(ctx, "Sub", o);
588 }catch( const BasePlatformException& err){
589 return JSWebAPIErrorFactory::postException(ctx, exception, err);
591 return JSValueMakeUndefined(ctx);