Programming Reference: ODScriptComponent

# Programming Reference

## ODScriptComponent

Class Definition File | ScrComp.idl
Class C++ Binding | ScrComp.xh

Class Hierarchy

    SOMObject
       Component
          ODScriptComponent

Description | This class is the base class for all script components. A script component is a separately built and packaged dll that provides scripting support for enabled OpenDoc classes. See ODScriptExtension for a description of the requirements for making a Part scriptable.

Methods

The methods defined by the ODScriptComponent class include:

- ActivateScriptComponent
- AddClass
- AddContainer
- AddInstance
- CloseScripting
- DropContainer
- DropInstance
- GetComponentData
- InitEditor
- InitScriptComponent
- ReleaseAll
- Rename

Overridden Methods | There are no methods overridden by the ODScriptComponent class.

### ActivateScriptComponent

This method indicates that a script component should perform any part initialization and activate event handling for registered parts.

Signature

    void ActivateScriptComponent ()

Parameters

None.

Returns

None.

Remarks

This method is called by the script extension after initialization is completed and after all current parts and classes are registered.

### AddClass

This method registers a class for scripting access.

Signature

    ODScrRegRet AddClass (string classname)

Parameters

classname (string) - input

  The name of the class to be exposed to the script interface.

Returns

rv (ODScrRegRet) - returns

  An ODScrRegRet value.

Remarks

This method requests to the Script Component to add the named class to the set of classes that are available for script access in this environment.

### AddContainer

This method registers a script extension object for scripting access.

Signature

    ODScrRegRet AddContainer (SOMObject instance,
                              string classname,
                              string containerName,
                              ODScriptExtension definingExt)

Parameters

instance (SOMObject) - input

  A pointer to the container object, an ODScriptExtension.

classname (string) - input

  The name of the class for that container.

containerName (string) - input

  The name by which the container should be referenced in the scripts.

definingExt (ODScriptExtension) - input

  The extension object that owns this container.

Returns

rv (ODScrRegRet) - returns

  An ODScrRegRet value.

Remarks

This method indicates that the container should be added to the set of objects accessible for script access.

### AddInstance

This method registers the object for scripting access.

Signature

    ODScrRegRet AddInstance (SOMObject instance,
                             string classname,
                             string instanceName,
                             ODScriptExtension definingExt)

Parameters

instance (SOMObject) - input

  A pointer to the object to be exposed for scripting.

classname (string) - input

  The name of the class to which the instance belongs.

instanceName (string) - input

  The name by which the instance should be referenced in the scripts.

definingExt (ODScriptExtension) - input

  The extension object that owns this instance.

Returns

rv (ODScrRegRet) - returns

  An ODScrRegRet value.

Remarks

This method indicates that the instance should be added to the set of objects accessible for script access.

### CloseScripting

This method terminates scripting for this scope.

Signature

    void CloseScripting ()

Parameters

None.

Returns

None.

Remarks

This method requests that the script component terminate scripting for the current scope. All scripts, registration data, and the internal state should be released.

### DropContainer

This method removes a script extension from the scripting environment.

Signature

    ODScrRegRet DropContainer (ODScriptExtension container)

Parameters

container (ODScriptExtension) - input

  A pointer to an ODScriptExtension object that was previously registered with this Script Component as a container and that should be removed from the current scope.

Returns

rv (ODScrRegRet) - returns

  An ODScrRegRet value.

Remarks

This method removes the indicated container from the scripting interface. Correction of references to such an object in the script code is up to the Script Component.

### DropInstance

This method removes an instance from the scripting environment.

Signature

    ODScrRegRet DropInstance (SOMObject instance)

Parameters

instance (SOMObject) - input

  A pointer to an object that was previously registered with this Script Component and that should be removed from the set of objects available for scripting.

Returns

rv (ODScrRegRet) - returns

  An ODScrRegRet value.

Remarks

This method removes the indicated instance from the scripting interface. Correction of references to such an object in the script code is up to the Script Component.

### GetComponentData

This method is an interface to get persistent data from the component.

Signature

    void GetComponentData (long *pBufferSize,
                           void *pBuffer)

Parameters

pBufferSize (long *) - in/out

  A pointer to the size of the buffer

pBuffer (void *) - input

  A pointer to the buffer to receive the data block.

Returns

None.

Remarks

This interface will be invoked by the script extension when it needs the component's persistent data. This would include the actual scripts, cached descriptive information, or other information that the component needs to have saved.

The pBufferSize value is updated with the actual size of the component data pBuffer. If the size specified on the call as the input is sufficient, the buffer will receive the component data.

If the buffer size provided is not sufficient, the pBufferSize value is updated with the size that is actually required. If the buffer was large enough, then the component's data is copied to that buffer and again the pBufferSize is updated to reflect the actual size of the data.

### InitEditor

This method initializes the interactive edit session.

Signature

    void InitEditor ()

Parameters

None.

Returns

None.

Remarks

This method is a request for the Script Component to present its script editor interface with the classes and objects previously registered presented in that interface.

### InitScriptComponent

This method initializes the script component and provides access for that script component to the associated script extension.

Signature

    void InitScriptComponent (ODScriptExtension theExt,
                              ODBoolean hasInitData)

Parameters

theExt (ODScriptExtension) - input

  A pointer to the ODScriptExtension object associated with the script component.

hasInitData (ODBoolean) - input

  A Boolean that indicates whether there is initialization data and this component should use the ODScriptExtension's RetrieveComponentData method to get that data to initialize its environment.

Returns

None.

Remarks

this method allows the script component to access the script extension, primarily for persistent data but other interfaces may be used.

### ReleaseAll

This method releases resources before closing down.

Signature

    void ReleaseAll ()

Parameters

None.

Returns

None.

Remarks

This method allows the script component to release resources prior to closing down. It is called by the ODScriptExtension prior to that object being deleted.

### Rename

This method renames an object after the object is exposed to scripting.

Signature

    ODBoolean Rename (SOMObject pObject,
                      char *pNewName)

Parameters

pObject (SOMObject) - input

  A pointer to an object that was previously registered for script access.

pNewName (char *) - input

  A pointer to a string that is the new name to be assigned to that instance.

Returns

rv (ODBoolean) - returns

  A flag indicating success.

  kODTrue | Successful completion.
  kODFalse | Name not accessed, collision, or invalid.

None.

Remarks

This interface is provided to support a user's ability to specify a name for an object, after the object has been exposed for scripting. The name for the object should be changed by the component. Any reference correction to the old object name is the responsibility of the component.

[ Top | Previous | Next | Contents | Index | Documentation Homepage ]