home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MATLIB
/
TEST.CPP
< prev
Wrap
C/C++ Source or Header
|
1996-01-06
|
2KB
|
148 lines
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <stdio.h>
#include <dos.h>
#include <string.h>
#include <assert.h>
extern "C" {
#include "lib.h"
#include "matrix.h"
#include "ml.h"
#include "matclass.h"
void test();
static void StreamInit();
static int StreamOutput( int, int, DataStruct* );
};
class ErrorObject {
public:
char msg[256] ;
};
#include "message.h"
static TMessageWindow *MessageOut ;
class TMyApp : public TApplication {
public:
TMyApp() : TApplication() {}
protected:
BOOL isidle ;
void InitMainWindow();
BOOL IdleAction( long );
};
void TMyApp::InitMainWindow()
{
isidle = TRUE ;
MessageOut = new TMessageWindow( "message window", 100 );
SetMainWindow( MessageOut->GetWindowPtr() );
}
ErrorObject err ;
void error( const char *msg ) throw( ErrorObject& )
{
static int errcnt = 0 ;
wprintf( msg );
wprintf( "\n" );
strcpy( err.msg, msg );
throw( err );
}
BOOL TMyApp::IdleAction( long /* idleCount */ )
{
#if 1
if ( isidle )
{
MessageSet( error, NULL );
try {
test();
}
catch( ErrorObject& err )
{
MainWindow->MessageBox( err.msg, "catch" );
MainWindow->CloseWindow();
}
isidle = FALSE ;
}
#endif
return FALSE ;
}
int OwlMain(int /*argc*/, char* /*argv*/ [])
{
if ( LibraryInit() < 0 )
return -1 ;
MatrixInit();
return TMyApp().Run();
}
void test()
{
int pdebug = FALSE, edebug = FALSE ;
MLInit();
ParseInit();
MatrixClassInit();
StreamInit();
DebugMode( pdebug, edebug );
wprintf( "open %s\n", "mat.ml" );
ParseSentenseAll( "mat.ml" );
#if 1
/* 実行 */
ExecInit();
ExecSentenseAll();
ExecExit();
#endif
ParseExit();
}
DataStruct StreamOut ;
int StreamClassID ;
static void StreamInit()
{
StreamClassID = NewClass( "Stream", 0 );
StreamOut.type = TYPE_OBJECT ;
StreamOut.od.ptr = ObjectAlloc( 0, StreamClassID );
NewConst( "cout", &StreamOut );
NewOperator( StreamClassID, OPE_LSFT, StreamOutput );
}
static int StreamOutput( ident, args, buf )
int ident ;
int args ;
DataStruct *buf ;
{
assert( args == 2 );
ident = FunctionName( "print" );
assert( ident > 0 );
CallFunction( ident, 1, buf+1 );
StackPush( &buf[0] );
return RETURN_RETURN ;
}