ZORALab / Hestia

One Peaceful Frontend+Backend Software Library Suite.
https://hestia.zoralab.com
Other
19 stars 1 forks source link

Develop Non-Reflective String Format hestiaINTERNAL /hestiaFMT Function #13

Closed hollowaykeanho closed 1 year ago

hollowaykeanho commented 2 years ago

Description

Please provide a short description of what feature you're looking forward to
add into the existing repository below. Please include the story behind your
idea as well to give a better visualization of your idea.

The current Go's Sprintf in fmt package is using a reflective for data type identification. This is not useful for Hestia library as we DO NOT want to base a human formatting function on a Go's niche runtime feature that is near impossible to implement across other programming languages. Hence, we have to supply our own string formatting function in hestiaINTERNAL package, maybe hestiaINTERNAL/hestiaFMT package.

This new package is required mainly to resolve the cycle-import problem across all packages where we do not want to happen at all.

This is only seen in Go and TinyGo programming languages. Rust does not have such issue and is offering format!() macro that does the work nicely.

As long as the function can process primitive data types (e.g. []byte, []rune, string, uintX, intX, floatX, and bool), they are good enough already.

Expected Behavior

Please specify the expected behavior of your requested feature. Some great and
helpful pointers are your expected interface (e.g. command patterns, simple
sketches of the user interface, etc).

Hestia packages use hestiaINTERNAL/hestiaFMT to process string internally across all its packages.

Current Absent Behavior

Please specify the current behavior (e.g. workaround, blockage, etc).

HestiaGO cannot format internal string with primitive data conversion without depending on reflective fmt.Sprintf function from standard library.

Attachment

Please drag and drop the necessary data files (e.g. screenshot, logs, etc)
below.
hollowaykeanho commented 2 years ago

Implemented FormatBOOL bool -> string feature

hollowaykeanho commented 2 years ago

Implemented FormatINT{N} int{N} -> string feature

hollowaykeanho commented 2 years ago

Implemented FormatUINT{N} uint{N} -> string feature

hollowaykeanho commented 2 years ago

Implemented FormatFLOAT32 float32 -> string function with base conversion capability.

hollowaykeanho commented 2 years ago

Implemented FormatPOINTER &pointer -> string function.

hollowaykeanho commented 2 years ago

Implemented FormatFLOAT64 float64 -> string function with base conversion capability.

hollowaykeanho commented 2 years ago

Implemented S64_ParseFLOAT64 string -> float64 function with base learning capability.

hollowaykeanho commented 1 year ago

Implemented S32_ParseFLOAT32 string -> float32 function with base learning capability.

hollowaykeanho commented 1 year ago

Implemented SN_ParseUINT string -> uint64 function with base learning and bit resizing capability.

hollowaykeanho commented 1 year ago

Implemented SN_ParseINT string -> int64 function with base learning and bit resizing capability.

hollowaykeanho commented 1 year ago

Implemented SN_Atoi string -> int64 function with base learning and bit resizing capability.

hollowaykeanho commented 1 year ago

Implemented M64_Format string formatting function similar to fmt.Sprintf function but without using reflection. This allows stable operations on TinyGo side.

hollowaykeanho commented 1 year ago

Released in https://github.com/ZORALab/Hestia/releases/tag/v1.0.0