Browse Source

...

generate_api
Volker Birk 2 years ago
parent
commit
a646c8de83
5 changed files with 83 additions and 31 deletions
  1. +19
    -17
      api/basic_api.yml2
  2. +12
    -2
      api/gen_c_header.ysl2
  3. +3
    -3
      api/message_api.yml2
  4. +11
    -8
      api/pEp.yml2
  5. +38
    -1
      api/to_c.ysl2

+ 19
- 17
api/basic_api.yml2 View File

@ -20,7 +20,7 @@ type hash_list doc="sequence of fingerprints of keys"
type TID doc="UUID version 4 variant 1"
is binary size=16;
type binary_ref is binary;
type binary_ref is weak< binary >;
enum content_disposition {
item attachment 0;
@ -29,15 +29,15 @@ enum content_disposition {
}
struct blob {
field binary_ref value;
field function=free binary_ref value;
field size_t size;
field string mime_type;
field string filename;
content_disposition disposition;
internal any_ref release_value;
field content_disposition disposition;
}
type blob_list is list< blob >;
type identity_list is list< identity >;
@ -46,6 +46,10 @@ type string_list is list< string >;
type string_pair is pair< string, string >;
type string_pair_list is list< string_pair >;
type any_ref is weak< any >;
enum cipher_suite {
item default 0;
@ -140,22 +144,20 @@ struct identity {
field bool me doc="if this is the local user herself/himself";
field unsigned major_ver doc="highest version of pEp message received, if any";
field unsigned minor_ver doc="highest version of pEp message received, if any";
field identity_flags_t flags doc="identity_flag1 | identity_flag2 | ...";
} // struct Identity
flags {
flag not_for_sync 0x0001
doc="don't use this identity for Sync";
flags {
flag not_for_sync 0x0001
doc="don't use this identity for Sync";
flag list 0x0002
doc="identity of list of persons";
flag list 0x0002
doc="identity of list of persons";
doc | the second octet flags are calculated
doc | the second octet flags are calculated
flag devicegroup 0x0100
doc="identity of a device group member";
}
flag devicegroup 0x0100
doc="identity of a device group member";
}
} // struct Identity
protocol session {


+ 12
- 2
api/gen_c_header.ysl2 View File

@ -34,6 +34,8 @@ tstylesheet {
extern "C" {
#endif
#include <pEp/basic_types.h>
||
apply "doc|type|enum|struct", 0;
||
@ -55,18 +57,26 @@ tstylesheet {
||
typedef struct _«func:name()» {
||
apply "field|doc";
apply "field|internal|doc";
apply "field[@function='free']", mode=free;
||
} «func:name()»;
||
}
template "field" {
template "field|internal" {
apply "@doc", 0;
| «func:c-type(@type)» «@name»;
}
template "field", mode=free
||
// free function for «@name»
void (*release_«@name»)(«func:c-type(@type)» «@name»);
||
template "enum" {
||
typedef enum _«func:name()» {


+ 3
- 3
api/message_api.yml2 View File

@ -85,12 +85,12 @@ struct message {
field identity_list bcc doc='whom a BCC is being sent';
field identity_list reply_to doc='where a reply should go to';
field string_list in_reply_to doc='list of strings with MessageIDs of refering messages';
internal field message_ref refering_msg_ref doc='reference to refering message';
field any_ref refering_msg_ref doc='reference to refering message';
field string_list references doc='list of strings with references';
field message_ref_list refered_by doc='list of references to messages being refered';
field string_list refered_by doc='list of references to messages being refered';
field string_list keywords doc='list of strings with keywords';
field string comments doc='string with comments';
field stringpair_list opt_fields doc='optional fields';
field string_pair_list opt_fields doc='optional fields';
field enc_format format doc='format of encrypted data';
new (msg_direction dir);


+ 11
- 8
api/pEp.yml2 View File

@ -15,6 +15,7 @@ decl enum @name;
decl item @name;
decl struct @name;
decl field @type @name;
decl internal < field >; // internal field, p≡p engine only
decl hex is item (output=hex);
decl flag @name;
decl protocol @name;
@ -42,14 +43,16 @@ decl caveat(mode=caveat) alias doc;
// base types
// string text
// p≡p engine uses UTF-8 strings which are NFC normalized.
// Cf. https //dev.pep.foundation/Engine/Basic%20Concepts%20of%20the%20pEp%20Engine
// binary binary data
// int signed integer number
// unsigned unsigned integer number
// size_t size in memory
// bool true or false
// string text
// p≡p engine uses UTF-8 strings which are NFC normalized.
// Cf. https //dev.pep.foundation/Engine/Basic%20Concepts%20of%20the%20pEp%20Engine
// binary binary data
// int signed integer number
// unsigned unsigned integer number
// size_t size in memory
// bool true or false
// timestamp point of time
// any any type
// collections


+ 38
- 1
api/to_c.ysl2 View File

@ -41,6 +41,7 @@ def "func:basetype" {
def "func:c-type" {
param "dsltype";
choose {
// base types
when "$dsltype = 'string'"
@ -55,14 +56,50 @@ def "func:c-type" {
result > size_t
when "$dsltype = 'bool'"
result > bool
when "$dsltype = 'timestamp'"
result > timestamp
when "$dsltype = 'any'"
result > void *
// basic type definitions
when "/package/package[@name='basic']/type[@name=$dsltype]"
result > «$dsltype»
when "/package/package[@name='basic']/struct[@name=$dsltype]"
result > pEp_«$dsltype»
when "/package/package[@name='basic']/enum[@name=$dsltype]"
result > pEp_«$dsltype»
// definitions in local module
when "../../type[@name=$dsltype]"
for "../../type[@name=$dsltype]"
result > «$dsltype»
when "../../struct[@name=$dsltype]"
for "../../struct[@name=$dsltype]"
result > «func:name()»
when "../../enum[@name=$dsltype]"
for "../../enum[@name=$dsltype]"
result > «func:name()»
// definitions in other module
when "/package/package/type[@name=$dsltype]"
for "/package/package/type[@name=$dsltype]" {
warning value "concat('WARNING: type ', $dsltype, ' found in non-local module')";
result > «$dsltype»
}
when "/package/package/struct[@name=$dsltype]"
for "/package/package/struct[@name=$dsltype]" {
warning value "concat('WARNING: type ', $dsltype, ' found in non-local module')";
result > «func:name()»
}
when "/package/package/enum[@name=$dsltype]"
for "/package/package/enum[@name=$dsltype]" {
warning value "concat('WARNING: type ', $dsltype, ' found in non-local module')";
result > «func:name()»
}
// other
otherwise
result call "name" with "abbr", "$dsltype";
error value "concat('type “', $dsltype, '” not found')";
}
}

Loading…
Cancel
Save