Skip to content

@cfunction for function taking binded class within c++ #460

Description

@k12Sergey

Hi.
Sorry for silly question, but how to use @cfunction in the foolowing case:
Suppose we bind class:

types.add_type<DataBase>("Database")
   .method("GetProperty", &DataBase::getProperty);

and write julia function which take this class:

function Eg(db::CppTypes.Database, mat::Cint)
    return GetProperty(db, mat)
end

and try to get cfunction pointer on this function from c++:

auto *eg = (double (*)(DataBase *, int)) jl_unbox_voidpointer(jl_eval_string("@cfunction(Eg, Cdouble, (Ptr{Cvoid}, Cint))")); 

Pointer exist, but call this is trow an exception.

where im wrong?

Binded classes wrapped on julia side

mutable struct WorldAllocated <: World
  cpp_object::Ptr{Cvoid}
end

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions