shirok / Gauche

Scheme Scripting Engine
https://practical-scheme.net/gauche
Other
808 stars 81 forks source link

Integrate cpp conditional forms for stubs and CiSE #882

Open shirok opened 1 year ago

shirok commented 1 year ago

We have CiSE macros corresponds to c preprocessor directives, e.g. .define, .include, or .error. They expand into #define, #include, and #error, respectively. These macros can appear in stub files, and we delegate its expansion to CiSE renderers.

However, conditional directives such as .if or .when require special treatment if they appear at the toplevel of stub files---the condition may affect multiple parts of the code (e.g. declaration, definition, and initialization) so that the simple CiSE expansion isn't enough. So gauche.cgen.stub intercepts these forms when they appear in toplevel.

However, it is confusing for users, since these directives appear inside CiSE forms are handled by CiSE expander. It is not immediately obvious that the apparently same forms can be handled differently.

Not sure what's the best way to address this yet, but it'll be nicer if we can consolidate the handler definitions of those toplevel cpp conditions.

shirok commented 1 year ago

Cf. https://github.com/shirok/Gauche/commit/3112d7e8067d6e01cc00c25d8c5c747618c2383b