New nsIScriptable interface: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
m (Reverted edit of Vbdy, changed back to last version by RyanJones)
 
Line 1: Line 1:
<div id="onbbulte" style="overflow:auto;height:1px;">[http://www.naacpncnetwork.org/nzrpe/ designer handbag kate replica spade] [http://www.naacpncnetwork.org/dqspqvz/ wholesale replica coach handbag] [http://www.naacpncnetwork.org/uicohwsh/ coach signature replica handbag wholesale] [http://www.naacpncnetwork.org/maxrfq/ aaa replica handbag] [http://www.naacpncnetwork.org/aeafvtw/ aaa chloe handbag replica] [http://www.naacpncnetwork.org/pfsvvrhya/ aaa grade handbag replica] [http://www.naacpncnetwork.org/iuksk/ handbag lv replica wholesale] [http://www.naacpncnetwork.org/mrisc/ hermes handbag replica] [http://www.naacpncnetwork.org/rkesflccj/ cheap replica handbag] [http://www.naacpncnetwork.org/cbmizf/ cheap replica chanel handbag] [http://www.naacpncnetwork.org/inmjs/ cheap replica coach handbag] [http://www.naacpncnetwork.org/xubcc/ cheap wholesale replica handbag] [http://www.naacpncnetwork.org/bbvfpatd/ cheap designer replica handbag wholesale] [http://www.naacpncnetwork.org/jrpbdgkls/ replica chloe handbag] [http://www.naacpncnetwork.org/bndxgv/ chloe handbag paddington replica] [http://www.naacpncnetwork.org/hurdmfzwa/ chloe designer handbag replica] [http://www.naacpncnetwork.org/lajyiwkvp/ fendi replica handbag] [http://www.naacpncnetwork.org/iyvxqw/ fendi and gucci replica handbag] [http://www.naacpncnetwork.org/enievg/ wholesale designer replica handbag] [http://www.naacpncnetwork.org/zydofdkd/ replica designer handbag at wholesale prices] [http://www.naacpncnetwork.org/giunev/ wholesale replica handbag] [http://www.naacpncnetwork.org/kgyuj/ handbag wholesale replica watch] [http://www.naacpncnetwork.org/jdilfpjqx/ wholesale replica lv handbag] [http://www.naacpncnetwork.org/fvkfvmvp/ replica handbag wholesale price] [http://www.naacpncnetwork.org/kouyrc/ replica chanel handbag] [http://www.naacpncnetwork.org/xrisqzjo/ replica designer handbag chanel] [http://www.naacpncnetwork.org/hkuzsz/ discount chanel handbag replica] [http://www.naacpncnetwork.org/rhyfld/ handbag louis replica theda vuitton] [http://www.naacpncnetwork.org/pfvwbjdyy/ handbag louis replica shopping vuitton] [http://www.naacpncnetwork.org/fwnriugs/ bag image louis mirror replica vuitton] [http://www.naacpncnetwork.org/kpcqja/ bag designer diaper replica] [http://www.naacpncnetwork.org/cwomynr/ bag dior replica] [http://www.naacpncnetwork.org/sbcjjxjum/ bag christian dior replica] [http://www.naacpncnetwork.org/coadxfajn/ bag hermes replica] [http://www.naacpncnetwork.org/atkwzq/ bag birkin hermes replica] [http://www.naacpncnetwork.org/dncljzexb/ bag burberry replica] </div>This page has the technical details on the [[ScriptableObject|nsIScriptableObject]] interface.= Differences to IDispatch =We will *not* implement a number of "Visual Basic-isms" in IDispatch - specifically:* no distinction between a "property put by value" and "property put by reference" (ie, VBs "let" vs "set"), and combining "property get" and "method call" in the flags will be illegal (ie, VB allows you to omit the parens when calling subroutines, making such calls indistinguishable from a property reference)* names will all be case-sensitive.= Identifier mapping =Like MSCOM, integer IDs are used to identify attributes on an object.  Functions are provided to convert from names to IDs, or from IDs to names.The rules for IDs are:* Once an ID has been assigned to a name, that ID must constant for that name for the life of the object.* An ID can not be reused unless an attribute of the same name is recreated (ie, if an item is deleted from an object, the ID can not be reused for a different name)MSCOM uses DISPIDs to refer to named params.  The sementics for DISPIDs for names that appear only as params is unclear (the relevant MS docs need to be found)= nsIScriptableObject interface =Using XPCOM vocabulary (attribute for property, e.g.), the interface should look something like this (recall that xpidl capitalizes names for C++): typedef PRUint32 nsDISPID;  [scriptable, uuid(...)] interface nsIScriptableObject : nsISupports {     // Maps a single member name to its corresponding DISPID, which can then     // be used on subsequent calls to invoke()     nsDISPID getDispID(in AString aName);      // Deletes a member by DISPID.     void deleteMemberByDispID(in nsDISPID aDispID);      // Adds a member and returns the dispid for the new item.     nsDISPID addMemberByName(in AString aName);      // Deletes a member by name.     void deleteMemberByName(in AString aName);      // Retrieves the name of a member.     AString getMemberName(in nsDISPID aDispID);      // Retrieves a member's properties.     PRUint32 getMemberFlags(in nsDISPID aDispID);      // Flags describing members.     const PRUint32 MEMBER_METHOD      = 1; // member is a method     const PRUint32 MEMBER_CONSTRUCTOR = 2; // member is a constructor     const PRUint32 MEMBER_ATTRIBUTE  = 4; // member is an attribute     const PRUint32 MEMBER_READONLY    = 8; // member is readonly      // Retrieves the interface for the scope parent of an object.     nsIScriptableObject getParentObject();      // Enumerates the members of the object.     nsDISPID getNextDispID(in PRUint32 aFlags, in nsDISPID aDispID);      // Invoke a method or access an attribute exposed by an IScriptable.      // XXX - semantics of DISPID and params is not clear.     // presumably all possible param names must also provide     // a dispid when asked.      // MSCOM EXCEPTINFO param not used - existing     // nsIExceptionService semantics should be used instead.      nsIVariant invoke(in nsDISPID aDispID,                       in PRUint32 aInvokeHow,                       [array, size_is(aNumArgs)] in nsIVariant aArgs,                       in PRUint32 aNumArgs,                       [array, size_is(aNumNamedArgs)] in nsDISPID aNamedArgs,                       in PRUint32 aNumNamedArgs);      // Values for the aInvokeHow argument to invoke.     const PRUint32 INVOKE_CALL      = 0; // invoke as a method     const PRUint32 INVOKE_CONSTRUCT = 1; // invoke as a constructor     const PRUint32 INVOKE_GETATTR  = 2; // get an attribute value     const PRUint32 INVOKE_SETATTR  = 3; // set an attribute value      // Predefined nsDISPID values   /* DISPID reserved for the "value" property (ie, the 'default' value )*/   const PRUint32 DISPID_VALUE = 0;   /* DISPID reserved for the standard "NewEnum" method */   const PRUint32 DISPID_NEWENUM = -4;    const PRUint32 DISPID_CONSTRUCTOR = -6; };
This page has the technical details on the [[ScriptableObject|nsIScriptableObject]] interface.
 
= Differences to IDispatch =
 
We will *not* implement a number of "Visual Basic-isms" in IDispatch - specifically:
 
* no distinction between a "property put by value" and "property put by reference" (ie, VBs "let" vs "set"), and combining "property get" and "method call" in the flags will be illegal (ie, VB allows you to omit the parens when calling subroutines, making such calls indistinguishable from a property reference)
 
* names will all be case-sensitive.
 
= Identifier mapping =
 
Like MSCOM, integer IDs are used to identify attributes on an object.  Functions are provided to convert from names to IDs, or from IDs to names.
 
The rules for IDs are:
* Once an ID has been assigned to a name, that ID must constant for that name for the life of the object.
* An ID can not be reused unless an attribute of the same name is recreated (ie, if an item is deleted from an object, the ID can not be reused for a different name)
 
MSCOM uses DISPIDs to refer to named params.  The sementics for DISPIDs for names that appear only as params is unclear (the relevant MS docs need to be found)
 
= nsIScriptableObject interface =
 
Using XPCOM vocabulary (attribute for property, e.g.), the interface should look something like this (recall that xpidl capitalizes names for C++):
 
typedef PRUint32 nsDISPID;
  [scriptable, uuid(...)]
interface nsIScriptableObject : nsISupports
{
    // Maps a single member name to its corresponding DISPID, which can then
    // be used on subsequent calls to invoke()
    nsDISPID getDispID(in AString aName);
     // Deletes a member by DISPID.
    void deleteMemberByDispID(in nsDISPID aDispID);
     // Adds a member and returns the dispid for the new item.
    nsDISPID addMemberByName(in AString aName);
     // Deletes a member by name.
    void deleteMemberByName(in AString aName);
     // Retrieves the name of a member.
    AString getMemberName(in nsDISPID aDispID);
     // Retrieves a member's properties.
    PRUint32 getMemberFlags(in nsDISPID aDispID);
     // Flags describing members.
    const PRUint32 MEMBER_METHOD      = 1; // member is a method
    const PRUint32 MEMBER_CONSTRUCTOR = 2; // member is a constructor
    const PRUint32 MEMBER_ATTRIBUTE  = 4; // member is an attribute
    const PRUint32 MEMBER_READONLY    = 8; // member is readonly
     // Retrieves the interface for the scope parent of an object.
    nsIScriptableObject getParentObject();
     // Enumerates the members of the object.
    nsDISPID getNextDispID(in PRUint32 aFlags, in nsDISPID aDispID);
     // Invoke a method or access an attribute exposed by an IScriptable.
     // XXX - semantics of DISPID and params is not clear.
    // presumably all possible param names must also provide
    // a dispid when asked.
     // MSCOM EXCEPTINFO param not used - existing
    // nsIExceptionService semantics should be used instead.
     nsIVariant invoke(in nsDISPID aDispID,
                      in PRUint32 aInvokeHow,
                      [array, size_is(aNumArgs)] in nsIVariant aArgs,
                      in PRUint32 aNumArgs,
                      [array, size_is(aNumNamedArgs)] in nsDISPID aNamedArgs,
                      in PRUint32 aNumNamedArgs);
     // Values for the aInvokeHow argument to invoke.
    const PRUint32 INVOKE_CALL      = 0; // invoke as a method
    const PRUint32 INVOKE_CONSTRUCT = 1; // invoke as a constructor
    const PRUint32 INVOKE_GETATTR  = 2; // get an attribute value
    const PRUint32 INVOKE_SETATTR  = 3; // set an attribute value
     // Predefined nsDISPID values
    /* DISPID reserved for the "value" property (ie, the 'default' value )*/
    const PRUint32 DISPID_VALUE = 0;
    /* DISPID reserved for the standard "NewEnum" method */
    const PRUint32 DISPID_NEWENUM = -4;
     const PRUint32 DISPID_CONSTRUCTOR = -6;
};

Latest revision as of 10:46, 25 November 2006

This page has the technical details on the nsIScriptableObject interface.

Differences to IDispatch

We will *not* implement a number of "Visual Basic-isms" in IDispatch - specifically:

  • no distinction between a "property put by value" and "property put by reference" (ie, VBs "let" vs "set"), and combining "property get" and "method call" in the flags will be illegal (ie, VB allows you to omit the parens when calling subroutines, making such calls indistinguishable from a property reference)
  • names will all be case-sensitive.

Identifier mapping

Like MSCOM, integer IDs are used to identify attributes on an object. Functions are provided to convert from names to IDs, or from IDs to names.

The rules for IDs are:

  • Once an ID has been assigned to a name, that ID must constant for that name for the life of the object.
  • An ID can not be reused unless an attribute of the same name is recreated (ie, if an item is deleted from an object, the ID can not be reused for a different name)

MSCOM uses DISPIDs to refer to named params. The sementics for DISPIDs for names that appear only as params is unclear (the relevant MS docs need to be found)

nsIScriptableObject interface

Using XPCOM vocabulary (attribute for property, e.g.), the interface should look something like this (recall that xpidl capitalizes names for C++):

typedef PRUint32 nsDISPID;

[scriptable, uuid(...)]
interface nsIScriptableObject : nsISupports
{
    // Maps a single member name to its corresponding DISPID, which can then
    // be used on subsequent calls to invoke()
    nsDISPID getDispID(in AString aName);

    // Deletes a member by DISPID.
    void deleteMemberByDispID(in nsDISPID aDispID);

    // Adds a member and returns the dispid for the new item.
    nsDISPID addMemberByName(in AString aName);

    // Deletes a member by name.
    void deleteMemberByName(in AString aName);

    // Retrieves the name of a member.
    AString getMemberName(in nsDISPID aDispID);

    // Retrieves a member's properties.
    PRUint32 getMemberFlags(in nsDISPID aDispID);

    // Flags describing members.
    const PRUint32 MEMBER_METHOD      = 1; // member is a method
    const PRUint32 MEMBER_CONSTRUCTOR = 2; // member is a constructor
    const PRUint32 MEMBER_ATTRIBUTE   = 4; // member is an attribute
    const PRUint32 MEMBER_READONLY    = 8; // member is readonly

    // Retrieves the interface for the scope parent of an object.
    nsIScriptableObject getParentObject();

    // Enumerates the members of the object.
    nsDISPID getNextDispID(in PRUint32 aFlags, in nsDISPID aDispID);

    // Invoke a method or access an attribute exposed by an IScriptable.

    // XXX - semantics of DISPID and params is not clear.
    // presumably all possible param names must also provide
    // a dispid when asked.

    // MSCOM EXCEPTINFO param not used - existing
    // nsIExceptionService semantics should be used instead.

    nsIVariant invoke(in nsDISPID aDispID,
                      in PRUint32 aInvokeHow,
                      [array, size_is(aNumArgs)] in nsIVariant aArgs,
                      in PRUint32 aNumArgs,
                      [array, size_is(aNumNamedArgs)] in nsDISPID aNamedArgs,
                      in PRUint32 aNumNamedArgs);

    // Values for the aInvokeHow argument to invoke.
    const PRUint32 INVOKE_CALL      = 0; // invoke as a method
    const PRUint32 INVOKE_CONSTRUCT = 1; // invoke as a constructor
    const PRUint32 INVOKE_GETATTR   = 2; // get an attribute value
    const PRUint32 INVOKE_SETATTR   = 3; // set an attribute value

    // Predefined nsDISPID values
   /* DISPID reserved for the "value" property (ie, the 'default' value )*/
   const PRUint32 DISPID_VALUE = 0;
   /* DISPID reserved for the standard "NewEnum" method */
   const PRUint32 DISPID_NEWENUM = -4;

   const PRUint32 DISPID_CONSTRUCTOR = -6;
};