comparison runtime/internal/genobj.d @ 1442:0a5f7890f327

Adjust some more code that was depending on the function and delegate calling conventions being equal. There's also an instance in `tango.text.convert.Layout` that should be adjusted: {{{ Index: tango/text/convert/Layout.d =================================================================== --- tango/text/convert/Layout.d (revision 4578) +++ tango/text/convert/Layout.d (working copy) -660,8 +660,12 @@ case TypeCode.STRUCT: auto s = cast(TypeInfo_Struct) type; - if (s.xtoString) - return Utf.fromString8 (s.xtoString(p), result); + if (s.xtoString) { + char[] delegate() toString; + toString.ptr = p; + toString.funcptr = cast(char[] function()) s.xtoString; + return Utf.fromString8 (toString(), result); + } goto default; case TypeCode.INTERFACE: }}}
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 31 May 2009 15:27:01 +0200
parents d7ec997de427
children 09734fb929c0
comparison
equal deleted inserted replaced
1441:a3af393d1936 1442:0a5f7890f327
150 */ 150 */
151 char[] name; /// class name 151 char[] name; /// class name
152 void*[] vtbl; /// virtual function pointer table 152 void*[] vtbl; /// virtual function pointer table
153 Interface[] interfaces; /// interfaces this class implements 153 Interface[] interfaces; /// interfaces this class implements
154 ClassInfo base; /// base class 154 ClassInfo base; /// base class
155 void* destructor; 155 void* destructor; // Only use as delegate.funcptr!
156 void* classInvariant; 156 void* classInvariant; // Only use as delegate.funcptr!
157 uint flags; 157 uint flags;
158 // 1: // IUnknown 158 // 1: // IUnknown
159 // 2: // has no possible pointers into GC memory 159 // 2: // has no possible pointers into GC memory
160 // 4: // has offTi[] member 160 // 4: // has offTi[] member
161 // 8: // has constructors 161 // 8: // has constructors
162 // 32: // has typeinfo 162 // 32: // has typeinfo
163 void* deallocator; 163 void* deallocator;
164 OffsetTypeInfo[] offTi; 164 OffsetTypeInfo[] offTi;
165 void* defaultConstructor; // default Constructor 165 void* defaultConstructor; // default Constructor. Only use as delegate.funcptr!
166 TypeInfo typeinfo; 166 TypeInfo typeinfo;
167 167
168 /** 168 /**
169 * Search all modules for ClassInfo corresponding to classname. 169 * Search all modules for ClassInfo corresponding to classname.
170 * Returns: null if not found 170 * Returns: null if not found
762 { hash_t h; 762 { hash_t h;
763 763
764 assert(p); 764 assert(p);
765 if (xtoHash) 765 if (xtoHash)
766 { debug(PRINTF) printf("getHash() using xtoHash\n"); 766 { debug(PRINTF) printf("getHash() using xtoHash\n");
767 h = (*xtoHash)(p); 767 hash_t delegate() toHash;
768 toHash.ptr = p;
769 toHash.funcptr = xtoHash;
770 h = toHash();
768 } 771 }
769 else 772 else
770 { 773 {
771 debug(PRINTF) printf("getHash() using default hash\n"); 774 debug(PRINTF) printf("getHash() using default hash\n");
772 // A sorry hash algorithm. 775 // A sorry hash algorithm.
785 788
786 if (p1 == p2) 789 if (p1 == p2)
787 c = 1; 790 c = 1;
788 else if (!p1 || !p2) 791 else if (!p1 || !p2)
789 c = 0; 792 c = 0;
790 else if (xopEquals) 793 else if (xopEquals) {
791 c = (*xopEquals)(p1, p2); 794 int delegate(void*) opEquals;
792 else 795 opEquals.ptr = p1;
796 opEquals.funcptr = xopEquals;
797 c = opEquals(p2);
798 } else
793 // BUG: relies on the GC not moving objects 799 // BUG: relies on the GC not moving objects
794 c = (memcmp(p1, p2, m_init.length) == 0); 800 c = (memcmp(p1, p2, m_init.length) == 0);
795 return c; 801 return c;
796 } 802 }
797 803
803 if (p1 != p2) 809 if (p1 != p2)
804 { 810 {
805 if (p1) 811 if (p1)
806 { if (!p2) 812 { if (!p2)
807 c = 1; 813 c = 1;
808 else if (xopCmp) 814 else if (xopCmp) {
809 // the x86 D calling conv requires the this arg to be last here 815 int delegate(void*) opCmp;
810 version(X86) 816 opCmp.ptr = p1;
811 c = (*xopCmp)(p2, p1); 817 opCmp.funcptr = xopCmp;
812 else 818 c = opCmp(p2);
813 c = (*xopCmp)(p1, p2); 819 } else
814 else
815 // BUG: relies on the GC not moving objects 820 // BUG: relies on the GC not moving objects
816 c = memcmp(p1, p2, m_init.length); 821 c = memcmp(p1, p2, m_init.length);
817 } 822 }
818 else 823 else
819 c = -1; 824 c = -1;
831 uint flags() { return m_flags; } 836 uint flags() { return m_flags; }
832 837
833 char[] name; 838 char[] name;
834 void[] m_init; // initializer; never null 839 void[] m_init; // initializer; never null
835 840
836 hash_t function(void*) xtoHash; 841 // These are ONLY for use as a delegate.funcptr!
837 int function(void*,void*) xopEquals; 842 hash_t function() xtoHash;
838 int function(void*,void*) xopCmp; 843 int function(void*) xopEquals;
839 char[] function(void*) xtoString; 844 int function(void*) xopCmp;
845 char[] function() xtoString;
840 846
841 uint m_flags; 847 uint m_flags;
842 } 848 }
843 849
844 class TypeInfo_Tuple : TypeInfo 850 class TypeInfo_Tuple : TypeInfo