PackageFile.pkg 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. $#include "IO/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 GetTotalDataSize() const;
  22. unsigned GetChecksum() const;
  23. bool IsCompressed() const;
  24. tolua_readonly tolua_property__get_set String name;
  25. tolua_readonly tolua_property__get_set StringHash nameHash;
  26. tolua_readonly tolua_property__get_set unsigned numFiles;
  27. tolua_readonly tolua_property__get_set unsigned totalSize;
  28. tolua_readonly tolua_property__get_set unsigned totalDataSize;
  29. tolua_readonly tolua_property__get_set unsigned checksum;
  30. tolua_readonly tolua_property__is_set bool compressed;
  31. };
  32. ${
  33. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new00
  34. static int tolua_IOLuaAPI_PackageFile_new00(lua_State* tolua_S)
  35. {
  36. return ToluaNewObject<PackageFile>(tolua_S);
  37. }
  38. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new00_local
  39. static int tolua_IOLuaAPI_PackageFile_new00_local(lua_State* tolua_S)
  40. {
  41. return ToluaNewObjectGC<PackageFile>(tolua_S);
  42. }
  43. /* method: new of class PackageFile */
  44. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new01
  45. static int tolua_IOLuaAPI_PackageFile_new01(lua_State* tolua_S)
  46. {
  47. tolua_Error tolua_err;
  48. if (
  49. !tolua_isusertable(tolua_S,1,"PackageFile",0,&tolua_err) ||
  50. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  51. !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
  52. !tolua_isnoobj(tolua_S,4,&tolua_err)
  53. )
  54. goto tolua_lerror;
  55. else
  56. {
  57. const String fileName = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  58. unsigned startOffset = ((unsigned) tolua_tonumber(tolua_S,3,0));
  59. {
  60. PackageFile* tolua_ret = (PackageFile*) Mtolua_new((PackageFile)(GetContext(tolua_S),fileName,startOffset));
  61. tolua_pushusertype(tolua_S,(void*)tolua_ret,"PackageFile");
  62. }
  63. }
  64. return 1;
  65. tolua_lerror:
  66. return tolua_IOLuaAPI_PackageFile_new00(tolua_S);
  67. }
  68. /* method: new_local of class PackageFile */
  69. #define TOLUA_DISABLE_tolua_IOLuaAPI_PackageFile_new01_local
  70. static int tolua_IOLuaAPI_PackageFile_new01_local(lua_State* tolua_S)
  71. {
  72. tolua_Error tolua_err;
  73. if (
  74. !tolua_isusertable(tolua_S,1,"PackageFile",0,&tolua_err) ||
  75. !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
  76. !tolua_isnumber(tolua_S,3,1,&tolua_err) ||
  77. !tolua_isnoobj(tolua_S,4,&tolua_err)
  78. )
  79. goto tolua_lerror;
  80. else
  81. {
  82. const String fileName = ((const String) tolua_tourho3dstring(tolua_S,2,0));
  83. unsigned startOffset = ((unsigned) tolua_tonumber(tolua_S,3,0));
  84. {
  85. PackageFile* tolua_ret = (PackageFile*) Mtolua_new((PackageFile)(GetContext(tolua_S),fileName,startOffset));
  86. tolua_pushusertype(tolua_S,(void*)tolua_ret,"PackageFile");
  87. tolua_register_gc(tolua_S,lua_gettop(tolua_S));
  88. }
  89. }
  90. return 1;
  91. tolua_lerror:
  92. return tolua_IOLuaAPI_PackageFile_new00_local(tolua_S);
  93. }
  94. $}