Recovered from cvs revision 2007-05-07 08:23:00

This commit is contained in:
hyung-hwan 2007-05-07 20:08:00 +00:00
parent 4821ee87ce
commit 8d1d47e26f
13 changed files with 90 additions and 52 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.9 2007/05/06 06:55:05 bacon Exp $
* $Id: Awk.cpp,v 1.11 2007/05/06 10:38:22 bacon Exp $
*/
#include <ase/awk/Awk.hpp>
@ -81,7 +81,6 @@ namespace ASE
Awk::~Awk ()
{
close ();
}
int Awk::parse ()
@ -105,10 +104,8 @@ namespace ASE
runios.pipe = pipeHandler;
runios.coproc = ASE_NULL;
/*
runios.file = fileHandler;
runios.console = consoleHandler;
*/
runios.custom_data = this;
return ase_awk_run (

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.8 2007/05/06 06:55:05 bacon Exp $
* $Id: Awk.hpp,v 1.10 2007/05/06 10:38:22 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_HPP_
@ -9,6 +9,16 @@
#include <ase/awk/map.h>
#include <stdarg.h>
#ifdef malloc
#undef malloc
#endif
#ifdef realloc
#undef realloc
#endif
#ifdef free
#undef free
#endif
namespace ASE
{
@ -108,7 +118,6 @@ namespace ASE
Mode mode;
};
Awk ();
virtual ~Awk ();
@ -231,7 +240,7 @@ namespace ASE
const char_t* fmt, ...);
static void dprintf (void* custom, const char_t* fmt, ...);
private:
protected:
ase_awk_t* awk;
ase_awk_map_t* functionMap;

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp,v 1.3 2007/05/06 06:55:05 bacon Exp $
* $Id: StdAwk.cpp,v 1.4 2007/05/06 10:38:22 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -16,11 +16,23 @@ namespace ASE
int n = Awk::open ();
if (n == 0)
{
/*
int opt = ASE_AWK_IMPLICIT |
ASE_AWK_EXPLICIT |
ASE_AWK_UNIQUEFN |
ASE_AWK_IDIV |
ASE_AWK_SHADING |
ASE_AWK_SHIFT |
ASE_AWK_EXTIO |
ASE_AWK_BLOCKLESS |
ASE_AWK_STRBASEONE |
ASE_AWK_STRIPSPACES |
ASE_AWK_NEXTOFILE /*|
ASE_AWK_ARGSTOMAIN*/;
ase_awk_setoption (awk, opt);
addFunction (ASE_T("sin"), 1, 1, (FunctionHandler)&StdAwk::sin);
addFunction (ASE_T("cos"), 1, 1, (FunctionHandler)&StdAwk::cos);
addFunction (ASE_T("tan"), 1, 1, (FunctionHandler)&StdAwk::tan);
*/
}
return n;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
* $Id: awk.c,v 1.5 2007/05/06 10:38:22 bacon Exp $
*
* {License}
*/
@ -40,12 +40,9 @@ ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
prmfns->misc.sprintf != ASE_NULL &&
prmfns->misc.dprintf != ASE_NULL);
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
awk = (ase_awk_t*) malloc (ASE_SIZEOF(ase_awk_t));
#else
awk = (ase_awk_t*) prmfns->mmgr.malloc (
prmfns->mmgr.custom_data, ASE_SIZEOF(ase_awk_t));
#endif
/* use ASE_MALLOC instead of ASE_AWK_MALLOC because
* the awk object has not been initialized yet */
awk = ASE_MALLOC (&prmfns->mmgr, ASE_SIZEOF(ase_awk_t));
if (awk == ASE_NULL) return ASE_NULL;
/* it uses the built-in ase_awk_memset because awk is not

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.4 2007/05/05 16:32:46 bacon Exp $
* $Id: awk_i.h,v 1.5 2007/05/06 10:08:54 bacon Exp $
*
* {License}
*/
@ -34,18 +34,9 @@ typedef struct ase_awk_tree_t ase_awk_tree_t;
#define ASE_AWK_MAX_LOCALS 9999
#define ASE_AWK_MAX_PARAMS 9999
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define ASE_AWK_MALLOC(awk,size) malloc (size)
#define ASE_AWK_REALLOC(awk,ptr,size) realloc (ptr, size)
#define ASE_AWK_FREE(awk,ptr) free (ptr)
#else
#define ASE_AWK_MALLOC(awk,size) ASE_MALLOC(&(awk)->prmfns.mmgr,size)
#define ASE_AWK_REALLOC(awk,ptr,size) ASE_REALLOC(&(awk)->prmfns.mmgr,ptr,size)
#define ASE_AWK_FREE(awk,ptr) ASE_FREE(&(awk)->prmfns.mmgr,ptr)
#endif
#define ASE_AWK_ISUPPER(awk,c) ASE_ISUPPER(&(awk)->prmfns.ccls,c)
#define ASE_AWK_ISLOWER(awk,c) ASE_ISLOWER(&(awk)->prmfns.ccls,c)

View File

@ -1,5 +1,5 @@
/*
* $Id: map.c,v 1.5 2007/05/06 06:55:05 bacon Exp $
* $Id: map.c,v 1.6 2007/05/06 08:52:18 bacon Exp $
*
* {License}
*/
@ -36,7 +36,7 @@ ase_awk_map_t* ase_awk_map_open (
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_pair_t*) * capa);
if (map->buck == ASE_NULL)
{
if (map->__dynamic) ASE_AWK_FREE (awk, map);
ASE_AWK_FREE (awk, map);
return ASE_NULL;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: map.h,v 1.5 2007/05/06 06:55:05 bacon Exp $
* $Id: map.h,v 1.6 2007/05/06 08:52:18 bacon Exp $
*
* {License}
*/
@ -34,7 +34,6 @@ struct ase_awk_map_t
ase_awk_pair_t** buck;
void (*freeval) (void*,void*);
ase_awk_t* awk;
ase_bool_t __dynamic;
};
#define ASE_AWK_PAIR_KEYPTR(p) ((p)->key.ptr)

View File

@ -1,5 +1,5 @@
/*
* $Id: macros.h,v 1.3 2007/04/30 05:55:36 bacon Exp $
* $Id: macros.h,v 1.5 2007/05/06 10:08:36 bacon Exp $
*
* {License}
*/
@ -118,9 +118,23 @@
(ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
#endif
#define ASE_MALLOC(mmgr,size) (mmgr)->malloc((mmgr)->custom_data, size)
#define ASE_REALLOC(mmgr,ptr,size) (mmgr)->realloc((mmgr)->custom_data, ptr, size)
#define ASE_FREE(mmgr,ptr) (mmgr)->free((mmgr)->custom_data, ptr)
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#include <stdlib.h>
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define ASE_MALLOC(mmgr,size) malloc (size)
#define ASE_REALLOC(mmgr,ptr,size) realloc (ptr, size)
#define ASE_FREE(mmgr,ptr) free (ptr)
#else
#define ASE_MALLOC(mmgr,size) \
(mmgr)->malloc((mmgr)->custom_data, size)
#define ASE_REALLOC(mmgr,ptr,size) \
(mmgr)->realloc((mmgr)->custom_data, ptr, size)
#define ASE_FREE(mmgr,ptr) \
(mmgr)->free((mmgr)->custom_data, ptr)
#endif
#define ASE_ISUPPER(ccls,c) (ccls)->is_upper((ccls)->custom_data,c)
#define ASE_ISLOWER(ccls,c) (ccls)->is_lower((ccls)->custom_data,c)

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h,v 1.4 2007/05/05 10:43:08 bacon Exp $
* $Id: types.h,v 1.6 2007/05/06 08:08:22 bacon Exp $
*
* {License}
*/
@ -163,7 +163,7 @@ typedef ase_uint_t ase_word_t;
typedef char ase_mchar_t;
typedef int ase_mcint_t;
#if defined(__cplusplus) && (__cplusplus>1)
#if defined(__cplusplus) && !(defined(_MSC_VER)&&(_MSC_VER<=1200))
/* C++ */
typedef wchar_t ase_wchar_t;
typedef wchar_t ase_wcint_t;

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.2 2007/05/06 06:55:05 bacon Exp $
* $Id: Awk.cpp,v 1.5 2007/05/06 10:38:22 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -11,11 +11,19 @@
#include <stdlib.h>
#include <math.h>
#if defined(_WIN32)
#include <windows.h>
#endif
class TestAwk: public ASE::StdAwk
{
public:
~TestAwk ()
{
close ();
}
int parse (const char_t* name)
{
ase_strxcpy (sourceInName, ASE_COUNTOF(sourceInName), name);
@ -32,6 +40,7 @@ protected:
FILE* fp = ase_fopen (sourceInName, ASE_T("r"));
if (fp == ASE_NULL) return -1;
io.setHandle (fp);
return 1;
}
else if (mode == Source::WRITE)
{
@ -61,7 +70,13 @@ protected:
ssize_t readSource (Source& io, char_t* buf, size_t count)
{
return 0;
if (count <= 0) return -1;
// TOOD: read more characters...
cint_t c = ase_fgetc ((FILE*)io.getHandle());
if (c == ASE_CHAR_EOF) return 0;
buf[0] = (ase_char_t)c;
return 1;
}
ssize_t writeSource (Source& io, char_t* buf, size_t count)
@ -95,7 +110,7 @@ protected:
}
ssize_t writeConsole (Console& io, char_t* buf, size_t len)
{
return ase_printf (ASE_T(".%s"), len, buf);
return ase_printf (ASE_T("%.*s"), len, buf);
}
int flushConsole (Console& io) { return 0; }
int nextConsole (Console& io) { return 0; }
@ -171,7 +186,7 @@ void ase_assert_printf (const ase_char_t* fmt, ...)
}
#endif
int ase_main (int argc, ase_char_t* argv[])
extern "C" int ase_main (int argc, ase_char_t* argv[])
{
TestAwk awk;
@ -182,7 +197,6 @@ int ase_main (int argc, ase_char_t* argv[])
return -1;
}
return -1;
if (awk.parse(ASE_T("t.awk")) == -1)
{
ase_fprintf (stderr, ASE_T("cannot parse\n"));
@ -197,6 +211,6 @@ return -1;
return -1;
}
awk.close ();
// awk.close ();
return 0;
}

View File

@ -1,11 +1,13 @@
#
# $Id: makefile.in,v 1.3 2007/04/30 08:32:41 bacon Exp $
# $Id: makefile.in,v 1.5 2007/05/06 08:10:31 bacon Exp $
#
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/@BUILDMODE@/lib
LIBS = @LIBS@ -laseawk -lasecmn -laseutl -lm
LIBS_CXX = -laseawk++ ${LIBS}
MODE = @BUILDMODE@
JAVAC = @JAVAC@
@ -21,7 +23,7 @@ ASEAWK_LIB =
all: build$(JNI)
build: $(TMP_DIR) $(OUT_DIR) $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini
build: $(TMP_DIR) $(OUT_DIR) $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini $(OUT_DIR)/aseawk++
buildjni: build $(OUT_DIR)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html
@ -31,6 +33,9 @@ $(OUT_DIR)/aseawk: awk.c
$(OUT_DIR)/aseawk_mini: mini.c
$(CC) $(CFLAGS) -o $@ mini.c $(LDFLAGS) $(LIBS)
$(OUT_DIR)/aseawk++: Awk.cpp
$(CXX) $(CFLAGS) -o $@ Awk.cpp $(LDFLAGS) $(LIBS_CXX)
$(OUT_DIR)/aseawk.jar: $(TMP_DIR)/AseAwkPanel.class $(TMP_DIR)/AseAwk.class $(TMP_DIR)/AseAwkApplet.class
cd $(TMP_DIR); $(JAR) -xvf ../$(LIB_DIR)/aseawk.jar
cd $(TMP_DIR); $(JAR) -cvfm ../$@ ../manifest *.class ase
@ -55,5 +60,5 @@ $(TMP_DIR):
mkdir -p $(TMP_DIR)
clean:
rm -rf $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini $(OUT_DIR)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html $(TMP_DIR)/*.class
rm -rf $(OUT_DIR)/aseawk $(OUT_DIR)/aseawk_mini $(OUT_DIR)/aseawk++ $(OUT_DIR)/aseawk.jar $(OUT_DIR)/AseAwkApplet.html $(TMP_DIR)/*.class

View File

@ -30,7 +30,7 @@
<ItemGroup>
<Reference Include="Interop.ASECOM, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>obj\Release\Interop.ASECOM.dll</HintPath>
<HintPath>..\..\cnt\obj\Debug\Interop.ASECOM.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />

View File

@ -1,5 +1,5 @@
/*
* $Id: main.h,v 1.3 2007/04/30 08:32:50 bacon Exp $
* $Id: main.h,v 1.4 2007/05/06 08:05:36 bacon Exp $
*/
#ifndef _ASE_UTL_MAIN_H_
@ -16,7 +16,7 @@
#else
#ifdef __cplusplus
extern "C" { int ase_main (...); }
/*extern "C" { int ase_main (...); }*/
#else
extern int ase_main ();
#endif