[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C struct from Lua table?
- From: Russell Haley <russ.haley@...>
- Date: Thu, 2 Nov 2017 09:36:56 -0700
Hi,
Thanks for the responses, I was elbow deep in Halloween costumes up
until a couple nights ago.
I guess what I am looking to do is copy a pattern I have seen at work.
Someone has used a scripting language (TCL) to generate dynamic web
pages which expose C structs for diagnostics (Tobias on the list will
know what I'm talking about). Unfortunately the tool was misused (IMO)
and is not well liked (no documentation and opaque coding style
doesn't help). I, however, see a great deal of both genius and
usefulness in the pattern.
So, truly, I had no idea what to ask. My working theory is thus: I
have found an init type system written in C++ that I quite like
(https://github.com/mheily/jobd). I envision using it as a
watchdog/application manager. It would be nice to be able to expose
the running diagnostics of the system via a web page.
So, Perhaps the Lua C interface and Sol2 are what I am looking for? To
generalize the idea, it would be nice to be able to web-expose data
from any application I choose. I see some sort of interface that
allows me to parse cdata and apply labels to the values. This is just
my opening review of how the pattern could be used, hence the very
general question to start.
Now, that said, I would be perfectly happy with a Lua based "init
system"/"application manager"/"watchdog" if one existed. I have also
considered using cqueues to create an init system, which would tie
quite nicely with lua-http.
Thanks for your suggestions Miha, the suggested projects may be what I
am looking for.
Thanks Tom, your stronger tool looks awesome! I could see it being
very useful for all sorts of prototyping.
Cheers,
Russ
On Thu, Nov 2, 2017 at 12:55 AM, Tom Yaxley <tommitytom@gmail.com> wrote:
> I built this a while ago and recently documented it.. I haven't used it in a
> while and it might be full of bugs, but it can convert lua tables to C
> structs.. check out the "How" section of the readme :)
>
> https://github.com/tommitytom/stronger
>
> On 28 October 2017 at 03:43, Charles Heywood <vandor2012@gmail.com> wrote:
>>
>> I'm not sure if you can do something like that in C. In C, aren't data
>> structures like structs defined at compile time? You could make a data
>> structure and then populate it based on a Lua method or something but it
>> feels like it'd be better to do it from C instead if it's just going to stay
>> in C (alternatively, if it's needed in Lua, provide a method to push a table
>> populated with the config to Lua).
>>
>> On Fri, Oct 27, 2017 at 3:02 AM Miha Cooper <mihakuper@gmail.com> wrote:
>>>
>>> What about C/C++ bindings over Lua API like Sol2 or LuaBridge? Is it
>>> necessary to generate structures to parse configs?
>>>
>>> On 27 October 2017 at 09:59, Russell Haley <russ.haley@gmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I was hoping someone had already written something that can use Lua
>>>> tables as templates for generating C structures? The idea was to
>>>> generate the structures to be used to read config files in C.
>>>>
>>>> Yes, very light on requirements.
>>>>
>>>> Thanks,
>>>> Russ
>>>>
>>>
>>>
>>>
>>> --
>>> With best regards,
>>> Kupriyanov Mikhail.
>>
>> --
>> --
>> Ryan | Charles <vandor2012@gmail.com>
>> Software Developer / System Administrator
>> https://hashbang.sh
>
>