Variant.pkg 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. $#include "Variant.h"
  2. enum VariantType
  3. {
  4. VAR_NONE = 0,
  5. VAR_INT,
  6. VAR_BOOL,
  7. VAR_FLOAT,
  8. VAR_VECTOR2,
  9. VAR_VECTOR3,
  10. VAR_VECTOR4,
  11. VAR_QUATERNION,
  12. VAR_COLOR,
  13. VAR_STRING,
  14. VAR_BUFFER,
  15. VAR_VOIDPTR,
  16. VAR_RESOURCEREF,
  17. VAR_RESOURCEREFLIST,
  18. VAR_VARIANTVECTOR,
  19. VAR_VARIANTMAP,
  20. VAR_INTRECT,
  21. VAR_INTVECTOR2,
  22. VAR_PTR,
  23. VAR_MATRIX3,
  24. VAR_MATRIX3X4,
  25. VAR_MATRIX4,
  26. MAX_VAR_TYPES
  27. };
  28. struct ResourceRef
  29. {
  30. ResourceRef();
  31. ResourceRef(ShortStringHash type);
  32. ResourceRef(ShortStringHash type, String name);
  33. ResourceRef(const ResourceRef& rhs);
  34. ~ResourceRef();
  35. ShortStringHash type_ @ type;
  36. String name_ @ name;
  37. bool operator == (const ResourceRef& rhs) const;
  38. };
  39. struct ResourceRefList
  40. {
  41. ResourceRefList();
  42. ResourceRefList(ShortStringHash type);
  43. ~ResourceRefList();
  44. ShortStringHash type_ @ type;
  45. bool operator == (const ResourceRefList& rhs) const;
  46. };
  47. class Variant
  48. {
  49. Variant();
  50. Variant(int value);
  51. Variant(unsigned value);
  52. Variant(const StringHash& value);
  53. Variant(const ShortStringHash& value);
  54. Variant(bool value);
  55. Variant(float value);
  56. Variant(const Vector2& value);
  57. Variant(const Vector3& value);
  58. Variant(const Vector4& value);
  59. Variant(const Quaternion& value);
  60. Variant(const Color& value);
  61. Variant(const String value);
  62. Variant(const char* value);
  63. Variant(const ResourceRef& value);
  64. Variant(const ResourceRefList& value);
  65. Variant(const IntRect& value);
  66. Variant(const IntVector2& value);
  67. Variant(const Matrix3& value);
  68. Variant(const Matrix3x4& value);
  69. Variant(const Matrix4& value);
  70. Variant(const String type, const String value);
  71. Variant(VariantType type, const String value);
  72. Variant(VariantType type, const char* value);
  73. Variant(const Variant& value);
  74. ~Variant();
  75. void Clear();
  76. bool operator == (const Variant& rhs) const;
  77. bool operator == (int rhs) const;
  78. bool operator == (unsigned rhs) const;
  79. bool operator == (bool rhs) const;
  80. bool operator == (float rhs) const;
  81. bool operator == (const Vector2& rhs);
  82. bool operator == (const Vector3& rhs) const;
  83. bool operator == (const Vector4& rhs) const;
  84. bool operator == (const Quaternion& rhs) const;
  85. bool operator == (const Color& rhs) const;
  86. bool operator == (const String rhs) const;
  87. bool operator == (const ResourceRef& rhs) const;
  88. bool operator == (const ResourceRefList& rhs) const;
  89. bool operator == (const IntRect& rhs) const;
  90. bool operator == (const IntVector2& rhs) const;
  91. bool operator == (const StringHash& rhs) const;
  92. bool operator == (const ShortStringHash& rhs) const;
  93. bool operator == (const Matrix3& rhs) const;
  94. bool operator == (const Matrix3x4& rhs) const;
  95. bool operator == (const Matrix4& rhs) const;
  96. tolua_outside void VariantSetInt @ SetInt(int value);
  97. tolua_outside void VariantSetUint @ SetUint(unsigned value);
  98. tolua_outside void VariantSetStringHash @ SetStringHash(const StringHash& value);
  99. tolua_outside void VariantSetShortStringHash @ SetShortStringHash(const ShortStringHash& value);
  100. tolua_outside void VariantSetBool @ SetBool(bool value);
  101. tolua_outside void VariantSetFloat @ SetFloat(float value);
  102. tolua_outside void VariantSetVector2 @ SetVector2(const Vector2& value);
  103. tolua_outside void VariantSetVector3 @ SetVector3(const Vector3& value);
  104. tolua_outside void VariantSetVector4 @ SetVector4(const Vector4& value);
  105. tolua_outside void VariantSetQuaternion @ SetQuaternion(const Quaternion& value);
  106. tolua_outside void VariantSetColor @ SetColor(const Color& value);
  107. tolua_outside void VariantSetString @ SetString(const String value);
  108. tolua_outside void VariantSetBuffer @ SetBuffer(const VectorBuffer& value);
  109. tolua_outside void VariantSetResourceRef @ SetResourceRef(const ResourceRef& value);
  110. tolua_outside void VariantSetResourceRefList @ SetResourceRefList(const ResourceRefList& value);
  111. tolua_outside void VariantSetIntRect @ SetIntRect(const IntRect& value);
  112. tolua_outside void VariantSetIntVector2 @ SetIntVector2(const IntVector2& value);
  113. tolua_outside void VariantSetMatrix3 @ SetMatrix3(const Matrix3& value);
  114. tolua_outside void VariantSetMatrix3x4 @ SetMatrix3x4(const Matrix3x4& value);
  115. tolua_outside void VariantSetMatrix4 @ SetMatrix4(const Matrix4& value);
  116. int GetInt() const;
  117. int GetUInt() const;
  118. StringHash GetStringHash();
  119. ShortStringHash GetShortStringHash();
  120. bool GetBool() const;
  121. float GetFloat() const;
  122. const Vector2& GetVector2() const;
  123. const Vector3& GetVector3() const;
  124. const Vector4& GetVector4() const;
  125. const Quaternion& GetQuaternion() const;
  126. const Color& GetColor() const;
  127. const String GetString() const;
  128. tolua_outside VectorBuffer VariantGetBuffer @ GetBuffer() const;
  129. const ResourceRef& GetResourceRef() const;
  130. const ResourceRefList& GetResourceRefList() const;
  131. const IntRect& GetIntRect() const;
  132. const IntVector2& GetIntVector2() const;
  133. const Matrix3& GetMatrix3() const;
  134. const Matrix3x4& GetMatrix3x4() const;
  135. const Matrix4& GetMatrix4() const;
  136. VariantType GetType() const;
  137. String GetTypeName() const;
  138. String ToString() const;
  139. bool IsZero() const;
  140. bool IsEmpty() const;
  141. tolua_readonly tolua_property__get_set VariantType type;
  142. tolua_readonly tolua_property__get_set String typeName;
  143. tolua_readonly tolua_property__is_set bool zero;
  144. tolua_readonly tolua_property__is_set bool empty;
  145. };
  146. class VariantMap
  147. {
  148. VariantMap();
  149. ~VariantMap();
  150. tolua_outside void VariantMapSetInt @ SetInt(const String key, int value);
  151. tolua_outside void VariantMapSetUInt @ SetUInt(const String key, unsigned value);
  152. tolua_outside void VariantMapSetStringHash @ SetStringHash(const String key, const StringHash& value);
  153. tolua_outside void VariantMapSetShortStringHash @ SetShortStringHash(const String key, const ShortStringHash& value);
  154. tolua_outside void VariantMapSetBool @ SetBool(const String key, bool value);
  155. tolua_outside void VariantMapSetFloat @ SetFloat(const String key, float value);
  156. tolua_outside void VariantMapSetVector2 @ SetVector2(const String key, const Vector2 value);
  157. tolua_outside void VariantMapSetVector3 @ SetVector3(const String key, const Vector3 value);
  158. tolua_outside void VariantMapSetVector4 @ SetVector4(const String key, const Vector4 value);
  159. tolua_outside void VariantMapSetQuaternion @ SetQuaternion(const String key, const Quaternion value);
  160. tolua_outside void VariantMapSetColor @ SetColor(const String key, const Color value);
  161. tolua_outside void VariantMapSetString @ SetString(const String key, const String value);
  162. tolua_outside void VariantMapSetBuffer @ SetBuffer(const String key, const VectorBuffer& value);
  163. tolua_outside void VariantMapSetResourceRef @ SetResourceRef(const String key, const ResourceRef value);
  164. tolua_outside void VariantMapSetResourceRefList @ SetResourceRefList(const String key, const ResourceRefList value);
  165. tolua_outside void VariantMapSetIntRect @ SetIntRect(const String key, const IntRect value);
  166. tolua_outside void VariantMapSetIntVector2 @ SetIntVector2(const String key, const IntVector2 value);
  167. tolua_outside void VariantMapSetPtr @ SetPtr(const String key, void* value);
  168. tolua_outside void VariantMapSetMatrix3 @ SetMatrix3(const String key, const Matrix3 value);
  169. tolua_outside void VariantMapSetMatrix3x4 @ SetMatrix3x4(const String key, const Matrix3x4 value);
  170. tolua_outside void VariantMapSetMatrix4 @ SetMatrix4(const String key, const Matrix4 value);
  171. tolua_outside int VariantMapGetInt @ GetInt(const String key);
  172. tolua_outside int VariantMapGetUInt @ GetUInt(const String key);
  173. tolua_outside StringHash VariantMapGetStringHash @ GetStringHash(const String key);
  174. tolua_outside ShortStringHash VariantMapGetShortStringHash @ GetShortStringHash(const String key);
  175. tolua_outside bool VariantMapGetBool @ GetBool(const String key);
  176. tolua_outside float VariantMapGetFloat @ GetFloat(const String key);
  177. tolua_outside const Vector2& VariantMapGetVector2 @ GetVector2(const String key);
  178. tolua_outside const Vector3& VariantMapGetVector3 @ GetVector3(const String key);
  179. tolua_outside const Vector4& VariantMapGetVector4 @ GetVector4(const String key);
  180. tolua_outside const Quaternion& VariantMapGetQuaternion @ GetQuaternion(const String key);
  181. tolua_outside const Color& VariantMapGetColor @ GetColor(const String key);
  182. tolua_outside const String VariantMapGetString @ GetString(const String key);
  183. tolua_outside VectorBuffer VariantMapGetBuffer @ GetBuffer(const String key);
  184. tolua_outside const ResourceRef& VariantMapGetResourceRef @ GetResourceRef(const String key);
  185. tolua_outside const ResourceRefList& VariantMapGetResourceRefList @ GetResourceRefList(const String key);
  186. tolua_outside const IntRect& VariantMapGetIntRect @ GetIntRect(const String key);
  187. tolua_outside const IntVector2& VariantMapGetIntVector2 @ GetIntVector2(const String key);
  188. tolua_outside const void* VariantMapGetPtr @ GetPtr(const String type, const String key);
  189. tolua_outside const Matrix3& VariantMapGetMatrix3 @ GetMatrix3(const String key);
  190. tolua_outside const Matrix3x4& VariantMapGetMatrix3x4 @ GetMatrix3x4(const String key);
  191. tolua_outside const Matrix4& VariantMapGetMatrix4 @ GetMatrix4(const String key);
  192. };
  193. ${
  194. static void VariantSetInt(Variant* variant, int value)
  195. {
  196. *variant = value;
  197. }
  198. static void VariantSetUint(Variant* variant, unsigned value)
  199. {
  200. *variant = value;
  201. }
  202. static void VariantSetStringHash(Variant* variant, const StringHash& value)
  203. {
  204. *variant = value;
  205. }
  206. static void VariantSetShortStringHash(Variant* variant, const ShortStringHash& value)
  207. {
  208. *variant = value;
  209. }
  210. static void VariantSetBool(Variant* variant, bool value)
  211. {
  212. *variant = value;
  213. }
  214. static void VariantSetFloat(Variant* variant, float value)
  215. {
  216. *variant = value;
  217. }
  218. static void VariantSetVector2(Variant* variant, const Vector2& value)
  219. {
  220. *variant = value;
  221. }
  222. static void VariantSetVector3(Variant* variant, const Vector3& value)
  223. {
  224. *variant = value;
  225. }
  226. static void VariantSetVector4(Variant* variant, const Vector4& value)
  227. {
  228. *variant = value;
  229. }
  230. static void VariantSetQuaternion(Variant* variant, const Quaternion& value)
  231. {
  232. *variant = value;
  233. }
  234. static void VariantSetColor(Variant* variant, const Color& value)
  235. {
  236. *variant = value;
  237. }
  238. static void VariantSetString(Variant* variant, const String value)
  239. {
  240. *variant = value;
  241. }
  242. static void VariantSetBuffer(Variant* variant, const VectorBuffer& value)
  243. {
  244. *variant == value.GetData();
  245. }
  246. static void VariantSetResourceRef(Variant* variant, const ResourceRef& value)
  247. {
  248. *variant = value;
  249. }
  250. static void VariantSetResourceRefList(Variant* variant, const ResourceRefList& value)
  251. {
  252. *variant = value;
  253. }
  254. static void VariantSetIntRect(Variant* variant, const IntRect& value)
  255. {
  256. *variant = value;
  257. }
  258. static void VariantSetIntVector2(Variant* variant, const IntVector2& value)
  259. {
  260. *variant = value;
  261. }
  262. static void VariantSetMatrix3(Variant* variant, const Matrix3& value)
  263. {
  264. *variant = value;
  265. }
  266. static void VariantSetMatrix3x4(Variant* variant, const Matrix3x4& value)
  267. {
  268. *variant = value;
  269. }
  270. static void VariantSetMatrix4(Variant* variant, const Matrix4& value)
  271. {
  272. *variant = value;
  273. }
  274. static VectorBuffer VariantGetBuffer(const Variant* variant)
  275. {
  276. return VectorBuffer(variant->GetBuffer());
  277. }
  278. static void VariantMapSetInt(VariantMap* vmap, const String& key, int value)
  279. {
  280. (*vmap)[ShortStringHash(key)] = value;
  281. }
  282. static void VariantMapSetUInt(VariantMap* vmap, const String& key, unsigned value)
  283. {
  284. (*vmap)[ShortStringHash(key)] = value;
  285. }
  286. static void VariantMapSetStringHash(VariantMap* vmap, const String& key, const StringHash& value)
  287. {
  288. (*vmap)[ShortStringHash(key)] = value;
  289. }
  290. static void VariantMapSetShortStringHash(VariantMap* vmap, const String& key, const ShortStringHash& value)
  291. {
  292. (*vmap)[ShortStringHash(key)] = value;
  293. }
  294. static void VariantMapSetBool(VariantMap* vmap, const String& key, bool value)
  295. {
  296. (*vmap)[ShortStringHash(key)] = value;
  297. }
  298. static void VariantMapSetFloat(VariantMap* vmap, const String& key, float value)
  299. {
  300. (*vmap)[ShortStringHash(key)] = value;
  301. }
  302. static void VariantMapSetVector2(VariantMap* vmap, const String& key, const Vector2& value)
  303. {
  304. (*vmap)[ShortStringHash(key)] = value;
  305. }
  306. static void VariantMapSetVector3(VariantMap* vmap, const String& key, const Vector3& value)
  307. {
  308. (*vmap)[ShortStringHash(key)] = value;
  309. }
  310. static void VariantMapSetVector4(VariantMap* vmap, const String& key, const Vector4& value)
  311. {
  312. (*vmap)[ShortStringHash(key)] = value;
  313. }
  314. static void VariantMapSetQuaternion(VariantMap* vmap, const String& key, const Quaternion& value)
  315. {
  316. (*vmap)[ShortStringHash(key)] = value;
  317. }
  318. static void VariantMapSetColor(VariantMap* vmap, const String& key, const Color& value)
  319. {
  320. (*vmap)[ShortStringHash(key)] = value;
  321. }
  322. static void VariantMapSetString(VariantMap* vmap, const String& key, const String& value)
  323. {
  324. (*vmap)[ShortStringHash(key)] = value;
  325. }
  326. static void VariantMapSetBuffer(VariantMap* vmap, const String& key, const VectorBuffer& value)
  327. {
  328. (*vmap)[ShortStringHash(key)] = value.GetData();
  329. }
  330. static void VariantMapSetResourceRef(VariantMap* vmap, const String& key, const ResourceRef& value)
  331. {
  332. (*vmap)[ShortStringHash(key)] = value;
  333. }
  334. static void VariantMapSetResourceRefList(VariantMap* vmap, const String& key, const ResourceRefList& value)
  335. {
  336. (*vmap)[ShortStringHash(key)] = value;
  337. }
  338. static void VariantMapSetIntRect(VariantMap* vmap, const String& key, const IntRect& value)
  339. {
  340. (*vmap)[ShortStringHash(key)] = value;
  341. }
  342. static void VariantMapSetIntVector2(VariantMap* vmap, const String& key, const IntVector2& value)
  343. {
  344. (*vmap)[ShortStringHash(key)] = value;
  345. }
  346. static void VariantMapSetPtr(VariantMap* vmap, const String& key, void* value)
  347. {
  348. (*vmap)[ShortStringHash(key)] = value;
  349. }
  350. static void VariantMapSetMatrix3(VariantMap* vmap, const String& key, const Matrix3& value)
  351. {
  352. (*vmap)[ShortStringHash(key)] = value;
  353. }
  354. static void VariantMapSetMatrix3x4(VariantMap* vmap, const String& key, const Matrix3x4& value)
  355. {
  356. (*vmap)[ShortStringHash(key)] = value;
  357. }
  358. static void VariantMapSetMatrix4(VariantMap* vmap, const String& key, const Matrix4& value)
  359. {
  360. (*vmap)[ShortStringHash(key)] = value;
  361. }
  362. static const Variant& FindVariant(const VariantMap* vmap, const String& key)
  363. {
  364. VariantMap::ConstIterator i = vmap->Find(ShortStringHash(key));
  365. return i != vmap->End() ? i->second_ : Variant::EMPTY;
  366. }
  367. static int VariantMapGetInt(const VariantMap* vmap, const String& key)
  368. {
  369. return FindVariant(vmap, key).GetInt();
  370. }
  371. static unsigned VariantMapGetUInt(const VariantMap* vmap, const String& key)
  372. {
  373. return FindVariant(vmap, key).GetUInt();
  374. }
  375. static StringHash VariantMapGetStringHash(const VariantMap* vmap, const String& key)
  376. {
  377. return FindVariant(vmap, key).GetStringHash();
  378. }
  379. static ShortStringHash VariantMapGetShortStringHash(const VariantMap* vmap, const String& key)
  380. {
  381. return FindVariant(vmap, key).GetShortStringHash();
  382. }
  383. static bool VariantMapGetBool(const VariantMap* vmap, const String& key)
  384. {
  385. return FindVariant(vmap, key).GetBool();
  386. }
  387. static float VariantMapGetFloat(const VariantMap* vmap, const String& key)
  388. {
  389. return FindVariant(vmap, key).GetFloat();
  390. }
  391. static const Vector2& VariantMapGetVector2(const VariantMap* vmap, const String& key)
  392. {
  393. return FindVariant(vmap, key).GetVector2();
  394. }
  395. static const Vector3& VariantMapGetVector3(const VariantMap* vmap, const String& key)
  396. {
  397. return FindVariant(vmap, key).GetVector3();
  398. }
  399. static const Vector4& VariantMapGetVector4(const VariantMap* vmap, const String& key)
  400. {
  401. return FindVariant(vmap, key).GetVector4();
  402. }
  403. static const Quaternion& VariantMapGetQuaternion(const VariantMap* vmap, const String& key)
  404. {
  405. return FindVariant(vmap, key).GetQuaternion();
  406. }
  407. static const Color& VariantMapGetColor(const VariantMap* vmap, const String& key)
  408. {
  409. return FindVariant(vmap, key).GetColor();
  410. }
  411. static const String& VariantMapGetString(const VariantMap* vmap, const String& key)
  412. {
  413. return FindVariant(vmap, key).GetString();
  414. }
  415. static VectorBuffer VariantMapGetBuffer(const VariantMap* vmap, const String key)
  416. {
  417. const PODVector<unsigned char>& buffer = FindVariant(vmap, key).GetBuffer();
  418. return VectorBuffer(buffer);
  419. }
  420. static const ResourceRef& VariantMapGetResourceRef(const VariantMap* vmap, const String& key)
  421. {
  422. return FindVariant(vmap, key).GetResourceRef();
  423. }
  424. static const ResourceRefList& VariantMapGetResourceRefList(const VariantMap* vmap, const String& key)
  425. {
  426. return FindVariant(vmap, key).GetResourceRefList();
  427. }
  428. static const IntRect& VariantMapGetIntRect(const VariantMap* vmap, const String& key)
  429. {
  430. return FindVariant(vmap, key).GetIntRect();
  431. }
  432. static const IntVector2& VariantMapGetIntVector2(const VariantMap* vmap, const String& key)
  433. {
  434. return FindVariant(vmap, key).GetIntVector2();
  435. }
  436. static const Matrix3& VariantMapGetMatrix3(const VariantMap* vmap, const String& key)
  437. {
  438. return FindVariant(vmap, key).GetMatrix3();
  439. }
  440. static const Matrix3x4& VariantMapGetMatrix3x4(const VariantMap* vmap, const String& key)
  441. {
  442. return FindVariant(vmap, key).GetMatrix3x4();
  443. }
  444. static const Matrix4& VariantMapGetMatrix4(const VariantMap* vmap, const String& key)
  445. {
  446. return FindVariant(vmap, key).GetMatrix4();
  447. }
  448. #define TOLUA_DISABLE_tolua_CoreLuaAPI_VariantMap_SetPtr00
  449. static int tolua_CoreLuaAPI_VariantMap_SetPtr00(lua_State* tolua_S)
  450. {
  451. #ifndef TOLUA_RELEASE
  452. tolua_Error tolua_err;
  453. if (
  454. !tolua_isusertype(tolua_S,1,"VariantMap",0,&tolua_err) ||
  455. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  456. !tolua_isuserdata(tolua_S,3,0,&tolua_err) ||
  457. !tolua_isnoobj(tolua_S,4,&tolua_err)
  458. )
  459. goto tolua_lerror;
  460. else
  461. #endif
  462. {
  463. VariantMap* self = (VariantMap*) tolua_tousertype(tolua_S,1,0);
  464. const String key = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  465. void* value = ((void*) tolua_tousertype(tolua_S,3,0));
  466. #ifndef TOLUA_RELEASE
  467. if (!self) tolua_error(tolua_S,"invalid 'self' in function 'VariantMapSetPtr'", NULL);
  468. #endif
  469. {
  470. VariantMapSetPtr(self,key,value);
  471. }
  472. }
  473. return 0;
  474. #ifndef TOLUA_RELEASE
  475. tolua_lerror:
  476. tolua_error(tolua_S,"#ferror in function 'SetPtr'.",&tolua_err);
  477. return 0;
  478. #endif
  479. }
  480. #define TOLUA_DISABLE_tolua_CoreLuaAPI_VariantMap_GetPtr00
  481. static int tolua_CoreLuaAPI_VariantMap_GetPtr00(lua_State* tolua_S)
  482. {
  483. #ifndef TOLUA_RELEASE
  484. tolua_Error tolua_err;
  485. if (!tolua_isusertype(tolua_S,1,"VariantMap",0,&tolua_err) ||
  486. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  487. !tolua_isurho3dstring(tolua_S,3,0,&tolua_err) ||
  488. !tolua_isnoobj(tolua_S,4,&tolua_err))
  489. goto tolua_lerror;
  490. else
  491. #endif
  492. {
  493. VariantMap* self = (VariantMap*) tolua_tousertype(tolua_S,1,0);
  494. const String type = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  495. const String key = ((const String) tolua_tourho3dstring(tolua_S,3,0));
  496. #ifndef TOLUA_RELEASE
  497. if (!self) tolua_error(tolua_S,"invalid 'self' in function 'VariantMapGetPtr'", NULL);
  498. #endif
  499. {
  500. void* tolua_ret = (void*)FindVariant(self, key).GetVoidPtr();
  501. tolua_pushusertype(tolua_S,tolua_ret, type.CString());
  502. }
  503. }
  504. return 1;
  505. #ifndef TOLUA_RELEASE
  506. tolua_lerror:
  507. tolua_error(tolua_S,"#ferror in function 'GetPtr'.",&tolua_err);
  508. return 0;
  509. #endif
  510. }
  511. $}