1 /******************************************************************************
2 *
3 * Copyright (C) 2006, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov (gentee)
11 *
12 ******************************************************************************/
13
14 #ifndef _GENTEE_
15 #define _GENTEE_
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif // __cplusplus
20
21 //--------------------------------------------------------------------------
22
23 #include "../common/str.h"
24 #include "../vm/vm.h"
25 #include "../compiler/compile.h"
26
27 /*-----------------------------------------------------------------------------
28 * Id: setpars D
29 *
30 * Summary: States for gentee_set function.
31 *
32 -----------------------------------------------------------------------------*/
33
34 #define GSET_TEMPDIR 0x0001 // Specify the custom temporary directory
35 #define GSET_PRINT 0x0002 // Specify the custom print function
36 #define GSET_MESSAGE 0x0003 // Specify the custom message function
37 #define GSET_EXPORT 0x0004 // Specify the custom export function
38 #define GSET_ARGS 0x0005 // Specify the command-line arguments
39 #define GSET_FLAG 0x0006 // Specify flags
40 #define GSET_DEBUG 0x0007 // Specify the custom debug function
41 #define GSET_GETCH 0x0008 // Specify the custom getch function
42
43 /*-----------------------------------------------------------------------------
44 * Id: ptrpars D
45 *
46 * Summary: States for gentee_ptr function.
47 *
48 -----------------------------------------------------------------------------*/
49
50 #define GPTR_GENTEE 0x0001 // Pointer to gentee structure. See $[tgentee].
51 #define GPTR_VM 0x0002 // Pointer to vm structure
52 #define GPTR_COMPILE 0x0003 // Pointer to compile structure
53
54 /*-----------------------------------------------------------------------------
55 * Id: geloadflag D
56 *
57 * Summary: Flags for gentee_load function.
58 *
59 -----------------------------------------------------------------------------*/
60
61 #define GLOAD_ARGS 0x0001 // Get command line arguments
62 #define GLOAD_FILE 0x0002 // Read file to load the bytecode. The bytecode /
63 // is name of the loading file
64 #define GLOAD_RUN 0x0004 // Load #lgt(entry) functions and run #lgt(main) /
65 // function.
66
67 /*-----------------------------------------------------------------------------
68 * Id: initflags D
69 *
70 * Summary: Flags for gentee_init and gentee.flags structure.
71 *
72 -----------------------------------------------------------------------------*/
73
74 #define G_CONSOLE 0x0001 // Console application.
75 #define G_SILENT 0x0002 // Don't display any service messages.
76 #define G_CHARPRN 0x0004 // Print Windows characters.
77
78 /*-----------------------------------------------------------------------------
79 * Id: getidflag D
80 *
81 * Summary: Flags for gentee_getid
82 *
83 -----------------------------------------------------------------------------*/
84
85 #define GID_ANYOBJ 0x01000000 // Find any object
86
87 /*-----------------------------------------------------------------------------
88 *
89 * ID: functype 25.10.06 0.0.A.
90 *
91 * Summary: The function types
92 *
93 -----------------------------------------------------------------------------*/
94
95 typedef uint (STDCALL* messagefunc)( pmsginfo );
96 typedef void (STDCALL* printfunc)( pubyte, uint );
97 typedef uint (STDCALL* getchfunc)( pubyte, uint );
98 typedef void* (STDCALL* exportfunc)( pubyte );
99 typedef void (STDCALL* debugfunc)( pstackpos );
100
101 /*-----------------------------------------------------------------------------
102 ** Id: tgentee T gentee
103 *
104 * Summary: The main structure of gentee engine.
105 *
106 -----------------------------------------------------------------------------*/
107
108 typedef struct {
109 uint flags; // Flags. $$[initflags]
110 uint multib; // 1 if the current page is two-bytes code page
111 uint tempid; // The indetifier of the temporary directory.
112 str tempdir; // The temporary directory
113 uint tempfile; // The handle of the file for locking tempdir
114 printfunc print; // The custom print function
115 getchfunc getch; // The custom getch and scan function
116 messagefunc message; // The custom message function
117 exportfunc export; // The custom export function
118 debugfunc debug; // The custom debug function
119 pubyte args; // Command -line arguments. arg1 0 arg2 00
120 } gentee, *pgentee;
121
122 //--------------------------------------------------------------------------
123
124 extern gentee _gentee;
125 extern pcompile _compile; // The pointer to compile structure
126
127 //--------------------------------------------------------------------------
128 #ifdef BUILD_DLLRT
129 #undef DLL_EXPORT
130 #define DLL_EXPORT __declspec(dllexport)
131 #endif
132
133 uint DLL_EXPORT STDCALL gentee_deinit( void );
134 uint DLL_EXPORT STDCALL gentee_init( uint flags );
135 uint DLL_EXPORT STDCALL gentee_set( uint state, pvoid val );
136 pvoid DLL_EXPORT STDCALL gentee_ptr( uint par );
137 uint DLL_EXPORT STDCALL gentee_load( pubyte bytecode, uint flag );
138 uint DLL_EXPORT CDECLCALL gentee_call( uint id, puint result, ... );
139 uint DLL_EXPORT CDECLCALL gentee_getid( pubyte name, uint count, ... );
140
141 //--------------------------------------------------------------------------
142
143 #ifdef __cplusplus
144 }
145 #endif // __cplusplus
146
147 #endif // _GENTEE_
Edit