Added JS engine.
This commit is contained in:
54
src/script/scripter.h
Normal file
54
src/script/scripter.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "api/api.h"
|
||||
|
||||
/**
|
||||
* Initialize the scripter engine.
|
||||
*
|
||||
* @param scripter Scripter engine to initialize.
|
||||
* @param engine Game engine to use.
|
||||
*/
|
||||
void scripterInit(scripter_t *scripter, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Dispose a previously created scripter instance.
|
||||
*
|
||||
* @param scripter Scripter to dispose.
|
||||
*/
|
||||
void scripterDispose(scripter_t *scripter);
|
||||
|
||||
/**
|
||||
* Retreive the scripter instance frm a scripter context.
|
||||
*
|
||||
* @param ctx Scripter context.
|
||||
* @return Pointer to the scripter instance.
|
||||
*/
|
||||
scripter_t * scripterFromContext(scriptercontext_t *ctx);
|
||||
|
||||
/**
|
||||
* Define a method onto the global scripter stack.
|
||||
*
|
||||
* @param scripter Scripter to define onto.
|
||||
* @param name Name of the method.
|
||||
* @param argCount Arguments that the method takes.
|
||||
* @param method Pointer to the method to receive the callback.
|
||||
*/
|
||||
void scripterDefineMethod(scripter_t *scripter,
|
||||
char *name, int32_t argCount, scriptermethod_t *method
|
||||
);
|
||||
|
||||
/**
|
||||
* Invoke a method (without arguments) off the global stack.
|
||||
*
|
||||
* @param scripter Scripter to invoke frmo
|
||||
* @param method Method to invoke.
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
bool scripterInvokeMethodSimple(scripter_t *scripter, char *method);
|
Reference in New Issue
Block a user