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