From a53a740a2a1cb6cbfa58cc79caedd4e947ff1ca0 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sun, 28 Nov 2010 18:27:48 +0000 Subject: * clef/: Add using directive at toplevel. * etc/: Likewise. * graph/: Likewise. * hyper/: Likewise. * lib/: Likewise. * sman/: Likewise. * Makefile.am (OA_SMAN_TARGETS): New. (OA_GRAPHICS_TARGETS): Likewise. --- src/include/open-axiom.h | 72 +++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'src/include/open-axiom.h') diff --git a/src/include/open-axiom.h b/src/include/open-axiom.h index 30cb3fd3..33be7e97 100644 --- a/src/include/open-axiom.h +++ b/src/include/open-axiom.h @@ -65,14 +65,10 @@ #elif defined (HAVE_INTTYPES_H) # include #endif -typedef uint8_t openaxiom_byte; /* The opaque datatype. */ #ifdef __WIN32__ -#include -typedef HANDLE openaxiom_handle; -#else -typedef void* openaxiom_handle; +# include #endif #include @@ -84,27 +80,40 @@ typedef void* openaxiom_handle; # define OPENAXIOM_HAVE_GRAPHICS 1 #endif -/* Byte order enumeration. */ -enum openaxiom_byteorder { - oa_unknown_endian, oa_little_endian, oa_big_endian -}; - +namespace OpenAxiom { + // A name for the byte datatype. + typedef uint8_t Byte; -/* Datatype for packaging information necessary tolaunch a process. */ -struct openaxiom_process { - int argc; - char** argv; - int id; -}; + // An opaque datatype +#ifdef __WIN32__ + typedef HANDLE Handle; +#else + typedef void* Handle; +#endif -enum openaxiom_spawn_flags { - openaxiom_spawn_search_path = 0x01, - openaxiom_spawn_replace = 0x02, -}; + // Byte order of machine word data. + enum Byteorder { + unknown_endian, little_endian, big_endian + }; + + // Datatype for packaging information necessary tolaunch a process. + struct Process { + int argc; + char** argv; + int id; + }; + + enum SpawnFlags { + spawn_search_path = 0x01, + spawn_replace = 0x02, + }; -/* Return the address of the data buffer `BUF'. */ -#define oa_buffer_address(BUF) ((openaxiom_byte*)&BUF[0]) + // Return the address of the byte array object representation of `t'. + template + inline Byte* byte_address(T& t) { + return reinterpret_cast(&t); + } /* Internal field separator character. */ #ifdef __WIN32__ @@ -124,19 +133,20 @@ enum openaxiom_spawn_flags { of magnitude of difference when compared to the Unix world. We abstract over that difference here. */ -static inline void -openaxiom_sleep(int n) -{ + static inline void + openaxiom_sleep(int n) + { #ifdef __WIN32__ - Sleep(n * 1000); + Sleep(n * 1000); #else - sleep(n); + sleep(n); #endif -} + } + OPENAXIOM_C_EXPORT void oa_allocate_process_argv(Process*, int); + OPENAXIOM_C_EXPORT int oa_spawn(Process*, SpawnFlags); + OPENAXIOM_C_EXPORT const char* oa_concatenate_string(const char*, const char*); -OPENAXIOM_C_EXPORT void oa_allocate_process_argv(openaxiom_process*, int); -OPENAXIOM_C_EXPORT int oa_spawn(openaxiom_process*, openaxiom_spawn_flags); -OPENAXIOM_C_EXPORT const char* oa_concatenate_string(const char*, const char*); +} #endif /* OPENAXIOM_included */ -- cgit v1.2.3