AngelScript

asIObjectType Class Reference

The interface for an object type.

List of all members.

## Public Member Functions
Miscellaneous
virtual asIScriptEngine * | GetEngine () const =0
| Returns a pointer to the script engine.
virtual const char * | GetConfigGroup () const =0
| Returns the config group in which the type was registered.
Memory management
virtual int | AddRef () const =0
| Increases the reference counter.
virtual int | Release () const =0
| Decrease reference counter.
Type info
virtual const char * | GetName () const =0
| Returns a temporary pointer to the name of the datatype.
virtual asIObjectType * | GetBaseType () const =0
| Returns the object type that this type derives from.
virtual bool | DerivesFrom (const asIObjectType *objType) const =0
| Returns true if the type inherits directly or indirectly from the informed type.
virtual asDWORD | GetFlags () const =0
| Returns the object type flags.
virtual asUINT | GetSize () const =0
| Returns the size of the object type.
virtual int | GetTypeId () const =0
| Returns the type id for the object type.
virtual int | GetSubTypeId () const =0
| Returns the type id of the template sub type.
virtual asIObjectType * | GetSubType () const =0
| Returns the template subtype, in case it is an object type.
Interfaces
virtual asUINT | GetInterfaceCount () const =0
| Returns the number of interfaces implemented.
virtual asIObjectType * | GetInterface (asUINT index) const =0
| Returns a temporary pointer to the specified interface or null if none are found.
virtual bool | Implements (const asIObjectType *objType) const =0
| Returns true if the type implements the informed interface type.
Factories
virtual asUINT | GetFactoryCount () const =0
| Returns the number of factory functions for the object type.
virtual int | GetFactoryIdByIndex (asUINT index) const =0
| Returns the factory id by index.
virtual int | GetFactoryIdByDecl (const char *decl) const =0
| Returns the factory id by declaration.
virtual asIScriptFunction * | GetFactoryByIndex (asUINT index) const =0
| Returns the factory function by the index.
virtual asIScriptFunction * | GetFactoryByDecl (const char *decl) const =0
| Returns the factory function by the declaration.
Methods
virtual asUINT | GetMethodCount () const =0
| Returns the number of methods for the object type.
virtual int | GetMethodIdByIndex (asUINT index, bool getVirtual=true) const =0
| Returns the method id by index.
virtual int | GetMethodIdByName (const char *name, bool getVirtual=true) const =0
| Returns the method id by name.
virtual int | GetMethodIdByDecl (const char *decl, bool getVirtual=true) const =0
| Returns the method id by declaration.
virtual asIScriptFunction * | GetMethodByIndex (asUINT index, bool getVirtual=true) const =0
| Returns the method by index.
virtual asIScriptFunction * | GetMethodByName (const char *name, bool getVirtual=true) const =0
| Returns the method by name.
virtual asIScriptFunction * | GetMethodByDecl (const char *decl, bool getVirtual=true) const =0
| Returns the method by declaration.
virtual asIScriptFunction * | GetMethodDescriptorByIndex (asUINT index, bool getVirtual=true) const =0
Properties
virtual asUINT | GetPropertyCount () const =0
| Returns the number of properties that the object contains.
virtual int | GetProperty (asUINT index, const char **name, int *typeId=0, bool *isPrivate=0, int *offset=0, bool *isReference=0) const =0
| Returns the attributes of the property.
virtual const char * | GetPropertyDeclaration (asUINT index) const =0
| Returns the declaration of the property.
Behaviours
virtual asUINT | GetBehaviourCount () const =0
| Returns the number of behaviours.
virtual int | GetBehaviourByIndex (asUINT index, asEBehaviours *outBehaviour) const =0
| Returns the function id and type of the behaviour.
User data
virtual void * | SetUserData (void *data)=0
| Register the memory address of some user data.
virtual void * | GetUserData () const =0
| Returns the address of the previously registered user data.

## Member Function Documentation

virtual int asIObjectType::AddRef | ( |  | ) | const`[pure virtual]`

Returns:
  The number of references to this object.

Call this method when storing an additional reference to the object.

virtual bool asIObjectType::DerivesFrom | ( | const asIObjectType * | objType | ) | const`[pure virtual]`

Parameters:

  [in] | objType | The potential parent type.

Returns:
  True if the type inherits directly or indirectly from the informed type.

virtual asIObjectType* asIObjectType::GetBaseType | ( |  | ) | const`[pure virtual]`

Returns:
  A pointer to the object type that this type derives from.

This method will only return a pointer in case of script classes that derives from another script class.

This does not increase the reference count of the returned object type.

virtual int asIObjectType::GetBehaviourByIndex | ( | asUINT | index,
|  | asEBehaviours * | outBehaviour
| ) |  | const`[pure virtual]`

Parameters:

  [in] | index | The index of the behaviour.
  [out] | outBehaviour | Receives the type of the behaviour.

Returns:
  The function id of the behaviour.

Return values:

  asINVALID_ARG | The index is too large.

virtual asUINT asIObjectType::GetBehaviourCount | ( |  | ) | const`[pure virtual]`

Returns:
  The number of behaviours for this type.

virtual const char* asIObjectType::GetConfigGroup | ( |  | ) | const`[pure virtual]`

Returns:
  The name of the config group, or null if not set.

virtual asIScriptEngine* asIObjectType::GetEngine | ( |  | ) | const`[pure virtual]`

Returns:
  A pointer to the engine.

virtual asIScriptFunction* asIObjectType::GetFactoryByDecl | ( | const char * | decl | ) | const`[pure virtual]`

Parameters:

  [in] | decl | The declaration of the function

Returns:
  The matching factory function or null if there are no matches

virtual asIScriptFunction* asIObjectType::GetFactoryByIndex | ( | asUINT | index | ) | const`[pure virtual]`

Parameters:

  [in] | index | The index of the factory function.

Returns:
  The factory function or null if the index is invalid.

virtual asUINT asIObjectType::GetFactoryCount | ( |  | ) | const`[pure virtual]`

Returns:
  The number of factory functions for this object.

virtual int asIObjectType::GetFactoryIdByDecl | ( | const char * | decl | ) | const`[pure virtual]`

Parameters:

  [in] | decl | The factory signature.

Returns:
  A negative value on error, or the factory id.

Return values:

  asNO_FUNCTION | Didn't find any matching functions.
  asINVALID_DECLARATION | decl is not a valid declaration.
  asERROR | The module for the type was not built successfully.

The factory function is named after the object type and returns a handle to the object. Example:

     id = type->GetFactoryIdByDecl("object@ object(int arg1, int arg2)");

virtual int asIObjectType::GetFactoryIdByIndex | ( | asUINT | index | ) | const`[pure virtual]`

Parameters:

  [in] | index | The index of the factory function.

Returns:
  A negative value on error, or the factory id.

Return values:

  asINVALID_ARG | index is out of bounds.

virtual asDWORD asIObjectType::GetFlags | ( |  | ) | const`[pure virtual]`

Returns:
  A bit mask with the flags from asEObjTypeFlags.

Script classes are identified by having the asOBJ_SCRIPT_OBJECT flag set. Interfaces are identified as a script class with a size of zero.

See also:
  GetSize

virtual asIObjectType* asIObjectType::GetInterface | ( | asUINT | index | ) | const`[pure virtual]`

Parameters:

  [in] | index | The interface index.

Returns:
  A pointer to the interface type.

virtual asUINT asIObjectType::GetInterfaceCount | ( |  | ) | const`[pure virtual]`

Returns:
  The number of interfaces implemented by this type.

virtual asIScriptFunction* asIObjectType::GetMethodByDecl | ( | const char * | decl,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | decl | The method signature.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  The method or null on error.

This method should be used to retrieve the script method for the object that you wish to execute. The method is then sent to the context's Prepare method.

The method will find the script method with the exact same declaration.

virtual asIScriptFunction* asIObjectType::GetMethodByIndex | ( | asUINT | index,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | index | The index of the method.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  The method or null on error.

This method should be used to retrieve the script method for the object that you wish to execute. The method is then sent to the context's Prepare method.

By default this returns the virtual method for script classes. This will allow you to call the virtual method on classes, and rely on the polymorphism to call the correct implementation. If you wish to inspect the real method, then you should set the second parameter to false to retrieve the real method.

virtual asIScriptFunction* asIObjectType::GetMethodByName | ( | const char * | name,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | name | The name of the method.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  Tthe method or null in case of error

This method should be used to retrieve the script method for the object that you wish to execute. The method is then sent to the context's Prepare method.

virtual asUINT asIObjectType::GetMethodCount | ( |  | ) | const`[pure virtual]`

Returns:
  The number of methods for this object.

virtual asIScriptFunction* asIObjectType::GetMethodDescriptorByIndex | ( | asUINT | index,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Deprecated:

Since:
  2011-10-03. Use asIObjectType::GetMethodByIndex instead

virtual int asIObjectType::GetMethodIdByDecl | ( | const char * | decl,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | decl | The method signature.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  A negative value on error, or the method id.

Return values:

  asMULTIPLE_FUNCTIONS | Found multiple matching methods.
  asNO_FUNCTION | Didn't find any matching method.
  asINVALID_DECLARATION | decl is not a valid declaration.
  asERROR | The module for the type was not built successfully.

This method should be used to retrieve the id of the script method for the object that you wish to execute. The id is then sent to the context's Prepare method.

The method will find the script method with the exact same declaration.

virtual int asIObjectType::GetMethodIdByIndex | ( | asUINT | index,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | index | The index of the method.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  A negative value on error, or the method id.

Return values:

  asINVALID_ARG | index is out of bounds.

This method should be used to retrieve the id of the script method for the object that you wish to execute. The id is then sent to the context's Prepare method.

By default this returns the virtual method for script classes. This will allow you to call the virtual method on classes, and rely on the polymorphism to call the correct implementation. If you wish to inspect the real method, then you should set the second parameter to false to retrieve the real method.

virtual int asIObjectType::GetMethodIdByName | ( | const char * | name,
|  | bool | getVirtual = `true`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | name | The name of the method.
  [in] | getVirtual | Set to true if the virtual method or the real method should be retrieved.

Returns:
  A negative value on error, or the method id.

Return values:

  asMULTIPLE_FUNCTIONS | Found multiple matching methods.
  asNO_FUNCTION | Didn't find any matching method.

This method should be used to retrieve the id of the script method for the object that you wish to execute. The id is then sent to the context's Prepare method.

virtual const char* asIObjectType::GetName | ( |  | ) | const`[pure virtual]`

Returns:
  A null terminated string with the name of the object type.

virtual int asIObjectType::GetProperty | ( | asUINT | index,
|  | const char ** | name,
|  | int * | typeId = `0`,
|  | bool * | isPrivate = `0`,
|  | int * | offset = `0`,
|  | bool * | isReference = `0`
| ) |  | const`[pure virtual]`

Parameters:

  [in] | index | The index of the property
  [out] | name | The name of the property
  [out] | typeId | The type of the property
  [out] | isPrivate | Whether the property is private or not
  [out] | offset | The offset into the object where the property is stored
  [out] | isReference | True is the property is not stored inline

Returns:
  A negative value on error

Return values:

  asINVALID_ARG | The index is out of bounds

virtual asUINT asIObjectType::GetPropertyCount | ( |  | ) | const`[pure virtual]`

Returns:
  The number of member properties of the script object.

virtual const char* asIObjectType::GetPropertyDeclaration | ( | asUINT | index | ) | const`[pure virtual]`

Parameters:

  [in] | index | The index of the property

Returns:
  The declaration of the property, or null on error.

virtual asUINT asIObjectType::GetSize | ( |  | ) | const`[pure virtual]`

Returns:
  The number of bytes necessary to store instances of this type.

Application registered reference types doesn't store this information, as the script engine doesn't allocate memory for these itself.

virtual asIObjectType* asIObjectType::GetSubType | ( |  | ) | const`[pure virtual]`

Returns:
  The object type of the template sub type, or null if the template subtype is not an object type.

virtual int asIObjectType::GetSubTypeId | ( |  | ) | const`[pure virtual]`

Returns:
  The type id of the template sub type, or a negative value on error.

Return values:

  asERROR | The type is not a template type.

virtual int asIObjectType::GetTypeId | ( |  | ) | const`[pure virtual]`

Returns:
  The type id for the object type.

virtual void* asIObjectType::GetUserData | ( |  | ) | const`[pure virtual]`

Returns:
  The pointer to the user data.

virtual bool asIObjectType::Implements | ( | const asIObjectType * | objType | ) | const`[pure virtual]`

Parameters:

  [in] | objType | The interface type.

Returns:
  True if the type implements the informed interface type.

virtual int asIObjectType::Release | ( |  | ) | const`[pure virtual]`

Returns:
  The number of references to this object.

Call this method when you will no longer use the references that you own.

virtual void* asIObjectType::SetUserData | ( | void * | data | ) | `[pure virtual]`

Parameters:

  [in] | data | A pointer to the user data.

Returns:
  The previous pointer stored in the object type.

This method allows the application to associate a value, e.g. a pointer, with the object type instance.

Optionally, a callback function can be registered to clean up the user data when the object type is destroyed. As the callback is registered with the engine, it is only necessary to do it once, even if more than one context is used.

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

- angelscript.h