lua-users home
lua-l archive

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

In message <>, Alexey Malyshev <> writes
Let's suppose we load two modules modA and modB in lua script, and in
each of these modules I call my C function fooFunc().
Is it possible to know from fooFunc(), in which module modA or modB
the calling occurs?

Yes. Get debug_info and look at "source" or "short_src" in the returned data.

local info = debug.getinfo(1, "S")
if (info) then
  -- example info.source and/or info.short_src here

Page 191 onwards in Roberto's book. The above is a shortened version of the code snippet on Page 193.

Stephen Kellett
Object Media Limited
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting