Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78ada85

Browse files
committed
comments to evaluate
1 parente1622f5 commit78ada85

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

‎bindings/storage/Resources.cpp‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,44 @@ py::class_<BResources>(m, "BResources")
4242
.def("Unset", &BResources::Unset,"")
4343
.def("InitCheck", &BResources::InitCheck,"")
4444
.def("File", &BResources::File,"")
45-
.def("LoadResource", py::overload_cast<type_code, int32,size_t *>(&BResources::LoadResource),"",py::arg("type"),py::arg("id"),py::arg("_size"))
46-
.def("LoadResource", py::overload_cast<type_code,constchar *,size_t *>(&BResources::LoadResource),"",py::arg("type"),py::arg("name"),py::arg("_size"))
45+
.def("LoadResource", py::overload_cast<type_code, int32,size_t *>(&BResources::LoadResource),"",py::arg("type"),py::arg("id"),py::arg("_size"))// should we keep these 2 functions? they return const void *
46+
.def("LoadResource", py::overload_cast<type_code,constchar *,size_t *>(&BResources::LoadResource),"",py::arg("type"),py::arg("name"),py::arg("_size"))//
4747
.def("PreloadResourceType", &BResources::PreloadResourceType,"",py::arg("type")=0)
4848
.def("Sync", &BResources::Sync,"")
4949
.def("MergeFrom", &BResources::MergeFrom,"",py::arg("fromFile"))
5050
.def("WriteTo", &BResources::WriteTo,"",py::arg("file"))
51-
.def("AddResource", &BResources::AddResource,"",py::arg("type"),py::arg("id"),py::arg("data"),py::arg("length"),py::arg("name")=NULL)
51+
.def("AddResource", &BResources::AddResource,"",py::arg("type"),py::arg("id"),py::arg("data"),py::arg("length"),py::arg("name")=NULL)// to change <- cannot pass void* data from python
5252
.def("HasResource", py::overload_cast<type_code, int32>(&BResources::HasResource),"",py::arg("type"),py::arg("id"))
5353
.def("HasResource", py::overload_cast<type_code,constchar *>(&BResources::HasResource),"",py::arg("type"),py::arg("name"))
5454
//.def("GetResourceInfo", py::overload_cast<int32, type_code *, int32*, const char * *, size_t *>(&BResources::GetResourceInfo), "", py::arg("byIndex"), py::arg("typeFound"), py::arg("idFound"), py::arg("nameFound"), py::arg("lengthFound"))
55+
/*.def("GetResourceInfo", [](BResources& self, int32 byIndex) {
56+
type_code typeFound;
57+
int32 idFound;
58+
const char* nameFound;
59+
size_t lengthFound;
60+
bool result = self.GetResourceInfo(byIndex, &typeFound, &idFound, &nameFound, &lengthFound);
61+
62+
// Creare una lista Python per contenere i risultati
63+
py::list resultList;
64+
65+
// Iterare attraverso i dati restituiti estrarre ciascun blocco
66+
size_t currentIndex = 0;
67+
while (currentIndex < lengthFound) {
68+
// Trova la lunghezza del blocco corrente
69+
size_t currentBlockLength = strlen(nameFound + currentIndex);
70+
71+
// Estrai il blocco corrente
72+
std::string currentBlock(nameFound + currentIndex, currentBlockLength);
73+
74+
// Aggiungi il blocco alla lista Python
75+
resultList.append(py::bytes(currentBlock));
76+
77+
// Passa al prossimo blocco
78+
currentIndex += currentBlockLength + 1; // +1 per includere il terminatore nullo
79+
}
80+
81+
return py::make_tuple(result, static_cast<int>(typeFound), idFound, resultList);
82+
}, "", py::arg("byIndex"))*/
5583
.def("GetResourceInfo", [](BResources& self, int32 byIndex){
5684
type_code typeFound;
5785
int32 idFound;
@@ -63,7 +91,6 @@ py::class_<BResources>(m, "BResources")
6391

6492
returnpy::make_tuple(result,static_cast<int>(typeFound), idFound, byteSequence, lengthFound);
6593
},"",py::arg("byIndex"))//<- this works
66-
6794
//.def("GetResourceInfo", py::overload_cast<type_code, int32, int32*, const char * *, size_t *>(&BResources::GetResourceInfo), "", py::arg("byType"), py::arg("andIndex"), py::arg("idFound"), py::arg("nameFound"), py::arg("lengthFound"))
6895
.def("GetResourceInfo_byTypeAndIndex", [](BResources& self, type_code byType, int32 andIndex){
6996
int32 idFound;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp