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

Commit219ef33

Browse files
committed
Fix GetResourceInfo
1 parent9767b26 commit219ef33

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

‎Jamfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ local sourceFiles =
194194
Query.cpp
195195
NodeMonitor.cpp
196196
NodeInfo.cpp
197+
#DiskDeviceDefs.cpp
197198
#FilePanel.cpp
198199
;
199200

‎bindings/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
from .Queryimport*
9696
from .NodeMonitorimport*
9797
from .NodeInfoimport*
98-
98+
#from .DiskDeviceDefs import *
9999
#from .FilePanel import *
100100

101101
_BWindow=BWindow

‎bindings/storage/Resources.cpp‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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+
/*
1415
std::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

2526
PYBIND11_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,constchar *>(&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+
constchar * 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+
returnpy::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){
5582
type_code typeFound;
5683
int32 idFound;
5784
const char * nameFound;
5885
//std::vector<char *> nameFound;
5986
size_t lengthFound;
6087
bool result = self.GetResourceInfo(byIndex, &typeFound, &idFound, &nameFound, &lengthFound);
61-
std::vector<char*> charPtrVector =convertConstCharPtrArray(&nameFound, lengthFound);
62-
returnpy::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,constchar *, int32*,size_t *>(&BResources::GetResourceInfo),"",py::arg("byType"),py::arg("andName"),py::arg("idFound"),py::arg("lengthFound"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp