From ff7ee3e3e070a2abee70fd93062065060118cf9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 12 Jan 2026 12:10:32 +0100 Subject: chore: wip: Introduce `libNectarStd`'s Generics Library. Signed-off-by: Amlal El Mahrouss --- include/LibNectarRuntime/.keep | 0 include/LibNectarStd/iostream.ncpp | 19 +++++++++++ include/LibNectarStd/iterator.ncpp | 13 ++++++++ .../src/Preprocessor/Preprocessor+Generic.cc | 17 +++------- test/test_samples/iostream.ncpp | 9 +++++ test/test_samples/ostream_test.ncpp | 39 ---------------------- test/test_samples/return_value.ncpp | 6 ++++ 7 files changed, 51 insertions(+), 52 deletions(-) delete mode 100644 include/LibNectarRuntime/.keep create mode 100644 include/LibNectarStd/iostream.ncpp create mode 100644 include/LibNectarStd/iterator.ncpp create mode 100644 test/test_samples/iostream.ncpp delete mode 100644 test/test_samples/ostream_test.ncpp create mode 100644 test/test_samples/return_value.ncpp diff --git a/include/LibNectarRuntime/.keep b/include/LibNectarRuntime/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/include/LibNectarStd/iostream.ncpp b/include/LibNectarStd/iostream.ncpp new file mode 100644 index 0000000..ecd1132 --- /dev/null +++ b/include/LibNectarStd/iostream.ncpp @@ -0,0 +1,19 @@ +// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (See accompanying +// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) +// Official repository: https://github.com/nekernel-org/nectar + +import printf, scanf; + +struct ostream +{ + let print(let data) + { + return nil; + } + + let scan(let fmt) + { + return nil; + } +}; \ No newline at end of file diff --git a/include/LibNectarStd/iterator.ncpp b/include/LibNectarStd/iterator.ncpp new file mode 100644 index 0000000..fe9015d --- /dev/null +++ b/include/LibNectarStd/iterator.ncpp @@ -0,0 +1,13 @@ + +struct iterator +{ + let begin(let collection) + { + return nil; + } + + let end(let collection) + { + return nil; + } +}; \ No newline at end of file diff --git a/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc b/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc index efaee88..7b3c219 100644 --- a/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc +++ b/src/CompilerKit/src/Preprocessor/Preprocessor+Generic.cc @@ -805,21 +805,12 @@ NECTAR_MODULE(GenericPreprocessorMain) { kMacros.push_back(macro_lang); - Detail::bpp_macro macro_size_t; - macro_size_t.fName = "__SIZE_TYPE__"; - macro_size_t.fValue = "unsigned long long int"; + Detail::bpp_macro macro_nil; - kMacros.push_back(macro_size_t); + macro_nil.fName = "nil"; + macro_nil.fValue = "0"; - macro_size_t.fName = "__UINT32_TYPE__"; - macro_size_t.fValue = "unsigned int"; - - kMacros.push_back(macro_size_t); - - macro_size_t.fName = "__UINTPTR_TYPE__"; - macro_size_t.fValue = "unsigned long long int"; - - kMacros.push_back(macro_size_t); + kMacros.push_back(macro_nil); for (auto index = 1UL; index < argc; ++index) { if (skip) { diff --git a/test/test_samples/iostream.ncpp b/test/test_samples/iostream.ncpp new file mode 100644 index 0000000..de1e6b8 --- /dev/null +++ b/test/test_samples/iostream.ncpp @@ -0,0 +1,9 @@ +import iostream; + +let main() +{ + let io = iostream{}; + let first_number = io.read_once(); + + return first_number; +} \ No newline at end of file diff --git a/test/test_samples/ostream_test.ncpp b/test/test_samples/ostream_test.ncpp deleted file mode 100644 index 2c4d5b2..0000000 --- a/test/test_samples/ostream_test.ncpp +++ /dev/null @@ -1,39 +0,0 @@ -struct iostream -{ - iostream() - { - return; - } - - ~iostream() - { - return; - } - - let write(let val) - { - return; - } - - let read() - { - let ch = 'a'; - return ch; - } -}; - -let dread() -{ - return 0; -} - -let main() -{ - let six_seven = 67; - - let io = iostream{}; - io.read(); - six_seven = dread(); - - return six_seven; -} diff --git a/test/test_samples/return_value.ncpp b/test/test_samples/return_value.ncpp new file mode 100644 index 0000000..897ca15 --- /dev/null +++ b/test/test_samples/return_value.ncpp @@ -0,0 +1,6 @@ +let main() +{ + let six_seven = 67; + + return six_seven; +} -- cgit v1.2.3