autowrap icon indicating copy to clipboard operation
autowrap copied to clipboard

Can't get == to work

Open DangerMouseB opened this issue 3 years ago • 2 comments

Hi Atila, I've pared this right down:

ex.d:

module ex;
export struct Ex{
    int id;
}
export bool exEquals(Ex exA, Ex exB) {return exA == exB;}

app.d:

import autowrap.python;
mixin(
    wrapAll(
        LibraryName("_bits"),
        Modules(
            "ex"
        )
    )
);

dub.sdl:

name "_bits"
targetType "dynamicLibrary"

configuration "osx" {
    dependency "autowrap:python" path=".../repos/github/symmetryinvestments/autowrap"
    platforms "osx"
    subConfiguration "autowrap:python" "env"             // the python38 configuration doesn't work for me
}

buildType "debug" {
    postBuildCommands "mv lib_bits.dylib _bits.so" platform="osx"
    preBuildCommands "rm -f lib_bits.dylib" platform="osx"
    preBuildCommands "rm -f _bits.so" platform="osx"
}

test_ex.py

from _bits import Ex, exEquals

print(Ex(1) == Ex(1))
print(exEquals(Ex(1), Ex(1)))

% python3 test_ex.py False True

I've tried adding opEquals to the struct. I had a quick look through the autowrap code and couldn't see opEquals anywhere though did find some occurrences of opCmp.

Could you double check if it's missing?

I'm on macos (the latest) + using autowrap cloned from github + dub --version -> DUB version 1.23.0, built on Sep 22 2020.

DangerMouseB avatar Oct 21 '20 20:10 DangerMouseB

I don't see how to get it to work with the default pyd backend of autowrap (which is what autowrap:python is under the covers). I've looked at the docs and I think the only way out there is to define opCmp. A workaround is to use the pynih backend after #270 gets merged.

atilaneves avatar Oct 27 '20 19:10 atilaneves

Understood, thank you.

DangerMouseB avatar Nov 03 '20 14:11 DangerMouseB