Skip to content

Commit

Permalink
feat: 0.4.2 Add list template (#67)
Browse files Browse the repository at this point in the history
* feat: Add linked list template to generate code, including Koliseo-based allocation 

* feat: rename internal KLS_Region_List funct

* chore: add back showList signatures as macros

* chore: bump amboso, invil

* fix: basic_example.c using < 0.4.x macro signature

* fix: drop () for type arg in KLS_PUSH_T_ARR_NAMED()

* feat: bump bootstrap_anvil.sh to v0.2

* chore: use actual current function name for failed calls
  • Loading branch information
jgabaut committed Apr 9, 2024
1 parent dd2ce58 commit 15367a8
Show file tree
Hide file tree
Showing 16 changed files with 830 additions and 242 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
+ [Curses](#extra_curses)
+ [Debug](#extra_debug)
+ [Gulp](#extra_gulp)
+ [List template](#list_template)
+ [Title banner](#extra_title)
+ [Experimental](#extra_exper)
+ [How to use extras](#extra_howto)
Expand Down Expand Up @@ -118,6 +119,25 @@ int main(void)
Utility to memory-map a file (always the best idea, right?) to a C string, by providing the filepath.
- Also includes a minimal string-view API, in case you want to work on the file contents differently.

### List template <a name = "list_template"></a>

Any time `LIST_T` is defined before including `koliseo.h`, a basic linked-list implementation supporting `Koliseo` allocation will be declared for the passed type.
- It can be done also after building a static object for the library.

The `LIST_T` macro and the `koliseo.h` should be repeatable without issues, allowing definition of more than one list interface.

This is implemented using some code-generating macros, which could rended build time slower if overused.

Defining the `LIST_NAME`, `LIST_PREFIX` and `LIST_LINKAGE` can allow customisation for each list implementation:
- `LIST_NAME`: The name of the data type to be generated.
- If not given, will expand to something like `list_int` for an `int`.
- `LIST_PREFIX`: Prefix for generated functions.
- If not given, will expand to something `LIST_NAME` + `_`. (eg. `list_int_`)
- `LIST_LINKAGE`: Customize the linkage of the function.
- If not given, will expand to `static inline`.

This is inspired by the dynamic array example by [David Priver](#credits).

### Title banner <a name = "extra_title"></a>

Include an ASCII art string to be printed as a title banner.
Expand Down Expand Up @@ -209,6 +229,8 @@ int main(void)

Thanks to [Tsoding](https://github.com/tsoding) for its creative string view library ([repo](https://github.com/tsoding/sv)), which indeed does things so simply you mostly can't do anything different.

Thanks to [David Priver](https://www.davidpriver.com/ctemplates.html#template-headers.) for its dynamic array template example.

## Todo <a name = "todo"></a>

- Break up internal extensions to the core functionality
Expand Down
2 changes: 1 addition & 1 deletion amboso
4 changes: 4 additions & 0 deletions bin/v0.4.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#amboso compliant version folder, will ignore everything inside BUT the gitignore, to keep the clean dir
*
!.gitignore
!static
1 change: 1 addition & 0 deletions bin/v0.4.1/static
4 changes: 4 additions & 0 deletions bin/v0.4.2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#amboso compliant version folder, will ignore everything inside BUT the gitignore, to keep the clean dir
*
!.gitignore
!static
1 change: 1 addition & 0 deletions bin/v0.4.2/static
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define the package name and version
AC_INIT([koliseo], [0.4.1], [[email protected]])
AC_INIT([koliseo], [0.4.2], [[email protected]])

# Verify automake version and enable foreign option
AM_INIT_AUTOMAKE([foreign -Wall])
Expand Down Expand Up @@ -50,10 +50,10 @@ case "${host_os}" in
if test "$enable_curses" = "yes"; then
echo "Building with curses header"
build_windows=yes
AC_SUBST([KOLISEO_CFLAGS], ["-I/usr/x86_64-w64-mingw32/include -static -fstack-protector -DWINDOWS_BUILD -DNCURSES_STATIC"])
AC_SUBST([KOLISEO_CFLAGS], ["-I/usr/x86_64-w64-mingw32/include -static -fstack-protector -DNCURSES_STATIC"])
AC_SUBST([KOLISEO_LDFLAGS], ["-L/usr/x86_64-w64-mingw32/lib -lncursesw"])
else
AC_SUBST([KOLISEO_CFLAGS], ["-I/usr/x86_64-w64-mingw32/include -static -fstack-protector -DWINDOWS_BUILD"])
AC_SUBST([KOLISEO_CFLAGS], ["-I/usr/x86_64-w64-mingw32/include -static -fstack-protector"])
AC_SUBST([KOLISEO_LDFLAGS], ["-L/usr/x86_64-w64-mingw32/lib"])
fi
AC_SUBST([CCOMP], ["/usr/bin/x86_64-w64-mingw32-gcc"])
Expand Down Expand Up @@ -104,7 +104,7 @@ AM_CONDITIONAL([LINUX_BUILD], [test "$build_linux" = "yes"])
# Set a default version number if not specified externally
AC_ARG_VAR([VERSION], [Version number])
if test -z "$VERSION"; then
VERSION="0.4.1"
VERSION="0.4.2"
fi

# Output variables to the config.h header
Expand Down
2 changes: 1 addition & 1 deletion docs/koliseo.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = koliseo
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.4.1
PROJECT_NUMBER = 0.4.2

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion invil
20 changes: 16 additions & 4 deletions scripts/bootstrap_anvil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

script_version="0.1"
script_version="0.2"

print_impls() {
printf "Impl list:\n"
printf " repo_amboso\n repo_invil\n path_anvil\n\n"
printf " repo_amboso\n repo_invil\n path_anvil\n cargo_invil\n\n"
}

prompt_impls() {
printf "\nSelect anvil implementation:\n"
hint="$1"
if [ ! -z "$hint" ] ; then {
printf "\nPress Enter to use {%s} as requested anvil impl or select anvil implementation:\n" "$hint"
} else {
printf "\nSelect anvil implementation:\n"
}
fi
print_impls
printf "Choice: \n"
}
Expand Down Expand Up @@ -73,13 +79,16 @@ if [ "$is_interactive" -eq 0 ] ; then {
} elif [ "$impl_q" = "path_anvil" ] ; then {
ln -s /usr/local/bin/anvil ./anvil
exit "$?"
} elif [ "$impl_q" = "cargo_invil" ] ; then {
ln -s "$HOME"/.cargo/bin/invil ./anvil
exit "$?"
} else {
printf "[ERROR] Invalid impl query: {%s}.\n" "$impl_q"
exit 1
}
fi
} else {
while read -p "$(prompt_impls)" line; do {
while read -p "$(prompt_impls "$2")" line; do {
if [ -z "$line" ] ; then {
line="$2"
}
Expand All @@ -103,6 +112,9 @@ while read -p "$(prompt_impls)" line; do {
} elif [ "$impl_q" = "path_anvil" ] ; then {
ln -s /usr/local/bin/anvil ./anvil
exit "$?"
} elif [ "$impl_q" = "cargo_invil" ] ; then {
ln -s "$HOME"/.cargo/bin/invil ./anvil
exit "$?"
} else {
printf "[ERROR] Invalid impl query: {%s}.\n" "$impl_q"
}
Expand Down
Loading

0 comments on commit 15367a8

Please sign in to comment.