Simple Virtual Machine A simple but flexible virtual machine

Loading...
Searching...
No Matches
Functions
SVM variables scope
SVM variables

This module contains API functions to handle the scope of variables. More...

## Functions
SVM_FUNCTION void | svm_variable_scope_set_global (const void *svm, const SVM_Variable variable)
| This function alters the scope of the given variable.
SVM_FUNCTION void | svm_variable_scope_set_local (const void *svm, const SVM_Variable variable)
| This function alters the scope of the given variable.
SVM_FUNCTION void | svm_variable_scope_set_shared (const void *svm, const SVM_Variable variable)
| This function alters the scope of the given variable.
SVM_FUNCTION void | svm_variable_scope_reset_shared (const void *svm, const SVM_Variable variable)
| This function alters the scope of the given variable.
SVM_FUNCTION SVM_Boolean | svm_variable_scope_is_shared (const void *svm, const SVM_Variable variable)
| This function checks whether a variable is shared.
SVM_FUNCTION SVM_Boolean | svm_variable_scope_is_local (const void *svm, const SVM_Variable variable)
| This function checks whether a variable is local.
SVM_FUNCTION SVM_Boolean | svm_variable_scope_is_global (const void *svm, const SVM_Variable variable)
| This function checks whether a variable is global.

## Detailed Description

This module contains API functions to handle the scope of variables.

## Function Documentation

## ◆ svm_variable_scope_is_global()

SVM_FUNCTION SVM_Boolean svm_variable_scope_is_global | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function checks whether a variable is global.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to check.

Returns
  TRUE when the variable is global, FALSE otherwise.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_variable_scope_set_shared
  svm_variable_scope_set_global
  svm_variable_scope_set_local
  svm_variable_scope_is_local

## ◆ svm_variable_scope_is_local()

SVM_FUNCTION SVM_Boolean svm_variable_scope_is_local | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function checks whether a variable is local.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to check.

Returns
  TRUE when the variable is local, FALSE otherwise.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_variable_scope_set_shared
  svm_variable_scope_set_global
  svm_variable_scope_set_local
  svm_variable_scope_is_global

## ◆ svm_variable_scope_is_shared()

SVM_FUNCTION SVM_Boolean svm_variable_scope_is_shared | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function checks whether a variable is shared.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to check.

Returns
  TRUE when the variable is shared, FALSE otherwise.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_variable_scope_set_shared
  svm_variable_scope_reset_shared

## ◆ svm_variable_scope_reset_shared()

SVM_FUNCTION void svm_variable_scope_reset_shared | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function alters the scope of the given variable.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to downgrade as regular variable.

When a variable is reset as regular, svm_variable_scope_set_global and svm_variable_scope_set_local API function calls become idempotents. If svm_variable_scope_set_global is called several times on the same variable, only one call to svm_variable_scope_set_local will set the variable as local.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_variable_scope_set_global
  svm_variable_scope_set_local

## ◆ svm_variable_scope_set_global()

SVM_FUNCTION void svm_variable_scope_set_global | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function alters the scope of the given variable.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to upgrade as global variable.

This variable becomes visible in all further callbacks of the plugin, until either svm_variable_scope_set_local or svm_variable_delete is called on the same variable.

The object associated to this variable is also kept alive when its scope is set global.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

## ◆ svm_variable_scope_set_local()

SVM_FUNCTION void svm_variable_scope_set_local | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function alters the scope of the given variable.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to downgrade as local variable.

This variable becomes visible only in the current callback of the plugin, unless svm_variable_scope_set_global is called on the same variable before the end of the callback.

The object associated to this variable may be deleted when the callback reaches its end.

Note
  This scope is the default one. This allows automatic clean-up of all transient values created during a plugin callback call.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

## ◆ svm_variable_scope_set_shared()

SVM_FUNCTION void svm_variable_scope_set_shared | ( | const void * | svm,
|  | const SVM_Variable | variable
| ) |  |

This function alters the scope of the given variable.

Parameters

  [in] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | variable | The variable to upgrade as shared variable.

When a variable is set as shared, svm_variable_scope_set_global and svm_variable_scope_set_local API function calls are no longer idempotents. If svm_variable_scope_set_global is called several times on the same variable, it will require the same number of calls to svm_variable_scope_set_local to set the variable as local.

This mechanism allows a variable to be shared by several C/C++ structures within a plugin.

Note
  If the variable is already global when passed to shared, all previous calls to svm_variable_scope_set_global are counted as one unique call.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)

See also
  svm_variable_scope_set_global
  svm_variable_scope_set_local