diff --git a/src/atlas.c3 b/src/atlas.c3 index 7f3a40b..c9c5f59 100644 --- a/src/atlas.c3 +++ b/src/atlas.c3 @@ -108,7 +108,7 @@ fn Point? Atlas.place(&atlas, char[] pixels, ushort w, ushort h, ushort stride) if (atlas.row.x + w <= atlas.width && atlas.row.y + h <= atlas.height) { p = atlas.row; } else { - return CANNOT_PLACE?; + return CANNOT_PLACE~; } } diff --git a/src/cache.c3 b/src/cache.c3 index 5d85494..f6c523b 100644 --- a/src/cache.c3 +++ b/src/cache.c3 @@ -1,4 +1,4 @@ -module cache{Key, Value, SIZE}; +module cache; /* LRU Cache * The cache uses a pool (array) to store all the elements, each element has @@ -29,7 +29,7 @@ struct Cache { } // Every CACHE_CYCLES operations mark as not-present the unused elements -macro Cache.cycle(&cache) @private { +macro Cache.cycle(&cache) { cache.cycle_count++; if (cache.cycle_count > CACHE_NCYCLES) { for (usz i = 0; i < cache.present.data.len; i++) { @@ -64,14 +64,14 @@ fn Value*? Cache.search(&cache, Key id) /* MISS, wrong key */ if (entry.key != id) { cache.table.remove(id)!; - return NOT_FOUND?; + return NOT_FOUND~; } /* MISS, the data is not valid (not present) */ if (!cache.present[entry.value]) { // if the data is not present but it is still in the table, remove it cache.table.remove(id)!; - return NOT_FOUND?; + return NOT_FOUND~; } /* HIT, set as recently used */ @@ -94,7 +94,7 @@ fn void Cache.remove(&cache, Key id) /* Look for a free spot in the present bitmap and return its index */ /* If there is no free space left then just return the first position */ -fn usz Cache.get_free_spot(&cache) @private +fn usz Cache.get_free_spot(&cache) { // TODO: in the upgrade to c3 1.7.5 use @bitsof() const BITS = $typeof(cache.present.data[0]).sizeof*8; @@ -108,7 +108,7 @@ fn usz Cache.get_free_spot(&cache) @private return 0; } -fn Value*? Cache.insert_at(&cache, Value* g, Key id, usz index) @private +fn Value*? Cache.insert_at(&cache, Value* g, Key id, usz index) { // TODO: verify index, g and id Value* spot; @@ -136,7 +136,7 @@ fn Value*? Cache.get_or_insert(&cache, Value* g, Key id, bool *is_new = null) Value*? c = cache.search(id); if (catch e = c) { if (e != NOT_FOUND) { - return e?; + return e~; } else { // if the element is new (inserted) set the is_new flag if (is_new) *is_new = true; diff --git a/src/core.c3 b/src/core.c3 index 8fc1e59..078ea45 100644 --- a/src/core.c3 +++ b/src/core.c3 @@ -183,7 +183,7 @@ fn PElemTuple? Ctx.get_elem(&ctx, Id id, ElemType type) elem.id = id; elem.layout = {}; if (is_new == false && elem.type != type) { - return WRONG_ELEMENT_TYPE?; + return WRONG_ELEMENT_TYPE~; } else { elem.type = type; } @@ -272,7 +272,7 @@ fn void? Ctx.frame_end(&ctx) { Elem* root = ctx.get_active_div()!; if (root.id != ROOT_ID) { - return WRONG_ID?; + return WRONG_ID~; } // 2. clear input fields diff --git a/src/font.c3 b/src/font.c3 index c7c1d56..afdf1f7 100644 --- a/src/font.c3 +++ b/src/font.c3 @@ -90,7 +90,7 @@ fn void? Font.load(&font, Allocator allocator, String name, ZString path, uint h font.sft.font = schrift::loadfile(path); if (font.sft.font == null) { font.table.free(); - return TTF_LOAD_FAILED?; + return TTF_LOAD_FAILED~; } schrift::SftLMetrics lmetrics; @@ -122,7 +122,7 @@ fn Glyph*? Font.get_glyph(&font, Codepoint code) if (catch excuse = gp) { if (excuse != NOT_FOUND) { - return excuse?; + return excuse~; } } else { return gp; @@ -136,11 +136,11 @@ fn Glyph*? Font.get_glyph(&font, Codepoint code) schrift::SftGMetrics gmtx; if (schrift::lookup(&font.sft, (SftUChar)code, &gid) < 0) { - return MISSING_GLYPH?; + return MISSING_GLYPH~; } if (schrift::gmetrics(&font.sft, gid, &gmtx) < 0) { - return BAD_GLYPH_METRICS?; + return BAD_GLYPH_METRICS~; } schrift::SftImage img = { @@ -150,7 +150,7 @@ fn Glyph*? Font.get_glyph(&font, Codepoint code) char[] pixels = mem::new_array(char, (usz)img.width * img.height); img.pixels = pixels; if (schrift::render(&font.sft, gid, img) < 0) { - return RENDER_ERROR?; + return RENDER_ERROR~; } glyph.code = code; @@ -217,7 +217,7 @@ fn Atlas*? Ctx.get_font_atlas(&ctx, String name) { // TODO: use the font name, for now there is only one font if (name.hash() != ctx.font.id) { - return WRONG_ID?; + return WRONG_ID~; } return &ctx.font.atlas; diff --git a/src/input.c3 b/src/input.c3 index 5bc7c31..f01322e 100644 --- a/src/input.c3 +++ b/src/input.c3 @@ -88,7 +88,7 @@ fn bool Ctx.check_key_combo(&ctx, ModKeys mod, String ...keys) fn void? Ctx.input_window_size(&ctx, short width, short height) { if (width <= 0 || height <= 0) { - return INVALID_SIZE?; + return INVALID_SIZE~; } ctx.current_input.events.resize = ctx.width != width || ctx.height != height; ctx.width = width; diff --git a/src/mtree.c3 b/src/mtree.c3 index 0481048..39536c0 100644 --- a/src/mtree.c3 +++ b/src/mtree.c3 @@ -1,4 +1,4 @@ -module mtree{Type}; +module mtree; /* ================================================================================================ * MTree, Bitmap-based tree @@ -127,7 +127,7 @@ fn int? MTree.get_free_spot(&tree) return spot; } } - return CAPACITY_EXCEEDED?; + return CAPACITY_EXCEEDED~; } <* @require idx >= 0 *> @@ -207,7 +207,7 @@ fn int? MTree.add(&tree, int parent, Type t) // if the new node does not land in the same subtree as the child we cannot do // anything since the references are immutable if (new_next/BITS != subtree) { - return CAPACITY_EXCEEDED?; + return CAPACITY_EXCEEDED~; } tree.set_used(new_next); tree.elements++; @@ -330,13 +330,13 @@ fn void MTree.prune(&tree, int parent) fn Type? MTree.get(&tree, int ref) @operator([]) { if (tree.is_used(ref)) return tree.elem_vec[ref]; - return NOT_FOUND?; + return NOT_FOUND~; } <* @param [&in] tree *> fn Type? MTree.parentof(&tree, int ref) { - if (!tree.is_used(ref)) return NOT_FOUND?; + if (!tree.is_used(ref)) return NOT_FOUND~; return tree.refs_vec[ref].parent; } diff --git a/src/sprite.c3 b/src/sprite.c3 index ab4127b..4057ae7 100644 --- a/src/sprite.c3 +++ b/src/sprite.c3 @@ -35,7 +35,7 @@ fn void? SpriteAtlas.init(&this, String name, AtlasType type, ushort width, usho { // FIXME: for now only R8G8B8A8 format is supported if (type != ATLAS_R8G8B8A8) { - return INVALID_TYPE?; + return INVALID_TYPE~; } this.id = name.hash(); diff --git a/src/string.c3 b/src/string.c3 index e6561f2..b5029cd 100644 --- a/src/string.c3 +++ b/src/string.c3 @@ -13,7 +13,7 @@ macro usz LineInfo.len(li) => li.end-li.start; alias LineStack @local = list::List{LineInfo}; -fn short Rect.y_off(Rect bounds, short height, Anchor anchor) @local +fn short Rect.y_off(Rect bounds, short height, Anchor anchor) { short off; @@ -34,7 +34,7 @@ fn short Rect.y_off(Rect bounds, short height, Anchor anchor) @local return off; } -fn short Rect.x_off(Rect bounds, short width, Anchor anchor) @local +fn short Rect.x_off(Rect bounds, short width, Anchor anchor) { short off; @@ -205,7 +205,7 @@ fn Rect? GlyphIterator.next(&self) // check if there is a next glyph and maybe update the line and offset indices if (self.anchor != TOP_LEFT) { if (self.line_idx >= self.lines.len()) { - return NO_MORE_ELEMENT?; + return NO_MORE_ELEMENT~; } LineInfo li = self.lines[self.line_idx]; @@ -213,7 +213,7 @@ fn Rect? GlyphIterator.next(&self) self.line_idx++; if (self.line_idx >= self.lines.len()) { - return NO_MORE_ELEMENT?; + return NO_MORE_ELEMENT~; } self.line_off = 0; @@ -223,7 +223,7 @@ fn Rect? GlyphIterator.next(&self) self.o.x = self.bounds.x + self.bounds.x_off(li.width, self.anchor) - li.first_off; } } else if (self.line_off >= self.text.len) { - return NO_MORE_ELEMENT?; + return NO_MORE_ELEMENT~; } String t;