Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsJSFileSpecObj.cpp File Reference
#include "jsapi.h"
#include "nscore.h"
#include "nsIScriptContext.h"
#include "nsString.h"
#include "nsInstall.h"
#include "nsJSFileSpecObj.h"

Go to the source code of this file.

Functions

void ConvertJSValToStr (nsString &aString, JSContext *aContext, jsval aValue)
void ConvertStrToJSVal (const nsString &aProp, JSContext *aContext, jsval *aReturn)
PRBool ConvertJSValToBool (PRBool *aProp, JSContext *aContext, jsval aValue)
static void PR_CALLBACK FileSpecObjectCleanup (JSContext *cx, JSObject *obj)
 fso_ToString (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 fso_AppendPath (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
PRInt32 InitFileSpecObjectPrototype (JSContext *jscontext, JSObject *global, JSObject **fileSpecObjectPrototype)

Variables

JSClass FileSpecObjectClass
static JSFunctionSpec fileSpecObjMethods []

Function Documentation

PRBool ConvertJSValToBool ( PRBool aProp,
JSContext aContext,
jsval  aValue 
)

Definition at line 276 of file nsJSInstall.cpp.

{
  JSBool temp;
  if(JSVAL_IS_BOOLEAN(aValue) && JS_ValueToBoolean(aContext, aValue, &temp))
  {
    *aProp = (PRBool)temp;
  }
  else
  {
    JS_ReportError(aContext, "Parameter must be a boolean");
    return JS_FALSE;
  }

  return JS_TRUE;
}
void ConvertJSValToStr ( nsString aString,
JSContext aContext,
jsval  aValue 
)

Definition at line 250 of file nsJSInstall.cpp.

{
  JSString *jsstring;

  if ( !JSVAL_IS_NULL(aValue) &&
       (jsstring = JS_ValueToString(aContext, aValue)) != nsnull)
  {
    aString.Assign(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)));
  }
  else
  {
    aString.Truncate();
  }
}
void ConvertStrToJSVal ( const nsString aProp,
JSContext aContext,
jsval aReturn 
)

Definition at line 267 of file nsJSInstall.cpp.

{
  JSString *jsstring = JS_NewUCStringCopyN(aContext, NS_REINTERPRET_CAST(const jschar*, aProp.get()), aProp.Length());
  // set the return value
  *aReturn = STRING_TO_JSVAL(jsstring);
}
static void PR_CALLBACK FileSpecObjectCleanup ( JSContext cx,
JSObject obj 
) [static]

Definition at line 130 of file nsJSFileSpecObj.cpp.

{
  nsInstallFolder *nativeThis = (nsInstallFolder*)JS_GetPrivate(cx, obj);
  if (nativeThis != nsnull)
    delete nativeThis;
}

Here is the call graph for this function:

fso_AppendPath ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 121 of file nsJSFileSpecObj.cpp.

{
  return JS_TRUE;
}
fso_ToString ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 89 of file nsJSFileSpecObj.cpp.

{
  nsInstallFolder *nativeThis =
    (nsInstallFolder*)JS_GetInstancePrivate(cx, obj, &FileSpecObjectClass,
                                            argv);
  if (!nativeThis)
    return JS_FALSE;

  nsAutoString stringReturned;

  *rval = JSVAL_NULL;

  if(NS_FAILED( nativeThis->ToString(&stringReturned)))
    return JS_TRUE;


  JSString *jsstring =
    JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*,
                                                stringReturned.get()),
                        stringReturned.Length());

  // set the return value
  *rval = STRING_TO_JSVAL(jsstring);

  return JS_TRUE;
}

Here is the call graph for this function:

PRInt32 InitFileSpecObjectPrototype ( JSContext jscontext,
JSObject global,
JSObject **  fileSpecObjectPrototype 
)

Definition at line 148 of file nsJSFileSpecObj.cpp.

{
  *fileSpecObjectPrototype  = JS_InitClass( jscontext,         // context
                                            global,            // global object
                                            nsnull,            // parent proto 
                                            &FileSpecObjectClass, // JSClass
                                            nsnull,            // JSNative ctor
                                            0,                 // ctor args
                                            nsnull,            // proto props
                                            fileSpecObjMethods,// proto funcs
                                            nsnull,            // ctor props (static)
                                            nsnull);           // ctor funcs (static)

  if (nsnull == *fileSpecObjectPrototype) 
  {
      return NS_ERROR_FAILURE;
  }

 
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
 
{
  {"appendPath",       fso_AppendPath,     1},
  {"toString",         fso_ToString,       0},
  {0}
}

Definition at line 140 of file nsJSFileSpecObj.cpp.