From: cas Date: Fri, 22 Oct 1999 18:05:40 +0000 (+0000) Subject: Initial revision X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=272196d996c532d35270089ef4e47415f05e0a15;p=occt-wok.git Initial revision --- diff --git a/src/WOKTCL/FILES b/src/WOKTCL/FILES new file mode 100755 index 0000000..37ee7bb --- /dev/null +++ b/src/WOKTCL/FILES @@ -0,0 +1,7 @@ +WOKTCL_CMPLRS.edl +WOKTCL_DefaultCommand.cxx +WOKTCL_DefaultCommand.hxx +WOKTCL_TriggerHandler.cxx +WOKTCL_TriggerHandler.hxx + + diff --git a/src/WOKTCL/WOKTCL.cdl b/src/WOKTCL/WOKTCL.cdl new file mode 100755 index 0000000..d8e6cb6 --- /dev/null +++ b/src/WOKTCL/WOKTCL.cdl @@ -0,0 +1,25 @@ +-- File: WOKTCL.cdl +-- Created: Fri Aug 11 11:33:51 1995 +-- Author: Jean GAUTIER +-- +---Copyright: Matra Datavision 1995 + + +package WOKTCL + + ---Purpose: + +uses + + WOKTclTools, + WOKTools, + WOKAPI + +is + + class Interpretor; + + ---class LocatorTable + --- instantiates HandleTable from WOKTclTools ( Locator from WOKAPI ); + +end WOKTCL; diff --git a/src/WOKTCL/WOKTCL_CMPLRS.edl b/src/WOKTCL/WOKTCL_CMPLRS.edl new file mode 100755 index 0000000..85c3276 --- /dev/null +++ b/src/WOKTCL/WOKTCL_CMPLRS.edl @@ -0,0 +1,21 @@ +-- File: WOKTCL_CMPLRS.edl +-- Author: Stagiaire Pascal BABIN +-- History: Tue Jul 9 13:44:05 1996 Stagiaire Pascal BABIN Creation +-- Copyright: Matra Datavision 1996 + +@ifnotdefined ( %WOKTCL_CMPLRS_EDL) then +@set %WOKTCL_CMPLRS_EDL = ""; + +@if ( (%Station != "wnt") && (%Station != "hp") ) then + @string %CMPLRS_CXX_Options = " -I/usr/tcltk/include -I/usr/tcltk/include/itcl -I/usr/include " %CMPLRS_CXX_Options ; +@endif; + +@if ( %Station == "hp" ) then + @string %CMPLRS_CXX_Options = " -I/usr/tcltk/include -I/usr/tcltk/include/itcl " %CMPLRS_CXX_Options ; +@endif; + +@if ( %Station == "wnt" ) then + @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -ID:/DevTools/TclTk/include "; +@endif; + +@endif; diff --git a/src/WOKTCL/WOKTCL_DefaultCommand.cxx b/src/WOKTCL/WOKTCL_DefaultCommand.cxx new file mode 100755 index 0000000..564372e --- /dev/null +++ b/src/WOKTCL/WOKTCL_DefaultCommand.cxx @@ -0,0 +1,123 @@ +// File: WOKTCL_DefaultCommand.cxx +// Created: Mon Oct 28 17:29:44 1996 +// Author: Jean GAUTIER +// + + + +#ifdef WNT +# ifdef TCL_VERSION_75 +# pragma comment( lib, "tcl75.lib" ) +# pragma message( "Information: tcl75.lib is using as TCL library" ) +# include +# elif defined( TCL_VERSION_76 ) +# pragma comment( lib, "tcl76.lib" ) +# pragma message( "Information: tcl76.lib is using as TCL library" ) +# else +# pragma comment( lib, "tcl76i.lib" ) +# pragma message( "Information: tcl76i.lib is using as TCL library" ) +# endif // TCL75 +#endif // WNT + +#include + +#include + +#include + +#include + +#include +#include +#include +#include + +#ifdef WNT +#include +#define WOKUtils_ProcessManager WOKUtils_ShellManager +#else +#include +#endif // WNT + +#include +#include + +#include + +#include + + +#ifndef WOK_SESSION_KEEP +#define WOK_SESSION_KEEP 1 +#endif + +extern Standard_IMPORT Handle(WOKTclTools_Interpretor) CurrentInterp; + +Standard_Integer DefaultCommand(ClientData clientData, Tcl_Interp *, + Standard_Integer argc, char* argv[]) +{ + Standard_Integer status; + + CData* C = (CData*) clientData; + + // set de l'interprete en cours + CurrentInterp = C->i; + + WOKAPI_APICommand acmd = C->f; + +#ifndef WOK_SESSION_KEEP + WOKAPI_Session* asess = (WOKAPI_Session *) &(C->i->Session()); + asess->Open(); +#endif + + try { + + WOKTools_Return returns; + + WOKUtils_ProcessManager::Arm(); + + // appel de la fonction API + if(!(*acmd)(C->i->Session(), argc, argv, returns)) + { + if(!C->i->TreatReturn(returns)) + { + WOKUtils_ProcessManager::UnArm(); + status = TCL_OK; + } + } + else + { + WOKUtils_ProcessManager::UnArm(); + status = TCL_ERROR; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) E = Standard_Failure::Caught(); + + strstream astream; + astream << E << ends; + + ErrorMsg << argv[0] << "Exception was raised : " << astream.str() << endm; + + WOKAPI_Session* asess = (WOKAPI_Session *) &(C->i->Session()); + asess->GeneralFailure(E); + + WOKUtils_ProcessManager::UnArm(); + + status = TCL_ERROR; + } + +#ifndef WOK_SESSION_KEEP + asess->Close(); +#endif + + return status; +} + +void DefaultCommandDelete (ClientData clientData) +{ + CData *C = (CData*) clientData; + delete C; +} + + diff --git a/src/WOKTCL/WOKTCL_DefaultCommand.hxx b/src/WOKTCL/WOKTCL_DefaultCommand.hxx new file mode 100755 index 0000000..1225a07 --- /dev/null +++ b/src/WOKTCL/WOKTCL_DefaultCommand.hxx @@ -0,0 +1,23 @@ +// File: WOKTCL_DefaultCommand.hxx +// Created: Mon Oct 28 17:28:26 1996 +// Author: Jean GAUTIER +// + + +#ifndef WOKTCL_DefaultCommand_HeaderFile +#define WOKTCL_DefaultCommand_HeaderFile + + +struct CData { + CData(WOKAPI_APICommand ff, Handle(WOKTCL_Interpretor) ii) : f(ff), i(ii) {} + WOKAPI_APICommand f; + Handle(WOKTCL_Interpretor) i; +}; + + +Standard_Integer DefaultCommand(ClientData , Tcl_Interp *, + Standard_Integer , char* []); + +void DefaultCommandDelete (ClientData ); + +#endif diff --git a/src/WOKTCL/WOKTCL_Interpretor.cdl b/src/WOKTCL/WOKTCL_Interpretor.cdl new file mode 100755 index 0000000..5d36107 --- /dev/null +++ b/src/WOKTCL/WOKTCL_Interpretor.cdl @@ -0,0 +1,41 @@ +-- File: WOKTCL_Interpretor.cdl +-- Created: Mon Apr 1 12:48:53 1996 +-- Author: Jean GAUTIER +-- +---Copyright: Matra Datavision 1996 + +class Interpretor from WOKTCL +inherits Interpretor from WOKTclTools + + ---Purpose: + +uses + Return from WOKTools, + PInterp from WOKTclTools, + Session from WOKAPI, + APICommand from WOKAPI + +is + + Create returns Interpretor from WOKTCL; + Create(anInterp : PInterp from WOKTclTools) returns Interpretor from WOKTCL; + + Add(me : mutable; Command : CString; + Help : CString; + Function : APICommand from WOKAPI; + Group : CString = "WOK Command"); + + Session(me) + ---C++: return const & + returns Session from WOKAPI; + + ChangeSession(me:mutable) + ---C++: return & + returns Session from WOKAPI; + + +fields + + mysession : Session from WOKAPI; + +end Interpretor; diff --git a/src/WOKTCL/WOKTCL_Interpretor.cxx b/src/WOKTCL/WOKTCL_Interpretor.cxx new file mode 100755 index 0000000..cfd1213 --- /dev/null +++ b/src/WOKTCL/WOKTCL_Interpretor.cxx @@ -0,0 +1,91 @@ +// File: WOKTCL_Interpretor.cxx +// Created: Mon Apr 1 19:26:43 1996 +// Author: Jean GAUTIER +// + +#if defined( WNT ) && defined( TCL_VERSION_75 ) +# include +#endif // WNT + +#include +#include + +#include +#include +#include +#include + +#ifdef WNT +#include +#define WOKUtils_ProcessManager WOKUtils_ShellManager +#else +#include +#endif // WNT + +#include + +#include + + +#include + + +#include + +extern Standard_IMPORT Handle(WOKTclTools_Interpretor) CurrentInterp; + +//======================================================================= +//function : WOKTCL_Interpretor +//purpose : +//======================================================================= +WOKTCL_Interpretor::WOKTCL_Interpretor() +{ +} +//======================================================================= +//function : WOKTCL_Interpretor +//purpose : +//======================================================================= +WOKTCL_Interpretor::WOKTCL_Interpretor(const WOKTclTools_PInterp& p) +: WOKTclTools_Interpretor(p) +{ +} + +//======================================================================= +//function : Add +//purpose : +//======================================================================= +void WOKTCL_Interpretor::Add(const Standard_CString Command, + const Standard_CString Help, + const WOKAPI_APICommand& Function, + const Standard_CString Group) +{ + CData* C = new CData(Function,this); + + Tcl_CreateCommand(Interp(), Command, DefaultCommand, (ClientData) C, DefaultCommandDelete); + + // add the help + Tcl_SetVar2(Interp(),"WOKTCL_Helps", Command,Help,TCL_GLOBAL_ONLY); + Tcl_SetVar2(Interp(),"WOKTCL_Groups",Group,Command, + TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); +} + + + +//======================================================================= +//function : Session +//purpose : +//======================================================================= +const WOKAPI_Session& WOKTCL_Interpretor::Session() const +{ + return mysession; +} + +//======================================================================= +//function : Session +//purpose : +//======================================================================= +WOKAPI_Session& WOKTCL_Interpretor::ChangeSession() +{ + return mysession; +} + diff --git a/src/WOKTCL/WOKTCL_TriggerHandler.cxx b/src/WOKTCL/WOKTCL_TriggerHandler.cxx new file mode 100755 index 0000000..a6278e3 --- /dev/null +++ b/src/WOKTCL/WOKTCL_TriggerHandler.cxx @@ -0,0 +1,168 @@ +// File: WOKTCL_TriggerHandler.cxx +// Created: Thu Nov 14 17:19:45 1996 +// Author: Jean GAUTIER +// + + + +#include +#include +#include +#include +#include + + + +#include + +#if defined( WNT ) && defined( TCL_VERSION_75 ) +# include +#endif // WNT + +#include + +extern Standard_IMPORT Handle(WOKTclTools_Interpretor) CurrentInterp; + +Standard_EXPORT WOKUtils_TriggerStatus WOKTCL_TriggerHandler(WOKUtils_Trigger &atrigger) +{ + Standard_Integer i; + + const WOKTools_Return& args = atrigger.Args(); + + for(i = 1; i <= args.Length() ; i++) + { + Handle(WOKTools_ReturnValue) avalue = args.Value(i); + + switch(avalue->Type()) + { + case WOKTools_InterpFile: + { + Handle(WOKTools_InterpFileValue) afile = Handle(WOKTools_InterpFileValue)::DownCast(avalue); + + if(afile->InterpType() == WOKTools_TclInterp) + { + WOK_TRACE { + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" + << "LoadFile : " << afile->File() << endm; + } + CurrentInterp->EvalFile(afile->File()->ToCString()); + } + } + break; + default: + break; + } + } + + if(!atrigger.Name().IsNull()) + { + if(CurrentInterp->IsCmdName(atrigger.Name()->ToCString())) + { + Handle(TCollection_HAsciiString) acmd = new TCollection_HAsciiString(atrigger.Name()); + + WOK_TRACE { + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" << "Handler called for trigger : " << atrigger.Name() << endm; + + // Prise en compte des resultats + const WOKTools_Return& args = atrigger.Args(); + + for(i = 1; i <= args.Length() ; i++) + { + Handle(WOKTools_ReturnValue) avalue = args.Value(i); + + switch(avalue->Type()) + { + case WOKTools_String: + { + Handle(WOKTools_StringValue) astrval = Handle(WOKTools_StringValue)::DownCast(avalue); + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" << "Arg " << i << " is : " << astrval->Value() << endm; + } + break; + default: + break; + } + } + } + + for(i = 1; i <= args.Length() ; i++) + { + Handle(WOKTools_ReturnValue) avalue = args.Value(i); + + switch(avalue->Type()) + { + case WOKTools_String: + { + Handle(WOKTools_StringValue) astrval = Handle(WOKTools_StringValue)::DownCast(avalue); + acmd->AssignCat(" \""); + acmd->AssignCat(astrval->Value()); + acmd->AssignCat("\""); + } + break; + default: + break; + } + } + + WOK_TRACE { + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" + << "Command is : " << acmd << endm; + } + if(CurrentInterp->Eval(acmd->ToCString())) + return WOKUtils_Failed; + else + { + CurrentInterp->GetReturnValues(atrigger.ChangeReturn()); + WOK_TRACE { + if(VerboseMsg("WOK_TRIGGER").IsSet()) + { + Standard_Integer i; + VerboseMsg << "WOKTCL_TriggerHandler" + << "Command returns : " << endm; + + const WOKTools_Return& rets = atrigger.Return(); + + for(i=1; i<=rets.Length(); i++) + { + Handle(WOKTools_ReturnValue) aval = rets.Value(i); + + VerboseMsg << "WOKTCL_TriggerHandler" + << " "; + + switch(aval->Type()) + { + case WOKTools_String: + { + Handle(WOKTools_StringValue) astrval = Handle(WOKTools_StringValue)::DownCast(aval); + VerboseMsg << "WOKTCL_TriggerHandler" + << " " << i << " : " << astrval->Value() << endm; + } + break; + default: + break; + } + } + } + } + } + return WOKUtils_Succeeded; + } + else + { +#ifdef WOK_VERBOSE + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" + << "Trigger : " << atrigger.Name() << " not setted" << endm; +#endif + return WOKUtils_NotSetted; + } + } + else + { +#ifdef WOK_VERBOSE + VerboseMsg("WOK_TRIGGER") << "WOKTCL_TriggerHandler" + << "No Trigger Name" << endm; +#endif + return WOKUtils_NotSetted; + } +} + + diff --git a/src/WOKTCL/WOKTCL_TriggerHandler.hxx b/src/WOKTCL/WOKTCL_TriggerHandler.hxx new file mode 100755 index 0000000..f11e7ac --- /dev/null +++ b/src/WOKTCL/WOKTCL_TriggerHandler.hxx @@ -0,0 +1,17 @@ +// File: WOKTCL_TriggerHandler.hxx +// Created: Wed Nov 20 16:17:39 1996 +// Author: Jean GAUTIER +// + + +#ifndef WOKTCL_TriggerHandler_HeaderFile +#define WOKTCL_TriggerHandler_HeaderFile + + +class WOKUtils_Trigger; + +#include + +WOKUtils_TriggerStatus WOKTCL_TriggerHandler(WOKUtils_Trigger &atrigger); + +#endif