renamed StdHawk to HawkStd.

added quite some c++ code to get Hawk free of compilation errors
This commit is contained in:
hyung-hwan 2020-01-05 04:32:14 +00:00
parent 0e4cdc0f04
commit 6f6b860971
10 changed files with 659 additions and 160 deletions

View File

@ -25,12 +25,90 @@
*/
#include <Hawk.hpp>
#include <HawkStd.hpp> // for MmgrStd only. i don't like this being mutually dependent
#include "hawk-prv.h"
/////////////////////////////////
HAWK_BEGIN_NAMESPACE(HAWK)
/////////////////////////////////
//////////////////////////////////////////////////////////////////
// Mmged
//////////////////////////////////////////////////////////////////
Mmged::Mmged (Mmgr* mmgr)
{
if (!mmgr) mmgr = Mmgr::getDFL();
this->_mmgr = mmgr;
}
void Mmged::setMmgr (Mmgr* mmgr)
{
if (!mmgr) mmgr = Mmgr::getDFL();
this->_mmgr = mmgr;
}
//////////////////////////////////////////////////////////////////
// Mmgr
//////////////////////////////////////////////////////////////////
void* Mmgr::alloc_mem (mmgr_t* mmgr, hawk_oow_t n) HAWK_CPP_NOEXCEPT
{
return ((Mmgr*)mmgr->ctx)->allocMem (n);
}
void* Mmgr::realloc_mem (mmgr_t* mmgr, void* ptr, hawk_oow_t n) HAWK_CPP_NOEXCEPT
{
return ((Mmgr*)mmgr->ctx)->reallocMem (ptr, n);
}
void Mmgr::free_mem (mmgr_t* mmgr, void* ptr) HAWK_CPP_NOEXCEPT
{
((Mmgr*)mmgr->ctx)->freeMem (ptr);
}
void* Mmgr::callocate (hawk_oow_t n, bool raise_exception) /*HAWK_CPP_THREXCEPT1(MemoryError)*/
{
void* ptr = this->allocate(n, raise_exception);
HAWK_MEMSET (ptr, 0, n);
return ptr;
}
#if 0
#if defined(__GNUC__)
static MmgrStd __attribute__((init_priority(101))) std_dfl_mmgr; //<- this solved the problem
#else
static MmgrStd std_dfl_mmgr; //<-- has an issue for undefined initialization order
#endif
Mmgr* Mmgr::dfl_mmgr = &std_dfl_mmgr;
//Mmgr* Mmgr::dfl_mmgr = MmgrStd::getInstance(); //<--- has an issue as well
Mmgr* Mmgr::getDFL () HAWK_CPP_NOEXCEPT
{
return Mmgr::dfl_mmgr;
}
#else
// C++ initialization order across translation units are not defined.
// so it's tricky to work around this... the init_priority attribute
// can solve this problem. but it's compiler dependent.
// Mmgr::getDFL() resets dfl_mmgr to &std_dfl_mmgr if it's NULL.
Mmgr* Mmgr::dfl_mmgr = HAWK_NULL;
Mmgr* Mmgr::getDFL () HAWK_CPP_NOEXCEPT
{
static MmgrStd std_dfl_mmgr;
Mmgr* mmgr = Mmgr::dfl_mmgr;
return mmgr? mmgr: &std_dfl_mmgr;
}
#endif
void Mmgr::setDFL (Mmgr* mmgr) HAWK_CPP_NOEXCEPT
{
Mmgr::dfl_mmgr = mmgr;
}
//////////////////////////////////////////////////////////////////
// Hawk::Source
//////////////////////////////////////////////////////////////////
@ -1326,14 +1404,14 @@ int Hawk::open ()
hawk_prm_t prm;
HAWK_MEMSET (&prm, 0, HAWK_SIZEOF(prm));
prm.math.pow = pow;
prm.math.mod = mod;
prm.modopen = modopen;
prm.modclose = modclose;
prm.modgetsym = modgetsym;
prm.math.pow = Hawk::pow;
prm.math.mod = Hawk::mod;
prm.modopen = Hawk::modopen;
prm.modclose = Hawk::modclose;
prm.modgetsym = Hawk::modgetsym;
hawk_errnum_t errnum;
this->awk = hawk_open(this->getMmgr(), HAWK_SIZEOF(xtn_t), &prm, &errnum);
this->awk = hawk_open(this->getMmgr(), HAWK_SIZEOF(xtn_t), hawk_get_cmgr_by_id(HAWK_CMGR_UTF8), &prm, &errnum);
if (!this->awk)
{
this->setError (errnum);
@ -2447,3 +2525,38 @@ void* Hawk::modgetsym (awk_t* awk, void* handle, const hawk_ooch_t* name)
/////////////////////////////////
HAWK_END_NAMESPACE(HAWK)
/////////////////////////////////
void* operator new (hawk_oow_t size, HAWK::Mmgr* mmgr) /*HAWK_CPP_THREXCEPT1(HAWK::Mmgr::MemoryError)*/
{
return mmgr->allocate (size);
}
#if defined(HAWK_CPP_NO_OPERATOR_DELETE_OVERLOADING)
void hawk_operator_delete (void* ptr, HAWK::Mmgr* mmgr)
#else
void operator delete (void* ptr, HAWK::Mmgr* mmgr)
#endif
{
mmgr->dispose (ptr);
}
void* operator new (hawk_oow_t size, HAWK::Mmgr* mmgr, void* existing_ptr) /*HAWK_CPP_THREXCEPT1(HAWK::Mmgr::MemoryError)*/
{
// mmgr unused. i put it in the parameter list to make this function
// less conflicting with the stock ::operator new() that doesn't allocate.
return existing_ptr;
}
#if 0
void* operator new[] (hawk_oow_t size, HAWK::Mmgr* mmgr)
{
return mmgr->allocate (size);
}
void operator delete[] (void* ptr, HAWK::Mmgr* mmgr)
{
mmgr->dispose (ptr);
}
#endif

View File

@ -28,10 +28,10 @@
#define _HAWK_HAWK_HPP_
#include <hawk.h>
#include <stdarg.h>
#define HAWK_USE_HTB_FOR_FUNCTION_MAP 1
//#define HAWK_VALUE_USE_IN_CLASS_PLACEMENT_NEW 1
//#define HAWK_NO_LOCATION_IN_EXCEPTION 1
// TOOD: redefine these NAMESPACE stuffs or move them somewhere else
#define HAWK_BEGIN_NAMESPACE(x) namespace x {
@ -51,11 +51,329 @@
HAWK_BEGIN_NAMESPACE(HAWK)
/////////////////////////////////
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900) // C++11 or later
#define HAWK_LANG_CPP11 1
#define HAWK_CPP_NOEXCEPT noexcept(true)
/// The HAWK_CPP_ENABLE_CPP11_MOVE macro enables C++11 move semantics in various classes.
#define HAWK_CPP_ENABLE_CPP11_MOVE 1
// The HAWK_CPP_CALL_DESTRUCTOR() macro calls a destructor explicitly.
#define HAWK_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
// The HAWK_CPP_CALL_PLACEMENT_DELETE1() macro calls the global operator delete
// with 1 extra argument given.
#define HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete((ptr), (arg1)))
#elif (__cplusplus >= 199711L) // C++98
#undef HAWK_LANG_CPP11
#define HAWK_CPP_NOEXCEPT throw()
#define HAWK_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
#define HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete((ptr), (arg1)))
#else
#undef HAWK_LANG_CPP11
#define HAWK_CPP_NOEXCEPT
#if defined(__BORLANDC__)
// Explicit destructor call requires a class name depending on the
// C++ standard/compiler.
//
// Node* x;
// x->~Node ();
//
// While x->~Node() is ok with modern compilers, some old compilers
// like BCC55 required the class name in the call as shown below.
//
// x->Node::~Node ();
#define HAWK_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->class_name::~class_name())
#define HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete((ptr), (arg1)))
#elif defined(__WATCOMC__)
// WATCOM has a problem with this syntax.
// Node* x; x->Node::~Node().
// But it doesn't support operator delete overloading.
#define HAWK_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
#define HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::hawk_operator_delete((ptr), (arg1)))
// When the name of a member template specialization appears after . or
// -> in a postfix-expression, or after :: in a qualified-id that explic-
// itly depends on a template-argument (_temp.dep_), the member template
// name must be prefixed by the keyword template. Otherwise the name is
// assumed to name a non-template. [Example:
// class X {
// public:
// template<size_t> X* alloc();
// };
// void f(X* p)
// {
// X* p1 = p->alloc<200>();
// // ill-formed: < means less than
// X* p2 = p->template alloc<200>();
// // fine: < starts explicit qualification
// }
// --end example]
//
// WATCOM doesn't support this qualifier.
#define HAWK_CPP_NO_OPERATOR_DELETE_OVERLOADING 1
#else
#define HAWK_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
#define HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, arg1) (::operator delete((ptr), (arg1)))
#endif
#endif
#if defined(HAWK_CPP_ENABLE_CPP11_MOVE)
template<typename T> struct HAWK_CPP_RMREF { typedef T Type; };
template<typename T> struct HAWK_CPP_RMREF<T&> { typedef T Type; };
template<typename T> struct HAWK_CPP_RMREF<T&&> { typedef T Type; };
template<typename T> inline
typename HAWK_CPP_RMREF<T>::Type&& HAWK_CPP_RVREF(T&& v)
{
return (typename HAWK_CPP_RMREF<T>::Type&&)v;
}
#else
/*
template<typename T> inline
T& HAWK_CPP_RVREF(T& v) { return (T&)v; }
template<typename T> inline
const T& HAWK_CPP_RVREF(const T& v) { return (const T&)v; }
*/
#define HAWK_CPP_RVREF(x) x
#endif
/// The Exception class implements the exception object.
class HAWK_EXPORT Exception
{
public:
Exception (
const hawk_ooch_t* name, const hawk_ooch_t* msg,
const hawk_ooch_t* file, hawk_oow_t line) HAWK_CPP_NOEXCEPT:
name(name), msg(msg)
#if !defined(HAWK_NO_LOCATION_IN_EXCEPTION)
, file(file), line(line)
#endif
{
}
const hawk_ooch_t* name;
const hawk_ooch_t* msg;
#if !defined(HAWK_NO_LOCATION_IN_EXCEPTION)
const hawk_ooch_t* file;
hawk_oow_t line;
#endif
};
#define HAWK_THROW(ex_name) \
throw ex_name(HAWK_Q(ex_name),HAWK_Q(ex_name), HAWK_T(__FILE__), (hawk_oow_t)__LINE__)
#define HAWK_THROW_WITH_MSG(ex_name,msg) \
throw ex_name(HAWK_Q(ex_name),msg, HAWK_T(__FILE__), (hawk_oow_t)__LINE__)
#define HAWK_EXCEPTION(ex_name) \
class ex_name: public HAWK::Exception \
{ \
public: \
ex_name (const hawk_ooch_t* name, const hawk_ooch_t* msg, \
const hawk_ooch_t* file, hawk_oow_t line) HAWK_CPP_NOEXCEPT: \
HAWK::Exception (name, msg, file, line) {} \
}
#define HAWK_EXCEPTION_NAME(exception_object) ((exception_object).name)
#define HAWK_EXCEPTION_MSG(exception_object) ((exception_object).msg)
#if !defined(HAWK_NO_LOCATION_IN_EXCEPTION)
# define HAWK_EXCEPTION_FILE(exception_object) ((exception_object).file)
# define HAWK_EXCEPTION_LINE(exception_object) ((exception_object).line)
#else
# define HAWK_EXCEPTION_FILE(exception_object) (HAWK_T(""))
# define HAWK_EXCEPTION_LINE(exception_object) (0)
#endif
class HAWK_EXPORT Uncopyable
{
public:
Uncopyable () HAWK_CPP_NOEXCEPT {}
//virtual ~Uncopyable () {}
private:
Uncopyable (const Uncopyable&);
const Uncopyable& operator= (const Uncopyable&);
};
///
/// The Mmgr class defines a memory manager interface that can be inherited
/// by a class in need of a memory manager as defined in the primitive
/// #hawk_mmgr_t type. Using the class over the primitive type enables you to
/// write code in more object-oriented fashion. An inheriting class should
/// implement three pure virtual functions.
///
/// You are free to call allocMem(), reallocMem(), and freeMem() in C++ context
/// where no exception raising is desired. If you want an exception to be
/// raised upon memory allocation errors, you can call allocate(), reallocate(),
/// dispose() instead.
///
///
class HAWK_EXPORT Mmgr: public hawk_mmgr_t
{
public:
/// defines an alias type to #hawk_mmgr_t
typedef hawk_mmgr_t mmgr_t;
HAWK_EXCEPTION (MemoryError);
public:
///
/// The Mmgr() function builds a memory manager composed of bridge
/// functions connecting itself with it.
///
Mmgr () HAWK_CPP_NOEXCEPT
{
// NOTE:
// the #hawk_mmgr_t interface is not affected by raise_exception
// because direct calls to the virtual functions that don't raise
// exceptions are made via bridge functions below.
this->alloc = alloc_mem;
this->realloc = realloc_mem;
this->free = free_mem;
this->ctx = this;
}
///
/// The ~Mmgr() function finalizes a memory manager.
///
virtual ~Mmgr () HAWK_CPP_NOEXCEPT {}
///
/// The allocate() function calls allocMem() for memory
/// allocation. if it fails, it raise an exception if it's
/// configured to do so.
///
void* allocate (hawk_oow_t n, bool raise_exception = true)
{
void* xptr = this->allocMem (n);
if (!xptr && raise_exception) HAWK_THROW (MemoryError);
return xptr;
}
///
/// The callocate() function allocates memory like allocate() and
/// clears the memory before returning.
///
void* callocate (hawk_oow_t n, bool raise_exception = true);
///
/// The reallocate() function calls reallocMem() for memory
/// reallocation. if it fails, it raise an exception if it's
/// configured to do so.
///
void* reallocate (void* ptr, hawk_oow_t n, bool raise_exception = true)
{
void* xptr = this->reallocMem (ptr, n);
if (!xptr && raise_exception) HAWK_THROW (MemoryError);
return xptr;
}
///
/// The dispose() function calls freeMem() for memory disposal.
///
void dispose (void* ptr) HAWK_CPP_NOEXCEPT
{
this->freeMem (ptr);
}
//protected:
///
/// The allocMem() function allocates a chunk of memory of the
/// size \a n and return the pointer to the beginning of the chunk.
/// If it fails to allocate memory, it should return #HAWK_NULL.
///
virtual void* allocMem (
hawk_oow_t n ///< size of memory chunk to allocate in bytes
) HAWK_CPP_NOEXCEPT = 0;
///
/// The reallocMem() function resizes a chunk of memory previously
/// allocated with the allocMem() function. When resized, the contents
/// of the surviving part of a memory chunk is preserved. If it fails to
/// resize memory, it should return HAWK_NULL.
///
virtual void* reallocMem (
void* ptr, ///< pointer to memory chunk to resize
hawk_oow_t n ///< new size in bytes
) HAWK_CPP_NOEXCEPT = 0;
///
/// The freeMem() function frees a chunk of memory allocated with
/// the allocMem() function or resized with the reallocMem() function.
///
virtual void freeMem (
void* ptr ///< pointer to memory chunk to free
) HAWK_CPP_NOEXCEPT = 0;
protected:
///
/// bridge function from the #hawk_mmgr_t type the allocMem() function.
///
static void* alloc_mem (mmgr_t* mmgr, hawk_oow_t n) HAWK_CPP_NOEXCEPT;
///
/// bridge function from the #hawk_mmgr_t type the reallocMem() function.
///
static void* realloc_mem (mmgr_t* mmgr, void* ptr, hawk_oow_t n) HAWK_CPP_NOEXCEPT;
///
/// bridge function from the #hawk_mmgr_t type the freeMem() function.
///
static void free_mem (mmgr_t* mmgr, void* ptr) HAWK_CPP_NOEXCEPT;
public:
static Mmgr* getDFL () HAWK_CPP_NOEXCEPT;
static void setDFL (Mmgr* mmgr) HAWK_CPP_NOEXCEPT;
protected:
static Mmgr* dfl_mmgr;
};
class HAWK_EXPORT Mmged
{
public:
Mmged (Mmgr* mmgr = HAWK_NULL);
///
/// The getMmgr() function returns the memory manager associated.
///
Mmgr* getMmgr () const { return this->_mmgr; }
protected:
///
/// The setMmgr() function changes the memory manager.
/// Changing memory manager requires extra care to be taken
/// especially when you have some data allocated with the previous
/// manager. for this reason, i put this as a protected function.
///
void setMmgr(Mmgr* mmgr);
private:
Mmgr* _mmgr;
};
///
/// The Hawk class implements an AWK interpreter by wrapping around
/// #hawk_t and #hawk_rtx_t.
///
class HAWK_EXPORT Hawk: public Uncopyable, public Types, public Mmged
class HAWK_EXPORT Hawk: public Uncopyable, public Mmged
{
public:
@ -1368,7 +1686,7 @@ protected:
static void* modopen (awk_t* awk, const mod_spec_t* spec);
static void modclose (awk_t* awk, void* handle);
static void* modsym (awk_t* awk, void* handle, const hawk_ooch_t* name);
static void* modgetsym (awk_t* awk, void* handle, const hawk_ooch_t* name);
public:
// use this with care
@ -1431,4 +1749,33 @@ private:
HAWK_END_NAMESPACE(HAWK)
/////////////////////////////////
HAWK_EXPORT void* operator new (hawk_oow_t size, HAWK::Mmgr* mmgr);
#if defined(HAWK_CPP_NO_OPERATOR_DELETE_OVERLOADING)
HAWK_EXPORT void hawk_operator_delete (void* ptr, HAWK::Mmgr* mmgr);
#else
HAWK_EXPORT void operator delete (void* ptr, HAWK::Mmgr* mmgr);
#endif
HAWK_EXPORT void* operator new (hawk_oow_t size, HAWK::Mmgr* mmgr, void* existing_ptr);
#if 0
// i found no way to delete an array allocated with
// the placement new operator. if the array element is an instance
// of a class, the pointer returned by the new operator call
// may not be the actual pointer allocated. some compilers
// seem to put some information about the array at the
// beginning of the allocated memory and return the pointer
// off a few bytes from the beginning.
void* operator new[] (hawk_oow_t size, HAWK::Mmgr* mmgr);
void operator delete[] (void* ptr, HAWK::Mmgr* mmgr);
#endif
#define HAWK_CPP_DELETE_WITH_MMGR(ptr, class_name, mmgr) \
do { \
HAWK_CPP_CALL_DESTRUCTOR (ptr, class_name); \
HAWK_CPP_CALL_PLACEMENT_DELETE1(ptr, mmgr); \
} while(0);
#endif

View File

@ -24,7 +24,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <StdHawk.hpp>
#include <HawkStd.hpp>
#include "hawk-prv.h"
#include <stdlib.h>
@ -45,14 +45,35 @@
# error UNSUPPORTED DYNAMIC LINKER
#endif
/////////////////////////////////
HAWK_BEGIN_NAMESPACE(HAWK)
/////////////////////////////////
StdHawk::ioattr_t StdHawk::default_ioattr;
//////////////////////////////////////////////////////////////////////////////
// MmgrStd
//////////////////////////////////////////////////////////////////////////////
void* MmgrStd::allocMem (hawk_oow_t n) HAWK_CPP_NOEXCEPT
{
return ::malloc(n);
}
static hawk_sio_t* open_sio (Hawk* awk, StdHawk::Run* run, const hawk_ooch_t* file, int flags)
void* MmgrStd::reallocMem (void* ptr, hawk_oow_t n) HAWK_CPP_NOEXCEPT
{
return ::realloc(ptr, n);
}
void MmgrStd::freeMem (void* ptr) HAWK_CPP_NOEXCEPT
{
::free (ptr);
}
//////////////////////////////////////////////////////////////////////////////
// HawkStd
//////////////////////////////////////////////////////////////////////////////
HawkStd::ioattr_t HawkStd::default_ioattr;
static hawk_sio_t* open_sio (Hawk* awk, HawkStd::Run* run, const hawk_ooch_t* file, int flags)
{
hawk_sio_t* sio;
@ -69,7 +90,7 @@ static hawk_sio_t* open_sio (Hawk* awk, StdHawk::Run* run, const hawk_ooch_t* fi
return sio;
}
static hawk_sio_t* open_sio_std (Hawk* awk, StdHawk::Run* run, hawk_sio_std_t std, int flags)
static hawk_sio_t* open_sio_std (Hawk* awk, HawkStd::Run* run, hawk_sio_std_t std, int flags)
{
hawk_sio_t* sio;
static const hawk_ooch_t* std_names[] =
@ -92,7 +113,7 @@ static hawk_sio_t* open_sio_std (Hawk* awk, StdHawk::Run* run, hawk_sio_std_t st
return sio;
}
int StdHawk::open ()
int HawkStd::open ()
{
int n = Hawk::open ();
if (n == -1) return n;
@ -110,8 +131,8 @@ int StdHawk::open ()
if (addFunction (HAWK_T("rand"), 1, 0, HAWK_T("math"), HAWK_NULL, 0) <= -1 ||
addFunction (HAWK_T("srand"), 1, 0, HAWK_T("math"), HAWK_NULL, 0) <= -1 ||
addFunction (HAWK_T("system"), 1, 0, HAWK_T("sys"), HAWK_NULL, 0) <= -1 ||
addFunction (HAWK_T("setioattr"), 3, 3, HAWK_NULL, (FunctionHandler)&StdHawk::setioattr, HAWK_RIO) <= -1 ||
addFunction (HAWK_T("getioattr"), 3, 3, HAWK_T("vvr"), (FunctionHandler)&StdHawk::getioattr, HAWK_RIO) <= -1)
addFunction (HAWK_T("setioattr"), 3, 3, HAWK_NULL, (FunctionHandler)&HawkStd::setioattr, HAWK_RIO) <= -1 ||
addFunction (HAWK_T("getioattr"), 3, 3, HAWK_T("vvr"), (FunctionHandler)&HawkStd::getioattr, HAWK_RIO) <= -1)
{
goto oops;
}
@ -134,7 +155,7 @@ oops:
return -1;
}
void StdHawk::close ()
void HawkStd::close ()
{
if (this->cmgrtab_inited)
{
@ -145,14 +166,14 @@ void StdHawk::close ()
clearConsoleOutputs ();
//
// StdHawk called hawk_stdmodstartup() after Hawk::open().
// HawkStd called hawk_stdmodstartup() after Hawk::open().
// It's logical to call hawk_stdmodshutdown() Hawk::close().
// but Hawk::close() still needs to call some module's fini and
// unload functions. So it must be done in StdHawk::uponClosing()
// unload functions. So it must be done in HawkStd::uponClosing()
// which is called after modules have been unloaded but while
// the underlying awk object is still alive.
//
// See StdHawk::uponClosing() below.
// See HawkStd::uponClosing() below.
//
//if (this->stdmod_up)
//{
@ -164,7 +185,7 @@ void StdHawk::close ()
Hawk::close ();
}
void StdHawk::uponClosing ()
void HawkStd::uponClosing ()
{
if (this->stdmod_up)
{
@ -176,7 +197,7 @@ void StdHawk::uponClosing ()
Hawk::uponClosing ();
}
StdHawk::Run* StdHawk::parse (Source& in, Source& out)
HawkStd::Run* HawkStd::parse (Source& in, Source& out)
{
Run* run = Hawk::parse(in, out);
@ -207,7 +228,7 @@ StdHawk::Run* StdHawk::parse (Source& in, Source& out)
return run;
}
int StdHawk::build_argcv (Run* run)
int HawkStd::build_argcv (Run* run)
{
Value argv (run);
@ -224,7 +245,7 @@ int StdHawk::build_argcv (Run* run)
return 0;
}
int StdHawk::__build_environ (Run* run, void* envptr)
int HawkStd::__build_environ (Run* run, void* envptr)
{
hawk_env_hawk_ooch_t** envarr = (hawk_env_hawk_ooch_t**)envptr;
Value v_env (run);
@ -307,7 +328,7 @@ int StdHawk::__build_environ (Run* run, void* envptr)
return run->setGlobal (this->gbl_environ, v_env);
}
int StdHawk::build_environ (Run* run)
int HawkStd::build_environ (Run* run)
{
hawk_env_t env;
int xret;
@ -324,7 +345,7 @@ int StdHawk::build_environ (Run* run)
return xret;
}
int StdHawk::make_additional_globals (Run* run)
int HawkStd::make_additional_globals (Run* run)
{
if (build_argcv (run) <= -1 ||
build_environ (run) <= -1) return -1;
@ -332,7 +353,7 @@ int StdHawk::make_additional_globals (Run* run)
return 0;
}
hawk_cmgr_t* StdHawk::getiocmgr (const hawk_ooch_t* ioname)
hawk_cmgr_t* HawkStd::getiocmgr (const hawk_ooch_t* ioname)
{
HAWK_ASSERT (this->cmgrtab_inited == true);
@ -343,7 +364,7 @@ hawk_cmgr_t* StdHawk::getiocmgr (const hawk_ooch_t* ioname)
return HAWK_NULL;
}
StdHawk::ioattr_t* StdHawk::get_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
HawkStd::ioattr_t* HawkStd::get_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
{
hawk_htb_pair_t* pair;
@ -353,7 +374,7 @@ StdHawk::ioattr_t* StdHawk::get_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
return (ioattr_t*)HAWK_HTB_VPTR(pair);
}
StdHawk::ioattr_t* StdHawk::find_or_make_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
HawkStd::ioattr_t* HawkStd::find_or_make_ioattr (const hawk_ooch_t* ptr, hawk_oow_t len)
{
hawk_htb_pair_t* pair;
@ -362,8 +383,8 @@ StdHawk::ioattr_t* StdHawk::find_or_make_ioattr (const hawk_ooch_t* ptr, hawk_oo
{
pair = hawk_htb_insert (
&this->cmgrtab, (void*)ptr, len,
(void*)&StdHawk::default_ioattr,
HAWK_SIZEOF(StdHawk::default_ioattr));
(void*)&HawkStd::default_ioattr,
HAWK_SIZEOF(HawkStd::default_ioattr));
if (pair == HAWK_NULL)
{
this->setError (HAWK_ENOMEM);
@ -383,7 +404,7 @@ static int timeout_code (const hawk_ooch_t* name)
return -1;
}
int StdHawk::setioattr (
int HawkStd::setioattr (
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
const hawk_ooch_t* name, hawk_oow_t len)
{
@ -458,7 +479,7 @@ int StdHawk::setioattr (
}
}
int StdHawk::getioattr (
int HawkStd::getioattr (
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
const hawk_ooch_t* name, hawk_oow_t len)
{
@ -476,7 +497,7 @@ int StdHawk::getioattr (
hawk_strxchr (ptr[1], l[1], HAWK_T('\0')) == HAWK_NULL)
{
ioattr_t* ioattr = get_ioattr (ptr[0], l[0]);
if (ioattr == HAWK_NULL) ioattr = &StdHawk::default_ioattr;
if (ioattr == HAWK_NULL) ioattr = &HawkStd::default_ioattr;
int tmout;
if ((tmout = timeout_code(ptr[1])) >= 0)
@ -499,7 +520,7 @@ int StdHawk::getioattr (
return ret.setInt ((int_t)xx);
}
int StdHawk::open_nwio (Pipe& io, int flags, void* nwad)
int HawkStd::open_nwio (Pipe& io, int flags, void* nwad)
{
hawk_nwio_tmout_t tmout_buf;
hawk_nwio_tmout_t* tmout = HAWK_NULL;
@ -534,7 +555,7 @@ int StdHawk::open_nwio (Pipe& io, int flags, void* nwad)
return 1;
}
int StdHawk::open_pio (Pipe& io)
int HawkStd::open_pio (Pipe& io)
{
Hawk::Pipe::Mode mode = io.getMode();
hawk_pio_t* pio = HAWK_NULL;
@ -611,7 +632,7 @@ static int parse_rwpipe_uri (const hawk_ooch_t* uri, int* flags, hawk_nwad_t* nw
return -1;
}
int StdHawk::openPipe (Pipe& io)
int HawkStd::openPipe (Pipe& io)
{
int flags;
hawk_nwad_t nwad;
@ -627,7 +648,7 @@ int StdHawk::openPipe (Pipe& io)
}
}
int StdHawk::closePipe (Pipe& io)
int HawkStd::closePipe (Pipe& io)
{
if (io.getUflags() > 0)
{
@ -657,35 +678,35 @@ int StdHawk::closePipe (Pipe& io)
return 0;
}
hawk_ooi_t StdHawk::readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::readPipe (Pipe& io, hawk_ooch_t* buf, hawk_oow_t len)
{
return (io.getUflags() > 0)?
hawk_nwio_read ((hawk_nwio_t*)io.getHandle(), buf, len):
hawk_pio_read ((hawk_pio_t*)io.getHandle(), HAWK_PIO_OUT, buf, len);
}
hawk_ooi_t StdHawk::writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::writePipe (Pipe& io, const hawk_ooch_t* buf, hawk_oow_t len)
{
return (io.getUflags() > 0)?
hawk_nwio_write((hawk_nwio_t*)io.getHandle(), buf, len):
hawk_pio_write((hawk_pio_t*)io.getHandle(), HAWK_PIO_IN, buf, len);
}
hawk_ooi_t StdHawk::writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::writePipeBytes (Pipe& io, const hawk_bch_t* buf, hawk_oow_t len)
{
return (io.getUflags() > 0)?
hawk_nwio_writebytes((hawk_nwio_t*)io.getHandle(), buf, len):
hawk_pio_writebytes((hawk_pio_t*)io.getHandle(), HAWK_PIO_IN, buf, len);
}
int StdHawk::flushPipe (Pipe& io)
int HawkStd::flushPipe (Pipe& io)
{
return (io.getUflags() > 0)?
hawk_nwio_flush ((hawk_nwio_t*)io.getHandle()):
hawk_pio_flush ((hawk_pio_t*)io.getHandle(), HAWK_PIO_IN);
}
int StdHawk::openFile (File& io)
int HawkStd::openFile (File& io)
{
Hawk::File::Mode mode = io.getMode();
hawk_sio_t* sio = HAWK_NULL;
@ -718,44 +739,44 @@ int StdHawk::openFile (File& io)
return 1;
}
int StdHawk::closeFile (File& io)
int HawkStd::closeFile (File& io)
{
hawk_sio_close ((hawk_sio_t*)io.getHandle());
return 0;
}
hawk_ooi_t StdHawk::readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::readFile (File& io, hawk_ooch_t* buf, hawk_oow_t len)
{
return hawk_sio_getoochars((hawk_sio_t*)io.getHandle(), buf, len);
}
hawk_ooi_t StdHawk::writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::writeFile (File& io, const hawk_ooch_t* buf, hawk_oow_t len)
{
return hawk_sio_putoochars((hawk_sio_t*)io.getHandle(), buf, len);
}
hawk_ooi_t StdHawk::writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::writeFileBytes (File& io, const hawk_bch_t* buf, hawk_oow_t len)
{
return hawk_sio_putbchars((hawk_sio_t*)io.getHandle(), buf, len);
}
int StdHawk::flushFile (File& io)
int HawkStd::flushFile (File& io)
{
return hawk_sio_flush((hawk_sio_t*)io.getHandle());
}
void StdHawk::setConsoleCmgr (const hawk_cmgr_t* cmgr)
void HawkStd::setConsoleCmgr (const hawk_cmgr_t* cmgr)
{
this->console_cmgr = (hawk_cmgr_t*)cmgr;
}
const hawk_cmgr_t* StdHawk::getConsoleCmgr () const
const hawk_cmgr_t* HawkStd::getConsoleCmgr () const
{
return this->console_cmgr;
}
int StdHawk::addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len)
int HawkStd::addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len)
{
HAWK_ASSERT (awk != HAWK_NULL);
int n = this->ofile.add (awk, arg, len);
@ -763,17 +784,17 @@ int StdHawk::addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len)
return n;
}
int StdHawk::addConsoleOutput (const hawk_ooch_t* arg)
int HawkStd::addConsoleOutput (const hawk_ooch_t* arg)
{
return addConsoleOutput (arg, hawk_count_oocstr(arg));
}
void StdHawk::clearConsoleOutputs ()
void HawkStd::clearConsoleOutputs ()
{
this->ofile.clear (awk);
}
int StdHawk::open_console_in (Console& io)
int HawkStd::open_console_in (Console& io)
{
hawk_rtx_t* rtx = (rtx_t*)io;
@ -932,7 +953,7 @@ int StdHawk::open_console_in (Console& io)
}
int StdHawk::open_console_out (Console& io)
int HawkStd::open_console_out (Console& io)
{
hawk_rtx_t* rtx = (rtx_t*)io;
@ -1005,7 +1026,7 @@ int StdHawk::open_console_out (Console& io)
}
}
int StdHawk::openConsole (Console& io)
int HawkStd::openConsole (Console& io)
{
Console::Mode mode = io.getMode();
@ -1030,13 +1051,13 @@ int StdHawk::openConsole (Console& io)
}
}
int StdHawk::closeConsole (Console& io)
int HawkStd::closeConsole (Console& io)
{
hawk_sio_close ((hawk_sio_t*)io.getHandle());
return 0;
}
hawk_ooi_t StdHawk::readConsole (Console& io, hawk_ooch_t* data, hawk_oow_t size)
hawk_ooi_t HawkStd::readConsole (Console& io, hawk_ooch_t* data, hawk_oow_t size)
{
hawk_ooi_t nn;
@ -1060,22 +1081,22 @@ hawk_ooi_t StdHawk::readConsole (Console& io, hawk_ooch_t* data, hawk_oow_t size
return nn;
}
hawk_ooi_t StdHawk::writeConsole (Console& io, const hawk_ooch_t* data, hawk_oow_t size)
hawk_ooi_t HawkStd::writeConsole (Console& io, const hawk_ooch_t* data, hawk_oow_t size)
{
return hawk_sio_putoochars((hawk_sio_t*)io.getHandle(), data, size);
}
hawk_ooi_t StdHawk::writeConsoleBytes (Console& io, const hawk_bch_t* data, hawk_oow_t size)
hawk_ooi_t HawkStd::writeConsoleBytes (Console& io, const hawk_bch_t* data, hawk_oow_t size)
{
return hawk_sio_putbchars((hawk_sio_t*)io.getHandle(), data, size);
}
int StdHawk::flushConsole (Console& io)
int HawkStd::flushConsole (Console& io)
{
return hawk_sio_flush ((hawk_sio_t*)io.getHandle());
}
int StdHawk::nextConsole (Console& io)
int HawkStd::nextConsole (Console& io)
{
int n;
hawk_sio_t* sio = (hawk_sio_t*)io.getHandle();
@ -1095,34 +1116,34 @@ int StdHawk::nextConsole (Console& io)
}
// memory allocation primitives
void* StdHawk::allocMem (hawk_oow_t n)
void* HawkStd::allocMem (hawk_oow_t n)
{
return ::malloc (n);
}
void* StdHawk::reallocMem (void* ptr, hawk_oow_t n)
void* HawkStd::reallocMem (void* ptr, hawk_oow_t n)
{
return ::realloc (ptr, n);
}
void StdHawk::freeMem (void* ptr)
void HawkStd::freeMem (void* ptr)
{
::free (ptr);
}
// miscellaneous primitive
StdHawk::flt_t StdHawk::pow (flt_t x, flt_t y)
HawkStd::flt_t HawkStd::pow (flt_t x, flt_t y)
{
return hawk_stdmathpow (this->awk, x, y);
}
StdHawk::flt_t StdHawk::mod (flt_t x, flt_t y)
HawkStd::flt_t HawkStd::mod (flt_t x, flt_t y)
{
return hawk_stdmathmod (this->awk, x, y);
}
void* StdHawk::modopen (const mod_spec_t* spec)
void* HawkStd::modopen (const mod_spec_t* spec)
{
void* h;
h = hawk_stdmodopen (this->awk, spec);
@ -1130,12 +1151,12 @@ void* StdHawk::modopen (const mod_spec_t* spec)
return h;
}
void StdHawk::modclose (void* handle)
void HawkStd::modclose (void* handle)
{
hawk_stdmodclose (this->awk, handle);
}
void* StdHawk::modgetsym (void* handle, const hawk_ooch_t* name)
void* HawkStd::modgetsym (void* handle, const hawk_ooch_t* name)
{
void* s;
s = hawk_stdmodgetsym (this->awk, handle, name);
@ -1143,7 +1164,7 @@ void* StdHawk::modgetsym (void* handle, const hawk_ooch_t* name)
return s;
}
int StdHawk::SourceFile::open (Data& io)
int HawkStd::SourceFile::open (Data& io)
{
hawk_sio_t* sio;
@ -1242,7 +1263,7 @@ int StdHawk::SourceFile::open (Data& io)
return 1;
}
int StdHawk::SourceFile::close (Data& io)
int HawkStd::SourceFile::close (Data& io)
{
hawk_sio_t* sio = (hawk_sio_t*)io.getHandle();
hawk_sio_flush (sio);
@ -1250,17 +1271,17 @@ int StdHawk::SourceFile::close (Data& io)
return 0;
}
hawk_ooi_t StdHawk::SourceFile::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::SourceFile::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
{
return hawk_sio_getoochars ((hawk_sio_t*)io.getHandle(), buf, len);
}
hawk_ooi_t StdHawk::SourceFile::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::SourceFile::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
{
return hawk_sio_putoochars ((hawk_sio_t*)io.getHandle(), buf, len);
}
int StdHawk::SourceString::open (Data& io)
int HawkStd::SourceString::open (Data& io)
{
hawk_sio_t* sio;
@ -1336,13 +1357,13 @@ int StdHawk::SourceString::open (Data& io)
return 1;
}
int StdHawk::SourceString::close (Data& io)
int HawkStd::SourceString::close (Data& io)
{
if (!io.isMaster()) hawk_sio_close ((hawk_sio_t*)io.getHandle());
return 0;
}
hawk_ooi_t StdHawk::SourceString::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::SourceString::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
{
if (io.isMaster())
{
@ -1356,7 +1377,7 @@ hawk_ooi_t StdHawk::SourceString::read (Data& io, hawk_ooch_t* buf, hawk_oow_t l
}
}
hawk_ooi_t StdHawk::SourceString::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
hawk_ooi_t HawkStd::SourceString::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
{
if (io.isMaster())
{

View File

@ -24,11 +24,10 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _HAWK_STDAWK_HPP_
#define _HAWK_STDAWK_HPP_
#ifndef _HAWK_HAWK_STD_HPP_
#define _HAWK_HAWK_STD_HPP_
#include <Hawk.hpp>
#include <StdMmgr.hpp>
/// \file
/// Standard AWK Interpreter
@ -37,12 +36,27 @@
HAWK_BEGIN_NAMESPACE(HAWK)
////////////////////////////////
class HAWK_EXPORT MmgrStd: public Mmgr
{
public:
MmgrStd () HAWK_CPP_NOEXCEPT: Mmgr () {}
void* allocMem (hawk_oow_t n) HAWK_CPP_NOEXCEPT;
void* reallocMem (void* ptr, hawk_oow_t n) HAWK_CPP_NOEXCEPT;
void freeMem (void* ptr) HAWK_CPP_NOEXCEPT;
#if 0
/// The getInstance() function returns the stock instance of the MmgrStd class.
static MmgrStd* getInstance () HAWK_CPP_NOEXCEPT;
#endif
};
///
/// The StdHawk class provides an easier-to-use interface by overriding
/// The HawkStd class provides an easier-to-use interface by overriding
/// primitive methods, and implementing the file handler, the pipe handler,
/// and common intrinsic functions.
///
class HAWK_EXPORT StdHawk: public Hawk
class HAWK_EXPORT HawkStd: public Hawk
{
public:
///
@ -87,7 +101,7 @@ public:
const hawk_ooch_t* ptr;
};
StdHawk (Mmgr* mmgr = HAWK_NULL): Hawk(mmgr), stdmod_up(false), console_cmgr(HAWK_NULL)
HawkStd (Mmgr* mmgr = HAWK_NULL): Hawk(mmgr), stdmod_up(false), console_cmgr(HAWK_NULL)
{
}

View File

@ -158,8 +158,9 @@ libhawk_la_LIBADD += $(UNWIND_LIBS)
endif
if ENABLE_CXX
pkginclude_HEADERS += Hawk.hpp HawkStd.hpp
pkglib_LTLIBRARIES += libhawkxx.la
libhawkxx_la_SOURCES = Hawk.cpp StdHawk.cpp
libhawkxx_la_SOURCES = Hawk.cpp HawkStd.cpp
libhawkxx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libhawkxx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libhawkxx_la_LIBADD = -lhawk $(LIBADD_LIB_COMMON)

View File

@ -93,26 +93,27 @@ host_triplet = @host@
@ENABLE_LIBLTDL_TRUE@am__append_4 = $(LTDL_LIBS)
@ENABLE_LIBLTDL_FALSE@am__append_5 = $(DL_LIBS)
@ENABLE_LIBUNWIND_TRUE@am__append_6 = $(UNWIND_LIBS)
@ENABLE_CXX_TRUE@am__append_7 = libhawkxx.la
@ENABLE_CXX_TRUE@am__append_7 = Hawk.hpp HawkStd.hpp
@ENABLE_CXX_TRUE@am__append_8 = libhawkxx.la
##################################################
# STATIC MODULES BUILT INTO MAIN LIBRARY
##################################################
@ENABLE_STATIC_MODULE_TRUE@am__append_8 = \
@ENABLE_STATIC_MODULE_TRUE@am__append_9 = \
@ENABLE_STATIC_MODULE_TRUE@ imap-imp.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-math.c mod-math.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-str.c mod-str.h \
@ENABLE_STATIC_MODULE_TRUE@ mod-sys.c mod-sys.h
@ENABLE_STATIC_MODULE_TRUE@am__append_9 =
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_10 = -lhawk-mysql
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_11 = ../mod/libhawk-mysql.la
@ENABLE_MOD_UCI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_12 = -lhawk-uci
@ENABLE_MOD_UCI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_13 = ../mod/libhawk-uci.la
@ENABLE_STATIC_MODULE_TRUE@am__append_10 =
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_11 = -lhawk-mysql
@ENABLE_MOD_MYSQL_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_12 = ../mod/libhawk-mysql.la
@ENABLE_MOD_UCI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_13 = -lhawk-uci
@ENABLE_MOD_UCI_TRUE@@ENABLE_STATIC_MODULE_TRUE@am__append_14 = ../mod/libhawk-uci.la
#pkglibdir = $(libdir)
#pkglib_LTLIBRARIES =
@ENABLE_STATIC_MODULE_FALSE@am__append_14 = libhawk-math.la \
@ENABLE_STATIC_MODULE_FALSE@am__append_15 = libhawk-math.la \
@ENABLE_STATIC_MODULE_FALSE@ libhawk-str.la libhawk-sys.la
subdir = lib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -126,7 +127,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(pkginclude_HEADERS) \
DIST_COMMON = $(srcdir)/Makefile.am $(am__pkginclude_HEADERS_DIST) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = hawk-cfg.h
@ -204,24 +205,25 @@ am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
am__libhawk_la_SOURCES_DIST = hawk.h hawk-chr.h hawk-cmn.h hawk-dir.h \
hawk-ecs.h hawk-fmt.h hawk-gem.h hawk-htb.h hawk-rbt.h \
hawk-pack1.h hawk-utl.h hawk-std.h hawk-tre.h hawk-unpack.h \
arr.c chr.c dir.c ecs-imp.h ecs.c err-prv.h err.c err-sys.c \
fmt-imp.h fmt.c fnc-prv.h fnc.c htb.c gem.c gem-skad.c \
gem-nwif.c gem-nwif2.c hawk-prv.h hawk.c mb8.c misc-prv.h \
misc.c parse-prv.h parse.c rbt.c rec.c rio-prv.h rio.c \
run-prv.h run.c tre-prv.h tre-ast.c tre-ast.h tre-compile.c \
tre-compile.h tre-match-bt.c tre-match-pa.c tre-match-ut.h \
tre-mem.c tre-mem.h tre-parse.c tre-parse.h tre-stack.c \
tre-stack.h tre.c tree-prv.h tree.c utf16.c utf8.c utl-ass.c \
utl-skad.c utl-skad.h utl-sort.c utl-str.c utl-sys.c utl.c \
val-prv.h val.c hawk-cli.h hawk-fio.h hawk-mtx.h hawk-pio.h \
hawk-sio.h hawk-tio.h cli.c fio.c mtx.c pio.c sio.c syscall.h \
tio.c std-prv.h std.c imap-imp.h mod-math.c mod-math.h \
mod-str.c mod-str.h mod-sys.c mod-sys.h
Hawk.hpp HawkStd.hpp arr.c chr.c dir.c ecs-imp.h ecs.c \
err-prv.h err.c err-sys.c fmt-imp.h fmt.c fnc-prv.h fnc.c \
htb.c gem.c gem-skad.c gem-nwif.c gem-nwif2.c hawk-prv.h \
hawk.c mb8.c misc-prv.h misc.c parse-prv.h parse.c rbt.c rec.c \
rio-prv.h rio.c run-prv.h run.c tre-prv.h tre-ast.c tre-ast.h \
tre-compile.c tre-compile.h tre-match-bt.c tre-match-pa.c \
tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c tre-parse.h \
tre-stack.c tre-stack.h tre.c tree-prv.h tree.c utf16.c utf8.c \
utl-ass.c utl-skad.c utl-skad.h utl-sort.c utl-str.c utl-sys.c \
utl.c val-prv.h val.c hawk-cli.h hawk-fio.h hawk-mtx.h \
hawk-pio.h hawk-sio.h hawk-tio.h cli.c fio.c mtx.c pio.c sio.c \
syscall.h tio.c std-prv.h std.c imap-imp.h mod-math.c \
mod-math.h mod-str.c mod-str.h mod-sys.c mod-sys.h
am__objects_1 =
@ENABLE_STATIC_MODULE_TRUE@am__objects_2 = libhawk_la-mod-math.lo \
am__objects_2 = $(am__objects_1)
@ENABLE_STATIC_MODULE_TRUE@am__objects_3 = libhawk_la-mod-math.lo \
@ENABLE_STATIC_MODULE_TRUE@ libhawk_la-mod-str.lo \
@ENABLE_STATIC_MODULE_TRUE@ libhawk_la-mod-sys.lo
am_libhawk_la_OBJECTS = $(am__objects_1) libhawk_la-arr.lo \
am_libhawk_la_OBJECTS = $(am__objects_2) libhawk_la-arr.lo \
libhawk_la-chr.lo libhawk_la-dir.lo libhawk_la-ecs.lo \
libhawk_la-err.lo libhawk_la-err-sys.lo libhawk_la-fmt.lo \
libhawk_la-fnc.lo libhawk_la-htb.lo libhawk_la-gem.lo \
@ -238,14 +240,14 @@ am_libhawk_la_OBJECTS = $(am__objects_1) libhawk_la-arr.lo \
libhawk_la-utl-str.lo libhawk_la-utl-sys.lo libhawk_la-utl.lo \
libhawk_la-val.lo libhawk_la-cli.lo libhawk_la-fio.lo \
libhawk_la-mtx.lo libhawk_la-pio.lo libhawk_la-sio.lo \
libhawk_la-tio.lo libhawk_la-std.lo $(am__objects_2)
libhawk_la-tio.lo libhawk_la-std.lo $(am__objects_3)
libhawk_la_OBJECTS = $(am_libhawk_la_OBJECTS)
libhawk_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libhawk_la_LDFLAGS) $(LDFLAGS) -o $@
am__libhawkxx_la_SOURCES_DIST = Hawk.cpp StdHawk.cpp
am__libhawkxx_la_SOURCES_DIST = Hawk.cpp HawkStd.cpp
@ENABLE_CXX_TRUE@am_libhawkxx_la_OBJECTS = libhawkxx_la-Hawk.lo \
@ENABLE_CXX_TRUE@ libhawkxx_la-StdHawk.lo
@ENABLE_CXX_TRUE@ libhawkxx_la-HawkStd.lo
libhawkxx_la_OBJECTS = $(am_libhawkxx_la_OBJECTS)
libhawkxx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@ -316,6 +318,10 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__pkginclude_HEADERS_DIST = hawk.h hawk-chr.h hawk-cmn.h hawk-dir.h \
hawk-ecs.h hawk-fmt.h hawk-gem.h hawk-htb.h hawk-rbt.h \
hawk-pack1.h hawk-utl.h hawk-std.h hawk-tre.h hawk-unpack.h \
Hawk.hpp HawkStd.hpp
HEADERS = $(pkginclude_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)hawk-cfg.h.in
@ -535,23 +541,11 @@ DEPENDENCIES_LIB_COMMON =
@WIN32_TRUE@CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" \
@WIN32_TRUE@ -DHAWK_DEFAULT_MODPOSTFIX=\"-1.dll\" \
@WIN32_TRUE@ $(am__append_1) $(am__append_2)
pkginclude_HEADERS = \
hawk.h \
hawk-chr.h \
hawk-cmn.h \
hawk-dir.h \
hawk-ecs.h \
hawk-fmt.h \
hawk-gem.h \
hawk-htb.h \
hawk-rbt.h \
hawk-pack1.h \
hawk-utl.h \
hawk-std.h \
hawk-tre.h \
hawk-unpack.h
pkglib_LTLIBRARIES = libhawk.la $(am__append_7) $(am__append_14)
pkginclude_HEADERS = hawk.h hawk-chr.h hawk-cmn.h hawk-dir.h \
hawk-ecs.h hawk-fmt.h hawk-gem.h hawk-htb.h hawk-rbt.h \
hawk-pack1.h hawk-utl.h hawk-std.h hawk-tre.h hawk-unpack.h \
$(am__append_7)
pkglib_LTLIBRARIES = libhawk.la $(am__append_8) $(am__append_15)
libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c dir.c ecs-imp.h \
ecs.c err-prv.h err.c err-sys.c fmt-imp.h fmt.c fnc-prv.h \
fnc.c htb.c gem.c gem-skad.c gem-nwif.c gem-nwif2.c hawk-prv.h \
@ -563,15 +557,15 @@ libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c dir.c ecs-imp.h \
utl-ass.c utl-skad.c utl-skad.h utl-sort.c utl-str.c utl-sys.c \
utl.c val-prv.h val.c hawk-cli.h hawk-fio.h hawk-mtx.h \
hawk-pio.h hawk-sio.h hawk-tio.h cli.c fio.c mtx.c pio.c sio.c \
syscall.h tio.c std-prv.h std.c $(am__append_8)
syscall.h tio.c std-prv.h std.c $(am__append_9)
libhawk_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) $(am__append_3)
libhawk_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libhawk_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_4) \
$(am__append_5) $(am__append_6) $(am__append_9) \
$(am__append_10) $(am__append_12)
libhawk_la_DEPENDENCIES = $(DEPENDENCIES_LIB_COMMON) $(am__append_11) \
$(am__append_13)
@ENABLE_CXX_TRUE@libhawkxx_la_SOURCES = Hawk.cpp StdHawk.cpp
$(am__append_5) $(am__append_6) $(am__append_10) \
$(am__append_11) $(am__append_13)
libhawk_la_DEPENDENCIES = $(DEPENDENCIES_LIB_COMMON) $(am__append_12) \
$(am__append_14)
@ENABLE_CXX_TRUE@libhawkxx_la_SOURCES = Hawk.cpp HawkStd.cpp
@ENABLE_CXX_TRUE@libhawkxx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
@ENABLE_CXX_TRUE@libhawkxx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
@ENABLE_CXX_TRUE@libhawkxx_la_LIBADD = -lhawk $(LIBADD_LIB_COMMON)
@ -758,7 +752,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_str_la-mod-str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_sys_la-mod-sys.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawkxx_la-Hawk.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawkxx_la-StdHawk.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawkxx_la-HawkStd.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@ -1179,12 +1173,12 @@ libhawkxx_la-Hawk.lo: Hawk.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawkxx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libhawkxx_la-Hawk.lo `test -f 'Hawk.cpp' || echo '$(srcdir)/'`Hawk.cpp
libhawkxx_la-StdHawk.lo: StdHawk.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawkxx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libhawkxx_la-StdHawk.lo -MD -MP -MF $(DEPDIR)/libhawkxx_la-StdHawk.Tpo -c -o libhawkxx_la-StdHawk.lo `test -f 'StdHawk.cpp' || echo '$(srcdir)/'`StdHawk.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawkxx_la-StdHawk.Tpo $(DEPDIR)/libhawkxx_la-StdHawk.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='StdHawk.cpp' object='libhawkxx_la-StdHawk.lo' libtool=yes @AMDEPBACKSLASH@
libhawkxx_la-HawkStd.lo: HawkStd.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawkxx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libhawkxx_la-HawkStd.lo -MD -MP -MF $(DEPDIR)/libhawkxx_la-HawkStd.Tpo -c -o libhawkxx_la-HawkStd.lo `test -f 'HawkStd.cpp' || echo '$(srcdir)/'`HawkStd.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawkxx_la-HawkStd.Tpo $(DEPDIR)/libhawkxx_la-HawkStd.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='HawkStd.cpp' object='libhawkxx_la-HawkStd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawkxx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libhawkxx_la-StdHawk.lo `test -f 'StdHawk.cpp' || echo '$(srcdir)/'`StdHawk.cpp
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawkxx_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libhawkxx_la-HawkStd.lo `test -f 'HawkStd.cpp' || echo '$(srcdir)/'`HawkStd.cpp
mostlyclean-libtool:
-rm -f *.lo

View File

@ -1,7 +1,7 @@
#
# generrcode.awk
#
# qseawk -f generrcode.awk awk.h
# hawk -f generrcode.awk hawk-cmn.h
#
BEGIN {

View File

@ -1,7 +1,7 @@
#
# genoptcode.awk
#
# qseawk -f generror.awk awk.h
# hawk -f generror.awk hawk.h
#
BEGIN {

View File

@ -420,11 +420,20 @@ typedef unsigned char hawk_bchu_t; /* unsigned version of hawk_bch_t f
typedef hawk_uint32_t hawk_uchu_t; /* same as hawk_uch_t as it is already unsigned */
# define HAWK_SIZEOF_UCH_T 4
#elif defined(__GNUC__) && defined(__CHAR16_TYPE__)
typedef __CHAR16_TYPE__ hawk_uch_t;
typedef hawk_uint16_t hawk_uchu_t; /* same as hawk_uch_t as it is already unsigned */
#elif (defined(__cplusplus) && (defined(HAWK_USE_CPP_CHAR16_T) || (__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1900))) /* user chosen or C++11 or later */
/* you can define HAWK_USE_CPP_CHAR16_T if you know the C++ compiler supports char16_t and
* it treats the u"XXX" or u'x' literals incompatibly with __CHAR16_TYPE__ */
typedef char16_t hawk_uch_t; /* char16_t is an unsigned integer type used for 16-bit wide characters */
typedef char16_t hawk_uchu_t; /* same as hawk_uch_t as it is already unsigned */
# define HAWK_SIZEOF_UCH_T 2
# define HAWK_UCH_IS_CHAR16_T
#elif defined(__GNUC__) && defined(__CHAR16_TYPE__)
typedef __CHAR16_TYPE__ hawk_uch_t; /* this part isn't fully compatible with c++. try 'const __CHAR16_TYPE__* x = u"abc";' with g++ */
typedef hawk_uint16_t hawk_uchu_t;
# define HAWK_SIZEOF_UCH_T 2
# define HAWK_UCH_IS_CHAR16_T
#else
typedef hawk_uint16_t hawk_uch_t;
typedef hawk_uint16_t hawk_uchu_t; /* same as hawk_uch_t as it is already unsigned */
@ -1249,19 +1258,19 @@ typedef enum hawk_log_mask_t hawk_log_mask_t;
/* =========================================================================
* CHARACTER/STRING LITERALS
* =========================================================================*/
#define HAWK_MQ_I(val) #val
#define HAWK_MQ(val) HAWK_MQ_I(val)
#define HAWK_BQ_I(val) #val
#define HAWK_BQ(val) HAWK_BQ_I(val)
/**
* The #HAWK_BT macro maps a multi-byte literal string literal as it is.
*/
#define HAWK_BT(txt) (txt)
#if defined(HAWK_UCH_IS_CHAR16_T)
# define HAWK_WQ_I(val) (u ## #val)
# define HAWK_WQ(val) HAWK_WQ_I(val)
# define HAWK_UQ_I(val) (u ## #val)
# define HAWK_UQ(val) HAWK_UQ_I(val)
#else
# define HAWK_WQ_I(val) (L ## #val)
# define HAWK_WQ(val) HAWK_WQ_I(val)
# define HAWK_UQ_I(val) (L ## #val)
# define HAWK_UQ(val) HAWK_UQ_I(val)
#endif
/**
@ -1281,10 +1290,10 @@ typedef enum hawk_log_mask_t hawk_log_mask_t;
* #HAWK_UT if #HAWK_OOCH_IS_UCH is defined.
*/
#if defined(HAWK_OOCH_IS_BCH)
# define HAWK_Q(val) HAWK_MQ(val)
# define HAWK_Q(val) HAWK_BQ(val)
# define HAWK_T(txt) HAWK_BT(txt)
#else
# define HAWK_Q(val) HAWK_WQ(val)
# define HAWK_Q(val) HAWK_UQ(val)
# define HAWK_T(txt) HAWK_UT(txt)
#endif

View File

@ -65,7 +65,7 @@ typedef struct modctx_t
unsigned int seed;
#if defined(HAVE_INITSTATE_R) && defined(HAVE_SRANDOM_R) && defined(HAVE_RANDOM_R)
struct random_data prand;
hawk_uint8_t prand_bin[256];
char prand_bin[256]; /* or hawk_uint8_t? */
#endif
} modctx_t;