Recovered from cvs revision 2007-05-03 15:14:00
This commit is contained in:
parent
6114d3ec90
commit
6f28e48ff9
@ -1,23 +1,18 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.2 2007/05/01 12:39:22 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.4 2007/05/02 15:07:33 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/Awk.hpp>
|
||||
|
||||
namespace ASE
|
||||
{
|
||||
|
||||
Awk::Awk (): awk (ASE_NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Awk::~Awk ()
|
||||
{
|
||||
if (awk != ASE_NULL)
|
||||
{
|
||||
ase_awk_close (awk);
|
||||
awk = ASE_NULL;
|
||||
}
|
||||
close ();
|
||||
}
|
||||
|
||||
int Awk::parse ()
|
||||
@ -27,18 +22,76 @@ namespace ASE
|
||||
/*awk = ase_awk_open (*/
|
||||
}
|
||||
|
||||
ase_awk_srcios_t srcios;
|
||||
|
||||
srcios.in = sourceReader;
|
||||
srcios.out = sourceWriter;
|
||||
srcios.custom_data = this;
|
||||
|
||||
return ase_awk_parse (awk, ASE_NULL);
|
||||
}
|
||||
|
||||
int Awk::run (/*const ase_char_t* main*/)
|
||||
int Awk::run (const ase_char_t* main, const ase_char_t** args)
|
||||
{
|
||||
if (awk == ASE_NULL)
|
||||
{
|
||||
// TODO: SET ERROR INFO
|
||||
return -1;
|
||||
}
|
||||
|
||||
//return ase_awk_run (awk, main);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Awk::close ()
|
||||
{
|
||||
if (awk != ASE_NULL)
|
||||
{
|
||||
ase_awk_close (awk);
|
||||
awk = ASE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ase_ssize_t Awk::sourceReader (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count)
|
||||
{
|
||||
ASE::Awk* awk = (ASE::Awk*)arg;
|
||||
|
||||
if (cmd == ASE_AWK_IO_OPEN)
|
||||
{
|
||||
return awk->openSource (ASE::Awk::SOURCE_READ);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_CLOSE)
|
||||
{
|
||||
return awk->closeSource (ASE::Awk::SOURCE_READ);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_READ)
|
||||
{
|
||||
return awk->readSource (data, count);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
ase_ssize_t Awk::sourceWriter (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count)
|
||||
{
|
||||
ASE::Awk* awk = (ASE::Awk*)arg;
|
||||
|
||||
if (cmd == ASE_AWK_IO_OPEN)
|
||||
{
|
||||
return awk->openSource (ASE::Awk::SOURCE_WRITE);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_CLOSE)
|
||||
{
|
||||
return awk->closeSource (ASE::Awk::SOURCE_WRITE);
|
||||
}
|
||||
else if (cmd == ASE_AWK_IO_WRITE)
|
||||
{
|
||||
return awk->writeSource (data, count);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.1 2007/04/30 05:47:33 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.3 2007/05/02 15:07:33 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_AWK_HPP_
|
||||
@ -14,10 +14,31 @@ namespace ASE
|
||||
{
|
||||
public:
|
||||
Awk ();
|
||||
~Awk ();
|
||||
virtual ~Awk ();
|
||||
|
||||
int parse ();
|
||||
int run ();
|
||||
int run (const ase_char_t* main, const ase_char_t** args);
|
||||
void close ();
|
||||
|
||||
enum SourceMode
|
||||
{
|
||||
SOURCE_READ,
|
||||
SOURCE_WRITE
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual int openSource (SourceMode mode) = 0;
|
||||
virtual int closeSource (SourceMode mode) = 0;
|
||||
|
||||
virtual ase_ssize_t readSource (
|
||||
ase_char_t* buf, ase_size_t len) = 0;
|
||||
virtual ase_ssize_t writeSource (
|
||||
ase_char_t* buf, ase_size_t len) = 0;
|
||||
|
||||
static ase_ssize_t sourceReader (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
||||
static ase_ssize_t sourceWriter (
|
||||
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
||||
|
||||
private:
|
||||
ase_awk_t* awk;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: makefile.in,v 1.3 2007/04/30 05:47:33 bacon Exp $
|
||||
# $Id: makefile.in,v 1.4 2007/05/02 15:07:33 bacon Exp $
|
||||
#
|
||||
|
||||
NAME = aseawk
|
||||
@ -51,9 +51,7 @@ OBJ_FILES_LIB = \
|
||||
|
||||
OBJ_FILES_JNI = $(TMP_DIR)/jni.o
|
||||
|
||||
OBJ_FILES_LIB_CXX = \
|
||||
$(OBJ_FILES_LIB) \
|
||||
$(TMP_DIR)/cxx/Awk.o
|
||||
OBJ_FILES_LIB_CXX = $(TMP_DIR)/cxx/Awk.o
|
||||
|
||||
OBJ_FILES_SO = $(OBJ_FILES_LIB:.o=.lo) $(OBJ_FILES_JNI:.o=.lo)
|
||||
|
||||
@ -77,7 +75,7 @@ $(OUT_FILE_JNI): $(TMP_DIR) $(OBJ_FILES_JNI) $(OBJ_FILES_JAR) $(OUT_FILE_LIB)
|
||||
$(LIBTOOL_LINK) $(CC) -rpath $(TOP_INSTALLDIR)/lib -version-info 1:0:0 -o $(OUT_FILE_JNI) $(OBJ_FILES_SO) -lm -L$(OUT_DIR) -l$(NAME) -lasecmn -laseutl
|
||||
$(JAR) -Mcvf $(OUT_FILE_JAR) -C $(TMP_DIR) ase
|
||||
|
||||
$(OUT_FILE_LIB_CXX): $(TMP_DIR_CXX) $(OUT_DIR) $(OBJ_FILES_LIB_CXX)
|
||||
$(OUT_FILE_LIB_CXX): $(TMP_DIR_CXX) $(OUT_DIR) $(OUT_FILE_LIB) $(OBJ_FILES_LIB_CXX)
|
||||
$(AR) cr $(OUT_FILE_LIB_CXX) $(OBJ_FILES_LIB_CXX)
|
||||
if [ "$(RANLIB)" = "ranlib" ]; then ranlib $(OUT_FILE_LIB_CXX); fi
|
||||
|
||||
@ -135,7 +133,7 @@ $(TMP_DIR)/ase/awk/Extio.class:
|
||||
$(TMP_DIR)/ase/awk/Exception.class:
|
||||
$(JAVAC) -classpath ../.. -d $(TMP_DIR) Exception.java
|
||||
|
||||
$(TMP_DIR)/cxx/Awk.o:
|
||||
$(TMP_DIR)/cxx/Awk.o: Awk.cpp Awk.hpp
|
||||
$(CXX) $(CXXFLAGS) -o $@ -c Awk.cpp
|
||||
|
||||
$(OUT_DIR):
|
||||
|
34
ase/test/awk/Awk.cpp
Normal file
34
ase/test/awk/Awk.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.1 2007/05/02 15:07:33 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/Awk.h>
|
||||
|
||||
class TestAwk: public ASE::Awk
|
||||
{
|
||||
int openSource (SourceMode mode)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int closeSource (SourceMode mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ase_ssize_t readSource (ase_char_t* buf, ase_size_t count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ase_ssize_t writeSource (ase_char_t* buf, ase_size_t count);
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
int main ()
|
||||
{
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user