VirtualMachineScopeInterface Class Reference

#include <vm.h>

Inheritance diagram for VirtualMachineScopeInterface:

Public Member Functions

MAXON_METHOD Result< void > Init (const String &identifier, const String &code, ERRORHANDLING errorHandling, const VmDebuggerConnectionRef *debug=nullptr)
 
MAXON_METHOD Result< void > Add (const String &name, const Data &data)
 
MAXON_METHOD Result< DataGet (const String &name)
 
MAXON_METHOD Result< void > Execute ()
 
MAXON_METHOD Result< Data * > PrivateInvoke (const String &name, BlockArray< Data > &helperStack, const DataType &expected=DataType::DefaultValue(), const Block< Data * > *arguments=nullptr)
 
MAXON_METHOD Result< void > ErrorHandling ()
 
MAXON_METHOD Result< void > _PrivateInit (const LibraryRef &lib)
 

Private Member Functions

 MAXON_INTERFACE (VirtualMachineScopeInterface, MAXON_REFERENCE_NORMAL, "net.maxon.python.interface.virtualmachinescope")
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( VirtualMachineScopeInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.python.interface.virtualmachinescope"   
)
private

◆ Init()

MAXON_METHOD Result<void> Init ( const String identifier,
const String code,
ERRORHANDLING  errorHandling,
const VmDebuggerConnectionRef *  debug = nullptr 
)

Initialized the virtual machine scope. Needs to be executed before any other function of the interface is used.

Parameters
[in]identifierHuman readable unique identifier. Depending on the engine, some exception handlers might print this into their exception to make it easier to understand where the exception comes from.
[in]codeCode to be executed.
[in]errorHandlingAdjust how the virtual machine should treat an exception.
[in]debugOptional virtual machine debugger connection, to debug the code.

◆ Add()

MAXON_METHOD Result<void> Add ( const String name,
const Data data 
)

Add an object to the scope. The Data object will be converted through the underlying library implementation. So the Data object must be representable in the target virtual machine.

Parameters
[in]nameVariable name of the object in the scope.
[in]dataObject that will be added to the scope.
Returns
Return state, depending on VirtualMachineScopeInterface::Init(errorHandling).

◆ Get()

MAXON_METHOD Result<Data> Get ( const String name)

Returns an object from the scope.

Parameters
[in]nameVariable name of the object in the scope.
Returns
Requested object or error.

◆ Execute()

MAXON_METHOD Result<void> Execute ( )

Execute the virtual machine scope. Before, and after executing the code, the optionally given debugger code from the VmDebuggerConnection will be executed.

Returns
Return state, depending on VirtualMachineScopeInterface::Init(errorHandling).

◆ PrivateInvoke()

MAXON_METHOD Result<Data*> PrivateInvoke ( const String name,
BlockArray< Data > &  helperStack,
const DataType expected = DataType::DefaultValue(),
const Block< Data * > *  arguments = nullptr 
)

Executes a callable object from the scope. Must only be called after VirtualMachineScopeInterface.Execute.

Parameters
[in]nameName of the callable object, e.g a function name
[in]helperStackA temporary helper stack for the return value.
[in]expected(Optional) Datatype of the returned object, otherwise the type of the object will be chosen automatically.
[in]arguments(Optional) Arguments which will be passed to the callable object.

◆ ErrorHandling()

MAXON_METHOD Result<void> ErrorHandling ( )

Normally to reset the error state of the internal virtual machine. E.g. In Python PyErr_Print is executed. Normally used after VirtualMachineScopeInterface.Execute or VirtualMachineScopeInterface.PrivateInvoke failed, but only if scope is initialized with ERRORHANDLING.REDIRECT.

Returns
OK if the error was handled, otherwise an exception is returned.

◆ _PrivateInit()

MAXON_METHOD Result<void> _PrivateInit ( const LibraryRef &  lib)

Private.