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.compiler.dmd.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) void _d_delinterface(void** p); 22 extern (C) ulong _d_newarrayT(TypeInfo ti, size_t length); 23 extern (C) ulong _d_newarrayiT(TypeInfo ti, size_t length); 24 extern (C) ulong _d_newarraymT(TypeInfo ti, int ndims, ...); 25 extern (C) ulong _d_newarraymiT(TypeInfo ti, int ndims, ...); 26 extern (C) void _d_delarray(Array *p); 27 extern (C) void _d_delmemory(void* *p); 28 extern (C) void _d_callinterfacefinalizer(void *p); 29 extern (C) void _d_callfinalizer(void* p); 30 alias bool function(Object) CollectHandler; 31 extern (C) void rt_setCollectHandler(CollectHandler h); 32 extern (C) void rt_finalize(void* p, bool det = true); 33 extern (C) byte[] _d_arraysetlengthT(TypeInfo ti, size_t newlength, Array *p); 34 extern (C) byte[] _d_arraysetlengthiT(TypeInfo ti, size_t newlength, Array *p); 35 extern (C) long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y); 36 extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...); 37 extern (C) byte[] _d_arraycatT(TypeInfo ti, byte[] x, byte[] y); 38 extern (C) byte[] _d_arraycatnT(TypeInfo ti, uint n, ...); 39 extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...); 40 extern (C) long _adDupT(TypeInfo ti, Array2 a); 41 42 // rt.aaA; 43 alias long ArrayRet_t; 44 struct aaA 45 { 46 aaA *left; 47 aaA *right; 48 hash_t hash; 49 /* key */ 50 /* value */ 51 } 52 struct BB 53 { 54 aaA*[] b; 55 size_t nodes; // total number of aaA nodes 56 TypeInfo keyti; // TODO: replace this with TypeInfo_AssociativeArray when available in _aaGet() 57 } 58 struct AA 59 { 60 BB* a; 61 } 62 extern (D) typedef int delegate(void *) dg_t; 63 extern (D) typedef int delegate(void *, void *) dg2_t; 64 extern (C) size_t _aaLen(AA aa); 65 extern (C) void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, ...); 66 extern (C) void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, ...); 67 extern (C) void* _aaIn(AA aa, TypeInfo keyti, ...); 68 extern (C) void _aaDel(AA aa, TypeInfo keyti, ...); 69 extern (C) ArrayRet_t _aaValues(AA aa, size_t keysize, size_t valuesize); 70 extern (C) void* _aaRehash(AA* paa, TypeInfo keyti); 71 extern (C) void _aaBalance(AA* paa); 72 extern (C) ArrayRet_t _aaKeys(AA aa, size_t keysize); 73 extern (C) int _aaApply(AA aa, size_t keysize, dg_t dg); 74 extern (C) int _aaApply2(AA aa, size_t keysize, dg2_t dg); 75 extern (C) BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...); 76