nsresult
MetadataHelper::GetSuccessResult(JSContext* aCx,
                                 JS::Value* aVal)
{
  JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr));
  NS_ENSURE_TRUE(obj, NS_ERROR_OUT_OF_MEMORY);

  if (mParams->SizeRequested()) {
    JS::Value val = JS_NumberValue(mParams->Size());

    if (!JS_DefineProperty(aCx, obj, "size", val, nullptr, nullptr,
                           JSPROP_ENUMERATE)) {
      return NS_ERROR_FAILURE;
    }
  }

  if (mParams->LastModifiedRequested()) {
    double msec = mParams->LastModified();
    JSObject *date = JS_NewDateObjectMsec(aCx, msec);
    NS_ENSURE_TRUE(date, NS_ERROR_OUT_OF_MEMORY);

    if (!JS_DefineProperty(aCx, obj, "lastModified", OBJECT_TO_JSVAL(date),
                           nullptr, nullptr, JSPROP_ENUMERATE)) {
      return NS_ERROR_FAILURE;
    }
  }

  *aVal = OBJECT_TO_JSVAL(obj);

  return NS_OK;
}
Exemple #2
0
static JSBool
AfxGlobal_glGenTextures(JSContext *cx, unsigned argc, JS::Value *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
	if(1 > args.length())
		return JS_FALSE;

	uint32_t length;
	if(!JS::ToUint32(cx, args[0], &length))
		return JS_FALSE;

	GLuint * textures = new GLuint[length];
	jsval * jsTextures = new jsval[length];

	glGenTextures(length, textures);

	for(uint32_t i=0; i<length; i++)
	{
		jsTextures[i] = JS_NumberValue(textures[i]);
	}

	delete textures;

	JSObject * retObj = JS_NewArrayObject(cx, length, jsTextures);

	delete jsTextures;

	if(!retObj)
		return JS_FALSE;

	args.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Exemple #3
0
static JSBool
AfxGlobal_width_get(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
	int value = g_AfxSettings.Width_get();

	vp.set(JS_NumberValue(value));
    return JS_TRUE;
}
Exemple #4
0
static JSBool
JsTestObject_value_get(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
	JsTestObject *p = (JsTestObject *)JS_GetPrivate(obj);

	vp.set(JS_NumberValue(p->GetValue()));
    return JS_TRUE;
}
Exemple #5
0
static bool
my_convert(JSContext* context, JS::HandleObject obj, JSType type, JS::MutableHandleValue rval)
{
    if (type == JSTYPE_VOID || type == JSTYPE_STRING || type == JSTYPE_NUMBER || type == JSTYPE_BOOLEAN) {
        rval.set(JS_NumberValue(123));
        return true;
    }
    return false;
}
Exemple #6
0
static JSBool
AfxGlobal_currentEntityIndex_get(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp)
{
	cl_entity_t *ce = pEngStudio->GetCurrentEntity();

	int idx = ce ? ce->index : -1;

	vp.set(JS_NumberValue(idx));
    return JS_TRUE;
}
Exemple #7
0
static JSBool
AfxGlobal_glGetCurrentColor(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	double oldColor[4];
	
	glGetDoublev(GL_CURRENT_COLOR, oldColor);
	
	jsval jsOldColor[4] = { JS_NumberValue(oldColor[0]), JS_NumberValue(oldColor[1]), JS_NumberValue(oldColor[2]), JS_NumberValue(oldColor[3]) };

	JSObject * retObj = JS_NewArrayObject(cx, 4, jsOldColor);

	if(!retObj)
		return JS_FALSE;

	rec.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Exemple #8
0
static JSBool
AfxGlobal_getZNear(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	double value = g_Filming.GetZNear();

	rec.rval().set(JS_NumberValue(value));

	return JS_TRUE;
}
Exemple #9
0
static JSBool
AfxGlobal_glGetBlendFunc(JSContext *cx, unsigned argc, JS::Value *vp)
{
	JS::CallReceiver rec = JS::CallReceiverFromVp(vp);

	GLint sfactor, dfactor;
	
	glGetIntegerv(GL_BLEND_SRC, &sfactor);
	glGetIntegerv(GL_BLEND_DST, &dfactor);
	
	jsval jsVals[2] = { JS_NumberValue(sfactor), JS_NumberValue(dfactor) };

	JSObject * retObj = JS_NewArrayObject(cx, 2, jsVals);

	if(!retObj)
		return JS_FALSE;

	rec.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
Exemple #10
0
NS_IMETHODIMP
LockedFile::GetLocation(JSContext* aCx,
                        jsval* aLocation)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  if (mLocation == LL_MAXUINT) {
    *aLocation = JSVAL_NULL;
  }
  else {
    *aLocation = JS_NumberValue(double(mLocation));
  }
  return NS_OK;
}
Exemple #11
0
bool ScriptEvent_OnSwapBuffers(HDC hDC, BOOL & bSwapRes)
{
	JSAutoCompartment ac(g_JsCx, g_JsGlobal);

	jsval f;

	if(!JS_GetProperty(g_JsCx, g_JsGlobal, "onSwapBuffers", &f) || JSVAL_IS_PRIMITIVE(f))
		return false;

	jsval y;
	jsval x[1] = { JS_NumberValue((unsigned int)hDC) };

	if(!JS_CallFunctionValue(g_JsCx, g_JsGlobal, f, 1, x, &y))
		return false;

	bSwapRes = JS::ToBoolean(y);

	return true;
}
Exemple #12
0
static JSBool
AfxGlobal_modReplaceOnGlBegin(JSContext *cx, unsigned argc, JS::Value *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
	if(1 > args.length())
		return JS_FALSE;

	GLint newTextureBinding2d;

	if(!JS::ToInt32(cx, args[0], &newTextureBinding2d))
		return JS_FALSE;

	GLint oldActiveTextureArb;
	GLboolean oldTexture2d;
	GLint oldTextureBinding2d;
	GLint oldTextureEnvMode;
	
	glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &oldActiveTextureArb);

	glActiveTextureARB(GL_TEXTURE2_ARB);

	oldTexture2d = glIsEnabled(GL_TEXTURE_2D);
	glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTextureBinding2d);
	glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldTextureEnvMode);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, newTextureBinding2d);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	
	jsval jsOldVals[4] = { JS_NumberValue(oldActiveTextureArb), BOOLEAN_TO_JSVAL(oldTexture2d), JS_NumberValue(oldTextureBinding2d), JS_NumberValue(oldTextureEnvMode) };

	JSObject * retObj = JS_NewArrayObject(cx, 4, jsOldVals);

	if(!retObj)
		return JS_FALSE;

	args.rval().set(OBJECT_TO_JSVAL(retObj));

	return JS_TRUE;
}
  nsresult
  GetResult(JSContext* aCx,
            const FileRequestMetadata* aMetadata,
            JS::MutableHandle<JS::Value> aResult)
  {
    JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
    if (NS_WARN_IF(!obj)) {
      return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
    }

    const FileRequestSize& size = aMetadata->size();
    if (size.type() != FileRequestSize::Tvoid_t) {
      MOZ_ASSERT(size.type() == FileRequestSize::Tuint64_t);

      JS::Rooted<JS::Value> number(aCx, JS_NumberValue(size.get_uint64_t()));

      if (NS_WARN_IF(!JS_DefineProperty(aCx, obj, "size", number, 0))) {
        return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
      }
    }

    const FileRequestLastModified& lastModified = aMetadata->lastModified();
    if (lastModified.type() != FileRequestLastModified::Tvoid_t) {
      MOZ_ASSERT(lastModified.type() == FileRequestLastModified::Tint64_t);

      JS::Rooted<JSObject*> date(aCx,
        JS::NewDateObject(aCx, JS::TimeClip(lastModified.get_int64_t())));
      if (NS_WARN_IF(!date)) {
        return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
      }

      if (NS_WARN_IF(!JS_DefineProperty(aCx, obj, "lastModified", date, 0))) {
        return NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
      }
    }

    aResult.setObject(*obj);
    return NS_OK;
  }
Exemple #14
0
DWORD FillBaseStat(JSContext* cx, jsval* argv, int table, int row, int column, char* szTable, char* szStat) {
    if (szTable) {
        table = -1;
        for (int i = 0; BaseStatTable[i].pTable != NULL; i++)
            if (!_strcmpi(szTable, BaseStatTable[i].szTableName)) {
                table = i;
                break;
            }

        if (table == -1)
            return false;
    }

    BinField* pTable = BaseStatTable[table].pTable;

    if (szStat) {
        column = -1;
        for (int i = 0; i < BaseStatTable[table].wTableSize; i++)
            if (!_strcmpi(szStat, pTable[i].szFieldName)) {
                column = i;
                break;
            }

        if (column == -1)
            return false;
    }

    if (column > BaseStatTable[table].wTableSize)
        return FALSE;

    DWORD dwBuffer = 0;
    WORD wBuffer = 0;
    char* szBuffer = NULL;
    DWORD dwHelperSize = pTable[column + 1].dwFieldOffset - pTable[column].dwFieldOffset;
    if (dwHelperSize > 4)
        dwHelperSize = 4;

    switch (pTable[column].eFieldType) {
    case FIELDTYPE_DATA_ASCII:
        szBuffer = new char[(pTable[column].dwFieldLength + 1)];
        memset(szBuffer, NULL, pTable[column].dwFieldLength + 1);
        if (!FillBaseStat(table, row, column, szBuffer, pTable[column].dwFieldLength + 1))
            (*argv) = JSVAL_VOID;
        else
            (*argv) = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, szBuffer));
        delete[] szBuffer;
        return TRUE;

    case FIELDTYPE_DATA_DWORD:
        if (!FillBaseStat(table, row, column, &dwBuffer, sizeof(DWORD)))
            (*argv) = JSVAL_VOID;
        else
            *argv = JS_NumberValue((jsdouble)dwBuffer);
        return TRUE;

    case FIELDTYPE_CALC_TO_DWORD:
    case FIELDTYPE_NAME_TO_DWORD:
    case FIELDTYPE_DATA_DWORD_2:
    case FIELDTYPE_UNKNOWN_11:
        if (!FillBaseStat(table, row, column, &dwBuffer, sizeof(DWORD)))
            (*argv) = JSVAL_VOID;
        else
            *argv = JS_NumberValue((long)dwBuffer);
        return TRUE;

    case FIELDTYPE_NAME_TO_INDEX_2:
    case FIELDTYPE_NAME_TO_WORD_2:
    case FIELDTYPE_NAME_TO_INDEX:
    case FIELDTYPE_NAME_TO_WORD:
    case FIELDTYPE_KEY_TO_WORD:
    case FIELDTYPE_DATA_WORD:
    case FIELDTYPE_CODE_TO_WORD:
        if (!FillBaseStat(table, row, column, &wBuffer, sizeof(WORD)))
            (*argv) = JSVAL_VOID;
        else
            (*argv) = INT_TO_JSVAL(wBuffer);
        return TRUE;

    case FIELDTYPE_CODE_TO_BYTE:
    case FIELDTYPE_DATA_BYTE_2:
    case FIELDTYPE_DATA_BYTE:
        if (!FillBaseStat(table, row, column, &dwBuffer, dwHelperSize))
            (*argv) = JSVAL_VOID;
        else
            (*argv) = INT_TO_JSVAL(dwBuffer);
        return TRUE;

    case FIELDTYPE_DATA_BIT:
        if (!FillBaseStat(table, row, column, &dwBuffer, sizeof(DWORD)))
            (*argv) = JSVAL_VOID;
        else
            (*argv) = INT_TO_JSVAL(dwBuffer);
        //(*argv) = (BOOLEAN_TO_JSVAL(!!dwBuffer) ? 1 : 0);
        return TRUE;

    case FIELDTYPE_ASCII_TO_CODE:
    case FIELDTYPE_DATA_RAW:
        szBuffer = new char[5];
        memset(szBuffer, NULL, 5);
        if (!FillBaseStat(table, row, column, szBuffer, 5))
            (*argv) = JSVAL_VOID;
        else
            (*argv) = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, szBuffer));
        delete[] szBuffer;
        return TRUE;

    case FIELDTYPE_MONSTER_COMPS:
        // ..? :E
        return FALSE;
    }
    return FALSE;
}
Exemple #15
0
bool
DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aValue)
{
    if (mCallback) {
        mCallback->RequestComplete();
        mCallback = nullptr;
    }

    switch (aValue.type()) {

    case DeviceStorageResponseValue::TErrorResponse:
    {
        ErrorResponse r = aValue;
        mRequest->FireError(r.error());
        break;
    }

    case DeviceStorageResponseValue::TSuccessResponse:
    {
        jsval result = StringToJsval(mRequest->GetOwner(), mFile->mPath);
        mRequest->FireSuccess(result);
        break;
    }

    case DeviceStorageResponseValue::TBlobResponse:
    {
        BlobResponse r = aValue;
        BlobChild* actor = static_cast<BlobChild*>(r.blobChild());
        nsCOMPtr<nsIDOMBlob> blob = actor->GetBlob();

        nsCOMPtr<nsIDOMFile> file = do_QueryInterface(blob);
        jsval result = InterfaceToJsval(mRequest->GetOwner(), file, &NS_GET_IID(nsIDOMFile));
        mRequest->FireSuccess(result);
        break;
    }

    case DeviceStorageResponseValue::TFreeSpaceStorageResponse:
    {
        FreeSpaceStorageResponse r = aValue;
        jsval result = JS_NumberValue(double(r.freeBytes()));
        mRequest->FireSuccess(result);
        break;
    }

    case DeviceStorageResponseValue::TUsedSpaceStorageResponse:
    {
        UsedSpaceStorageResponse r = aValue;
        jsval result = JS_NumberValue(double(r.usedBytes()));
        mRequest->FireSuccess(result);
        break;
    }

    case DeviceStorageResponseValue::TAvailableStorageResponse:
    {
        AvailableStorageResponse r = aValue;
        jsval result = StringToJsval(mRequest->GetOwner(), r.mountState());
        mRequest->FireSuccess(result);
        break;
    }

    case DeviceStorageResponseValue::TEnumerationResponse:
    {
        EnumerationResponse r = aValue;
        nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());

        uint32_t count = r.paths().Length();
        for (uint32_t i = 0; i < count; i++) {
            nsCOMPtr<nsIFile> f;
            nsresult rv = NS_NewLocalFile(r.paths()[i].fullpath(), false, getter_AddRefs(f));
            if (NS_FAILED(rv)) {
                continue;
            }

            nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(r.paths()[i].type(), f);
            dsf->SetPath(r.paths()[i].name());
            cursor->mFiles.AppendElement(dsf);
        }

        nsCOMPtr<ContinueCursorEvent> event = new ContinueCursorEvent(cursor);
        event->Continue();
        break;
    }

    default:
    {
        NS_RUNTIMEABORT("not reached");
        break;
    }
    }
    return true;
}
bool
DeviceStorageRequestChild::
  Recv__delete__(const DeviceStorageResponseValue& aValue)
{
  if (mCallback) {
    mCallback->RequestComplete();
    mCallback = nullptr;
  }

  nsCOMPtr<nsPIDOMWindow> window = mRequest->GetOwner();
  if (!window) {
    return true;
  }

  switch (aValue.type()) {

    case DeviceStorageResponseValue::TErrorResponse:
    {
      ErrorResponse r = aValue;
      mRequest->FireError(r.error());
      break;
    }

    case DeviceStorageResponseValue::TSuccessResponse:
    {
      nsString fullPath;
      mDSFile->GetFullPath(fullPath);
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, fullPath, &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TFileDescriptorResponse:
    {
      FileDescriptorResponse r = aValue;

      nsString fullPath;
      mDSFile->GetFullPath(fullPath);
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, fullPath, &result);

      mDSFileDescriptor->mDSFile = mDSFile;
      mDSFileDescriptor->mFileDescriptor = r.fileDescriptor();
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TBlobResponse:
    {
      BlobResponse r = aValue;
      BlobChild* actor = static_cast<BlobChild*>(r.blobChild());
      nsRefPtr<BlobImpl> bloblImpl = actor->GetBlobImpl();
      nsRefPtr<Blob> blob = Blob::Create(mRequest->GetParentObject(),
                                         bloblImpl);

      AutoJSContext cx;

      JS::Rooted<JSObject*> obj(cx, blob->WrapObject(cx, JS::NullPtr()));
      MOZ_ASSERT(obj);

      JS::Rooted<JS::Value> result(cx, JS::ObjectValue(*obj));
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TFreeSpaceStorageResponse:
    {
      FreeSpaceStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx, JS_NumberValue(double(r.freeBytes())));
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TUsedSpaceStorageResponse:
    {
      UsedSpaceStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx, JS_NumberValue(double(r.usedBytes())));
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TAvailableStorageResponse:
    {
      AvailableStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, r.mountState(), &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TStorageStatusResponse:
    {
      StorageStatusResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, r.storageStatus(), &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TFormatStorageResponse:
    {
      FormatStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, r.mountState(), &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TMountStorageResponse:
    {
      MountStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, r.storageStatus(), &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TUnmountStorageResponse:
    {
      UnmountStorageResponse r = aValue;
      AutoJSContext cx;
      JS::Rooted<JS::Value> result(cx);
      StringToJsval(window, r.storageStatus(), &result);
      mRequest->FireSuccess(result);
      break;
    }

    case DeviceStorageResponseValue::TEnumerationResponse:
    {
      EnumerationResponse r = aValue;
      nsDOMDeviceStorageCursor* cursor
        = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());

      uint32_t count = r.paths().Length();
      for (uint32_t i = 0; i < count; i++) {
        nsRefPtr<DeviceStorageFile> dsf
          = new DeviceStorageFile(r.type(), r.paths()[i].storageName(),
                                  r.rootdir(), r.paths()[i].name());
        cursor->mFiles.AppendElement(dsf);
      }

      nsRefPtr<ContinueCursorEvent> event = new ContinueCursorEvent(cursor);
      event->Continue();
      break;
    }

    default:
    {
      NS_RUNTIMEABORT("not reached");
      break;
    }
  }
  return true;
}
Exemple #17
0
jsval
RUST_JS_NumberValue(double d)
{
    return JS_NumberValue(d);
}
Exemple #18
0
void
SmsRequest::NotifyThreadList(const InfallibleTArray<ThreadListItem>& aItems)
{
  MOZ_ASSERT(!mParent);
  MOZ_ASSERT(GetOwner());

  nsresult rv;
  nsIScriptContext* sc = GetContextForEventHandlers(&rv);
  NS_ENSURE_SUCCESS_VOID(rv);
  NS_ENSURE_TRUE_VOID(sc);

  JSContext* cx = sc->GetNativeContext();
  MOZ_ASSERT(cx);

  nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(GetOwner());

  JSObject* ownerObj = sgo->GetGlobalJSObject();
  NS_ENSURE_TRUE_VOID(ownerObj);

  nsCxPusher pusher;
  NS_ENSURE_TRUE_VOID(pusher.Push(cx, false));

  JSAutoRequest ar(cx);
  JSAutoCompartment ac(cx, ownerObj);

  JSObject* array = JS_NewArrayObject(cx, aItems.Length(), nullptr);
  NS_ENSURE_TRUE_VOID(array);

  bool ok;

  for (uint32_t i = 0; i < aItems.Length(); i++) {
    const ThreadListItem& source = aItems[i];

    nsString temp = source.senderOrReceiver();

    jsval senderOrReceiver;
    ok = xpc::StringToJsval(cx, temp, &senderOrReceiver);
    NS_ENSURE_TRUE_VOID(ok);

    JSObject* timestampObj = JS_NewDateObjectMsec(cx, source.timestamp());
    NS_ENSURE_TRUE_VOID(timestampObj);

    jsval timestamp = OBJECT_TO_JSVAL(timestampObj);

    temp = source.body();

    jsval body;
    ok = xpc::StringToJsval(cx, temp, &body);
    NS_ENSURE_TRUE_VOID(ok);

    jsval unreadCount = JS_NumberValue(double(source.unreadCount()));

    JSObject* elementObj = JS_NewObject(cx, nullptr, nullptr, nullptr);
    NS_ENSURE_TRUE_VOID(elementObj);

    ok = JS_SetProperty(cx, elementObj, "senderOrReceiver", &senderOrReceiver);
    NS_ENSURE_TRUE_VOID(ok);

    ok = JS_SetProperty(cx, elementObj, "timestamp", &timestamp);
    NS_ENSURE_TRUE_VOID(ok);

    ok = JS_SetProperty(cx, elementObj, "body", &body);
    NS_ENSURE_TRUE_VOID(ok);

    ok = JS_SetProperty(cx, elementObj, "unreadCount", &unreadCount);
    NS_ENSURE_TRUE_VOID(ok);

    jsval element = OBJECT_TO_JSVAL(elementObj);

    ok = JS_SetElement(cx, array, i, &element);
    NS_ENSURE_TRUE_VOID(ok);
  }

  NotifyThreadList(OBJECT_TO_JSVAL(array), cx);
}
static inline void JS_NewNumberValue(JSContext *cx, double d, jsval *rval) {
  *rval = JS_NumberValue(d);
}