nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype)
{
  JSObject *proto = nsnull;

  if (prototype != nsnull)
    *prototype = nsnull;

    proto = JS_InitClass(jscontext,                       // context
                         global,                          // global object
                         nsnull,                          // parent proto
                         &InstallTriggerGlobalClass,      // JSClass
                         nsnull,                          // JSNative ctor
                         nsnull,                          // ctor args
                         nsnull,                          // proto props
                         nsnull,                          // proto funcs
                         nsnull,                          // ctor props (static)
                         InstallTriggerGlobalMethods);    // ctor funcs (static)


    if (nsnull == proto) return NS_ERROR_FAILURE;

    if ( PR_FALSE == JS_DefineConstDoubles(jscontext, proto, diff_constants) )
            return NS_ERROR_FAILURE;

    if (prototype != nsnull)
      *prototype = proto;

  return NS_OK;
}
Example #2
0
BOOL __declspec(dllexport) InitExports(JSContext * cx, JSObject * global)
{
    JSFunctionSpec wimFileFuncs[] = {
        { "Close", wimg_close_handle, 0, 0 },
        { "SetTemporaryPath", wimg_set_temporary_path, 1, 0 },
        { "GetImageCount", wimg_get_image_count, 0, 0 },
        { "DeleteImage", wimg_delete_image, 1, 0 },
        { "CaptureImage", wimg_capture_image, 2, 0 },
        { "StartUI", wimg_start_ui, 0, 0 },
        { "StopUI", wimg_stop_ui, 0, 0 },
        { "LoadImage", wimg_load_image, 2, 0 },
        { "SetExceptionsList", wimg_set_exceptions, 1, 0 },
        { 0 },
    };

    JSFunctionSpec wimImageFuncs[] = {
        { "ApplyImage", wimg_apply_image, 2, 0 },
        { "Close", wimg_close_handle, 0, 0 },
        { 0 },
    };

    JSPropertySpec wimProps[] = {
        { "information", 0, JSPROP_PERMANENT, wimg_image_info_getter, wimg_image_info_setter },
        { "imageCount", 0, JSPROP_PERMANENT | JSPROP_READONLY, wimg_image_count_getter, NULL },
        { 0 }
    };

    JSConstDoubleSpec wimg_consts [] = {
        { WIM_GENERIC_READ, "WIM_GENERIC_READ", 0, 0 },
        { WIM_GENERIC_WRITE, "WIM_GENERIC_WRITE", 0, 0, },
        { WIM_CREATE_NEW, "WIM_CREATE_NEW", 0, 0 },
        { WIM_CREATE_ALWAYS, "WIM_CREATE_ALWAYS", 0, 0 },
        { WIM_OPEN_EXISTING, "WIM_OPEN_EXISTING", 0, 0 },
        { WIM_OPEN_ALWAYS, "WIM_OPEN_ALWAYS", 0, 0 },
        { WIM_FLAG_VERIFY, "WIM_FLAG_VERIFY", 0, 0 },
        { WIM_FLAG_SHARE_WRITE, "WIM_FLAG_SHARE_WRITE", 0, 0 },
        { WIM_COMPRESS_NONE, "WIM_COMPRESS_NONE", 0, 0 },
        { WIM_COMPRESS_XPRESS, "WIM_COMPRESS_XPRESS", 0, 0 },
        { WIM_COMPRESS_LZX, "WIM_COMPRESS_LXZ", 0, 0 },
        { WIM_CREATED_NEW, "WIM_CREATED_NEW", 0, 0 },
        { WIM_OPENED_EXISTING, "WIM_OPENED_EXISTING", 0, 0 },
        { WIM_FLAG_INDEX, "WIM_FLAG_INDEX", 0, 0 },
        { WIM_FLAG_NO_APPLY, "WIM_FLAG_NO_APPLY", 0, 0 },
        { WIM_FLAG_FILEINFO, "WIM_FLAG_FILEINFO", 0, 0 },
        { WIM_FLAG_NO_DIRACL, "WIM_FLAG_NO_DIRACL", 0, 0 },
        { WIM_FLAG_NO_FILEACL, "WIM_FLAG_NO_FILEACL", 0, 0 },
        { WIM_FLAG_NO_RP_FIX, "WIM_FLAG_NO_RP_FIX", 0, 0 },
        { 0 },
    };

    JS_BeginRequest(cx);
    wimFileProto = JS_InitClass(cx, global, NULL, &wimFileClass, NULL, 0, wimProps, wimFileFuncs, NULL, NULL);
    wimImageProto = JS_InitClass(cx, global, NULL, &wimImageClass, NULL, 0, wimProps, wimImageFuncs, NULL, NULL);
    JS_DefineFunction(cx, global, "WIMCreateFile", wimg_create_file, 5, 0);
    JS_DefineFunction(cx, global, "GetOpenFileName", openfiledlg, 4, 0);
    JS_DefineConstDoubles(cx, global, wimg_consts);
    JS_EndRequest(cx);
    return TRUE;
}
Example #3
0
/**
 * adds the InstallVersion class to a JS context
 */
JSBool su_DefineVersion(JSContext *cx, JSObject *obj)
{
    JSObject *su_version_proto;

    su_version_proto = JS_InitClass(cx, obj, NULL, &su_version_class, NewVersion, 1,
        NULL, version_methods, NULL, NULL);

    if ( su_version_proto != NULL )
        if ( JS_DefineConstDoubles(cx, su_version_proto, version_constants) )
            return JS_TRUE;
    
    return JS_FALSE;
}
Example #4
0
////////////////////////////////////////////////////////////////////
//
// INITIALIZATION
//
JSObject* ChJS_InitClass_ChGeneticOptimizer(JSContext* cx, JSObject* glob, JSObject* parent)
{
	JSObject* ret = JS_InitClass(cx, glob,
				parent,					// parent prototype (parent class)
				&chjs_ChGeneticOptimizer,		// this class
				ChGeneticOptimizer_construct, 0,	// constructor fx and parameters
				ChGeneticOptimizer_props, ChGeneticOptimizer_methods,
				NULL, NULL);

	if (!JS_DefineConstDoubles(cx, ret, genetic_constants))
     return NULL;

	return ret;
}
Example #5
0
JSObject *
js_InitMathClass(JSContext *cx, JSObject *obj)
{
    JSObject *Math;
    
    Math = JS_DefineObject(cx, obj, "Math", &math_class, NULL, 0);
    if (!Math)
        return NULL;
    if (!JS_DefineFunctions(cx, Math, math_static_methods))
        return NULL;
    if (!JS_DefineConstDoubles(cx, Math, math_constants))
        return NULL;
    return Math;
}
Example #6
0
void InitWin32s(JSContext * cx, JSObject * global)
{
	struct JSConstDoubleSpec win32MessageBoxTypes[] = {
		{ MB_ABORTRETRYIGNORE, "MB_ABORTRETRYIGNORE", 0, 0 },
		{ MB_CANCELTRYCONTINUE, "MB_CANCELTRYCONTINUE", 0, 0 },
		{ MB_HELP, "MB_HELP", 0, 0 },
		{ MB_OK, "MB_OK", 0, 0 },
		{ MB_OKCANCEL, "MB_OKCANCEL", 0, 0 },
		{ MB_RETRYCANCEL, "MB_RETRYCANCEL", 0, 0 },
		{ MB_YESNO, "MB_YESNO", 0, 0 },
		{ MB_YESNOCANCEL, "MB_YESNOCANCEL", 0, 0 },
		{ MB_ICONEXCLAMATION, "MB_ICONEXCLAMATION", 0, 0 },
		{ MB_ICONWARNING, "MB_ICONWARNING", 0, 0 },
		{ MB_ICONINFORMATION, "MB_ICONINFORMATION", 0, 0 },
		{ MB_ICONASTERISK, "MB_ICONASTERISK", 0, 0 },
		{ MB_ICONQUESTION, "MB_ICONQUESTION", 0, 0 },
		{ MB_ICONSTOP, "MB_ICONSTOP", 0, 0 },
		{ MB_ICONERROR, "MB_ICONERROR", 0, 0 },
		{ MB_ICONHAND, "MB_ICONHAND", 0, 0 },
		{ IDABORT, "IDABORT", 0, 0 },
		{ IDCANCEL, "IDCANCEL", 0, 0 },
		{ IDCONTINUE, "IDCONTINUE", 0, 0 },
		{ IDIGNORE, "IDIGNORE", 0, 0 },
		{ IDNO, "IDNO", 0, 0 },
		{ IDOK, "IDOK", 0, 0 },
		{ IDRETRY, "IDRETRY", 0, 0 },
		{ IDTRYAGAIN, "IDTRYAGAIN", 0, 0 },
		{ IDYES, "IDYES", 0, 0 },
		{ 0 },
	};

	JS_DefineConstDoubles(cx, global, win32MessageBoxTypes);

	struct JSFunctionSpec win32s[] = {
		{ "MessageBox", win32_messagebox, 1, 0 },
		{ "GetLastError", win32_getlasterror, 0, 0 },
		{ "GetLastErrorMessage", win32_getlasterrormsg, 0, 0 },
		{ "SetEnv", win32_setenv, 2, 0 },
		{ "GetEnv", win32_getenv, 2, 0 },
		{ "SetCurrentDirectory", win32_setcurrentdirectory, 1, 0 },
		{ "GetCurrentDirectory", win32_getcurrentdirectory, 0, 0 },
		{ "SetDllDirectory", win32_setdlldirectory, 1, 0 },
		{ "Sleep", win32_sleep, 1, 0 },
		{ "ImpersonateUser", win32_impersonateuser, 2, 0 },
		{ "RevertToSelf", win32_reverttoself, 0, 0 },
		{ 0 }
	};

	JS_DefineFunctions(cx, global, win32s);
}
void CG_JS_Sys_Init(JSContext *ctx, JSObject *global)
{
    JSObject *Sys;
    int len = strlen(GAME_VERSION);
    char *gv = (char *)JS_malloc(ctx, len+1);

    Sys = JS_DefineObject(ctx, global, "Sys", &sys_class, NULL, 0);
    if (!Sys)
        CG_Error("Failed to Define javascript Sys object\n");
    if (!JS_DefineFunctions(ctx, Sys, sys_static_methods))
        CG_Error("Failed to Define javascript Sys functions\n");
    if (!JS_DefineConstDoubles(ctx, Sys, sys_constants))
        CG_Error("Failed to Define javascript Sys constants\n");

    CG_JS_Sys_Cvar_Init(ctx, Sys);
}
Example #8
0
JSObject *
js_InitMathClass(JSContext *cx, JSObject *obj)
{
    JSObject *Math;

    Math = JS_NewObject(cx, &js_MathClass, NULL, obj);
    if (!Math)
        return NULL;
    if (!JS_DefineProperty(cx, obj, js_Math_str, OBJECT_TO_JSVAL(Math),
                           JS_PropertyStub, JS_PropertyStub, 0)) {
        return NULL;
    }

    if (!JS_DefineFunctions(cx, Math, math_static_methods))
        return NULL;
    if (!JS_DefineConstDoubles(cx, Math, math_constants))
        return NULL;
    return Math;
}
Example #9
0
BOOL __declspec(dllexport) InitExports(JSContext * cx, JSObject * global)
{
	JSFunctionSpec xdeployFunctions[] = {
		{ "SetComputerName", setcomputername, 2, 0 },
		{ "NetJoinDomain", netjoindomain, 6, 0 },
		{ "NetLocalGroupAddMembers", netlocalgroupaddmembers, 2, 0 },
		{ "NetGetLastErrorMessage", GetLastNetErrorMessage, 1, 0 },
		{ "NetGetJoinableOUs", netgetjoinableous, 3, 0 },
		{ "HideFirstUXWnd", close_FirstUXWnd, 0, 0 },
		{ 0 },
	};

	JS_BeginRequest(cx);
	JS_DefineFunctions(cx, global, xdeployFunctions);
	JS_DefineConstDoubles(cx, global, xdeployConsts);
	InitCrypto(cx, global);
	InitMsi(cx, global);
	InitProgressDlg(cx, global);
	JS_EndRequest(cx);
	return TRUE;
}
Example #10
0
JSBool
lm_InitEventClasses(MochaDecoder *decoder)
{
    JSContext *cx;
    JSObject *prototype, *ctor;

    cx = decoder->js_context;

    prototype = JS_InitClass(cx, decoder->window_object, NULL, &lm_event_class,
			     lm_Event, 0, event_props, NULL, NULL, NULL);

    if (!prototype|| !(ctor = JS_GetConstructor(cx, prototype)))
	return JS_FALSE;

    if (!JS_DefineConstDoubles(cx, ctor, event_constants))
	return JS_FALSE;

    decoder->event_prototype = prototype;

    prototype = JS_InitClass(cx, decoder->window_object, NULL,
			     &event_receiver_class, EventReceiver, 0,
			     NULL, event_receiver_methods, NULL, NULL);

    if (!prototype)
	return JS_FALSE;
    decoder->event_receiver_prototype = prototype;

    prototype = JS_InitClass(cx, decoder->window_object,
			     decoder->event_receiver_prototype,
			     &event_capturer_class, EventCapturer, 0,
			     NULL, event_capturer_methods, NULL, NULL);


    if (!prototype)
	return JS_FALSE;
    decoder->event_capturer_prototype = prototype;
    return JS_TRUE;
}