From f026ab0b1f166eac780f3294743cd28135ec3d67 Mon Sep 17 00:00:00 2001 From: Volker Birk Date: Tue, 31 Mar 2020 10:16:23 +0200 Subject: [PATCH] ... --- api/Makefile | 4 ++-- api/basic_api.yml2 | 18 ++++++++++++++++++ api/message_api.yml2 | 8 ++++---- api/pEp.yml2 | 6 +++--- api/to_c.ysl2 | 17 +++++++++++++++-- 5 files changed, 42 insertions(+), 11 deletions(-) diff --git a/api/Makefile b/api/Makefile index 5d03cf88..d71aad0b 100644 --- a/api/Makefile +++ b/api/Makefile @@ -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 diff --git a/api/basic_api.yml2 b/api/basic_api.yml2 index b05ce5df..a1455d40 100644 --- a/api/basic_api.yml2 +++ b/api/basic_api.yml2 @@ -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 >; diff --git a/api/message_api.yml2 b/api/message_api.yml2 index 8ffd30d9..2db738f7 100644 --- a/api/message_api.yml2 +++ b/api/message_api.yml2 @@ -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'; diff --git a/api/pEp.yml2 b/api/pEp.yml2 index 1ce823bb..4f9f0ce7 100644 --- a/api/pEp.yml2 +++ b/api/pEp.yml2 @@ -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 diff --git a/api/to_c.ysl2 b/api/to_c.ysl2 index fc57d10c..661c9e11 100644 --- a/api/to_c.ysl2 +++ b/api/to_c.ysl2 @@ -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"; } }