Pyd: Stackthreads and returning arrays from D
Simen Haugen
simen at norstat.no
Wed Jun 27 02:45:34 PDT 2007
Thats not the problem. If I change the test to use a getter method instead,
the same error occurs.
import pyd.pyd;
class Item {
}
class Container {
private:
Item[] _items;
public:
Item[] getItems() {
return _items;
}
}
extern(C) void PydMain() {
module_init();
wrap_class!(Item);
wrap_class!(
Container,
Def!(Container.getItems)
);
}
The same error:
running build
running build_ext
building 'test' extension
sources: ['test.d', 'python.d', 'class_wrap.d', 'ctor_wrap.d', 'def.d',
'dg_con
vert.d', 'exception.d', 'func_wrap.d', 'lib_abstract.d', 'make_object.d',
'make_
wrapper.d', 'op_wrap.d', 'pyd.d', 'pydobject.d', 'struct_wrap.d',
'pydmain.d', '
Default.d', 'Demangle.d', 'Nameof.d', 'Util.d',
'python_dll_windows_boilerplate.
d']
c:\d\dmd\bin\dmd.exe -c -version=Python_2_4_Or_Later -version=Python_Unicode_UCS
2 -debug -IC:\Python24\lib\site-packages\celerid\infrastructure\python\2.4 -IC:\
Python24\lib\site-packages\celerid\infrastructure -ofbuild\temp.win32-2.4\Releas
e\project\test.obj test.d
wrap_class: Item
class wrapper : T {
mixin OverloadShim;
}
wrap_class: Container
class wrapper : T {
mixin OverloadShim;
alias Params[0] __pyd_p0;
ReturnType!(__pyd_p0.func_t)
getItems(ParameterTypeTuple!(__pyd_p0.func_t) t
) {
return __pyd_get_overload!("getItems",
__pyd_p0.func_t).func("getItems",
t);
}
}
C:\Python24\lib\site-packages\celerid\infrastructure\pyd\make_object.d(228):
fun
ction pyd.make_object.d_type!(Item[]).d_type expected to return a value of
type
Item[]
C:\Python24\lib\site-packages\celerid\infrastructure\pyd\make_object.d(289):
tem
plate instance pyd.make_object.d_type!(Item[]) error instantiating
C:\Python24\lib\site-packages\celerid\infrastructure\pyd\func_wrap.d(274):
templ
ate instance pyd.func_wrap.PydWrappedFunc.fn!(Item[]) error instantiating
C:\Python24\lib\site-packages\celerid\infrastructure\pyd\func_wrap.d(264):
templ
ate instance pyd.func_wrap._pycallable_asdgT!(Item[] delegate(())) error
instant
iating
error: command 'c:\d\dmd\bin\dmd.exe' failed with exit status 1
"Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message
news:f5tar1$2u2p$1 at digitalmars.com...
> Simen Haugen wrote:
>> Ok, I just cannot get it to work..
>> Look at this simple example:
>>
>> import pyd.pyd;
>>
>>
>> class Item {
>> }
>>
>>
>> class Container {
>> private:
>> Item[] _items;
>>
>> public:
>> Item[] items() {
>> return _items;
>> }
>>
>> void items(Item[] items) {
>> _items = items;
>> }
>
> Try:
> Item[] items(Item[] items) {
> return _items = items;
> }
>
>> }
>>
>>
>> extern(C) void PydMain() {
>> module_init();
>>
>> wrap_class!(Item);
>>
>> wrap_class!(
>> Container,
>> Property!(Container.items)
>> );
>> }
>>
>> When trying to compile this I get an error "expected to return a value of
>> type Item[]" for the Container.items property:
> [snip]
>> When I used stackthreads I had no problem returning array of classes.
>
> I think the error message was for the second method (the setter) which
> *didn't* return an Item[] as was expected.
> So if I'm correct your only problem with returning an array of classes was
> forgetting to do so :P (in the setter).
More information about the Digitalmars-d
mailing list