VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/VDScript.h@ 45221

Last change on this file since 45221 was 44941, checked in by vboxsync, 12 years ago

Storage/testcase: More scripting language work

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/** @file
2 *
3 * VBox HDD container test utility - scripting engine.
4 */
5
6/*
7 * Copyright (C) 2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#ifndef _VDScript_h__
18#define _VDScript_h__
19
20/** Handle to the scripting context. */
21typedef struct VDSCRIPTCTXINT *VDSCRIPTCTX;
22/** Pointer to a scripting context handle. */
23typedef VDSCRIPTCTX *PVDSCRIPTCTX;
24
25/**
26 * Supprted primitive types in the scripting engine.
27 */
28typedef enum VDSCRIPTTYPE
29{
30 /** Invalid type, do not use. */
31 VDSCRIPTTYPE_INVALID = 0,
32 /** void type, used for no return value of methods. */
33 VDSCRIPTTYPE_VOID,
34 /** unsigned 8bit integer. */
35 VDSCRIPTTYPE_UINT8,
36 VDSCRIPTTYPE_INT8,
37 VDSCRIPTTYPE_UINT16,
38 VDSCRIPTTYPE_INT16,
39 VDSCRIPTTYPE_UINT32,
40 VDSCRIPTTYPE_INT32,
41 VDSCRIPTTYPE_UINT64,
42 VDSCRIPTTYPE_INT64,
43 VDSCRIPTTYPE_STRING,
44 VDSCRIPTTYPE_BOOL,
45 /** As usual, the 32bit blowup hack. */
46 VDSCRIPTTYPE_32BIT_HACK = 0x7fffffff
47} VDSCRIPTTYPE;
48/** Pointer to a type. */
49typedef VDSCRIPTTYPE *PVDSCRIPTTYPE;
50/** Pointer to a const type. */
51typedef const VDSCRIPTTYPE *PCVDSCRIPTTYPE;
52
53/**
54 * Script argument.
55 */
56typedef struct VDSCRIPTARG
57{
58 /** Type of the argument. */
59 VDSCRIPTTYPE enmType;
60 /** Value */
61 union
62 {
63 uint8_t u8;
64 int8_t i8;
65 uint16_t u16;
66 int16_t i16;
67 uint32_t u32;
68 int32_t i32;
69 uint64_t u64;
70 int64_t i64;
71 const char *psz;
72 bool f;
73 };
74} VDSCRIPTARG;
75/** Pointer to an argument. */
76typedef VDSCRIPTARG *PVDSCRIPTARG;
77
78/** Script callback. */
79typedef DECLCALLBACK(int) FNVDSCRIPTCALLBACK(PVDSCRIPTARG paScriptArgs, void *pvUser);
80/** Pointer to a script callback. */
81typedef FNVDSCRIPTCALLBACK *PFNVDSCRIPTCALLBACK;
82
83/**
84 * Callback registration structure.
85 */
86typedef struct VDSCRIPTCALLBACK
87{
88 /** The function name. */
89 const char *pszFnName;
90 /** The return type of the function. */
91 VDSCRIPTTYPE enmTypeReturn;
92 /** Pointer to the array of argument types. */
93 PCVDSCRIPTTYPE paArgs;
94 /** Number of arguments this method takes. */
95 unsigned cArgs;
96 /** The callback handler. */
97 PFNVDSCRIPTCALLBACK pfnCallback;
98} VDSCRIPTCALLBACK;
99/** Pointer to a callback register entry. */
100typedef VDSCRIPTCALLBACK *PVDSCRIPTCALLBACK;
101/** Pointer to a const callback register entry. */
102typedef const VDSCRIPTCALLBACK *PCVDSCRIPTCALLBACK;
103
104/**
105 * Create a new scripting context.
106 *
107 * @returns VBox status code.
108 * @param phScriptCtx Where to store the scripting context on success.
109 */
110DECLHIDDEN(int) VDScriptCtxCreate(PVDSCRIPTCTX phScriptCtx);
111
112/**
113 * Destroys the given scripting context.
114 *
115 * @returns nothing.
116 * @param hScriptCtx The script context to destroy.
117 */
118DECLHIDDEN(void) VDScriptCtxDestroy(VDSCRIPTCTX hScriptCtx);
119
120/**
121 * Register callbacks for the scripting context.
122 *
123 * @returns VBox status code.
124 * @param hScriptCtx The script context handle.
125 * @param paCallbacks Pointer to the callbacks to register.
126 * @param cCallbacks Number of callbacks in the array.
127 * @param pvUser Opaque user data to pass on the callback invocation.
128 */
129DECLHIDDEN(int) VDScriptCtxCallbacksRegister(VDSCRIPTCTX hScriptCtx, PCVDSCRIPTCALLBACK paCallbacks,
130 unsigned cCallbacks, void *pvUser);
131
132/**
133 * Load a given script into the context.
134 *
135 * @returns VBox status code.
136 * @param hScriptCtx The script context handle.
137 * @param pszScript Pointer to the char buffer containing the script.
138 */
139DECLHIDDEN(int) VDScriptCtxLoadScript(VDSCRIPTCTX hScriptCtx, const char *pszScript);
140
141/**
142 * Execute a given method in the script context.
143 *
144 * @returns VBox status code.
145 * @param hScriptCtx The script context handle.
146 * @param pszFnCall The method to call.
147 * @param paArgs Pointer to arguments to pass.
148 * @param cArgs Number of arguments.
149 */
150DECLHIDDEN(int) VDScriptCtxCallFn(VDSCRIPTCTX hScriptCtx, const char *pszFnCall,
151 PVDSCRIPTARG paArgs, unsigned cArgs);
152
153#endif /* _VDScript_h__ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette