VDScriptInternal.h revision 9e0b97c99123f5eb89a851ce0182f7e438000c0d
567N/A/** @file
567N/A *
567N/A * VBox HDD container test utility - scripting engine, internal script structures.
567N/A */
567N/A
567N/A/*
567N/A * Copyright (C) 2013 Oracle Corporation
567N/A *
567N/A * This file is part of VirtualBox Open Source Edition (OSE), as
567N/A * available from http://www.virtualbox.org. This file is free software;
567N/A * you can redistribute it and/or modify it under the terms of the GNU
567N/A * General Public License (GPL) as published by the Free Software
567N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
567N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
567N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
567N/A */
567N/A#ifndef _VDScriptInternal_h__
567N/A#define _VDScriptInternal_h__
873N/A
567N/A#include <iprt/list.h>
567N/A#include <iprt/string.h>
567N/A
567N/A#include "VDScript.h"
567N/A
5208N/A/**
5613N/A * Script function which can be called.
567N/A */
567N/Atypedef struct VDSCRIPTFN
567N/A{
567N/A /** String space core. */
5208N/A RTSTRSPACECORE Core;
567N/A /** Flag whether function is defined in the source or was
567N/A * registered from the outside. */
3853N/A bool fExternal;
5208N/A /** Flag dependent data. */
567N/A union
567N/A {
861N/A /** Data for functions defined in the source. */
861N/A struct
861N/A {
5208N/A /** Pointer to the AST defining the function. */
3853N/A PVDSCRIPTASTFN pAstFn;
3853N/A } Internal;
3853N/A /** Data for external defined functions. */
4603N/A struct
567N/A {
4603N/A /** Callback function. */
567N/A PFNVDSCRIPTCALLBACK pfnCallback;
3853N/A /** Opaque user data. */
5208N/A void *pvUser;
861N/A } External;
567N/A } Type;
567N/A /** Return type of the function. */
567N/A VDSCRIPTTYPE enmTypeRetn;
619N/A /** Number of arguments the function takes. */
619N/A unsigned cArgs;
567N/A /** Variable sized array of argument types. */
2095N/A VDSCRIPTTYPE aenmArgTypes[1];
2095N/A} VDSCRIPTFN;
2095N/A/** Pointer to a script function registration structure. */
2095N/Atypedef VDSCRIPTFN *PVDSCRIPTFN;
2095N/A
619N/A/** Pointer to a tokenize state. */
567N/Atypedef struct VDTOKENIZER *PVDTOKENIZER;
567N/A
2127N/A/**
2127N/A * Script context.
2127N/A */
2127N/Atypedef struct VDSCRIPTCTXINT
2127N/A{
2650N/A /** String space of external registered and source defined functions. */
2650N/A RTSTRSPACE hStrSpaceFn;
5636N/A /** List of ASTs for functions - VDSCRIPTASTFN. */
2650N/A RTLISTANCHOR ListAst;
2650N/A /** Pointer to the current tokenizer state. */
3693N/A PVDTOKENIZER pTokenizer;
3693N/A} VDSCRIPTCTXINT;
5636N/A/** Pointer to a script context. */
3693N/Atypedef VDSCRIPTCTXINT *PVDSCRIPTCTXINT;
3693N/A
2127N/A/**
2127N/A * Check the context for type correctness.
2127N/A *
2127N/A * @returns VBox status code.
2127N/A * @param pThis The script context.
2127N/A */
2127N/ADECLHIDDEN(int) vdScriptCtxCheck(PVDSCRIPTCTXINT pThis);
2127N/A
2127N/A/**
2127N/A * Interprete a given function AST. The executed functions
2127N/A * must be type correct, otherwise the behavior is undefined
2127N/A * (Will assert in debug builds).
2127N/A *
2127N/A * @returns VBox status code.
2127N/A * @param pThis The script context.
2127N/A * @param pszFn The function name to interprete.
2762N/A * @param paArgs Arguments to pass to the function.
2762N/A * @param cArgs Number of arguments.
2762N/A * @param pRet Where to store the return value on success.
2762N/A *
5208N/A * @note: The AST is not modified in any way during the interpretation process.
5208N/A */
5208N/ADECLHIDDEN(int) vdScriptCtxInterprete(PVDSCRIPTCTXINT pThis, const char *pszFn,
5208N/A PVDSCRIPTARG paArgs, unsigned cArgs,
5208N/A PVDSCRIPTARG pRet);
5208N/A
5208N/A#endif /* _VDScriptInternal_h__ */
5208N/A