1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
16 #ifndef SQUIRRELJME_STDTYPES_H
17 #define SQUIRRELJME_STDTYPES_H
22 #include "sjme/config.h"
26 #ifndef SJME_CXX_IS_EXTERNED
27 #define SJME_CXX_IS_EXTERNED
28 #define SJME_CXX_SQUIRRELJME_STDTYPES_H
31 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
32 #endif /* #ifdef __cplusplus */
34 /*--------------------------------------------------------------------------*/
37 * Basic data type identifier.
41 typedef enum sjme_basicTypeId
44 SJME_BASIC_TYPE_ID_INTEGER
= 0,
47 SJME_JAVA_TYPE_ID_INTEGER
= SJME_BASIC_TYPE_ID_INTEGER
,
50 SJME_BASIC_TYPE_ID_LONG
= 1,
53 SJME_JAVA_TYPE_ID_LONG
= SJME_BASIC_TYPE_ID_LONG
,
56 SJME_BASIC_TYPE_ID_FLOAT
= 2,
59 SJME_JAVA_TYPE_ID_FLOAT
= SJME_BASIC_TYPE_ID_FLOAT
,
62 SJME_BASIC_TYPE_ID_DOUBLE
= 3,
65 SJME_JAVA_TYPE_ID_DOUBLE
= SJME_BASIC_TYPE_ID_DOUBLE
,
68 SJME_BASIC_TYPE_ID_OBJECT
= 4,
71 SJME_JAVA_TYPE_ID_OBJECT
= SJME_BASIC_TYPE_ID_OBJECT
,
73 /** The number of Java type IDs. */
74 SJME_NUM_JAVA_TYPE_IDS
= 5,
76 /** Boolean or byte. */
77 SJME_JAVA_TYPE_ID_BOOLEAN_OR_BYTE
= SJME_NUM_JAVA_TYPE_IDS
,
79 /** Character or short type. */
80 SJME_JAVA_TYPE_ID_SHORT_OR_CHAR
= 6,
83 SJME_BASIC_TYPE_ID_VOID
= 7,
86 SJME_JAVA_TYPE_ID_VOID
= SJME_BASIC_TYPE_ID_VOID
,
88 /** End of extended Java types. */
89 SJME_NUM_EXTENDED_JAVA_TYPE_IDS
= 8,
92 SJME_BASIC_TYPE_ID_SHORT
= SJME_NUM_EXTENDED_JAVA_TYPE_IDS
,
95 SJME_BASIC_TYPE_ID_CHARACTER
= 9,
97 /** Specifically boolean. */
98 SJME_BASIC_TYPE_ID_BOOLEAN
= 10,
100 /** Specifically jbyte. */
101 SJME_BASIC_TYPE_ID_BYTE
= 11,
103 /** Number of basic type IDs. */
104 SJME_NUM_BASIC_TYPE_IDS
= 11
112 typedef enum sjme_jboolean
119 /** Basic @c sjme_jboolean type identifier. */
120 #define SJME_TYPEOF_BASIC_sjme_jboolean SJME_BASIC_TYPE_ID_BOOLEAN
122 /** Java @c sjme_jboolean type identifier. */
123 #define SJME_TYPEOF_JAVA_sjme_jboolean SJME_JAVA_TYPE_ID_BOOLEAN_OR_BYTE
125 /** Is a pointer for @c sjme_jboolean ? */
126 #define SJME_TYPEOF_IS_POINTER_sjme_jboolean 0
133 typedef int8_t sjme_jbyte
;
135 /** Basic @c sjme_jbyte type identifier. */
136 #define SJME_TYPEOF_BASIC_sjme_jbyte SJME_BASIC_TYPE_ID_BYTE
138 /** Java @c sjme_jbyte type identifier. */
139 #define SJME_TYPEOF_JAVA_sjme_jbyte SJME_JAVA_TYPE_ID_BOOLEAN_OR_BYTE
141 /** Is a pointer for @c sjme_jbyte ? */
142 #define SJME_TYPEOF_IS_POINTER_sjme_jbyte 0
145 * Promoted @c sjme_jbyte .
149 typedef int sjme_jbyte_promoted
;
152 * Unsigned byte type.
156 typedef uint8_t sjme_jubyte
;
158 /** Basic @c sjme_jubyte type identifier. */
159 #define SJME_TYPEOF_BASIC_sjme_jubyte SJME_BASIC_TYPE_ID_BYTE
161 /** Java @c sjme_jubyte type identifier. */
162 #define SJME_TYPEOF_JAVA_sjme_jubyte SJME_JAVA_TYPE_ID_BOOLEAN_OR_BYTE
164 /** Is a pointer for @c sjme_jubyte ? */
165 #define SJME_TYPEOF_IS_POINTER_sjme_jubyte 0
168 * Promoted @c sjme_jubyte .
172 typedef int sjme_jubyte_promoted
;
179 typedef int16_t sjme_jshort
;
181 /** Basic @c sjme_jshort type identifier. */
182 #define SJME_TYPEOF_BASIC_sjme_jshort SJME_BASIC_TYPE_ID_SHORT
184 /** Java @c sjme_jshort type identifier. */
185 #define SJME_TYPEOF_JAVA_sjme_jshort SJME_JAVA_TYPE_ID_INTEGER
187 /** Is a pointer for @c sjme_jshort ? */
188 #define SJME_TYPEOF_IS_POINTER_sjme_jshort 0
191 * Promoted @c sjme_jshort .
195 typedef int sjme_jshort_promoted
;
202 typedef uint16_t sjme_jchar
;
204 /** Basic @c sjme_jchar type identifier. */
205 #define SJME_TYPEOF_BASIC_sjme_jchar SJME_BASIC_TYPE_ID_CHARACTER
207 /** Java @c sjme_jchar type identifier. */
208 #define SJME_TYPEOF_JAVA_sjme_jchar SJME_JAVA_TYPE_ID_INTEGER
210 /** Is a pointer for @c sjme_jchar ? */
211 #define SJME_TYPEOF_IS_POINTER_sjme_jchar 0
214 * Promoted @c sjme_jchar .
218 typedef int sjme_jchar_promoted
;
225 typedef int32_t sjme_jint
;
227 /** Basic @c sjme_jint type identifier. */
228 #define SJME_TYPEOF_BASIC_sjme_jint SJME_BASIC_TYPE_ID_INTEGER
230 /** Java @c sjme_jint type identifier. */
231 #define SJME_TYPEOF_JAVA_sjme_jint SJME_JAVA_TYPE_ID_INTEGER
233 /** Is a pointer for @c sjme_jint ? */
234 #define SJME_TYPEOF_IS_POINTER_sjme_jint 0
237 * Unsigned integer type.
241 typedef uint32_t sjme_juint
;
243 /** Basic @c sjme_juint type identifier. */
244 #define SJME_TYPEOF_BASIC_sjme_juint SJME_BASIC_TYPE_ID_INTEGER
246 /** Java @c sjme_juint type identifier. */
247 #define SJME_TYPEOF_JAVA_sjme_juint SJME_JAVA_TYPE_ID_INTEGER
249 /** Is a pointer for @c sjme_juint ? */
250 #define SJME_TYPEOF_IS_POINTER_sjme_juint 0
257 typedef sjme_jint sjme_fixed
;
264 typedef char sjme_cchar
;
266 #if defined(CHAR_BIT) && (CHAR_BIT == 64)
267 /** Basic @c sjme_cchar type identifier. */
268 #define SJME_TYPEOF_BASIC_sjme_cchar SJME_BASIC_TYPE_ID_LONG
269 #elif defined(CHAR_BIT) && (CHAR_BIT == 32)
270 /** Basic @c sjme_cchar type identifier. */
271 #define SJME_TYPEOF_BASIC_sjme_cchar SJME_BASIC_TYPE_ID_INTEGER
272 #elif defined(CHAR_BIT) && (CHAR_BIT == 16)
273 /** Basic @c sjme_cchar type identifier. */
274 #define SJME_TYPEOF_BASIC_sjme_cchar SJME_BASIC_TYPE_ID_SHORT
276 /** Basic @c sjme_cchar type identifier. */
277 #define SJME_TYPEOF_BASIC_sjme_cchar SJME_BASIC_TYPE_ID_BYTE
280 /** Is a pointer for @c sjme_cchar ? */
281 #define SJME_TYPEOF_IS_POINTER_sjme_cchar 0
283 #if defined(SJME_CONFIG_HAS_ARCH_IA16)
285 * Pointer to C string.
289 typedef sjme_cchar huge
* sjme_lpstr
;
292 * Pointer to C string.
296 typedef sjme_cchar
* sjme_lpstr
;
299 /** Basic @c sjme_lpstr type identifier. */
300 #define SJME_TYPEOF_BASIC_sjme_lpstr SJME_BASIC_TYPE_ID_OBJECT
302 /** Is a pointer for @c sjme_lpstr ? */
303 #define SJME_TYPEOF_IS_POINTER_sjme_lpstr 1
305 #if defined(SJME_CONFIG_HAS_ARCH_IA16)
307 * Pointer to constant C string.
311 typedef const sjme_cchar huge
* sjme_lpcstr
;
314 * Pointer to constant C string.
318 typedef const sjme_cchar
* sjme_lpcstr
;
321 /** Basic @c sjme_lpcstr type identifier. */
322 #define SJME_TYPEOF_BASIC_sjme_lpcstr SJME_BASIC_TYPE_ID_OBJECT
324 /** Is a pointer for @c sjme_lpcstr ? */
325 #define SJME_TYPEOF_IS_POINTER_sjme_lpcstr 1
327 #if defined(SJME_CONFIG_HAS_ARCH_IA16)
333 typedef void huge
* sjme_pointer
;
340 typedef void* sjme_pointer
;
343 /** Basic @c sjme_pointer type identifier. */
344 #define SJME_TYPEOF_BASIC_sjme_pointer SJME_BASIC_TYPE_ID_OBJECT
346 /** Is a pointer for @c sjme_pointer ? */
347 #define SJME_TYPEOF_IS_POINTER_sjme_pointer 1
349 #if defined(SJME_CONFIG_HAS_ARCH_IA16)
351 * Generic pointer to const data.
355 typedef const void huge
* sjme_cpointer
;
358 * Generic pointer to const data.
362 typedef const void* sjme_cpointer
;
365 /** Basic @c sjme_cpointer type identifier. */
366 #define SJME_TYPEOF_BASIC_sjme_cpointer SJME_BASIC_TYPE_ID_OBJECT
368 /** Is a pointer for @c sjme_cpointer ? */
369 #define SJME_TYPEOF_IS_POINTER_sjme_cpointer 1
376 typedef sjme_pointer sjme_buffer
;
383 typedef sjme_cpointer sjme_cbuffer
;
386 * Integer based pointer.
390 typedef intptr_t sjme_intPointer
;
392 /** Calculates a pointer offset. */
393 #define SJME_POINTER_OFFSET(base, off) \
394 (sjme_pointer)(((sjme_intPointer)(base)) + ((sjme_intPointer)(off)))
396 #if defined(SJME_CONFIG_HAS_POINTER64)
397 #define SJME_TYPEOF_BASIC_sjme_intPointer SJME_TYPEOF_BASIC_sjme_jpointer
399 #define SJME_TYPEOF_BASIC_sjme_intPointer SJME_TYPEOF_BASIC_sjme_juint
402 #define SJME_TYPEOF_IS_POINTER_sjme_intPointer 0
409 typedef union sjme_jlong
411 /** Parts of the long. */
414 #if defined(SJME_CONFIG_HAS_LITTLE_ENDIAN)
429 /** The full long. */
433 /** Basic @c sjme_jlong type identifier. */
434 #define SJME_TYPEOF_BASIC_sjme_jlong SJME_BASIC_TYPE_ID_LONG
436 /** Java @c sjme_jlong type identifier. */
437 #define SJME_TYPEOF_JAVA_sjme_jlong SJME_JAVA_TYPE_ID_LONG
439 /** Is a pointer for @c sjme_jlong ? */
440 #define SJME_TYPEOF_IS_POINTER_sjme_jlong 0
447 typedef struct sjme_jfloat
452 /** Basic @c sjme_jfloat type identifier. */
453 #define SJME_TYPEOF_BASIC_sjme_jfloat SJME_BASIC_TYPE_ID_FLOAT
455 /** Java @c sjme_jfloat type identifier. */
456 #define SJME_TYPEOF_JAVA_sjme_jfloat SJME_JAVA_TYPE_ID_FLOAT
458 /** Is a pointer for @c sjme_jfloat ? */
459 #define SJME_TYPEOF_IS_POINTER_sjme_jfloat 0
466 typedef struct sjme_jdouble
468 #if defined(SJME_CONFIG_HAS_LITTLE_ENDIAN)
483 /** Basic @c sjme_jdouble type identifier. */
484 #define SJME_TYPEOF_BASIC_sjme_jdouble SJME_BASIC_TYPE_ID_DOUBLE
486 /** Java @c sjme_jdouble type identifier. */
487 #define SJME_TYPEOF_JAVA_sjme_jdouble SJME_JAVA_TYPE_ID_DOUBLE
489 /** Is a pointer for @c sjme_jdouble ? */
490 #define SJME_TYPEOF_IS_POINTER_sjme_jdouble 0
497 typedef sjme_jint sjme_tempIndex
;
504 typedef struct sjme_range
506 /** Start of the range. */
509 /** End of the range. */
514 * Represents a pointer and a length.
518 typedef struct sjme_pointerLen
520 /** The pointer to the data. */
521 sjme_pointer pointer
;
523 /** The length of the pointer. */
527 /** The Java type ID. */
528 typedef sjme_basicTypeId sjme_javaTypeId
;
531 * Represents multiple type IDs.
535 typedef struct sjme_basicTypeIds
537 /** The number of IDs. */
541 const sjme_javaTypeId ids
[sjme_flexibleArrayCount
];
545 * Base object information.
549 typedef struct sjme_jobjectBase sjme_jobjectBase
;
556 typedef sjme_jobjectBase
* sjme_jobject
;
558 /** Basic @c sjme_jobject type identifier. */
559 #define SJME_TYPEOF_BASIC_sjme_jobject SJME_BASIC_TYPE_ID_OBJECT
561 /** Java @c sjme_jobject type identifier. */
562 #define SJME_TYPEOF_JAVA_sjme_jobject SJME_BASIC_TYPE_ID_OBJECT
564 /** Is a pointer for @c sjme_jobject ? */
565 #define SJME_TYPEOF_IS_POINTER_sjme_jobject 1
568 * Generic value union.
572 typedef union sjme_jvalue
598 /** Object/Reference. */
603 * Structure which stores the pooled memory allocator.
607 typedef struct sjme_alloc_pool sjme_alloc_pool
;
609 /*--------------------------------------------------------------------------*/
613 #ifdef SJME_CXX_SQUIRRELJME_STDTYPES_H
615 #undef SJME_CXX_SQUIRRELJME_STDTYPES_H
616 #undef SJME_CXX_IS_EXTERNED
617 #endif /* #ifdef SJME_CXX_SQUIRRELJME_STDTYPES_H */
618 #endif /* #ifdef __cplusplus */
620 #endif /* SQUIRRELJME_STDTYPES_H */