You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pEpEngine/api/gen_c_header.ysl2

97 lines
1.5 KiB
Plaintext

// p≡p API header generator
// Copyleft (c) 2019, p≡p foundation
// this file is under GNU General Public License 3.0
// see LICENSE.txt
// written by Volker Birk
include yslt.yml2
include ./config.yml2
tstylesheet {
include ./to_c.ysl2
const "version" **version;
const "copyleft" **copyleft;
template "/package"
apply "package", 0;
template "package" document "{@name}_{@type}.h", "text" {
||
// «../@name» «$version»
// «@name»_«@type».h
// «$copyleft»
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
||
apply "doc|type|enum|struct", 0;
||
#ifdef __cplusplus
} // extern "C"
#endif
||
}
template "type" {
if "@doc" | // «@doc»
| typedef «func:basetype(@name)» «@name»;
|
}
template "struct" {
||
typedef struct _«func:name()» {
||
apply "field";
||
} «func:name()»;
||
}
template "field" {
if "@doc" | // «@doc»
| «func:c-type(@type)» «@name»;
|
}
template "enum" {
||
typedef enum _«func:name()» {
||
apply "item|doc";
||
} «func:name()»;
||
}
template "doc"
||
// «.»
||
template "item" {
0> «func:name()»`if "text()" { " = " value "." }``if "position()!=last()" > ,`
choose {
when "@doc" > // «@doc»\n
otherwise > \n
}
}
}