Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
3d792b66
Commit
3d792b66
authored
Dec 14, 2005
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Same as 1.52...
parent
067a4a63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
143 deletions
+60
-143
wb/lib/wb/src/wb_wblnode.cpp
wb/lib/wb/src/wb_wblnode.cpp
+60
-143
No files found.
wb/lib/wb/src/wb_wblnode.cpp
View file @
3d792b66
/*
* Proview $Id: wb_wblnode.cpp,v 1.5
3 2005-12-14 07:22:38
claes Exp $
* Proview $Id: wb_wblnode.cpp,v 1.5
4 2005-12-14 11:28:19
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -25,52 +25,14 @@
#include "wb_orepwbl.h"
#include "wb_merep.h"
#include "wb_cdrep.h"
#include "wb_wblvocabTokenTypes.hpp"
#include "wb_dbs.h"
#include "wb_name.h"
#include "wb_treeimport.h"
#include "wb_wblvocabTokenTypes.hpp"
typedef
enum
{
tokensEOF_
=
1
,
tokensOBJECT
=
4
,
tokensENDOBJECT
=
5
,
tokensVOLUME
=
6
,
tokensENDVOLUME
=
7
,
tokensSOBJECT
=
8
,
tokensENDSOBJECT
=
9
,
tokensBODY
=
10
,
tokensENDBODY
=
11
,
tokensATTRIBUTE
=
12
,
tokensBUFFER
=
13
,
tokensENDBUFFER
=
14
,
tokensDOBJECT
=
15
,
tokensENDDOBJECT
=
16
,
tokensDBUFFER
=
17
,
tokensENDDBUFFER
=
18
,
tokensDATTRIBUTE
=
19
,
tokensNUM_FLOAT
=
20
,
tokensINT
=
21
,
tokensOID
=
22
,
tokensDOCBLOCK
=
23
,
tokensASC_TIME
=
24
,
tokensEQ
=
25
,
tokensOREQ
=
26
,
tokensWS
=
27
,
tokensCOMMENT
=
28
,
tokensINDEX
=
29
,
tokensVALUE
=
30
,
tokensCHAR_LITERAL
=
31
,
tokensSTRING_LITERAL
=
32
,
tokensDIGITS
=
33
,
tokensESC
=
34
,
tokensSWEC
=
35
,
tokensNULL_TREE_LOOKAHEAD
=
3
}
wblnode_eTokens
;
struct
wb_wblvocabTokenTypes
tokens
;
#define wblAlign(size) ((size + 3) & ~3)
struct
wb_wblvocabTokenTypes
tokens
;
/* Datatypes */
static
wbl_sSym
datatypes
[]
=
...
...
@@ -450,8 +412,8 @@ int wb_wblnode::convconst( int *val, char *str)
ref_wblnode
wb_wblnode
::
find
(
wb_name
*
oname
,
int
level
)
{
switch
(
getType
())
{
case
tokensOBJECT
:
if
(
getType
()
==
tokens
.
OBJECT
)
{
if
(
oname
->
segmentIsEqual
(
name
(),
level
))
{
if
(
!
oname
->
hasSegment
(
level
+
1
))
return
this
;
...
...
@@ -464,15 +426,15 @@ ref_wblnode wb_wblnode::find( wb_name *oname, int level)
return
o
->
fws
->
find
(
oname
,
level
);
else
return
0
;
case
tokensVOLUME
:
}
if
((
getType
()
==
tokens
.
VOLUME
)
||
(
getType
()
==
tokens
.
OBJECT
))
{
if
(
oname
->
volumeIsEqual
(
name
())
&&
!
oname
->
hasSegment
(
0
))
return
this
;
else
if
(
o
->
fch
)
return
o
->
fch
->
find
(
oname
,
0
);
else
return
0
;
default:
;
}
return
0
;
}
...
...
@@ -1056,8 +1018,7 @@ void wb_wblnode::buildBody( ref_wblnode object)
ref_wblnode
first_child
;
ref_wblnode
next_sibling
;
switch
(
getType
())
{
case
tokensBODY
:
if
(
getType
()
==
tokens
.
BODY
)
{
if
(
cdh_NoCaseStrcmp
(
name
(),
"SysBody"
)
==
0
)
bix
=
pwr_eBix_sys
;
else
if
(
cdh_NoCaseStrcmp
(
name
(),
"RtBody"
)
==
0
)
...
...
@@ -1072,7 +1033,7 @@ void wb_wblnode::buildBody( ref_wblnode object)
first_child
=
getFirstChild
();
// First child might be body time
if
(
first_child
&&
first_child
->
getType
()
==
tokensASC_TIME
)
{
if
(
first_child
&&
first_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
first_child
->
getText
();
pwr_tTime
bodytime
;
if
(
stringToTime
(
timestr
.
c_str
(),
&
bodytime
))
{
...
...
@@ -1094,8 +1055,7 @@ void wb_wblnode::buildBody( ref_wblnode object)
next_sibling
=
getNextSibling
();
if
(
next_sibling
)
next_sibling
->
buildBody
(
object
);
break
;
default:
}
else
{
next_sibling
=
getNextSibling
();
if
(
next_sibling
)
next_sibling
->
buildBody
(
object
);
...
...
@@ -1118,9 +1078,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
int
int_val
,
current_int_val
;
bool
string_continue
=
false
;
switch
(
getType
())
{
case
tokensATTRIBUTE
:
{
if
(
getType
()
==
tokens
.
ATTRIBUTE
)
{
first_child
=
getFirstChild
();
if
(
!
first_child
)
{
// Attr exception
...
...
@@ -1128,17 +1086,13 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
goto
error_continue
;
}
switch
(
oper
=
first_child
->
getType
())
{
case
tokensOREQ
:
case
tokensEQ
:
break
;
default:
oper
=
first_child
->
getType
();
if
((
oper
!=
tokens
.
OREQ
)
&&
(
oper
!=
tokens
.
EQ
))
{
// Attr exception
m_vrep
->
error
(
"Attribute value required"
,
getFileName
(),
line_number
);
goto
error_continue
;
}
if
(
!
m_vrep
->
getAttrInfo
(
name
(),
(
pwr_eBix
)
bix
,
object
->
o
->
m_cid
,
&
size
,
&
offset
,
&
tid
,
&
elements
,
&
type
,
&
flags
))
{
// This might be string special syntax
...
...
@@ -1188,7 +1142,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if
(
size
==
sizeof
(
int_val
)
&&
convconst
(
&
int_val
,
value
))
{
if
(
oper
==
tokensEQ
)
{
if
(
oper
==
tokens
.
EQ
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
memcpy
(
(
char
*
)((
unsigned
int
)
object
->
o
->
rbody
+
offset
),
&
int_val
,
size
);
...
...
@@ -1196,7 +1150,7 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
memcpy
(
(
char
*
)((
unsigned
int
)
object
->
o
->
dbody
+
offset
),
&
int_val
,
size
);
}
else
if
(
oper
==
tokensOREQ
)
{
else
if
(
oper
==
tokens
.
OREQ
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
{
current_int_val
=
*
(
int
*
)
((
unsigned
int
)
object
->
o
->
rbody
+
offset
);
int_val
|=
current_int_val
;
...
...
@@ -1231,16 +1185,14 @@ void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
// Attr conversion exception
m_vrep
->
error
(
"Unable to convert string to value"
,
getFileName
(),
line_number
);
}
error_continue:
break
;
error_continue:
;
}
case
tokensBUFFER
:
else
if
(
getType
()
==
tokens
.
BUFFER
)
{
buildBuff
(
object
,
bix
,
0
,
0
,
0
);
break
;
}
default:
;
}
}
...
...
@@ -1291,7 +1243,7 @@ void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_ci
delete
adrep
;
}
first_child
=
getFirstChild
();
if
(
first_child
&&
first_child
->
getType
()
==
tokensINDEX
)
{
if
(
first_child
&&
first_child
->
getType
()
==
tokens
.
INDEX
)
{
int
index
;
int
nr
=
sscanf
(
first_child
->
name
(),
"%d"
,
&
index
);
if
(
nr
!=
1
)
{
...
...
@@ -1331,8 +1283,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
wb_adrep
*
adrep
;
wb_attrname
aname
;
switch
(
getType
())
{
case
tokensATTRIBUTE
:
if
(
getType
()
==
tokens
.
ATTRIBUTE
)
{
first_child
=
getFirstChild
();
if
(
!
first_child
)
{
...
...
@@ -1341,11 +1292,8 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
goto
error_continue
;
}
switch
(
oper
=
first_child
->
getType
())
{
case
tokensOREQ
:
case
tokensEQ
:
break
;
default:
oper
=
first_child
->
getType
();
if
((
oper
!=
tokens
.
OREQ
)
&&
(
oper
!=
tokens
.
EQ
))
{
// Attr exception
m_vrep
->
error
(
"Attribute value required"
,
getFileName
(),
line_number
);
goto
error_continue
;
...
...
@@ -1464,7 +1412,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if
(
size
/
elements
==
sizeof
(
int_val
)
&&
convconst
(
&
int_val
,
value
))
{
if
(
oper
==
tokensEQ
)
{
if
(
oper
==
tokens
.
EQ
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
memcpy
(
(
char
*
)((
unsigned
int
)
object
->
o
->
rbody
+
offset
),
&
int_val
,
size
/
elements
);
...
...
@@ -1472,7 +1420,7 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
memcpy
(
(
char
*
)((
unsigned
int
)
object
->
o
->
dbody
+
offset
),
&
int_val
,
size
/
elements
);
}
else
if
(
oper
==
tokensOREQ
)
{
else
if
(
oper
==
tokens
.
OREQ
)
{
if
(
bix
==
pwr_eBix_rt
||
bix
==
pwr_eBix_sys
)
{
current_int_val
=
*
(
int
*
)
((
unsigned
int
)
object
->
o
->
rbody
+
offset
);
int_val
|=
current_int_val
;
...
...
@@ -1500,16 +1448,13 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffe
m_vrep
->
error
(
"Unable to convert string to value"
,
getFileName
(),
line_number
);
}
error_continue:
break
;
;
}
case
tokensBUFFER
:
else
if
(
getType
()
==
tokens
.
BUFFER
)
{
buildBuff
(
object
,
bix
,
buffer_cid
,
buffer_offset
,
buffer_size
);
break
;
}
default:
;
}
next_sibling
=
getNextSibling
();
if
(
next_sibling
)
next_sibling
->
buildBuffAttr
(
object
,
bix
,
buffer_cid
,
buffer_offset
,
buffer_size
);
...
...
@@ -1520,9 +1465,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_a
ref_wblnode
first_child
;
ref_wblnode
next_sibling
;
switch
(
getType
())
{
case
tokensOBJECT
:
case
tokensVOLUME
:
if
((
getType
()
==
tokens
.
OBJECT
)
||
(
getType
()
==
tokens
.
VOLUME
))
{
if
(
!
father
)
{
// Volume root
vol
->
root_object
=
this
;
...
...
@@ -1554,12 +1497,12 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_a
prev
=
child
;
child
=
child
->
getNextSibling
();
}
if
(
prev
&&
prev
->
getType
()
==
tokensDOCBLOCK
)
if
(
prev
&&
prev
->
getType
()
==
tokens
.
DOCBLOCK
)
o
->
docblock
=
prev
;
}
// cout << "Linking " << name << endl;
break
;
case
tokensSOBJECT
:
}
else
if
(
getType
()
==
tokens
.
SOBJECT
)
{
ref_wblnode
snode
=
m_vrep
->
find
(
name
());
if
(
!
snode
)
{
...
...
@@ -1574,9 +1517,7 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father, ref_wblnode parent_a
next_sibling
=
getNextSibling
();
if
(
next_sibling
)
next_sibling
->
link
(
vol
,
father
);
break
;
}
default:
}
else
{
first_child
=
getFirstChild
();
if
(
first_child
)
first_child
->
link
(
vol
,
father
);
...
...
@@ -1592,12 +1533,10 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
ref_wblnode
first_child
=
getFirstChild
();
m_vrep
=
vol
;
switch
(
getType
())
{
case
tokensDOCBLOCK
:
{
if
(
getType
()
==
tokens
.
DOCBLOCK
)
{
string
txt
=
getText
();
break
;
}
case
tokensOBJECT
:
else
if
(
getType
()
==
tokens
.
OBJECT
)
{
if
(
!
o
)
...
...
@@ -1622,27 +1561,27 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// If $ClassDef, register class in classlist
if
(
!
isTemplate
())
{
if
(
first_child
->
getType
()
==
tokensVALUE
&&
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$ClassDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_ClassDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_ClassDef
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$Type"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_Type"
)
==
0
))
{
node_type
=
wbl_eNodeType_Type
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$TypeDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_TypeDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_TypeDef
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$ObjBodyDef"
)
==
0
||
strcmp
(
o
->
cname
,
"pwr_eClass_ObjBodyDef"
)
==
0
))
{
node_type
=
wbl_eNodeType_ObjBodyDef
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$Attribute"
)
==
0
||
strcmp
(
o
->
cname
,
"$Input"
)
==
0
||
strcmp
(
o
->
cname
,
"$Output"
)
==
0
||
...
...
@@ -1652,11 +1591,11 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
strcmp
(
o
->
cname
,
"pwr_eClass_Param"
)
==
0
))
{
node_type
=
wbl_eNodeType_Attribute
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$Buffer"
)
==
0
))
{
node_type
=
wbl_eNodeType_Buffer
;
}
else
if
(
first_child
->
getType
()
==
tokensVALUE
&&
else
if
(
first_child
->
getType
()
==
tokens
.
VALUE
&&
(
strcmp
(
o
->
cname
,
"$Param"
)
==
0
))
{
m_vrep
->
error
(
"Obsolete attribute class, use $Attribute instead"
,
getFileName
(),
line_number
);
...
...
@@ -1668,32 +1607,29 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
if
(
second_child
)
{
ref_wblnode
third_child
=
second_child
->
getNextSibling
();
switch
(
second_child
->
getType
())
{
case
tokensVALUE
:
case
tokensINT
:
{
if
((
second_child
->
getType
()
==
tokens
.
VALUE
)
||
(
second_child
->
getType
()
==
tokens
.
INT
))
{
string
oixstr
=
second_child
->
getText
();
if
(
!
stringToOix
(
oixstr
.
c_str
(),
&
o
->
m_oid
.
oix
))
{
o
->
m_oid
.
oix
=
m_vrep
->
nextOix
();
}
if
(
third_child
&&
third_child
->
getType
()
==
tokensASC_TIME
)
{
if
(
third_child
&&
third_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
third_child
->
getText
();
if
(
!
stringToTime
(
timestr
.
c_str
(),
&
o
->
m_ohtime
))
m_vrep
->
error
(
"Time syntax"
,
getFileName
(),
line_number
);
}
break
;
}
case
tokensASC_TIME
:
{
else
if
(
second_child
->
getType
()
==
tokens
.
ASC_TIME
)
{
string
timestr
=
second_child
->
getText
();
if
(
!
stringToTime
(
timestr
.
c_str
(),
&
o
->
m_ohtime
))
m_vrep
->
error
(
"Time syntax"
,
getFileName
(),
line_number
);
break
;
}
case
tokensENDOBJECT
:
case
tokensOBJECT
:
case
tokensBODY
:
else
if
((
second_child
->
getType
()
==
tokens
.
ENDOBJECT
)
||
(
second_child
->
getType
()
==
tokens
.
OBJECT
)
||
(
second_child
->
getType
()
==
tokens
.
BODY
))
{
o
->
m_oid
.
oix
=
m_vrep
->
nextOix
();
break
;
default:
}
else
{
;
// Syntax exception -- oix
m_vrep
->
error
(
"Syntax"
,
getFileName
(),
line_number
);
}
...
...
@@ -1727,7 +1663,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
ref_wblnode
last_child
=
child
;
string
childname
;
while
(
child
)
{
if
(
child
->
getType
()
==
tokensOBJECT
)
{
if
(
child
->
getType
()
==
tokens
.
OBJECT
)
{
childname
=
child
->
getText
();
if
(
strcmp
(
childname
.
c_str
(),
"Template"
)
==
0
)
{
o
->
c
.
templ
=
child
;
...
...
@@ -1747,7 +1683,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
wb_wblnode
*
templ
=
new
wb_wblnode
();
// ref_wblnode reftempl(templ);
o
->
c
.
templ
=
templ
;
o
->
c
.
templ
->
setType
(
tokensOBJECT
);
o
->
c
.
templ
->
setType
(
tokens
.
OBJECT
);
string
tname
(
"Template"
);
o
->
c
.
templ
->
setText
(
tname
);
if
(
last_child
)
...
...
@@ -1775,9 +1711,8 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
if
(
!
(
o
->
b
.
bix
==
pwr_eBix_rt
||
o
->
b
.
bix
==
pwr_eBix_sys
||
o
->
b
.
bix
==
pwr_eBix_dev
))
m_vrep
->
error
(
"Bad body index"
,
getFileName
(),
line_number
);
}
break
;
}
case
tokensVOLUME
:
else
if
(
getType
()
==
tokens
.
VOLUME
)
{
pwr_tVid
vid
;
int
sts
;
...
...
@@ -1797,18 +1732,15 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Get oid
ref_wblnode
second_child
=
first_child
->
getNextSibling
();
if
(
second_child
)
{
switch
(
second_child
->
getType
())
{
case
tokensOID
:
{
if
(
second_child
->
getType
()
==
tokens
.
OID
)
{
string
vidstring
=
second_child
->
getText
();
sts
=
cdh_StringToVolumeId
(
(
char
*
)
vidstring
.
c_str
(),
&
vid
);
if
(
EVEN
(
sts
))
{
// Syntax exception -- vid
m_vrep
->
error
(
"Volume id syntax"
,
getFileName
(),
line_number
);
}
break
;
}
default:
else
{
// Syntax exception -- vid
m_vrep
->
error
(
"Volume syntax"
,
getFileName
(),
line_number
);
}
...
...
@@ -1830,18 +1762,8 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
// Build to get next oix
build
(
false
);
}
break
;
}
case
tokensATTRIBUTE
:
case
tokensSOBJECT
:
case
tokensBODY
:
case
tokensVALUE
:
case
tokensINT
:
case
tokensNUM_FLOAT
:
{
break
;
}
case
tokensCHAR_LITERAL
:
else
if
(
getType
()
==
tokens
.
CHAR_LITERAL
)
{
// Remove quotes
char
str
[
10
];
...
...
@@ -1851,9 +1773,8 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
str
[
strlen
(
str
)
-
1
]
=
0
;
string
new_text
(
str
);
setText
(
new_text
);
break
;
}
case
tokensSTRING_LITERAL
:
else
if
(
getType
()
==
tokens
.
STRING_LITERAL
)
{
// Remove quotes and replace \" with "
char
str
[
2048
];
...
...
@@ -1875,10 +1796,6 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
*
t
=
0
;
string
new_text
(
str
);
setText
(
new_text
);
break
;
}
default:
;
}
ref_wblnode
child
=
first_child
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment