Skip to content

Commit f8f337f

Browse files
committed
Merge pull request libdynd#453 from izaid/gfunc
Removed gfunc_callable_functions
2 parents bbdb24d + bb4f8a9 commit f8f337f

File tree

5 files changed

+23
-334
lines changed

5 files changed

+23
-334
lines changed

Diff for: CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ set(pydynd_SRC
182182
dynd/include/do_import_array.hpp
183183
dynd/include/eval_context_functions.hpp
184184
dynd/include/exception_translation.hpp
185-
dynd/include/gfunc_callable_functions.hpp
186185
dynd/include/git_version.hpp
187186
dynd/include/init.hpp
188187
dynd/include/numpy_interop.hpp
@@ -208,7 +207,6 @@ set(pydynd_SRC
208207
dynd/src/ctypes_interop.cpp
209208
dynd/src/eval_context_functions.cpp
210209
dynd/src/exception_translation.cpp
211-
dynd/src/gfunc_callable_functions.cpp
212210
${CMAKE_CURRENT_BINARY_DIR}/dynd/src/git_version.cpp
213211
dynd/src/git_version.cpp.in
214212
dynd/src/init.cpp

Diff for: dynd/cpp/type.pxd

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ from .func.callable cimport callable
1010

1111
cdef extern from 'dynd/types/base_type.hpp' namespace 'dynd::ndt' nogil:
1212
cdef cppclass base_type:
13+
void get_dynamic_type_properties(map[string, callable] &)
14+
void get_dynamic_type_functions(map[string, callable] &)
1315
void get_dynamic_array_properties(map[string, callable] &)
1416
void get_dynamic_array_functions(map[string, callable] &)
1517

@@ -31,6 +33,7 @@ cdef extern from 'dynd/type.hpp' namespace 'dynd::ndt' nogil:
3133
type get_canonical_type()
3234

3335
bool is_builtin()
36+
bool is_null()
3437

3538
bint operator==(type&)
3639
bint operator!=(type&)

Diff for: dynd/include/gfunc_callable_functions.hpp

-77
This file was deleted.

Diff for: dynd/ndt/type.pyx

+20-20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from cpython.object cimport Py_EQ, Py_NE
44
from libc.stdint cimport intptr_t
5+
from libcpp.map cimport map
56
from libcpp.string cimport string
67

78
from ..cpp.types.type_id cimport (type_id_t, uninitialized_type_id,
@@ -24,24 +25,14 @@ from ..cpp.types.var_dim_type cimport dynd_make_var_dim_type
2425
from ..cpp.types.tuple_type cimport make_tuple as _make_tuple
2526
from ..cpp.types.struct_type cimport make_struct as _make_struct
2627
from ..cpp.types.callable_type cimport make_callable
28+
from ..cpp.func.callable cimport callable as _callable
2729

2830
from ..config cimport translate_exception
2931
from ..wrapper cimport set_wrapper_type, wrap
3032

3133
cdef extern from "numpy_interop.hpp" namespace "pydynd":
3234
object numpy_dtype_obj_from__type(_type&) except +translate_exception
3335

34-
cdef extern from 'gfunc_callable_functions.hpp' namespace 'pydynd':
35-
void add_type_names_to_dir_dict(_type&, object) except +translate_exception
36-
object get__type_dynamic_property(_type&, object) except +translate_exception
37-
38-
# Function properties
39-
cdef cppclass _type_callable_wrapper:
40-
pass
41-
object _type_callable_call(_type_callable_wrapper&, object, object) except +translate_exception
42-
43-
void init_w__type_callable_typeobject(object)
44-
4536
cdef extern from 'type_functions.hpp' namespace 'pydynd':
4637
void init_w_type_typeobject(object)
4738

@@ -219,7 +210,24 @@ cdef class type(object):
219210
return _type_get_type_id(self.v)
220211

221212
def __getattr__(self, name):
222-
return get__type_dynamic_property(self.v, name)
213+
if self.v.is_null():
214+
raise AttributeError(name)
215+
216+
cdef _callable p
217+
cdef map[string, _callable] properties
218+
cdef map[string, _callable] functions
219+
cdef _callable f
220+
if (not self.v.is_builtin()):
221+
self.v.get().get_dynamic_type_properties(properties)
222+
p = properties[name]
223+
if (not p.is_null()):
224+
return wrap(p(self.v))
225+
self.v.get().get_dynamic_type_functions(functions)
226+
f = functions[name]
227+
if (not f.is_null()):
228+
return wrap(f(self.v))
229+
230+
raise AttributeError(name)
223231

224232
def __str__(self):
225233
return str(<char *>_type_str(self.v).c_str())
@@ -288,14 +296,6 @@ cdef type dynd_ndt_type_from_cpp(_type t):
288296

289297
set_wrapper_type[_type](type)
290298

291-
cdef class type_callable:
292-
cdef _type_callable_wrapper v
293-
294-
def __call__(self, *args, **kwargs):
295-
return _type_callable_call(self.v, args, kwargs)
296-
297-
init_w__type_callable_typeobject(type_callable)
298-
299299
class UnsuppliedType(object):
300300
pass
301301

0 commit comments

Comments
 (0)