From: briot.emmanuel@gmail.com
Subject: Re: Where to find good/simple examples for gnatcoll (python)?
Date: Thu, 20 Oct 2016 00:57:04 -0700 (PDT)
Date: 2016-10-20T00:57:04-07:00 [thread overview]
Message-ID: <174e458e-70b8-411b-b1aa-b888838145d1@googlegroups.com> (raw)
In-Reply-To: <9f771768-9d3e-43a1-b2e7-048851f5b4f9@googlegroups.com>
If you only want to execute a python script (and perhaps get the output as a
string), you could try:
Python : constant Scripting_Language :=
Lookup_Scripting_Language (Repo, "python");
GNATCOLL.Scripts.Execute_Command (Python, "2 + 3");
Now, if you want to get the result, this is a little more complicated. Assuming you
want to call a foo() function in python, you have to prepare an object with the arguments,
and that will receive the return value.
Data : Callback_Data'Class := Create (Python, 0);
Result : Integer;
Data.Execute_Expression ("2+3"); -- newer versions of gnatcoll
Result := Data.Return_Value;
or
Data : Callback_Data'Class := Create (Python, 2);
Result : Integer;
Data.Set_Nth_Arg (1, 2);
Data.Set_Nth_Arg (2, 3);
Data.Execute_Command ("foo"); -- newer versions of gnatcoll
Result := Data.Return_Value;
next prev parent reply other threads:[~2016-10-20 7:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 17:48 Where to find good/simple examples for gnatcoll (python)? reinkor
2016-10-19 8:15 ` Vratislav Podzimek
2016-10-19 12:01 ` reinkor
2016-10-20 7:57 ` briot.emmanuel [this message]
2016-10-21 8:27 ` reinkor
2016-10-31 8:40 ` briot.emmanuel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox