1 2 /* 3 * COPYRIGHT NOTICE: This file contains original source code from the 4 * Jenarix (TM) Library, Copyright (C) 2007-8 by Warren L. Delano of 5 * DeLano Scientific LLC, Palo Alto, California, United States. 6 * Please see the accompanying LICENSE file for further information. 7 * All rights not explicitly granted in that LICENSE file are 8 * reserved. It is unlawful to modify or remove this notice. 9 * TRADEMARK NOTICE: Jenarix is a Trademark of DeLano Scientific LLC. 10 */ 11 #ifndef _H_ov_types 12 #define _H_ov_types 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 #ifdef _PYMOL_MINGW 19 #include <windows.h> 20 #endif 21 22 /* automatically detect 64-bit machines */ 23 24 #ifndef OV_32_BIT 25 #if (((size_t)-1) != 0xFFFFFFFF) 26 #ifndef OV_64_BIT 27 #define OV_64_BIT 28 #endif 29 #endif 30 #endif 31 32 /* Jenarix native structs */ 33 34 typedef struct ov__object ov_object; 35 typedef struct ov__gc_head ov_gc_head; 36 typedef struct ov__cell ov_cell; 37 typedef struct ov__block ov_block; 38 typedef struct ov__opaque_head ov_opaque_head; 39 typedef struct ov__triplet ov_triplet; 40 typedef struct ov__node ov_node; 41 42 /* Jenarix prototypes for native functions and object dispatch 43 * NOTE: parameter "void" below is a workaround -- you must cast as 44 * appropriate to enable parameter type checking */ 45 46 typedef ov_object(*ov__fn) (void); 47 typedef ov_object(*ov__dispatch_fn) (void); 48 49 /* owned primitive types */ 50 51 typedef char ov_char8; 52 typedef unsigned char ov_uchar8; 53 typedef char ov_int8; 54 typedef unsigned char ov_uint8; 55 typedef short int ov_int16; 56 typedef unsigned short int ov_uint16; 57 typedef int ov_int32; 58 typedef unsigned int ov_uint32; 59 typedef float ov_float32; 60 typedef double ov_float64; 61 #ifdef WIN32 62 typedef __int64 ov_int64; 63 typedef unsigned __int64 ov_uint64; 64 #else 65 typedef long long ov_int64; 66 typedef unsigned long long ov_uint64; 67 #endif 68 typedef size_t ov_size; 69 typedef ptrdiff_t ov_diff; 70 71 #ifdef OV_64_BIT 72 73 /* 64 bit mode: Jenarix objects are 96 bits wide and can hold a 74 double-precision floating point number without owning any 75 external resources */ 76 77 typedef ov_float64 ov_float; 78 79 #define OV_FLOAT_ZERO 0.0 80 #define OV_UWORD_MAX 0xFFFFFFFFFFFFFFFF 81 82 #else 83 84 /* 32 bit mode: Jenarix objects are 64 bits wide and can only hold a 85 single-precision floating point number */ 86 87 typedef ov_float32 ov_float; 88 89 #define OV_FLOAT_ZERO 0.0F 90 #define OV_UWORD_MAX 0xFFFFFFFF 91 92 #endif 93 94 /* machine word types */ 95 96 typedef ov_size ov_uword; 97 typedef ov_diff ov_word; 98 99 /* additional derived / convenience types */ 100 101 typedef ov_uword ov_boolean; 102 103 typedef ov_uint32 ov_meta; /* object "meta" bits */ 104 typedef ov_int32 ov_status; 105 106 typedef ov_word ov_int; /* C-like synonyms */ 107 typedef ov_uword ov_uint; 108 typedef ov_char8 ov_char; 109 typedef ov_uchar8 ov_uchar; 110 111 typedef ov_word ov_selector; /* Jenarix method selector */ 112 113 /* generic untyped free pointer/resource method */ 114 115 typedef void ov_void_free(void *ptr); 116 117 /* Jenarix object struct/union */ 118 119 struct ov__object { 120 ov_uint32 meta; 121 122 union { 123 /* machine word */ 124 125 ov_word word; 126 ov_uword uword; 127 128 /* method selector */ 129 ov_selector selector; 130 131 /* functions */ 132 133 ov__fn fn; /* cast as ov_fn for parameter checking */ 134 ov__dispatch_fn dispatch_fn; /* cast as ov_dispatch_fn for 135 parameter checking */ 136 137 /* C string constants (i.e. for hardcoded use with method import) */ 138 139 const char *str_const; 140 141 /* cells & blocks, requiring external storage */ 142 143 ov_word *ref_cnt; 144 ov_gc_head *gc; /* garbage collection and method dispatch */ 145 ov_block *block; 146 ov_cell *cell; 147 ov_opaque_head *opaque; 148 ov_triplet *triplet; 149 150 /* various in-place particle payloads */ 151 152 ov_word boolean; 153 ov_char8 char8; 154 ov_uchar8 uchar8; 155 ov_int8 int8; 156 ov_uint8 uint8; 157 ov_int16 int16; 158 ov_uint16 uint16; 159 ov_int32 int32; 160 ov_uint32 uint32; 161 ov_float32 float32; 162 163 #ifdef OV_64_BIT 164 ov_float64 float64; 165 ov_int64 int64; 166 ov_uint64 uint64; 167 #endif 168 169 /* data pointer types */ 170 171 union { 172 ov_word *word; 173 ov_uword *uword; 174 ov_word *boolean; 175 ov_char8 *char8; 176 ov_uchar8 *uchar8; 177 ov_int8 *int8; 178 ov_uint8 *uint8; 179 ov_int16 *int16; 180 ov_uint16 *uint16; 181 ov_int32 *int32; 182 ov_uint32 *uint32; 183 ov_float32 *float32; 184 ov_float64 *float64; 185 ov_int64 *int64; 186 ov_uint64 *uint64; 187 } ptr; 188 189 } data; 190 }; 191 192 /* unfortunately, due to circularity of definition, we can't get 193 * compile-time parameter checking with : 194 * ov_object.fn(...) 195 * so must use: 196 * ((ov_fn)ov_object.fn)(...) instead */ 197 198 typedef ov_object(*ov_fn) (ov_object, ov_object); 199 typedef ov_object(*ov_dispatch_fn) (ov_object, ov_object, ov_object); 200 201 #ifdef __cplusplus 202 } 203 #endif 204 #endif 205