changed #private to #package and #private_file to #local
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 12 Nov 2021 21:02:37 +0000 (15:02 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 12 Nov 2021 21:02:37 +0000 (15:02 -0600)
55 files changed:
CHANGELOG
core/alloc.onyx
core/alloc/arena.onyx
core/alloc/fixed.onyx
core/alloc/heap.onyx
core/alloc/logging.onyx
core/alloc/pool.onyx
core/alloc/ring.onyx
core/builtin.onyx
core/container/array.onyx
core/container/bucket_array.onyx
core/container/iter.onyx
core/container/list.onyx
core/container/map.onyx
core/container/set.onyx
core/intrinsics/atomics.onyx
core/io/file.onyx
core/io/stream.onyx
core/io/writer.onyx
core/math.onyx
core/random.onyx
core/std.onyx
core/stdio.onyx
core/string/buffer.onyx
core/string/builder.onyx
core/threads/thread.onyx
core/type_info/helper.onyx
core/wasi/env.onyx
docs/plan
modules/bmfont/bmfont_loader.onyx
modules/bmfont/position.onyx
modules/bmfont/utils.onyx
modules/immediate_mode/gl_utils.onyx
modules/immediate_mode/module.onyx
modules/js_events/js_events.onyx
modules/js_events/request_file.onyx
modules/json/parser.onyx
modules/json/tokenizer.onyx
modules/ouit/module.onyx
modules/ouit/ouit.onyx
modules/ttf/ttf.onyx
modules/ui/components/scrollable_region.onyx
modules/ui/components/textbox.onyx
modules/ui/components/workspace.onyx
modules/ui/font.onyx
modules/ui/input.onyx
modules/ui/module.onyx
modules/ui/ui.onyx
modules/vecmath/vector2.onyx
modules/wasm_utils/instructions.onyx
modules/wasm_utils/module.onyx
modules/wasm_utils/parser.onyx
modules/wasm_utils/utils.onyx
modules/webgl2/webgl2.onyx
src/parser.c

index 8b6e71def4dd0013cafee98c72096d6a4660ed81..308b4ea5b56118ad2aef7a92f7e46a220185f363 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -157,7 +157,7 @@ Additions:
     - Will also report errors in the cast is not possible.
 * Arbitrarily typed varargs. They behave similar to C-style varargs.
 * vararg_get builtin procedure to retrieve a value from a ... vararg.
-* #private_file directive for placing a symbol at file scope.
+* #local directive for placing a symbol at file scope.
 * a basic implentation of printf in the standard library.
 * use statements at the function level.
 * nested packages, i.e. 'core.array'
@@ -201,7 +201,7 @@ Additions:
 * Added println to core library; print followed by a newline.
 * Added tests/ folder and runtests.sh which will compile and execute the programs in the
     folder and test against their expected output.
-* #private_file for specifying symbols at the file scope.
+* #local for specifying symbols at the file scope.
 
 Removals:
 
index 1fc81f024b1eec705cc42b396029b38eae7947a5..f53b2223425440cfb0da62e8b2ecbd621402f46c 100644 (file)
@@ -13,7 +13,7 @@ TEMPORARY_ALLOCATOR_SIZE :: 1 << 12; // 4Kb
 heap_allocator : Allocator;
 
 // The global temp allocator, set up upon program intialization.
-#private_file
+#local
 temp_state     : ring.RingState;
 temp_allocator : Allocator;
 
index 074317a5bef0b981bfce9a1ae630be2319ef37de..8b3da21c5f27871a1820db136028fa18f05517e6 100644 (file)
@@ -25,7 +25,7 @@ ArenaState :: struct {
 
 Arena :: struct { next : ^Arena; }
 
-#private_file
+#local
 arena_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
     alloc_arena := cast(^ArenaState) data;
 
index 2ab51ee0b907a6760e264e26bcb2b3d8ab1bddf2..3e73bf2cdbd16df27038c9f8902980ffaff8f3a3 100644 (file)
@@ -15,7 +15,7 @@ FixedAllocatorData :: struct {
     size : u32;
 }
 
-#private_file
+#local
 fixed_allocator_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
     fa_data := cast(^FixedAllocatorData) data;  
 
index 2ef8848c9e03aacf3837d883d31ad16bee7ba382..afddccd2521f39c5aefb999a05abbe29fb95bff0 100644 (file)
@@ -35,7 +35,7 @@ init :: () {
 
 get_watermark :: () => cast(u32) heap_state.next_alloc;
 
-#private_file {
+#local {
     use package core.intrinsics.wasm {
         memory_size, memory_grow,
         memory_copy, memory_fill,
index 33579f3c46662853f864aa6a799be682e9ab8806..4ff900f99f123d7e9520184c8190ee59c9a2eb2a 100644 (file)
@@ -8,7 +8,7 @@ Allocation_Action_Strings := str.[
     "resize",
 ];
 
-#private_file
+#local
 logging_allocator_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
     allocator := cast(^Allocator) data;
     res := allocator.func(allocator.data, aa, size, align, oldptr);
index 1bf8504cae5b3836ff9268f6a0575f5b79130fc2..b54e5b4e4fdf45736c710e2acaabf322d4a50fad 100644 (file)
@@ -16,7 +16,7 @@ PoolAllocator :: struct (Elem: type_expr) {
     first_free : ^Elem;
 }
 
-#private_file
+#local
 pool_allocator_proc :: (pool: ^PoolAllocator($Elem), aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
     switch aa {
         case .Alloc {
index e9ff8b843ffddc7ffafc17f6c7a67fa460d88d0b..a0752f3353b2fd6761895847b5c709aaeddf5379 100644 (file)
@@ -16,7 +16,7 @@ RingState :: struct {
     curr_ptr : rawptr;
 }
 
-#private_file
+#local
 ring_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32, oldptr: rawptr) -> rawptr {
     ss := cast(^RingState) data;
 
index 7ff4865080651ec2fc70f806ce7e2a5ca6899694..3b4c41b046da4ebf8cc45ccb239a6794985180cf 100644 (file)
@@ -3,7 +3,7 @@ package builtin
 // CLEANUP: Should builtin.onyx really be including other files in the compilation?
 // Does that complicate things too much?
 #load "core/runtime/build_opts"
-#private_file runtime :: package runtime
+#local runtime :: package runtime
 
 str  :: #type []u8;
 cstr :: #type ^u8;
@@ -61,13 +61,13 @@ OnyxContext :: struct {
 }
 
 #if runtime.Runtime != runtime.Runtime_Custom {
-    #private_file default_logger :: (data: rawptr, msg: str) {
+    #local default_logger :: (data: rawptr, msg: str) {
         use package core
         println(msg);
     }
 
 } else {
-    #private_file default_logger :: (data: rawptr, msg: str) {
+    #local default_logger :: (data: rawptr, msg: str) {
         // In a custom runtime, there is no way to know how to log something.
     }
 }
@@ -98,7 +98,7 @@ log :: (msg: str, use logger: Logger = context.logger) {
 // The implementations of all of the allocators can be found in core/alloc/.
 // These need to be here so the context structure has the types and enum values.
 //
-#private_file
+#local
 Default_Allocation_Alignment :: 16
 
 AllocationAction :: enum {
@@ -107,7 +107,7 @@ AllocationAction :: enum {
     Resize;
 }
 
-#private_file
+#local
 allocator_proc :: #type (data: rawptr, action: AllocationAction, size: u32, align: u32, old_ptr: rawptr) -> rawptr;
 
 Allocator :: struct {
index 26d8ff932e881c8f2d6db535037b1433e71a47be..5f8d52397d09935bdc80c7200fc67d4adc7ec1bb 100644 (file)
@@ -158,8 +158,8 @@ fold_idx_elem :: (arr: [] $T, cmp: (T, T) -> bool) -> (i32, T) {
     return idx, elem;
 }
 
-#private_file cmp_greater :: (x, y) => x > y;
-#private_file cmp_less    :: (x, y) => x < y;
+#local cmp_greater :: (x, y) => x > y;
+#local cmp_less    :: (x, y) => x < y;
 
 greatest :: #match {
     (arr: [..] $T) -> (i32, T) { return fold_idx_elem(arr, cmp_greater); },
@@ -309,7 +309,7 @@ quicksort :: #match {
     (arr: [] $T, cmp: (^T, ^T) -> i32) do quicksort_impl(arr, cmp, 0, arr.count - 1); ,
 }
 
-#private_file {
+#local {
     quicksort_impl :: (arr: [] $T, cmp: $PredicateFunction, lo, hi: i32) {
         if lo < 0 || hi < 0 do return;
         if lo >= hi do return;
index 83b9e7ce17a4c84d6d065cda86306882cf995e6b..852985cd421bfbcf9cb373e33ded92dabab2f36f 100644 (file)
@@ -2,7 +2,7 @@
 
 package core.bucket_array
 
-#private_file array :: package core.array
+#local array :: package core.array
 
 Bucket_Array :: struct (T: type_expr) {
     allocator : Allocator;
@@ -138,7 +138,7 @@ iterator :: (b: ^Bucket_Array($T)) -> Iterator(T) {
     };
 }
 
-#private
+#package
 alloc_bucket :: (use b: ^Bucket_Array($T)) -> Bucket_Array.Bucket(T) {
     data := raw_alloc(allocator, sizeof T * elements_per_bucket);
     return .{ 0, data };
index 6a70f42213198ae677e7636301d1e11712e01772..f09f2e2c146d31a04bd3bbd8c04c2fc212b55030 100644 (file)
@@ -188,7 +188,7 @@ skip :: (it: Iterator($T), count: u32) -> Iterator(T) {
     };
 }
 
-#private_file Zipped :: struct (T: type_expr, R: type_expr) {
+#local Zipped :: struct (T: type_expr, R: type_expr) {
     first: T;
     second: R;
 }
@@ -238,7 +238,7 @@ const :: (value: $T) -> Iterator(T) {
     };
 }
 
-#private_file Enumeration_Value :: struct (T: type_expr) {
+#local Enumeration_Value :: struct (T: type_expr) {
     index: i32;
     value: T;
 }
index ceaaf3b2781df1ed32a51d059dbfd618c9a113ef..c7169efbbd3f1969675fc651255a0bd55a09a29c 100644 (file)
@@ -119,5 +119,5 @@ get_iterator :: (list: ^List($T)) -> Iterator(T) {
     };
 }
 
-#private_file
+#local
 allocate_elem :: macro (list: ^List($T)) => new(#type ListElem(T), allocator=list.allocator);
index f99b5dd80d173ed160c923080331cca682d7f3ec..a6604fa2a5607fc3bfec00cfc25fa978fdbd5685 100644 (file)
@@ -1,6 +1,6 @@
 package core.map
 
-#private_file {
+#local {
     array  :: package core.array
     hash   :: package core.hash
     memory :: package core.memory
@@ -9,7 +9,7 @@ package core.map
     use package core.intrinsics.onyx { __zero_value, __initialize }
 }
 
-#private_file {
+#local {
     ValidKey :: interface (T: type_expr) {
         // In order to use a certain type as a key in a Map, you must
         // provide an implementation of core.hash.to_u32() for that type,
@@ -147,7 +147,7 @@ empty :: (use map: ^Map($K, $V)) -> bool {
 // Private symbols
 //
 
-#private_file {
+#local {
     MapLookupResult :: struct {
         hash_index  : i32 = -1;
         entry_index : i32 = -1;
index 551e537c84db56ec2e33d44725637ef48925154d..89867cf3c1e3452a87358d68d61ed857b457a575 100644 (file)
@@ -1,6 +1,6 @@
 package core.set
 
-#private_file {
+#local {
     array :: package core.array
     hash  :: package core.hash
     memory :: package core.memory
@@ -136,7 +136,7 @@ iterator :: (set: ^Set($T)) -> Iterator(T) {
 // Private symbols
 //
 
-#private_file {
+#local {
     SetLookupResult :: struct {
         hash_index  : i32 = -1;
         entry_index : i32 = -1;
index 70cd2536fc004f8289f080da73688fb1fc4b5e55..542513bdffeca5277ed190d8a363b6c3eacac15f 100644 (file)
@@ -1,6 +1,6 @@
 package core.intrinsics.atomics
 
-#private_file {
+#local {
     runtime :: package runtime
 
     #if !runtime.Multi_Threading_Enabled {
index 4c3a7f1e5db13dc009c4d53564c369481e81a172..2606355a580d9f20f803ade8b7f4f12a028d8ce2 100644 (file)
@@ -1,13 +1,13 @@
 package core.io
 
-#private_file runtime :: package runtime
+#local runtime :: package runtime
 #if runtime.Runtime != runtime.Runtime_Wasi {
     #error "The file system library is currently only available on the WASI runtime, and should only be included if that is the chosen runtime."
 }
 
 use package core
 
-#private_file wasi :: package wasi
+#local wasi :: package wasi
 use package wasi {
     FileDescriptor,
     FDFlags, OFlags, Rights,
@@ -186,7 +186,7 @@ close :: (file: ^FileStream) {
     file.stream.vtable = null;
 }
 
-#private
+#package
 file_stream_vtable := Stream_Vtable.{
     seek = (use fs: ^FileStream, to: i32, whence: SeekFrom) -> Error {
         // Currently, the new offset is just ignored.
@@ -307,7 +307,7 @@ file_logger_close :: (logger := context.logger) {
     cfree(logger.data);
 }
 
-#private_file
+#local
 file_logger_proc :: (data: ^File, msg: str) {
     file_write(*data, msg);
     file_write(*data, "\n");
index 3d785991a4f8758b4a5568a020b5a8b3201f04e1..260c2e228fd5062cbcfe4b27fbefded4dcee9263 100644 (file)
@@ -6,7 +6,7 @@ Stream :: struct {
     vtable : ^Stream_Vtable;
 }
 
-// #private
+// #package
 Stream_Vtable :: struct {
     seek         : (s: ^Stream, to: i32, whence: SeekFrom) -> Error;
     tell         : (s: ^Stream) -> (Error, u32);
@@ -157,7 +157,7 @@ string_stream_to_str :: (use ss: ^StringStream) -> str {
     return .{ data.data, curr_pos };
 }
 
-#private
+#package
 string_stream_vtable := Stream_Vtable.{
     seek = (use ss: ^StringStream, to: i32, whence: SeekFrom) -> Error {
         if to >= data.count do return .OutOfBounds;
@@ -277,7 +277,7 @@ dynamic_string_stream_to_str :: (use dds: ^DynamicStringStream) -> str {
     return data.data[0 .. curr_pos];
 }
 
-#private
+#package
 dynamic_string_stream_vtable := Stream_Vtable.{
     seek = (use dss: ^DynamicStringStream, to: i32, whence: SeekFrom) -> Error {
         dest : i32;
index 6d9f32a9f0cb0328d623c44569d6788bcc124916..8928c98675fe332b9ad58af653ad8705147f0fa9 100644 (file)
@@ -1,6 +1,6 @@
 package core.io
 
-#private_file conv :: package core.conv
+#local conv :: package core.conv
 
 Writer :: struct {
     stream : ^Stream;
index e544a1413ef39f3860e767f35e66c28bc219e6dc..592f86bbb621cc34f00398f1ef065c64562afdd2 100644 (file)
@@ -1,6 +1,6 @@
 package core.math
 
-#private_file wasm :: package core.intrinsics.wasm
+#local wasm :: package core.intrinsics.wasm
 
 // Things that are useful in any math library:
 //  - Trigonometry
index 0bc3e50e9ba9252db79e2a98e303e63a0de78db3..bc633bd5418a0bd7306f17a7eb69bd88777f342b 100644 (file)
@@ -1,10 +1,10 @@
 package core.random
 
-#private_file seed : i64 = 8675309
+#local seed : i64 = 8675309
 
-#private_file RANDOM_MULTIPLIER :: 25214903917
-#private_file RANDOM_INCREMENT  :: cast(i64) 11
-// #private_file RANDOM_MODULUS    :: 1 << 32
+#local RANDOM_MULTIPLIER :: 25214903917
+#local RANDOM_INCREMENT  :: cast(i64) 11
+// #local RANDOM_MODULUS    :: 1 << 32
 
 set_seed :: #match {
     (s: u32) do seed = ~~s; ,
index 9ad51a9eb87bc2b9ebba25aaa99bd40f03aadce8..d1daefdf5477bead4834d3b70066f206bb3c120d 100644 (file)
@@ -36,7 +36,7 @@ package core
 
 #load "./type_info/helper"
 
-#private_file runtime :: package runtime
+#local runtime :: package runtime
 #if runtime.Runtime == runtime.Runtime_Wasi {
     #load "./runtime/wasi"
     #load "./wasi/wasi"
index 4fb13f105aa3b758dbbd91c0bf0cf4cea52b14ea..1b611fbd7636ec37c6863207bce6a30ddfbe97ac 100644 (file)
@@ -7,7 +7,7 @@ package core
 // in anyway.
 
 
-#private_file runtime :: package runtime
+#local runtime :: package runtime
 #if runtime.Runtime == runtime.Runtime_Custom {
     #error "'stdio' can only be included in the 'wasi' or 'js' runtime."
 }
index 75fecbf8459f8c97c53305a22e3291dd8abba411..40d92814734c7442114e6d87cd214da0f77eafe3 100644 (file)
@@ -6,7 +6,7 @@
 
 package core.string
 
-#private_file math :: package core.math
+#local math :: package core.math
 
 String_Buffer :: struct {
     data     : ^u8;
index b5e7f635fc56a0a6fd79279be13e6d4226ea91fc..7ff0329359cbe83ce3518abcd9b7ea56fed96921 100644 (file)
@@ -5,9 +5,9 @@ package core.string.builder
 
 #if false {
 
-#private_file array  :: package core.array
-#private_file string :: package core.string
-#private_file conv   :: package core.conv
+#local array  :: package core.array
+#local string :: package core.string
+#local conv   :: package core.conv
 
 Builder :: struct {
     data  : [..] u8;
index da13427e784c55316aeaed6c7855bc232b1599e1..2f1d8b658e494cd7ad649f1437dad802e8886833 100644 (file)
@@ -3,7 +3,7 @@ package core.thread
 use package core
 use package core.intrinsics.atomics
 
-#private {
+#package {
     runtime :: package runtime
 
     thread_mutex   : sync.Mutex;
index 2bf52c3651b1f2326f91ce5e6041d9a738a7a2a1..9ddaf5eac37dd6f8c1ef0e98d9cd82defbfd599c 100644 (file)
@@ -1,6 +1,6 @@
 package builtin.type_info
 
-#private_file io :: package core.io
+#local io :: package core.io
 
 write_type_name :: (writer: ^io.Writer, t: type_expr) {
     info := get_type_info(t);
index 67fabd25b32cd9cbac35159bb3d67846a19e07a6..dfb408d4c5986d469ae6bd084dbce6e3b98453c7 100644 (file)
@@ -6,9 +6,9 @@ package core.env
 
 
 use package wasi { environ_get, environ_sizes_get, Size }
-#private map    :: package core.map
-#private memory :: package core.memory
-#private string :: package core.string
+#package map    :: package core.map
+#package memory :: package core.memory
+#package string :: package core.string
 
 Environment :: struct {
     vars             : Map(str, str);
index 116ef9e70ee8df788c3256cc406c94210fcf28b4..80201c995a464a07edb35eb247b974f85f1da1ef 100644 (file)
--- a/docs/plan
+++ b/docs/plan
@@ -159,7 +159,7 @@ HOW:
         [X] Pointer math
             - Addition and subtraction
 
-        [X] #private
+        [X] #package
             - symbol is scoped to package and not brought in from a 'use package' statement
 
         [X] Hex literals
index 413ef4fd62fb9b53b5987f520453c29bc1d2d89a..3a31a340416acaec7e321e78bb98663b675ddb8c 100644 (file)
@@ -1,7 +1,7 @@
 package bmfont
 
 use package core
-#private_file json :: package json
+#local json :: package json
 
 load_bmfont :: (fnt_data: [] u8) -> BMFont {
     bmf := create_bmfont();
@@ -27,7 +27,7 @@ load_bmfont_from_json :: (fnt_data: [] u8) -> BMFont {
     extract_bmfont_from_json(^bmf, j.root);
 }
 
-#private_file
+#local
 create_bmfont :: () -> BMFont {
     bmf: BMFont;
     memory.set(^bmf, 0, sizeof BMFont);
@@ -38,7 +38,7 @@ create_bmfont :: () -> BMFont {
     return bmf;
 }
 
-#private_file
+#local
 parse_bmfont :: (fnt_data: [] u8, font: ^BMFont) {
     R :: package core.string.reader
 
@@ -151,7 +151,7 @@ parse_bmfont :: (fnt_data: [] u8, font: ^BMFont) {
     }
 }
 
-#private_file
+#local
 extract_bmfont_from_json :: (font: ^BMFont, root: ^json.Value) {
     font_info          := root["info"];
     font.info.face_name = font_info["face"]->as_str();
index 7f16298bb75eb15c426d17c140711172b6f6a46e..602fb91248092512dcf51bf3c103e3fbe937b34e 100644 (file)
@@ -1,6 +1,6 @@
 package bmfont
 
-#private_file {
+#local {
     math :: package core.math
 
     renderable_glyph: Renderable_Glyph;
index 5e61f5c96e795da726a34d1909d0c84dcbeba2d9..118d00fc21245c3aa6535fac7460125ede076a6c 100644 (file)
@@ -1,6 +1,6 @@
 package bmfont
 
-#private_file math :: package core.math
+#local math :: package core.math
 
 get_width :: (use font: ^BMFont, text: str, size: f32) -> f32 {
     max_x := 0.0f;
index a4b90c69f9720b76d97a3ce1405548133f13356c..a06b4877f86f8ecd43f710555a5c7a388d0cba69 100644 (file)
@@ -1,7 +1,7 @@
 package immediate_mode
 
 use package core
-#private_file gl :: package gl
+#local gl :: package gl
 
 // This Shader represents an OpenGL program, not a shader. The name
 // is confusing but conceptually for most people, shaders are a bundled
index 47fae0faed2695254047bd567eb5bba0f309f37c..2e988f13b67492aa65d95d58c03ef01f917822df 100644 (file)
@@ -7,4 +7,4 @@ package immediate_mode
 #load "./texture"
 #load "./transform"
 
-#private gl :: package gl
+#package gl :: package gl
index bb69ec41a165fabecbef76a9f4b7e6a9d6ed0ca8..38f0be35f81e27fe81e61b06526e0a89881d781d 100644 (file)
@@ -5,7 +5,7 @@
 
 package js_events
 
-#private_file Max_Buffered_Events :: 16
+#local Max_Buffered_Events :: 16
 
 // NOTE: These need to match exactly what is in the corresponding javascript
 DomEventKind :: enum {
@@ -110,7 +110,7 @@ init :: () {
     event_setup(^event_storage, sizeof Event);
 }
 
-#private_file processing_event: Event
+#local processing_event: Event
 consume :: () -> Iterator(^Event) {
     next :: (_: rawptr) -> (^Event, bool) {
         if event_storage.event_count == 0 do return null, false;
@@ -131,11 +131,11 @@ consume :: () -> Iterator(^Event) {
 
 /* Private members */
 
-#private EventStorage :: struct {
+#package EventStorage :: struct {
     event_count  : u32;
     max_events   : u32;
     event_buffer : [Max_Buffered_Events] Event;
 }
 
-#private event_storage : EventStorage;
-#private event_setup :: (event_storage: ^EventStorage, event_size: u32) -> void #foreign "js_events" "setup" ---
+#package event_storage : EventStorage;
+#package event_setup :: (event_storage: ^EventStorage, event_size: u32) -> void #foreign "js_events" "setup" ---
index bcddb23e4ebc3cefbd838fbed3de2c169ae38af1..b9d7487002b3382775e126ab773b9f474f8958e1 100644 (file)
@@ -1,7 +1,7 @@
 package js_events
 
 // 0 is reserved for dropped files
-#private_file next_request_id := 1;
+#local next_request_id := 1;
 
 request_file :: (filepath: str) -> u32 {
     js_request_file :: (event_storage: ^EventStorage, event_size: u32, filepath: str, fileid: u32) -> void #foreign "js_events" "request_file" ---;
index 68f03efad249c005079112ce3df8cbb7b6730631..7bfa9105d85c01504c5cd2c4aca2e1660da62332 100644 (file)
@@ -1,7 +1,7 @@
 package json
 use package core
 
-#private
+#package
 Parser :: struct {
     tokenizer : Tokenizer;
     allocator : Allocator;
@@ -10,7 +10,7 @@ Parser :: struct {
     previous_token : Token;
 }
 
-#private
+#package
 make_parser :: (data: [] u8, allocator := context.allocator) -> Parser {
     parser: Parser;
     parser.tokenizer = Tokenizer.{ data = data };
@@ -19,13 +19,13 @@ make_parser :: (data: [] u8, allocator := context.allocator) -> Parser {
     return parser;
 }
 
-#private
+#package
 parse :: (data: [] u8, allocator := context.allocator) -> (^Value, Error) {
     parser := make_parser(data, allocator);
     return parse_value(^parser);
 }
 
-#private_file
+#local
 consume_token :: (use parser: ^Parser) -> (Token, Error) {
     error: Error;
     previous_token = current_token;
@@ -33,7 +33,7 @@ consume_token :: (use parser: ^Parser) -> (Token, Error) {
     return previous_token, error;
 }
 
-#private_file
+#local
 consume_token_if_next :: (use parser: ^Parser, kind: Token.Kind) -> bool {
     if current_token.kind == kind {
         consume_token(parser);
@@ -43,7 +43,7 @@ consume_token_if_next :: (use parser: ^Parser, kind: Token.Kind) -> bool {
     return false;
 }
 
-#private_file
+#local
 expect_token :: (use parser: ^Parser, kind: Token.Kind) -> (Token, Error) {
     previous :=  current_token;
     consume_token(parser);
@@ -52,7 +52,7 @@ expect_token :: (use parser: ^Parser, kind: Token.Kind) -> (Token, Error) {
     return previous, error;
 }
 
-#private
+#package
 parse_value :: (use parser: ^Parser) -> (^Value, Error) {
     return_value: ^Value = null;
 
@@ -120,7 +120,7 @@ parse_value :: (use parser: ^Parser) -> (^Value, Error) {
     return return_value, .{ .None };
 }
 
-#private_file
+#local
 parse_array :: (use parser: ^Parser) -> (^Value_Array, Error) {
     value := new(Value_Array, allocator);
 
@@ -162,7 +162,7 @@ parse_array :: (use parser: ^Parser) -> (^Value_Array, Error) {
 }
 
 
-#private_file
+#local
 parse_object :: (use parser: ^Parser) -> (^Value_Object, Error) {
     value := new(Value_Object, allocator);
 
@@ -228,7 +228,7 @@ parse_object :: (use parser: ^Parser) -> (^Value_Object, Error) {
 }
 
 
-#private_file
+#local
 unescape_string :: (token: Token, allocator: Allocator) -> str {
     if token.kind != .String do return "";
 
index 0bb7eea4ce4c7c97be07fc3dd70ee995b55edd69..32a7ed610b9a24810a2b3f2704a9adb8b3cddfdf 100644 (file)
@@ -1,4 +1,4 @@
-// Everything in this file is marked #private because I do not think
+// Everything in this file is marked #package because I do not think
 // that this code will be needed outside of this module. I do not see
 // the value of having access to the tokenizer and parser of JSON directly.
 
@@ -6,13 +6,13 @@
 package json
 use package core
 
-#private
+#package
 Tokenizer :: struct {
     data: [] u8;
     use position := Position.{ 0, 1, 1 };
 }
 
-#private
+#package
 Token :: struct {
     Kind :: enum {
         Invalid;
@@ -40,13 +40,13 @@ Token :: struct {
     use position := Position.{ 0, 1, 1 };
 }
 
-#private
+#package
 Position :: struct {
     offset       : u32;  // Offset into the stream
     line, column : u32;  // Line and column number
 }
 
-#private
+#package
 token_get :: (use tkn: ^Tokenizer) -> (Token, Error) {
     err := Error.{};
 
@@ -138,7 +138,7 @@ token_get :: (use tkn: ^Tokenizer) -> (Token, Error) {
     return token, err;
 }
 
-#private_file
+#local
 next_character :: (use tkn: ^Tokenizer) -> (u8, bool) {
     if offset >= data.count do return 0, false;
 
@@ -149,7 +149,7 @@ next_character :: (use tkn: ^Tokenizer) -> (u8, bool) {
     return retval, true;
 }
 
-#private_file
+#local
 skip_whitespace :: (use tkn: ^Tokenizer) {
     while offset < data.count {
         switch data[offset] {
@@ -170,7 +170,7 @@ skip_whitespace :: (use tkn: ^Tokenizer) {
     }
 }
 
-#private_file
+#local
 skip_alpha_numeric :: (use tkn: ^Tokenizer) {
     while offset < data.count {
         switch data[offset] {
@@ -184,7 +184,7 @@ skip_alpha_numeric :: (use tkn: ^Tokenizer) {
     }
 }
 
-#private_file
+#local
 skip_numeric :: (use tkn: ^Tokenizer) {
     while offset < data.count {
         switch data[offset] {
@@ -198,7 +198,7 @@ skip_numeric :: (use tkn: ^Tokenizer) {
     }
 }
 
-#private_file
+#local
 skip_escape :: (use tkn: ^Tokenizer) {
     switch data[offset] {
         case #char "u" {
index 060f0ab7a8fc7bfc37e11a4ed3458763d8fa91ee..3200961f8b6829773f9c7b6562d3ecc83e55b66d 100644 (file)
@@ -16,5 +16,6 @@ it easy to setup a web-based user interface.
 #load "modules/js_events/module"
 #load "modules/ui/module"
 #load "modules/webgl2/module"
+#load "modules/json/module"
 
-#load "./ouit"
\ No newline at end of file
+#load "./ouit"
index 726d1078de6384faf08714c2dd5770c29ca7b12e..24d63d4f51b3bb7103d71085cf8178f42c43751d 100644 (file)
@@ -1,6 +1,6 @@
 package ouit
 
-#private_file {
+#local {
     gl     :: package gl
     gfx    :: package immediate_mode
     events :: package js_events
@@ -22,7 +22,7 @@ init :: (canvas_name: str,
     ouit_draw         = d;
 }
 
-#private {
+#package {
     ouit_handle_event : (^events.Event) -> void;
     ouit_update       : (dt: f32)       -> void;
     ouit_draw         : ()              -> void;
index 07a68b50110c0641eae38572f139285a25ce383d..bb9c362d84303201e9760fc51c0fb2190d42aa12 100644 (file)
@@ -131,7 +131,7 @@ ttf_create :: (ttf_data: [] u8) -> True_Type_Font {
     return ttf;
 }
 
-#private
+#package
 ttf_read_offset_table :: (use ttf: ^True_Type_Font) {
     scalar_type = reader->get_u32();
     num_tables := reader->get_u16();
@@ -162,7 +162,7 @@ ttf_read_offset_table :: (use ttf: ^True_Type_Font) {
     }
 }
 
-#private
+#package
 ttf_read_head_table :: (use ttf: ^True_Type_Font) {
     head_table_info  := map.get(^tables, string_to_beu32("head"));
     reader->seek(head_table_info.offset);
@@ -246,7 +246,7 @@ ttf_glyph_destroy :: (glyph: ^TTF_Glyph, allocator := context.allocator) {
     raw_free(allocator, glyph);
 }
 
-#private_file
+#local
 TTF_Glyph_Flags :: enum #flags {
     On_Curve  :: 0x01;
     X_Is_Byte :: 0x02;
@@ -256,7 +256,7 @@ TTF_Glyph_Flags :: enum #flags {
     Y_Delta   :: 0x20;
 }
 
-#private_file
+#local
 ttf_read_simple_glyph :: (use ttf: ^True_Type_Font, glyph: ^TTF_Glyph) {
     array.init(^glyph.contour_ends, ~~glyph.contour_count);
     array.init(^glyph.points);
@@ -423,13 +423,13 @@ ttf_lookup_glyph_by_char :: (use ttf: ^True_Type_Font, charcode: u32) -> u32 {
     return potential_code;
 }
 
-#private_file
+#local
 ttf_lookup_in_cmap0 :: (use ttf: ^True_Type_Font, cmap: ^TTF_Cmap0, charcode: u32) -> u32 {
     if charcode < 0 || charcode >= 256 do return 0;
     return ~~cmap.glyph_indicies[charcode];
 }
 
-#private_file
+#local
 ttf_lookup_in_cmap4 :: (use ttf: ^True_Type_Font, cmap: ^TTF_Cmap4, charcode: u32) -> u32 {
     if map.has(^cmap.cache, charcode) do return map.get(^cmap.cache, charcode);
 
@@ -511,7 +511,7 @@ ttf_lookup_horizontal_metrics :: (use ttf: ^True_Type_Font, glyph_index: u32) ->
 }
 
 
-#private_file
+#local
 ttf_calc_table_checksum :: (reader: ^TTF_Reader, offset: u32, length: u32) -> u32 {
     old := reader->seek(offset);
     defer reader->seek(old);
@@ -522,7 +522,7 @@ ttf_calc_table_checksum :: (reader: ^TTF_Reader, offset: u32, length: u32) -> u3
     return sum;
 }
 
-#private_file
+#local
 string_to_beu32 :: (s: str) -> u32 {
     return (cast(u32) s[0] << 24)
          | (cast(u32) s[1] << 16)
index c946319456669bc223cd8715a53c71b63df80714..b2e473bfab426df5dc752a1f2746af15d2b2bc83 100644 (file)
@@ -9,7 +9,7 @@ Scrollable_Region_State :: struct {
     };
 }
 
-#private
+#package
 scrollable_region_states : Map(UI_Id, Scrollable_Region_State);
 
 Scrollable_Region_Controls :: struct {
index 052c475316cc2aac12f4ce95d523717f372c0c6e..6a96d66a98596d76f06584412d9743f933cfb648 100644 (file)
@@ -29,7 +29,7 @@ Textbox_Theme :: struct {
 
 default_textbox_theme := Textbox_Theme.{};
 
-#private_file
+#local
 Textbox_Editing_State :: struct {
     hash: UI_Id = 0;
 
@@ -39,7 +39,7 @@ Textbox_Editing_State :: struct {
     cursor_animation_speed := 0.02f;
 }
 
-#private
+#package
 // There is only one 'Textbox_Editing_State', not a map of them because there can only be one textbox being edited at once.
 textbox_editing_state := Textbox_Editing_State.{};
 
@@ -182,7 +182,7 @@ textbox :: (use r: Rectangle, text_buffer: ^string.String_Buffer, placeholder :=
     return result;
 }
 
-#private_file
+#local
 get_cursor_location :: (text_buffer: ^string.String_Buffer, text_x: f32, text_y: f32, text_size: f32, cursor_position: i32) -> f32 {
     countdown := cursor_position + 1;
     last_x : f32 = text_x;
@@ -205,7 +205,7 @@ get_cursor_location :: (text_buffer: ^string.String_Buffer, text_x: f32, text_y:
     return last_x + last_w;
 }
 
-#private_file
+#local
 get_cursor_position :: (text_buffer: ^string.String_Buffer, text_x: f32, text_y: f32, text_size: f32, mouse_x: f32, mouse_y: f32) -> i32 {
     cursor_position := 0;
 
index d5f4f275ac27cd39a8689031faecab13814ead46..853c28b06c28e8a0db35a58926bcc4b618cd709a 100644 (file)
@@ -20,7 +20,7 @@ Workspace_State :: struct {
     dragging := false;
 }
 
-#private
+#package
 workspace_states : Map(UI_Id, Workspace_State);
 
 workspace_start :: (use r: Rectangle, site := #callsite, state: ^Workspace_State = null) {
index 6d8a82a7e8b595f44eb18c32a44d97c3108d20aa..88567247a9a12b2ef2e9f1a38cacd075f800ff9f 100644 (file)
@@ -2,7 +2,7 @@ package ui
 
 // A simple wrapper for a BMFont and an OpenGL Texture
 
-#private_file RK :: enum { Luminance; Color; }
+#local RK :: enum { Luminance; Color; }
 
 Font :: struct {
     texture : gfx.Texture;
@@ -71,7 +71,7 @@ create_font :: (bmfont_data: [] u8, font_texture_data: [] u8) -> Font {
 
 Font_Index :: i32;
 
-#private font_registry : Map(Font_Index, Font);
+#package font_registry : Map(Font_Index, Font);
 register_font :: (index: Font_Index, font: Font) {
     assert(!map.has(^font_registry, index), "Font with this index already exists.");
     map.put(^font_registry, index, font);
index 3d885871b1e156992aef0489b2d77630acdf2d35..604238addffa0e27c06eda9725188c2d052cf425 100644 (file)
@@ -67,7 +67,7 @@ update_mouse_position :: (new_x: f32, new_y: f32) {
     mouse_state.y_  = new_y;
 }
 
-#private_file Mouse_Button_Kind :: enum { Left; Right; Middle; WheelUp; WheelDown; }
+#local Mouse_Button_Kind :: enum { Left; Right; Middle; WheelUp; WheelDown; }
 
 button_pressed :: (kind: Mouse_Button_Kind) {
     switch kind {
@@ -103,7 +103,7 @@ button_released :: (kind: Mouse_Button_Kind) {
     }
 }
 
-#private_file
+#local
 __key_state_transition_table := Keyboard_State.Key_State.[
                     /* KeyUp */                        /* KeyDown */
     /* Up */        Keyboard_State.Key_State.Up,       Keyboard_State.Key_State.Just_Down,
index a492917b7fc05f13ddc8fe53af88b630b954abc6..c88379728ccf820e60f27d1c4d4a9ccc8c3d31bc 100644 (file)
@@ -53,9 +53,9 @@ package ui
 #load "./components/scrollable_region"
 
 // Package inclusions that are part of all files in the "ui" package.
-#private gfx    :: package immediate_mode    // The immediate_mode module needs to be accessible
-#private gl     :: package gl
-#private bmfont :: package bmfont
+#package gfx    :: package immediate_mode    // The immediate_mode module needs to be accessible
+#package gl     :: package gl
+#package bmfont :: package bmfont
 
-#private math   :: package core.math
-#private map    :: package core.map
\ No newline at end of file
+#package math   :: package core.math
+#package map    :: package core.map
\ No newline at end of file
index bf2ba31161176388aef18bf2661f96b62388f42c..0246486035f755892911df11f6b014543c7f26ef 100644 (file)
@@ -7,7 +7,7 @@ DEFAULT_TEXT_SIZE :: 1.0f
 
 UI_Id :: #type u32
 
-#private {
+#package {
     hot_item    : UI_Id = 0
     active_item : UI_Id = 0
     hot_item_was_set := false
@@ -78,8 +78,8 @@ set_active_item :: (id: UI_Id) -> bool {
     return true;
 }
 
-#private_file hot_item_depth := 0;
-#private_file hot_item_depth_needed := 0;
+#local hot_item_depth := 0;
+#local hot_item_depth_needed := 0;
 
 set_hot_item :: (id: UI_Id, force := false) -> bool {
     if active_item != 0 do return false;
@@ -192,7 +192,7 @@ Animation_Theme :: struct {
 // Animation states are stored globally as there is not much to the state of a button.
 // Forcing the end user to store a structure for each button that is just the animation
 // state of the component feels very wrong.
-#private_file animation_states : Map(UI_Id, Animation_State);
+#local animation_states : Map(UI_Id, Animation_State);
 
 Animation_State :: struct {
     hover_time := 0.0f;
@@ -249,7 +249,7 @@ move_towards :: macro (value: ^$T, target: T, step: T) {
     if *value > target - step && *value < target + step do *value = target;
 }
 
-#private color_lerp :: macro (t: f32, c1: gfx.Color4, c2: gfx.Color4) -> gfx.Color4 {
+#package color_lerp :: macro (t: f32, c1: gfx.Color4, c2: gfx.Color4) -> gfx.Color4 {
     return .{
         r = c1.r * (1 - t) + c2.r * t,
         g = c1.g * (1 - t) + c2.g * t,
index 2ebe62e3e30f4cd7e5385f345e9751bba33552ac..cd1864805c126f4f342d6fe7c2d64e96b191ec0f 100644 (file)
@@ -1,6 +1,6 @@
 package vecmath
 
-#private_file io :: package core.io
+#local io :: package core.io
 use package core.intrinsics.onyx { __zero_value }
 
 Vector2i :: #type Vector2(i32);
index c826c1316ec0c06e449d7d6c0c83e739a75ca409..72380e3c9f20b3b57fea7637db82621f9fa5e5b3 100644 (file)
@@ -269,7 +269,7 @@ instructions_as_array :: (binary: ^WasmBinary, code: ^WasmCode, allocator := con
            |> iter.to_array(allocator=allocator);
 }
 
-#private
+#package
 parse_instruction :: (reader: ^io.Reader, binary: ^WasmBinary, code_offset := 0, current_block_depth: ^i32 = null) -> WasmInstruction {
 
     Parse_After :: enum {
index cfb1361bca6a153e31adb9e03d022abbcea15945..50843f8193d5c72cbd553c73e31c72122ae9d067 100644 (file)
@@ -11,8 +11,8 @@ package wasm_utils
 #load "./parser"
 #load "./instructions"
 
-#private map    :: package core.map
-#private io     :: package core.io
-#private hash   :: package core.hash
-#private memory :: package core.memory
-#private iter   :: package core.iter
\ No newline at end of file
+#package map    :: package core.map
+#package io     :: package core.io
+#package hash   :: package core.hash
+#package memory :: package core.memory
+#package iter   :: package core.iter
\ No newline at end of file
index 1b509e2751768fcd06eebb73ce17b304b1d75f83..03fcba5127087d60bb3dc900ddc6227ba32281fb 100644 (file)
@@ -10,7 +10,7 @@ package wasm_utils
 // calling any of the top-level parsing functions. Because this is here, it is
 // unsafe to use this library in a multi-threaded context, if Wasm ever officially
 // supports that.
-#private_file wasm_allocator : Allocator
+#local wasm_allocator : Allocator
 
 parse_type_section :: (use bin: ^WasmBinary, allocator := context.allocator) -> [] WasmFuncType {
     if !map.has(^sections, .Type) do return .{ null, 0 };
@@ -294,7 +294,7 @@ parse_code_section :: (use bin: ^WasmBinary, allocator := context.allocator) ->
     }
 }
 
-#private
+#package
 parse_vector :: macro (reader: ^io.Reader, bin: ^WasmBinary,
                        read: (^io.Reader, ^WasmBinary) -> $T) -> [] T {
     wasm_allocator :: wasm_allocator;
@@ -309,7 +309,7 @@ parse_vector :: macro (reader: ^io.Reader, bin: ^WasmBinary,
     return result;
 }
 
-#private
+#package
 parse_name :: (reader: ^io.Reader, bin: ^WasmBinary) -> [] u8 {
     return parse_vector(reader, bin, read_byte);
 
@@ -318,7 +318,7 @@ parse_name :: (reader: ^io.Reader, bin: ^WasmBinary) -> [] u8 {
     }
 }
 
-#private
+#package
 parse_limits :: (reader: ^io.Reader, bin: ^WasmBinary) -> WasmLimits {
     byte := io.read_byte(reader);
 
@@ -342,7 +342,7 @@ parse_limits :: (reader: ^io.Reader, bin: ^WasmBinary) -> WasmLimits {
     return .{ minimum=minimum, maximum=maximum, shared=shared };
 }
 
-#private
+#package
 read_val_type :: (reader: ^io.Reader, binary: ^WasmBinary) -> WasmValueType {
     byte := io.read_byte(reader);
     switch byte {
@@ -364,7 +364,7 @@ read_val_type :: (reader: ^io.Reader, binary: ^WasmBinary) -> WasmValueType {
     return ~~0;
 }
 
-#private
+#package
 parse_const_uint32 :: (reader: ^io.Reader, binary: ^WasmBinary) -> u32 {
     assert(io.read_byte(reader) == 65, "Expected integer constant");
     value := read_uleb128(reader);
@@ -373,7 +373,7 @@ parse_const_uint32 :: (reader: ^io.Reader, binary: ^WasmBinary) -> u32 {
     return ~~value;
 }
 
-#private
+#package
 parse_section_locations :: (use bin: ^WasmBinary) -> bool {
     stream := io.string_stream_make(data);
     reader := io.reader_make(^stream);
index 326da066a116ad651b7099a24c3d6813194066c3..c9abbd3dced360af4410a20394645c9aa1689727 100644 (file)
@@ -1,8 +1,8 @@
 package wasm_utils
 
-#private_file io :: package core.io
+#local io :: package core.io
 
-#private
+#package
 read_uleb128 :: (use reader: ^io.Reader) -> u64 {
     result: u64 = 0;
     shift := 0;
@@ -19,7 +19,7 @@ read_uleb128 :: (use reader: ^io.Reader) -> u64 {
     return result;
 }
 
-#private
+#package
 read_sleb128 :: (use reader: ^io.Reader, size := 4) -> i64 {
     result: i64 = 0;
     shift := 0;
index 6d45cd14618eab194c105e1a146413a110481af5..637bec2f414824ada24d0f17289784de0e154946 100644 (file)
@@ -3,7 +3,7 @@ package gl
 // To be used with the corresponding gl.js
 // There are many things that are missing but this suffices for me.
 
-#private_file runtime :: package runtime
+#local runtime :: package runtime
 #if runtime.Runtime != runtime.Runtime_Js {
     #error "'webgl' can only be used with the 'js' runtime."
 }
index 263fd460cd88a2066116192c8a50af4b207c205a..f8f55a7c4778fb4a1cf1a981fa6822a90c6ee851 100644 (file)
@@ -2819,7 +2819,8 @@ static void parse_top_level_statement(OnyxParser* parser) {
         private_kind = bh_arr_last(parser->scope_flags);
 
     // :CLEANUP this very repetetive code...
-    if (parse_possible_directive(parser, "private")) {
+    if (next_tokens_are(parser, 2, '#', Token_Type_Keyword_Package)) {
+        consume_tokens(parser, 2);
         private_kind = Ast_Flag_Private_Package;
         if (parser->curr->type == '{') {
             bh_arr_push(parser->scope_flags, private_kind);
@@ -2832,7 +2833,7 @@ static void parse_top_level_statement(OnyxParser* parser) {
             return;
         }
     }
-    else if (parse_possible_directive(parser, "private_file")) {
+    else if (parse_possible_directive(parser, "local")) {
         private_kind = Ast_Flag_Private_File;
         if (parser->curr->type == '{') {
             bh_arr_push(parser->scope_flags, private_kind);