cwRuntime, what is it?
cwRuntime is a compiler agnostic and cross platform collection of utility libraries for Delphi and FreePascal.
It is heavily interface based, offering ARC based memory management features and flexible implementation abstraction, with the goal of forming a source bridge for developers familiar with the two supported compilers.
Currently, the library does depend on some small parts of the Delphi or FreePascal runtime libraries, most noteabily the sysutils and classes units, however, it is my intention to remove the dependency entirely. The library was migrated from my personal code collection to become open source under the three clause BSD license.
Delphi XE5, XE6, XE7, XE8, Berlin (10.1), Tokyo (10.2), Rio (10.3) and Sydney (10.4)
Windows ( x86, x86_64 )
Linux ( x86, x86_64, arm, arrch64 )
Android ( as binary arm, arrch64 )
Support for Apple devices is currently considered experimental, it should work, but there is no CI integration for testing – TBD –
What’s in it?
The library is comprised of the following sub-libraries…
A unit testing framework written from scratch, approximately comparable with Delphi’s older DUnit framework, or the FPCUnit equivalent. While this lacks some of the nice features of more modern unit testing frameworks, it is trivially simple to use, and compatible with both pascal compilers. Compiler agnosticism being the primary feature, allowing you to keep your code compatible with both.
Provides a data-type named ‘TStatus’, which may be used to send return codes from functions and methods as either a 128-bit integer value (GUID) or as a “reason” string. The GUID form is useful for conditionally handling error states as, you might with a boolean or integer data type, while the string form may be used to return a ‘human-readable’ reason for the error state.
Messages may be registered with the cwStatus library which contain place-holders for inserting run-time values, and may be later translated to other languages by loading of language files.
(Language file feature is currently being rebuilt, and is part of the cwLog feature, see blow)
cwTypes is something of a smorgasbord of type helpers, offering conversion or coercion of types such as strings, chars, integers, floats etc. Many of these conversions are useful in reducing compiler hints and warnings produced when performing the conversions by traditional means.
(* Half precision floating point with permission from, and thanks to Marek Mauder at Galfar’s Lair: galfar.vevb.net *)
Provides data types for managing collections (as-in: bag-of-things) of interface references, such as lists, dictionaries, stacks etc. cwCollections makes heavy use of generics to provide flexible collections to be used in dependency injection, and properties of other interfaces and classes.
Provides an interface for loading dynamic libraries, such as windows DLL files, Linux/Posix .so files and Mac OS .dynlib files. This is particularly useful for implementing plugin systems when combined with the cwCollections features.
An implementation of a Unicode codec (coder, decoder) with support for utf-8, 16 and 32, in both big-endian and little-endian carrier formats. While you may use the codec directly, most of it’s features are made more conveniently accessible via the included TUTFString and TUTF8String advanced records, and via the following cwIO features.
Provides interfaces for working with streams and buffers, and a handful of implementations for each. Tightly integrated with cwUnicode, the cwIO library enables saving and loading of unicode content from files and data streams.
A simple logging system. Multiple instances of a log may be created, and then assigned one or more ‘log-targets’ for log messages to be inserted into. cwLog uses status messages as previously registered from the cwStatus system, to insert translatable messages with place-holders into it’s logs.
(Language translation feature is currently undergoing a rebuild)
Essentially a rebuild (and redesign), from the ground up, of my earlier ‘deThreading / darkThreading’ library.
This library has been very useful to me over the past few years, however, it was built as part of another project, resulting in feature/domain-creep, and ultimately made the library more complex than it needed to be.
cwThreading removes this complication, offering a simple interface for running multiple types of thread, including:
- Long-Running threads which run until the application terminates.
- Message Subscriber threads, using light-locking atomic messages.
- Task threads, able to pick up and execute arrays of discrete tasks.
- Parallel ‘for-loop’ tasks.
- Scheduled Tasks which may be scheduled to run at a pre-defined n-second intervals.
A library of simple records representing vectors and matrices (among some other geometric primitives) of half-precision, single-precision or double-precision floats. Offering some utility functions for computing intersections and products.
Provides cross-platform implementations for high-precision timers, allowing for high accuracy simulation and profiling.
A wrapper around WinSock2 under windows, and BSD sockets for posix targets. This is a low-level wrapper, providing vanilla TCP/UPD/Other protocol access for applications to build on top of. It does not provide any protocol support (such as http, ftp etc), but is more useful in raw-socket communications.
A very simple (and somewhat limited) wrapper around the operating system heap calls, for safe allocation of heap buffers among threads. There are intentions to enhance this feature further, and to make it the basis of allocation for the cwIO feature.
Breaking Change - The most recent commit, at revision 108 alters some of the class methods in cwVectors to be virtual methods on the record. These pertain mainly to matrices such that a rotation matrix may be created using "m.rotation( angle )" as opposed to "m := matrix.rotation(angle);"
All instances of change are similarly minor, and make for easier use of the matrix types in practice.