Subj : Re: AutoConfigProxy -> JSEng To : netscape.public.mozilla.jseng From : "Corail131" Date : Fri Apr 02 2004 04:11 pm Ho i'm sorry, i have not good read the response to set into rval. I thought that it is JS_TRUE, and in real this is JSVAL_TRUE... Forgot the last message!!!! Many thanks Corail131 "Corail131" wrote in message news:c4jji5$cuk1@ripley.netscape.com... > Thanks a lot for your help to both. > > I just had a problem, because if I assign rval to JS_TRUE, the function (if > (localHostOrDomainIs) in javascript return 0. > I must assign rval to ~JS_TRUE to have a return equal to true > > My code is now as it: > > /* 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; > > *rval = ~bret; > > return bret; > } > > > Good code, bye > Corail131 > > "Brendan Eich" wrote in message > news:406C097D.605@meer.net... > > Mark Warren wrote: > > > You need to set *rval to either JSVAL_TRUE or JSVAL_FALSE to return a > > > boolean value back to the script. Returning JS_TRUE/JS_FALSE from the > > > function simply tells the JS engine whether to continue or abort > execution. > > > > Right -- thanks for following up, showing JSVAL_TRUE and JSVAL_FALSE in > > particular. But one note: it's bad practice to return false from the C > > function to abort execution, without reporting the error or calling an > > API or one of your own subroutines that reported for you. Silently > > aborting is painful -- it's difficult to find whodunnit. > > > > /be > > .