Skip to content

Commit 7d9664c

Browse files
author
Christopher Doris
committed
get Core working
1 parent bfe282a commit 7d9664c

File tree

7 files changed

+116
-100
lines changed

7 files changed

+116
-100
lines changed

src/API/API.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function pycopy! end
2020
function getptr end
2121
function pydel! end
2222
function unsafe_pynext end
23+
function pyconvert end
2324
function pyconvert_add_rule end
2425
function pyconvert_return end
2526
function pyconvert_unconverted end
@@ -222,6 +223,7 @@ export pycallable
222223
export pycompile
223224
export pybuiltins
224225
export @pyconst
226+
export pyconvert
225227

226228
# public bindings
227229
if Base.VERSION v"1.11"

src/Core/Core.jl

Lines changed: 111 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
"""
2-
module PythonCall.Core
3-
4-
Defines the `Py` type and directly related functions.
5-
"""
61
module Core
72

8-
const VERSION = v"0.9.23"
9-
const ROOT_DIR = dirname(dirname(@__DIR__))
10-
11-
using ..PythonCall: PythonCall # needed for docstring cross-refs
3+
using ..PythonCall
124
using ..C: C
135
using ..GC: GC
146
using ..Utils: Utils
@@ -26,12 +18,120 @@ using Dates:
2618
millisecond,
2719
microsecond,
2820
nanosecond
29-
using MacroTools: MacroTools, @capture
21+
using MacroTools: @capture
3022
using Markdown: Markdown
3123

24+
import PythonCall:
25+
VERSION,
26+
Py,
27+
PyException,
28+
ispy,
29+
pyis,
30+
pyrepr,
31+
pyascii,
32+
pyhasattr,
33+
pygetattr,
34+
pysetattr,
35+
pydelattr,
36+
pyissubclass,
37+
pyisinstance,
38+
pyhash,
39+
pytruth,
40+
pynot,
41+
pylen,
42+
pyhasitem,
43+
pygetitem,
44+
pysetitem,
45+
pydelitem,
46+
pydir,
47+
pycall,
48+
pyeq,
49+
pyne,
50+
pyle,
51+
pylt,
52+
pyge,
53+
pygt,
54+
pycontains,
55+
pyin,
56+
pyneg,
57+
pypos,
58+
pyabs,
59+
pyinv,
60+
pyindex,
61+
pyadd,
62+
pysub,
63+
pymul,
64+
pymatmul,
65+
pyfloordiv,
66+
pytruediv,
67+
pymod,
68+
pydivmod,
69+
pylshift,
70+
pyrshift,
71+
pyand,
72+
pyxor,
73+
pyor,
74+
pyiadd,
75+
pyisub,
76+
pyimul,
77+
pyimatmul,
78+
pyifloordiv,
79+
pyitruediv,
80+
pyimod,
81+
pyilshift,
82+
pyirshift,
83+
pyiand,
84+
pyixor,
85+
pyior,
86+
pypow,
87+
pyipow,
88+
pyiter,
89+
pynext,
90+
pybool,
91+
pystr,
92+
pybytes,
93+
pyint,
94+
pyfloat,
95+
pycomplex,
96+
pytype,
97+
pyslice,
98+
pyrange,
99+
pytuple,
100+
pylist,
101+
pycollist,
102+
pyrowlist,
103+
pyset,
104+
pyfrozenset,
105+
pydict,
106+
pydate,
107+
pytime,
108+
pydatetime,
109+
pyfraction,
110+
pyeval,
111+
pyexec,
112+
@pyeval,
113+
@pyexec,
114+
pywith,
115+
pyimport,
116+
pyprint,
117+
pyhelp,
118+
pyall,
119+
pyany,
120+
pycallable,
121+
pycompile,
122+
@pyconst,
123+
pyconvert,
124+
pynew,
125+
pyisnull,
126+
pycopy!,
127+
getptr,
128+
pydel!,
129+
unsafe_pynext
130+
131+
const ROOT_DIR = dirname(dirname(@__DIR__))
132+
32133
include("Py.jl")
33134
include("err.jl")
34-
include("config.jl")
35135
include("consts.jl")
36136
include("builtins.jl")
37137
include("stdlib.jl")

src/Core/Py.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ True if `x` is a Python object.
99
This includes `Py` and Python wrapper types such as `PyList`.
1010
"""
1111
ispy(x) = false
12-
export ispy
1312

1413
"""
1514
pyisnull(x)
@@ -28,10 +27,10 @@ getptr(x) = ispy(x) ? getptr(Py(x)::Py) : throw(MethodError(getptr, (x,)))
2827
py_finalizer(x::Py) = GC.enqueue(getptr(x))
2928

3029
ispy(::Py) = true
31-
getptr(x::Py) = getfield(x, :ptr)
30+
getptr(x::Py) = C.PyPtr(getfield(x, :ptr))
3231
pyconvert(::Type{Py}, x::Py) = x
3332

34-
setptr!(x::Py, ptr::C.PyPtr) = (setfield!(x, :ptr, ptr); x)
33+
setptr!(x::Py, ptr::C.PyPtr) = (setfield!(x, :ptr, Ptr{Cvoid}(ptr)); x)
3534

3635
const PYNULL_CACHE = Py[]
3736

0 commit comments

Comments
 (0)