[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: to get module
- From: Stephen Kellett <lua@...>
- Date: Thu, 10 Nov 2005 13:13:04 +0000
In message <754368376.20051110160357@kaluga.net>, Alexey Malyshev
<malma@kaluga.net> 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
end
Page 191 onwards in Roberto's book. The above is a shortened version of
the code snippet on Page 193.
Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting