bool VJSObject::CallAsConstructor (const std::vector<VJSValue> *inValues, VJSObject *outCreatedObject, JS4D::ExceptionRef *outException) { xbox_assert(outCreatedObject != NULL); if (!JSObjectIsConstructor(GetContextRef(), GetObjectRef())) return false; uLONG argumentCount = inValues == NULL || inValues->empty() ? 0 : (uLONG) inValues->size(); JSValueRef *values = argumentCount == 0 ? NULL : new JSValueRef[argumentCount]; if (values != NULL) { std::vector<VJSValue>::const_iterator i; uLONG j; for (i = inValues->begin(), j = 0; i != inValues->end(); i++, j++) values[j] = i->GetValueRef(); } JS4D::ExceptionRef exception; JS4D::ObjectRef createdObject; exception = NULL; createdObject = JSObjectCallAsConstructor(GetContextRef(), GetObjectRef(), argumentCount, values, &exception); if (values != NULL) delete[] values; if (outException != NULL) *outException = exception; outCreatedObject->SetContext(fContext); if (exception != NULL || createdObject == NULL) { outCreatedObject->SetUndefined(); return false; } else { outCreatedObject->SetObjectRef(createdObject); return true; } }
NATIVE(JSObject,jboolean,isConstructor) (PARAMS, jlong ctx, jlong object) { return JSObjectIsConstructor((JSContextRef) ctx, (JSObjectRef) object); }