This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: (PR11207) Macroprocessor discussion



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]