lua-users home
lua-l archive

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


Thanks for your help but I think I didn't understand your example or this
is not what I want to do.

Let me try to explain my situation in a better way.

I have these three functions:

function query()
-- Function code for query a register
end

function insert()
-- Function code for insert a register
end

function remove()
-- Function code for remove a register
end

-- Execute just two functions
query()
remove()


In another different file I should have one list (I still don't know how
to make this list. It has to be in a generic way to be used for any
program just changing the list) of the functions that I want to intercept
(for example, the query and remove). Before or after the execution of
them, it must execute the function logging and then return to execute the
next function.

function logging()
-- Function code for logging
end


I don't want to call the logging function inside the query or remove
functions, but intercept them, execute logging() and return to the normal
execution of the program. Is that possible?



> Roughly....
>
> q = x
> function x()
> 	q()
> 	z()
> 	x = q -- auto "unhook" x
> end
>
> -----------
> With some parameter/return handling....
>
> q = x
> function x(...)
> 	Rets = {q(unpack(arg))}
> 	z()
> 	x = q -- auto "unhook" x
> 	return unpack(Rets)
> end
>
> -------
> Of course this doesn't catch other references to x, such as....
>
> b = x
> .....
> q = x
> function x()
> 	q()
> 	z()
> 	x = q -- auto "unhook" x
> end
> ...
> b() -- Does not call "hook"
> x() -- Does call "hook"
>
> -------
> If this isn't in the class of what you wanted, then you should probably
> spend some quality time with the Debug interface.
>
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Fabrício de
> Alexandria
> Sent: Wednesday, October 22, 2003 11:05 AM
> To: lua@bazar2.conectiva.com.br
> Subject: Intercept function call
>
>
>
>
> Here is my situation. Suppose that I have three functions:
>
> function x()
>   print "x"
> end
>
> function y()
>   print "y"
> end
>
> function z()
>   print "z"
> end
>
> x()
> y()
>
>
> I want to execute x() and y() but before or after the execution of x() I
> want to execute z(). Something like during the execution of the program
> I want to intercept the x() function call, execute z() and then return
> to the normal execution of the program. How can I do that?
>
> I searched something like this in the archive but I didn't find
> anything.
>
>
>
>
> Fabrício de Alexandria Fernandes
> HomePage: http://www.ppgsc.ufrn.br/~fabricio
> E-mail: fabricio@ppgsc.ufrn.br
> UFRN - CCET - DIMAp
> Natal - RN - Brasil


Fabrício de Alexandria Fernandes
HomePage: http://www.ppgsc.ufrn.br/~fabricio
E-mail: fabricio@ppgsc.ufrn.br
UFRN - CCET - DIMAp
Natal - RN - Brasil