Mercurial > projects > dwt-linux
comparison dwt/dwthelper/utils.d @ 220:ba054b4a1c55
ImportData for loading compile time images
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 09 Apr 2008 16:46:02 +0200 |
parents | 9b4e6fc63930 |
children | d0081b1505da |
comparison
equal
deleted
inserted
replaced
219:9b4e6fc63930 | 220:ba054b4a1c55 |
---|---|
61 value = data; | 61 value = data; |
62 } | 62 } |
63 public int opEquals( T other ){ | 63 public int opEquals( T other ){ |
64 return value == other; | 64 return value == other; |
65 } | 65 } |
66 public int opEquals( Object other ){ | |
67 if( auto o = cast(ValueWrapperT!(T))other ){ | |
68 return value == o.value; | |
69 } | |
70 return false; | |
71 } | |
66 } | 72 } |
67 | 73 |
68 class Boolean : ValueWrapperT!(bool) { | 74 class Boolean : ValueWrapperT!(bool) { |
69 public static Boolean TRUE; | 75 public static Boolean TRUE; |
70 public static Boolean FALSE; | 76 public static Boolean FALSE; |
214 return cast(double)value; | 220 return cast(double)value; |
215 } | 221 } |
216 | 222 |
217 public override hash_t toHash(){ | 223 public override hash_t toHash(){ |
218 return intValue(); | 224 return intValue(); |
219 } | |
220 | |
221 public override int opEquals( Object obj ){ | |
222 implMissing( __FILE__, __LINE__ ); | |
223 return false; | |
224 } | 225 } |
225 | 226 |
226 public override char[] toString(){ | 227 public override char[] toString(){ |
227 return tango.text.convert.Integer.toString( value ); | 228 return tango.text.convert.Integer.toString( value ); |
228 } | 229 } |
801 return *p; | 802 return *p; |
802 } | 803 } |
803 return null; | 804 return null; |
804 } | 805 } |
805 } | 806 } |
807 /+++ | |
806 | 808 |
807 import dwt.dwthelper.InputStream; | 809 import dwt.dwthelper.InputStream; |
808 InputStream ClassInfoGetResourceAsStream( ClassInfo ci, char[] aName ){ | 810 InputStream ClassInfoGetResourceAsStream( ClassInfo ci, char[] aName ){ |
809 implMissing( __FILE__, __LINE__ ); | 811 implMissing( __FILE__, __LINE__ ); |
810 return null; | 812 return null; |
811 } | 813 } |
812 | 814 +++/ |
813 void ExceptionPrintStackTrace( Exception e ){ | 815 void ExceptionPrintStackTrace( Exception e ){ |
814 ExceptionPrintStackTrace( e, Stderr ); | 816 ExceptionPrintStackTrace( e, Stderr ); |
815 } | 817 } |
816 void ExceptionPrintStackTrace( Exception e, Print!(char) print ){ | 818 void ExceptionPrintStackTrace( Exception e, Print!(char) print ){ |
817 print.formatln( "Exception in {}({}): {}", e.file, e.line, e.msg ); | 819 print.formatln( "Exception in {}({}): {}", e.file, e.line, e.msg ); |
1140 idx++; | 1142 idx++; |
1141 } | 1143 } |
1142 return res; | 1144 return res; |
1143 } | 1145 } |
1144 | 1146 |
1145 | 1147 void PrintStackTrace(){ |
1148 try{ | |
1149 throw new Exception( null ); | |
1150 } | |
1151 catch( Exception e ){ | |
1152 foreach( msg; e.info ){ | |
1153 Trace.formatln( "trc: {}", msg ); | |
1154 } | |
1155 } | |
1156 } | |
1157 | |
1158 struct ImportData{ | |
1159 void[] data; | |
1160 char[] name; | |
1161 | |
1162 public static ImportData opCall( void[] data, char[] name ){ | |
1163 ImportData res; | |
1164 res.data = data; | |
1165 res.name = name; | |
1166 return res; | |
1167 } | |
1168 } | |
1169 | |
1170 template getImportData(char[] name ){ | |
1171 const ImportData getImportData = ImportData( import(name), name ); | |
1172 } |