index

Reference: asIScriptAny

class asIScriptAny
{
public:
  // Memory management
  int AddRef();
  int Release();

  // Contained value
  void Store(void *ref, int typeId);
  int  Retrieve(void *ref, int typeId);
  int  GetTypeId();
  int  CopyFrom(asIScriptAny *other);
};

AddRef

int AddRef();

Description

This method increases the internal reference counter of the object and returns the count. The returned value shouldn't be used for anything else but debugging.

Call AddRef() each time you assign a reference to a new variable.

Returns

The internal reference counter.

Release

int Release();

Description

Decreases the internal reference counter and returns the count. If the counter reaches 0 the object is deleted and the memory is freed.

After calling Release() don't forget to set your reference to 0 so that you don't mistakenly try to use the reference again.

Returns

The internal reference counter.

Store

void Store(void *ref, int typeId);

Description

This method is used to store a value in the container object. The application should pass a pointer to the variable with the value, and the typeId that represents the type of the variable. The method will make a copy of the value held by the variable.

Currently only object handles are supported, but later on all types will be supported.

Parameters

ref 

A pointer to the variable that hold the value that should be stored.

typeId 

The typeId representing the type of the variable.

Retrieve

int Retrieve(void *ref, int typeId);

Description

Call this method to retrieve a copy of the contained value. The application should pass a pointer to the variable that will receive the copy. The typeId represents the type of the value that you want to retrieve, if the contained value is incompatible with this type, then the method will not retrieve anything and will return a negative value.

Parameters

ref 

A pointer to the variable that should receive the copy of the contained value.

typeId 

The typeId representing the type of the variable.

Returns

A negative value on error.

GetTypeId

int GetTypeId();

Description

Returns the type id of the contained value. If no value has been set yet the return value is 0, which represents the type id of void.

Returns

The type id of the contained value.

CopyFrom

int CopyFrom(asIScriptAny *other);

Description

This method copies the contents of the other object to this one.

Parameters

other 

A pointer to the other any object.

Returns

A negative value on error.

top