Recovered from cvs revision 2007-09-07 03:08:00
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.22 2007/08/24 13:17:59 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.23 2007/09/06 08:44:42 bacon Exp $
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
@ -87,7 +87,15 @@ namespace ASE
|
||||
const char_t* getErrorString (ASE::Net::Awk^ wrapper, ErrorCode num) const
|
||||
{
|
||||
this->wrapper = wrapper;
|
||||
const char_t* x = Awk::getErrorString(num);
|
||||
const char_t* x = Awk::getErrorString (num);
|
||||
this->wrapper = nullptr;
|
||||
return x;
|
||||
}
|
||||
|
||||
int setErrorString (ASE::Net::Awk^ wrapper, ErrorCode num, const char_t* msg)
|
||||
{
|
||||
this->wrapper = wrapper;
|
||||
int x = Awk::setErrorString (num, msg);
|
||||
this->wrapper = nullptr;
|
||||
return x;
|
||||
}
|
||||
@ -165,6 +173,7 @@ namespace ASE
|
||||
void onRunStart (const Run& run)
|
||||
{
|
||||
wrapper->runErrorReported = false;
|
||||
wrapper->stopRequested = false;
|
||||
|
||||
if (wrapper->OnRunStart != nullptr)
|
||||
{
|
||||
@ -197,6 +206,8 @@ namespace ASE
|
||||
|
||||
void onRunStatement (const Run& run, size_t line)
|
||||
{
|
||||
if (wrapper->stopRequested) run.stop ();
|
||||
|
||||
if (wrapper->OnRunStatement != nullptr)
|
||||
{
|
||||
wrapper->OnRunStatement (wrapper);
|
||||
@ -650,6 +661,20 @@ namespace ASE
|
||||
if (awk != NULL) awk->setOption (this, (int)this->option);
|
||||
}
|
||||
|
||||
bool Awk::SetErrorString (Awk::ERROR num, System::String^ msg)
|
||||
{
|
||||
if (awk == NULL)
|
||||
{
|
||||
setError (ERROR::NOPER);
|
||||
return false;
|
||||
}
|
||||
|
||||
cli::pin_ptr<const ASE::Awk::char_t> nptr = PtrToStringChars(msg);
|
||||
bool r = (awk->setErrorString (this, (ASE::Awk::ErrorCode)num, nptr) == 0);
|
||||
if (!r) { retrieveError (); }
|
||||
return r;
|
||||
}
|
||||
|
||||
void Awk::Close ()
|
||||
{
|
||||
if (awk != NULL)
|
||||
@ -687,6 +712,7 @@ namespace ASE
|
||||
bool Awk::Run (System::String^ entryPoint, cli::array<System::String^>^ args)
|
||||
{
|
||||
runErrorReported = false;
|
||||
stopRequested = false;
|
||||
|
||||
if (awk == NULL)
|
||||
{
|
||||
@ -694,11 +720,12 @@ namespace ASE
|
||||
return false;
|
||||
}
|
||||
|
||||
if (OnRunStart != nullptr || OnRunEnd != nullptr ||
|
||||
OnRunReturn != nullptr || OnRunStatement != nullptr)
|
||||
{
|
||||
// callback needs to be enabled to support the Stop method
|
||||
//if (OnRunStart != nullptr || OnRunEnd != nullptr ||
|
||||
// OnRunReturn != nullptr || OnRunStatement != nullptr)
|
||||
//{
|
||||
awk->enableRunCallback (this);
|
||||
}
|
||||
//}
|
||||
|
||||
if (args == nullptr || args->Length <= 0)
|
||||
{
|
||||
@ -801,6 +828,11 @@ namespace ASE
|
||||
}
|
||||
}
|
||||
|
||||
void Awk::Stop ()
|
||||
{
|
||||
stopRequested = true;
|
||||
}
|
||||
|
||||
bool Awk::AddFunction (
|
||||
System::String^ name, int minArgs, int maxArgs,
|
||||
FunctionHandler^ handler)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.20 2007/08/26 14:33:38 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.21 2007/09/06 08:44:42 bacon Exp $
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -470,6 +470,11 @@ namespace ASE
|
||||
virtual bool Run ();
|
||||
virtual bool Run (System::String^ entryPoint, cli::array<System::String^>^ args);
|
||||
|
||||
/**
|
||||
* sets the request to stop the Run method
|
||||
*/
|
||||
virtual void Stop ();
|
||||
|
||||
delegate void RunStartHandler (Awk^ awk);
|
||||
delegate void RunEndHandler (Awk^ awk);
|
||||
delegate void RunReturnHandler (Awk^ awk);
|
||||
@ -491,10 +496,12 @@ namespace ASE
|
||||
virtual bool SetMaxDepth (DEPTH id, size_t depth);
|
||||
virtual bool GetMaxDepth (DEPTH id, size_t* depth);
|
||||
|
||||
virtual bool SetErrorString (ERROR num, System::String^ str);
|
||||
|
||||
property OPTION Option
|
||||
{
|
||||
OPTION get (); //{ return this->option; }
|
||||
void set (OPTION opt); //{ this->option = opt; }
|
||||
OPTION get ();
|
||||
void set (OPTION opt);
|
||||
}
|
||||
|
||||
property System::String^ ErrorMessage
|
||||
@ -567,6 +574,7 @@ namespace ASE
|
||||
void setError (ERROR num);
|
||||
void retrieveError ();
|
||||
bool runErrorReported; // only used if the run-callback is activated.
|
||||
bool stopRequested;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.cpp,v 1.10 2007/09/05 14:42:06 bacon Exp $
|
||||
* $Id: StdAwk.cpp,v 1.12 2007/09/06 09:23:34 bacon Exp $
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
@ -112,6 +112,13 @@ namespace ASE
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER>=1400)
|
||||
#define time_t __time64_t
|
||||
#define time _time64
|
||||
#define localtime _localtime64
|
||||
#define gmtime _gmtime64
|
||||
#endif
|
||||
|
||||
bool StdAwk::Systime (System::String^ name, array<Argument^>^ args, Return^ ret)
|
||||
{
|
||||
ret->LongValue = (long_t)::time(NULL);
|
||||
@ -221,15 +228,8 @@ namespace ASE
|
||||
}
|
||||
else
|
||||
{
|
||||
try{
|
||||
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
|
||||
sw->Close ();
|
||||
}
|
||||
catch (...)
|
||||
|
||||
{
|
||||
System::Diagnostics::Debug::Print ("XXXXXX");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user