You need to check jl_gc_is_enabled() before calling
jl_gc_disable/jl_gc_enable. However, this is not recommended. Instead
you should use JL_GC_PUSHn to root each argument.

You also want to avoid using pointer_from_objref since it hides the
object reference from the GC. You can use a ccall argument type of Any
to get the same effect.

You can get modules the same way you get other globals, with jl_get_global.

Why do you want to avoid passing parameters to the ccall? It would
seem much easier to pass a reference to the preallocated MyType
instance that you want filled.

On Sun, Feb 9, 2014 at 6:46 AM, Carlos Becker <[email protected]> wrote:
> I think I finally made it work, close to what I wanted.
>
> This could be good for future reference for anyone trying to do something
> similar.
> The code is at https://gist.github.com/anonymous/8897943.
>
> I have two questions about it:
>   1) calling jl_gc_disable() and jl_gc_enable() is ok in that context? (see
> link above)
>   2) I still don't know how to avoid passing a pointer to the module I want
> to get the type from to the C call.
>
> Thanks.
>
>
> El domingo, 9 de febrero de 2014 00:40:33 UTC+1, Carlos Becker escribió:
>>
>> Hi Steven,
>>
>> I tried that before, I know it is possible, but if the size is unknown to
>> julia, it must be returned as another variable, which makes
>> coding more difficult if many of such return arrays are needed.
>>
>> That is why I think it would be interesting to see the julia-api side of
>> it, to see if this can be avoided.
>> (I prefer to write a bit more of C code but make the ccall clearer in
>> julia)
>>
>> About my previous question, I am still struggling to create a custom type
>> with julia's C API and fill it in, to pass it back then.
>> Has anyone done this in such scenario before? I wonder if the necessary
>> symbols are already exported for 3rd party use.
>>
>> Cheers.

Reply via email to