Re: Calling Lua functions form C++

From: mitchell <mforal.n....at.gmail.com>
Date: Sun, 6 Jun 2010 20:00:09 -0700 (PDT)

Hi Brian,

On Jun 5, 3:40 am, Brian Schott <briancsch....at.gmail.com> wrote:
> Question mostly for Mitchell: Is there a clean way to call the "open"
> function in file_io.lua from the C++ side of Textadept? That's the last
> thing I need for making a single-instance patch for Linux.

Something like this should do the trick:

lua_getglobal(lua, "textadept");
lua_getfield(lua, -1, "io"); // textadept.io
lua_getfield(lua, -1, "open"); // textadept.io.open
lua_pushstring(lua, "filename");
lua_pcall(lua, 1, 0, 0); // textadept.io.open('filename')
lua_pop(lua, 2); // textadept, textadept.io tables

I am also excited to see what you come up with.
Received on Sun 06 Jun 2010 - 23:00:09 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:47:08 EST