Bug 338678: For source compatibility fields "uint16 extra,spare" in JSFunctionSpec are replaced by singe "uint32 extra". In this way we do need to update the current sources that list just 5 fields to include the additional ",0" corresponding to "spare" field. To quell GCC warnings all sources that list less then 5 fields of JSFunctionSpec are updated to explicitly list all 5 fields. r=mrbkap, s=brendan

This commit is contained in:
igor%mir2.org 2006-05-22 22:58:31 +00:00
Родитель f7e7729eb0
Коммит 271c305869
17 изменённых файлов: 208 добавлений и 1163 удалений

Просмотреть файл

@ -271,14 +271,15 @@ netscape_security_invalidate(JSContext *cx, JSObject *obj, uintN argc,
} }
static JSFunctionSpec PrivilegeManager_static_methods[] = { static JSFunctionSpec PrivilegeManager_static_methods[] = {
{ "isPrivilegeEnabled", netscape_security_isPrivilegeEnabled, 1}, { "isPrivilegeEnabled", netscape_security_isPrivilegeEnabled, 1,0,0},
{ "enablePrivilege", netscape_security_enablePrivilege, 1}, { "enablePrivilege", netscape_security_enablePrivilege, 1,0,0},
{ "disablePrivilege", netscape_security_disablePrivilege, 1}, { "disablePrivilege", netscape_security_disablePrivilege, 1,0,0},
{ "revertPrivilege", netscape_security_revertPrivilege, 1}, { "revertPrivilege", netscape_security_revertPrivilege, 1,0,0},
//-- System Cert Functions //-- System Cert Functions
{ "setCanEnablePrivilege", netscape_security_setCanEnablePrivilege, 2}, { "setCanEnablePrivilege", netscape_security_setCanEnablePrivilege,
{ "invalidate", netscape_security_invalidate, 1}, 2,0,0},
{0} { "invalidate", netscape_security_invalidate, 1,0,0},
{nsnull,nsnull,0,0,0}
}; };
/* /*

Просмотреть файл

@ -390,22 +390,22 @@ GetOutputStream(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
// win.p = print, where win is rooted in some other global // win.p = print, where win is rooted in some other global
// object. // object.
static JSFunctionSpec global_functions[] = { static JSFunctionSpec global_functions[] = {
{"print", Print, 1, JSFUN_BOUND_METHOD}, {"print", Print, 1, JSFUN_BOUND_METHOD, 0},
{"dump", Print, 1, JSFUN_BOUND_METHOD}, {"dump", Print, 1, JSFUN_BOUND_METHOD, 0},
{"quit", Quit, 0, JSFUN_BOUND_METHOD}, {"quit", Quit, 0, JSFUN_BOUND_METHOD, 0},
{"exit", Quit, 0, JSFUN_BOUND_METHOD}, {"exit", Quit, 0, JSFUN_BOUND_METHOD, 0},
{"load", Load, 1, JSFUN_BOUND_METHOD}, {"load", Load, 1, JSFUN_BOUND_METHOD, 0},
{"suspend", Suspend, 0, JSFUN_BOUND_METHOD}, {"suspend", Suspend, 0, JSFUN_BOUND_METHOD, 0},
{"resume", Resume, 0, JSFUN_BOUND_METHOD}, {"resume", Resume, 0, JSFUN_BOUND_METHOD, 0},
{"flushEventQueue", FlushEventQueue,0, JSFUN_BOUND_METHOD}, {"flushEventQueue", FlushEventQueue,0, JSFUN_BOUND_METHOD, 0},
{"addressOf", AddressOf, 1, 0}, {"addressOf", AddressOf, 1, 0, 0},
{"setProtocol", SetProtocol, 1, JSFUN_BOUND_METHOD}, {"setProtocol", SetProtocol, 1, JSFUN_BOUND_METHOD, 0},
{"getProtocol", GetProtocol, 0, JSFUN_BOUND_METHOD}, {"getProtocol", GetProtocol, 0, JSFUN_BOUND_METHOD, 0},
{"setContextObj", SetContextObj, 1, JSFUN_BOUND_METHOD}, {"setContextObj", SetContextObj, 1, JSFUN_BOUND_METHOD, 0},
{"debugBreak", DebugBreak, 0, JSFUN_BOUND_METHOD}, {"debugBreak", DebugBreak, 0, JSFUN_BOUND_METHOD, 0},
{"getInputStream", GetInputStream, 0, JSFUN_BOUND_METHOD}, {"getInputStream", GetInputStream, 0, JSFUN_BOUND_METHOD, 0},
{"getOutputStream", GetOutputStream,0, JSFUN_BOUND_METHOD}, {"getOutputStream", GetOutputStream,0, JSFUN_BOUND_METHOD, 0},
{0} {nsnull, nsnull, 0, 0, 0}
}; };

Просмотреть файл

@ -1190,7 +1190,7 @@ DumpScope(JSContext *cx, JSObject *obj, FILE *fp)
for (sprop = SCOPE_LAST_PROP(scope); sprop; sprop = sprop->parent) { for (sprop = SCOPE_LAST_PROP(scope); sprop; sprop = sprop->parent) {
if (SCOPE_HAD_MIDDLE_DELETE(scope) && !SCOPE_HAS_PROPERTY(scope, sprop)) if (SCOPE_HAD_MIDDLE_DELETE(scope) && !SCOPE_HAS_PROPERTY(scope, sprop))
continue; continue;
fprintf(fp, "%3u %p", i, sprop); fprintf(fp, "%3u %p", i, (void *)sprop);
if (JSID_IS_INT(sprop->id)) { if (JSID_IS_INT(sprop->id)) {
fprintf(fp, " [%ld]", (long)JSVAL_TO_INT(sprop->id)); fprintf(fp, " [%ld]", (long)JSVAL_TO_INT(sprop->id));
} else if (JSID_IS_ATOM(sprop->id)) { } else if (JSID_IS_ATOM(sprop->id)) {
@ -1211,7 +1211,7 @@ DumpScope(JSContext *cx, JSObject *obj, FILE *fp)
#undef DUMP_ATTR #undef DUMP_ATTR
fprintf(fp, " slot %lu flags %x shortid %d\n", fprintf(fp, " slot %lu flags %x shortid %d\n",
sprop->slot, sprop->flags, sprop->shortid); (unsigned long)sprop->slot, sprop->flags, sprop->shortid);
} }
} }
@ -1666,7 +1666,8 @@ static JSClass sandbox_class = {
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
sandbox_enumerate, (JSResolveOp)sandbox_resolve, sandbox_enumerate, (JSResolveOp)sandbox_resolve,
JS_ConvertStub, JS_FinalizeStub JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}; };
static JSBool static JSBool
@ -1730,44 +1731,44 @@ out:
} }
static JSFunctionSpec shell_functions[] = { static JSFunctionSpec shell_functions[] = {
{"version", Version, 0}, {"version", Version, 0,0,0},
{"options", Options, 0}, {"options", Options, 0,0,0},
{"load", Load, 1}, {"load", Load, 1,0,0},
{"readline", ReadLine, 0}, {"readline", ReadLine, 0,0,0},
{"print", Print, 0}, {"print", Print, 0,0,0},
{"help", Help, 0}, {"help", Help, 0,0,0},
{"quit", Quit, 0}, {"quit", Quit, 0,0,0},
{"gc", GC, 0}, {"gc", GC, 0,0,0},
{"trap", Trap, 3}, {"trap", Trap, 3,0,0},
{"untrap", Untrap, 2}, {"untrap", Untrap, 2,0,0},
{"line2pc", LineToPC, 0}, {"line2pc", LineToPC, 0,0,0},
{"pc2line", PCToLine, 0}, {"pc2line", PCToLine, 0,0,0},
{"stringsAreUtf8", StringsAreUtf8, 0}, {"stringsAreUtf8", StringsAreUtf8, 0,0,0},
{"testUtf8", TestUtf8, 1}, {"testUtf8", TestUtf8, 1,0,0},
{"throwError", ThrowError, 0}, {"throwError", ThrowError, 0,0,0},
#ifdef DEBUG #ifdef DEBUG
{"dis", Disassemble, 1}, {"dis", Disassemble, 1,0,0},
{"dissrc", DisassWithSrc, 1}, {"dissrc", DisassWithSrc, 1,0,0},
{"notes", Notes, 1}, {"notes", Notes, 1,0,0},
{"tracing", Tracing, 0}, {"tracing", Tracing, 0,0,0},
{"stats", DumpStats, 1}, {"stats", DumpStats, 1,0,0},
#endif #endif
#ifdef TEST_EXPORT #ifdef TEST_EXPORT
{"xport", DoExport, 2}, {"xport", DoExport, 2,0,0},
#endif #endif
#ifdef TEST_CVTARGS #ifdef TEST_CVTARGS
{"cvtargs", ConvertArgs, 0,0,12}, {"cvtargs", ConvertArgs, 0,0,12},
#endif #endif
{"build", BuildDate, 0}, {"build", BuildDate, 0,0,0},
{"clear", Clear, 0}, {"clear", Clear, 0,0,0},
{"intern", Intern, 1}, {"intern", Intern, 1,0,0},
{"clone", Clone, 1}, {"clone", Clone, 1,0,0},
{"seal", Seal, 1,0,1}, {"seal", Seal, 1,0,1},
{"getpda", GetPDA, 1}, {"getpda", GetPDA, 1,0,0},
{"getslx", GetSLX, 1}, {"getslx", GetSLX, 1,0,0},
{"toint32", ToInt32, 1}, {"toint32", ToInt32, 1,0,0},
{"evalcx", EvalInContext, 1}, {"evalcx", EvalInContext, 1,0,0},
{0} {NULL,NULL,0,0,0}
}; };
/* NOTE: These must be kept in sync with the above. */ /* NOTE: These must be kept in sync with the above. */
@ -1891,13 +1892,13 @@ enum its_tinyid {
}; };
static JSPropertySpec its_props[] = { static JSPropertySpec its_props[] = {
{"color", ITS_COLOR, JSPROP_ENUMERATE}, {"color", ITS_COLOR, JSPROP_ENUMERATE, NULL, NULL},
{"height", ITS_HEIGHT, JSPROP_ENUMERATE}, {"height", ITS_HEIGHT, JSPROP_ENUMERATE, NULL, NULL},
{"width", ITS_WIDTH, JSPROP_ENUMERATE}, {"width", ITS_WIDTH, JSPROP_ENUMERATE, NULL, NULL},
{"funny", ITS_FUNNY, JSPROP_ENUMERATE}, {"funny", ITS_FUNNY, JSPROP_ENUMERATE, NULL, NULL},
{"array", ITS_ARRAY, JSPROP_ENUMERATE}, {"array", ITS_ARRAY, JSPROP_ENUMERATE, NULL, NULL},
{"rdonly", ITS_RDONLY, JSPROP_READONLY}, {"rdonly", ITS_RDONLY, JSPROP_READONLY, NULL, NULL},
{0} {NULL,0,0,NULL,NULL}
}; };
static JSBool static JSBool
@ -1937,9 +1938,9 @@ its_bindMethod(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
} }
static JSFunctionSpec its_methods[] = { static JSFunctionSpec its_methods[] = {
{"item", its_item, 0}, {"item", its_item, 0,0,0},
{"bindMethod", its_bindMethod, 2}, {"bindMethod", its_bindMethod, 2,0,0},
{0} {NULL,NULL,0,0,0}
}; };
#ifdef JSD_LOWLEVEL_SOURCE #ifdef JSD_LOWLEVEL_SOURCE
@ -2073,12 +2074,13 @@ static JSClass its_class = {
"It", JSCLASS_NEW_RESOLVE, "It", JSCLASS_NEW_RESOLVE,
its_addProperty, its_delProperty, its_getProperty, its_setProperty, its_addProperty, its_delProperty, its_getProperty, its_setProperty,
its_enumerate, (JSResolveOp)its_resolve, its_enumerate, (JSResolveOp)its_resolve,
its_convert, its_finalize its_convert, its_finalize,
JSCLASS_NO_OPTIONAL_MEMBERS
}; };
JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = { JSErrorFormatString jsShell_ErrorFormatString[JSErr_Limit] = {
#define MSG_DEF(name, number, count, exception, format) \ #define MSG_DEF(name, number, count, exception, format) \
{ format, count } , { format, count, JSEXN_ERR } ,
#include "jsshell.msg" #include "jsshell.msg"
#undef MSG_DEF #undef MSG_DEF
}; };
@ -2303,7 +2305,8 @@ JSClass global_class = {
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
global_enumerate, (JSResolveOp) global_resolve, global_enumerate, (JSResolveOp) global_resolve,
JS_ConvertStub, JS_FinalizeStub JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}; };
static JSBool static JSBool
@ -2417,7 +2420,8 @@ static JSClass env_class = {
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub, env_setProperty, JS_PropertyStub, env_setProperty,
env_enumerate, (JSResolveOp) env_resolve, env_enumerate, (JSResolveOp) env_resolve,
JS_ConvertStub, JS_FinalizeStub JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}; };
#ifdef NARCISSUS #ifdef NARCISSUS

Просмотреть файл

@ -3653,6 +3653,9 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
CHECK_REQUEST(cx); CHECK_REQUEST(cx);
ctor = NULL; ctor = NULL;
for (; fs->name; fs++) { for (; fs->name; fs++) {
/* High bits of fs->extra are reserved. */
JS_ASSERT((fs->extra & 0xFFFF0000) == 0);
flags = fs->flags; flags = fs->flags;
/* /*

Просмотреть файл

@ -1118,8 +1118,10 @@ struct JSFunctionSpec {
JSNative call; JSNative call;
uint16 nargs; uint16 nargs;
uint16 flags; uint16 flags;
uint16 extra; /* number of arg slots for local GC roots */ uint32 extra; /* extra & 0xFFFF:
uint16 spare; number of arg slots for local GC roots
extra >> 16:
reserved, must be zero */
}; };
extern JS_PUBLIC_API(JSObject *) extern JS_PUBLIC_API(JSObject *)

Просмотреть файл

@ -118,11 +118,11 @@ JSClass perlClass = {
}; };
static JSFunctionSpec perlMethods[] = { static JSFunctionSpec perlMethods[] = {
{"toString", (JSNative)PerlToString, 0}, {"toString", (JSNative)PerlToString, 0,0,0},
{"eval", (JSNative)perl_eval, 0}, {"eval", (JSNative)perl_eval, 0,0,0},
{"call", (JSNative)perl_call, 0}, {"call", (JSNative)perl_call, 0,0,0},
{"use", (JSNative)perl_use, 0}, {"use", (JSNative)perl_use, 0,0,0},
{ NULL, NULL,0 } {NULL, NULL, 0,0,0}
}; };
@ -134,8 +134,8 @@ JSClass perlModuleClass = {
}; };
JSFunctionSpec perlModuleMethods[] = { JSFunctionSpec perlModuleMethods[] = {
{"toString", (JSNative)PMToString, 0}, {"toString", (JSNative)PMToString, 0,0,0},
{ NULL, NULL,0 } {NULL, NULL, 0,0,0}
}; };
@ -147,8 +147,8 @@ JSClass perlValueClass = {
}; };
JSFunctionSpec perlValueMethods[] = { JSFunctionSpec perlValueMethods[] = {
{"toString", (JSNative)PVToString, 0}, {"toString", (JSNative)PVToString, 0,0,0},
{ NULL, NULL, 0} {NULL, NULL, 0,0,0}
}; };
/* /*

Просмотреть файл

@ -191,9 +191,9 @@ Debug(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} }
static JSFunctionSpec gGlobalFun[] = { static JSFunctionSpec gGlobalFun[] = {
{"dump", Dump, 1 }, {"dump", Dump, 1,0,0},
{"debug", Debug, 1 }, {"debug", Debug, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
class JSCLContextHelper class JSCLContextHelper

Просмотреть файл

@ -352,16 +352,16 @@ Clear(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} }
static JSFunctionSpec glob_functions[] = { static JSFunctionSpec glob_functions[] = {
{"print", Print, 0}, {"print", Print, 0,0,0},
{"load", Load, 1}, {"load", Load, 1,0,0},
{"quit", Quit, 0}, {"quit", Quit, 0,0,0},
{"version", Version, 1}, {"version", Version, 1,0,0},
{"build", BuildDate, 0}, {"build", BuildDate, 0,0,0},
{"dumpXPC", DumpXPC, 1}, {"dumpXPC", DumpXPC, 1,0,0},
{"dump", Dump, 1}, {"dump", Dump, 1,0,0},
{"gc", GC, 0}, {"gc", GC, 0,0,0},
{"clear", Clear, 1}, {"clear", Clear, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
JSClass global_class = { JSClass global_class = {

Просмотреть файл

@ -2133,9 +2133,9 @@ static JSClass SandboxClass = {
}; };
static JSFunctionSpec SandboxFunctions[] = { static JSFunctionSpec SandboxFunctions[] = {
{"dump", SandboxDump, 1}, {"dump", SandboxDump, 1,0,0},
{"debug", SandboxDebug, 1}, {"debug", SandboxDebug, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
#endif /* !XPCONNECT_STANDALONE */ #endif /* !XPCONNECT_STANDALONE */

Просмотреть файл

@ -116,9 +116,9 @@ Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} }
static JSFunctionSpec glob_functions[] = { static JSFunctionSpec glob_functions[] = {
{"print", Print, 0}, {"print", Print, 0,0,0},
{"load", Load, 1}, {"load", Load, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
static JSClass global_class = { static JSClass global_class = {

Просмотреть файл

@ -1416,31 +1416,31 @@ InstallFileOpWinRegisterServer(JSContext *cx, JSObject *obj, uintN argc, jsval *
// //
static JSFunctionSpec FileOpMethods[] = static JSFunctionSpec FileOpMethods[] =
{ {
{"dirCreate", InstallFileOpDirCreate, 1}, {"dirCreate", InstallFileOpDirCreate, 1,0,0},
{"dirGetParent", InstallFileOpDirGetParent, 1}, {"dirGetParent", InstallFileOpDirGetParent, 1,0,0},
{"dirRemove", InstallFileOpDirRemove, 2}, {"dirRemove", InstallFileOpDirRemove, 2,0,0},
{"dirRename", InstallFileOpDirRename, 2}, {"dirRename", InstallFileOpDirRename, 2,0,0},
{"copy", InstallFileOpFileCopy, 2}, {"copy", InstallFileOpFileCopy, 2,0,0},
{"remove", InstallFileOpFileRemove, 1}, {"remove", InstallFileOpFileRemove, 1,0,0},
{"exists", InstallFileOpFileExists, 1}, {"exists", InstallFileOpFileExists, 1,0,0},
{"execute", InstallFileOpFileExecute, 2}, {"execute", InstallFileOpFileExecute, 2,0,0},
{"nativeVersion", InstallFileOpFileGetNativeVersion, 1}, {"nativeVersion", InstallFileOpFileGetNativeVersion, 1,0,0},
{"windowsVersion", InstallFileOpFileGetNativeVersion, 1}, {"windowsVersion", InstallFileOpFileGetNativeVersion, 1,0,0},
{"diskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1}, {"diskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1,0,0},
{"modDate", InstallFileOpFileGetModDate, 1}, {"modDate", InstallFileOpFileGetModDate, 1,0,0},
{"size", InstallFileOpFileGetSize, 1}, {"size", InstallFileOpFileGetSize, 1,0,0},
{"isDirectory", InstallFileOpFileIsDirectory, 1}, {"isDirectory", InstallFileOpFileIsDirectory, 1,0,0},
{"isWritable", InstallFileOpFileIsWritable, 1}, {"isWritable", InstallFileOpFileIsWritable, 1,0,0},
{"isFile", InstallFileOpFileIsFile, 1}, {"isFile", InstallFileOpFileIsFile, 1,0,0},
{"modDateChanged", InstallFileOpFileModDateChanged, 2}, {"modDateChanged", InstallFileOpFileModDateChanged, 2,0,0},
{"move", InstallFileOpFileMove, 2}, {"move", InstallFileOpFileMove, 2,0,0},
{"rename", InstallFileOpFileRename, 2}, {"rename", InstallFileOpFileRename, 2,0,0},
{"windowsGetShortName", InstallFileOpFileWindowsGetShortName, 1}, {"windowsGetShortName", InstallFileOpFileWindowsGetShortName, 1,0,0},
{"windowsShortcut", InstallFileOpFileWindowsShortcut, 7}, {"windowsShortcut", InstallFileOpFileWindowsShortcut, 7,0,0},
{"macAlias", InstallFileOpFileMacAlias, 2}, {"macAlias", InstallFileOpFileMacAlias, 2,0,0},
{"unixLink", InstallFileOpFileUnixLink, 2}, {"unixLink", InstallFileOpFileUnixLink, 2,0,0},
{"windowsRegisterServer", InstallFileOpWinRegisterServer, 1}, {"windowsRegisterServer", InstallFileOpWinRegisterServer, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };

Просмотреть файл

@ -139,9 +139,9 @@ static void PR_CALLBACK FileSpecObjectCleanup(JSContext *cx, JSObject *obj)
// //
static JSFunctionSpec fileSpecObjMethods[] = static JSFunctionSpec fileSpecObjMethods[] =
{ {
{"appendPath", fso_AppendPath, 1}, {"appendPath", fso_AppendPath, 1,0,0},
{"toString", fso_ToString, 0}, {"toString", fso_ToString, 0,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };

Просмотреть файл

@ -1867,64 +1867,64 @@ static JSConstDoubleSpec install_constants[] =
static JSFunctionSpec InstallMethods[] = static JSFunctionSpec InstallMethods[] =
{ {
/*START HACK FOR DEBUGGING UNTIL ALERTS WORK*/ /*START HACK FOR DEBUGGING UNTIL ALERTS WORK*/
{"TRACE", InstallTRACE, 1}, {"TRACE", InstallTRACE, 1,0,0},
/*END HACK FOR DEBUGGING UNTIL ALERTS WORK*/ /*END HACK FOR DEBUGGING UNTIL ALERTS WORK*/
// -- new forms that match prevailing javascript style -- // -- new forms that match prevailing javascript style --
{"addDirectory", InstallAddDirectory, 6}, {"addDirectory", InstallAddDirectory, 6,0,0},
{"addFile", InstallAddSubcomponent, 6}, {"addFile", InstallAddSubcomponent, 6,0,0},
{"alert", InstallAlert, 1}, {"alert", InstallAlert, 1,0,0},
{"cancelInstall", InstallAbortInstall, 1}, {"cancelInstall", InstallAbortInstall, 1,0,0},
{"confirm", InstallConfirm, 8}, {"confirm", InstallConfirm, 8,0,0},
{"execute", InstallExecute, 2}, {"execute", InstallExecute, 2,0,0},
{"gestalt", InstallGestalt, 1}, {"gestalt", InstallGestalt, 1,0,0},
{"getComponentFolder", InstallGetComponentFolder, 2}, {"getComponentFolder", InstallGetComponentFolder, 2,0,0},
{"getFolder", InstallGetFolder, 2}, {"getFolder", InstallGetFolder, 2,0,0},
{"getLastError", InstallGetLastError, 0}, {"getLastError", InstallGetLastError, 0,0,0},
{"getWinProfile", InstallGetWinProfile, 2}, {"getWinProfile", InstallGetWinProfile, 2,0,0},
{"getWinRegistry", InstallGetWinRegistry, 0}, {"getWinRegistry", InstallGetWinRegistry, 0,0,0},
{"initInstall", InstallStartInstall, 4}, {"initInstall", InstallStartInstall, 4,0,0},
{"loadResources", InstallLoadResources, 1}, {"loadResources", InstallLoadResources, 1,0,0},
{"logComment", InstallLogComment, 1}, {"logComment", InstallLogComment, 1,0,0},
{"patch", InstallPatch, 5}, {"patch", InstallPatch, 5,0,0},
{"performInstall", InstallFinalizeInstall, 0}, {"performInstall", InstallFinalizeInstall, 0,0,0},
{"registerChrome", InstallRegisterChrome, 2}, {"registerChrome", InstallRegisterChrome, 2,0,0},
{"refreshPlugins", InstallRefreshPlugins, 1}, {"refreshPlugins", InstallRefreshPlugins, 1,0,0},
{"resetError", InstallResetError, 1}, {"resetError", InstallResetError, 1,0,0},
// {"selectChrome", InstallSelectChrome, 2}, // {"selectChrome", InstallSelectChrome, 2,0,0},
{"setPackageFolder", InstallSetPackageFolder, 1}, {"setPackageFolder", InstallSetPackageFolder, 1,0,0},
{"uninstall", InstallUninstall, 1}, {"uninstall", InstallUninstall, 1,0,0},
// the raw file methods are deprecated, use the File object instead // the raw file methods are deprecated, use the File object instead
{"dirCreate", InstallFileOpDirCreate, 1}, {"dirCreate", InstallFileOpDirCreate, 1,0,0},
{"dirGetParent", InstallFileOpDirGetParent, 1}, {"dirGetParent", InstallFileOpDirGetParent, 1,0,0},
{"dirRemove", InstallFileOpDirRemove, 2}, {"dirRemove", InstallFileOpDirRemove, 2,0,0},
{"dirRename", InstallFileOpDirRename, 2}, {"dirRename", InstallFileOpDirRename, 2,0,0},
{"fileCopy", InstallFileOpFileCopy, 2}, {"fileCopy", InstallFileOpFileCopy, 2,0,0},
{"fileDelete", InstallFileOpFileRemove, 1}, {"fileDelete", InstallFileOpFileRemove, 1,0,0},
{"fileExists", InstallFileOpFileExists, 1}, {"fileExists", InstallFileOpFileExists, 1,0,0},
{"fileExecute", InstallFileOpFileExecute, 2}, {"fileExecute", InstallFileOpFileExecute, 2,0,0},
{"fileGetNativeVersion", InstallFileOpFileGetNativeVersion, 1}, {"fileGetNativeVersion", InstallFileOpFileGetNativeVersion, 1,0,0},
{"fileGetDiskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1}, {"fileGetDiskSpaceAvailable", InstallFileOpFileGetDiskSpaceAvailable,1,0,0},
{"fileGetModDate", InstallFileOpFileGetModDate, 1}, {"fileGetModDate", InstallFileOpFileGetModDate, 1,0,0},
{"fileGetSize", InstallFileOpFileGetSize, 1}, {"fileGetSize", InstallFileOpFileGetSize, 1,0,0},
{"fileIsDirectory", InstallFileOpFileIsDirectory, 1}, {"fileIsDirectory", InstallFileOpFileIsDirectory, 1,0,0},
{"fileIsWritable", InstallFileOpFileIsWritable, 1}, {"fileIsWritable", InstallFileOpFileIsWritable, 1,0,0},
{"fileIsFile", InstallFileOpFileIsFile, 1}, {"fileIsFile", InstallFileOpFileIsFile, 1,0,0},
{"fileModDateChanged", InstallFileOpFileModDateChanged, 2}, {"fileModDateChanged", InstallFileOpFileModDateChanged, 2,0,0},
{"fileMove", InstallFileOpFileMove, 2}, {"fileMove", InstallFileOpFileMove, 2,0,0},
{"fileRename", InstallFileOpFileRename, 2}, {"fileRename", InstallFileOpFileRename, 2,0,0},
{"fileWindowsShortcut", InstallFileOpFileWindowsShortcut, 7}, {"fileWindowsShortcut", InstallFileOpFileWindowsShortcut, 7,0,0},
{"fileMacAlias", InstallFileOpFileMacAlias, 2}, {"fileMacAlias", InstallFileOpFileMacAlias, 2,0,0},
{"fileUnixLink", InstallFileOpFileUnixLink, 2}, {"fileUnixLink", InstallFileOpFileUnixLink, 2,0,0},
// -- documented but never supported -- // -- documented but never supported --
{"deleteRegisteredFile", InstallDeleteComponent, 1}, {"deleteRegisteredFile", InstallDeleteComponent, 1,0,0},
// -- obsolete forms for temporary compatibility -- // -- obsolete forms for temporary compatibility --
{"abortInstall", InstallAbortInstall, 1}, {"abortInstall", InstallAbortInstall, 1,0,0},
{"finalizeInstall", InstallFinalizeInstall, 0}, {"finalizeInstall", InstallFinalizeInstall, 0,0,0},
{"startInstall", InstallStartInstall, 4}, {"startInstall", InstallStartInstall, 4,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };

Просмотреть файл

@ -741,19 +741,19 @@ InstallTriggerGlobalGetVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *
static JSFunctionSpec InstallTriggerGlobalMethods[] = static JSFunctionSpec InstallTriggerGlobalMethods[] =
{ {
// -- obsolete forms, do not document. Kept for 4.x compatibility // -- obsolete forms, do not document. Kept for 4.x compatibility
{"UpdateEnabled", InstallTriggerGlobalUpdateEnabled, 0}, {"UpdateEnabled", InstallTriggerGlobalUpdateEnabled, 0,0,0},
{"StartSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2}, {"StartSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2,0,0},
{"CompareVersion", InstallTriggerGlobalCompareVersion, 5}, {"CompareVersion", InstallTriggerGlobalCompareVersion, 5,0,0},
{"GetVersion", InstallTriggerGlobalGetVersion, 2}, {"GetVersion", InstallTriggerGlobalGetVersion, 2,0,0},
{"updateEnabled", InstallTriggerGlobalUpdateEnabled, 0}, {"updateEnabled", InstallTriggerGlobalUpdateEnabled, 0,0,0},
// -- new forms to match JS style -- // -- new forms to match JS style --
{"enabled", InstallTriggerGlobalUpdateEnabled, 0}, {"enabled", InstallTriggerGlobalUpdateEnabled, 0,0,0},
{"install", InstallTriggerGlobalInstall, 2}, {"install", InstallTriggerGlobalInstall, 2,0,0},
{"installChrome", InstallTriggerGlobalInstallChrome, 2}, {"installChrome", InstallTriggerGlobalInstallChrome, 2,0,0},
{"startSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2}, {"startSoftwareUpdate", InstallTriggerGlobalStartSoftwareUpdate, 2,0,0},
{"compareVersion", InstallTriggerGlobalCompareVersion, 5}, {"compareVersion", InstallTriggerGlobalCompareVersion, 5,0,0},
{"getVersion", InstallTriggerGlobalGetVersion, 2}, {"getVersion", InstallTriggerGlobalGetVersion, 2,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
@ -769,7 +769,7 @@ static JSConstDoubleSpec diff_constants[] =
{ CHROME_LOCALE, "LOCALE" }, { CHROME_LOCALE, "LOCALE" },
{ CHROME_CONTENT, "CONTENT" }, { CHROME_CONTENT, "CONTENT" },
{ CHROME_ALL, "PACKAGE" }, { CHROME_ALL, "PACKAGE" },
{0} {0,nsnull}
}; };

Просмотреть файл

@ -523,10 +523,10 @@ static JSPropertySpec InstallVersionProperties[] =
// //
static JSFunctionSpec InstallVersionMethods[] = static JSFunctionSpec InstallVersionMethods[] =
{ {
{"init", InstallVersionInit, 1}, {"init", InstallVersionInit, 1,0,0},
{"toString", InstallVersionToString, 0}, {"toString", InstallVersionToString, 0,0,0},
{"compareTo", InstallVersionCompareTo, 1}, {"compareTo", InstallVersionCompareTo, 1,0,0},
{0} {nsnull,nsnull,0,0,0}
}; };
static JSConstDoubleSpec version_constants[] = static JSConstDoubleSpec version_constants[] =
@ -540,7 +540,7 @@ static JSConstDoubleSpec version_constants[] =
{ nsIDOMInstallVersion::MINOR_DIFF_MINUS, "MINOR_DIFF_MINUS" }, { nsIDOMInstallVersion::MINOR_DIFF_MINUS, "MINOR_DIFF_MINUS" },
{ nsIDOMInstallVersion::MAJOR_DIFF, "MAJOR_DIFF" }, { nsIDOMInstallVersion::MAJOR_DIFF, "MAJOR_DIFF" },
{ nsIDOMInstallVersion::MAJOR_DIFF_MINUS, "MAJOR_DIFF_MINUS" }, { nsIDOMInstallVersion::MAJOR_DIFF_MINUS, "MAJOR_DIFF_MINUS" },
{0} {0,nsnull}
}; };

Просмотреть файл

@ -1,217 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsString.h"
#include "nsInstall.h"
#include "nsWinProfile.h"
#include "nsJSWinProfile.h"
extern void ConvertJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
static void PR_CALLBACK
WinProfileCleanup(JSContext *cx, JSObject *obj);
/***********************************************************************/
//
// class for WinProfile
//
JSClass WinProfileClass = {
"WinProfile",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
WinProfileCleanup
};
static void PR_CALLBACK WinProfileCleanup(JSContext *cx, JSObject *obj)
{
nsWinProfile *nativeThis = (nsWinProfile*)JS_GetPrivate(cx, obj);
delete nativeThis;
}
/***********************************************************************************/
// Native mothods for WinProfile functions
//
// Native method GetString
//
PR_STATIC_CALLBACK(JSBool)
WinProfileGetString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinProfile *nativeThis =
(nsWinProfile*)JS_GetInstancePrivate(cx, obj, &WinProfileClass, argv);
if (!nativeThis)
return JS_FALSE;
nsString nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public string getString ( String section,
// String key);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
nativeThis->GetString(b0, b1, &nativeRet);
ConvertStrToJSVal(nativeRet, cx, rval);
}
else
{
JS_ReportWarning(cx, "WinProfile.getString() parameters error");
}
return JS_TRUE;
}
//
// Native method WriteString
//
PR_STATIC_CALLBACK(JSBool)
WinProfileWriteString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinProfile *nativeThis =
(nsWinProfile*)JS_GetInstancePrivate(cx, obj, &WinProfileClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
nsAutoString b2;
*rval = JSVAL_ZERO;
if(argc >= 3)
{
// public int writeString ( String section,
// String key,
// String value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
ConvertJSValToStr(b2, cx, argv[2]);
if(NS_OK == nativeThis->WriteString(b0, b1, b2, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinProfile.writeString() parameters error");
}
return JS_TRUE;
}
//
// WinProfile constructor
//
PR_STATIC_CALLBACK(JSBool)
WinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
static JSConstDoubleSpec winprofile_constants[] =
{
{0}
};
//
// WinProfile class methods
//
static JSFunctionSpec WinProfileMethods[] =
{
{"getString", WinProfileGetString, 2},
{"writeString", WinProfileWriteString, 3},
{0}
};
PRInt32
InitWinProfilePrototype(JSContext *jscontext, JSObject *global, JSObject **winProfilePrototype)
{
*winProfilePrototype = JS_InitClass( jscontext, // context
global, // global object
nsnull, // parent proto
&WinProfileClass, // JSClass
nsnull, // JSNative ctor
0, // ctor args
nsnull, // proto props
nsnull, // proto funcs
nsnull, // ctor props (static)
WinProfileMethods); // ctor funcs (static)
if(nsnull == *winProfilePrototype)
{
return NS_ERROR_FAILURE;
}
if(PR_FALSE == JS_DefineConstDoubles(jscontext, *winProfilePrototype, winprofile_constants))
return NS_ERROR_FAILURE;
return NS_OK;
}

Просмотреть файл

@ -1,748 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsString.h"
#include "nsInstall.h"
#include "nsWinReg.h"
#include "nsJSWinReg.h"
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj);
extern void ConvertJSValToStr(nsString& aString,
JSContext* aContext,
jsval aValue);
extern void ConvertStrToJSVal(const nsString& aProp,
JSContext* aContext,
jsval* aReturn);
extern PRBool ConvertJSValToBool(PRBool* aProp,
JSContext* aContext,
jsval aValue);
static void PR_CALLBACK WinRegCleanup(JSContext *cx, JSObject *obj)
{
nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj);
delete nativeThis;
}
/***********************************************************************/
//
// class for WinReg
//
JSClass WinRegClass = {
"WinReg",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
WinRegCleanup
};
/***********************************************************************************/
// Native mothods for WinReg functions
//
// Native method SetRootKey
//
PR_STATIC_CALLBACK(JSBool)
WinRegSetRootKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 b0;
*rval = JSVAL_NULL;
if(argc >= 1)
{
// public void setRootKey(PRInt32 key);
if(JS_ValueToInt32(cx, argv[0], (int32 *)&b0))
{
nativeThis->SetRootKey(b0);
}
else
{
JS_ReportWarning(cx, "Parameter must be a number");
}
}
else
{
JS_ReportWarning(cx, "Function SetRootKey requires 1 parameters");
}
return JS_TRUE;
}
//
// Native method KeyExists
//
PR_STATIC_CALLBACK(JSBool)
WinRegKeyExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRBool nativeRet;
nsAutoString b0;
*rval = JSVAL_FALSE;
if(argc >= 1)
{
// public boolean keyExists ( String subKey );
ConvertJSValToStr(b0, cx, argv[0]);
if(NS_OK == nativeThis->KeyExists(b0, &nativeRet))
{
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
else
{
NS_WARNING("WinReg.KeyExists() internal error");
}
}
else
{
JS_ReportWarning(cx, "WinReg.KeyExists() parameters error");
}
return JS_TRUE;
}
//
// Native method ValueExists
//
PR_STATIC_CALLBACK(JSBool)
WinRegValueExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRBool nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_FALSE;
if(argc >= 2)
{
// public boolean valueExists ( String subKey,
// String value );
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->ValueExists(b0, b1, &nativeRet))
{
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.ValueExists() parameters error");
}
return JS_TRUE;
}
//
// Native method IsKeyWritable
//
PR_STATIC_CALLBACK(JSBool)
WinRegIsKeyWritable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = JSVAL_FALSE;
if(argc >= 1)
{
// public boolean isKeyWritable ( String subKey );
ConvertJSValToStr(b0, cx, argv[0]);
if(NS_OK == nativeThis->IsKeyWritable(b0, &nativeRet))
{
*rval = BOOLEAN_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.IsKeyWritable() parameters error");
}
return JS_TRUE;
}
//
// Native method CreateKey
//
PR_STATIC_CALLBACK(JSBool)
WinRegCreateKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 2)
{
// public int createKey ( String subKey,
// String className);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->CreateKey(b0, b1, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.CreateKey() parameters error");
}
return JS_TRUE;
}
//
// Native method DeleteKey
//
PR_STATIC_CALLBACK(JSBool)
WinRegDeleteKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 1)
{
// public int deleteKey ( String subKey);
ConvertJSValToStr(b0, cx, argv[0]);
if(NS_OK == nativeThis->DeleteKey(b0, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.DeleteKey() parameters error");
}
return JS_TRUE;
}
//
// Native method DeleteValue
//
PR_STATIC_CALLBACK(JSBool)
WinRegDeleteValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsString b0;
nsString b1;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 2)
{
// public int deleteValue ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->DeleteValue(b0, b1, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.DeleteValue() parameters error");
}
return JS_TRUE;
}
//
// Native method SetValueString
//
PR_STATIC_CALLBACK(JSBool)
WinRegSetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
nsAutoString b2;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 3)
{
// public int setValueString ( String subKey,
// String valueName,
// String value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
ConvertJSValToStr(b2, cx, argv[2]);
if(NS_OK == nativeThis->SetValueString(b0, b1, b2, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.SetValueString() parameters error");
}
return JS_TRUE;
}
//
// Native method GetValueString
//
PR_STATIC_CALLBACK(JSBool)
WinRegGetValueString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
nsString nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public string getValueString ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->GetValueString(b0, b1, &nativeRet))
{
ConvertStrToJSVal(nativeRet, cx, rval);
}
}
else
{
JS_ReportWarning(cx, "WinReg.GetValueString() parameters error");
}
return JS_TRUE;
}
//
// Native method enumValueNames
//
PR_STATIC_CALLBACK(JSBool)
WinRegEnumValueNames(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
nsAutoString nativeRet;
nsAutoString b0;
int32 b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public String enumValueNames ( String subkey,
// Int index);
ConvertJSValToStr(b0, cx, argv[0]);
if(JS_ValueToInt32(cx, argv[1], &b1))
{
if ( NS_OK == nativeThis->EnumValueNames(b0, b1, nativeRet) )
{
ConvertStrToJSVal(nativeRet, cx, rval);
}
}
else
{
JS_ReportWarning(cx, "WinReg.enumValueNames - Parameter 2 must be a number");
}
}
else
{
JS_ReportWarning(cx, "WinReg.enumValueNames() - Too few parameters");
}
return JS_TRUE;
}
//
// Native method enumKeys
//
PR_STATIC_CALLBACK(JSBool)
WinRegEnumKeys(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
nsAutoString nativeRet;
nsAutoString b0;
int32 b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public String enumKeys ( String subkey,
// Int index);
ConvertJSValToStr(b0, cx, argv[0]);
if(JS_ValueToInt32(cx, argv[1], &b1))
{
if ( NS_OK == nativeThis->EnumKeys(b0, b1, nativeRet) )
{
ConvertStrToJSVal(nativeRet, cx, rval);
}
}
else
{
JS_ReportWarning(cx, "WinReg.enumKeys() - Parameter 2 must be a number");
}
}
else
{
JS_ReportWarning(cx, "WinReg.enumKeys() - Too few parameters");
}
return JS_TRUE;
}
//
// Native method SetValueNumber
//
PR_STATIC_CALLBACK(JSBool)
WinRegSetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
int32 ib2;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 3)
{
// public int setValueNumber ( String subKey,
// String valueName,
// Number value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(!JS_ValueToInt32(cx, argv[2], &ib2))
{
JS_ReportWarning(cx, "Parameter 3 must be a number");
}
else if(NS_OK == nativeThis->SetValueNumber(b0, b1, ib2, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.SetValueNumber() parameters error");
}
return JS_TRUE;
}
//
// Native method GetValueNumber
//
PR_STATIC_CALLBACK(JSBool)
WinRegGetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public int getValueNumber ( String subKey,
// Number valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->GetValueNumber(b0, b1, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.GetValueNumber() parameters error");
}
return JS_TRUE;
}
//
// Native method SetValue
//
PR_STATIC_CALLBACK(JSBool)
WinRegSetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
nsAutoString b0;
nsAutoString b1;
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);
if(argc >= 3)
{
// public int setValue ( String subKey,
// String valueName,
// nsWinRegItem *value);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
// fix: this parameter is an object, not a string.
// A way needs to be figured out to convert the JSVAL to this object type
// ConvertJSValToStr(b2, cx, argv[2]);
// if(NS_OK != nativeThis->SetValue(b0, b1, b2, &nativeRet))
// {
// return JS_FALSE;
// }
// *rval = INT_TO_JSVAL(nativeRet);
}
else
{
JS_ReportWarning(cx, "WinReg.SetValue() parameters error");
}
return JS_TRUE;
}
//
// Native method GetValue
//
PR_STATIC_CALLBACK(JSBool)
WinRegGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsWinReg *nativeThis =
(nsWinReg*)JS_GetInstancePrivate(cx, obj, &WinRegClass, argv);
if (!nativeThis)
return JS_FALSE;
nsWinRegValue *nativeRet;
nsAutoString b0;
nsAutoString b1;
*rval = JSVAL_NULL;
if(argc >= 2)
{
// public int getValue ( String subKey,
// String valueName);
ConvertJSValToStr(b0, cx, argv[0]);
ConvertJSValToStr(b1, cx, argv[1]);
if(NS_OK == nativeThis->GetValue(b0, b1, &nativeRet))
{
*rval = INT_TO_JSVAL(nativeRet);
}
}
else
{
JS_ReportWarning(cx, "WinReg.GetValue() parameters error");
}
return JS_TRUE;
}
//
// WinReg constructor
//
PR_STATIC_CALLBACK(JSBool)
WinReg(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
return JS_FALSE;
}
static JSConstDoubleSpec winreg_constants[] =
{
{ nsWinReg::NS_HKEY_CLASSES_ROOT, "HKEY_CLASSES_ROOT" },
{ nsWinReg::NS_HKEY_CURRENT_USER, "HKEY_CURRENT_USER" },
{ nsWinReg::NS_HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE" },
{ nsWinReg::NS_HKEY_USERS, "HKEY_USERS" },
{0}
};
//
// WinReg class methods
//
static JSFunctionSpec WinRegMethods[] =
{
{"setRootKey", WinRegSetRootKey, 1},
{"keyExists", WinRegKeyExists, 1},
{"valueExists", WinRegValueExists, 2},
{"isKeyWritable", WinRegIsKeyWritable, 1},
{"createKey", WinRegCreateKey, 2},
{"deleteKey", WinRegDeleteKey, 1},
{"deleteValue", WinRegDeleteValue, 2},
{"setValueString", WinRegSetValueString, 3},
{"getValueString", WinRegGetValueString, 2},
{"setValueNumber", WinRegSetValueNumber, 3},
{"getValueNumber", WinRegGetValueNumber, 2},
{"setValue", WinRegSetValue, 3},
{"getValue", WinRegGetValue, 2},
{"enumKeys", WinRegEnumKeys, 2},
{"enumValueNames", WinRegEnumValueNames, 2},
{0}
};
PRInt32
InitWinRegPrototype(JSContext *jscontext, JSObject *global, JSObject **winRegPrototype)
{
*winRegPrototype = JS_InitClass( jscontext, // context
global, // global object
nsnull, // parent proto
&WinRegClass, // JSClass
nsnull, // JSNative ctor
0, // ctor args
nsnull, // proto props
nsnull, // proto funcs
nsnull, // ctor props (static)
WinRegMethods); // ctor funcs (static)
if(nsnull == *winRegPrototype)
{
return NS_ERROR_FAILURE;
}
if(PR_FALSE == JS_DefineConstDoubles(jscontext, *winRegPrototype, winreg_constants))
return NS_ERROR_FAILURE;
return NS_OK;
}