VirtualBox

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

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

Storage/testcase: Start new scripting engine for enhanced testing capabilities (better testing of the reworked async I/O code), wip

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 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
51/**
52 * Script argument.
53 */
54typedef union VDSCRIPTARG
55{
56 uint8_t u8;
57 int8_t i8;
58 uint16_t u16;
59 int16_t i16;
60 uint32_t u32;
61 int32_t i32;
62 uint64_t u64;
63 int64_t i64;
64 const char *psz;
65 bool f;
66} VDSCRIPTARG;
67/** Pointer to an argument. */
68typedef VDSCRIPTARG *PVDSCRIPTARG;
69
70/** Script callback. */
71typedef DECLCALLBACK(int) FNVDSCRIPTCALLBACK(PVDSCRIPTARG paScriptArgs, void *pvUser);
72/** Pointer to a script callback. */
73typedef FNVDSCRIPTCALLBACK *PFNVDSCRIPTCALLBACK;
74
75/**
76 * Callback registration structure.
77 */
78typedef struct VDSCRIPTCALLBACK
79{
80 /** The function name. */
81 const char *pszFnName;
82 /** The return type of the function. */
83 VDSCRIPTTYPE enmTypeReturn;
84 /** Number of arguments this method takes. */
85 unsigned cArgs;
86 /** Pointer to the array of argument types. */
87 PVDSCRIPTTYPE paArgs;
88 /** The callback handler. */
89 PFNVDSCRIPTCALLBACK pfnCallback;
90} VDSCRIPTCALLBACK;
91/** Pointer to a callback register entry. */
92typedef VDSCRIPTCALLBACK *PVDSCRIPTCALLBACK;
93
94/**
95 * Create a new scripting context.
96 *
97 * @returns VBox status code.
98 * @param phScriptCtx Where to store the scripting context on success.
99 */
100DECLHIDDEN(int) VDScriptCtxCreate(PVDSCRIPTCTX phScriptCtx);
101
102/**
103 * Destroys the given scripting context.
104 *
105 * @returns nothing.
106 * @param hScriptCtx The script context to destroy.
107 */
108DECLHIDDEN(void) VDScriptCtxDestroy(VDSCRIPTCTX hScriptCtx);
109
110/**
111 * Register callbacks for the scripting context.
112 *
113 * @returns VBox status code.
114 * @param hScriptCtx The script context handle.
115 * @param paCallbacks Pointer to the callbacks to register.
116 * @param cCallbacks Number of callbacks in the array.
117 * @param pvUser Opaque user data to pass on the callback invocation.
118 */
119DECLHIDDEN(int) VDScriptCtxCallbacksRegister(VDSCRIPTCTX hScriptCtx, PVDSCRIPTCALLBACK paCallbacks,
120 unsigned cCallbacks, void *pvUser);
121
122/**
123 * Load a given script into the context.
124 *
125 * @returns VBox status code.
126 * @param hScriptCtx The script context handle.
127 * @param pszScript Pointer to the char buffer containing the script.
128 */
129DECLHIDDEN(int) VDScriptCtxLoadScript(VDSCRIPTCTX hScriptCtx, const char *pszScript);
130
131/**
132 * Execute a given method in the script context.
133 *
134 * @returns VBox status code.
135 * @param hScriptCtx The script context handle.
136 * @param pszFnCall The method to call.
137 * @param paArgs Pointer to arguments to pass.
138 * @param cArgs Number of arguments.
139 */
140DECLHIDDEN(int) VDScriptCtxCallFn(VDSCRIPTCTX hScriptCtx, const char *pszFnCall,
141 PVDSCRIPTARG paArgs, unsigned cArgs);
142
143#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