Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Commit

Permalink
Document vm_function.h
Browse files Browse the repository at this point in the history
  • Loading branch information
nilium committed Nov 13, 2014
1 parent 8e51352 commit 49a4de5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions vm_function.h
Expand Up @@ -17,13 +17,28 @@
class vm_thread;


// Semi-internal.
template <class... ARGS>
vm_value vm_invoke_function(vm_thread &thread, int64_t pointer, ARGS &&... args);


/**
* Invokable function type for Rusalka.
*
* vm_function is bound to a specific thread and, given an instruction pointer,
* can be used to call a VM function (whether it's a host callback or bytecode
* function) similar to a normal function. Automagically converts its arguments
* to VM values.
*/
class vm_function
{
/** The thread the function is bound to. */
vm_thread &_thread;
/**
* The instruction pointer of the function.
*
* If negative, points to a host callback.
*/
int64_t _pointer;

vm_function(vm_thread &thread, int64_t pointer)
Expand All @@ -36,11 +51,21 @@ class vm_function
friend vm_thread;

public:
/** Copy ctor. */
vm_function(const vm_function &other) = default;

vm_function() = delete;

/**
* Call operator. Given any number of arguments, will attempt to convert them
* all to VM value types and call the function with those after pushing them
* onto the stack.
*/
template <class... ARGS>
vm_value operator()(ARGS&&... args);
/**
* Argumentless call operator. Does what you think it does.
*/
vm_value operator() ();
};

Expand Down

0 comments on commit 49a4de5

Please sign in to comment.