VirtualBox

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

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

Storage/VDScript: Updates

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