| 1 |
|
| /* |
| 2 |
|
| * *********************************************** |
| 3 |
|
| * |
| 4 |
|
| * !!!! DO NOT EDIT !!!! |
| 5 |
|
| * |
| 6 |
|
| * This file was auto-generated by Build.PL. |
| 7 |
|
| * |
| 8 |
|
| * *********************************************** |
| 9 |
|
| * |
| 10 |
|
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| 11 |
|
| * contributor license agreements. See the NOTICE file distributed with |
| 12 |
|
| * this work for additional information regarding copyright ownership. |
| 13 |
|
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 14 |
|
| * (the "License"); you may not use this file except in compliance with |
| 15 |
|
| * the License. You may obtain a copy of the License at |
| 16 |
|
| * |
| 17 |
|
| * http://www.apache.org/licenses/LICENSE-2.0 |
| 18 |
|
| * |
| 19 |
|
| * Unless required by applicable law or agreed to in writing, software |
| 20 |
|
| * distributed under the License is distributed on an "AS IS" BASIS, |
| 21 |
|
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 |
|
| * See the License for the specific language governing permissions and |
| 23 |
|
| * limitations under the License. |
| 24 |
|
| */ |
| 25 |
|
| |
| 26 |
|
| #ifndef CFISH_CFISH_PARCEL_H |
| 27 |
|
| #define CFISH_CFISH_PARCEL_H 1 |
| 28 |
|
| |
| 29 |
|
| #ifdef __cplusplus |
| 30 |
|
| extern "C" { |
| 31 |
|
| #endif |
| 32 |
|
| |
| 33 |
|
| #include <stdarg.h> |
| 34 |
|
| #include <stddef.h> |
| 35 |
|
| |
| 36 |
|
| #include "cfish_platform.h" |
| 37 |
|
| #include "cfish_hostdefs.h" |
| 38 |
|
| |
| 39 |
|
| #ifdef CFP_CFISH |
| 40 |
|
| #define CFISH_VISIBLE CFISH_EXPORT |
| 41 |
|
| #else |
| 42 |
|
| #define CFISH_VISIBLE CFISH_IMPORT |
| 43 |
|
| #endif |
| 44 |
|
| |
| 45 |
|
| typedef struct cfish_Obj cfish_Obj; |
| 46 |
|
| typedef struct cfish_Blob cfish_Blob; |
| 47 |
|
| typedef struct cfish_Boolean cfish_Boolean; |
| 48 |
|
| typedef struct cfish_ByteBuf cfish_ByteBuf; |
| 49 |
|
| typedef struct cfish_CharBuf cfish_CharBuf; |
| 50 |
|
| typedef struct cfish_Class cfish_Class; |
| 51 |
|
| typedef struct cfish_Err cfish_Err; |
| 52 |
|
| typedef struct cfish_Float cfish_Float; |
| 53 |
|
| typedef struct cfish_Hash cfish_Hash; |
| 54 |
|
| typedef struct cfish_HashIterator cfish_HashIterator; |
| 55 |
|
| typedef struct cfish_Integer cfish_Integer; |
| 56 |
|
| typedef struct cfish_Method cfish_Method; |
| 57 |
|
| typedef struct cfish_String cfish_String; |
| 58 |
|
| typedef struct cfish_StringIterator cfish_StringIterator; |
| 59 |
|
| typedef struct cfish_TestBatch cfish_TestBatch; |
| 60 |
|
| typedef struct cfish_TestBatchRunner cfish_TestBatchRunner; |
| 61 |
|
| typedef struct cfish_TestFormatter cfish_TestFormatter; |
| 62 |
|
| typedef struct cfish_TestFormatterCF cfish_TestFormatterCF; |
| 63 |
|
| typedef struct cfish_TestFormatterTAP cfish_TestFormatterTAP; |
| 64 |
|
| typedef struct cfish_TestSuite cfish_TestSuite; |
| 65 |
|
| typedef struct cfish_TestSuiteRunner cfish_TestSuiteRunner; |
| 66 |
|
| typedef struct cfish_Vector cfish_Vector; |
| 67 |
|
| |
| 68 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_OBJ; |
| 69 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_BLOB; |
| 70 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_BOOLEAN; |
| 71 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_BYTEBUF; |
| 72 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_CHARBUF; |
| 73 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_CLASS; |
| 74 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_ERR; |
| 75 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_FLOAT; |
| 76 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_HASH; |
| 77 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_HASHITERATOR; |
| 78 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_INTEGER; |
| 79 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_METHOD; |
| 80 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_STRING; |
| 81 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_STRINGITERATOR; |
| 82 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTBATCH; |
| 83 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTBATCHRUNNER; |
| 84 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTFORMATTER; |
| 85 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTFORMATTERCF; |
| 86 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTFORMATTERTAP; |
| 87 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTSUITE; |
| 88 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_TESTSUITERUNNER; |
| 89 |
|
| extern CFISH_VISIBLE cfish_Class *CFISH_VECTOR; |
| 90 |
|
| |
| 91 |
|
| #define CFISH_UNUSED_VAR(var) ((void)var) |
| 92 |
|
| #define CFISH_UNREACHABLE_RETURN(type) return (type)0 |
| 93 |
|
| |
| 94 |
|
| /* Generic method pointer. |
| 95 |
|
| */ |
| 96 |
|
| typedef void |
| 97 |
|
| (*cfish_method_t)(const void *vself); |
| 98 |
|
| |
| 99 |
|
| /* Access the function pointer for a given method from the class. |
| 100 |
|
| */ |
| 101 |
|
| #define CFISH_METHOD_PTR(_class, _full_meth) \ |
| 102 |
|
| ((_full_meth ## _t)cfish_method(_class, _full_meth ## _OFFSET)) |
| 103 |
|
| |
| 104 |
|
| static CFISH_INLINE cfish_method_t |
| 105 |
50 |
| cfish_method(const void *klass, uint32_t offset) { |
| 106 |
|
| union { char *cptr; cfish_method_t *fptr; } ptr; |
| 107 |
50 |
| ptr.cptr = (char*)klass + offset; |
| 108 |
50 |
| return ptr.fptr[0]; |
| 109 |
|
| } |
| 110 |
|
| |
| 111 |
|
| typedef struct cfish_Dummy { |
| 112 |
|
| CFISH_OBJ_HEAD |
| 113 |
|
| void *klass; |
| 114 |
|
| } cfish_Dummy; |
| 115 |
|
| |
| 116 |
|
| typedef struct cfish_HostObjWrapper { |
| 117 |
|
| CFISH_OBJ_HEAD |
| 118 |
|
| void *klass; |
| 119 |
|
| void *wrapped; |
| 120 |
|
| } cfish_HostObjWrapper; |
| 121 |
|
| |
| 122 |
|
| /* Access the function pointer for a given method from the object. |
| 123 |
|
| */ |
| 124 |
|
| static CFISH_INLINE cfish_method_t |
| 125 |
17 |
| cfish_obj_method(const void *object, uint32_t offset) { |
| 126 |
17 |
| cfish_Dummy *dummy = (cfish_Dummy*)object; |
| 127 |
17 |
| return cfish_method(dummy->klass, offset); |
| 128 |
|
| } |
| 129 |
|
| |
| 130 |
|
| /* Access the function pointer for the given method in the |
| 131 |
|
| * superclass. */ |
| 132 |
|
| #define CFISH_SUPER_METHOD_PTR(_class, _full_meth) \ |
| 133 |
|
| ((_full_meth ## _t)cfish_super_method(_class, \ |
| 134 |
|
| _full_meth ## _OFFSET)) |
| 135 |
|
| |
| 136 |
|
| extern CFISH_VISIBLE uint32_t cfish_Class_offset_of_parent; |
| 137 |
|
| static CFISH_INLINE cfish_method_t |
| 138 |
|
| cfish_super_method(const void *klass, uint32_t offset) { |
| 139 |
|
| char *class_as_char = (char*)klass; |
| 140 |
|
| cfish_Class **parent_ptr |
| 141 |
|
| = (cfish_Class**)(class_as_char + cfish_Class_offset_of_parent); |
| 142 |
|
| return cfish_method(*parent_ptr, offset); |
| 143 |
|
| } |
| 144 |
|
| |
| 145 |
|
| typedef void |
| 146 |
|
| (*cfish_destroy_t)(void *vself); |
| 147 |
|
| extern CFISH_VISIBLE uint32_t CFISH_Obj_Destroy_OFFSET; |
| 148 |
|
| |
| 149 |
|
| /** Invoke the [](.Destroy) method found in `klass` on |
| 150 |
|
| * `self`. |
| 151 |
|
| * |
| 152 |
|
| * TODO: Eliminate this function if we can arrive at a proper SUPER syntax. |
| 153 |
|
| */ |
| 154 |
|
| static CFISH_INLINE void |
| 155 |
|
| cfish_super_destroy(void *vself, cfish_Class *klass) { |
| 156 |
|
| cfish_Obj *self = (cfish_Obj*)vself; |
| 157 |
|
| if (self != NULL) { |
| 158 |
|
| cfish_destroy_t super_destroy |
| 159 |
|
| = (cfish_destroy_t)cfish_super_method(klass, CFISH_Obj_Destroy_OFFSET); |
| 160 |
|
| super_destroy(self); |
| 161 |
|
| } |
| 162 |
|
| } |
| 163 |
|
| |
| 164 |
|
| #define CFISH_SUPER_DESTROY(_self, _class) \ |
| 165 |
|
| cfish_super_destroy(_self, _class) |
| 166 |
|
| |
| 167 |
|
| extern CFISH_VISIBLE cfish_Obj* |
| 168 |
|
| cfish_inc_refcount(void *vself); |
| 169 |
|
| |
| 170 |
|
| /** NULL-safe invocation invocation of `cfish_inc_refcount`. |
| 171 |
|
| * |
| 172 |
|
| * @return NULL if `self` is NULL, otherwise the return value |
| 173 |
|
| * of `cfish_inc_refcount`. |
| 174 |
|
| */ |
| 175 |
|
| static CFISH_INLINE cfish_Obj* |
| 176 |
|
| cfish_incref(void *vself) { |
| 177 |
|
| if (vself != NULL) { return cfish_inc_refcount(vself); } |
| 178 |
|
| else { return NULL; } |
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
|
| #define CFISH_INCREF(_self) cfish_incref(_self) |
| 182 |
|
| #define CFISH_INCREF_NN(_self) cfish_inc_refcount(_self) |
| 183 |
|
| |
| 184 |
|
| extern CFISH_VISIBLE uint32_t |
| 185 |
|
| cfish_dec_refcount(void *vself); |
| 186 |
|
| |
| 187 |
|
| /** NULL-safe invocation of `cfish_dec_refcount`. |
| 188 |
|
| * |
| 189 |
|
| * @return NULL if `self` is NULL, otherwise the return value |
| 190 |
|
| * of `cfish_dec_refcount`. |
| 191 |
|
| */ |
| 192 |
|
| static CFISH_INLINE uint32_t |
| 193 |
2 |
| cfish_decref(void *vself) { |
| 194 |
2 |
▶ | if (vself != NULL) { return cfish_dec_refcount(vself); } |
Branch: 1 branch
| Branch | True | False | Total |
| if (vself != NULL) { return cfish_dec_refcount(vself); } |
2 |
0 |
2 |
|
| 195 |
0 |
| else { return 0; } |
| 196 |
|
| } |
| 197 |
|
| |
| 198 |
|
| #define CFISH_DECREF(_self) cfish_decref(_self) |
| 199 |
|
| #define CFISH_DECREF_NN(_self) cfish_dec_refcount(_self) |
| 200 |
|
| |
| 201 |
|
| extern CFISH_VISIBLE uint32_t |
| 202 |
|
| cfish_get_refcount(void *vself); |
| 203 |
|
| |
| 204 |
|
| #define CFISH_REFCOUNT_NN(_self) \ |
| 205 |
|
| cfish_get_refcount(_self) |
| 206 |
|
| |
| 207 |
|
| /* Flags for internal use. */ |
| 208 |
|
| #define CFISH_fREFCOUNTSPECIAL 0x00000001 |
| 209 |
|
| #define CFISH_fFINAL 0x00000002 |
| 210 |
|
| #define CFISH_fEMPTY 0x00000004 |
| 211 |
|
| #define CFISH_fHOST 0x00000008 |
| 212 |
|
| /* Structs for Class initialization. |
| 213 |
|
| */ |
| 214 |
|
| |
| 215 |
|
| typedef struct cfish_NovelMethSpec { |
| 216 |
|
| uint32_t *offset; |
| 217 |
|
| const char *name; |
| 218 |
|
| cfish_method_t func; |
| 219 |
|
| cfish_method_t callback_func; |
| 220 |
|
| } cfish_NovelMethSpec; |
| 221 |
|
| |
| 222 |
|
| typedef struct cfish_OverriddenMethSpec { |
| 223 |
|
| uint32_t *offset; |
| 224 |
|
| uint32_t *parent_offset; |
| 225 |
|
| cfish_method_t func; |
| 226 |
|
| } cfish_OverriddenMethSpec; |
| 227 |
|
| |
| 228 |
|
| typedef struct cfish_InheritedMethSpec { |
| 229 |
|
| uint32_t *offset; |
| 230 |
|
| uint32_t *parent_offset; |
| 231 |
|
| } cfish_InheritedMethSpec; |
| 232 |
|
| |
| 233 |
|
| typedef enum { |
| 234 |
|
| cfish_ClassSpec_FINAL = 1 |
| 235 |
|
| } cfish_ClassSpecFlags; |
| 236 |
|
| |
| 237 |
|
| typedef struct cfish_ClassSpec { |
| 238 |
|
| cfish_Class **klass; |
| 239 |
|
| cfish_Class **parent; |
| 240 |
|
| const char *name; |
| 241 |
|
| uint32_t ivars_size; |
| 242 |
|
| uint32_t *ivars_offset_ptr; |
| 243 |
|
| uint32_t num_novel_meths; |
| 244 |
|
| uint32_t num_overridden_meths; |
| 245 |
|
| uint32_t num_inherited_meths; |
| 246 |
|
| uint32_t flags; |
| 247 |
|
| } cfish_ClassSpec; |
| 248 |
|
| |
| 249 |
|
| typedef struct cfish_ParcelSpec { |
| 250 |
|
| const cfish_ClassSpec *class_specs; |
| 251 |
|
| const cfish_NovelMethSpec *novel_specs; |
| 252 |
|
| const cfish_OverriddenMethSpec *overridden_specs; |
| 253 |
|
| const cfish_InheritedMethSpec *inherited_specs; |
| 254 |
|
| uint32_t num_classes; |
| 255 |
|
| } cfish_ParcelSpec; |
| 256 |
|
| |
| 257 |
|
| #ifdef CFISH_USE_SHORT_NAMES |
| 258 |
|
| #define UNUSED_VAR CFISH_UNUSED_VAR |
| 259 |
|
| #define UNREACHABLE_RETURN CFISH_UNREACHABLE_RETURN |
| 260 |
|
| #define METHOD_PTR CFISH_METHOD_PTR |
| 261 |
|
| #define SUPER_METHOD_PTR CFISH_SUPER_METHOD_PTR |
| 262 |
|
| #define SUPER_DESTROY(_self, _class) CFISH_SUPER_DESTROY(_self, _class) |
| 263 |
|
| #define INCREF(_self) CFISH_INCREF(_self) |
| 264 |
|
| #define INCREF_NN(_self) CFISH_INCREF_NN(_self) |
| 265 |
|
| #define DECREF(_self) CFISH_DECREF(_self) |
| 266 |
|
| #define DECREF_NN(_self) CFISH_DECREF_NN(_self) |
| 267 |
|
| #define REFCOUNT_NN(_self) CFISH_REFCOUNT_NN(_self) |
| 268 |
|
| #endif |
| 269 |
|
| |
| 270 |
|
| CFISH_VISIBLE void |
| 271 |
|
| cfish_bootstrap_internal(int force); |
| 272 |
|
| |
| 273 |
|
| CFISH_VISIBLE void |
| 274 |
|
| cfish_bootstrap_parcel(void); |
| 275 |
|
| |
| 276 |
|
| void |
| 277 |
|
| cfish_init_parcel(void); |
| 278 |
|
| |
| 279 |
|
| #ifdef __cplusplus |
| 280 |
|
| } |
| 281 |
|
| #endif |
| 282 |
|
| |
| 283 |
|
| #endif /* CFISH_CFISH_PARCEL_H */ |
| 284 |
|
| |
| 285 |
|
| |
| 286 |
|
| |