Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add complex class test #143

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,57 @@
"Python_3_8_Or_Later"
]
},
{
"name": "python39",
"libs-windows-x86-dmd": [
"$PYD_PACKAGE_DIR\\infrastructure\\windows\\python39_digitalmars"
],
"libs-windows-x86_mscoff": [
"python39"
],
"libs-windows-x86-ldc": [
"python39"
],
"libs-windows-x86_64": [
"python39"
],
"libs-posix": [
"python3.9"
],
"lflags-windows-x86_64-ldc": [
"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python39\\libs",
"/LIBPATH:C:\\Program Files\\Python39\\libs"
],
"lflags-windows-x86-ldc": [
"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python39-32\\libs",
"/LIBPATH:C:\\Program Files (x86)\\Python39-32\\libs"
],
"lflags-windows-x86_64-dmd": [
"\\\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python39\\libs\\\"",
"\\\"/LIBPATH:C:\\Program Files\\Python39\\libs\\\""
],
"lflags-windows-x86_mscoff-dmd": [
"\\\"/LIBPATH:$USERPROFILE\\AppData\\Local\\Programs\\Python\\Python39-32\\libs\\\"",
"\\\"/LIBPATH:C:\\Program Files (x86)\\Python39-32\\libs\\\""
],

"versions": [
"Python_2_4_Or_Later",
"Python_2_5_Or_Later",
"Python_2_6_Or_Later",
"Python_2_7_Or_Later",
"Python_3_0_Or_Later",
"Python_3_1_Or_Later",
"Python_3_2_Or_Later",
"Python_3_3_Or_Later",
"Python_3_4_Or_Later",
"Python_3_5_Or_Later",
"Python_3_6_Or_Later",
"Python_3_7_Or_Later",
"Python_3_8_Or_Later",
"Python_3_9_Or_Later"
]
},
{
"name": "env",
"versions": [
Expand Down
10 changes: 7 additions & 3 deletions examples/dub/simple_embedded/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
"targetType": "executable",
"dflags-posix-dmd": ["-defaultlib=libphobos2.so"],
"dependencies": {
"pyd": "~>0.13.0",
"pyd": "~>0.14.0",
},
"subConfigurations": {
"pyd": "python27",
}
"pyd": "python38",
},
"lflags-linux": [
"-L/home/zhou/anaconda3/lib",
"-lpython3.8"
]
}
6 changes: 6 additions & 0 deletions examples/dub/simple_embedded/source/c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

c = complex(2,-1)
h = c.__hash__();

print(c)
print(h)
16 changes: 12 additions & 4 deletions examples/dub/simple_embedded/source/hello.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ shared static this() {

void main() {
writeln(py_eval!string("'1 + %s' % 2"));
}




auto c = py_eval("complex(2,-1)");
/* https://github.com/ariovistus/pyd/pull/143#issuecomment-748557221
there is no way to get opDispatch to distinguish between obj.property and obj.property().
So we have this kind of compromise where no parameters are treated as obj.property and
presence of parameters are treated as a method call.
*/
auto hm = c.conjugate; // return <method-wrapper 'conjugate' of complex object at 0x7fa8c49897d0>
auto hr = c.conjugate()(); // return the result of the function call.
writeln(c);
writeln(hm);
writeln(hr);
}
1 change: 1 addition & 0 deletions examples/testdll/testdll.d
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ extern(C) void PydMain() {
module_init();
wrap_class!(
Foo,
Member!("m_i", Mode!"rw"),
PyName!"Foo",
Docstring!"A sample class.",
Init!(int),
Expand Down