sourcepawn/include/sp_vm_api.h
changeset 175 d8fc20f56ca0
parent 172 d8a8186eccbf
child 179 628bdadc9b32
     1.1 --- a/sourcepawn/include/sp_vm_api.h	Sat Nov 11 01:19:46 2006 +0000
     1.2 +++ b/sourcepawn/include/sp_vm_api.h	Sat Nov 11 05:47:00 2006 +0000
     1.3 @@ -4,6 +4,8 @@
     1.4  #include <stdio.h>
     1.5  #include "sp_vm_types.h"
     1.6  
     1.7 +#define SOURCEPAWN_VM_API_VERSION		1
     1.8 +
     1.9  namespace SourcePawn
    1.10  {
    1.11  	class IVirtualMachine;
    1.12 @@ -393,12 +395,17 @@
    1.13  	{
    1.14  	public:
    1.15  		/**
    1.16 -		 * Returns the string name of a VM implementation.
    1.17 +		 * @brief Returns the current API version.
    1.18 +		 */
    1.19 +		virtual unsigned int GetAPIVersion() =0;
    1.20 +
    1.21 +		/**
    1.22 +		 * @brief Returns the string name of a VM implementation.
    1.23  		 */
    1.24  		virtual const char *GetVMName() =0;
    1.25  
    1.26  		/**
    1.27 -		 * Begins a new compilation
    1.28 +		 * @brief Begins a new compilation
    1.29  		 * 
    1.30  		 * @param plugin	Pointer to a plugin structure.
    1.31  		 * @return			New compilation pointer.
    1.32 @@ -406,7 +413,7 @@
    1.33  		virtual ICompilation *StartCompilation(sp_plugin_t *plugin) =0;
    1.34  
    1.35  		/**
    1.36 -		 * Sets a compilation option.
    1.37 +		 * @brief Sets a compilation option.
    1.38  		 *
    1.39  		 * @param co		Pointer to a compilation.
    1.40  		 * @param key		Option key name.
    1.41 @@ -416,7 +423,7 @@
    1.42  		virtual bool SetCompilationOption(ICompilation *co, const char *key, const char *val) =0;
    1.43  
    1.44  		/**
    1.45 -		 * Finalizes a compilation into a new sp_context_t.
    1.46 +		 * @brief Finalizes a compilation into a new sp_context_t.
    1.47  		 * Note: This will free the ICompilation pointer.
    1.48  		 *
    1.49  		 * @param co		Compilation pointer.
    1.50 @@ -426,28 +433,46 @@
    1.51  		virtual sp_context_t *CompileToContext(ICompilation *co, int *err) =0;
    1.52  
    1.53  		/**
    1.54 -		 * Aborts a compilation and frees the ICompilation pointer.
    1.55 +		 * @brief Aborts a compilation and frees the ICompilation pointer.
    1.56  		 *
    1.57  		 * @param co		Compilation pointer.
    1.58  		 */
    1.59  		virtual void AbortCompilation(ICompilation *co) =0;
    1.60  
    1.61  		/**
    1.62 -		 * Frees any internal variable usage on a context.
    1.63 +		 * @brief Frees any internal variable usage on a context.
    1.64  		 *
    1.65  		 * @param ctx		Context structure pointer.
    1.66  		 */
    1.67  		virtual void FreeContext(sp_context_t *ctx) =0;
    1.68  
    1.69  		/**
    1.70 -		 * Calls the "execute" function on a context.
    1.71 +		 * @brief Calls the "execute" function on a context.
    1.72  		 *
    1.73  		 * @param ctx		Executes a function in a context.
    1.74 -		 * @param code_idx	Index into the code section.
    1.75 -		 * @param result	Pointer to store result in.
    1.76 +		 * @param code_addr	Index into the code section.
    1.77 +		 * @param result	Pointer to store result into.
    1.78  		 * @return			Error code (if any).
    1.79  		 */
    1.80 -		virtual int ContextExecute(sp_context_t *ctx, uint32_t code_idx, cell_t *result) =0;
    1.81 +		virtual int ContextExecute(sp_context_t *ctx, uint32_t code_addr, cell_t *result) =0;
    1.82 +
    1.83 +		/**
    1.84 +		 * @brief Given a context and a code address, returns the index of the function.
    1.85 +		 * 
    1.86 +		 * @param ctx		Context to search.
    1.87 +		 * @param code_addr	Index into the code section.
    1.88 +		 * @param result	Pointer to store result into.
    1.89 +		 * @return			True if code index is valid, false otherwise.
    1.90 +		 */
    1.91 +		virtual bool FunctionLookup(const sp_context_t *ctx, uint32_t code_addr, unsigned int *result) =0;
    1.92 +
    1.93 +		/**
    1.94 +		 * @brief Returns the number of functions defined in the context.
    1.95 +		 *
    1.96 +		 * @param ctx		Context to search.
    1.97 +		 * @return			Number of functions.
    1.98 +		 */
    1.99 +		virtual unsigned int FunctionCount(const sp_context_t *ctx) =0;
   1.100  	};
   1.101  };
   1.102