mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Dynamic protocols.
This commit is contained in:
committed by
Christoffer Lerno
parent
4cc30c0d33
commit
49c4595457
@@ -13,7 +13,7 @@ fn void EnumMap.init(&self, ValueType init_value)
|
||||
}
|
||||
}
|
||||
|
||||
fn usz! EnumMap.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! EnumMap.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
usz n = formatter.print("{ ")!;
|
||||
foreach (i, &value : self.values)
|
||||
@@ -25,7 +25,7 @@ fn usz! EnumMap.to_format(&self, Formatter* formatter) @dynamic
|
||||
return n;
|
||||
}
|
||||
|
||||
fn String EnumMap.to_string(&self, Allocator* using = mem::heap()) @dynamic
|
||||
fn String EnumMap.to_string(&self, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return string::printf("%s", *self);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ fn EnumSet EnumSet.xor_of(&self, EnumSet s)
|
||||
$endif
|
||||
}
|
||||
|
||||
fn usz! EnumSet.to_format(&set, Formatter* formatter) @dynamic
|
||||
fn usz! EnumSet.to_format(&set, Formatter* formatter) : Printable
|
||||
{
|
||||
usz n = formatter.print("[")!;
|
||||
bool found;
|
||||
@@ -140,7 +140,7 @@ fn usz! EnumSet.to_format(&set, Formatter* formatter) @dynamic
|
||||
return n;
|
||||
}
|
||||
|
||||
fn String EnumSet.to_string(&set, Allocator* using = mem::heap()) @dynamic
|
||||
fn String EnumSet.to_string(&set, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return string::printf("%s", *set);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import std::io;
|
||||
import std::math;
|
||||
|
||||
def ElementPredicate = fn bool(Type *type);
|
||||
def ElementTest = fn bool(Type *type, any context);
|
||||
def ElementTest = fn bool(Type *type, any* context);
|
||||
const ELEMENT_IS_EQUATABLE = types::is_equatable_type(Type);
|
||||
const ELEMENT_IS_POINTER = Type.kindof == POINTER;
|
||||
|
||||
@@ -42,7 +42,7 @@ fn void List.tinit(&self, usz initial_capacity = 16)
|
||||
self.init(initial_capacity, mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn usz! List.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! List.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
switch (self.size)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ fn usz! List.to_format(&self, Formatter* formatter) @dynamic
|
||||
}
|
||||
}
|
||||
|
||||
fn String List.to_string(&self, Allocator* using = mem::heap()) @dynamic
|
||||
fn String List.to_string(&self, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return string::printf("%s", *self);
|
||||
}
|
||||
@@ -286,12 +286,12 @@ macro usz List._remove_if(&self, ElementPredicate filter, bool $invert) @local
|
||||
return size - self.size;
|
||||
}
|
||||
|
||||
fn usz List.remove_using_test(&self, ElementTest filter, any context)
|
||||
fn usz List.remove_using_test(&self, ElementTest filter, any* context)
|
||||
{
|
||||
return self._remove_using_test(filter, false, context);
|
||||
}
|
||||
|
||||
fn usz List.retain_using_test(&self, ElementTest filter, any context)
|
||||
fn usz List.retain_using_test(&self, ElementTest filter, any* context)
|
||||
{
|
||||
return self._remove_using_test(filter, true, context);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ struct Object
|
||||
}
|
||||
|
||||
|
||||
fn usz! Object.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! Object.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
switch (self.type)
|
||||
{
|
||||
|
||||
@@ -133,12 +133,12 @@ fn Type PrivatePriorityQueue.peek_at(&self, usz index) @operator([])
|
||||
return self.heap[index];
|
||||
}
|
||||
|
||||
fn usz! PrivatePriorityQueue.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! PrivatePriorityQueue.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
return self.heap.to_format(formatter);
|
||||
}
|
||||
|
||||
fn String PrivatePriorityQueue.to_string(&self, Allocator* using = mem::heap()) @dynamic
|
||||
fn String PrivatePriorityQueue.to_string(&self, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return self.heap.to_string(using);
|
||||
}
|
||||
@@ -29,12 +29,12 @@ fn Type Range.get(&self, usz index) @operator([])
|
||||
return self.start + (Type)index;
|
||||
}
|
||||
|
||||
fn String Range.to_string(&self, Allocator* using = mem::heap()) @dynamic
|
||||
fn String Range.to_string(&self, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return string::printf("[%s..%s]", self.start, self.end);
|
||||
}
|
||||
|
||||
fn usz! Range.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! Range.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
return formatter.printf("[%s..%s]", self.start, self.end)!;
|
||||
}
|
||||
@@ -56,12 +56,12 @@ fn bool ExclusiveRange.contains(&self, Type value) @inline
|
||||
return value >= self.start && value < self.end;
|
||||
}
|
||||
|
||||
fn usz! ExclusiveRange.to_format(&self, Formatter* formatter) @dynamic
|
||||
fn usz! ExclusiveRange.to_format(&self, Formatter* formatter) : Printable
|
||||
{
|
||||
return formatter.printf("[%s..<%s]", self.start, self.end)!;
|
||||
}
|
||||
|
||||
fn String ExclusiveRange.to_string(&self, Allocator* using = mem::heap()) @dynamic
|
||||
fn String ExclusiveRange.to_string(&self, Allocator* using = mem::heap()) : Printable
|
||||
{
|
||||
return string::printf("[%s..<%s]", self.start, self.end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user