PackageFile.pkg 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. $#include "PackageFile.h"
  2. struct PackageEntry
  3. {
  4. unsigned offset_ @ offset;
  5. unsigned size_ @ size;
  6. unsigned checksum_ @ checksum;
  7. };
  8. class PackageFile : public Object
  9. {
  10. PackageFile();
  11. PackageFile(const String fileName, unsigned startOffset = 0);
  12. ~PackageFile();
  13. bool Open(const String fileName, unsigned startOffset = 0);
  14. bool Exists(const String fileName) const;
  15. const PackageEntry* GetEntry(const String fileName) const;
  16. const HashMap<String, PackageEntry>& GetEntries() const;
  17. const String GetName() const;
  18. StringHash GetNameHash() const;
  19. unsigned GetNumFiles() const;
  20. unsigned GetTotalSize() const;
  21. unsigned GetChecksum() const;
  22. bool IsCompressed() const;
  23. tolua_readonly tolua_property__get_set String name;
  24. tolua_readonly tolua_property__get_set StringHash nameHash;
  25. tolua_readonly tolua_property__get_set unsigned numFiles;
  26. tolua_readonly tolua_property__get_set unsigned totalSize;
  27. tolua_readonly tolua_property__get_set unsigned checksum;
  28. tolua_readonly tolua_property__is_set bool compressed;
  29. };
  30. ${
  31. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new00
  32. static int tolua_IOLuaAPI_PackageFile_new00(lua_State* tolua_S)
  33. {
  34. return ToluaNewObject<PackageFile>(tolua_S);
  35. }
  36. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new00_local
  37. static int tolua_IOLuaAPI_PackageFile_new00_local(lua_State* tolua_S)
  38. {
  39. return ToluaNewObjectGC<PackageFile>(tolua_S);
  40. }
  41. /* method: new of class PackageFile */
  42. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new01
  43. static int tolua_IOLuaAPI_PackageFile_new01(lua_State* tolua_S)
  44. {
  45. tolua_Error tolua_err;
  46. if (
  47. !tolua_isusertable(tolua_S,1,"PackageFile",0,&tolua_err) ||
  48. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  49. !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
  50. !tolua_isnoobj(tolua_S,4,&tolua_err)
  51. )
  52. goto tolua_lerror;
  53. else
  54. {
  55. const String fileName = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  56. unsigned startOffset = ((unsigned) tolua_tonumber(tolua_S,3,0));
  57. {
  58. PackageFile* tolua_ret = (PackageFile*) Mtolua_new((PackageFile)(GetContext(tolua_S),fileName,startOffset));
  59. tolua_pushusertype(tolua_S,(void*)tolua_ret,"PackageFile");
  60. }
  61. }
  62. return 1;
  63. tolua_lerror:
  64. return tolua_IOLuaAPI_PackageFile_new00(tolua_S);
  65. }
  66. /* method: new_local of class PackageFile */
  67. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new01_local
  68. static int tolua_IOLuaAPI_PackageFile_new01_local(lua_State* tolua_S)
  69. {
  70. tolua_Error tolua_err;
  71. if (
  72. !tolua_isusertable(tolua_S,1,"PackageFile",0,&tolua_err) ||
  73. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  74. !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
  75. !tolua_isnoobj(tolua_S,4,&tolua_err)
  76. )
  77. goto tolua_lerror;
  78. else
  79. {
  80. const String fileName = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  81. unsigned startOffset = ((unsigned) tolua_tonumber(tolua_S,3,0));
  82. {
  83. PackageFile* tolua_ret = (PackageFile*) Mtolua_new((PackageFile)(GetContext(tolua_S),fileName,startOffset));
  84. tolua_pushusertype(tolua_S,(void*)tolua_ret,"PackageFile");
  85. tolua_register_gc(tolua_S,lua_gettop(tolua_S));
  86. }
  87. }
  88. return 1;
  89. tolua_lerror:
  90. return tolua_IOLuaAPI_PackageFile_new00_local(tolua_S);
  91. }
  92. $}