1 /+ 2 + The C interface exported by the runtime, this is the only interface that should be used 3 + from outside the runtime 4 + 5 + Fawzi Mohamed 6 +/ 7 module rt.cInterface; 8 9 // rt.lifetime 10 struct Array 11 { 12 size_t length; 13 byte* data; 14 } 15 struct Array2 16 { 17 size_t length; 18 void* ptr; 19 } 20 //extern (C) Object _d_newclass(ClassInfo ci); 21 extern (C) Object _d_allocclass(ClassInfo ci); 22 extern (C) void _d_delinterface(void** p); 23 extern (C) ulong _d_newarrayT(TypeInfo ti, size_t length); 24 extern (C) ulong _d_newarrayiT(TypeInfo ti, size_t length); 25 extern (C) ulong _d_newarraymT(TypeInfo ti, int ndims, ...); 26 extern (C) ulong _d_newarraymiT(TypeInfo ti, int ndims, ...); 27 extern (C) void _d_delarray(Array *p); 28 extern (C) void _d_delmemory(void* *p); 29 extern (C) void _d_callinterfacefinalizer(void *p); 30 extern (C) void _d_callfinalizer(void* p); 31 alias bool function(Object) CollectHandler; 32 extern (C) void rt_setCollectHandler(CollectHandler h); 33 extern (C) void rt_finalize(void* p, bool det = true); 34 extern (C) byte[] _d_arraysetlengthT(TypeInfo ti, size_t newlength, Array *p); 35 extern (C) byte[] _d_arraysetlengthiT(TypeInfo ti, size_t newlength, Array *p); 36 extern (C) long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y); 37 extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...); 38 extern (C) byte[] _d_arraycatT(TypeInfo ti, byte[] x, byte[] y); 39 extern (C) byte[] _d_arraycatnT(TypeInfo ti, uint n, ...); 40 extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...); 41 extern (C) long _adDupT(TypeInfo ti, Array2 a); 42 43 // rt.aaA; 44 alias long ArrayRet_t; 45 struct aaA 46 { 47 aaA *left; 48 aaA *right; 49 hash_t hash; 50 /* key */ 51 /* value */ 52 } 53 struct BB 54 { 55 aaA*[] b; 56 size_t nodes; // total number of aaA nodes 57 TypeInfo keyti; // TODO: replace this with TypeInfo_AssociativeArray when available in _aaGet() 58 } 59 struct AA 60 { 61 BB* a; 62 } 63 extern (D) typedef int delegate(void *) dg_t; 64 extern (D) typedef int delegate(void *, void *) dg2_t; 65 extern (C) size_t _aaLen(AA aa); 66 extern (C) void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, ...); 67 extern (C) void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, ...); 68 extern (C) void* _aaIn(AA aa, TypeInfo keyti, ...); 69 extern (C) void _aaDel(AA aa, TypeInfo keyti, ...); 70 extern (C) ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize); 71 extern (C) void* _aaRehash(AA* paa, TypeInfo keyti); 72 extern (C) void _aaBalance(AA* paa); 73 extern (C) ArrayRet_t _aaKeys(AA aa, size_t keysize); 74 extern (C) int _aaApply(AA aa, size_t keysize, dg_t dg); 75 extern (C) int _aaApply2(AA aa, size_t keysize, dg2_t dg); 76 extern (C) BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...); 77