mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
@ is now part of the name of an attribute or a macro. Macros without '@' must be function-like.
This commit is contained in:
@@ -52,13 +52,13 @@ fn Doc! readDoc(char[] url)
|
||||
{
|
||||
if (contains(url, "fail")) return ReadError.BAD_READ!;
|
||||
if (contains(url, "head-missing")) return { .head = null };
|
||||
if (contains(url, "title-missing")) return { @dupe(Head { .title = null })? };
|
||||
if (contains(url, "title-empty")) return { @dupe(Head { .title = @dupe((char[])"")? })? };
|
||||
if (contains(url, "title-missing")) return { dupe(Head { .title = null })? };
|
||||
if (contains(url, "title-empty")) return { dupe(Head { .title = dupe((char[])"")? })? };
|
||||
// Not particularly elegant due to missing string functions.
|
||||
int len = libc::snprintf(null, 0, "Title of %.*s", (int)url.len, url.ptr);
|
||||
char* str = mem::alloc_checked(len + 1)?;
|
||||
libc::snprintf(str, len + 1, "Title of %.*s", (int)url.len, url.ptr);
|
||||
return { @dupe(Head { .title = @dupe(str[..len - 1])? })? };
|
||||
return { dupe(Head { .title = dupe(str[..len - 1])? })? };
|
||||
}
|
||||
|
||||
fn Summary buildSummary(Doc doc)
|
||||
@@ -132,13 +132,13 @@ fn void main()
|
||||
Allocator allocator = mem::dynamic_arena_allocator(&dynamic_arena);
|
||||
foreach (char[] url : URLS)
|
||||
{
|
||||
@mem::with_allocator(allocator)
|
||||
mem::@with_allocator(allocator)
|
||||
{
|
||||
// Yes, it's pretty onerous to print strings for the moment in C3
|
||||
libc::printf(`Checking "https://%.*s/":` "\n", (int)url.len, url.ptr);
|
||||
Summary summary = readAndBuildSummary(url);
|
||||
libc::printf(" Summary: ");
|
||||
summary.print(@libc::stdout());
|
||||
summary.print(libc::stdout());
|
||||
libc::printf("\n");
|
||||
char[] title_sure = summary.title ? *summary.title : "";
|
||||
libc::printf(" Title: %.*s\n", (int)title_sure.len, title_sure.ptr);
|
||||
|
||||
@@ -462,7 +462,7 @@ fn void get_random_piece()
|
||||
incoming_piece[2][1] = MOVING;
|
||||
incoming_piece[3][1] = MOVING; //S inversa
|
||||
default:
|
||||
@unreachable();
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ struct TopoList
|
||||
|
||||
fn void sort(InputPair[] pairs, uint elements)
|
||||
{
|
||||
InputPair[] result = @array::make(InputPair, pairs.len);
|
||||
TopoList* top = @array::make(TopoList, elements);
|
||||
InputPair[] result = array::alloc(InputPair, pairs.len);
|
||||
TopoList* top = array::alloc(TopoList, elements);
|
||||
for (int i = 0; i < pairs.len; i++)
|
||||
{
|
||||
InputPair pair = pairs[i];
|
||||
assert(pair.value >= 0 && pair.value < elements);
|
||||
assert(pair.successor >= 0 && pair.successor < elements);
|
||||
top[pair.successor].count++;
|
||||
Entry* successor_entry = @mem::malloc(Entry);
|
||||
Entry* successor_entry = mem::malloc(Entry);
|
||||
*successor_entry = { pair.successor, null };
|
||||
Entry** next_ref = &top[pair.value].next;
|
||||
while (*next_ref)
|
||||
@@ -42,7 +42,7 @@ fn void sort(InputPair[] pairs, uint elements)
|
||||
}
|
||||
*next_ref = successor_entry;
|
||||
}
|
||||
int[] intout = @array::make(int, elements);
|
||||
int[] intout = array::alloc(int, elements);
|
||||
int count = 0;
|
||||
while LOOP: (1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user