Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsSampleImpl Class Reference

#include <nsSample.h>

Inheritance diagram for nsSampleImpl:
Inheritance graph
Collaboration diagram for nsSampleImpl:
Collaboration graph

List of all members.

Public Member Functions

 nsSampleImpl ()
 A sample of XPConnect.
void writeValue (in string aPrefix)
void poke (in string aValue)

Public Attributes

attribute string value

Private Member Functions

 ~nsSampleImpl ()
 This macro expands into a declaration of the nsISupports interface.

Private Attributes

char * mValue

Detailed Description

Definition at line 63 of file nsSample.h.

Constructor & Destructor Documentation

A sample of XPConnect.

This file contains an implementation nsSample of the interface nsISample.

Definition at line 54 of file nsSample.cpp.

                           : mValue(nsnull)
    mValue = (char*)nsMemory::Clone("initial value", 14);

Here is the call graph for this function:

This macro expands into a declaration of the nsISupports interface.

Every XPCOM component needs to implement nsISupports, as it acts as the gateway to other interfaces this component implements. You could manually declare QueryInterface, AddRef, and Release instead of using this macro, but why? This macro is defined in the nsISample.h file, and is generated automatically by the xpidl compiler. It expands to declarations of all of the methods required to implement the interface. xpidl will generate a NS_DECL_[INTERFACENAME] macro for each interface that it processes.

The methods of nsISample are discussed individually below, but commented out (because this macro already defines them.) The following is an explanation of how the interface header file expands to for a c++ implementation. NS_DELC_NSISAMPLE takes care of defining the right c++ implementation.

The following if provided for more understanding.

NS_IMETHOD expands to the standard XPCOM return type. XPCOM methods should never return any other type. The return value is used behind the scenes by the XPConnect runtime to figure out if the call failed in any way. These methods were generated by "attribute string Value" in nsISample.idl. When reflected into JavaScript, XPCOM will use these calls as Getter/Setter ops, so that they can be called transparently as "sample.Value='foo';" and "var val = sample.Value" The const came from the "in" specifier in nsISample.idl. "in" specifies that the value of this parameter is used only for input, this method is not allowed to modify the contents of the buffer. nsISample.idl specifies all of it's string types as string, instead of wstring (wide string), the Unicode type. If the world were a perfect place, all normal strings in XPCOM interfaces would be unicode. If this type had been specified as wstring, it would appear as PRUnichar * in C++, which is the NSPR type for unicode characters.

Definition at line 59 of file nsSample.cpp.

    if (mValue)

Member Function Documentation

void nsISample::poke ( in string  aValue) [inherited]
void nsISample::writeValue ( in string  aPrefix) [inherited]

Member Data Documentation

char* nsSampleImpl::mValue [private]

Definition at line 128 of file nsSample.h.

Definition at line 60 of file nsISample.idl.

The documentation for this class was generated from the following files: