/tool/gec/bootstrap/gec.h
C Header | 18110 lines | 11880 code | 2824 blank | 3406 comment | 47 complexity | 5eea93f4e13c0e4b8197eddc6f7fcccd MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- #define GE_USE_THREADS
- /*
- description:
- "C declarations for the Gobo Eiffel runtime."
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2005-2020, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_EIFFEL_H
- #define GE_EIFFEL_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- /* Class name mapping as defined in the FreeELKS library. */
- #ifndef EIF_INTEGER
- #define EIF_INTEGER EIF_INTEGER_32
- #endif
- #ifndef EIF_CHARACTER
- #define EIF_CHARACTER EIF_CHARACTER_8
- #endif
- #ifndef EIF_REAL
- #define EIF_REAL EIF_REAL_32
- #endif
- #ifndef EIF_DOUBLE
- #define EIF_DOUBLE EIF_REAL_64
- #endif
- #ifndef GE_ms
- #if EIF_CHARACTER == EIF_CHARACTER_8
- #define GE_ms(s,c) GE_ms8((s),(c))
- #else
- #define GE_ms(s,c) GE_ms32((s),(c))
- #endif
- #endif
- #if defined(__USE_POSIX) || defined(__unix__) || defined(_POSIX_C_SOURCE)
- #include <unistd.h>
- #endif
- #if !defined(WIN32) && \
- (defined(WINVER) || defined(_WIN32_WINNT) || defined(_WIN32) || \
- defined(__WIN32__) || defined(__TOS_WIN__) || defined(_MSC_VER) || \
- defined(__MINGW32__))
- #define WIN32 1
- #endif
- #ifdef WIN32
- #define EIF_WINDOWS 1
- #include <windows.h>
- #endif
- /* See https://sourceforge.net/p/predef/wiki/OperatingSystems/ */
- #if (defined(macintosh) || defined(Macintosh))
- #define EIF_MAC 1
- #define EIF_MACOSX 1
- #endif
- #if (defined(__APPLE__) && defined(__MACH__))
- /* Apparently ISE does not define EIF_MASOSX for Mac OS X >=10.4 (see EXECUTION_ENVIRONMENT.available_cpu_count) */
- #define EIF_MAC 1
- #endif
- #if (defined(VMS) || defined(__VMS))
- #define EIF_VMS 1
- #endif
- #if (defined(__VXWORKS__) || defined(__vxworks))
- #define EIF_VXWORKS 1
- #endif
- #define BYTEORDER 0x1234
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
- #include <string.h>
- #include <stddef.h>
- #define EIF_OS_WINNT 1
- #define EIF_OS_LINUX 2
- #define EIF_OS_DARWIN 4
- #define EIF_OS_VXWORKS 11
- #define EIF_OS_VMS 12
- /* Platform definition */
- /* Unix definition */
- #define EIF_IS_UNIX EIF_TRUE
- #define EIF_OS EIF_OS_LINUX
- /* Windows definition */
- #ifdef EIF_WINDOWS
- #define EIF_IS_WINDOWS EIF_TRUE
- #undef EIF_OS
- #define EIF_OS EIF_OS_WINNT
- #undef EIF_IS_UNIX
- #define EIF_IS_UNIX EIF_FALSE
- #else
- #define EIF_IS_WINDOWS EIF_FALSE
- #endif
- /* VMS definition */
- #ifdef EIF_VMS
- #define EIF_IS_VMS EIF_TRUE
- #undef EIF_OS
- #define EIF_OS EIF_OS_VMS
- #undef EIF_IS_UNIX
- #define EIF_IS_UNIX EIF_FALSE
- #else
- #define EIF_IS_VMS EIF_FALSE
- #endif
- /* MAC definition */
- #ifdef EIF_MAC
- #define EIF_IS_MAC EIF_TRUE
- #undef EIF_OS
- #define EIF_OS EIF_OS_DARWIN
- #undef EIF_IS_UNIX
- #define EIF_IS_UNIX EIF_FALSE
- #else
- #define EIF_IS_MAC EIF_FALSE
- #endif
- /* VxWorks definition */
- #ifdef EIF_VXWORKS
- #define EIF_IS_VXWORKS EIF_TRUE
- #undef EIF_OS
- #define EIF_OS EIF_OS_VXWORKS
- #undef EIF_IS_UNIX
- #define EIF_IS_UNIX EIF_FALSE
- #else
- #define EIF_IS_VXWORKS EIF_FALSE
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef _MSC_VER /* MSVC */
- typedef signed char int8_t;
- typedef signed short int16_t;
- typedef signed int int32_t;
- typedef signed __int64 int64_t;
- typedef unsigned char uint8_t;
- typedef unsigned short uint16_t;
- typedef unsigned int uint32_t;
- typedef unsigned __int64 uint64_t;
- #else
- #if defined (__BORLANDC__) && (__BORLANDC__ < 0x600) /* Borland before 6.0 */
- typedef signed char int8_t;
- typedef signed short int16_t;
- typedef signed long int int32_t;
- typedef signed __int64 int64_t;
- typedef unsigned char uint8_t;
- typedef unsigned short uint16_t;
- typedef unsigned long int uint32_t;
- typedef unsigned __int64 uint64_t;
- #else
- #include <inttypes.h>
- #endif
- #endif
- /* Portable integer pointers */
- #ifdef EIF_WINDOWS
- #ifndef _INTPTR_T_DEFINED
- #define _INTPTR_T_DEFINED
- #ifdef _WIN64
- typedef __int64 intptr_t;
- #else
- typedef int intptr_t;
- #endif
- #endif
- #ifndef _UINTPTR_T_DEFINED
- #define _UINTPTR_T_DEFINED
- #ifdef _WIN64
- typedef unsigned __int64 uintptr_t;
- #else
- typedef unsigned int uintptr_t;
- #endif
- #endif
- #endif
- /* C type for underlying integer type identifying object's dynamic type. */
- typedef uint16_t EIF_TYPE_INDEX;
- /*
- * Abstraction representing an Eiffel type.
- * It is made of a compiler type-id,
- * and of some annotations (attached/detachable/separate/variant/frozen).
- */
- typedef struct eif_type {
- EIF_TYPE_INDEX id;
- EIF_TYPE_INDEX annotations;
- } EIF_TYPE;
- /*
- * Since EIF_TYPE and EIF_ENCODED_TYPE have the same size, the encoded version
- * is basically a memcpy version of the EIF_TYPE representation.
- * It is used to provide backward compatibility to most Eiffel and
- * C APIs manipulating types as an INTEGER.
- */
- typedef int32_t EIF_ENCODED_TYPE;
- typedef EIF_ENCODED_TYPE EIF_TYPE_ID;
- #define EIF_NO_TYPE (EIF_TYPE_ID)(-1)
- /* Basic Eiffel types */
- typedef char EIF_BOOLEAN;
- typedef unsigned char EIF_CHARACTER_8;
- typedef uint32_t EIF_CHARACTER_32;
- typedef int8_t EIF_INTEGER_8;
- typedef int16_t EIF_INTEGER_16;
- typedef int32_t EIF_INTEGER_32;
- typedef int64_t EIF_INTEGER_64;
- typedef uint8_t EIF_NATURAL_8;
- typedef uint16_t EIF_NATURAL_16;
- typedef uint32_t EIF_NATURAL_32;
- typedef uint64_t EIF_NATURAL_64;
- typedef void* EIF_POINTER;
- typedef float EIF_REAL_32;
- typedef double EIF_REAL_64;
- typedef struct {EIF_TYPE_INDEX id; uint16_t flags;} EIF_ANY;
- typedef EIF_ANY* EIF_REFERENCE;
- typedef struct {EIF_TYPE_INDEX id; uint16_t flags; EIF_REFERENCE area; EIF_INTEGER count;} EIF_STRING;
- typedef struct {EIF_TYPE_INDEX id; uint16_t flags; uint32_t offset; EIF_INTEGER count; EIF_INTEGER capacity;} EIF_SPECIAL;
- #ifdef EIF_WINDOWS
- typedef wchar_t EIF_NATIVE_CHAR;
- #else
- typedef char EIF_NATIVE_CHAR;
- #endif
- typedef EIF_NATIVE_CHAR* EIF_FILENAME;
- #define EIF_VOID ((EIF_REFERENCE)0)
- #define EIF_FALSE ((EIF_BOOLEAN)'\0')
- #define EIF_TRUE ((EIF_BOOLEAN)'\1')
- #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
- #define EIF_IS_WORKBENCH EIF_FALSE
- #define EIF_POINTER_DISPLAY "lX"
- /* For INTEGER and NATURAL manifest constants */
- #define GE_int8(x) x
- #define GE_nat8(x) x
- #define GE_int16(x) x
- #define GE_nat16(x) x
- #define GE_int32(x) x##L
- #define GE_nat32(x) x##U
- #if defined (_MSC_VER) && (_MSC_VER < 1400) /* MSC older than v8 */
- #define GE_int64(x) x##i64
- #define GE_nat64(x) x##ui64
- #elif defined(__BORLANDC__) && (__BORLANDC__ < 0x600) /* Borland before 6.0 */
- #define GE_int64(x) x##i64
- #define GE_nat64(x) x##ui64
- #else /* ISO C 99 */
- #define GE_int64(x) x##LL
- #define GE_nat64(x) x##ULL
- #endif
- #ifdef __LCC__
- /* lcc-win32 reports a constant overflow for -21474836478. */
- #define GE_min_int32 (-GE_int32(2147483647)-GE_int32(1))
- #else
- #define GE_min_int32 GE_int32(-2147483648)
- #endif
- #define GE_max_int32 GE_int32(2147483647)
- #if defined(__LCC__) || defined(__GNUC__) || defined(__MINGW32__)
- /* lcc-win32 reports a constant overflow for -9223372036854775808. */
- /* gcc and mingw-win64 warn that integer constant is so large that it is unsigned. */
- #define GE_min_int64 (-GE_int64(9223372036854775807)-GE_int64(1))
- #else
- #define GE_min_int64 GE_int64(-9223372036854775808)
- #endif
- #if defined(__LCC__) && !defined(_WIN64)
- /* lcc-win32 does not consider 64 bit constants as constants in case statement. */
- #define GE_case_int64(x) ((int32_t)(x))
- #define GE_case_nat64(x) ((uint32_t)(x))
- #else
- #define GE_case_int64(x) (x)
- #define GE_case_nat64(x) (x)
- #endif
- #ifdef _WIN64
- #define GE_IS_64_BITS EIF_TRUE
- #else
- #define GE_IS_64_BITS EIF_TEST(sizeof(void*)==64)
- #endif
- /* Posix threads */
- #if !defined(EIF_WINDOWS)
- #define GE_USE_POSIX_THREADS
- #endif
- #ifdef _MSC_VER /* MSVC */
- /* MSVC does not support ISO C 99's 'snprintf' from stdio.h */
- #define snprintf(a,b,c,d) sprintf(a,c,d)
- #endif
- /*
- * Gobo compiler version.
- * Starts with 6080 (looks like GOBO) followed by 5 digits.
- */
- #define GE_compiler_version() 608000001
- /*
- Interoperability with ISE.
- */
- #define RTI64C(x) GE_int64(x)
- #define EIF_OBJECT EIF_REFERENCE
- #define EIF_OBJ EIF_OBJECT
- #define OVERHEAD sizeof(EIF_ANY)
- /* Function pointer call to make sure all arguments are correctly pushed onto stack. */
- /* FUNCTION_CAST is for standard C calls. */
- /* FUNCTION_CAST_TYPE is for non-standard C calls. */
- #define FUNCTION_CAST(r_type,arg_types) (r_type (*) arg_types)
- #define FUNCTION_CAST_TYPE(r_type,call_type,arg_types) (r_type (call_type *) arg_types)
- #define SIGBLOCK
- #define SIGRESUME
- #define rt_public /* default C scope */
- #define rt_private static /* static outside a block means private */
- #define rt_shared /* data shared between modules, but not public */
- typedef intptr_t rt_int_ptr;
- typedef uintptr_t rt_uint_ptr;
- #define RTMS(s) GE_str8(s)
- #define RTMS_EX(s,c) GE_ms8((s),(c))
- #ifdef __cplusplus
- }
- #endif
- #endif
- /*
- description:
- "C types used to implement class THREAD and related threading facilities"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2017, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_THREAD_TYPES_H
- #define GE_THREAD_TYPES_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifdef GE_USE_THREADS
- #define EIF_THREADS
- #ifdef GE_USE_POSIX_THREADS
- #define EIF_POSIX_THREADS
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifdef GE_USE_POSIX_THREADS
- #include <pthread.h>
- #include <semaphore.h>
- #elif defined EIF_WINDOWS
- #include <windows.h>
- #include <process.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef GE_USE_POSIX_THREADS
- #define EIF_THR_TYPE pthread_t
- #define EIF_CS_TYPE pthread_mutex_t
- #define EIF_MUTEX_TYPE pthread_mutex_t
- #define EIF_COND_TYPE pthread_cond_t
- #define EIF_SEM_TYPE sem_t
- #define EIF_RWL_TYPE pthread_rwlock_t
- #elif defined EIF_WINDOWS
- #define EIF_THR_TYPE HANDLE
- #define EIF_CS_TYPE CRITICAL_SECTION
- #define EIF_MUTEX_TYPE CRITICAL_SECTION
- #define EIF_SEM_TYPE HANDLE
- typedef struct {
- /* Semaphore used to queue up threads waiting for the condition to become signaled. */
- EIF_SEM_TYPE* semaphore;
- /* Serialize access to fields of Current. */
- EIF_CS_TYPE* csection;
- /* Number of waiters. */
- unsigned long num_waiting;
- /* Number of already awoken. */
- unsigned long num_wake;
- /* Number of time we signaled/broadcasted for improving fairness.
- * This ensures one thread won't steal wakeups from other threads in queue. */
- unsigned long generation;
- } EIF_COND_TYPE;
- typedef struct {
- EIF_MUTEX_TYPE* m; /* Internal monitor lock. */
- int rwlock; /* >0 = # readers, <0 = writer, 0 = none */
- EIF_COND_TYPE* readers_ok; /* Start waiting readers. */
- unsigned int waiting_writers; /* Number of waiting writers. */
- EIF_COND_TYPE* writers_ok; /* Start a waiting writer. */
- } EIF_RWL_TYPE;
- #endif
- typedef struct {
- unsigned int priority;
- unsigned int stack_size;
- } EIF_THR_ATTR_TYPE;
- /* Struct for thread context. */
- typedef struct GE_thread_context_struct GE_thread_context;
- struct GE_thread_context_struct {
- EIF_THR_TYPE thread_id; /* Thread identifier for associated thread. */
- EIF_REFERENCE current; /* Eiffel root object. */
- void (*routine)(EIF_REFERENCE); /* Eiffel routine. */
- void (*set_terminated)(EIF_REFERENCE,EIF_BOOLEAN); /* Eiffel routine to set {THREAD}.terminated. */
- unsigned int initial_priority; /* Initial priority. */
- EIF_THR_TYPE last_thread_id; /* Last thread created from current thread. */
- volatile int n_children; /* Number of direct thread children. */
- EIF_MUTEX_TYPE* children_mutex; /* Mutex to wait for thread children. */
- EIF_COND_TYPE* children_cond; /* Condition variable to wait for thread children. */
- GE_thread_context* parent_context; /* Context of parent thread, NULL if main thread. */
- int thread_exiting; /* Has current thread already called GE_thread_exit? */
- volatile int is_alive; /* Is Current thread still alive? */
- };
- #ifdef __cplusplus
- }
- #endif
- #endif
- #endif
- /*
- description:
- "C functions used to implement once features"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2017, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_ONCE_H
- #define GE_ONCE_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*
- * Struct to keep track of the call status
- * and results of once features.
- */
- typedef struct {
- EIF_BOOLEAN* boolean_value;
- EIF_REFERENCE* boolean_exception;
- unsigned char* boolean_status;
- unsigned int boolean_count;
- EIF_CHARACTER_8* character_8_value;
- EIF_REFERENCE* character_8_exception;
- unsigned char* character_8_status;
- unsigned int character_8_count;
- EIF_CHARACTER_32* character_32_value;
- EIF_REFERENCE* character_32_exception;
- unsigned char* character_32_status;
- unsigned int character_32_count;
- EIF_INTEGER_8* integer_8_value;
- EIF_REFERENCE* integer_8_exception;
- unsigned char* integer_8_status;
- unsigned int integer_8_count;
- EIF_INTEGER_16* integer_16_value;
- EIF_REFERENCE* integer_16_exception;
- unsigned char* integer_16_status;
- unsigned int integer_16_count;
- EIF_INTEGER_32* integer_32_value;
- EIF_REFERENCE* integer_32_exception;
- unsigned char* integer_32_status;
- unsigned int integer_32_count;
- EIF_INTEGER_64* integer_64_value;
- EIF_REFERENCE* integer_64_exception;
- unsigned char* integer_64_status;
- unsigned int integer_64_count;
- EIF_NATURAL_8* natural_8_value;
- EIF_REFERENCE* natural_8_exception;
- unsigned char* natural_8_status;
- unsigned int natural_8_count;
- EIF_NATURAL_16* natural_16_value;
- EIF_REFERENCE* natural_16_exception;
- unsigned char* natural_16_status;
- unsigned int natural_16_count;
- EIF_NATURAL_32* natural_32_value;
- EIF_REFERENCE* natural_32_exception;
- unsigned char* natural_32_status;
- unsigned int natural_32_count;
- EIF_NATURAL_64* natural_64_value;
- EIF_REFERENCE* natural_64_exception;
- unsigned char* natural_64_status;
- unsigned int natural_64_count;
- EIF_POINTER* pointer_value;
- EIF_REFERENCE* pointer_exception;
- unsigned char* pointer_status;
- unsigned int pointer_count;
- EIF_REAL_32* real_32_value;
- EIF_REFERENCE* real_32_exception;
- unsigned char* real_32_status;
- unsigned int real_32_count;
- EIF_REAL_64* real_64_value;
- EIF_REFERENCE* real_64_exception;
- unsigned char* real_64_status;
- unsigned int real_64_count;
- EIF_REFERENCE* reference_value;
- EIF_REFERENCE* reference_exception;
- unsigned char* reference_status;
- unsigned int reference_count;
- EIF_REFERENCE* procedure_exception;
- unsigned char* procedure_status;
- unsigned int procedure_count;
- } GE_onces;
- /*
- * Variable to keep track of the call status
- * and results of once-per-process features.
- */
- extern GE_onces* GE_process_onces;
- /*
- * Initialize `GE_process_onces'.
- */
- extern void GE_init_onces(
- unsigned int a_boolean_count,
- unsigned int a_character_8_count,
- unsigned int a_character_32_count,
- unsigned int a_integer_8_count,
- unsigned int a_integer_16_count,
- unsigned int a_integer_32_count,
- unsigned int a_integer_64_count,
- unsigned int a_natural_8_count,
- unsigned int a_natural_16_count,
- unsigned int a_natural_32_count,
- unsigned int a_natural_64_count,
- unsigned int a_pointer_count,
- unsigned int a_real_32_count,
- unsigned int a_real_64_count,
- unsigned int a_reference_count,
- unsigned int a_procedure_count);
- /*
- * Create a new 'GE_onces' struct which can deal with the
- * numbers of once features passed as argument.
- */
- extern GE_onces* GE_new_onces(
- unsigned int a_boolean_count,
- unsigned int a_character_8_count,
- unsigned int a_character_32_count,
- unsigned int a_integer_8_count,
- unsigned int a_integer_16_count,
- unsigned int a_integer_32_count,
- unsigned int a_integer_64_count,
- unsigned int a_natural_8_count,
- unsigned int a_natural_16_count,
- unsigned int a_natural_32_count,
- unsigned int a_natural_64_count,
- unsigned int a_pointer_count,
- unsigned int a_real_32_count,
- unsigned int a_real_64_count,
- unsigned int a_reference_count,
- unsigned int a_procedure_count);
- /*
- * Free memory allocated by `a_onces'.
- */
- extern void GE_free_onces(GE_onces* a_onces);
- #ifdef __cplusplus
- }
- #endif
- #endif
- /*
- description:
- "C functions used to implement class EXCEPTION"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2007-2018, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_EXCEPTION_H
- #define GE_EXCEPTION_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifndef GE_ONCE_H
- #include "ge_once.h"
- #endif
- #ifdef GE_USE_THREADS
- #ifndef GE_THREAD_TYPES_H
- #include "ge_thread_types.h"
- #endif
- #endif
- #include <setjmp.h>
- /*
- * On Linux glibc systems, we need to use sig* versions of jmp_buf,
- * setjmp and longjmp to preserve the signal handling context.
- * One way to detect this is if _SIGSET_H_types has
- * been defined in /usr/include/setjmp.h.
- * NOTE: ANSI only recognizes the non-sig versions.
- */
- #if (defined(_SIGSET_H_types) && !defined(__STRICT_ANSI__))
- #define GE_jmp_buf sigjmp_buf
- #define GE_setjmp(x) sigsetjmp((x),1)
- #define GE_longjmp(x,y) siglongjmp((x),(y))
- #else
- #define GE_jmp_buf jmp_buf
- #define GE_setjmp(x) setjmp((x))
- #define GE_longjmp(x,y) longjmp((x),(y))
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*
- * Predefined exception codes.
- */
- #define GE_EX_VOID 1 /* Feature applied to void reference */
- #define GE_EX_MEM 2 /* No more memory */
- #define GE_EX_PRE 3 /* Pre-condition violated */
- #define GE_EX_POST 4 /* Post-condition violated */
- #define GE_EX_FLOAT 5 /* Floating point exception (signal SIGFPE) */
- #define GE_EX_CINV 6 /* Class invariant violated */
- #define GE_EX_CHECK 7 /* Check instruction violated */
- #define GE_EX_FAIL 8 /* Routine failure */
- #define GE_EX_WHEN 9 /* Unmatched inspect value */
- #define GE_EX_VAR 10 /* Non-decreasing loop variant */
- #define GE_EX_LINV 11 /* Loop invariant violated */
- #define GE_EX_SIG 12 /* Operating system signal */
- #define GE_EX_BYE 13 /* Eiffel run-time panic */
- #define GE_EX_RESC 14 /* Exception in rescue clause */
- #define GE_EX_OMEM 15 /* Out of memory (cannot be ignored) */
- #define GE_EX_RES 16 /* Resumption failed (retry did not succeed) */
- #define GE_EX_CDEF 17 /* Create on deferred */
- #define GE_EX_EXT 18 /* External event */
- #define GE_EX_VEXP 19 /* Void assigned to expanded */
- #define GE_EX_HDLR 20 /* Exception in signal handler */
- #define GE_EX_IO 21 /* I/O error */
- #define GE_EX_SYS 22 /* Operating system error */
- #define GE_EX_RETR 23 /* Retrieval error */
- #define GE_EX_PROG 24 /* Developer exception */
- #define GE_EX_FATAL 25 /* Eiffel run-time fatal error */
- #define GE_EX_DOL 26 /* $ applied to melted feature */
- #define GE_EX_ISE_IO 27 /* I/O error raised by the ISE Eiffel runtime */
- #define GE_EX_COM 28 /* COM error raised by EiffelCOM runtime */
- #define GE_EX_RT_CHECK 29 /* Runtime check error such as out-of-bound array access */
- #define GE_EX_OLD 30 /* Old violation */
- #define GE_EX_SEL 31 /* Serialization failure */
- #define GE_EX_DIRTY 32 /* SCOOP processor dirty exception. */
- #define GE_EX_NEX 32 /* Number of internal exceptions */
- /*
- * String buffer used to build the exception trace.
- */
- typedef struct GE_exception_trace_buffer_struct GE_exception_trace_buffer;
- struct GE_exception_trace_buffer_struct {
- char* area;
- uint32_t count;
- uint32_t capacity;
- };
- /*
- * Information about the feature being executed.
- */
- typedef struct GE_call_struct GE_call;
- struct GE_call_struct {
- #ifdef GE_USE_CURRENT_IN_EXCEPTION_TRACE
- void* object; /* Current object */
- #endif
- const char* class_name;
- const char* feature_name;
- GE_call* caller; /* previous feature in the call chain */
- };
- /*
- * Context of features containing a rescue clause.
- */
- typedef struct GE_rescue_struct GE_rescue;
- struct GE_rescue_struct {
- GE_jmp_buf jb;
- GE_rescue* previous; /* previous context in the call chain */
- };
- /*
- * Information about the execution context.
- * One such struct per thread.
- */
- typedef struct GE_context_struct GE_context;
- struct GE_context_struct {
- GE_call* call; /* Call stack */
- uint32_t in_assertion; /* Is an assertion evaluated? */
- GE_rescue* last_rescue; /* Context of last feature entered containing a rescue clause */
- uint32_t in_rescue; /* Number of rescue clauses currently being executed */
- EIF_REFERENCE exception_manager; /* Exception manager */
- char raising_exception; /* Is an exception currently being raised? */
- char exception_trace_enabled; /* Should exception trace be displayed? */
- long exception_code; /* Code of the exception currently being raised, 0 otherwise */
- const char* exception_tag; /* Tag of the exception currently being raised, NULL otherwise */
- GE_exception_trace_buffer exception_trace_buffer; /* String buffer used to build the exception trace */
- GE_exception_trace_buffer last_exception_trace; /* Last non-routine-failure exception trace */
- int pre_ecma_mapping_status; /* Do we map old names to new name? (i.e. STRING to STRING_8, INTEGER to INTEGER_32, ...). */
- #ifdef GE_USE_THREADS
- GE_thread_context* thread; /* Thread context */
- GE_onces* process_onces; /* Cache for status and results of onces-per-process */
- GE_onces* thread_onces; /* Status and results of onces-per-thread */
- void* wel_per_thread_data; /* WEL private data */
- #endif
- };
- /*
- * Default initialization for `GE_context'.
- */
- extern GE_context GE_default_context;
- /*
- * Execution context of main thread.
- */
- extern GE_context* GE_main_context;
- /*
- * Execution context of current thread.
- */
- extern GE_context* GE_current_context(void);
- /*
- * Initialization of exception handling.
- */
- extern void GE_init_exception(GE_context* context);
- /*
- * Free memory allocated in `a_context' for exception handling.
- */
- extern void GE_free_exception(GE_context* a_context);
- /*
- * Pointer to function to create a new exception manager object
- * (of type ISE_EXCEPTION_MANAGER).
- */
- extern EIF_REFERENCE (*GE_new_exception_manager)(EIF_BOOLEAN);
- /*
- * Pointer to Eiffel routine ISE_EXCEPTION_MANAGER.init_exception_manager.
- */
- extern void (*GE_init_exception_manager)(GE_context*, EIF_REFERENCE);
- /*
- * Pointer to Eiffel routine ISE_EXCEPTION_MANAGER.last_exception.
- */
- extern EIF_REFERENCE (*GE_last_exception)(GE_context*, EIF_REFERENCE);
- /*
- * Pointer to Eiffel routine ISE_EXCEPTION_MANAGER.once_raise.
- */
- extern void (*GE_once_raise)(GE_context*, EIF_REFERENCE, EIF_REFERENCE);
- /*
- * Pointer to Eiffel routine ISE_EXCEPTION_MANAGER.set_exception_data.
- */
- extern void (*GE_set_exception_data)(GE_context*, EIF_REFERENCE, EIF_INTEGER_32, EIF_BOOLEAN, EIF_INTEGER_32, EIF_INTEGER_32, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_REFERENCE, EIF_INTEGER_32, EIF_BOOLEAN);
- /*
- * Exception tag associated with `a_code'.
- */
- extern char* GE_exception_tag(long a_code);
- /*
- * Raise an exception with code `a_code'.
- */
- extern void GE_raise(long a_code);
- /*
- * Raise an exception with code `a_code' and message `msg'.
- */
- extern void GE_raise_with_message(long a_code, const char* msg);
- /*
- * Raise an exception from EXCEPTION_MANAGER.
- */
- extern void GE_developer_raise(long a_code, char* a_meaning, char* a_message);
- /*
- * Raise exception which was raised the first time a once routine
- * was executed when executing it again.
- */
- extern void GE_raise_once_exception(GE_context* a_context, EIF_REFERENCE a_exception);
- /*
- * Exception, if any, which was last raised in `a_context'.
- */
- extern EIF_REFERENCE GE_last_exception_raised(GE_context* a_context);
- /*
- * Jump to execute the rescue of the last routine with a rescue
- * in the call stack.
- */
- extern void GE_jump_to_last_rescue(GE_context* a_context);
- /*
- * Set `in_assertion' to 'not b'.
- * Return the opposite of previous value.
- */
- extern EIF_BOOLEAN GE_check_assert(EIF_BOOLEAN b);
- /*
- * Check whether the type id of `obj' is not in `type_ids'.
- * If it is, then raise a CAT-call exception. Don't do anything if `obj' is Void.
- * `nb' is the number of ids in `type_ids' and is expected to be >0.
- * `type_ids' is sorted in increasing order.
- * Return `obj'.
- */
- #define GE_catcall(obj,type_ids,nb) GE_check_catcall((obj),(type_ids),(nb))
- extern EIF_REFERENCE GE_check_catcall(EIF_REFERENCE obj, EIF_TYPE_INDEX type_ids[], int nb);
- /*
- * Check whether `obj' is Void.
- * If it is, then raise a call-on-void-target exception.
- * Return `obj'.
- */
- #define GE_void(obj) (!(obj)?GE_check_void(obj):(obj))
- extern EIF_REFERENCE GE_check_void(EIF_REFERENCE obj);
- /*
- * Check whether `ptr' is a null pointer.
- * If it is, then raise a no-more-memory exception.
- * Return `ptr'.
- */
- #define GE_null(ptr) GE_check_null(ptr)
- extern void* GE_check_null(void* ptr);
- #ifdef EIF_WINDOWS
- /*
- * Set default exception handler.
- */
- extern void GE_set_windows_exception_filter(void);
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
- /*
- description:
- "C functions used to implement class THREAD and related threading facilities"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2016-2017, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_THREAD_H
- #define GE_THREAD_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifdef GE_USE_THREADS
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifndef GE_THREAD_TYPES_H
- #include "ge_thread_types.h"
- #endif
- #ifndef GE_EXCEPTION_H
- #include "ge_exception.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef GE_USE_POSIX_THREADS
- #include <unistd.h>
- #endif
- #ifdef GE_USE_POSIX_THREADS
- # define EIF_TSD_VAL_TYPE void*
- # define EIF_TSD_TYPE pthread_key_t
- # define EIF_TSD_CREATE(key,msg) \
- if (pthread_key_create(&(key),NULL)) \
- GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_SET(key,val,msg) \
- if (pthread_setspecific((key), (EIF_TSD_VAL_TYPE)(val))) \
- GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_GET0(val_type,key,val) (val = pthread_getspecific(key))
- # define EIF_TSD_GET(val_type,key,val,msg) \
- if (EIF_TSD_GET0(val_type,key,val) == (void*) 0) GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_DESTROY(key,msg) if (pthread_key_delete(key)) GE_raise_with_message(GE_EX_EXT, msg)
- #elif defined EIF_WINDOWS
- # define EIF_TSD_VAL_TYPE LPVOID
- # define EIF_TSD_TYPE DWORD
- # define EIF_TSD_CREATE(key,msg) \
- if ((key=TlsAlloc())==TLS_OUT_OF_INDEXES) GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_SET(key,val,msg) \
- if (!TlsSetValue((key),(EIF_TSD_VAL_TYPE)(val))) GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_GET0(val_type,key,val) \
- val=(val_type) TlsGetValue(key)
- # define EIF_TSD_GET(val_type,key,val,msg) \
- EIF_TSD_GET0(val_type,key,val); \
- if (GetLastError() != NO_ERROR) GE_raise_with_message(GE_EX_EXT, msg)
- # define EIF_TSD_DESTROY(key,msg) \
- if (!TlsFree(key)) GE_raise_with_message(GE_EX_EXT, msg)
- #endif
- /* Thread priority levels. */
- #define EIF_MIN_THR_PRIORITY 0L
- #define EIF_BELOW_NORMAL_THR_PRIORITY 100L
- #define EIF_DEFAULT_THR_PRIORITY 127L
- #define EIF_ABOVE_NORMAL_THR_PRIORITY 154L
- #define EIF_MAX_THR_PRIORITY 255L
- /*
- * Mutexes used to protect the calls to once-per-process features.
- */
- typedef struct {
- EIF_POINTER* boolean_mutex;
- EIF_POINTER* character_8_mutex;
- EIF_POINTER* character_32_mutex;
- EIF_POINTER* integer_8_mutex;
- EIF_POINTER* integer_16_mutex;
- EIF_POINTER* integer_32_mutex;
- EIF_POINTER* integer_64_mutex;
- EIF_POINTER* natural_8_mutex;
- EIF_POINTER* natural_16_mutex;
- EIF_POINTER* natural_32_mutex;
- EIF_POINTER* natural_64_mutex;
- EIF_POINTER* pointer_mutex;
- EIF_POINTER* real_32_mutex;
- EIF_POINTER* real_64_mutex;
- EIF_POINTER* reference_mutex;
- EIF_POINTER* procedure_mutex;
- } GE_once_mutexes;
- /*
- * Mutexes used to protect the calls to once-per-process features.
- */
- extern GE_once_mutexes* GE_process_once_mutexes;
- /*
- * Create a new 'GE_once_mutexes' struct which can deal with the
- * numbers of once features passed as argument.
- */
- extern GE_once_mutexes* GE_new_once_mutexes(
- unsigned int a_boolean_count,
- unsigned int a_character_8_count,
- unsigned int a_character_32_count,
- unsigned int a_integer_8_count,
- unsigned int a_integer_16_count,
- unsigned int a_integer_32_count,
- unsigned int a_integer_64_count,
- unsigned int a_natural_8_count,
- unsigned int a_natural_16_count,
- unsigned int a_natural_32_count,
- unsigned int a_natural_64_count,
- unsigned int a_pointer_count,
- unsigned int a_real_32_count,
- unsigned int a_real_64_count,
- unsigned int a_reference_count,
- unsigned int a_procedure_count);
- /*
- * Keep track of the numbers of once-per-thread features.
- */
- extern void GE_thread_onces_set_counts(
- unsigned int a_boolean_count,
- unsigned int a_character_8_count,
- unsigned int a_character_32_count,
- unsigned int a_integer_8_count,
- unsigned int a_integer_16_count,
- unsigned int a_integer_32_count,
- unsigned int a_integer_64_count,
- unsigned int a_natural_8_count,
- unsigned int a_natural_16_count,
- unsigned int a_natural_32_count,
- unsigned int a_natural_64_count,
- unsigned int a_pointer_count,
- unsigned int a_real_32_count,
- unsigned int a_real_64_count,
- unsigned int a_reference_count,
- unsigned int a_procedure_count);
- /*
- * Initialize data to handle threads.
- * To be called at the beginning of the main function
- * on the main thread.
- */
- extern void GE_init_thread(GE_context* a_context);
- /*
- * Create a new thread with attributes `attr' and execute
- * Eiffel routine `routine' on object `current'.
- */
- extern void GE_thread_create_with_attr(EIF_REFERENCE current, void (*routine)(EIF_REFERENCE), void (*set_terminated)(EIF_REFERENCE,EIF_BOOLEAN), EIF_THR_ATTR_TYPE* attr);
- /*
- * Execution context of current thread.
- */
- extern GE_context* GE_thread_current_context(void);
- /*
- * Thead ID of current thread.
- */
- extern EIF_POINTER GE_thread_id(void);
- /*
- * Thread ID of last thread created from current thread.
- */
- extern EIF_POINTER GE_last_thread_created(void);
- #ifdef EIF_WINDOWS
- /*
- * Support for Windows GUI that requires that all GUI operations are performed in the same thread.
- * Allocate new structure of the given size `a_size', assign it to `wel_per_thread_data'.
- * Return newly allocated memory block. It will be freed automatically on thread termination.
- */
- extern void* GE_thread_create_wel_per_thread_data(size_t a_size);
- #endif
- /*
- * Waits until a child thread sets `terminated' from `obj' to True,
- * which means it is terminated. The calling thread must be the
- * direct parent of the thread, or the function might loop indefinitely.
- */
- extern void GE_thread_wait(EIF_REFERENCE obj, EIF_BOOLEAN (*get_terminated)(EIF_REFERENCE));
- /*
- * Waits until a child thread sets `terminated' from `obj' to True,
- * which means it is terminated, or reaching `a_timeout_ms'.
- * The calling thread must be the direct parent of the thread,
- * or the function might loop indefinitely.
- */
- extern EIF_BOOLEAN GE_thread_wait_with_timeout(EIF_REFERENCE obj, EIF_BOOLEAN (*get_terminated)(EIF_REFERENCE), EIF_NATURAL_64 a_timeout_ms);
- /*
- * Yields execution to other threads.
- */
- extern void GE_thread_yield(void);
- /*
- * The calling thread waits for all other children threads to terminate.
- */
- extern void GE_thread_join_all(void);
- /*
- * Function called to terminate a thread launched by Eiffel with `GE_thread_create_with_attr'.
- * This function must be called from the thread itself (not the parent).
- */
- extern void GE_thread_exit(void);
- /*
- * Default thread priority level.
- */
- extern EIF_INTEGER GE_thread_default_priority(void);
- /*
- * Minimum thread priority level.
- */
- extern EIF_INTEGER GE_thread_min_priority(void);
- /*
- * Maximum thread priority level.
- */
- extern EIF_INTEGER GE_thread_max_priority(void);
- /*
- * Create a new mutex.
- */
- extern EIF_POINTER GE_mutex_create(void);
- /*
- * Lock mutex.
- */
- extern void GE_mutex_lock(EIF_POINTER a_mutex);
- /*
- * Try to lock mutex. Return True on success.
- */
- extern EIF_BOOLEAN GE_mutex_try_lock(EIF_POINTER a_mutex);
- /*
- * Unlock mutex.
- */
- extern void GE_mutex_unlock(EIF_POINTER a_mutex);
- /*
- * Destroy and free all resources used by mutex.
- */
- extern void GE_mutex_destroy(EIF_POINTER a_mutex);
- /*
- * Create a new semaphore allowing `a_count' threads
- * to go into a critical section.
- */
- extern EIF_POINTER GE_semaphore_create(EIF_INTEGER a_count);
- /*
- * Decrement semaphore count, waiting if necessary
- * until that becomes possible.
- */
- extern void GE_semaphore_wait(EIF_POINTER a_semaphore);
- /*
- * Has client been successful in decrementing semaphore
- * count without waiting?
- */
- extern EIF_BOOLEAN GE_semaphore_try_wait(EIF_POINTER a_semaphore);
- /*
- * Increment semaphore count.
- */
- extern void GE_semaphore_post(EIF_POINTER a_semaphore);
- /*
- * Destroy and free all resources used by semaphore.
- */
- extern void GE_semaphore_destroy(EIF_POINTER a_semaphore);
- /*
- * Create a new condition variable.
- */
- extern EIF_POINTER GE_condition_variable_create(void);
- /*
- * Unblock all threads blocked on condition variable.
- */
- extern void GE_condition_variable_broadcast(EIF_POINTER a_condition_variable);
- /*
- * Unblock one thread blocked on condition variable.
- */
- extern void GE_condition_variable_signal(EIF_POINTER a_condition_variable);
- /*
- * Block calling thread on condition variable.
- */
- extern void GE_condition_variable_wait(EIF_POINTER a_condition_variable, EIF_POINTER a_mutex);
- /*
- * Block calling thread on condition variable for at most `a_timeout' milliseconds.
- * Return 1 is we got the condition variable on time, otherwise return 0.
- */
- extern EIF_INTEGER GE_condition_variable_wait_with_timeout(EIF_POINTER a_condition_variable, EIF_POINTER a_mutex, EIF_INTEGER a_timeout);
- /*
- * Destroy and free all resources used by condition variable.
- */
- extern void GE_condition_variable_destroy(EIF_POINTER a_condition_variable);
- /*
- * Create a new read-write lock.
- */
- extern EIF_POINTER GE_read_write_lock_create(void);
- /*
- * Acquire a read lock. Multiple readers can go if there are no writer.
- */
- extern void GE_read_write_lock_read_lock(EIF_POINTER a_read_write_lock);
- /*
- * Acquire a write lock. Only a single write can proceed.
- */
- extern void GE_read_write_lock_write_lock(EIF_POINTER a_read_write_lock);
- /*
- * Unlock a read or write lock.
- */
- extern void GE_read_write_lock_unlock(EIF_POINTER a_read_write_lock);
- /*
- * Destroy and free all resources used by read-write lock.
- */
- extern void GE_read_write_lock_destroy(EIF_POINTER a_read_write_lock);
- #ifdef __cplusplus
- }
- #endif
- #endif
- #endif
- /*
- description:
- "C functions used to manipulate native strings"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2013-2018, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_NATIVE_STRING_H
- #define GE_NATIVE_STRING_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #include <string.h>
- #ifdef EIF_WINDOWS
- #ifdef __LCC__
- /* With lcc-win32, stat.h should be included before wchar.h. */
- #include <sys/stat.h>
- #endif
- #include <wchar.h>
- #else
- #include <sys/types.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef EIF_WINDOWS
- /* Macro used to manipulate native strings, i.e: (wchar_t*) */
- #define GE_nstrlen wcslen /* size of string */
- #define GE_nstrncpy wcsncpy /* Copy n characters of one string to another */
- #define GE_nstrcpy wcscpy /* Copy one string to another */
- #define GE_nstrncat wcsncat /* Append characters of a string */
- #define GE_nstrcat wcscat /* Append a string */
- #define GE_nstrstr wcsstr /* Return a pointer to the first occurrence of a search string in a string. */
- #define GE_nmakestr(quote) L##quote /* Manifest Native string declaration */
- #define GE_nstr_fopen _wfopen /* Open file using native string name */
- #define GE_nstrcmp wcscmp /* Compare two strings. */
- #define GE_nstrdup _wcsdup /* Duplicate string. */
- #define GE_nstr_cat_ascii(dest, src) { \
- int i; \
- size_t dest_len, src_len; \
- dest_len = rt_nstrlen (dest); \
- src_len = strlen (src); \
- for (i = 0; i < src_len; i++) { \
- dest[dest_len + i] = (EIF_NATIVE_CHAR)src[i]; \
- } \
- dest[dest_len + src_len] = (EIF_NATIVE_CHAR)0; \
- }
- #else /* not EIF_WINDOWS */
- /* Macro used to manipulate native strings, i.e: (char*) */
- #define GE_nstrlen strlen /* size of string */
- #define GE_nstrncpy strncpy /* Copy n characters of one string to another */
- #define GE_nstrcpy strcpy /* Copy one string to another */
- #define GE_nstrncat strncat /* Append characters of a string */
- #define GE_nstrcat strcat /* Append a string */
- #define GE_nstrstr strstr /* Return a pointer to the first occurrence of a search string in a string. */
- #define GE_nmakestr(quote) quote /* Manifest Native string declaration */
- #define GE_nstr_fopen fopen /* Open file using native string name */
- #define GE_nstrcmp strcmp /* Compare two strings. */
- #define GE_nstrdup strdup /* Duplicate string. */
- #define GE_nstr_cat_ascii strcat
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
- /*
- description:
- "C functions used to implement class ARGUMENTS"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2007-2017, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_ARGUMENTS_H
- #define GE_ARGUMENTS_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- extern int GE_argc;
- extern EIF_NATIVE_CHAR** GE_argv;
- #ifdef __cplusplus
- }
- #endif
- #endif
- /*
- description:
- "C functions used to implement type information"
- system: "Gobo Eiffel Compiler"
- copyright: "Copyright (c) 2016-2018, Eric Bezault and others"
- license: "MIT License"
- date: "$Date$"
- revision: "$Revision$"
- */
- #ifndef GE_TYPES_H
- #define GE_TYPES_H
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- #pragma once
- #endif
- #ifndef GE_EIFFEL_H
- #include "ge_eiffel.h"
- #endif
- #ifndef GE_EXCEPTION_H
- #include "ge_exception.h"
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*
- * Type annotations.
- * When a type has no annotation, it means a detachable, non-separate, variant type.
- * In all other cases, there will be an annotation.
- */
- #define ANNOTATION_MASK 0x007F /* All possible annotations. */
- #define ATTACHED_FLAG 0x0001
- #define DETACHABLE_FLAG 0x0002 /* Only present when overriding an attached type. */
- #define SEPARATE_FLAG 0x0004
- #define VARIANT_FLAG 0x0008 /* Only present when overriding a frozen/poly type. */
- #define UNUSABLE_FLAG 0x0010 /* Reserved for backward compatibility for storables. */
- #define FROZEN_FLAG 0x0020
- #define POLY_FLAG 0x0040
- /*
- * Type flags.
- */
- #define GE_TYPE_FLAG_SPECIAL 0x0010
- #define GE_TYPE_FLAG_TUPLE 0x0020
- #define GE_TYPE_FLAG_EXPANDED 0x0040
- #define GE_TYPE_FLAG_DEFERRED 0x0080
- #define GE_TYPE_FLAG_NONE 0x0100
- #define GE_TYPE_FLAG_BASIC_MASK 0x000F /* One of "BOOLEAN", "CHARACTER_8", "CHARACTER_32", "INTEGER_8", "INTEGER_16", "INTEGER_32", "INTEGER_64", "NATURAL_8", "NATURAL_16", "NATURAL_32", "NATURAL_64", "POINTER", "REAL_32", "REAL_64" */
- #define GE_TYPE_FLAG_BOOLEAN 0x0001
- #define GE_TYPE_FLAG_CHARACTER_8 0x0002
- #define GE_TYPE_FLAG_CHARACTER_32 0x0003
- #define GE_TYPE_FLAG_INTEGER_8 0x0004
- #define GE_TYPE_FLAG_INTEGER_16 0x0005
- #define GE_TYPE_FLAG_INTEGER_32 0x0006
- #define GE_TYPE_FLAG_INTEGER_64 0x0007
- #define GE_TYPE_FLAG_NATURAL_8 0x0008
- #define GE_TYPE_FLAG_NATURAL_16 0x0009
- #define GE_TYPE_FLAG_NATURAL_32 0x000A
- #define GE_TYPE_FLAG_NATURAL_64 0x000B
- #define GE_TYPE_FLAG_POINTER 0x000C
- #define GE_TYPE_FLAG_REAL_32 0x000D
- #define GE_TYPE_FLAG_REAL_64 0x000E
- /*
- * Convention for attribute types.
- * The values are in sync with REFLECTOR_CONSTANTS.
- */
- #define GE_TYPE_KIND_INVALID -1
- #define GE_TYPE_KIND_POINTER 0
- #define GE_TYPE_KIND_REFERENCE 1
- #define GE_TYPE_KIND_CHARACTER_8 2
- #define GE_TYPE_KIND_BOOLEAN 3
- #define GE_TYPE_KIND_INTEGER_32 4
- #define GE_TYPE_KIND_REAL_32 5
- #define GE_TYPE_KIND_REAL_64 6
- #define GE_TYPE_KIND_EXPANDED 7
- #define GE_TYPE_KIND_INTEGER_8 9
- #define GE_TYPE_KIND_INTEGER_16 10
- #define GE_TYPE_KIND_INTEGER_64 11
- #define GE_TYPE_KIND_CHARACTER_32 12
- #define GE_TYPE_KIND_NATURAL_8 13
- #define GE_TYPE_KIND_NATURAL_16 14
- #define GE_TYPE_KIND_NATURAL_32 15
- #define GE_TYPE_KIND_NATURAL_64 16
- /*
- * Object flags.
- */
- #define GE_OBJECT_FLAG_MARKED 0x0001
- /*
- * Ancestor relationship between two types X and Y.
- */
- #ifdef GE_USE_ANCESTORS
- typedef struct {
- EIF_TYPE_INDEX type_id; /* Type id of Y */
- EIF_BOOLEAN conforms; /* Does X conform to Y? */
- void (**qualified_calls)(); /* Function pointers, indexed by call id, when the static type of the target is Y and the dynamic type is X */
- } GE_ancestor;
- #endif
- /*
- * Attribute.
- */
- #ifdef GE_USE_ATTRIBUTES
- typedef struct {
- #ifdef GE_USE_ATTRIBUTE_NAME
- const char* name; /* Attribute name */
- #endif
- #ifdef GE_USE_ATTRIBUTE_TYPE_ID
- EIF_ENCODED_TYPE type_id; /* Static type id */
- #endif
- #ifdef GE_USE_ATTRIBUTE_OFFSET
- uint32_t offset; /* Address offset in object */
- #endif
- } GE_attribute;
- #endif
- /*
- * Type information.
- */
- typedef struct {
- EIF_TYPE_INDEX type_id;
- uint16_t flags;
- #ifdef GE_USE_TYPE_GENERATOR
- const char* generator; /* Generator class name */
- #endif
- #ifdef GE_USE_TYPE_NAME
- const char* name; /* Full type name */
- #endif
- #ifdef GE_USE_TYPE_GENERIC_PARAMETERS
- EIF_ENCODED_TYPE* generic_parameters;
- uint32_t generic_parameter_count;
- #endif
- #ifdef GE_USE_ANCESTORS
- GE_ancestor** ancestors;
- uint32_t ancestor_count;
- #endif
- #ifdef GE_USE_ATTRIBUTES
- GE_attribute** attributes;
- uint32_t attribute_count;
- #endif
- #ifdef GE_USE_TYPE_OBJECT_SIZE
- uint64_t object_size;
- #endif
- EIF_REFERENCE (*new_instance)();
- void (*dispose)(GE_context*, EIF_REFERENCE);
- } GE_type_info;
- typedef struct {
- EIF_TYPE_INDEX id; /* Type id of the "TYPE [X]" object */
- EIF_INTEGER type_id; /* Type id of the type "X" */
- EIF_BOOLEAN is_special;
- void (*dispose)(GE_context*, EIF_REFERENCE);
- EIF_REFERENCE a1; /* internal_name */
- EIF_REFERENCE a2; /* internal_name_32 */
- } EIF_TYPE_OBJ;
- /*
- * Types indexed by type id.
- * Generated by the compiler.
- */
- extern EIF_TYPE_OBJ GE_types[][2];
- extern GE_type_info GE_type_infos[];
- /*
- * Number of type infos in `GE_type_infos'.
- * Do not take into account the fake item at index 0.
- */
- extern int GE_type_info_count;
- /*
- * Encode a EIF_TYPE into a EIF_ENCODED_TYPE.
- * The lower part of EIF_ENCODED_TYPE contains the .id field,
- * and the upper part the .annotations.
- */
- extern EIF_ENCODED_TYPE GE_encoded_type(EIF_TYPE a_type);
- /*
- * Decode a EIF_ENCODED_TYPE into a EIF_TYPE.
- * The lower part of EIF_ENCODED_TYPE contains the .id field,
- * and the upper part the .annotations.
- */
- extern EIF_TYPE GE_decoded_type(EIF_ENCODED_TYPE a_type);
- /*
- * Type with `a_id' and `a_annotations'.
- */
- extern EIF_TYPE GE_new_type(EIF_TYPE_INDEX a_id, EIF_TYPE_INDEX a_annotations);
- /*
- * Type of object `obj'.
- */
- #define GE_object_type(obj) GE_new_type(((EIF_REFERENCE)(obj))->id, 0x0)
- #define GE_object_encoded_type(obj) GE_encoded_type(GE_object_type(obj))
- /*
- * Attachment status of `a_type'.
- */
- #define GE_is_attached_type(a_type) EIF_TEST(((a_type).annotations & ATTACHED_FLAG) || GE_is_expanded_type_index((a_type).id))
- #define GE_is_attached_encoded_type(a_type) GE_is_attached_type(GE_decoded_type(a_type))
- /*
- * Associated detachable type of `a_type' if any,
- * otherwise `a_type'.
- */
- extern EIF_TYPE GE_non_attached_type(EIF_TYPE a_type);
- #define GE_non_attached_encoded_type(a_type) GE_encoded_type(GE_non_attached_type(GE_decoded_type(a_type)))
- /*
- * Associated attached type of `a_type' if any,
- * otherwise `a_type'.
- */
- extern EIF_TYPE GE_attached_type(EIF_TYPE a_type);
- #define GE_attached_encoded_type(t) GE_encoded_type(GE_attached_type(GE_decoded_type(t)))
- /*
- * Is `a_type' a SPECIAL type?
- */
- #define GE_is_special_type_index(a_type) EIF_TEST(GE_type_infos[a_type].flags & GE_TYPE_FLAG_SPECIAL)
- #define GE_is_special_encoded_type(a_type) GE_is_special_type_index(GE_decoded_type(a_type).id)
- #define GE_is_special_object(obj) GE_is_special_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' a SPECIAL type of user-defined expanded type?
- */
- extern EIF_BOOLEAN GE_is_special_of_expanded_type_index(EIF_TYPE_INDEX a_type);
- #define GE_is_special_of_expanded_encoded_type(a_type) GE_is_special_of_expanded_type_index(GE_decoded_type(a_type).id)
- #define GE_is_special_of_expanded_object(obj) GE_is_special_of_expanded_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' a SPECIAL type of reference type?
- */
- extern EIF_BOOLEAN GE_is_special_of_reference_type_index(EIF_TYPE_INDEX a_type);
- #define GE_is_special_of_reference_encoded_type(a_type) GE_is_special_of_reference_type_index(GE_decoded_type(a_type).id)
- #define GE_is_special_of_reference_object(obj) GE_is_special_of_reference_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' a SPECIAL type of reference type or basic expanded type?
- * (Note that user-defined expanded types are excluded.)
- */
- extern EIF_BOOLEAN GE_is_special_of_reference_or_basic_expanded_type_index(EIF_TYPE_INDEX a_type);
- #define GE_is_special_of_reference_or_basic_expanded_encoded_type(a_type) GE_is_special_of_reference_or_basic_expanded_type_index(GE_decoded_type(a_type).id)
- #define GE_is_special_of_reference_or_basic_expanded_object(obj) GE_is_special_of_reference_or_basic_expanded_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' a TUPLE type?
- */
- #define GE_is_tuple_type_index(a_type) EIF_TEST(GE_type_infos[a_type].flags & GE_TYPE_FLAG_TUPLE)
- #define GE_is_tuple_encoded_type(a_type) GE_is_tuple_type_index(GE_decoded_type(a_type).id)
- #define GE_is_tuple_object(obj) GE_is_tuple_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' an expanded type?
- */
- #define GE_is_expanded_type_index(a_type) EIF_TEST(GE_type_infos[a_type].flags & GE_TYPE_FLAG_EXPANDED)
- #define GE_is_expanded_encoded_type(a_type) GE_is_expanded_type_index(GE_decoded_type(a_type).id)
- #define GE_is_expanded_object(obj) GE_is_expanded_type_index(((EIF_REFERENCE)(obj))->id)
- /*
- * Is `a_type' a type whose base class is deferred?
- */
- #define GE_is_deferred_type_index(a_type) EIF_TEST(GE_type_infos[a_type].flags & GE_TYPE_FLAG_DEFERRED)
- #define GE_is_deferred_encoded_type(a_type) GE_is_deferred_type_index(GE_decoded_type(a_type).id)
- /*
- * Does `i'-th field of `a_object + a_physical_offset' (which is expected to be reference)
- * denote a reference with copy semantics?
- */
- extern EIF_BOOLEAN GE_is_copy_semantics_field(EIF_INTEGER i, EIF_POINTER a_object, EIF_INTEGER a_physical_offset);
- /*
- * Does `i'-th item of special `a_object' (which is expected to be reference)
- * denote a reference with copy semantics?
- */
- extern EIF_BOOLEAN GE_is_special_copy_semantics_item(EIF_INTEGER i, EIF_POINTER a_object);
- /*
- * Generator class name of `a_type'.
- */
- extern EIF_REFERENCE GE_generator_of_type_index(EIF_TYPE_INDEX a_type);
- #define GE_generator_of_encoded_type(a_type) GE_generator_of_type_index(GE_decoded_type(a_type).id)
- extern EIF_REFERENCE GE_generator_8_of_type_index(EIF_TYPE_INDEX a_type);
- #define GE_generator_8_of_encoded_type(a_type) GE_generator_8_of_type_index(GE_decoded_type(a_type).id)
- /*
- * Full name of `a_type'.
- */
- extern EIF_REFERENCE GE_generating_type_of_encoded_type(EIF_ENCODED_TYPE a_type);
- extern EIF_REFERENCE GE_generating_type_8_of_encoded_type(EIF_ENCODED_TYPE a_type);
- /*
- * Encoded type whose name is `a_name'.
- * -1 if no such type.
- */
- extern EIF_ENCODED_TYPE GE_encoded_type_from_name(EIF_POINTER a_name);
- /*
- * Does `a_type_1' conform to `a_type_2'?
- */
- extern EIF_BOOLEAN GE_encoded_type_conforms_to(EIF_ENCODED_TYPE a_type_1, EIF_ENCODED_TYPE a_type_2);
- /*
- * Number of generic parameters.
- */
- extern EIF_INTEGER GE_generic_parameter_count_of_type_index(EIF_TYPE_INDEX a_type);
- #define GE_generic_parameter_count_of_encoded_type(a_type) GE_generic_parameter_count_of_type_index(GE_decoded_type(a_type).id)
- /*
- * Type of `i'-th generic parameter of `a_type'.
- */
- extern EIF_INTEGER GE_generic_parameter_of_type_index(EIF_TYPE_INDEX a_type, EIF_INTEGER i);
- #define GE_generic_parameter_of_encoded_type(a_type,i) GE_generic_parameter_of_type_index(GE_decoded_type(a_type).id, (i))
- /*
- * Number of fields of an object of dynamic type `a_type'.
- */
- extern EIF_INTEGER GE_field_count_of_type_index(EIF_TYPE_INDEX a_type);
- #define GE_field_count_of_encoded_type(a_type) GE_field_count_of_type_index(GE_decoded_type(a_type).id)
- /*
- * Physical offset of the `i'-th field for an object of dynamic type `a_type'.
- */
- extern EIF_INTEGER GE_field_offset_of_type_index(EIF_INTEGER i, EIF_TYPE_INDEX a_type);
- #define GE_field_offset_of_encoded_type(i, a_type) GE_field_offset_of_type_index((i), GE_decoded_type(a_type).id)
- /*
- * Name of the `i'-th field for an object of dynamic type `a_type'.
- */
- extern EIF_POINTER GE_field_name_of_type_index(EIF_INTEGER i, EIF_TYPE_INDEX a_type);
- #define GE_field_name_of_encoded_type(i, a_type) GE_field_name_of_type_index((i), GE_decoded_type(a_type).id)
- /*
- * Static type of the `i'-th field for an object of dynamic type `a_type'.
- */
- extern EIF_INTEGER GE_field_static_type_of_type_index(EIF_INTEGER i, EIF_TYPE_INDEX a_type);
- #define GE_field_static_type_of_encoded_type(i, a_type) GE_field_static_type_of_type_index((i), GE_decoded_type(a_type).id)
- /*
- * Kind of type of the `i'-th field for an object of dynamic type `a_type'.
- */
- extern EIF_INTEGER GE_field_type_kind_of_type_index(EIF_INTEGER i, EIF_TYPE_INDEX a_type);
- #define GE_field_type_kind_of_encoded_type(i, a_type) GE_field_type_kind_of_type_index((i), GE_decoded_type(a_type).id)
- /*
- * Physical size of `a_object'.
- */
- extern EIF_NATURAL_64 GE_object_size(EIF_POINTER a_object);
- /*
- * Is `i'-th field of objects of type `a_type' a user-defined expanded attribute?
- */
- extern EIF_BOOLEAN GE_is_field_expanded_of_type_index(EIF_INTEGER i, EIF_TYPE_INDEX a_type);
- #define GE_is_field_expanded_of_encoded_type(i, a_type) GE_is_field_expanded_of_type_index((i), GE_decoded_type(a_type).id)
- #define GE_field_address_at(a_field_offset, a_object, a_physical_offset) ((char*)(a_object) + (a_physical_offset) + (a_field_offset))
- #define GE_object_at_offset(a_enclosing, a_physical_offset) (EIF_REFERENCE)(GE_field_address_at(0,…
Large files files are truncated, but you can click here to view the full file