Menu

[b84aab]: / src / common / units.h  Maximize  Restore  History

Download this file

150 lines (128 with data), 2.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// This file is part of SmallBASIC
//
// SmallBASIC Unit (SB units) manager
//
// This program is distributed under the terms of the GPL v2.0 or later
// Download the GNU Public License (GPL) from www.gnu.org
//
// Copyright(C) 2000 Nicholas Christopoulos
#if !defined(__sb_units_h)
#define __sb_units_h
#include "common/sys.h"
#include "common/var.h"
#if defined(__cplusplus)
extern "C" {
#endif
#define UID_UNIT_BIT 0x8000
/**
* @ingroup exec
*
* @typedef sym_type_t
* symbol type (export/import)
*/
typedef enum {
stt_variable, stt_procedure, stt_function
} sym_type_t;
/**
* @ingroup exec
*
* @typedef unit_sym_t
* symbol structure
*/
typedef struct {
char symbol[SB_KEYWORD_SIZE]; /**< symbol name */
sym_type_t type; /**< type of symbol (function, procedure, variable) */
addr_t address; /**< code address if proc/func */
addr_t vid; /**< return Variable-ID if func; or Variable-ID if variable */
} unit_sym_t;
/**
* @ingroup exec
*
* unit status
*/
typedef enum {
unit_undefined, /**< unused record */
unit_loaded, /**< unit is loaded */
unit_nil
} unit_status_t;
/**
* @ingroup exec
* @typedef unit_file_t
* unit: file header
*/
typedef struct {
dword sign[4]; /**< Always "SBUn" */
int version; /**< version of this structure, always 1 */
char base[SB_KEYWORD_SIZE + 1]; /**< unit-base name */
int sym_count; /**< number of symbols */
} unit_file_t;
/**
* @ingroup exec
* @typedef unit_t
* unit-memory structure
*/
typedef struct {
unit_status_t status; /**< status of this record */
char name[OS_FILENAME_SIZE + 1]; /**< unit/file name */
unit_file_t hdr; /**< data from file */
unit_sym_t *symbols; /**< table of symbols */
}unit_t;
/**
* @ingroup exec
*
* initialization
*/
void unit_mgr_init() SEC(BIO2);
/**
* @ingroup exec
*
* close up
*/
void unit_mgr_close() SEC(BIO2);
/**
* @ingroup exec
*
* returns the full-pathname of unit
*
* @param name unit's name
* @param file buffer to store the filename
* @return non-zero on success
*/
int find_unit(const char *name, char *file) SEC(BIO2);
/**
* @ingroup exec
*
* open unit
*
* @param file is the filename
* @return the unit handle or -1 on error
*/
int open_unit(const char *file) SEC(BIO2);
/**
* @ingroup exec
*
* closes a unit
*
* @param uid is the unit's handle
* @return 0 on success
*/
int close_unit(int uid) SEC(BIO2);
/**
* @ingroup exec
*
* imports unit's names
*
* @param uid unit's handle
* @return 0 on success
*/
int import_unit(int uid) SEC(BIO2);
/**
* @ingroup exec
*
* execute
*/
int unit_exec(int lib_id, int index, var_t * ret) SEC(BIO2);
#if defined(__cplusplus)
}
#endif
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.