lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


David Given wrote:
>> Very easy. It's possible to write a extend Lua to allow native C or C++ code
>> to be called from a Lua script in a handful of lines of code
You mean, I am able to create scripting language for my app that supports C aside Lua?
Something like asm integration in mainstreem languages, via asm{ ..} directive ?
Its hard for me to beleive that, can you provide me an example ? Somehow I think we didn't understand eatchother...

Imagine this scenario: I have OnTitleClick even in mention DM software. Usere should be able to write Lua script for eventual plugin.
So for instance if it wants to "display an message" on right click on title bar he could write something like this (pseudocode as I am just reading Lua ref) assuming that I provided wrapper for MessageBox winwdows API in the form of msgbox

function OnTitleClick( args )
    MsgBox( args.title .. "is clicked") 
end

Now, If I don't provide MessageBox wrapper user must be able to do call this function from adequate Windows DLL.
I supose there is some kind of DllCall() function that alows for this like in AutoHotKey automatition language:
   
     DllCall("user32.dll\MessageBox", "uint", 0, "uint", .... "str", "myString".... )

THings get more compolicated with real time examples, like using APIs that require callbacks like EnumWindows to enumerate all windows in the system etc...

David Given wrote:
>>However, you *could* write a system where the other process sends a message to
>>the process that owns the Lua VM, which does the work there. I don't know the
>>Windows window manager model --- doesn't it all run in a single process?
Applications in windows run in separate process space. You can't access anything from adr space of other process except using specific methods of code injection so to fool Windows it native code.
Redirection to Lua VM that resides in its own adr space is of course possible but in that case conastant piping of data will be necessery, generaly.
Its maybe possible to load LUA VM into adr space of every application :)