Subj : Re: AutoConfigProxy -> JSEng To : Corail From : Brendan Eich Date : Thu Apr 01 2004 04:19 am Corail wrote: > Hi, > > this is the code : > > /* Define a bunch of native functions first: */ > static JSBool mylocalHostOrDomainIs(JSContext *cx, JSObject *obj, uintN > argc, jsval *argv, jsval *rval) > { > JSBool bret = JS_FALSE; > if (argc != 2) > return bret; > > char *host=NULL, *hostdom=NULL; > > host = JS_GetStringBytes(JSVAL_TO_STRING(argv[0])); > hostdom = JS_GetStringBytes(JSVAL_TO_STRING(argv[1])); > > if (_tcschr(host, '.') == NULL) > bret = JS_TRUE; > > if ( _tcsnicmp(host, hostdom, _tcslen(host)) == 0) > bret = JS_TRUE; > > return bret; > } Please read http://lxr.mozilla.org/mozilla/source/js/src/README.html, noting especially the Defining functions section, and this paragraph: In general, errors are signaled by false or unoverloaded-null return values, and are reported using JS_ReportError() or one of its variants by the lowest level in order to provide the most detail. Client code can substitute its own error reporting function and suppress errors, or reflect them into Java or some other runtime system as exceptions, GUI dialogs, etc. You took pains to return JS_FALSE from the C native function as if that were the return value of the function called from JS. It is not. The return value, which is not necessarily a boolean, goes in *rval. The C return value is a boolean meaning error (JS_FALSE) or ok (JS_TRUE). In the error case, you must have reported the error yourself, or called a JS API that itself returned false (or null) indicating that it reported an error you should propagate. /be > > Corail131 > > "Brendan Eich" wrote in message > news:406B9E88.7040602@meer.net... > >>Corail131 wrote: >> >> >>>I have add a function into my JSObject object named >>>mylocalHostOrDomainIs that is bind to ths javascript function >>>localHostOrDomainIs. >>> >>>Why the second IF doesn't run ??? >> >>Show your code for mylocalHostOrDomainIs and perhaps someone can help. >>Not showing code that anyone trying to diagnose the problem would need >>to read is not helpful. >> >>/be >> > > > .