This commit is contained in:
parent
a2d5d649ba
commit
b363d651b1
@ -1031,10 +1031,24 @@ static void handle_args (argc, argv)
|
|||||||
|
|
||||||
typedef struct extension_t
|
typedef struct extension_t
|
||||||
{
|
{
|
||||||
|
ase_mmgr_t mmgr;
|
||||||
ase_awk_prmfns_t prmfns;
|
ase_awk_prmfns_t prmfns;
|
||||||
}
|
}
|
||||||
extension_t;
|
extension_t;
|
||||||
|
|
||||||
|
static void* fuser (void* org, void* space)
|
||||||
|
{
|
||||||
|
extension_t* ext = (extension_t*)space;
|
||||||
|
ext->mmgr = *(ase_mmgr_t*)org;
|
||||||
|
|
||||||
|
ext->prmfns.pow = custom_awk_pow;
|
||||||
|
ext->prmfns.sprintf = custom_awk_sprintf;
|
||||||
|
ext->prmfns.dprintf = custom_awk_dprintf;
|
||||||
|
ext->prmfns.custom_data = ASE_NULL;
|
||||||
|
|
||||||
|
return &ext->mmgr;
|
||||||
|
}
|
||||||
|
|
||||||
static int awk_main (int argc, ase_char_t* argv[])
|
static int awk_main (int argc, ase_char_t* argv[])
|
||||||
{
|
{
|
||||||
ase_awk_t* awk;
|
ase_awk_t* awk;
|
||||||
@ -1094,7 +1108,7 @@ static int awk_main (int argc, ase_char_t* argv[])
|
|||||||
mmgr.custom_data = ASE_NULL;
|
mmgr.custom_data = ASE_NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
awk = ase_awk_open (&mmgr, ASE_SIZEOF(extension_t));
|
awk = ase_awk_open (&mmgr, ASE_SIZEOF(extension_t), fuser);
|
||||||
if (awk == ASE_NULL)
|
if (awk == ASE_NULL)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -1107,16 +1121,9 @@ static int awk_main (int argc, ase_char_t* argv[])
|
|||||||
app_awk = awk;
|
app_awk = awk;
|
||||||
|
|
||||||
extension = (extension_t*) ase_awk_getextension (awk);
|
extension = (extension_t*) ase_awk_getextension (awk);
|
||||||
//extension->mmgr = mmgr;
|
|
||||||
extension->prmfns.pow = custom_awk_pow;
|
|
||||||
extension->prmfns.sprintf = custom_awk_sprintf;
|
|
||||||
extension->prmfns.dprintf = custom_awk_dprintf;
|
|
||||||
extension->prmfns.custom_data = ASE_NULL;
|
|
||||||
|
|
||||||
ase_awk_setccls (awk, ASE_GETCCLS());
|
ase_awk_setccls (awk, ASE_GETCCLS());
|
||||||
ase_awk_setprmfns (awk, &extension->prmfns);
|
ase_awk_setprmfns (awk, &extension->prmfns);
|
||||||
|
|
||||||
|
|
||||||
if (ase_awk_addfunc (awk,
|
if (ase_awk_addfunc (awk,
|
||||||
ASE_T("sleep"), 5, 0,
|
ASE_T("sleep"), 5, 0,
|
||||||
1, 1, ASE_NULL, bfn_sleep) == ASE_NULL)
|
1, 1, ASE_NULL, bfn_sleep) == ASE_NULL)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp 245 2008-07-15 05:56:32Z baconevi $
|
* $Id: Awk.hpp 279 2008-07-21 05:27:34Z baconevi $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -1104,6 +1104,10 @@ private:
|
|||||||
Awk& operator= (const Awk&);
|
Awk& operator= (const Awk&);
|
||||||
|
|
||||||
void triggerOnRunStart (Run& run);
|
void triggerOnRunStart (Run& run);
|
||||||
|
|
||||||
|
ase_mmgr_t mmgr;
|
||||||
|
ase_ccls_t ccls;
|
||||||
|
ase_awk_prmfns_t prmfns;
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h 278 2008-07-21 03:49:09Z baconevi $
|
* $Id: awk.h 279 2008-07-21 05:27:34Z baconevi $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -597,6 +597,12 @@ extern ase_awk_val_t* ase_awk_val_one;
|
|||||||
* is valid until it is successfully destroyed using the ase_ase_close()
|
* is valid until it is successfully destroyed using the ase_ase_close()
|
||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
|
* The mmgr_fuser() function is called if mmgr_fuser is not ASE_NULL.
|
||||||
|
* It is passed two parameters; the memory manager pointer as passed
|
||||||
|
* into the ase_awk_open() function and the pointer to the extension
|
||||||
|
* area allocated. It should return the pointer to the location of the
|
||||||
|
* memory manager fused into the extension area.
|
||||||
|
*
|
||||||
* RETURNS the pointer to an ase_awk_t instance on success, ASE_NULL on failure
|
* RETURNS the pointer to an ase_awk_t instance on success, ASE_NULL on failure
|
||||||
*/
|
*/
|
||||||
ase_awk_t* ase_awk_open (
|
ase_awk_t* ase_awk_open (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: types.h 278 2008-07-21 03:49:09Z baconevi $
|
* $Id: types.h 279 2008-07-21 05:27:34Z baconevi $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -314,9 +314,10 @@ typedef int ase_mcint_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* a fuser should fuse(copy and combine) the orginal data into the given space
|
/* ase_fuser_t is an abstract function type that can be used to
|
||||||
|
* fuse(copy and combine) the orginal data into the given space
|
||||||
* and return the pointer to its new location in the space */
|
* and return the pointer to its new location in the space */
|
||||||
typedef void* (*ase_fuser_t) (void* org, void* space, ase_size_t size);
|
typedef void* (*ase_fuser_t) (void* org, void* space);
|
||||||
|
|
||||||
typedef struct ase_cstr_t ase_cstr_t;
|
typedef struct ase_cstr_t ase_cstr_t;
|
||||||
typedef struct ase_mmgr_t ase_mmgr_t;
|
typedef struct ase_mmgr_t ase_mmgr_t;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.cpp 245 2008-07-15 05:56:32Z baconevi $
|
* $Id: Awk.cpp 279 2008-07-21 05:27:34Z baconevi $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -1028,6 +1028,31 @@ Awk::Awk (): awk (ASE_NULL), functionMap (ASE_NULL),
|
|||||||
|
|
||||||
{
|
{
|
||||||
this->errmsg[0] = ASE_T('\0');
|
this->errmsg[0] = ASE_T('\0');
|
||||||
|
|
||||||
|
mmgr.malloc = allocMem;
|
||||||
|
mmgr.realloc = reallocMem;
|
||||||
|
mmgr.free = freeMem;
|
||||||
|
mmgr.custom_data = this;
|
||||||
|
|
||||||
|
ccls.is_upper = isUpper;
|
||||||
|
ccls.is_lower = isLower;
|
||||||
|
ccls.is_alpha = isAlpha;
|
||||||
|
ccls.is_digit = isDigit;
|
||||||
|
ccls.is_xdigit = isXdigit;
|
||||||
|
ccls.is_alnum = isAlnum;
|
||||||
|
ccls.is_space = isSpace;
|
||||||
|
ccls.is_print = isPrint;
|
||||||
|
ccls.is_graph = isGraph;
|
||||||
|
ccls.is_cntrl = isCntrl;
|
||||||
|
ccls.is_punct = isPunct;
|
||||||
|
ccls.to_upper = toUpper;
|
||||||
|
ccls.to_lower = toLower;
|
||||||
|
ccls.custom_data = this;
|
||||||
|
|
||||||
|
prmfns.pow = pow;
|
||||||
|
prmfns.sprintf = sprintf;
|
||||||
|
prmfns.dprintf = dprintf;
|
||||||
|
prmfns.custom_data = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Awk::~Awk ()
|
Awk::~Awk ()
|
||||||
@ -1130,41 +1155,15 @@ int Awk::open ()
|
|||||||
{
|
{
|
||||||
ASE_ASSERT (awk == ASE_NULL && functionMap == ASE_NULL);
|
ASE_ASSERT (awk == ASE_NULL && functionMap == ASE_NULL);
|
||||||
|
|
||||||
ase_awk_prmfns_t prmfns;
|
awk = ase_awk_open (&mmgr, 0, ASE_NULL);
|
||||||
|
|
||||||
prmfns.mmgr.malloc = allocMem;
|
|
||||||
prmfns.mmgr.realloc = reallocMem;
|
|
||||||
prmfns.mmgr.free = freeMem;
|
|
||||||
prmfns.mmgr.custom_data = this;
|
|
||||||
|
|
||||||
prmfns.ccls.is_upper = isUpper;
|
|
||||||
prmfns.ccls.is_lower = isLower;
|
|
||||||
prmfns.ccls.is_alpha = isAlpha;
|
|
||||||
prmfns.ccls.is_digit = isDigit;
|
|
||||||
prmfns.ccls.is_xdigit = isXdigit;
|
|
||||||
prmfns.ccls.is_alnum = isAlnum;
|
|
||||||
prmfns.ccls.is_space = isSpace;
|
|
||||||
prmfns.ccls.is_print = isPrint;
|
|
||||||
prmfns.ccls.is_graph = isGraph;
|
|
||||||
prmfns.ccls.is_cntrl = isCntrl;
|
|
||||||
prmfns.ccls.is_punct = isPunct;
|
|
||||||
prmfns.ccls.to_upper = toUpper;
|
|
||||||
prmfns.ccls.to_lower = toLower;
|
|
||||||
prmfns.ccls.custom_data = this;
|
|
||||||
|
|
||||||
prmfns.misc.pow = pow;
|
|
||||||
prmfns.misc.sprintf = sprintf;
|
|
||||||
prmfns.misc.dprintf = dprintf;
|
|
||||||
prmfns.misc.custom_data = this;
|
|
||||||
|
|
||||||
awk = ase_awk_open (&prmfns);
|
|
||||||
if (awk == ASE_NULL)
|
if (awk == ASE_NULL)
|
||||||
{
|
{
|
||||||
setError (ERR_NOMEM);
|
setError (ERR_NOMEM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ase_awk_setassocdata (awk, this);
|
ase_awk_setccls (awk, &ccls);
|
||||||
|
ase_awk_setprmfns (awk, &prmfns);
|
||||||
|
|
||||||
functionMap = ase_map_open (
|
functionMap = ase_map_open (
|
||||||
this, 512, 70, freeFunctionMapValue, ASE_NULL,
|
this, 512, 70, freeFunctionMapValue, ASE_NULL,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c 278 2008-07-21 03:49:09Z baconevi $
|
* $Id: awk.c 279 2008-07-21 05:27:34Z baconevi $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -37,7 +37,7 @@ ase_awk_t* ase_awk_open (
|
|||||||
if (awk == ASE_NULL) return ASE_NULL;
|
if (awk == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
ase_memset (awk, 0, ASE_SIZEOF(ase_awk_t) + extension);
|
ase_memset (awk, 0, ASE_SIZEOF(ase_awk_t) + extension);
|
||||||
if (mmgr_fuser) mmgr = mmgr_fuser (mmgr, awk + 1, extension);
|
if (mmgr_fuser) mmgr = mmgr_fuser (mmgr, awk + 1);
|
||||||
awk->mmgr = mmgr;
|
awk->mmgr = mmgr;
|
||||||
|
|
||||||
if (ase_str_open (&awk->token.name, 128, mmgr) == ASE_NULL)
|
if (ase_str_open (&awk->token.name, 128, mmgr) == ASE_NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user