|
Bond 0.9
C++ Bond Runtime Library API Documentation
|
Sets up and invokes a call to a Bond function from native code. More...
#include <bond/vm/vm.h>
Public Member Functions | |
| InvocationStackFrame (VM &vm, const QualifiedName &functionName) | |
| Constructs an InvocationStackFrame object for a call to a function that returns void. | |
| InvocationStackFrame (VM &vm, const char *functionName) | |
| Constructs an InvocationStackFrame object for a call to a function that returns void. | |
| InvocationStackFrame (VM &vm, const Function &function) | |
| Constructs an InvocationStackFrame object for a call to a function that returns void. | |
| template<typename ReturnType> | |
| InvocationStackFrame (VM &vm, const QualifiedName &functionName, ReturnType *returnPointer) | |
| Constructs an InvocationStackFrame object for a call to a function that returns a value. | |
| template<typename ReturnType> | |
| InvocationStackFrame (VM &vm, const char *functionName, ReturnType *returnPointer) | |
| Constructs an InvocationStackFrame object for a call to a function that returns a value. | |
| template<typename ReturnType> | |
| InvocationStackFrame (VM &vm, const Function &function, ReturnType *returnPointer) | |
| Constructs an InvocationStackFrame object for a call to a function that returns a value. | |
| template<typename ArgType> | |
| void | PushArg (const ArgType &arg) |
| Pushes the next argument of the function call. | |
| template<typename... Args> | |
| void | PushArgs (Args... args) |
| Pushes the next arguments of the function call, in order, as if by calling PushArg() for each of them. | |
| void | Call () |
| Invokes the function. Must be called after all of its arguments have been pushed. | |
| InvocationStackFrame & | operator= (const InvocationStackFrame &other)=delete |
Sets up and invokes a call to a Bond function from native code.
Constructing an InvocationStackFrame pushes a new StackFrame onto the VM's call stack, and destroying it pops the frame off. Arguments are pushed in order with PushArg() or PushArgs(), after which the function is invoked with Call(). Since the frame is popped by the destructor, InvocationStackFrames must be destroyed in the reverse order of their construction, which is naturally the case when they are local variables.
The constructors that look up a function by name throw a Bond::Exception if no such function exists in the VM's CodeSegment, and all constructors throw a Bond::Exception if the frame does not fit on the VM stack. When BOND_RUNTIME_CHECKS_ENABLED is non-zero, the constructors also validate the return type, PushArg() validates the argument types and count, and Call() validates that all arguments have been pushed. Violations throw a Bond::Exception.
VM::CallFunction and VM::CallVoidFunction are convenient alternatives for calls whose arguments are all known up front.
| Bond::InvocationStackFrame::InvocationStackFrame | ( | VM & | vm, |
| const QualifiedName & | functionName ) |
Constructs an InvocationStackFrame object for a call to a function that returns void.
| vm | The VM on which the function is invoked. |
| functionName | The fully qualified name of the function. |
| Bond::InvocationStackFrame::InvocationStackFrame | ( | VM & | vm, |
| const char * | functionName ) |
Constructs an InvocationStackFrame object for a call to a function that returns void.
| vm | The VM on which the function is invoked. |
| functionName | The fully qualified name of the function with its elements separated by the '.' character, e.g. "Namespace.Function". |
Constructs an InvocationStackFrame object for a call to a function that returns void.
| vm | The VM on which the function is invoked. |
| function | The function to be invoked. It must belong to the VM's CodeSegment. |
| Bond::InvocationStackFrame::InvocationStackFrame | ( | VM & | vm, |
| const QualifiedName & | functionName, | ||
| ReturnType * | returnPointer ) |
Constructs an InvocationStackFrame object for a call to a function that returns a value.
| ReturnType | The native type of the return value. Integers smaller than 32 bits are returned widened to 32 bits, so they must be received in an int32_t or uint32_t. |
| Bond::InvocationStackFrame::InvocationStackFrame | ( | VM & | vm, |
| const char * | functionName, | ||
| ReturnType * | returnPointer ) |
Constructs an InvocationStackFrame object for a call to a function that returns a value.
| ReturnType | The native type of the return value. Integers smaller than 32 bits are returned widened to 32 bits, so they must be received in an int32_t or uint32_t. |
| Bond::InvocationStackFrame::InvocationStackFrame | ( | VM & | vm, |
| const Function & | function, | ||
| ReturnType * | returnPointer ) |
Constructs an InvocationStackFrame object for a call to a function that returns a value.
| ReturnType | The native type of the return value. Integers smaller than 32 bits are returned widened to 32 bits, so they must be received in an int32_t or uint32_t. |
| vm | The VM on which the function is invoked. |
| function | The function to be invoked. It must belong to the VM's CodeSegment. |
| returnPointer | Pointer to where the return value is written. It must remain valid until Call() returns. |
| void Bond::InvocationStackFrame::Call | ( | ) |
Invokes the function. Must be called after all of its arguments have been pushed.
|
delete |
| void Bond::InvocationStackFrame::PushArg | ( | const ArgType & | arg | ) |
Pushes the next argument of the function call.
Enums are passed as their underlying type and nullptr is passed as a null void pointer.
| ArgType | The native type of the argument. |
| arg | The value of the argument. |
| void Bond::InvocationStackFrame::PushArgs | ( | Args... | args | ) |
Pushes the next arguments of the function call, in order, as if by calling PushArg() for each of them.
| args | The values of the arguments. |