1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

14
src/StepFile/FILES Executable file
View File

@@ -0,0 +1,14 @@
StepFile_CallFailure.cxx
StepFile_CallFailure.hxx
StepFile_Read.cxx
stepread.c
StepFile_Read.hxx
StepFile_Transfer.hxx
step.lex
recfile.pc
recfile.ph
stepread.ph
StepFile_WOKSteps.edl
step.yacc
StepFile_CODEGEN.edl
StepFile_CMPLRS.edl

View File

@@ -0,0 +1,15 @@
-- File: StepFile_CMPLRS.edl
-- Author: admin of IED Factory
-- History: Wed Sep 13 18:37:16 2000 admin of IED Factory Creation
-- Copyright: Matra Datavision 2000
@ifnotdefined ( %StepFile_CMPLRS_EDL) then
@set %StepFile_CMPLRS_EDL = "";
--- Insert your stuff Here
@if ( %Station == "hp" ) then
@string %CMPLRS_C_Options += " -Aa "; -- usage of ANSI mode
@endif;
@endif;

View File

@@ -0,0 +1,34 @@
-- File: StepFile_CODEGEN.edl
-- Author: data exchange team
-- History: Tue Feb 29 16:31:08 2000 data exchange team Creation
-- Copyright: Matra Datavision 2000
@ifnotdefined ( %StepFile_CODEGEN_EDL) then
@set %StepFile_CODEGEN_EDL = "";
--- Insert your stuff Here
@if ( %Station != "wnt" ) then
@template CODEGEN_LEX_OptLine (%CODEGEN_FlexBisHome) is
$%CODEGEN_FlexBisHome/flex -P<Module> -L -8 <LexFile>
@end;
@template CODEGEN_LEX_CmdLine ( %CODEGEN_FlexBisHome, %Source, %BaseName, %OutputDir ) is
$cd %OutputDir
$%CODEGEN_FlexBisHome/flex -P%BaseName -L -8 %Source
@end;
@else
@template CODEGEN_LEX_OptLine (%CODEGEN_LEX_CmdPath) is
$%CODEGEN_LEX_CmdPath -P <Module> -L -8 <LexFile>
@end;
@set %CODEGEN_LEX_CmdPath = "%WOKHOME%/lib/wnt/flex";
@template CODEGEN_LEX_CmdLine ( %CODEGEN_LEX_CmdPath, %Source, %BaseName, %OutputDir ) is
$cd %OutputDir;
$%CODEGEN_LEX_CmdPath -P%BaseName -L -8 %Source
@end;
@endif;
@endif;

View File

@@ -0,0 +1,12 @@
// File: StepFile_CallFailure.cxx
// Created: Tue Feb 05 17:46:31 2002
// Author: Sergey KUUL
// <skl@polox>
#include <Standard_Failure.hxx>
#include <StepFile_CallFailure.hxx>
void StepFile_CallFailure(char * const message)
{
Standard_Failure::Raise(message);
}

View File

@@ -0,0 +1,4 @@
#ifdef __cplusplus
extern "C"
#endif
void StepFile_CallFailure(char * const message);

216
src/StepFile/StepFile_Read.cxx Executable file
View File

@@ -0,0 +1,216 @@
// File: StepFile_Read.cxx
// Created: Fri Aug 30 11:31:31 1991
// Author: Christian CAILLET
// <cky@phobox>
// StepFile_Read
// routine assurant l enchainement des operations de lecture d un fichier
// STEP dans un StepModel, en fonction d une cle de reconnaissance
// Retour de la fonction :
// 0 si OK (le StepModel a ete charge)
// -1 si abandon car fichier pas pu etre ouvert
// 1 si erreur en cours de lecture
// Compilation conditionnelle : concerne les mesures de performances
#include <stdio.h>
#include "recfile.ph"
#include "stepread.ph"
extern "C" void recfile_modeprint (int mode); // controle trace recfile
// recfile_modeprint est declare a part
#include <Interface_ParamType.hxx>
#include <Interface_Protocol.hxx>
#include <Interface_Check.hxx>
#include <StepData_Protocol.hxx>
#include <StepData_StepReaderData.hxx>
#include <StepData_StepReaderTool.hxx>
#include <StepFile_Read.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Interface_InterfaceError.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#define CHRONOMESURE
#ifdef CHRONOMESURE
# include <OSD_Timer.hxx>
#endif
// ## ## ## ## ON SAURA AU MOINS TRAITER UndefinedEntity ## ## ## ##
static Handle(Interface_Check) checkread = new Interface_Check;
static Standard_Integer modepr = 1;
void StepFile_ReadTrace (const Standard_Integer mode)
{
modepr = mode; // recfile_modeprint est rappele a chaque lecture de fichier
}
static Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata);
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
{
return StepFile_Read
(nomfic,stepmodel,
Handle(StepData_Protocol)::DownCast(Interface_Protocol::Active()),
recoheader,recodata);
}
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_Protocol)& protocol)
{
Handle(StepData_FileRecognizer) nulreco;
return StepFile_Read (nomfic,stepmodel,protocol,recoheader,nulreco);
}
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol)
{
Handle(StepData_FileRecognizer) nulreco;
return StepFile_Read (nomfic,stepmodel,protocol,nulreco,nulreco);
}
// ## ## ## ## ## ## Corps de la Routine ## ## ## ## ## ##
static Interface_ParamType LesTypes[10]; // passage types (recstep/Interface)
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
{
Handle(Message_Messenger) sout = Message::DefaultMessenger();
char *ficnom = nomfic ; // because const (non reconnu par C)
checkread->Clear();
recfile_modeprint ( (modepr > 0 ? modepr-1 : 0) );
FILE* newin = stepread_setinput(ficnom);
if (!newin) return -1;
#ifdef CHRONOMESURE
Standard_Integer n ;
OSD_Timer c ;
c.Reset () ;
c.Start();
sout << " ... Step File Reading : " << ficnom << "" << endl;
#endif
try {
OCC_CATCH_SIGNALS
if (stepread () != 0) { lir_file_fin(3); stepread_endinput (newin,ficnom); return 1; }
}
catch (Standard_Failure) {
sout << " ... Exception Raised while reading Step File : " << ficnom << ":\n" << endl;
sout << Standard_Failure::Caught()->GetMessageString();
sout << " ..." << endl;
lir_file_fin(3);
stepread_endinput (newin,ficnom);
return 1;
}
// Continue reading of file despite of possible fails
//if (checkread->HasFailed()) { lir_file_fin(3); stepread_endinput (newin,ficnom); return 1; }
#ifdef CHRONOMESURE
sout << " ... STEP File Read ... " << endl;
c.Show();
#endif
// Creation du StepReaderData
LesTypes[rec_argNondef] = Interface_ParamVoid ;
LesTypes[rec_argSub] = Interface_ParamSub ;
LesTypes[rec_argIdent] = Interface_ParamIdent ;
LesTypes[rec_argInteger] = Interface_ParamInteger ;
LesTypes[rec_argFloat] = Interface_ParamReal ;
LesTypes[rec_argEnum] = Interface_ParamEnum ;
LesTypes[rec_argBinary] = Interface_ParamBinary ;
LesTypes[rec_argText] = Interface_ParamText ;
LesTypes[rec_argHexa] = Interface_ParamHexa ;
LesTypes[rec_argMisc] = Interface_ParamMisc ;
Standard_Integer nbhead, nbrec, nbpar;
lir_file_nbr (&nbhead,&nbrec,&nbpar); // renvoi par lex/yacc
Handle(StepData_StepReaderData) undirec =
new StepData_StepReaderData(nbhead,nbrec,nbpar); // creation tableau de records
for ( Standard_Integer nr = 1; nr <= nbrec; nr ++) {
int nbarg; char* ident; char* typrec ;
lir_file_rec (&ident, &typrec, &nbarg);
undirec->SetRecord (nr, ident, typrec, nbarg);
if (nbarg>0) {
int typa; char* val;
Interface_ParamType newtype;
while(lir_file_arg (&typa, &val) == 1) {
newtype = LesTypes[typa] ;
undirec->AddStepParam (nr, val, newtype);
}
}
undirec->InitParams(nr);
lir_file_finrec();
}
lir_file_fin(1);
// on a undirec pret pour la suite
#ifdef CHRONOMESURE
sout << " ... Step File loaded ... " << endl;
c.Show();
sout << " "<< undirec->NbRecords () <<
" records (entities,sub-lists,scopes), "<< nbpar << " parameters\n" << endl;
#endif
// Analyse : par StepReaderTool
StepData_StepReaderTool readtool (undirec,protocol);
readtool.SetErrorHandle (Standard_True);
readtool.PrepareHeader(recoheader); // Header. reco nul -> pour Protocol
readtool.Prepare(recodata); // Data. reco nul -> pour Protocol
#ifdef CHRONOMESURE
sout << " ... Parameters prepared ... ";
c.Show();
#endif
readtool.LoadModel(stepmodel);
if (stepmodel->Protocol().IsNull()) stepmodel->SetProtocol (protocol);
lir_file_fin(2);
#ifdef CHRONOMESURE
sout << " ... Objets analysed ... " << endl;
c.Show();
n = stepmodel->NbEntities() ;
sout << " STEP Loading done : " << n << " Entities" << endl;
#endif
stepread_endinput (newin,ficnom); return 0 ;
}
void StepFile_Interrupt (char* mess)
{
Handle(Message_Messenger) sout = Message::DefaultMessenger();
sout << " **** StepFile Error : " << mess << " ****" << endl;
checkread->AddFail(mess);
}

45
src/StepFile/StepFile_Read.hxx Executable file
View File

@@ -0,0 +1,45 @@
// File: StepFile_Read.hxx
// Created: Fri Aug 30 11:31:31 1991
// Author: Christian CAILLET
// <cky@phobox>
// StepFile_Read.hxx
// routine assurant l'enchainement des operations de lecture d'un fichier
// STEP dans un StepModel, en fonction d'une cle de reconnaissance
// Retour de la fonction :
// 0 si OK (le StepModel a ete charge)
// -1 si abandon car fichier pas pu etre ouvert
// 1 si erreur en cours de lecture
#ifndef StepFile_Read_HeaderFile
#define StepFile_Read_HeaderFile
//# include <stepread.h> : sauf recfile_modeprint, declare ici
# include <StepData_StepModel.hxx>
# include <StepData_FileRecognizer.hxx>
# include <StepData_Protocol.hxx>
Standard_EXPORT void StepFile_ReadTrace (const Standard_Integer mode);
// Modal : 0 pas de trace, 1 trace LoadModel, 2 & 3 + trace interne lex-yac
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader, // Reconnait le Header
const Handle(StepData_FileRecognizer)& recodata); // Entites du Data
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader, // Reconnait le Header
const Handle(StepData_Protocol)& protocol); // Entites du Data
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol); // Header & Data
#endif

View File

@@ -0,0 +1,13 @@
// General Purpose Include file
// provides all required Include directives to Load and Transfer (to Cas.Cade)
// the content of a Step File
#include <StepFile_Read.hxx>
#include <StepData_StepModel.hxx>
#include <Transfer_TransferOutput.hxx>
//#include <Transfer_PersistentProcess.hxx>
//#include <Transfer_IteratorOfPersistentProcess.hxx>
#include <Transfer_Binder.hxx>
// and, to allow easy DownCasting :
#include <Interface_Macros.hxx>

View File

@@ -0,0 +1,6 @@
@set %WOKSteps_UseSourceInclude = "yes";

595
src/StepFile/recfile.pc Executable file
View File

@@ -0,0 +1,595 @@
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#if defined(HAVE_MALLOC_H)
#include "malloc.h"
#endif
#include "recfile.ph"
/* enregistrement d'un fichier d'interface sous forme de records
gere les scopes
Ce fichier comprend 3 parties
- les routines traitant les char*, avec la notion de texte courant
- les declarations des donnees de travail proprement dites pour le fichier
- le corps des programmes d'enregistrement
*/
/* ROUTINES UTILITAIRES de traitement des textes (char*) */
/* Gestion du texte courant : c'est un texte alloue dynamiquement
rec_restext en alloue un (jete le precedent alloue si pas lu)
rec_gettext lit le texte en cours, qui ne sera pas desalloue ensuite
rec_settext en force un autre en jetant le precedent (idem rec_newtext)
tandis que rec_newtext alloue un texte, sans lien avec le courant
*/
#define Maxcar 50000
static struct carpage {
struct carpage* next; /* chainage des pages de caracteres */
int used; /* place deja prise */
char cars[Maxcar+1]; /* page de caracteres */
} *onecarpage;
static char* restext = NULL ; /* texte courant (allocation dynamique) */
/* static int resalloc = 0 ;*/ /* alloue (memoire a liberer) ou non */
static char txt_cart_p[] = "CARTESIAN_POINT";
void rec_restext(newtext,lentext) /* destine a etre appele de l'exterieur */
char* newtext; int lentext;
{
char *res, *text;
if(strcmp(newtext,txt_cart_p)==0) {
restext = txt_cart_p;
return;
}
if (onecarpage->used > Maxcar-lentext-1) { /* allouer nouvelle page */
struct carpage *newpage;
int sizepage = sizeof(struct carpage);
if (lentext >= Maxcar) sizepage += (lentext+1 - Maxcar);
newpage = (struct carpage*) malloc (sizepage);
newpage->next = onecarpage;
onecarpage = newpage;
onecarpage->used = 0;
}
restext = onecarpage->cars + onecarpage->used;
onecarpage->used += (lentext + 1);
/* strcpy */
res = restext ; text = newtext;
while (*text != '\0') { *res=*text ; res++ ; text++ ; }
*res = '\0' ;
}
void rec_gettext(r)
char* *r ;
{ *r = restext; }
/* Le resultat retourne (pointeur) est destine a etre inclus dans un struct */
void rec_settext(s)
char* s ; /* substituer le texte courant par un autre deja alloue */
{ restext = s ; }
char* rec_newtext(r)
/* routine utilitaire creant une chaine dynamique a partir d'un char[] */
char* r ;
{
char* savrestext; char* s0;
savrestext = restext;
rec_restext(r,strlen(r)); s0 = restext;
restext = savrestext;
return (s0);
}
static int modeprint = 0 ; /* CONTROLE D'IMPRESSION (pour appel depuis yacc)*/
/* DECLARATIONS des donnees de travail (en cours d'enregistrement) */
static int typarg ; /* type du dernier argument lu */
static int nbrec = 0; /* nombre total d'enregistrements de donnees */
static int nbhead = 0; /* nb de records pris par le Header */
static int nbpar = 0; /* nb de parametres lus au total */
static int yarec = 0; /* presence Record deja cree (1 apres Ident) */
static struct rec { /* DESCRIPTION D'UN RECORD */
char* ident ; /* identifieur du record (en #12345...) ou scope-end */
char* type ; /* type du record (peut etre sublist) */
/* int nbarg ; nombre de parametres (arguments) du record, not used */
struct unarg* first ; /* 1er argument */
/* struct unarg* last ;dernier argument, not used */
struct rec* next ; /* record suivant */
} *currec ; /* currec meme : record courant */
#define Maxrec 5000
static struct recpage {
struct recpage* next;
int used;
struct rec args[Maxrec+1];
} *onerecpage;
static struct rec* firstrec ; /* 1er record du fichier */
static struct rec* lastrec ; /* dernier record du fichier */
static char* curtype; /* type dernier record (ou = sublist) */
static char* subarg ; /* ident dernier record (sub-list eventuel) */
static int numsub ; /* numero de sous-liste en cours */
static struct unarg { /* DESCRIPTION D'UN ARGUMENT */
int type ; /* type de l'arg, dans une liste courte : entier, reel ... */
char* val ; /* valeur alphanum de l'arg */
struct unarg* next ; /* argument suivant dans la liste pour ce record */
} *curarg ;
#define Maxarg 10000
static struct argpage { /* Allocation optimisee des arguments */
struct argpage* next;
int used;
struct unarg args[Maxarg+1];
} *oneargpage;
static struct scope { /* DESCRIPTION D'UN SCOPE */
/* les scopes sont empilables sans limite */
struct scope* prev; /* scope precedent, auquel il faudra revenir */
struct rec* rec; /* record interrompu par le scope (a reprendre) */
} *curscope ; /* curscope est le scope en cours */
/* Constantes litterales */
static char txt_sublist[] = "/* (SUB) */" ;
static char txt_scope[] = "SCOPE" ;
static char txt_endscope[] = "ENDSCOPE" ;
static char txt_nil[] = " " ;
static char sub1[] = "$1" ; /* optimisation ... */
static char sub2[] = "$2" ;
static char argtype1[] = "(IF#TnEHBx"; /* types arguments (2 1es lettres) */
static char argtype2[] = ")nlIxdnxix";
static char idzero[] = "#0";
/* Trace pour controle */
void recfile_modeprint(mode)
int mode ;
{ modeprint = mode; }
static int lastno;
extern int steplineno;
extern int modcom;
extern int modend;
void rec_inityyll ()
{
steplineno = 0;
modcom = 0;
modend = 0;
lastno = -1;
}
/* INITIALISATION */
void rec_debfile()
{
/*initialization of recpage*/
onerecpage = (struct recpage*) malloc ( sizeof(struct recpage) );
onerecpage->used = 0; onerecpage->next = NULL;
onecarpage = (struct carpage*) malloc ( sizeof(struct carpage) );
onecarpage->used = 0; onecarpage->next = NULL; restext = NULL;
yarec = 0; nbhead = nbrec = nbpar = 0 ; firstrec = NULL ; lastrec = NULL ;
curtype = txt_sublist;
currec = NULL ; curarg = NULL ;
curscope = NULL ;
oneargpage = (struct argpage*) malloc ( sizeof(struct argpage) );
oneargpage->next = NULL; oneargpage->used = 0;
rec_inityyll();
}
/* INTERMEDIAIRE : passage de Header a Data */
void rec_finhead() { nbhead = nbrec; }
/* CONCLUSION : actuellement, ne fait rien */
void rec_finfile() { }
/* GESTION DES RECORDS */
/* ENREGISTRER UN RECORD (deja pret) */
void static rec_new(newrec)
struct rec* newrec ; /* nouveau record a enregistrer */
{
nbrec ++ ;
if ( firstrec == NULL ) firstrec = newrec ;
if ( lastrec != NULL ) lastrec->next = newrec ;
lastrec = newrec ;
}
/* type du dernier argument lu */
void rec_typarg(argtype)
int argtype ;
{ typarg = argtype; }
/* ENREGISTRER UNE ENTITE (record courant) */
void rec_newent()
{
rec_new(currec) ; /* le record courant (currec) est enregistre */
/* gestion des sous-listes : si currec a un suivant note (cf pointeur suite),
alors c'est une sous-liste et le suivant est son contenant
EN CE CAS, il faut memoriser cette sous-liste en argument courant
En effet, d'une part la liste est reconnue comme un argument, d'autre part
part elle se termine par ")" : c'est donc ici qu'elle sera enregistree */
rec_typarg (rec_argSub) ;
subarg = currec->ident ; /* si sous-liste, sera argument du contenant */
/* rec_check(1) ; */
currec = currec->next ; /* si nul, c'est qu'une autre entite suit */
lastrec->next = NULL ;
}
static struct rec*rec_newrec()
{
struct rec* newrec;
if (onerecpage->used >= Maxrec) {
struct recpage* newrecpage;
newrecpage = (struct recpage*) malloc ( sizeof (struct recpage) );
newrecpage->next = onerecpage;
onerecpage = newrecpage;
onerecpage->used = 0;
}
newrec = &(onerecpage->args[onerecpage->used]);
onerecpage->used++;
return newrec;
}
/* RECORD COURANT : */
/* creer et preciser l'identifieur */
void rec_ident()
{
currec = rec_newrec();
/*currec = (struct rec*) malloc (sizeof (struct rec)) ;*/
/*currec->nbarg = 0 ;*/
rec_gettext(&(currec->ident)) ;
currec->next = NULL ; currec->first = NULL ; /*currec->last = NULL ;*/
yarec = 1;
}
/* preciser le type ; demarrage de la description de l'entite */
void rec_type()
{
/* Pour le header : pas d'ident, donc en simuler un : derive de rec_ident */
if (!yarec) {
/*currec = (struct rec*) malloc (sizeof (struct rec)) ;*/
currec = rec_newrec();
/*currec->nbarg = 0 ;*/
currec->ident = idzero; /* Ident bidon (il en faut un ...) */
currec->next = NULL ; currec->first = NULL ; /*currec->last = NULL ;*/
}
rec_gettext(&(currec->type)) ;
yarec = numsub = 0 ; /* debut de l'entite */
}
/* type d une liste qui n est pas une entite mais un argument
par defaut (cf rec_deblist) il n est pas defini donc mis = "/ (SUB) /" */
void rec_listype()
{ rec_gettext(&(curtype)); }
/* ajouter un argument (type & valeur deja connus) */
void rec_newarg()
{
struct unarg *newarg;
nbpar ++;
/*currec->nbarg ++ ;*/
/* newarg = (struct unarg*) malloc (sizeof (struct unarg)) ; */
if (oneargpage->used >= Maxarg) {
struct argpage* newargpage;
newargpage = (struct argpage*) malloc ( sizeof(struct argpage) );
newargpage->next = oneargpage;
oneargpage = newargpage;
oneargpage->used = 0;
}
newarg = &(oneargpage->args[oneargpage->used]);
oneargpage->used ++;
newarg->type = typarg ;
if (typarg == rec_argSub) newarg->val = subarg ;
else rec_gettext (&(newarg->val));
/* if (currec->first == NULL) currec->first = newarg;
else currec->last->next = newarg;
currec->last = newarg;*/
if (currec->first == NULL) currec->first = newarg;
else {
struct unarg* nextarg = currec->first;
while(nextarg->next != NULL)
nextarg = nextarg->next;
nextarg->next = newarg;
}
newarg->next = NULL ;
/* rec_check(0) ; */
}
/* Ajouter une sous-liste
Une ouverture de parentheses A L'INTERIEUR d'une liste de parametres
signale une sous-liste : c'est une entite non identifiee, directement
utilisee comme argument de la liste contenante) d'un type reserve(SUB)
Elle est enregistree avec un identifieur special : '$' suivi d'un numero
de sous-liste dans l'entite en cours.
Son enregistrement consiste a definir un nouveau record courant, pour la
sous-liste, qui note comme suivant l'ancien courant, qui est son contenant
A la fin de la sous-liste, elle est enregistree comme toute entite (cf
rec_new) mais le suivant devient le nouveau courant dont l'enregistrement
des parametres continue
La premiere ouverture de parentheses dans l'entite est celle de la liste
principale de parametres et non d'une sous-liste
*/
void rec_deblist()
{
if (numsub > 0) { /* enregistrement d'une sous-liste */
/* int i ; */ struct rec* subrec ;
/* creation du nouvel enregistrement et chainage au precedent */
subrec = rec_newrec();
/*subrec = (struct rec*) malloc (sizeof (struct rec)) ;*/
switch (numsub) {
case 1: subrec->ident = sub1; break;
case 2: subrec->ident = sub2; break;
default: {
char bufsub[10];
if (numsub > 9) sprintf (bufsub,"$%d",numsub) ;
else { bufsub[0] = '$'; bufsub[1] = numsub + 48; bufsub[2] = '\0'; }
subrec->ident = rec_newtext(bufsub) ;
}
}
subrec->type = curtype ;
curtype = txt_sublist; /* type reserve par defaut */
/*subrec->nbarg = 0 ;*/ subrec->next = currec ;
subrec->first = NULL ; /*subrec->last = NULL ;*/
/* les arguments de la sous-liste vont suivre ;
elle meme est argument de son contenant, ce qui est pris en compte
a la fermeture de la parenthese */
currec = subrec ; /* substitution finale */
}
numsub ++ ; /* numero de la prochaine sous-liste (la principale est en 0) */
/* rec_check(0) ; */
}
/* Affichage du contenu d'un record */
void rec_print(unrec)
struct rec* unrec ;
{
int numa = 0; int numl = 0; int argl = 0;
if (unrec == NULL) { printf ("Non defini\n") ; return; }
printf ("Ident : %s Type : %s Nb.Arg.s : %s\n",
unrec->ident,unrec->type, (unrec->first ? unrec->first->val : "")) ;
if (modeprint < 2) return ;
curarg = unrec->first ;
while (curarg != NULL) {
numa ++; argl = strlen(curarg->val) + 18; numl += argl;
if (numl > 132) { printf("\n"); numl = argl; }
printf (" - Arg.%d[%c%c] : %s",
numa,argtype1[curarg->type],argtype2[curarg->type],curarg->val);
curarg = curarg->next ;
}
if (argl > 0) printf("\n");
return ;
}
/* GESTION DES SCOPES */
/* Ouverture de scope :
un scope est un record particulier (pas de type ni d'argument)
d'une part il est enregistre, d'autre part il faut gerer le record en cours
En effet, une entite step etait en cours d'enregistrement (ident deja connu),
mais son type et ses arguments seront fournis apres fermeture du scope ...
Il faut donc la mettre de cote (c'est currec), pour la restaurer ensuite
Mais ATTENTION, il y a l'EXPORT : au ENDSCOPE, peut etre attachee une liste
d'Idents : ce sont les idents internes au SCOPE mais declares visibles de
l'exterieur du SCOPE (en plus de l''entite sur laquelle il porte)
*/
void scope_debut()
{
/* ouverture du scope et sauvegarde de l'entite en cours */
struct scope* newscope; struct rec* unscope;
newscope = (struct scope*) malloc (sizeof (struct scope)) ;
newscope->rec = currec ;
newscope->prev = curscope ;
curscope = newscope ;
/* enregistrement de ce scope comme un record */
unscope = rec_newrec();
/*unscope = (struct rec*) malloc (sizeof (struct rec)) ;*/
unscope->ident = txt_scope ;
unscope->type = txt_nil ;
unscope->first = NULL;
/*unscope->nbarg = 0 ;*/
rec_new(unscope) ;
}
/* Fermeture de scope :
La fin de scope est, comme son debut, un enregistrement special.
Il faut donc l'enregistrer.
Il faut aussi restaurer l'entite concernee par le scope, afin de terminer
son enregistrement (manquent ses arguments) */
void scope_fin()
{ struct scope* oldscope ; struct rec* unscope;
if (curscope == NULL) return ; /* cela dit, c'est anormal ... */
/* enregistrement de cette fin de scope comme un record */
unscope = rec_newrec();
/* unscope = (struct rec*) malloc (sizeof (struct rec)) ;*/
unscope->ident = txt_endscope ;
unscope->type = txt_nil ;
unscope->first = NULL;
/*unscope->nbarg = 0 ;*/
/* Si on doit prendre en compte une Export List ... */
if (subarg[0] == '$') {
if (modeprint > 0) {
printf("Export List : (List in Record n0 %d) -- ",nbrec);
rec_print(lastrec);
}
currec = unscope;
typarg = rec_argSub;
rec_newarg();
}
rec_new(unscope) ;
/* fermeture effective du scope */
currec = curscope->rec ; /* restaurer l'entite en cours d'enreg. */
yarec = 1;
oldscope = curscope ;
curscope = oldscope->prev ; /* restauration de l'etat precedent */
free (oldscope) ; /* suppression "physique" */
}
/* CONCLUSION : retour des valeurs pour constituer la liste des records,
sous forme de directory / tableau
La liberation de la memoire est faite par lir_file_fin, en une fois
*/
void lir_file_nbr(nbh,nbr,nbp)
int* nbh; int* nbr; int* nbp;
/* initialise le traitement et retourne la taille du directory et du header */
{
currec = firstrec ;
/* rec_check(0) ; */
*nbh = nbhead; *nbr = nbrec; *nbp = nbpar;
}
void lir_file_fin(mode)
int mode;
/* fin du traitement : regroupe les liberations de memoire en une phase */
/* mode = 1 : rec+arg. 2 : carpage; 3 : 1+2 */
{
if (mode & 1) {
while(onerecpage != NULL) {
struct recpage* newpage; newpage = onerecpage->next;
free(onerecpage);
onerecpage = newpage;
}
/* struct rec* oldrec;
oldrec = NULL;
currec = firstrec;
while (currec != NULL) {
oldrec = currec;
currec = currec->next;*/
/* liberation memoire pour type & ident : si scope-endscope rien a liberer
si sous-liste : type pas a liberer, ident partage aussi par l'argument sera
libere par lui ... donc ici aussi, rien a liberer. CQFD */
/* free (oldrec) ;
}*/
while (oneargpage != NULL) {
struct argpage* newpage; newpage = oneargpage->next;
free (oneargpage);
oneargpage = newpage;
}
}
if (mode & 2) {
while (onecarpage != NULL) {
struct carpage* newpage; newpage = onecarpage->next;
free (onecarpage);
onecarpage = newpage;
}
}
}
int lir_file_rec(ident,type,nbarg)
/* retourne les parametres du record courant
retour de fonction ; 1 si ok, 0 si liste epuisee */
char* *ident ; char* *type ; int *nbarg ;
{
if (currec == NULL) return (0) ;
/* rec_check(2) ; */
*ident = currec->ident ;
*type = currec->type ;
*nbarg = (currec->first != NULL);
curarg = currec->first ; /* prepare lecture arg.s */
return (1) ;
}
void lir_file_finrec()
/* fait le menage et passe au record suivant
ne pas appeler apres l'indication de fin mais apres chaque record ok ! */
{
currec = currec->next ;
/* rec_check(2) ; */
}
int lir_file_arg(type,val)
int* type ; char* *val ;
/* lit l'argument courant (au debut le 1er), fait le menage, prepare suivant
retourne 1 si ok, 0 si c'est fini
attention, suppose que nbarg > 0 ... (bref, pas de protection) */
{
if (curarg == NULL) return (0) ;
*type = curarg->type ;
*val = curarg->val ;
curarg = curarg->next ;
return (1) ;
}
/* Verification de l'integrite des donnees */
/* Affiche ce qui ne va pas, mais aussi accede a tout : ainsi, les adresses
verolees aparaissent au grand jour du dbx */
void rec_check(mode)
int mode ; /* =1 pas de controle nbrec (en cours d'enregistrement) */
{
struct rec* lerec ; struct unarg* larg ; int nr,na ;
lerec = firstrec ;
if (mode == 2) lerec = currec ;
nr = 0 ;
while (lerec != NULL) {
nr ++ ;
if (lerec->ident == NULL) printf("Record %d : ident null\n",nr) ;
if (lerec->type == NULL) printf("Record %d : type null\n",nr) ;
/*if (mode < 2 && (lerec->nbarg < 0 || lerec->nbarg > 10) ) printf
("N.B.: Record %d : nbarg pas entre 0 & 10, vaut %d\n",nr,lerec->nbarg);
*/
na = 0 ;
larg = lerec->first ;
while (larg != NULL) {
na ++ ;
if (larg->type < 0 || larg->type > 9) printf
("Record %d , Arg. %d : type incorrect : %d\n",nr,na,larg->type) ;
if (larg->val == NULL) printf("Record %d , Arg %d : val null\n",nr,na) ;
larg = larg->next ;
}
/*if (na != lerec->nbarg) printf
("Record %d : arglist pourrie, nb note %d relu %d\n",nr,lerec->nbarg,na) ;*/
lerec = lerec->next ;
}
if (mode == 0 && nr != nbrec) printf
("Liste des records pourrie, nb note %d relu %d\n",nbrec,nr) ;
}
void steperror (char *mess);
int steplex (void);

12
src/StepFile/recfile.ph Executable file
View File

@@ -0,0 +1,12 @@
/*Types d'arguments (parametres) d'entites STEP (sans entrer dans le detail) */
#define rec_argSub 0
#define rec_argInteger 1
#define rec_argFloat 2
#define rec_argIdent 3
#define rec_argText 4
#define rec_argNondef 5
#define rec_argEnum 6
#define rec_argHexa 7
#define rec_argBinary 8
#define rec_argMisc 9

68
src/StepFile/step.lex Executable file
View File

@@ -0,0 +1,68 @@
%{
#include "step.tab.h"
#include "recfile.ph"
#include "stdio.h"
#include <StepFile_CallFailure.hxx>
/* skl 31.01.2002 for OCC133(OCC96,97) - uncorrect
long string in files Henri.stp and 401.stp*/
#define YY_FATAL_ERROR(msg) StepFile_CallFailure( msg )
/* abv 07.06.02: force inclusion of stdlib.h on WNT to avoid warnings */
#include <stdlib.h>
/*
void steperror ( FILE *input_file );
void steprestart ( FILE *input_file );
*/
void rec_restext(char *newtext, int lentext);
void rec_typarg(int argtype);
int steplineno; /* Comptage de ligne (ben oui, fait tout faire) */
int modcom = 0; /* Commentaires type C */
int modend = 0; /* Flag for finishing of the STEP file */
void resultat () /* Resultat alloue dynamiquement, "jete" une fois lu */
{ if (modcom == 0) rec_restext(yytext,yyleng); }
%}
%%
" " {;}
" " {;}
[\n] { steplineno ++; }
[\r] {;} /* abv 30.06.00: for reading DOS files */
[\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
#[0-9]+/= { resultat(); if (modcom == 0) return(ENTITY); }
#[0-9]+/[ ]*= { resultat(); if (modcom == 0) return(ENTITY); }
#[0-9]+ { resultat(); if (modcom == 0) return(IDENT); }
[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argInteger); return(QUID); } }
[-+\.0-9][\.0-9]+ { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); if (modcom == 0) { rec_typarg(rec_argFloat); return(QUID); } }
[\']([\n]|[\000\011-\046\050-\176\201-\237\240-\777]|[\047][\047])*[\'] { resultat(); if (modcom == 0) { rec_typarg(rec_argText); return(QUID); } }
["][0-9A-F]+["] { resultat(); if (modcom == 0) { rec_typarg(rec_argHexa); return(QUID); } }
[.][A-Z0-9_]+[.] { resultat(); if (modcom == 0) { rec_typarg(rec_argEnum); return(QUID); } }
[(] { if (modcom == 0) return ('('); }
[)] { if (modcom == 0) return (')'); }
[,] { if (modcom == 0) return (','); }
[$] { resultat(); if (modcom == 0) { rec_typarg(rec_argNondef); return(QUID); } }
[=] { if (modcom == 0) return ('='); }
[;] { if (modcom == 0) return (';'); }
"/*" { modcom = 1; }
"*/" { if (modend == 0) modcom = 0; }
STEP; { if (modcom == 0) return(STEP); }
HEADER; { if (modcom == 0) return(HEADER); }
ENDSEC; { if (modcom == 0) return(ENDSEC); }
DATA; { if (modcom == 0) return(DATA); }
ENDSTEP; { if (modend == 0) {modcom = 0; return(ENDSTEP);} }
"ENDSTEP;".* { if (modend == 0) {modcom = 0; return(ENDSTEP);} }
END-ISO[0-9\-]*; { modcom = 1; modend = 1; return(ENDSTEP); }
ISO[0-9\-]*; { if (modend == 0) {modcom = 0; return(STEP); } }
[/] { if (modcom == 0) return ('/'); }
&SCOPE { if (modcom == 0) return(SCOPE); }
ENDSCOPE { if (modcom == 0) return(ENDSCOPE); }
[a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); }
![a-zA-Z0-9_]+ { resultat(); if (modcom == 0) return(TYPE); }
[^)] { resultat(); if (modcom == 0) { rec_typarg(rec_argMisc); return(QUID); } }

125
src/StepFile/step.yacc Executable file
View File

@@ -0,0 +1,125 @@
%token STEP HEADER ENDSEC DATA ENDSTEP SCOPE ENDSCOPE ENTITY TYPE INTEGER FLOAT IDENT TEXT NONDEF ENUM HEXA QUID
%start stepf
%{
#include "recfile.ph" /* definitions des types d'arguments */
#include "recfile.pc" /* la-dedans, tout y est */
/*
#define stepparse STEPparse
#define steplex STEPlex
#define stepwrap STEPwrap
#define steprestart STEPrestart
#define steplex STEPlex
#define steplval STEPlval
#define stepval STEPval
#define stepchar STEPchar
#define stepdebug STEPdebug
#define stepnerrs STEPnerrs
#define steperror STEPerror
*/
#define stepclearin yychar = -1
#define steperrok yyerrflag = 0
/*
#define stepin STEPin
#define yyerrflag STEPerrflag
#define yyerrstatus STEPerrflag
*/
/* ABV 19.12.00: merging porting modifications by POP (for WNT, AIX) */
#if defined(WNT) && !defined(MSDOS)
#define MSDOS WNT
#endif
#if defined(_AIX)
#include <malloc.h>
#define alloca malloc
#endif
%}
%%
/* N.B. : les commentaires sont filtres par LEX */
/* La fin vide (selon systeme emetteur) est filtree ici */
finvide : ' '
| finvide ' ' ;
finstep : ENDSTEP
| ENDSTEP finvide ;
stepf1 : STEP HEADER headl ENDSEC endhead model ENDSEC finstep ;
stepf2 : STEP HEADER ENDSEC endhead model ENDSEC ENDSTEP ;
stepf3 : STEP HEADER ENDSEC endhead model error ;
stepf : stepf1 | stepf2 | stepf3
{ rec_finfile(); return(0); /* fini pour celui-la */ }
;
headl : headent
| headl headent
;
headent : enttype listarg ';'
| error /* Erreur sur Entite : la sauter */
;
endhead : DATA
{ rec_finhead(); }
;
unarg : IDENT { rec_typarg(rec_argIdent); rec_newarg(); }
| QUID { /* deja fait par lex*/ rec_newarg(); }
| listarg /* rec_newent lors du ')' */ { rec_newarg(); }
| listype listarg /* liste typee */ { rec_newarg(); }
| error { rec_typarg(rec_argMisc); rec_newarg();
yyerrstatus = 1; yyclearin; }
/* Erreur sur Parametre : tacher de le noter sans jeter l'Entite */
;
listype : TYPE
{ rec_listype(); }
;
deblist : '('
{ rec_deblist(); }
;
finlist : ')'
{ if (modeprint > 0)
{ printf("Record no : %d -- ",nbrec+1); rec_print(currec); }
rec_newent (); yyerrstatus = 0; }
;
listarg : deblist finlist /* liste vide (peut y en avoir) */
| deblist arglist finlist /* liste normale, non vide */
| deblist error
;
arglist : unarg
| arglist ',' unarg
| arglist error
;
model : bloc
| model bloc
;
bloc : entlab '=' unent ';'
| entlab '=' debscop model finscop unent ';'
| entlab '=' debscop finscop unent ';'
| error /* Erreur sur Entite : la sauter */
;
plex : enttype listarg
| plex enttype listarg /* sert a ce qui suit : */
;
unent : enttype listarg /* Entite de Type Simple */
| '(' plex ')' /* Entite de Type Complexe */
;
debscop : SCOPE
{ scope_debut(); }
;
unid : IDENT
{ rec_typarg(rec_argIdent); rec_newarg(); }
;
export : unid
| export ',' unid
;
debexp : '/'
{ rec_deblist(); }
;
finscop : ENDSCOPE
{ scope_fin(); }
| ENDSCOPE debexp export '/'
{ printf("*** Warning : Export List not yet processed\n");
rec_newent(); scope_fin() ; }
/* La liste Export est prise comme ARGUMENT du EndScope */
;
entlab : ENTITY
{ rec_ident(); }
;
enttype : TYPE
{ rec_type (); }
;

100
src/StepFile/stepread.c Executable file
View File

@@ -0,0 +1,100 @@
/* pdn PRO16162: do restart in order to restore after possible crash or wrong data
rln 10.01.99 - transmission of define's into this file
*
*/
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include "recfile.ph"
/* StepFile_Error.c
Ce programme substitue au yyerror standard, qui fait "exit" (brutal !)
une action plus adaptee a un fonctionnement en process :
Affichage de la ligne qui a provoque l' erreur,
Preparation d'un eventuel appel suivant (vu qu on ne fait plus exit),
en pour le retour, on s'arrange pour lever une exception
(c-a-d qu on provoque un plantage)
Adaptation pour flex (flex autorise d avoir plusieurs lex dans un meme
executable) : les fonctions et variables sont renommees; et la
continuation a change
*/
static int lastno;
extern int steplineno;
extern void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
int stepparse(void);
void rec_debfile();
void steprestart(FILE *input_file);
void rec_finfile();
void steperror (char *mess)
{
char newmess[80];
if (steplineno == lastno) return;
lastno = steplineno;
sprintf (newmess,"At line %d, %s",steplineno+1,mess);
/* yysbuf[0] = '\0';
yysptr = yysbuf;
* yylineno = 0; */
StepFile_Interrupt(newmess);
}
/* But de ce mini-programme : appeler yyparse et si besoin preciser un
fichier d'entree
StepFile_Error redefinit yyerror pour ne pas stopper (s'y reporter)
*/
extern FILE* stepin ; /* input de yyparse (executeur de lex-yacc) */
extern int steplineno; /* compteur de ligne lex (pour erreurs) */
/* Designation d'un fichier de lecture
(par defaut, c'est l'entree standard)
Appel : iflag = stepread_setinput ("...") ou (char[] ...) ;
stepread_setinput ("") [longueur nulle] laisse en standard
iflag retourne vaut 0 si c'est OK, 1 sinon
*/
FILE* stepread_setinput (char* nomfic)
{
FILE* newin ;
if (strlen(nomfic) == 0) return stepin ;
newin = fopen(nomfic,"r") ;
if (newin == NULL) {
return NULL ;
} else {
stepin = newin ; return newin ;
}
}
void stepread_endinput (FILE* infic, char* nomfic)
{
if (!infic) return;
if (strlen(nomfic) == 0) return;
fclose (infic);
}
/* Lecture d'un fichier ia grammaire lex-yacc
Appel : i = stepread() ; i est la valeur retournee par yyparse
(0 si OK, 1 si erreur)
*/
int stepread ()
{
int letat;
lastno = 0;
steplineno = 0;
rec_debfile() ;
steprestart(stepin);
letat = stepparse() ;
rec_finfile() ;
return letat;
}
int stepwrap () { return 1; }

18
src/StepFile/stepread.ph Executable file
View File

@@ -0,0 +1,18 @@
// stepread.h
/* lecture du fichier STEP (par appel a lex+yac) */
extern "C" FILE* stepread_setinput (char* nomfic) ;
extern "C" void stepread_endinput (FILE* infic, char* nomfic);
extern "C" int stepread() ;
extern "C" void recfile_modeprint (int mode) ; /* controle trace recfile */
/* creation du Direc a partir de recfile : entrys connues de c++ */
extern "C" void lir_file_nbr(int* nbh, int* nbr, int* nbp) ;
extern "C" int lir_file_rec(char* *ident , char* *type , int* nbarg) ;
extern "C" void lir_file_finrec() ;
extern "C" int lir_file_arg(int* type , char* *val) ;
extern "C" void lir_file_fin(int mode);
/* Interruption passant par C++ */
extern "C" void StepFile_Interrupt (char* nomfic);