On Thu, 22 Mar 2001 13:18:24 +1200, Patrick McHale
<mchalepNO#[EMAIL PROTECTED]> wrote:

>The XPIDL
>compiler generates the variable name used in the method implementation in the
>C++ code, including an 'a' in front of the parameter variable. It shows it
>being used and declared but why?.

Can't say I follow.  The attribute keyword in IDL:

1. saves you from writing a line of code. It automatically generates a
getter and a setter for a member.  The getter and setter methods are
generated with signatures sufficient for the type of the member
attribute that you've declared in the interface with the attribute
keyword.  One could just as easily make the getter and setter explicit
and not used the attribute.

2. Allows users of the class to refer to the member directly rather
than explicitly calling the getter or setter.  

// only valid with 'attribute string text'
document.foo.text = "bar";

vs

// valid with 'attribute string text' and with an explicit setter
document.foo.setText("bar");


>Is this declaration of this variable in Javascript used as some kind of
>reference to data stored in memory - in order to be accessible by Javascript.
>I don't understand the link and why it is used.?
>
>i.e
>Sample.idl file:
>
>attribute string text  // text from Javascript

what do you mean by 'text from Javascript'?

>attribute string value
>void poke(in string aValue);  // if this is defined here in IDL file
>
>There would be a mapping to:
>
>NS_IMETHODIMP SimplePluginInstance::GetText(char * *aText)
>NS_IMETHODIMP SimplePluginInstance::SetText(const char * aText)
>NS_IMETHODIMP SimplePluginInstance::Poke(const char* aValue)

Since there's another line (attribute string value) in the interface
definition, you'd also need:
NS_IMETHODIMP SimplePluginInstance::GetValue(char * *aValue)
NS_IMETHODIMP SimplePluginInstance::SetValue(const char * aValue)



Reply via email to