22#include < pybind11/stl.h>
33#include < pybind11/iostream.h>
44#include < pybind11/operators.h>
5+ // #include <pybind11/numpy.h>
56
67#include < Resources.h>
78
@@ -10,7 +11,7 @@ namespace py = pybind11;
1011// using namespace BPrivate::Storage;
1112// using namespace BPrivate::Storage::Mime;
1213// using namespace BPackageKit;
13-
14+ /*
1415std::vector<char*> convertConstCharPtrArray(const char** constCharPtrArray, std::size_t size) {
1516 std::vector<char*> charPtrVector;
1617
@@ -20,7 +21,7 @@ std::vector<char*> convertConstCharPtrArray(const char** constCharPtrArray, std:
2021 }
2122
2223 return charPtrVector;
23- }
24+ }*/
2425
2526PYBIND11_MODULE (Resources, m)
2627{
@@ -51,16 +52,44 @@ py::class_<BResources>(m, "BResources")
5152.def (" HasResource" , py::overload_cast<type_code, int32>(&BResources::HasResource)," " ,py::arg (" type" ),py::arg (" id" ))
5253.def (" HasResource" , py::overload_cast<type_code,const char *>(&BResources::HasResource)," " ,py::arg (" type" ),py::arg (" name" ))
5354// .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+ // Utilizza py::bytes per rappresentare la sequenza di byte
63+ py::bytesbyteSequence (nameFound, lengthFound);
64+
65+ return py::make_tuple (result,static_cast <int >(typeFound), idFound, byteSequence, lengthFound);
66+ }," " ,py::arg (" byIndex" ))
67+ /*
68+ .def("GetResourceInfo", [](BResources& self, int32 byIndex){
69+ type_code typeFound;
70+ int32 idFound;
71+ const char * nameFound;
72+ size_t lengthFound;
73+ bool result = self.GetResourceInfo(byIndex, &typeFound, &idFound, &nameFound, &lengthFound);
74+
75+ // Utilizza py::str per rappresentare la stringa in Python
76+ py::str pythonString(nameFound, lengthFound);
77+
78+ return py::make_tuple(result, static_cast<int>(typeFound), idFound, pythonString, lengthFound);
79+ }, "", py::arg("byIndex"))*/
80+ /*
5481.def("GetResourceInfo", [](BResources& self, int32 byIndex){
5582type_code typeFound;
5683int32 idFound;
5784const char * nameFound;
5885//std::vector<char *> nameFound;
5986size_t lengthFound;
6087bool result = self.GetResourceInfo(byIndex, &typeFound, &idFound, &nameFound, &lengthFound);
61- std::vector<char *> charPtrVector =convertConstCharPtrArray (&nameFound, lengthFound);
62- return py::make_tuple (result, typeFound, idFound, charPtrVector, lengthFound);
63- }," " ,py::arg (" byIndex" ))
88+ py::array_t<const char> array = py::array_t<const char>({static_cast<ssize_t>(lengthFound)}, {sizeof(const char)}, nameFound);
89+ return py::make_tuple(result, typeFound, idFound, array, lengthFound);
90+ //std::vector<char*> charPtrVector = convertConstCharPtrArray(&nameFound, lengthFound);
91+ //return py::make_tuple(result, typeFound, idFound, charPtrVector, lengthFound);
92+ }, "", py::arg("byIndex"))*/
6493// .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"))
6594// .def("GetResourceInfo", py::overload_cast<type_code, int32, const char * *, size_t *>(&BResources::GetResourceInfo), "", py::arg("byType"), py::arg("andID"), py::arg("nameFound"), py::arg("lengthFound"))
6695.def (" GetResourceInfo" , py::overload_cast<type_code,const char *, int32*,size_t *>(&BResources::GetResourceInfo)," " ,py::arg (" byType" ),py::arg (" andName" ),py::arg (" idFound" ),py::arg (" lengthFound" ))