|
|
> First, apologies if I'm posting this in thewrong section, I'm pretty new to the
> board.
povray.general would have been appropriate. This section is
about about the programming *of* POV-Ray, not *in* POV-Ray.
> For those of you who know about the thing, is there any way to pass macros (and
> by that I mean the real macro identifier, not a macro application) as another
> macro argument ?
I was going to say it's not supported by the language, but you may
in fact bend the rules a little if you write each macro body into
a separate source file, so by passing the macro name you can then
actually include code as required.
I just made the following sample:
--- BEGIN mymacro.inc ---------------
// #macro mymacro(VALUE)
// Map generic parameter names to functional names
#local VALUE = P1;
// Actual macro body
#debug concat("MyMacro Invocation: ", str(VALUE,1,3), "\n")
--- END mymacro.inc ---------------
--- BEGIN user.pov ---------------
// Sample for misusing include files to allow passing macros as
// parameters to other macros.
// Note that both include file macro bodies and local
// macro wrappers need to follow a fixed naming convention
// such as P1,P2,P3,... for the parameter names. Of course,
// the number of parameters must be known in advance as it
// forms the signature contract for the expected macro.
// There may be restrictions regarding nesting and cycles.
#macro MetaMacro(MACRO_NAME,VALUE)
#macro LOCAL_MACRO(P1)
#include concat(MACRO_NAME,".inc")
#end
LOCAL_MACRO(VALUE)
#end
// Invocation
MetaMacro("mymacro",5)
--- END user.pov ---------------
Post a reply to this message
|
|