This commit is contained in:
hyung-hwan 2008-06-29 03:38:00 +00:00
parent cbc48145c4
commit 07b451aedb
9 changed files with 67 additions and 24 deletions

View File

@ -1153,7 +1153,7 @@ static int awk_main (int argc, ase_char_t* argv[])
prmfns.misc.dprintf = custom_awk_dprintf;
prmfns.misc.custom_data = NULL;
awk = ase_awk_open(&prmfns, ASE_NULL);
awk = ase_awk_open(&prmfns);
if (awk == ASE_NULL)
{
#ifdef _WIN32

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 223 2008-06-26 06:44:41Z baconevi $
* $Id: awk.h 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -458,12 +458,22 @@ enum ase_awk_global_id_t
extern "C" {
#endif
ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data);
ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns);
int ase_awk_close (ase_awk_t* awk);
int ase_awk_clear (ase_awk_t* awk);
/**
* @function ase_awk_setassocdata
* @brief ssociats the user-specified data with an interpreter
*/
void ase_awk_setassocdata (ase_awk_t* awk, void* data);
/**
* @function ase_awk_getassocdata
* @brief returns the user-specified data associated with an interpreter
*/
void* ase_awk_getassocdata (ase_awk_t* awk);
ase_mmgr_t* ase_awk_getmmgr (ase_awk_t* awk);
void* ase_awk_getcustomdata (ase_awk_t* awk);
const ase_char_t* ase_awk_geterrstr (ase_awk_t* awk, int num);
int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str);

View File

@ -94,6 +94,17 @@ ase_lsp_t* ase_lsp_open (
void ase_lsp_close (ase_lsp_t* lsp);
/**
* @function ase_lsp_setassocdata
* @brief ssociats the user-specified data with an interpreter
*/
void ase_lsp_setassocdata (ase_lsp_t* lsp, void* data);
/**
* @function ase_lsp_getassocdata
* @brief returns the user-specified data associated with an interpreter
*/
void* ase_lsp_getassocdata (ase_lsp_t* lsp);
void ase_lsp_geterror (
ase_lsp_t* lsp, int* errnum, const ase_char_t** errmsg);

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 129 2008-03-13 05:45:36Z baconevi $
* $Id: Awk.cpp 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -1158,13 +1158,15 @@ int Awk::open ()
prmfns.misc.dprintf = dprintf;
prmfns.misc.custom_data = this;
awk = ase_awk_open (&prmfns, this);
awk = ase_awk_open (&prmfns);
if (awk == ASE_NULL)
{
setError (ERR_NOMEM);
return -1;
}
ase_awk_setassocdata (awk, this);
functionMap = ase_map_open (
this, 512, 70, freeFunctionMapValue, ASE_NULL,
ase_awk_getmmgr(awk));

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 197 2008-06-09 06:24:10Z baconevi $
* $Id: awk.c 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -24,7 +24,7 @@ static void free_bfn (void* awk, void* afn);
ase_awk_seterror ((awk), (code), (line), &errarg, 1); \
} while (0)
ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns)
{
ase_awk_t* awk;
@ -224,7 +224,7 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_BUILD, 0);
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_MATCH, 0);
awk->custom_data = custom_data;
awk->assoc_data = ASE_NULL;
if (ase_awk_initglobals (awk) == -1)
{
@ -375,6 +375,16 @@ int ase_awk_clear (ase_awk_t* awk)
return 0;
}
void ase_awk_setassocdata (ase_awk_t* awk, void* data)
{
awk->assoc_data = data;
}
void* ase_awk_getassocdata (ase_awk_t* awk)
{
return awk->assoc_data;
}
int ase_awk_getoption (ase_awk_t* awk)
{
return awk->option;
@ -390,11 +400,6 @@ ase_mmgr_t* ase_awk_getmmgr (ase_awk_t* awk)
return &awk->prmfns.mmgr;
}
void* ase_awk_getcustomdata (ase_awk_t* awk)
{
return awk->custom_data;
}
void ase_awk_stopall (ase_awk_t* awk)
{
awk->stopall = ASE_TRUE;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h 192 2008-06-06 10:33:44Z baconevi $
* $Id: awk_i.h 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -75,7 +75,7 @@ struct ase_awk_tree_t
struct ase_awk_t
{
ase_awk_prmfns_t prmfns;
void* custom_data;
void* assoc_data;
/* options */
int option;

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c 115 2008-03-03 11:13:15Z baconevi $
* $Id: jni.c 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -407,7 +407,7 @@ static void throw_exception (
static jboolean is_debug (ase_awk_t* awk)
{
awk_data_t* awk_data = (awk_data_t*)ase_awk_getcustomdata (awk);
awk_data_t* awk_data = (awk_data_t*)ase_awk_getassocdata (awk);
return awk_data->debug? JNI_TRUE: JNI_FALSE;
}
@ -490,7 +490,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
awk_data->heap = heap;
#endif
awk = ase_awk_open (&prmfns, awk_data);
awk = ase_awk_open (&prmfns);
if (awk == ASE_NULL)
{
#if defined(_WIN32) && defined(__DMC__)
@ -503,6 +503,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
return;
}
ase_awk_setassocdata (awk, awk_data);
class = (*env)->GetObjectClass(env, obj);
handle = (*env)->GetFieldID (env, class, FIELD_AWKID, "J");
(*env)->DeleteLocalRef (env, class);
@ -551,7 +553,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj, jlong a
OutputDebugStringW (L"<<<CLOSING AWK>>>\n");
#endif
tmp = (awk_data_t*)ase_awk_getcustomdata (awk);
tmp = (awk_data_t*)ase_awk_getassocdata (awk);
#if defined(_WIN32) && defined(__DMC__)
HANDLE heap = tmp->heap;
#endif
@ -1938,7 +1940,7 @@ JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug (JNIEnv* env, jobject obj,
{
ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_ASE_NULL_AWK_RETURNING (env, awk, JNI_FALSE);
return ((awk_data_t*)ase_awk_getcustomdata(awk))->debug? JNI_TRUE: JNI_FALSE;
return ((awk_data_t*)ase_awk_getassocdata(awk))->debug? JNI_TRUE: JNI_FALSE;
}
JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug (
@ -1946,7 +1948,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug (
{
ase_awk_t* awk = (ase_awk_t*)awkid;
EXCEPTION_ON_ASE_NULL_AWK (env, awk);
((awk_data_t*)ase_awk_getcustomdata(awk))->debug = debug;
((awk_data_t*)ase_awk_getassocdata(awk))->debug = debug;
}
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_getword (

View File

@ -1,5 +1,5 @@
/*
* $Id: lsp.c 215 2008-06-19 10:27:37Z baconevi $
* $Id: lsp.c 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -54,6 +54,7 @@ ase_lsp_t* ase_lsp_open (
* fully initialized yet */
ase_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t));
ase_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
lsp->assoc_data = ASE_NULL;
if (ase_lsp_name_open(&lsp->token.name, 0, lsp) == ASE_NULL)
{
@ -101,6 +102,16 @@ void ase_lsp_close (ase_lsp_t* lsp)
ASE_LSP_FREE (lsp, lsp);
}
void ase_lsp_setassocdata (ase_lsp_t* lsp, void* data)
{
lsp->assoc_data = data;
}
void* ase_lsp_getassocdata (ase_lsp_t* lsp)
{
return lsp->assoc_data;
}
int ase_lsp_attinput (ase_lsp_t* lsp, ase_lsp_io_t input, void* arg)
{
if (ase_lsp_detinput(lsp) == -1) return -1;

View File

@ -1,5 +1,5 @@
/*
* $Id: lsp_i.h 215 2008-06-19 10:27:37Z baconevi $
* $Id: lsp_i.h 232 2008-06-28 09:38:00Z baconevi $
*
* {License}
*/
@ -43,6 +43,8 @@
struct ase_lsp_t
{
ase_lsp_prmfns_t prmfns;
/* user-specified data */
void* assoc_data;
/* error */
int errnum;