initial commit

This commit is contained in:
2007-04-28 21:31:31 +00:00
parent 6acf470ccc
commit 2779dacb22
258 changed files with 10337 additions and 17385 deletions

139
ase/net/Awk.cpp Normal file
View File

@ -0,0 +1,139 @@
/*
* $Id: Awk.cpp,v 1.1 2007/05/15 08:29:30 bacon Exp $
*/
#include "stdafx.h"
#include "Awk.hpp"
#include <ase/utl/ctype.h>
#include <ase/utl/stdio.h>
#include <stdlib.h>
#include <math.h>
#include <msclr/auto_gcroot.h>
namespace ASE
{
class StubAwk: public Awk
{
public:
StubAwk (NET::Awk^ wrapper): wrapper(wrapper)
{
}
int openSource (Source& io)
{
NET::Awk::Source^ nio = gcnew NET::Awk::Source ();
int n = wrapper->OpenSource (nio);
// TODO: put nio back to io.
return n;
}
int closeSource (Source& io)
{
return 0;
}
ssize_t readSource (Source& io, char_t* buf, size_t len)
{
return 0;
}
ssize_t writeSource (Source& io, char_t* buf, size_t len)
{
return 0;
}
int openPipe (Pipe& io) {return 0; }
int closePipe (Pipe& io) {return 0; }
ssize_t readPipe (Pipe& io, char_t* buf, size_t len) {return 0; }
ssize_t writePipe (Pipe& io, char_t* buf, size_t len) {return 0; }
int flushPipe (Pipe& io) {return 0; }
int openFile (File& io) {return 0; }
int closeFile (File& io) {return 0; }
ssize_t readFile (File& io, char_t* buf, size_t len) {return 0; }
ssize_t writeFile (File& io, char_t* buf, size_t len) {return 0; }
int flushFile (File& io) {return 0; }
int openConsole (Console& io) {return 0; }
int closeConsole (Console& io) {return 0; }
ssize_t readConsole (Console& io, char_t* buf, size_t len) {return 0; }
ssize_t writeConsole (Console& io, char_t* buf, size_t len) {return 0; }
int flushConsole (Console& io) {return 0; }
int nextConsole (Console& io) {return 0; }
// primitive operations
void* allocMem (size_t n) { return ::malloc (n); }
void* reallocMem (void* ptr, size_t n) { return ::realloc (ptr, n); }
void freeMem (void* ptr) { ::free (ptr); }
bool_t isUpper (cint_t c) { return ase_isupper (c); }
bool_t isLower (cint_t c) { return ase_islower (c); }
bool_t isAlpha (cint_t c) { return ase_isalpha (c); }
bool_t isDigit (cint_t c) { return ase_isdigit (c); }
bool_t isXdigit (cint_t c) { return ase_isxdigit (c); }
bool_t isAlnum (cint_t c) { return ase_isalnum (c); }
bool_t isSpace (cint_t c) { return ase_isspace (c); }
bool_t isPrint (cint_t c) { return ase_isprint (c); }
bool_t isGraph (cint_t c) { return ase_isgraph (c); }
bool_t isCntrl (cint_t c) { return ase_iscntrl (c); }
bool_t isPunct (cint_t c) { return ase_ispunct (c); }
cint_t toUpper (cint_t c) { return ase_toupper (c); }
cint_t toLower (cint_t c) { return ase_tolower (c); }
real_t pow (real_t x, real_t y)
{
return ::pow (x, y);
}
int vsprintf (char_t* buf, size_t size, const char_t* fmt, va_list arg)
{
return ase_vsprintf (buf, size, fmt, arg);
}
void vdprintf (const char_t* fmt, va_list arg)
{
ase_vfprintf (stderr, fmt, arg);
}
private:
msclr::auto_gcroot<NET::Awk^> wrapper;
};
namespace NET
{
Awk::Awk ()
{
awk = new ASE::StubAwk (this);
}
Awk::~Awk ()
{
delete awk;
}
bool Awk::Parse ()
{
return awk->parse () == 0;
}
bool Awk::Run ()
{
return awk->run () == 0;
}
bool Awk::AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler)
{
return false;
}
bool Awk::DeleteFunction (System::String^ name)
{
return false;
}
}
}

123
ase/net/Awk.hpp Normal file
View File

@ -0,0 +1,123 @@
/*
* $Id: Awk.hpp,v 1.1 2007/05/15 08:29:30 bacon Exp $
*/
#pragma once
#include <ase/awk/Awk.hpp>
using namespace System;
namespace ASE
{
namespace NET
{
public ref class Awk abstract
{
public:
ref class Source
{
public:
enum class MODE
{
READ = ASE::Awk::Source::READ,
WRITE = ASE::Awk::Source::WRITE
};
property MODE^ Mode
{
MODE^ get () { return this->mode; }
void set (MODE^ mode) { this->mode = mode; }
};
private:
MODE^ mode;
};
ref class Extio
{
};
ref class Pipe: public Extio
{
public:
enum class MODE
{
READ = ASE::Awk::Pipe::READ,
WRITE = ASE::Awk::Pipe::WRITE
};
property MODE^ Mode
{
MODE^ get () { return this->mode; }
void set (MODE^ mode) { this->mode = mode; }
};
private:
MODE^ mode;
};
ref class File: public Extio
{
public:
enum class MODE
{
READ = ASE::Awk::File::READ,
WRITE = ASE::Awk::File::WRITE,
APPEND = ASE::Awk::File::APPEND
};
property MODE^ Mode
{
MODE^ get () { return this->mode; }
void set (MODE^ mode) { this->mode = mode; }
};
private:
MODE^ mode;
};
ref class Console: public Extio
{
public:
enum class MODE
{
READ = ASE::Awk::Console::READ,
WRITE = ASE::Awk::Console::WRITE
};
property MODE^ Mode
{
MODE^ get () { return this->mode; }
void set (MODE^ mode) { this->mode = mode; }
};
private:
MODE^ mode;
};
Awk ();
virtual ~Awk ();
bool Parse ();
bool Run ();
delegate System::Object^ FunctionHandler (array<System::Object^>^ args);
bool AddFunction (System::String^ name, int minArgs, int maxArgs, FunctionHandler^ handler);
bool DeleteFunction (System::String^ name);
virtual int OpenSource (Source^ io) = 0;
virtual int CloseSource (Source^ io) = 0;
virtual int ReadSource (Source^ io, ASE::Awk::char_t* buf, ASE::Awk::size_t len) = 0;
virtual int WriteSource (Source^ io, ASE::Awk::char_t* buf, ASE::Awk::size_t len) = 0;
private:
ASE::Awk* awk;
};
}
}

15
ase/net/StdAwk.cpp Normal file
View File

@ -0,0 +1,15 @@
/*
* $Id: StdAwk.cpp,v 1.1 2007/07/15 16:31:59 bacon Exp $
*/
#include "stdafx.h"
#include <ase/net/StdAwk.hpp>
namespace ASE
{
namespace Net
{
}
}

16
ase/net/StdAwk.hpp Normal file
View File

@ -0,0 +1,16 @@
/*
* $Id: StdAwk.hpp,v 1.1 2007/07/15 16:31:59 bacon Exp $
*/
#include <ase/net/Awk.hpp>
namespace ASE
{
namespace Net
{
public ref class StdAwk: Awk
{
public:
};
}
}

7
ase/net/asenet.cpp Normal file
View File

@ -0,0 +1,7 @@
/*
* $Id: asenet.cpp,v 1.1 2007/05/15 08:29:30 bacon Exp $
*/
#include "stdafx.h"
#include "asenet.h"

15
ase/net/asenet.h Normal file
View File

@ -0,0 +1,15 @@
/*
* $Id: asenet.h,v 1.1 2007/05/15 08:29:30 bacon Exp $
*/
#pragma once
using namespace System;
namespace ASE
{
namespace NET
{
}
}

40
ase/net/assert.cpp Normal file
View File

@ -0,0 +1,40 @@
/*
* $Id: assert.cpp,v 1.1 2007/07/15 16:31:59 bacon Exp $
*/
#include "stdafx.h"
#ifndef NDEBUG
#include <ase/cmn/types.h>
#include <ase/cmn/macros.h>
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
void ase_assert_abort (void)
{
::abort ();
}
void ase_assert_printf (const ase_char_t* fmt, ...)
{
va_list ap;
#ifdef _WIN32
int n;
ase_char_t buf[1024];
#endif
va_start (ap, fmt);
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
//ase_vprintf (fmt, ap);
::MessageBox (NULL, buf,
ASE_T("ASSERTION FAILURE"), MB_OK|MB_ICONERROR);
va_end (ap);
}
#endif

55
ase/net/misc.cpp Normal file
View File

@ -0,0 +1,55 @@
/*
* $Id: misc.cpp,v 1.1 2007/07/20 09:23:37 bacon Exp $
*/
#include "stdafx.h"
#include "misc.h"
#ifndef NDEBUG
#include <ase/cmn/types.h>
#include <ase/cmn/macros.h>
#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#pragma warning(disable:4996)
#pragma unmanaged
void ase_assert_abort (void)
{
::abort ();
}
void ase_assert_printf (const ase_char_t* fmt, ...)
{
va_list ap;
#ifdef _WIN32
int n;
ase_char_t buf[1024];
#endif
va_start (ap, fmt);
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
//ase_vprintf (fmt, ap);
::MessageBox (NULL, buf,
ASE_T("ASSERTION FAILURE"), MB_OK|MB_ICONERROR);
va_end (ap);
}
#endif
char* unicode_to_multibyte (const wchar_t* in, int inlen, int* outlen)
{
int n;
n = WideCharToMultiByte (CP_UTF8, 0, in, inlen, NULL, 0, NULL, 0);
char* ptr = (char*)::malloc (sizeof(char)*n);
if (ptr == NULL) return NULL;
*outlen = WideCharToMultiByte (CP_UTF8, 0, in, inlen, ptr, n, NULL, 0);
return ptr;
}

18
ase/net/misc.h Normal file
View File

@ -0,0 +1,18 @@
/*
* $Id: misc.h,v 1.1 2007/07/20 09:23:37 bacon Exp $
*/
#ifndef _MISC_H_
#define _MISC_H_
#ifdef __cplusplus
extern "C" {
#endif
char* unicode_to_multibyte (const wchar_t* in, int inlen, int* outlen);
#ifdef __cplusplus
}
#endif
#endif