Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base64/base64.c2
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public fn i32 decode(const i8* in, u32 len, u8* out) {
i8 cc;
switch (i % 4) {
case 0:
cc = (c << 2);
cc = (i8)(c << 2);
out[j] = cast<u8>(cc);
//out[j] = cast<u8>((c << 2) & 0xFF); // TODO c2c assert fails on cast
continue;
Expand All @@ -95,15 +95,15 @@ public fn i32 decode(const i8* in, u32 len, u8* out) {
// if not last char with padding
if (i < (len -3) || in[len -2] != PAD) {
//out[j] = cast<u8>((c & 0xF) << 4); // TODO c2c assert fails on cast
cc = (c & 0xF) << 4;
cc = (i8)((c & 0xF) << 4);
out[j] = cast<u8>(cc);
}
continue;
case 2:
out[j++] += (c >> 2) & 0xF;
if (i < (len -2) || in[len -1] != PAD) {
//out[j] = cast<u8>((c & 0x3) << 6); // TODO c2c assert fails on cast
cc = (c & 0x3) << 6;
cc = (i8)((c & 0x3) << 6);
out[j] = cast<u8>(cc);
}
continue;
Expand Down
14 changes: 14 additions & 0 deletions plugin/plugin1.c2
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@ import other;

import stdio;

public i32[] array1 = { 1, 2, 3 }

public i32[+] array2;

array2 += 4;
array2 += 5;
array2 += 6;
array2 += 7;

public i32[5] array3 = { 8, 9, 10, 11, 12 }

public fn void load(i32 arg) {
stdio.printf("Plugin1.load() %d\n", arg);
stdio.printf("other.test1 = %p\n", other.test1);
stdio.printf("plugin1.array1 = %d\n", elemsof(array1));
stdio.printf("plugin1.array2 = %d\n", elemsof(array2));
stdio.printf("plugin1.array3 = %d\n", elemsof(array3));
other.test1();
}

43 changes: 43 additions & 0 deletions plugin/test_lib.c2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module test;

import stdio local;
import plugin_main;

public fn i32 main() {
#if 1
u32 len1 = elemsof(plugin_main.array1);
#else
u32 len1 = 3;
#endif
printf("i32[%d] plugin1.array1 = { ", len1);
for (u32 i = 0; i < len1; i++) {
printf("%d, ", plugin_main.array1[i]);
}
printf("};\n");

#if 1
u32 len2 = elemsof(plugin_main.array2);
#else
// length of incremental arrays is not exposed in the interface
u32 len2 = 4;
#endif
printf("i32[%d] plugin1.array2 = { ", len2);
for (u32 i = 0; i < len2; i++) {
printf("%d, ", plugin_main.array2[i]);
}
printf("};\n");

#if 1
u32 len3 = elemsof(plugin_main.array3);
#else
// length of incremental arrays is not exposed in the interface
u32 len3 = 5;
#endif
printf("i32[%d] plugin1.array3 = { ", len3);
for (u32 i = 0; i < len3; i++) {
printf("%d, ", plugin_main.array3[i]);
}
printf("};\n");

return 0;
}
7 changes: 7 additions & 0 deletions recipe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ executable plugin_mgr
plugin/plugin_mgr.c2
end

executable test_lib
$warnings no-unused
$backend c
$use plugin1 dynamic
plugin/test_lib.c2
end

executable pthread_test
$warnings no-unused
$backend c
Expand Down