Main Page   Compound List   File List   Compound Members   File Members  

TclXPCOMMarshall.cpp File Reference

#include "TclXPCOMPrivate.h"
#include "nsAString.h"
#include "nsReadableUtils.h"

Go to the source code of this file.

Functions

size_t GetElementTypeSize (nsXPTType *type)
void CleanupParam (void **params, void *param, nsXPTType *type, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo)
nsresult Native2Tcl (void **params, void *param, nsXPTType *type, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo, Tcl_Obj **result)
int Tcl2Native (Tcl_Interp *interp, Tcl_Obj *value, void **params, void *param, nsXPTType *type, int shared, nsIInterfaceInfo *interfaceinfo, PRUint16 methodindex, nsXPTParamInfo *paraminfo)


Detailed Description

Functions for converting between Tcl and XPCOM values.

See also:
http://www.mozilla.org/scriptable/typelib_file.html#TypeDescriptor

Definition in file TclXPCOMMarshall.cpp.


Function Documentation

size_t GetElementTypeSize nsXPTType *    type
 

Determines the size of an XPT type.

Returns:
the size in bytes of the given type, or 0 if the typecode is invalid
Parameters:
type  (in) an XPT typecode

Definition at line 55 of file TclXPCOMMarshall.cpp.

Referenced by CleanupParam, Native2Tcl, and Tcl2Native.

void CleanupParam void **    params,
void *    param,
nsXPTType *    type,
nsIInterfaceInfo *    interfaceinfo,
PRUint16    methodindex,
nsXPTParamInfo *    paraminfo
 

Frees a parameter, if appropriate for the given type.

Note:
Void* parameters are not freed: calling non-scriptable methods with these may cause memory leaks.
Parameters:
params  (in) array of parameters in method
param  (in) address of parameter to free
type  (in) XPT typecode of the parameter to free
interfaceinfo  (in) interface information for the method
methodindex  (in) index into interface of method
paraminfo  (in) array of parameter info for method

Definition at line 128 of file TclXPCOMMarshall.cpp.

References CleanupParam, and GetElementTypeSize.

nsresult Native2Tcl void **    params,
void *    param,
nsXPTType *    type,
nsIInterfaceInfo *    interfaceinfo,
PRUint16    methodindex,
nsXPTParamInfo *    paraminfo,
Tcl_Obj **    result
 

Converts a native value to a new Tcl object whose refcount is 0.

Return values:
NS_OK  - if successful
NS_ERROR_INVALID_ARG  - if the given typecode is invalid
NS_ERROR_NULL_POINTER  - if the parameter cannot be a null pointer
Parameters:
params  (in) array of parameters in method
param  (in) address of parameter to convert
type  (in) XPT typecode of the parameter to convert
interfaceinfo  (in) interface information for the method
methodindex  (in) index into interface of method
paraminfo  (in) array of parameter info for method
result  (out) address to store a reference to the created Tcl Object

Definition at line 204 of file TclXPCOMMarshall.cpp.

References GetElementTypeSize, Native2Tcl, TclXPCOM_NewISupportsObj, TclXPCOM_NewNsIDObj, TclXPCOM_NewPointerObj, TclXPCOM_NewWideIntObj, and TclXPCOM_WideInt.

int Tcl2Native Tcl_Interp *    interp,
Tcl_Obj *    value,
void **    params,
void *    param,
nsXPTType *    type,
int    shared,
nsIInterfaceInfo *    interfaceinfo,
PRUint16    methodindex,
nsXPTParamInfo *    paraminfo
 

Converts a Tcl Object to a native value. If an error occurs, an error message will be stored in the interpreter's result and the 'errorCode' variable will be set to the corresponding XPCOM return code.

Return values:
TCL_OK  - if successful
TCL_ERROR  - if an error occurs during conversion
Parameters:
interp  (in) interpreter to hold error message
value  (in) Tcl Object to convert
params  (in) array of parameters in method
param  (out) address to store converted parameter
type  (in) XPT typecode of parameter
shared  (in) flag indicating parameter is shared & dependent
interfaceinfo  (in) interface information for the method
methodindex  (in) index into interface of method
paraminfo  (in) array of parameter info for method

Definition at line 502 of file TclXPCOMMarshall.cpp.

References CloneMemory, GetElementTypeSize, Tcl2Native, TclXPCOM_GetISupportsFromObj, TclXPCOM_GetNsIDFromObj, TclXPCOM_GetPointerFromObj, TclXPCOM_GetWideIntFromObj, TclXPCOM_IsNULL, TclXPCOM_QueryISupportsObj, TclXPCOM_SetError, and TclXPCOM_WideInt.


Generated on Fri Jun 14 23:25:52 2002 for TclXPCOM by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002