VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/VDScriptInternal.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** @file
2 *
3 * VBox HDD container test utility - scripting engine, internal script structures.
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_testcase_VDScriptInternal_h
29#define VBOX_INCLUDED_SRC_testcase_VDScriptInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/list.h>
35#include <iprt/string.h>
36
37#include "VDScript.h"
38
39/**
40 * Script function which can be called.
41 */
42typedef struct VDSCRIPTFN
43{
44 /** String space core. */
45 RTSTRSPACECORE Core;
46 /** Flag whether function is defined in the source or was
47 * registered from the outside. */
48 bool fExternal;
49 /** Flag dependent data. */
50 union
51 {
52 /** Data for functions defined in the source. */
53 struct
54 {
55 /** Pointer to the AST defining the function. */
56 PVDSCRIPTASTFN pAstFn;
57 } Internal;
58 /** Data for external defined functions. */
59 struct
60 {
61 /** Callback function. */
62 PFNVDSCRIPTCALLBACK pfnCallback;
63 /** Opaque user data. */
64 void *pvUser;
65 } External;
66 } Type;
67 /** Return type of the function. */
68 VDSCRIPTTYPE enmTypeRetn;
69 /** Number of arguments the function takes. */
70 unsigned cArgs;
71 /** Variable sized array of argument types. */
72 VDSCRIPTTYPE aenmArgTypes[1];
73} VDSCRIPTFN;
74/** Pointer to a script function registration structure. */
75typedef VDSCRIPTFN *PVDSCRIPTFN;
76
77/** Pointer to a tokenize state. */
78typedef struct VDTOKENIZER *PVDTOKENIZER;
79
80/**
81 * Script context.
82 */
83typedef struct VDSCRIPTCTXINT
84{
85 /** String space of external registered and source defined functions. */
86 RTSTRSPACE hStrSpaceFn;
87 /** List of ASTs for functions - VDSCRIPTASTFN. */
88 RTLISTANCHOR ListAst;
89 /** Pointer to the current tokenizer state. */
90 PVDTOKENIZER pTokenizer;
91} VDSCRIPTCTXINT;
92/** Pointer to a script context. */
93typedef VDSCRIPTCTXINT *PVDSCRIPTCTXINT;
94
95/**
96 * Check the context for type correctness.
97 *
98 * @returns VBox status code.
99 * @param pThis The script context.
100 */
101DECLHIDDEN(int) vdScriptCtxCheck(PVDSCRIPTCTXINT pThis);
102
103/**
104 * Interprete a given function AST. The executed functions
105 * must be type correct, otherwise the behavior is undefined
106 * (Will assert in debug builds).
107 *
108 * @returns VBox status code.
109 * @param pThis The script context.
110 * @param pszFn The function name to interprete.
111 * @param paArgs Arguments to pass to the function.
112 * @param cArgs Number of arguments.
113 * @param pRet Where to store the return value on success.
114 *
115 * @note: The AST is not modified in any way during the interpretation process.
116 */
117DECLHIDDEN(int) vdScriptCtxInterprete(PVDSCRIPTCTXINT pThis, const char *pszFn,
118 PVDSCRIPTARG paArgs, unsigned cArgs,
119 PVDSCRIPTARG pRet);
120
121#endif /* !VBOX_INCLUDED_SRC_testcase_VDScriptInternal_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use