cool. you can go up to jl_call3. after that you need to pack the args in a
jl_value_t** and use the general form  `jl_call(f, args, nargs)` ... there
should be a lot of examples how to do that if you grep through src/ for
"jl_call".

On Tue, Jun 30, 2015 at 12:26 PM, Kostas Tavlaridis-Gyparakis <
kostas.tavlari...@gmail.com> wrote:

> Ok, thanks a lot it did work just fine!
> just one more quick question, if I got it right jl_call1 is for adding one
> input argument to the functions and jl_call2 is for adding two input
> arguments to the function.
> For adding more arguments I continue in the same way? For instance for 4
> arguments I just use use jl_call4?
> Or what I am saying is completely mistaken?
>
> On Tuesday, June 30, 2015 at 5:58:18 PM UTC+2, Isaiah wrote:
>>
>> try
>>
>> jl_value_t * mod = (jl_value_t*)jl_eval_string("mymodule");
>> jl_function_t * func = jl_get_function((jl_module_t*)mod,"myfunction");
>>
>> (jl_new_module creates a new module -- that's not what you want, because
>> the module containing your function is created when you eval "yourfile.jl")
>>
>> On Tue, Jun 30, 2015 at 11:47 AM, Kostas Tavlaridis-Gyparakis <
>> kostas.t...@gmail.com> wrote:
>>
>>> Ok, so first of all thanks a lot for all the help so far.
>>> So, now I try to follow the instructions and I write the following three
>>> lines of code inside C++:
>>>
>>>  jl_load("mymodule.jl");
>>>         jl_value_t * mod = jl_eval_string("mymodule");
>>>         jl_function_t * func =
>>> jl_get_function(jl_new_module(mod),"myfunction");
>>>
>>> (the jl file and the module itself have the same name in this case
>>> mymodule)
>>> But I do receive the following 2 errors when Eclipse compiles:
>>>
>>> 1) error: invalid conversion from ‘void*’ to ‘jl_value_t* {aka
>>> _jl_value_t*}’ [-fpermissive] (this is referring to  jl_value_t * mod =
>>> jl_eval_string("mymodule");)
>>>
>>> 2) error: cannot convert ‘jl_value_t* {aka _jl_value_t*}’ to ‘jl_sym_t*
>>> {aka _jl_sym_t*}’ for argument ‘1’ to ‘jl_module_t*
>>> jl_new_module(jl_sym_t*)’ (this referring to jl_function_t * func =
>>> jl_get_function(jl_new_module(mod),"myfunction");)
>>>
>>>
>>> >No problem, no stupid questions. However, I would suggest that you
>>> might want to spend some time getting really familiar with Julia by itself,
>>> before trying to use the embedding API. It might save a lot of time in the
>>> long run.
>>>
>>> You are totally right on this, I am just trying first to check if it is
>>> doable to do some combinations between C++ in Eclipse and Julia (such as
>>> using functions written in
>>> Julia inside a C++ routine etc), because I am planning to connect a
>>> large-scale C++ with Julia and before starting to studying Julia in full
>>> detail and start writing proper
>>> code was thinking to do some small tests in connectivity between the
>>> two. But it turns out that I don't know some very basic things to finish
>>> this task.
>>>
>>>
>>> On Tuesday, June 30, 2015 at 5:32:53 PM UTC+2, Isaiah wrote:
>>>>
>>>> Sorry but I am not sure what you mean and how to "*evaluate your .jl
>>>>> file defining the module first*"?
>>>>
>>>>
>>>> Ok, say you have a file:
>>>>
>>>> ```
>>>> module mymod
>>>> function foo() ... end
>>>> end
>>>> ```
>>>>
>>>> At the Julia prompt you would do:
>>>>
>>>> julia> include("myfile.jl")
>>>>
>>>> And then you have the module `mymod` available in the global namespace.
>>>> In C you can do the equivalent with:
>>>>
>>>> `jl_load("myfile.jl")`
>>>>
>>>> I am really new to Julia so maybe the question sounds really stupid,
>>>>> sorry for that
>>>>
>>>>
>>>> No problem, no stupid questions. However, I would suggest that you
>>>> might want to spend some time getting really familiar with Julia by itself,
>>>> before trying to use the embedding API. It might save a lot of time in the
>>>> long run.
>>>>
>>>> On Tue, Jun 30, 2015 at 10:54 AM, Kostas Tavlaridis-Gyparakis <
>>>> kostas.t...@gmail.com> wrote:
>>>>
>>>>> Sorry but I am not sure what you mean and how to "*evaluate your .jl
>>>>> file defining the module first*"?
>>>>> (I am really new to Julia so maybe the question sounds really stupid,
>>>>> sorry for that)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tuesday, June 30, 2015 at 4:28:54 PM UTC+2, Isaiah wrote:
>>>>>>
>>>>>> `jl_new_module` creates a new module. You must evaluate your .jl file
>>>>>> defining the module first, then to get a reference to the module do:
>>>>>>
>>>>>> `jl_value_t* mod = jl_eval_string("MyModName");
>>>>>>
>>>>>> Then you can pass "mod" as the argument to `jl_get_function`.
>>>>>>
>>>>>> On Tue, Jun 30, 2015 at 10:16 AM, Kostas Tavlaridis-Gyparakis <
>>>>>> kostas.t...@gmail.com> wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>> I am trying to write some function in Julia which I will be able to
>>>>>>> call inside my C++ projects in Eclipse.
>>>>>>> In the documentation there is this
>>>>>>> <http://julia-demo.readthedocs.org/en/latest/manual/embedding.html#calling-julia-functions>
>>>>>>> example on how to call a function of julia from an existing module.
>>>>>>> So, what I have done was to create my own module where inside I
>>>>>>> included my function and then my
>>>>>>> understanding is that I should be using "jl_new_module(jl_sym_t
>>>>>>> *name);" instead of jl_base_module.
>>>>>>> But I am not sure (in case my assumption that this is the correct
>>>>>>> command is true) how to proper use
>>>>>>> it's syntax, as what I am trying is:
>>>>>>>
>>>>>>>         jl_function_t * func =
>>>>>>> jl_get_function(jl_new_module(mymodule),"myfunction");
>>>>>>>
>>>>>>> and I tried instead of mymodule also mymodule.jl and "mymodule" and
>>>>>>> "mymodule.jl" and in all the attempts I
>>>>>>> recieve an error that:
>>>>>>>
>>>>>>> mymodule  was not declared in this scope
>>>>>>>
>>>>>>>
>>>>>>> Let me note beforehand that the module is being stored globaly as when 
>>>>>>> I run julia on the terminal I can use it
>>>>>>> through the comand using mymodule.
>>>>>>> Still maybe I am trying to use the wrong command or sth, so if there is 
>>>>>>> any suggestion I would be really greatful
>>>>>>> to hear it.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>

Reply via email to