Browse Source

...

generate_api
Volker Birk 2 years ago
parent
commit
f026ab0b1f
5 changed files with 42 additions and 11 deletions
  1. +2
    -2
      api/Makefile
  2. +18
    -0
      api/basic_api.yml2
  3. +4
    -4
      api/message_api.yml2
  4. +3
    -3
      api/pEp.yml2
  5. +15
    -2
      api/to_c.ysl2

+ 2
- 2
api/Makefile View File

@ -3,13 +3,13 @@ all: basic_api.h
YML2=$(wildcard *.yml2)
YSL2=$(wildcard *.ysl2)
%.xml: %.yml2 $(YML2) $(YSL2)
%.xml: %.yml2
yml2proc -P $< -o $@
%.xsl: %.ysl2
yml2proc -DP $< -o $@
%.h: $(YML2) $(YSL2) pEp.xml
%.h: $(YML2) $(YSL2)
yml2proc -y gen_c_header.ysl2 pEp.yml2
.PHONY: clean


+ 18
- 0
api/basic_api.yml2 View File

@ -20,6 +20,24 @@ 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;
enum content_disposition {
item attachment 0;
item inline 1;
item other -1 doc="must be affirmatively set";
}
struct blob {
field binary_ref value;
field size_t size;
field string mime_type;
field string filename;
content_disposition disposition;
internal any_ref release_value;
}
type blob_list is list< blob >;
type identity_list is list< identity >;


+ 4
- 4
api/message_api.yml2 View File

@ -1,6 +1,6 @@
// p≡p Message API
// Copyleft (c) 2019, p≡p foundation
// Copyleft (c) 2019-2020, p≡p foundation
// this file is under GNU General Public License 3.0
// see LICENSE.txt
@ -38,7 +38,7 @@ enum rating {
item cannot_decrypt 1;
item have_no_key 2;
item unencrypted 3;
// 5 is reserved
// 4 is reserved
item unreliable 5;
doc "yellow";
@ -74,7 +74,7 @@ struct message {
field string longmsg doc='string of long message (plain)';
field string longmsg_formatted doc='string of long message (formatted)';
field blob_list attachments doc='blobs with attachements';
field blob_ref rawmsg_ref doc='reference to raw message data';
field binary_ref rawmsg_ref doc='reference to raw message data';
field size_t rawmsg_size doc='size of raw message data';
field timestamp sent doc='when the message is sent';
field timestamp recv doc='when the message is received';
@ -85,7 +85,7 @@ 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';
field message_ref refering_msg_ref doc='reference to refering message';
internal field message_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 keywords doc='list of strings with keywords';


+ 3
- 3
api/pEp.yml2 View File

@ -45,9 +45,9 @@ decl caveat(mode=caveat) alias doc;
// 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
// int integer number
// blob Binary Large Object
// binary binary data
// int signed integer number
// unsigned unsigned integer number
// size_t size in memory
// bool true or false


+ 15
- 2
api/to_c.ysl2 View File

@ -42,14 +42,27 @@ def "func:basetype" {
def "func:c-type" {
param "dsltype";
choose {
// base types
when "$dsltype = 'string'"
result > char *
when "$dsltype = 'binary'"
result > unsigned char *
result > char *
when "$dsltype = 'int'"
result > int
when "$dsltype = 'unsigned'"
result > unsigned int
when "$dsltype = 'size_t'"
result > size_t
when "$dsltype = 'bool'"
result > bool
// basic type definitions
when "/package/package[@name='basic']/type[@name=$dsltype]"
result > «$dsltype»
// other
otherwise
result "$dsltype";
result call "name" with "abbr", "$dsltype";
}
}

Loading…
Cancel
Save