@@ -144,17 +144,43 @@ end
144
144
145
145
# ! format: off
146
146
get_class (:: Type{T} ) where {T} = error (" invalid object type: $T , expected a `CppObject` that represents a C++ object or a pointer to a C++ object" )
147
- get_class (:: Type{T} ) where {S,Q,T<: CppType{S,Q} } = S
147
+ get_class (:: Type{T} ) where {S,Q,T<: CppType{S,Q} } = string (S)
148
148
get_class (:: Type{S} ) where {N,T<: CppType ,S<: CppObject{T,N} } = get_class (T)
149
149
get_class (:: Type{S} ) where {N,T<: CppType ,S<: CppObject{Ptr{T},N} } = get_class (T)
150
150
get_class (:: Type{S} ) where {N,T<: CppType ,S<: CppObject{CppCPtr{T},N} } = get_class (T)
151
151
get_class (:: Type{S} ) where {N,NR,T,V<: CppObject{T,N} ,S<: CppObject{Ptr{V},NR} } = get_class (T)
152
152
get_class (:: Type{S} ) where {N,NR,T,V<: CppObject{T,N} ,S<: CppObject{CppCPtr{V},NR} } = get_class (T)
153
+
154
+ get_class (:: Type{Cvoid} ) = " void"
155
+ get_class (:: Type{Cchar} ) = " char"
156
+ get_class (:: Type{Cuchar} ) = " unsigned char"
157
+ get_class (:: Type{Cshort} ) = " short"
158
+ get_class (:: Type{Cushort} ) = " unsigned short"
159
+ get_class (:: Type{Cint} ) = " int"
160
+ get_class (:: Type{Cuint} ) = " unsigned int"
161
+ get_class (:: Type{Clong} ) = " long"
162
+ get_class (:: Type{Culong} ) = " unsigned long"
163
+ if Clonglong != = Clong
164
+ get_class (:: Type{Clonglong} ) = " long long"
165
+ get_class (:: Type{Culonglong} ) = " unsigned long long"
166
+ end
167
+ get_class (:: Type{Cfloat} ) = " float"
168
+ get_class (:: Type{Cdouble} ) = " double"
169
+ get_class (:: Type{Bool} ) = " _Bool"
170
+
171
+ function get_class (:: Type{CppTemplate{T,Targs}} ) where {S,Q,T<: CppType{S,Q} ,Targs}
172
+ return string (S) * " <" * join (map (x -> get_class (x), Targs. types), " ," ) * " >"
173
+ end
174
+ get_class (:: Type{S} ) where {N,T<: CppTemplate ,S<: CppObject{T,N} } = get_class (T)
175
+ get_class (:: Type{S} ) where {N,T<: CppTemplate ,S<: CppObject{Ptr{T},N} } = get_class (T)
176
+ get_class (:: Type{S} ) where {N,T<: CppTemplate ,S<: CppObject{CppCPtr{T},N} } = get_class (T)
177
+ # get_class(::Type{S}) where {N,NR,T<:CppTemplate,V<:CppObject{T,N},S<:CppObject{Ptr{V},NR}} = get_class(T)
178
+ # get_class(::Type{S}) where {N,NR,T<:CppTemplate,V<:CppObject{T,N},S<:CppObject{CppCPtr{V},NR}} = get_class(T)
153
179
# ! format: on
154
180
155
181
@generated function cppmtcall (:: CppContext{ID} , :: CppIdentifier{S} , obj:: T , params... ) where {ID,S,T}
156
182
I = CPPCALL_INSTANCES[ID]
157
- n = string ( get_class (T) ) * " ::" * string (S)
183
+ n = get_class (T) * " ::" * string (S)
158
184
candidates = lookup (I, n, FuncOverloadingLookup ())
159
185
func = dispatch (I, candidates, params)
160
186
isnothing (func) &&
202
228
203
229
_unwrap (:: Type{Type{T}} ) where {T} = T
204
230
205
-
206
231
@inline function dispatch (I:: CppInterpreter , func:: FunctionProtoType , params)
207
232
argnum = length (params) ÷ 2
208
233
get_param_num (func) != argnum && return false
@@ -227,14 +252,16 @@ end
227
252
return GC. @preserve result params invoke (x, ret_ptr, arg_ptrs, self)
228
253
end
229
254
230
- @inline function cppinvoke (x:: CXScope , self:: S , result:: Union{CppObject,Ptr} , params... ) where {N,T<: CppType ,S<: CppObject{T,N} }
255
+ @inline function cppinvoke (x:: CXScope , self:: S , result:: Union{CppObject,Ptr} ,
256
+ params... ) where {N,T<: CppType ,S<: CppObject{T,N} }
231
257
ret_ptr = unsafe_pointer_rt (result)
232
258
arg_ptrs = [unsafe_pointer (params[i]) for i = 1 : (length (params) ÷ 2 )]
233
259
self_ptr = unsafe_pointer (self)
234
260
return GC. @preserve self result params invoke (x, ret_ptr, arg_ptrs, self_ptr)
235
261
end
236
262
237
- @inline function cppinvoke (x:: CXScope , self:: S , result:: Union{CppObject,Ptr} , params... ) where {N,T,S<: CppObject{Ptr{T},N} }
263
+ @inline function cppinvoke (x:: CXScope , self:: S , result:: Union{CppObject,Ptr} ,
264
+ params... ) where {N,T,S<: CppObject{Ptr{T},N} }
238
265
ret_ptr = unsafe_pointer_rt (result)
239
266
arg_ptrs = [unsafe_pointer (params[i]) for i = 1 : (length (params) ÷ 2 )]
240
267
self_ptr = reinterpret (Ptr{Cvoid}, self. data)
0 commit comments