Difference between revisions of "Template:Csig"
From Maths
(Testing version) |
m (Adding template:ctd - for typedefs) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | {{cs|1={{{ | + | {{cs|1={{#if:{{{pre|}}}|{{{pre|}}} <nowiki/>|}}{{echo|1={{{1|<noinclude>int</noinclude>}}}}} {{echo|1={{{2|<noinclude>printf</noinclude>}}}}}<!-- |
− | + | ||
− | + | ||
+ | -->{{#if:{{{3|<noinclude>const char*</noinclude>}}}{{{4|<noinclude>format</noinclude>}}}<!-- | ||
+ | We concatenate the following on too, this will be something if 3 is actually present, just empty. Allowing {{csig|pid_t|getpid|}} to show as a function for example | ||
+ | -->{{#if:{{{3|something}}}|<!--3 is not empty, or it wasn't set case-->|XXX}}<!-- XXX is the result if 3 is set but empty, as required. | ||
+ | End of if body, onto cases | ||
+ | -->|<!-- | ||
+ | case true: | ||
if 3 concatenated with 4 is not empty (ie there is an arg) | if 3 concatenated with 4 is not empty (ie there is an arg) | ||
− | -->({{/Arg|1={{{3|}}}|2={{{4|}}}|3={{/Arg|1={{{5|}}}|2={{{6|}}}|3=<!-- | + | ARGUMENTS ARE EXPANDED HERE |
+ | -->(<!-- | ||
+ | ARG1 | ||
+ | -->{{csig/Arg|1={{{3|}}}|2={{{4|}}}|3=<!-- | ||
+ | ARG2 | ||
+ | -->{{csig/Arg|1={{{5|}}}|2={{{6|}}}|3=<!-- | ||
+ | ARG3 | ||
+ | -->{{csig/Arg|1={{{7|}}}|2={{{8|}}}|3=<!-- | ||
+ | ARG4 | ||
+ | -->{{csig/Arg|1={{{9|}}}|2={{{10|}}}|3=<!-- | ||
+ | ARG5 | ||
+ | -->{{csig/Arg|1={{{11|}}}|2={{{12|}}}|3=<!-- | ||
+ | ARG6 | ||
+ | -->{{csig/Arg|1={{{13|}}}|2={{{14|}}}|3=<!-- | ||
+ | Closing arg6 | ||
+ | -->}}<!-- | ||
+ | Closing arg5 | ||
+ | -->}}<!-- | ||
+ | Closing arg4 | ||
+ | -->}}<!-- | ||
+ | Closing arg3 | ||
+ | -->}}<!-- | ||
+ | Closing arg2 | ||
+ | -->}}<!-- | ||
+ | closing arg3 | ||
+ | -->}}<!-- | ||
+ | closing bracket | ||
+ | -->)<!-- | ||
-->|<!-- | -->|<!-- | ||
+ | case false: | ||
else (eg a variable) | else (eg a variable) | ||
--><!-- | --><!-- | ||
Line 16: | Line 48: | ||
--> {{{post|}}}<!-- | --> {{{post|}}}<!-- | ||
− | -->}} | + | -->}}<noinclude> |
+ | ==Usage== | ||
+ | Currently supports up to 6 arguments, you may use {{C|pre}} and {{C|post}} to make things appear before and after (with a space between them and the body, if present), arguments go as follows: | ||
+ | # return or type (eg {{C|int}}) | ||
+ | # symbol name (eg {{C|printf}}) | ||
+ | # arg1 - type (eg {{C|const char*}}) | ||
+ | #* If not present, then no brackets are rendered after the symbol name, for a variable definition | ||
+ | #* If present but empty then brackets are shown, this is how you'd achieve a function with no arguments over a variable | ||
+ | # arg1 - name | ||
+ | # arg2 - type | ||
+ | # arg2 - name | ||
+ | # arg3 - type | ||
+ | # arg4 - name | ||
+ | and so on. | ||
+ | |||
+ | An argument is considered present if the type/name arguments are ''not both empty'', so an empty type with the name as {{C|...}} is valid, for example varadic functions (c-style) | ||
+ | ==[[/Example|Examples]]== | ||
+ | {{/Example}} | ||
+ | ==Family== | ||
+ | Think of any {{C|*_t}} versions as "template" - to be used alone, without the {{C|_t}} at the end they may be styling (only csig and cs are designed to be used alone and lack a {{C|_t}} to indicate this) | ||
+ | * [[template:cprim]] - used within [[template:csig]] or [[template:cs]] to style primitive types. | ||
+ | ** [[template:cprim_t]] - standalone version, used inline, rather than inside csig or cs | ||
+ | * [[template:ckw]] - used within csig or cs | ||
+ | ** [[template:ckw_t]] - standalone version | ||
+ | * [[template:ctd]] - typedefs | ||
+ | ** [[template:ctd_t]] - standalone version | ||
+ | |||
+ | </noinclude> |
Latest revision as of 08:40, 1 October 2017
int printf()
Usage
Currently supports up to 6 arguments, you may use pre and post to make things appear before and after (with a space between them and the body, if present), arguments go as follows:
- return or type (eg int)
- symbol name (eg printf)
- arg1 - type (eg const char*)
- If not present, then no brackets are rendered after the symbol name, for a variable definition
- If present but empty then brackets are shown, this is how you'd achieve a function with no arguments over a variable
- arg1 - name
- arg2 - type
- arg2 - name
- arg3 - type
- arg4 - name
and so on.
An argument is considered present if the type/name arguments are not both empty, so an empty type with the name as ... is valid, for example varadic functions (c-style)
Examples
- int printf(const char* format, ...)
- int printf(const char* format, ...)
- int errno __attribute__((aligned(16)))
- pid_t getpid()
- long:
- int lots_of_args(a b, c d, e f, g h) __attribute__((noreturn))
Family
Think of any *_t versions as "template" - to be used alone, without the _t at the end they may be styling (only csig and cs are designed to be used alone and lack a _t to indicate this)
- template:cprim - used within template:csig or template:cs to style primitive types.
- template:cprim_t - standalone version, used inline, rather than inside csig or cs
- template:ckw - used within csig or cs
- template:ckw_t - standalone version
- template:ctd - typedefs
- template:ctd_t - standalone version