@@ -34,16 +34,19 @@ Dynamic Throw(Dynamic inDynamic)
34
34
namespace hx
35
35
{
36
36
37
- typedef std::map<std::wstring,Resource> ResourceSet;
38
- static ResourceSet sgResources;
37
+ // typedef std::map<std::wstring,Resource> ResourceSet;
38
+ // static ResourceSet sgResources;
39
+
40
+ Resource *sgResources;
39
41
40
42
void RegisterResources (Resource *inResources)
41
43
{
42
- while (inResources->mData )
43
- {
44
- sgResources[inResources->mName .__s ] = *inResources;
45
- inResources++;
46
- }
44
+ sgResources = inResources;
45
+ // while(inResources->mData)
46
+ // {
47
+ // sgResources[inResources->mName.__s] = *inResources;
48
+ // inResources++;
49
+ // }
47
50
}
48
51
49
52
}
@@ -53,39 +56,39 @@ using namespace hx;
53
56
Array<String> __hxcpp_resource_names ()
54
57
{
55
58
Array<String> result (0 ,0 );
56
- for (ResourceSet::iterator i=sgResources.begin (); i!=sgResources.end ();++i)
57
- {
58
- int len = i->first .length ();
59
- wchar_t *copy = hx::NewString (len);
60
- memcpy (copy,i->first .c_str (), len*sizeof (wchar_t ));
61
- result->push ( String (copy) );
62
- }
59
+
60
+ for (Resource *reso = sgResources; reso->mData ; reso++)
61
+ result->push ( reso->mName );
62
+
63
63
return result;
64
64
}
65
65
66
66
String __hxcpp_resource_string (String inName)
67
67
{
68
- ResourceSet::iterator i=sgResources.find (inName.__s );
69
- if (i==sgResources.end ())
70
- return null ();
71
- return String ((const char *) i->second .mData , i->second .mDataLength );
68
+ for (Resource *reso = sgResources; reso->mData ; reso++)
69
+ {
70
+ if (reso->mName == inName)
71
+ return String ((const char *) reso->mData , reso->mDataLength );
72
+ }
73
+ return null ();
72
74
}
73
75
74
76
Array<unsigned char > __hxcpp_resource_bytes (String inName)
75
77
{
76
- ResourceSet::iterator i=sgResources.find (inName.__s );
77
- if (i==sgResources.end ())
78
- return null ();
79
- int len = i->second .mDataLength ;
80
- Array<unsigned char > result ( len, 0 );
81
- memcpy ( result->GetBase () , i->second .mData , len );
82
- return result;
78
+ for (Resource *reso = sgResources; reso->mData ; reso++)
79
+ {
80
+ if (reso->mName == inName)
81
+ {
82
+ int len = reso->mDataLength ;
83
+ Array<unsigned char > result ( len, 0 );
84
+ memcpy ( result->GetBase () , reso->mData , len );
85
+ return result;
86
+ }
87
+ }
83
88
}
84
89
85
90
86
91
87
-
88
-
89
92
// --- System ---------------------------------------------------------------------
90
93
91
94
@@ -264,9 +267,10 @@ Dynamic __hxcpp_parse_int(const String &inString)
264
267
265
268
#ifdef ANDROID
266
269
char buf[100 ];
267
- for (int i=0 ;i<99 && i<inString.length ;i++)
270
+ int i;
271
+ for (i=0 ;i<99 && i<inString.length ;i++)
268
272
buf[i] = str[i];
269
- buf[99 ] = ' \0 ' ;
273
+ buf[i ] = ' \0 ' ;
270
274
271
275
char *end = 0 ;
272
276
if (hex)
@@ -291,9 +295,10 @@ double __hxcpp_parse_float(const String &inString)
291
295
const wchar_t *str = inString.__s ;
292
296
#ifdef ANDROID
293
297
char buf[100 ];
294
- for (int i=0 ;i<99 && i<inString.length ;i++)
298
+ int i;
299
+ for (i=0 ;i<99 && i<inString.length ;i++)
295
300
buf[i] = str[i];
296
- buf[99 ] = ' \0 ' ;
301
+ buf[i ] = ' \0 ' ;
297
302
char *end;
298
303
double result = strtod (buf,&end);
299
304
if (end==buf)
@@ -406,4 +411,3 @@ STATIC_HX_DEFINE_DYNAMIC_FUNC2(CppInt32___obj,make,return )
406
411
407
412
408
413
409
-
0 commit comments