This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: (PR11207) Macroprocessor discussion
- From: fche at redhat dot com (Frank Ch. Eigler)
- To: Serguei Makarov <smakarov at redhat dot com>
- Cc: systemtap at sourceware dot org
- Date: Wed, 13 Jun 2012 21:15:18 -0400
- Subject: Re: (PR11207) Macroprocessor discussion
- References: <f1a29b1a-adce-401a-8222-f213c8233958@zmail19.collab.prod.int.phx2.redhat.com> <9f6124ad-2a82-4647-a074-3d0d9a823bb8@zmail19.collab.prod.int.phx2.redhat.com>
Hi, Serhei -
Lots of work done there, thank you! I suspect we would want to start
a little smaller, and see how far that can go. I also have one or two
syntax tweaks for you to consider.
> [...]
> # Example Usage - Defining a Shorthand for a Cast Operation
>
> %define(FOO,ptr, @cast(ptr, "struct foo", "/path/to/app:<sys/foo.h") )
> bar = %FOO(p)->bar
> baz = %FOO(p)->baz
>
> # Example Usage - Equivalent to a Standard CPP #define Macro
>
> %define(AREA,base,height, ((base)*(height)/2.0) )
> a = AREA(2+2,5) // correctly handles precedence
These look basically good.
> # Detailed Explanation
> [...]
> This business with the parens allows us to write complex multiline
> definitions:
> %define(multiline_macro,(
> ... multiple lines of stuff go here ...
> ))
Instead of using so much parenthesis/whitespace magic, how about:
To define:
%define macro2(a,b)
something(a) + something_else(b)
%end
To invoke:
%macro2(foo,bar)
(The code will have to take care w.r.t. undesirable recursion/nesting
with macroexpansion.)
> The macro processor is aware of docstrings. When invoking a macro,
> it keeps track of the most recent docstring it saw before the
> invocation. If the docstring is accessed via %grab_invocation_docs
> or %grab_definition_docs [...]
I wonder if, instead of this, we can extend the doc extractor widget
to accept formats that a more naive macro engine could produce. Drop
the requirement for exact /* * foo */ patterns, accept some other,
appendable format. Perhaps:
%define general_docs (name)
/*** <--- signal to have kerneldoc widget glue this comment to previous one
* some more text to be added
* @param foo bar
*/
%end
%define general_body (name1,name2) // without cpp style # / ## token-pasting
name1 = @var(name2)
%end
/** sfunction foobar */
%general_docs (foobar)
/*** more docs */
function foobar () {
%general_body (foobar,"foobar")
}
> Predefined Macros (possibility)
> %define(name, param_1, param_2, ..., param_n, macro_body)
> %defloc(name, param_1, param_2, ..., param_n, macro_body)
> %grab_invocation_docs(param_1, param_2, ..., param_n)
> -- defines a local %invocation_docs(...) macro
> %grab_definition_docs(param_1, param_2, ..., param_n)
> -- defines a local %definition_docs(...) macro
> %undef(name)
> [...]
I'd start just with the first and last and see how far one can get
with only them. If that %defloc macro is only for meta-macros, I'd
like to see whether we can get by without them.
- FChE