Manual_Resource.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Resource/ResourceCache.h"
  24. #include "../IO/PackageFile.h"
  25. namespace Urho3D
  26. {
  27. // bool Resource::Load(Deserializer &source) | File: ../Resource/Resource.h
  28. bool ResourceLoad(File* file, Resource* ptr);
  29. // bool Resource::Load(Deserializer &source) | File: ../Resource/Resource.h
  30. bool ResourceLoadVectorBuffer(VectorBuffer& buffer, Resource* ptr);
  31. // virtual bool Resource::Save(Serializer &dest) const | File: ../Resource/Resource.h
  32. bool ResourceSave(File* file, Resource* ptr);
  33. // virtual bool Resource::Save(Serializer &dest) const | File: ../Resource/Resource.h
  34. bool ResourceSaveVectorBuffer(VectorBuffer& buffer, Resource* ptr);
  35. // TODO bool Load(File@+), bool Load(VectorBuffer&) наверно не нужны, когда есть Lead(Deserializer) - зарегать как дочерний класс если вомзожно
  36. #define REGISTER_MANUAL_PART_Resource(T, className) \
  37. /* bool Resource::Load(Deserializer &source) | File: ../Resource/Resource.h */ \
  38. engine->RegisterObjectMethod(className, "bool Load(File@+)", asFUNCTION(ResourceLoad), asCALL_CDECL_OBJLAST); \
  39. /* bool Resource::Load(Deserializer &source) | File: ../Resource/Resource.h */ \
  40. engine->RegisterObjectMethod(className, "bool Load(VectorBuffer&)", asFUNCTION(ResourceLoadVectorBuffer), asCALL_CDECL_OBJLAST); \
  41. /* virtual bool Resource::Save(Serializer &dest) const | File: ../Resource/Resource.h */ \
  42. engine->RegisterObjectMethod(className, "bool Save(File@+) const", asFUNCTION(ResourceSave), asCALL_CDECL_OBJLAST); \
  43. /* virtual bool Resource::Save(Serializer &dest) const | File: ../Resource/Resource.h */ \
  44. engine->RegisterObjectMethod(className, "bool Save(VectorBuffer&) const", asFUNCTION(ResourceSaveVectorBuffer), asCALL_CDECL_OBJLAST);
  45. // ========================================================================================
  46. #define REGISTER_MANUAL_PART_XPathQuery(T, className) \
  47. /* bool XPathQuery::SetQuery(const String &queryString, const String &variableString=String::EMPTY, bool bind=true) | File: ../Resource/XMLElement.h */ \
  48. /* TODO Is need wrapping function? */ \
  49. engine->RegisterObjectMethod(className, "void set_query(const String&)", asMETHOD(T, SetQuery), asCALL_THISCALL);
  50. // ========================================================================================
  51. // XMLElement XMLFile::GetRoot(const String &name=String::EMPTY) | File: ../Resource/XMLFile.h
  52. XMLElement XMLFileGetRootDefault(XMLFile* ptr);
  53. #define REGISTER_MANUAL_PART_XMLFile(T, className) \
  54. /* XMLElement XMLFile::GetRoot(const String &name=String::EMPTY) | File: ../Resource/XMLFile.h */ \
  55. engine->RegisterObjectMethod(className, "XMLElement get_root()", asFUNCTION(XMLFileGetRootDefault), asCALL_CDECL_OBJLAST);
  56. // ========================================================================================
  57. // bool XMLElement::SetVariantVector(const VariantVector &value) | File: ../Resource/XMLElement.h
  58. bool XMLElementSetVariantVector(CScriptArray* value, XMLElement* ptr);
  59. // VariantVector XMLElement::GetVariantVector() const | File: ../Resource/XMLElement.h
  60. CScriptArray* XMLElementGetVariantVector(XMLElement* ptr);
  61. #define REGISTER_MANUAL_PART_XMLElement(T, className) \
  62. /* XMLElement XMLElement::SelectSingle(const String &query, pugi::xpath_variable_set *variables=nullptr) const | File: ../Resource/XMLElement.h */ \
  63. engine->RegisterObjectMethod(className, "XMLElement SelectSingle(const String&in)", asMETHOD(T, SelectSingle), asCALL_THISCALL); \
  64. /* XPathResultSet XMLElement::Select(const String &query, pugi::xpath_variable_set *variables=nullptr) const | File: ../Resource/XMLElement.h */ \
  65. engine->RegisterObjectMethod(className, "XPathResultSet Select(const String&in)", asMETHOD(T, Select), asCALL_THISCALL); \
  66. /* bool XMLElement::SetVariantVector(const VariantVector &value) | File: ../Resource/XMLElement.h */ \
  67. engine->RegisterObjectMethod(className, "bool SetVariantVector(Array<Variant>@+)", asFUNCTION(XMLElementSetVariantVector), asCALL_CDECL_OBJLAST); \
  68. /* VariantVector XMLElement::GetVariantVector() const | File: ../Resource/XMLElement.h */ \
  69. engine->RegisterObjectMethod(className, "Array<Variant>@ GetVariantVector() const", asFUNCTION(XMLElementGetVariantVector), asCALL_CDECL_OBJLAST);
  70. // ========================================================================================
  71. // void ResourceCache::GetResources(PODVector< Resource * > &result, StringHash type) const | File: ../Resource/ResourceCache.h
  72. CScriptArray* ResourceCacheGetResources(StringHash type, ResourceCache* ptr);
  73. #define REGISTER_MANUAL_PART_ResourceCache(T, className) \
  74. /* void ResourceCache::GetResources(PODVector< Resource * > &result, StringHash type) const | File: ../Resource/ResourceCache.h */ \
  75. engine->RegisterObjectMethod(className, "Array<Resource@>@ GetResources(StringHash)", asFUNCTION(ResourceCacheGetResources), asCALL_CDECL_OBJLAST);
  76. // ========================================================================================
  77. // void JSONValue::SetVariant(const Variant &variant, Context *context=nullptr) | File: ../Resource/JSONValue.h
  78. void JSONValueSetVariant(const Variant& variant, JSONValue& jsonValue);
  79. // void JSONValue::SetVariantMap(const VariantMap &variantMap, Context *context=nullptr) | File: ../Resource/JSONValue.h
  80. void JSONValueSetVariantMap(const VariantMap& variantMap, JSONValue& jsonValue);
  81. CScriptArray* JSONValueGetKeys(const JSONValue& jsonValue);
  82. CScriptArray* JSONValueGetValues(const JSONValue& jsonValue);
  83. #define REGISTER_MANUAL_PART_JSONValue(T, className) \
  84. engine->RegisterObjectMethod(className, "Array<String>@ get_keys() const", asFUNCTION(JSONValueGetKeys), asCALL_CDECL_OBJLAST); \
  85. engine->RegisterObjectMethod(className, "Array<JSONValue>@ get_values() const", asFUNCTION(JSONValueGetValues), asCALL_CDECL_OBJLAST); \
  86. /* void JSONValue::SetVariant(const Variant &variant, Context *context=nullptr) | File: ../Resource/JSONValue.h */ \
  87. engine->RegisterObjectMethod(className, "void SetVariant(const Variant&in)", asFUNCTION(JSONValueSetVariant), asCALL_CDECL_OBJLAST); \
  88. /* void JSONValue::SetVariantMap(const VariantMap &variantMap, Context *context=nullptr) | File: ../Resource/JSONValue.h */ \
  89. engine->RegisterObjectMethod(className, "void SetVariantMap(const VariantMap&in)", asFUNCTION(JSONValueSetVariantMap), asCALL_CDECL_OBJLAST);
  90. }