Hotfix Release available. [36.1] (what's this?)
 

Particularités

Le type void

Le type void, dans le fichier IDL, n'est utilisé que comme paramètre de retour. Pour siginifer qu'une fonction n'a pas de paramètre d'entrée, mettre une liste de paramètre vide '()'.

Ceci est incorrect :

void F( void );

Ceci est correct :

void F();

Et a pour équivalent C++ :

NS_IMETHODIMP myclass::F( void )

Chaîne de caractères

(Tiré de http://www.mozilla.org/scriptable/faq.html#i9)

Lorsque l'on désire implémenter une fonction semblable à ceci (.idl):

interface nsIXPCTestString : nsISupports {
    string GetStringA();
};

il ne faut pas l'implémenter de la manière suivante (.cpp):

NS_IMETHODIMP
xpcstringtest::GetStringA(char **_retval)
{
    *_retval = "result of xpcstringtest::GetStringA";
    return NS_OK;
}        

mais de la manière suivante (.cpp):

NS_IMETHODIMP
xpcstringtest::GetStringA(char **_retval)
{
    const char myResult[] = "result of xpcstringtest::GetStringA";
 
    if(!_retval)
        return NS_ERROR_NULL_POINTER;
 
    *_retval = (char*) nsMemory::Clone(myResult, 
                                       sizeof(char)*(strlen(myResult)+1));
    return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

A priori, cela est également valable pour les chaînes de caractères passé comme paramètre 'out'.

'nsEmbedString'

Beaucoup de méthodes requièrent un nsEmbedString. Poour convertir un const char *, en nsEmbedString, utiliser NS_LITERAL_STRING. Exemple :

nsEmbedString String = NS_LITERAL_STRING( "texte à convertir." );

Types

(Tiré de http://www.mozilla.org/scriptable/xpidl/idl-authors-guide/rules.html#types)

IDL C++ mapping
void1) void
boolean PRBool
octet PRUint8
short PRInt16
long PRInt32
long long PRInt64
unsigned short PRUint16
unsigned long PRUint32
unsigned long long PRUint64
float float
double double
char char
wchar PRUnichar
string char*
wstring PRUnichar*
1) voir remarque sur le type void en début de page
other/gecko/xpcom/writing/xpidl/synthesis.txt · Last modified: 2007/11/26 11:06 by 217.167.194.108
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki