From 882b9446cbf7316345de391188e68c2a7333da5b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 26 Dec 2020 19:21:17 +0100 Subject: Format all code with clang-format --- lv2/atom/forge.h | 422 ++++++++++++++++++++++++++----------------------------- 1 file changed, 202 insertions(+), 220 deletions(-) (limited to 'lv2/atom/forge.h') diff --git a/lv2/atom/forge.h b/lv2/atom/forge.h index 0920e0a..42471f5 100644 --- a/lv2/atom/forge.h +++ b/lv2/atom/forge.h @@ -75,52 +75,52 @@ typedef void* LV2_Atom_Forge_Sink_Handle; typedef intptr_t LV2_Atom_Forge_Ref; /** Sink function for writing output. See lv2_atom_forge_set_sink(). */ -typedef LV2_Atom_Forge_Ref -(*LV2_Atom_Forge_Sink)(LV2_Atom_Forge_Sink_Handle handle, - const void* buf, - uint32_t size); +typedef LV2_Atom_Forge_Ref (*LV2_Atom_Forge_Sink)( + LV2_Atom_Forge_Sink_Handle handle, + const void* buf, + uint32_t size); /** Function for resolving a reference. See lv2_atom_forge_set_sink(). */ -typedef LV2_Atom* -(*LV2_Atom_Forge_Deref_Func)(LV2_Atom_Forge_Sink_Handle handle, - LV2_Atom_Forge_Ref ref); +typedef LV2_Atom* (*LV2_Atom_Forge_Deref_Func)( + LV2_Atom_Forge_Sink_Handle handle, + LV2_Atom_Forge_Ref ref); /** A stack frame used for keeping track of nested Atom containers. */ typedef struct LV2_Atom_Forge_Frame { - struct LV2_Atom_Forge_Frame* parent; - LV2_Atom_Forge_Ref ref; + struct LV2_Atom_Forge_Frame* parent; + LV2_Atom_Forge_Ref ref; } LV2_Atom_Forge_Frame; /** A "forge" for creating atoms by appending to a buffer. */ typedef struct { - uint8_t* buf; - uint32_t offset; - uint32_t size; - - LV2_Atom_Forge_Sink sink; - LV2_Atom_Forge_Deref_Func deref; - LV2_Atom_Forge_Sink_Handle handle; - - LV2_Atom_Forge_Frame* stack; - - LV2_URID Blank LV2_DEPRECATED; - LV2_URID Bool; - LV2_URID Chunk; - LV2_URID Double; - LV2_URID Float; - LV2_URID Int; - LV2_URID Long; - LV2_URID Literal; - LV2_URID Object; - LV2_URID Path; - LV2_URID Property; - LV2_URID Resource LV2_DEPRECATED; - LV2_URID Sequence; - LV2_URID String; - LV2_URID Tuple; - LV2_URID URI; - LV2_URID URID; - LV2_URID Vector; + uint8_t* buf; + uint32_t offset; + uint32_t size; + + LV2_Atom_Forge_Sink sink; + LV2_Atom_Forge_Deref_Func deref; + LV2_Atom_Forge_Sink_Handle handle; + + LV2_Atom_Forge_Frame* stack; + + LV2_URID Blank LV2_DEPRECATED; + LV2_URID Bool; + LV2_URID Chunk; + LV2_URID Double; + LV2_URID Float; + LV2_URID Int; + LV2_URID Long; + LV2_URID Literal; + LV2_URID Object; + LV2_URID Path; + LV2_URID Property; + LV2_URID Resource LV2_DEPRECATED; + LV2_URID Sequence; + LV2_URID String; + LV2_URID Tuple; + LV2_URID URI; + LV2_URID URID; + LV2_URID Vector; } LV2_Atom_Forge; static inline void @@ -135,32 +135,32 @@ lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size); static inline void lv2_atom_forge_init(LV2_Atom_Forge* forge, LV2_URID_Map* map) { - lv2_atom_forge_set_buffer(forge, NULL, 0); - forge->Blank = map->map(map->handle, LV2_ATOM__Blank); - forge->Bool = map->map(map->handle, LV2_ATOM__Bool); - forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk); - forge->Double = map->map(map->handle, LV2_ATOM__Double); - forge->Float = map->map(map->handle, LV2_ATOM__Float); - forge->Int = map->map(map->handle, LV2_ATOM__Int); - forge->Long = map->map(map->handle, LV2_ATOM__Long); - forge->Literal = map->map(map->handle, LV2_ATOM__Literal); - forge->Object = map->map(map->handle, LV2_ATOM__Object); - forge->Path = map->map(map->handle, LV2_ATOM__Path); - forge->Property = map->map(map->handle, LV2_ATOM__Property); - forge->Resource = map->map(map->handle, LV2_ATOM__Resource); - forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence); - forge->String = map->map(map->handle, LV2_ATOM__String); - forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple); - forge->URI = map->map(map->handle, LV2_ATOM__URI); - forge->URID = map->map(map->handle, LV2_ATOM__URID); - forge->Vector = map->map(map->handle, LV2_ATOM__Vector); + lv2_atom_forge_set_buffer(forge, NULL, 0); + forge->Blank = map->map(map->handle, LV2_ATOM__Blank); + forge->Bool = map->map(map->handle, LV2_ATOM__Bool); + forge->Chunk = map->map(map->handle, LV2_ATOM__Chunk); + forge->Double = map->map(map->handle, LV2_ATOM__Double); + forge->Float = map->map(map->handle, LV2_ATOM__Float); + forge->Int = map->map(map->handle, LV2_ATOM__Int); + forge->Long = map->map(map->handle, LV2_ATOM__Long); + forge->Literal = map->map(map->handle, LV2_ATOM__Literal); + forge->Object = map->map(map->handle, LV2_ATOM__Object); + forge->Path = map->map(map->handle, LV2_ATOM__Path); + forge->Property = map->map(map->handle, LV2_ATOM__Property); + forge->Resource = map->map(map->handle, LV2_ATOM__Resource); + forge->Sequence = map->map(map->handle, LV2_ATOM__Sequence); + forge->String = map->map(map->handle, LV2_ATOM__String); + forge->Tuple = map->map(map->handle, LV2_ATOM__Tuple); + forge->URI = map->map(map->handle, LV2_ATOM__URI); + forge->URID = map->map(map->handle, LV2_ATOM__URID); + forge->Vector = map->map(map->handle, LV2_ATOM__Vector); } /** Access the Atom pointed to by a reference. */ static inline LV2_Atom* lv2_atom_forge_deref(LV2_Atom_Forge* forge, LV2_Atom_Forge_Ref ref) { - return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref); + return forge->buf ? (LV2_Atom*)ref : forge->deref(forge->handle, ref); } /** @@ -179,43 +179,42 @@ lv2_atom_forge_push(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, LV2_Atom_Forge_Ref ref) { - frame->parent = forge->stack; - frame->ref = ref; + frame->parent = forge->stack; + frame->ref = ref; - if (ref) { - forge->stack = frame; // Don't push, so walking the stack is always safe - } + if (ref) { + forge->stack = frame; // Don't push, so walking the stack is always safe + } - return ref; + return ref; } /** Pop a stack frame. This must be called when a container is finished. */ static inline void lv2_atom_forge_pop(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) { - if (frame->ref) { - // If frame has a valid ref, it must be the top of the stack - assert(frame == forge->stack); - forge->stack = frame->parent; - } - // Otherwise, frame was not pushed because of overflow, do nothing + if (frame->ref) { + // If frame has a valid ref, it must be the top of the stack + assert(frame == forge->stack); + forge->stack = frame->parent; + } + // Otherwise, frame was not pushed because of overflow, do nothing } /** Return true iff the top of the stack has the given type. */ static inline bool lv2_atom_forge_top_is(LV2_Atom_Forge* forge, uint32_t type) { - return forge->stack && forge->stack->ref && - (lv2_atom_forge_deref(forge, forge->stack->ref)->type == type); + return forge->stack && forge->stack->ref && + (lv2_atom_forge_deref(forge, forge->stack->ref)->type == type); } /** Return true iff `type` is an atom:Object. */ static inline bool lv2_atom_forge_is_object_type(const LV2_Atom_Forge* forge, uint32_t type) { - return (type == forge->Object || - type == forge->Blank || - type == forge->Resource); + return (type == forge->Object || type == forge->Blank || + type == forge->Resource); } /** Return true iff `type` is an atom:Object with a blank ID. */ @@ -224,8 +223,7 @@ lv2_atom_forge_is_blank(const LV2_Atom_Forge* forge, uint32_t type, const LV2_Atom_Object_Body* body) { - return (type == forge->Blank || - (type == forge->Object && body->id == 0)); + return (type == forge->Blank || (type == forge->Object && body->id == 0)); } /** @@ -238,13 +236,13 @@ lv2_atom_forge_is_blank(const LV2_Atom_Forge* forge, static inline void lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size) { - forge->buf = buf; - forge->size = (uint32_t)size; - forge->offset = 0; - forge->deref = NULL; - forge->sink = NULL; - forge->handle = NULL; - forge->stack = NULL; + forge->buf = buf; + forge->size = (uint32_t)size; + forge->offset = 0; + forge->deref = NULL; + forge->sink = NULL; + forge->handle = NULL; + forge->stack = NULL; } /** @@ -267,12 +265,12 @@ lv2_atom_forge_set_sink(LV2_Atom_Forge* forge, LV2_Atom_Forge_Deref_Func deref, LV2_Atom_Forge_Sink_Handle handle) { - forge->buf = NULL; - forge->size = forge->offset = 0; - forge->deref = deref; - forge->sink = sink; - forge->handle = handle; - forge->stack = NULL; + forge->buf = NULL; + forge->size = forge->offset = 0; + forge->deref = deref; + forge->sink = sink; + forge->handle = handle; + forge->stack = NULL; } /** @@ -289,55 +287,53 @@ lv2_atom_forge_set_sink(LV2_Atom_Forge* forge, static inline LV2_Atom_Forge_Ref lv2_atom_forge_raw(LV2_Atom_Forge* forge, const void* data, uint32_t size) { - LV2_Atom_Forge_Ref out = 0; - if (forge->sink) { - out = forge->sink(forge->handle, data, size); - } else { - out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset; - uint8_t* mem = forge->buf + forge->offset; - if (forge->offset + size > forge->size) { - return 0; - } - forge->offset += size; - memcpy(mem, data, size); - } - for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) { - lv2_atom_forge_deref(forge, f->ref)->size += size; - } - return out; + LV2_Atom_Forge_Ref out = 0; + if (forge->sink) { + out = forge->sink(forge->handle, data, size); + } else { + out = (LV2_Atom_Forge_Ref)forge->buf + forge->offset; + uint8_t* mem = forge->buf + forge->offset; + if (forge->offset + size > forge->size) { + return 0; + } + forge->offset += size; + memcpy(mem, data, size); + } + for (LV2_Atom_Forge_Frame* f = forge->stack; f; f = f->parent) { + lv2_atom_forge_deref(forge, f->ref)->size += size; + } + return out; } /** Pad output accordingly so next write is 64-bit aligned. */ static inline void lv2_atom_forge_pad(LV2_Atom_Forge* forge, uint32_t written) { - const uint64_t pad = 0; - const uint32_t pad_size = lv2_atom_pad_size(written) - written; - lv2_atom_forge_raw(forge, &pad, pad_size); + const uint64_t pad = 0; + const uint32_t pad_size = lv2_atom_pad_size(written) - written; + lv2_atom_forge_raw(forge, &pad, pad_size); } /** Write raw output, padding to 64-bits as necessary. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_write(LV2_Atom_Forge* forge, const void* data, uint32_t size) { - LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size); - if (out) { - lv2_atom_forge_pad(forge, size); - } - return out; + LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, data, size); + if (out) { + lv2_atom_forge_pad(forge, size); + } + return out; } /** Write a null-terminated string body. */ static inline LV2_Atom_Forge_Ref -lv2_atom_forge_string_body(LV2_Atom_Forge* forge, - const char* str, - uint32_t len) +lv2_atom_forge_string_body(LV2_Atom_Forge* forge, const char* str, uint32_t len) { - LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len); - if (out && (out = lv2_atom_forge_raw(forge, "", 1))) { - lv2_atom_forge_pad(forge, len + 1); - } - return out; + LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, str, len); + if (out && (out = lv2_atom_forge_raw(forge, "", 1))) { + lv2_atom_forge_pad(forge, len + 1); + } + return out; } /** @@ -350,66 +346,66 @@ lv2_atom_forge_string_body(LV2_Atom_Forge* forge, static inline LV2_Atom_Forge_Ref lv2_atom_forge_atom(LV2_Atom_Forge* forge, uint32_t size, uint32_t type) { - const LV2_Atom a = { size, type }; - return lv2_atom_forge_raw(forge, &a, sizeof(a)); + const LV2_Atom a = {size, type}; + return lv2_atom_forge_raw(forge, &a, sizeof(a)); } /** Write a primitive (fixed-size) atom. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a) { - return (lv2_atom_forge_top_is(forge, forge->Vector) - ? lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size) - : lv2_atom_forge_write( - forge, a, (uint32_t)sizeof(LV2_Atom) + a->size)); + return ( + lv2_atom_forge_top_is(forge, forge->Vector) + ? lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size) + : lv2_atom_forge_write(forge, a, (uint32_t)sizeof(LV2_Atom) + a->size)); } /** Write an atom:Int. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_int(LV2_Atom_Forge* forge, int32_t val) { - const LV2_Atom_Int a = { { sizeof(val), forge->Int }, val }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_Int a = {{sizeof(val), forge->Int}, val}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom:Long. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_long(LV2_Atom_Forge* forge, int64_t val) { - const LV2_Atom_Long a = { { sizeof(val), forge->Long }, val }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_Long a = {{sizeof(val), forge->Long}, val}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom:Float. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_float(LV2_Atom_Forge* forge, float val) { - const LV2_Atom_Float a = { { sizeof(val), forge->Float }, val }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_Float a = {{sizeof(val), forge->Float}, val}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom:Double. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_double(LV2_Atom_Forge* forge, double val) { - const LV2_Atom_Double a = { { sizeof(val), forge->Double }, val }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_Double a = {{sizeof(val), forge->Double}, val}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom:Bool. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_bool(LV2_Atom_Forge* forge, bool val) { - const LV2_Atom_Bool a = { { sizeof(int32_t), forge->Bool }, val ? 1 : 0 }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_Bool a = {{sizeof(int32_t), forge->Bool}, val ? 1 : 0}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom:URID. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_urid(LV2_Atom_Forge* forge, LV2_URID id) { - const LV2_Atom_URID a = { { sizeof(id), forge->URID }, id }; - return lv2_atom_forge_primitive(forge, &a.atom); + const LV2_Atom_URID a = {{sizeof(id), forge->URID}, id}; + return lv2_atom_forge_primitive(forge, &a.atom); } /** Write an atom compatible with atom:String. Used internally. */ @@ -419,23 +415,23 @@ lv2_atom_forge_typed_string(LV2_Atom_Forge* forge, const char* str, uint32_t len) { - const LV2_Atom_String a = { { len + 1, type } }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a)); - if (out) { - if (!lv2_atom_forge_string_body(forge, str, len)) { - LV2_Atom* atom = lv2_atom_forge_deref(forge, out); - atom->size = atom->type = 0; - out = 0; - } - } - return out; + const LV2_Atom_String a = {{len + 1, type}}; + LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a)); + if (out) { + if (!lv2_atom_forge_string_body(forge, str, len)) { + LV2_Atom* atom = lv2_atom_forge_deref(forge, out); + atom->size = atom->type = 0; + out = 0; + } + } + return out; } /** Write an atom:String. Note that `str` need not be NULL terminated. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len) { - return lv2_atom_forge_typed_string(forge, forge->String, str, len); + return lv2_atom_forge_typed_string(forge, forge->String, str, len); } /** @@ -446,14 +442,14 @@ lv2_atom_forge_string(LV2_Atom_Forge* forge, const char* str, uint32_t len) static inline LV2_Atom_Forge_Ref lv2_atom_forge_uri(LV2_Atom_Forge* forge, const char* uri, uint32_t len) { - return lv2_atom_forge_typed_string(forge, forge->URI, uri, len); + return lv2_atom_forge_typed_string(forge, forge->URI, uri, len); } /** Write an atom:Path. Note that `path` need not be NULL terminated. */ static inline LV2_Atom_Forge_Ref lv2_atom_forge_path(LV2_Atom_Forge* forge, const char* path, uint32_t len) { - return lv2_atom_forge_typed_string(forge, forge->Path, path, len); + return lv2_atom_forge_typed_string(forge, forge->Path, path, len); } /** Write an atom:Literal. */ @@ -464,21 +460,19 @@ lv2_atom_forge_literal(LV2_Atom_Forge* forge, uint32_t datatype, uint32_t lang) { - const LV2_Atom_Literal a = { - { (uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1), - forge->Literal }, - { datatype, - lang } - }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a)); - if (out) { - if (!lv2_atom_forge_string_body(forge, str, len)) { - LV2_Atom* atom = lv2_atom_forge_deref(forge, out); - atom->size = atom->type = 0; - out = 0; - } - } - return out; + const LV2_Atom_Literal a = { + {(uint32_t)(sizeof(LV2_Atom_Literal) - sizeof(LV2_Atom) + len + 1), + forge->Literal}, + {datatype, lang}}; + LV2_Atom_Forge_Ref out = lv2_atom_forge_raw(forge, &a, sizeof(a)); + if (out) { + if (!lv2_atom_forge_string_body(forge, str, len)) { + LV2_Atom* atom = lv2_atom_forge_deref(forge, out); + atom->size = atom->type = 0; + out = 0; + } + } + return out; } /** Start an atom:Vector. */ @@ -488,12 +482,10 @@ lv2_atom_forge_vector_head(LV2_Atom_Forge* forge, uint32_t child_size, uint32_t child_type) { - const LV2_Atom_Vector a = { - { sizeof(LV2_Atom_Vector_Body), forge->Vector }, - { child_size, child_type } - }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Vector a = {{sizeof(LV2_Atom_Vector_Body), forge->Vector}, + {child_size, child_type}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** Write a complete atom:Vector. */ @@ -504,16 +496,15 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge, uint32_t n_elems, const void* elems) { - const LV2_Atom_Vector a = { - { (uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size), - forge->Vector }, - { child_size, child_type } - }; - LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); - if (out) { - lv2_atom_forge_write(forge, elems, child_size * n_elems); - } - return out; + const LV2_Atom_Vector a = { + {(uint32_t)(sizeof(LV2_Atom_Vector_Body) + n_elems * child_size), + forge->Vector}, + {child_size, child_type}}; + LV2_Atom_Forge_Ref out = lv2_atom_forge_write(forge, &a, sizeof(a)); + if (out) { + lv2_atom_forge_write(forge, elems, child_size * n_elems); + } + return out; } /** @@ -536,9 +527,9 @@ lv2_atom_forge_vector(LV2_Atom_Forge* forge, static inline LV2_Atom_Forge_Ref lv2_atom_forge_tuple(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame) { - const LV2_Atom_Tuple a = { { 0, forge->Tuple } }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Tuple a = {{0, forge->Tuple}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** @@ -571,12 +562,10 @@ lv2_atom_forge_object(LV2_Atom_Forge* forge, LV2_URID id, LV2_URID otype) { - const LV2_Atom_Object a = { - { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Object }, - { id, otype } - }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Object a = { + {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Object}, {id, otype}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** @@ -592,12 +581,10 @@ lv2_atom_forge_resource(LV2_Atom_Forge* forge, LV2_URID id, LV2_URID otype) { - const LV2_Atom_Object a = { - { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Resource }, - { id, otype } - }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Object a = { + {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Resource}, {id, otype}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** @@ -613,12 +600,10 @@ lv2_atom_forge_blank(LV2_Atom_Forge* forge, uint32_t id, LV2_URID otype) { - const LV2_Atom_Object a = { - { (uint32_t)sizeof(LV2_Atom_Object_Body), forge->Blank }, - { id, otype } - }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Object a = { + {(uint32_t)sizeof(LV2_Atom_Object_Body), forge->Blank}, {id, otype}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** @@ -627,11 +612,10 @@ lv2_atom_forge_blank(LV2_Atom_Forge* forge, See lv2_atom_forge_object() documentation for an example. */ static inline LV2_Atom_Forge_Ref -lv2_atom_forge_key(LV2_Atom_Forge* forge, - LV2_URID key) +lv2_atom_forge_key(LV2_Atom_Forge* forge, LV2_URID key) { - const LV2_Atom_Property_Body a = { key, 0, { 0, 0 } }; - return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); + const LV2_Atom_Property_Body a = {key, 0, {0, 0}}; + return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); } /** @@ -645,8 +629,8 @@ lv2_atom_forge_property_head(LV2_Atom_Forge* forge, LV2_URID key, LV2_URID context) { - const LV2_Atom_Property_Body a = { key, context, { 0, 0 } }; - return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); + const LV2_Atom_Property_Body a = {key, context, {0, 0}}; + return lv2_atom_forge_write(forge, &a, 2 * (uint32_t)sizeof(uint32_t)); } /** @@ -657,12 +641,10 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, uint32_t unit) { - const LV2_Atom_Sequence a = { - { (uint32_t)sizeof(LV2_Atom_Sequence_Body), forge->Sequence }, - { unit, 0 } - }; - return lv2_atom_forge_push( - forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); + const LV2_Atom_Sequence a = { + {(uint32_t)sizeof(LV2_Atom_Sequence_Body), forge->Sequence}, {unit, 0}}; + return lv2_atom_forge_push( + forge, frame, lv2_atom_forge_write(forge, &a, sizeof(a))); } /** @@ -673,7 +655,7 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge, static inline LV2_Atom_Forge_Ref lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames) { - return lv2_atom_forge_write(forge, &frames, sizeof(frames)); + return lv2_atom_forge_write(forge, &frames, sizeof(frames)); } /** @@ -684,13 +666,13 @@ lv2_atom_forge_frame_time(LV2_Atom_Forge* forge, int64_t frames) static inline LV2_Atom_Forge_Ref lv2_atom_forge_beat_time(LV2_Atom_Forge* forge, double beats) { - return lv2_atom_forge_write(forge, &beats, sizeof(beats)); + return lv2_atom_forge_write(forge, &beats, sizeof(beats)); } LV2_RESTORE_WARNINGS #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif /** @@ -698,4 +680,4 @@ LV2_RESTORE_WARNINGS @} */ -#endif /* LV2_ATOM_FORGE_H */ +#endif /* LV2_ATOM_FORGE_H */ -- cgit v1.2.1