libs/core.git
17 months agoPthread_setname_np is a GNU extension master
Mikko Rasa [Fri, 6 Jan 2017 02:54:14 +0000 (04:54 +0200)]
Pthread_setname_np is a GNU extension

19 months agoAdd implementations of find and find_if that take a container
Mikko Rasa [Sat, 5 Nov 2016 11:28:12 +0000 (13:28 +0200)]
Add implementations of find and find_if that take a container

Rather than an iterator pair.  Searching through an entire container is
a very common use case.

19 months agoAdd integration between EventDispatcher and Timer
Mikko Rasa [Sun, 30 Oct 2016 15:15:40 +0000 (17:15 +0200)]
Add integration between EventDispatcher and Timer

19 months agoAdd a class for loading and accessing modules at runtime
Mikko Rasa [Sat, 29 Oct 2016 16:43:42 +0000 (19:43 +0300)]
Add a class for loading and accessing modules at runtime

19 months agoAdd microsecond precision to RFC 3339 dates
Mikko Rasa [Fri, 28 Oct 2016 21:41:01 +0000 (00:41 +0300)]
Add microsecond precision to RFC 3339 dates

19 months agoAdd a construct to create conditional RAII objects
Mikko Rasa [Fri, 28 Oct 2016 11:24:40 +0000 (14:24 +0300)]
Add a construct to create conditional RAII objects

21 months agoUse the correct unit of time for WaitForSingleObject
Mikko Rasa [Tue, 20 Sep 2016 00:40:46 +0000 (03:40 +0300)]
Use the correct unit of time for WaitForSingleObject

21 months agoUse a different diagnostic pragma for recent GCC versions
Mikko Rasa [Fri, 2 Sep 2016 22:10:07 +0000 (01:10 +0300)]
Use a different diagnostic pragma for recent GCC versions

22 months agoFix an incorrect comparison
Mikko Rasa [Sun, 14 Aug 2016 18:46:42 +0000 (21:46 +0300)]
Fix an incorrect comparison

22 months agoUse variadic templates for format and print functions if available
Mikko Rasa [Tue, 2 Aug 2016 09:16:25 +0000 (12:16 +0300)]
Use variadic templates for format and print functions if available

22 months agoMerge agouti:prog/core
Mikko Rasa [Wed, 27 Jul 2016 15:49:16 +0000 (18:49 +0300)]
Merge agouti:prog/core

22 months agoAdd conversion from RFC3339 string to DateTime
Mikko Rasa [Sun, 24 Jul 2016 14:24:01 +0000 (17:24 +0300)]
Add conversion from RFC3339 string to DateTime

23 months agoRemove an outdated comment
Mikko Rasa [Wed, 20 Jul 2016 23:51:09 +0000 (02:51 +0300)]
Remove an outdated comment

23 months agoAdd an interface for naming threads
Mikko Rasa [Wed, 20 Jul 2016 23:50:56 +0000 (02:50 +0300)]
Add an interface for naming threads

2 years agoMake Mutex non-copyable
Mikko Rasa [Tue, 14 Jun 2016 05:13:20 +0000 (08:13 +0300)]
Make Mutex non-copyable

2 years agoUse #ifdef _WIN32 rather than WIN32
Mikko Rasa [Tue, 14 Jun 2016 05:04:42 +0000 (08:04 +0300)]
Use #ifdef _WIN32 rather than WIN32

It is the proper compiler-defined macro to use.  WIN32 is defined by SDK
headers and may not appear in all cases.

2 years agoUse Core Foundation to discover standard locations on OS X
Mikko Rasa [Sun, 31 Jan 2016 15:29:52 +0000 (17:29 +0200)]
Use Core Foundation to discover standard locations on OS X

2 years agoAdd a missing #include
Mikko Rasa [Sun, 31 Jan 2016 15:28:08 +0000 (17:28 +0200)]
Add a missing #include

2 years agoProvide access to the Java VM on Android
Mikko Rasa [Sun, 31 Jan 2016 15:20:54 +0000 (17:20 +0200)]
Provide access to the Java VM on Android

2 years agoDisallow negative timeouts for Timer::tick
Mikko Rasa [Sun, 31 Jan 2016 15:20:36 +0000 (17:20 +0200)]
Disallow negative timeouts for Timer::tick

2 years agoSplit Timer::tick into two overloads
Mikko Rasa [Fri, 25 Dec 2015 10:16:47 +0000 (12:16 +0200)]
Split Timer::tick into two overloads

This is in line with other similar interfaces, such as Poller and
Semaphore.  The old function still exists but is deprecated.

2 years agoRefactor Timer::tick
Mikko Rasa [Fri, 25 Dec 2015 10:13:57 +0000 (12:13 +0200)]
Refactor Timer::tick

The previous version had some bugs: the blocking flag was not reset and
it might have tried to execute a canceled (and thus deleted) slot.

2 years agoHack to make 64-bit seeks work on Android
Mikko Rasa [Thu, 19 Nov 2015 16:49:52 +0000 (18:49 +0200)]
Hack to make 64-bit seeks work on Android

2 years agoFix end-of-file detection in Slice
Mikko Rasa [Mon, 7 Sep 2015 09:25:48 +0000 (12:25 +0300)]
Fix end-of-file detection in Slice

Prepare_op was incorrectly adding start_offset to the remaining length.

2 years agoMake fix_case to work with relative paths
Mikko Rasa [Sun, 26 Jul 2015 16:58:38 +0000 (19:58 +0300)]
Make fix_case to work with relative paths

2 years agoAdd negation operator and abs function for TimeDelta
Mikko Rasa [Sun, 26 Jul 2015 16:57:58 +0000 (19:57 +0300)]
Add negation operator and abs function for TimeDelta

3 years agoInclude filename in errors from stat
Mikko Rasa [Tue, 7 Apr 2015 11:05:12 +0000 (14:05 +0300)]
Include filename in errors from stat

3 years agoExpose window flags and set fullscreen mode by default
Mikko Rasa [Thu, 13 Nov 2014 20:46:48 +0000 (22:46 +0200)]
Expose window flags and set fullscreen mode by default

I'll likely change the default once I figure out a good way to add
fullscreen support to libmspgui on Android.

3 years agoMove the generic file-based Asset implementation to a generic directory
Mikko Rasa [Thu, 13 Nov 2014 20:46:14 +0000 (22:46 +0200)]
Move the generic file-based Asset implementation to a generic directory

3 years agoTerminate the process when the application has finished running
Mikko Rasa [Thu, 13 Nov 2014 20:44:51 +0000 (22:44 +0200)]
Terminate the process when the application has finished running

Otherwise the OS may try to start the activity again in the same process,
which doesn't work because of Application::run semantics.

3 years agoChdir into a sensible location before starting the application
Mikko Rasa [Wed, 12 Nov 2014 20:22:15 +0000 (22:22 +0200)]
Chdir into a sensible location before starting the application

System location accessors will ultimately return this directory.  The
default is /, which can easily cause problems.  In particular, many of
my applications expect to have their data in get_sys_data_dir()/"data".
On Android /data exists but is not readable.

3 years agoHave get_user_data_dir return a proper location on Android
Mikko Rasa [Wed, 12 Nov 2014 20:21:36 +0000 (22:21 +0200)]
Have get_user_data_dir return a proper location on Android

3 years agoSplit getcwd and chdir to platform files
Mikko Rasa [Wed, 12 Nov 2014 20:10:25 +0000 (22:10 +0200)]
Split getcwd and chdir to platform files

3 years agoDeprecate the system directory accessors that take arguments
Mikko Rasa [Mon, 10 Nov 2014 17:32:54 +0000 (19:32 +0200)]
Deprecate the system directory accessors that take arguments

They are fundamentally broken due to their dependence on cwd and $PATH,
which may be changed after application startup.  Now that Application
stores an absolute argv0, the argument-less versions can provide a more
consistent answer.

Implementations for the functions are still the same, as they behave
correctly when an absolute argv0 is passed in.  At some point in the
future I'll remove the old versions completely.

3 years agoFix an infinite recursion bug
Mikko Rasa [Mon, 10 Nov 2014 17:32:41 +0000 (19:32 +0200)]
Fix an infinite recursion bug

3 years agoStore absolute path to argv[0] in Application
Mikko Rasa [Mon, 10 Nov 2014 17:29:11 +0000 (19:29 +0200)]
Store absolute path to argv[0] in Application

Working directory or $PATH may be changed by the program, so it may not
be possible to recover the executable later.  It's still not completely
reliable since the parent process can pass any value for argv[0] through
execve().

3 years agoAllow startup info to be set externally
Mikko Rasa [Mon, 10 Nov 2014 17:25:19 +0000 (19:25 +0200)]
Allow startup info to be set externally

... but only if startup didn't happen through Application::run().  Certain
facilities, like Graphics::Display on Windows, require startup info to be
set and would not work without this in a custom startup scenario.

3 years agoAdd a class for accessing applications assets
Mikko Rasa [Sun, 19 Oct 2014 22:34:17 +0000 (01:34 +0300)]
Add a class for accessing applications assets

3 years agoZero-arguments overloads and better error checking for get*dir functions
Mikko Rasa [Sun, 19 Oct 2014 22:27:10 +0000 (01:27 +0300)]
Zero-arguments overloads and better error checking for get*dir functions

3 years agoStore argv0 and application name in the Application class
Mikko Rasa [Sun, 19 Oct 2014 22:24:43 +0000 (01:24 +0300)]
Store argv0 and application name in the Application class

It can get quite annoying having to pass them around to be fed to the
standard path retrieval functions.

3 years agoExpose the asset manager from Android::MainThread
Mikko Rasa [Sun, 19 Oct 2014 17:23:02 +0000 (20:23 +0300)]
Expose the asset manager from Android::MainThread

AFAICT the asset manager is tied to the application and not the activity,
so this simple approach should be safe even if the activity gets destroyed
and recreated due to orientation change or whatever.

3 years agoSynchronize access to the underlying object of Slice
Mikko Rasa [Sun, 19 Oct 2014 13:33:01 +0000 (16:33 +0300)]
Synchronize access to the underlying object of Slice

This was prompted by the interactions between GL::ResourceManager and
some upcoming changes to DataFile::PackSource.  If a new Slice object is
created and tries to connect to signal_flush_required at the exact moment
another Slice is seeking and causing the signal to be emitted, the emit
and connect calls step on each others' toes and corrupt the heap.

3 years agoDerive Slice from sigc::trackable as it connects to external signals
Mikko Rasa [Sun, 19 Oct 2014 09:20:59 +0000 (12:20 +0300)]
Derive Slice from sigc::trackable as it connects to external signals

3 years agoDeal with the activity being recreated during process lifetime
Mikko Rasa [Sun, 12 Oct 2014 15:27:43 +0000 (18:27 +0300)]
Deal with the activity being recreated during process lifetime

This can happen if e.g. screen orientation changes.

3 years agoAdd window and input management signals for Android
Mikko Rasa [Sun, 12 Oct 2014 11:35:05 +0000 (14:35 +0300)]
Add window and input management signals for Android

The onCreate handler will now wait until either the main Application
object is constructed or the MainThread's resume_startup function is
called.  This ensures that the application (or a library such as mspgui)
can connect to the signals before they are emitted.

3 years agoMinimalistic port for Android
Mikko Rasa [Sat, 11 Oct 2014 10:32:23 +0000 (13:32 +0300)]
Minimalistic port for Android

Application startup through NativeActivity is provided and uncaught
exceptions are logged.  A number of things are still in need of proper
implementations.

3 years agoMove OS X main function to an overlay
Mikko Rasa [Fri, 10 Oct 2014 19:59:42 +0000 (22:59 +0300)]
Move OS X main function to an overlay

3 years agoSilence clang's complaints about unused private members
Mikko Rasa [Mon, 6 Oct 2014 22:30:39 +0000 (01:30 +0300)]
Silence clang's complaints about unused private members

3 years agoMake FS::Path::Iterator meet forward iterator requirements
Mikko Rasa [Sun, 5 Oct 2014 18:20:48 +0000 (21:20 +0300)]
Make FS::Path::Iterator meet forward iterator requirements

3 years agoUse direct constant values for non-POSIX baud rates
Mikko Rasa [Sun, 5 Oct 2014 10:48:57 +0000 (13:48 +0300)]
Use direct constant values for non-POSIX baud rates

Not all systems (particularly older ones) have #defines for the extended
baud rates, and the standard doesn't provide anything to check their
existence either.

3 years agoAdd a missing include
Mikko Rasa [Sun, 5 Oct 2014 10:48:15 +0000 (13:48 +0300)]
Add a missing include

3 years agoAdditional baud rates from termios.h
Mikko Rasa [Fri, 27 Jun 2014 16:02:13 +0000 (19:02 +0300)]
Additional baud rates from termios.h

4 years agoChange get_bin_dir logic to assume exe in cwd if not otherwise found
Mikko Rasa [Mon, 6 Jan 2014 19:55:30 +0000 (21:55 +0200)]
Change get_bin_dir logic to assume exe in cwd if not otherwise found

Windows has an implicit . component in $PATH, which can cause programs
started from command line to not find their executable in $PATH.  This
fixes the issue, and should not cause undue trouble on other systems.

4 years agoWindows uses ; as separator in $PATH
Mikko Rasa [Mon, 6 Jan 2014 19:53:25 +0000 (21:53 +0200)]
Windows uses ; as separator in $PATH

4 years agoAdd RAII class for atomic overwrites
Mikko Rasa [Mon, 18 Nov 2013 14:41:26 +0000 (16:41 +0200)]
Add RAII class for atomic overwrites

4 years agoRemove a useless const qualifier
Mikko Rasa [Wed, 6 Nov 2013 09:24:51 +0000 (11:24 +0200)]
Remove a useless const qualifier

4 years agoAdd a function to remove an item from a map, checking for existence
Mikko Rasa [Wed, 6 Nov 2013 09:23:31 +0000 (11:23 +0200)]
Add a function to remove an item from a map, checking for existence

4 years agoSet exists to true if the file was found
Mikko Rasa [Wed, 16 Oct 2013 18:13:16 +0000 (21:13 +0300)]
Set exists to true if the file was found

4 years agoMove Handle::operator void * to the common part
Mikko Rasa [Tue, 15 Oct 2013 12:46:38 +0000 (15:46 +0300)]
Move Handle::operator void * to the common part

4 years agoAvoid closing handles twice
Mikko Rasa [Tue, 15 Oct 2013 12:45:59 +0000 (15:45 +0300)]
Avoid closing handles twice

4 years agoAllow setting a pipe read-only or write-only after creation
Mikko Rasa [Tue, 15 Oct 2013 11:53:04 +0000 (14:53 +0300)]
Allow setting a pipe read-only or write-only after creation

This is useful for handing the pipe to a child process and then closing
the unused end so an end-of-file event can be properly received.

4 years agoInterpret POLLHUP as end-of-file
Mikko Rasa [Tue, 15 Oct 2013 11:51:52 +0000 (14:51 +0300)]
Interpret POLLHUP as end-of-file

4 years agoAdd a Process class for running and interfacing with other programs
Mikko Rasa [Mon, 14 Oct 2013 19:23:11 +0000 (22:23 +0300)]
Add a Process class for running and interfacing with other programs

4 years agoAdd get_handle to Console
Mikko Rasa [Mon, 14 Oct 2013 19:19:16 +0000 (22:19 +0300)]
Add get_handle to Console

This is needed to e.g. redirect cerr to cout.

4 years agoThrow an exception in list_files if the directory can't be opened
Mikko Rasa [Sun, 13 Oct 2013 22:06:03 +0000 (01:06 +0300)]
Throw an exception in list_files if the directory can't be opened

4 years agoRewrite BufferedFile as a standalone class
Mikko Rasa [Mon, 7 Oct 2013 16:36:04 +0000 (19:36 +0300)]
Rewrite BufferedFile as a standalone class

The generic Filtered template is unable to account for the complexities of
buffering a seekable object.  In particular, relative seeks were broken.

I may revisit the template form at a later date if I come up with a
workable design.  For now its use is discouraged.

4 years agoBetter method of preventing duplicate applications
Mikko Rasa [Sat, 5 Oct 2013 12:15:07 +0000 (15:15 +0300)]
Better method of preventing duplicate applications

Application::run can now be called multiple times, but not recursively.

4 years agoRedesign uncaught exception handling to allow external reporters
Mikko Rasa [Sat, 5 Oct 2013 12:12:35 +0000 (15:12 +0300)]
Redesign uncaught exception handling to allow external reporters

This helps keep UI code out of the core library.  It was becoming a
problem especially on OS X where including an Objective-C wrapper around
NSAlert would have broken Builder's bootstrap.  Libmspgui will acquire
a class that will present graphical error dialogs on each platform.

4 years agoUpdate .gitignore
Mikko Rasa [Fri, 4 Oct 2013 21:45:40 +0000 (00:45 +0300)]
Update .gitignore

4 years agoOS X tweaks
Mikko Rasa [Fri, 4 Oct 2013 21:44:41 +0000 (00:44 +0300)]
OS X tweaks

4 years agoMove Application member documentation to the header
Mikko Rasa [Fri, 4 Oct 2013 19:26:07 +0000 (22:26 +0300)]
Move Application member documentation to the header

4 years agoAvoid leaking external references through default c'tors and d'tors
Mikko Rasa [Tue, 27 Aug 2013 19:39:17 +0000 (22:39 +0300)]
Avoid leaking external references through default c'tors and d'tors

4 years agoSuppress usage errors if help is requested
Mikko Rasa [Tue, 27 Aug 2013 19:35:24 +0000 (22:35 +0300)]
Suppress usage errors if help is requested

4 years agosize_t needs <cstddef>
Mikko Rasa [Mon, 5 Aug 2013 14:38:56 +0000 (17:38 +0300)]
size_t needs <cstddef>

5 years agoAdd RAII utilities
Mikko Rasa [Fri, 31 May 2013 21:56:23 +0000 (00:56 +0300)]
Add RAII utilities

5 years agoThe threads flag is more correct than specifying -lpthread directly
Mikko Rasa [Fri, 24 May 2013 16:29:09 +0000 (19:29 +0300)]
The threads flag is more correct than specifying -lpthread directly

5 years agoMiscellaneous fixes
Mikko Rasa [Fri, 24 May 2013 14:45:49 +0000 (17:45 +0300)]
Miscellaneous fixes

5 years agoAvoid a shadowing warning from clang
Mikko Rasa [Fri, 24 May 2013 14:42:09 +0000 (17:42 +0300)]
Avoid a shadowing warning from clang

It considers the handle member of the outer class to be shadowed by the
parameter of an inner class member function.

5 years agoUse _FILE_OFFSET_BITS rather than _LARGEFILE64_SOURCE
Mikko Rasa [Fri, 24 May 2013 14:38:32 +0000 (17:38 +0300)]
Use _FILE_OFFSET_BITS rather than _LARGEFILE64_SOURCE

lseek64 and off64_t are non-portable.  This makes the standard lseek use
a 64-bit interface.

5 years agoDon't output the list of options in usage with full help
Mikko Rasa [Tue, 7 May 2013 13:41:21 +0000 (16:41 +0300)]
Don't output the list of options in usage with full help

5 years agoAdd test cases for path manipulation functions
Mikko Rasa [Fri, 3 May 2013 09:49:14 +0000 (12:49 +0300)]
Add test cases for path manipulation functions

5 years agoThrow an exception for nonsensical arguments in some FS functions
Mikko Rasa [Fri, 3 May 2013 09:47:51 +0000 (12:47 +0300)]
Throw an exception for nonsensical arguments in some FS functions

5 years agoCosmetic fixes for comments and output
Mikko Rasa [Fri, 3 May 2013 09:47:24 +0000 (12:47 +0300)]
Cosmetic fixes for comments and output

5 years agoAdd new test cases to cover positional arguments
Mikko Rasa [Fri, 3 May 2013 09:46:49 +0000 (12:46 +0300)]
Add new test cases to cover positional arguments

5 years agoAdd support for positional arguments in GetOpt
Mikko Rasa [Fri, 3 May 2013 09:42:27 +0000 (12:42 +0300)]
Add support for positional arguments in GetOpt

This addresses the issue of any positional arguments recognized by an
application not showing up in the generated help text.  It also reduces
the amount of processing and validation required from the application
itself and provides consistent error messages.

5 years agoRestore the check that list options must take an argument
Mikko Rasa [Fri, 3 May 2013 09:40:20 +0000 (12:40 +0300)]
Restore the check that list options must take an argument

5 years agoRestructure internals of GetOpt
Mikko Rasa [Thu, 2 May 2013 11:21:19 +0000 (14:21 +0300)]
Restructure internals of GetOpt

Value storage is now handled by a separate class hierarchy, making it more
reusable.

5 years agoUse a typedef for the option descriptor list
Mikko Rasa [Thu, 2 May 2013 09:58:36 +0000 (12:58 +0300)]
Use a typedef for the option descriptor list

5 years agoMove GetOpt exception handling to the .cpp file
Mikko Rasa [Tue, 30 Apr 2013 12:57:45 +0000 (15:57 +0300)]
Move GetOpt exception handling to the .cpp file

5 years agoAdd missing terminator entries to some test data arrays
Mikko Rasa [Wed, 24 Apr 2013 13:40:27 +0000 (16:40 +0300)]
Add missing terminator entries to some test data arrays

5 years agoMove most platform-specific code into overlay directories
Mikko Rasa [Wed, 24 Apr 2013 13:22:18 +0000 (16:22 +0300)]
Move most platform-specific code into overlay directories

A few things, in particular FS::Path, were not trivial to split.  I'm not
certain what to do with features like zlib either.

5 years agoClean up after the timedelta.h/units.h merge
Mikko Rasa [Wed, 24 Apr 2013 13:11:11 +0000 (16:11 +0300)]
Clean up after the timedelta.h/units.h merge

Quite a few files were still including units.h, and documentation for
TimeDelta contained a reference to it.

5 years agoUse UInt64 for FileSize
Mikko Rasa [Wed, 24 Apr 2013 13:08:45 +0000 (16:08 +0300)]
Use UInt64 for FileSize

The MSVC define was incorrect anyway.

5 years agoUse the system call name as parameter to system_error
Mikko Rasa [Tue, 23 Apr 2013 13:42:10 +0000 (16:42 +0300)]
Use the system call name as parameter to system_error

5 years agoMake the Thread state machine more strict
Mikko Rasa [Mon, 22 Apr 2013 10:54:32 +0000 (13:54 +0300)]
Make the Thread state machine more strict

Trying to re-launch a thread after it has finished now throws a
logic_error.

Added a state to indicate the thread having finished.

5 years agoLink examples against the library with a use statement
Mikko Rasa [Sat, 20 Apr 2013 16:37:59 +0000 (19:37 +0300)]
Link examples against the library with a use statement

5 years agoFix Timer to use is Semaphore correctly
Mikko Rasa [Sat, 20 Apr 2013 14:47:50 +0000 (17:47 +0300)]
Fix Timer to use is Semaphore correctly

Besides still assuming the old condvar-style semantics, it was also
horribly broken and contained potential deadlocks and race conditions.
Not to mention unusable due to a missing constructor.

5 years agoAvoid an extra copy by making Variant::Store's c'tor take a const ref
Mikko Rasa [Sat, 20 Apr 2013 14:32:04 +0000 (17:32 +0300)]
Avoid an extra copy by making Variant::Store's c'tor take a const ref

5 years agoAdd activation check to the rest of Filtered's virtual functions
Mikko Rasa [Sat, 20 Apr 2013 14:19:55 +0000 (17:19 +0300)]
Add activation check to the rest of Filtered's virtual functions

This fixes a bug manifesting in builder where a put call that triggers a
BufferedFile's buffer flush causes the buffer contents to be written to
the file twice.

5 years agoEncapsulate serial device state into a struct
Mikko Rasa [Sat, 20 Apr 2013 14:18:23 +0000 (17:18 +0300)]
Encapsulate serial device state into a struct