Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
e737a308
Commit
e737a308
authored
Jun 26, 2011
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fill out more SWEET "inherits" support
parent
3d8c48e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
26 deletions
+166
-26
make-dir-lib-source-test-data.sh
new/make-dir-lib-source-test-data.sh
+4
-0
sch_part.cpp
new/sch_part.cpp
+65
-12
sch_part.h
new/sch_part.h
+96
-13
sch_sweet_parser.cpp
new/sch_sweet_parser.cpp
+1
-1
No files found.
new/make-dir-lib-source-test-data.sh
View file @
e737a308
...
...
@@ -96,6 +96,7 @@ for C in ${CATEGORIES}; do
mkdir
-p
$BASEDIR
/
$C
for
P
in
${
PARTS
}
;
do
for
R
in
${
REVS
}
;
do
echo
"(part
$C
/
$P
(value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE
...
...
@@ -119,6 +120,7 @@ for C in ${CATEGORIES}; do
$PIN_MERGE
)"
>
$BASEDIR
/
$C
/
$P
.part.
$R
done
# also make the part without a rev:
echo
"(part
$C
/
$P
(value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE
...
...
@@ -141,6 +143,8 @@ for C in ${CATEGORIES}; do
$PIN_DELETE
$PIN_MERGE
)"
>
$BASEDIR
/
$C
/
$P
.part
done
done
new/sch_part.cpp
View file @
e737a308
...
...
@@ -155,6 +155,25 @@ PROPERTY* PART::FieldLookup( PROP_ID aPropertyId )
return
p
;
}
PROPERTY
&
PROPERTY
::
operator
=
(
const
PROPERTY
&
r
)
{
*
(
BASE_GRAPHIC
*
)
this
=
(
BASE_GRAPHIC
&
)
r
;
name
=
r
.
name
;
text
=
r
.
text
;
delete
effects
;
if
(
r
.
effects
)
effects
=
new
TEXT_EFFECTS
(
*
r
.
effects
);
else
effects
=
0
;
return
*
this
;
}
PINS
::
iterator
PART
::
pinFindByPad
(
const
wxString
&
aPad
)
{
PINS
::
iterator
it
;
...
...
@@ -196,7 +215,6 @@ bool PART::PinDelete( const wxString& aPad )
}
PART
::~
PART
()
{
clear
();
...
...
@@ -210,25 +228,60 @@ void PART::setExtends( LPID* aLPID )
}
void
PART
::
inherit
(
const
PART
&
othe
r
)
void
PART
::
inherit
(
const
PART
&
r
)
{
contains
=
other
.
contains
;
// Inherit can be called at any time, even from an interactive text
// editor, so cannot assume 'this' object is new. Clear it.
clear
();
// copy anything inherited, such as drawables, properties, pins, etc. here
contains
=
r
.
contains
;
base
=
&
r
;
// @todo copy the inherited drawables, properties, and pins here
anchor
=
r
.
anchor
;
for
(
int
i
=
REFERENCE
;
i
<
END
;
++
i
)
{
if
(
r
.
mandatory
[
i
]
)
mandatory
[
i
]
=
(
PROPERTY
*
)
r
.
mandatory
[
i
]
->
Clone
(
this
);
}
for
(
PROPERTIES
::
const_iterator
it
=
r
.
properties
.
begin
();
it
!=
r
.
properties
.
end
();
++
it
)
properties
.
push_back
(
(
PROPERTY
*
)
(
*
it
)
->
Clone
(
this
)
);
for
(
GRAPHICS
::
const_iterator
it
=
r
.
graphics
.
begin
();
it
!=
r
.
graphics
.
end
();
++
it
)
graphics
.
push_back
(
(
*
it
)
->
Clone
(
this
)
);
for
(
PINS
::
const_iterator
it
=
r
.
pins
.
begin
();
it
!=
r
.
pins
.
end
();
++
it
)
pins
.
push_back
(
(
PIN
*
)
(
*
it
)
->
Clone
(
this
)
);
/* not sure about this concept yet:
for( PART_REFS::const_iterator it = r.alternates.begin(); it != r.alternates.end(); ++it )
alternates.push_back( *it );
*/
for
(
KEYWORDS
::
const_iterator
it
=
r
.
keywords
.
begin
();
it
!=
r
.
keywords
.
end
();
++
it
)
keywords
.
insert
(
*
it
);
for
(
MERGE_SETS
::
const_iterator
it
=
r
.
pin_merges
.
begin
();
it
!=
r
.
pin_merges
.
end
();
++
it
)
{
pin_merges
[
*
it
->
first
]
=
*
new
MERGE_SET
(
*
it
->
second
);
}
}
PART
&
PART
::
operator
=
(
const
PART
&
othe
r
)
PART
&
PART
::
operator
=
(
const
PART
&
r
)
{
owner
=
other
.
owner
;
partNameAndRev
=
other
.
partNameAndRev
;
body
=
other
.
body
;
base
=
other
.
base
;
// maintain in concert with inherit(), which is a partial assignment operator.
inherit
(
r
);
setExtends
(
other
.
extends
?
new
LPID
(
*
other
.
extends
)
:
0
);
owner
=
r
.
owner
;
partNameAndRev
=
r
.
partNameAndRev
;
body
=
r
.
body
;
base
=
r
.
base
;
// maintain in concert with inherit(), which is a partial assignment operator.
inherit
(
other
);
setExtends
(
r
.
extends
?
new
LPID
(
*
r
.
extends
)
:
0
);
return
*
this
;
}
...
...
new/sch_part.h
View file @
e737a308
...
...
@@ -110,9 +110,15 @@ public:
wxPoint
(
x
,
y
)
{}
POINT
(
const
POINT
&
r
)
:
wxPoint
(
r
)
{}
POINT
()
:
wxPoint
()
{}
// assume assignment operator is inherited.
};
};
...
...
@@ -135,7 +141,7 @@ class FONTZ
{
public
:
#define FONTZ_DEFAULT -1 ///< when size defers to higher control
#define FONTZ_DEFAULT -1
///< when size defers to higher control
FONTZ
()
:
height
(
FONTZ_DEFAULT
),
...
...
@@ -146,6 +152,7 @@ public:
int
width
;
};
typedef
float
ANGLE
;
typedef
int
STROKE
;
///< will be a class someday, currently only line width
...
...
@@ -158,7 +165,7 @@ class FONT
friend
class
SWEET_PARSER
;
protected
:
wxString
name
;
///< name or other id such as number, TBD
wxString
name
;
///< name or other id such as number, TBD
FONTZ
size
;
bool
italic
;
...
...
@@ -172,6 +179,8 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
// trust compiler to write its own assignment operator for this class OK.
};
...
...
@@ -193,6 +202,8 @@ struct TEXT_EFFECTS
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
// trust compiler to write its own assignment operator for this class OK.
};
...
...
@@ -200,7 +211,6 @@ struct TEXT_EFFECTS
#define FILL_TYPE_DEFAULT PR::T_none ///< fillType defaut
class
BASE_GRAPHIC
{
friend
class
PART
;
...
...
@@ -218,6 +228,14 @@ public:
virtual
~
BASE_GRAPHIC
()
{}
/**
* Function Clone
* invokes the copy constructor on a heap allocated object of this same
* type and creates a deep copy of 'this' into it
* @param aOwner is the owner of the returned, new object.
*/
virtual
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
=
0
;
static
const
char
*
ShowFill
(
int
aFillType
)
{
return
SWEET_LEXER
::
TokenName
(
PR
::
T
(
aFillType
)
);
...
...
@@ -232,6 +250,7 @@ public:
{}
};
typedef
std
::
deque
<
POINT
>
POINTS
;
class
POLY_LINE
:
public
BASE_GRAPHIC
...
...
@@ -257,8 +276,16 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
POLY_LINE
*
n
=
new
POLY_LINE
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
class
BEZIER
:
public
POLY_LINE
{
friend
class
PART
;
...
...
@@ -274,8 +301,16 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
BEZIER
*
n
=
new
BEZIER
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
class
RECTANGLE
:
public
BASE_GRAPHIC
{
friend
class
PART
;
...
...
@@ -297,6 +332,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
RECTANGLE
*
n
=
new
RECTANGLE
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
...
...
@@ -322,6 +364,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
CIRCLE
*
n
=
new
CIRCLE
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
...
...
@@ -349,6 +398,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
ARC
*
n
=
new
ARC
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
...
...
@@ -387,6 +443,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
GR_TEXT
*
n
=
new
GR_TEXT
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
...
...
@@ -416,6 +479,16 @@ public:
effects
(
0
)
{}
PROPERTY
(
const
PROPERTY
&
r
)
:
BASE_GRAPHIC
(
NULL
),
effects
(
0
)
{
// use assignment operator
*
this
=
r
;
}
PROPERTY
&
operator
=
(
const
PROPERTY
&
r
);
// @todo
~
PROPERTY
()
{
clear
();
...
...
@@ -436,6 +509,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
PROPERTY
*
n
=
new
PROPERTY
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
};
...
...
@@ -488,6 +568,13 @@ public:
void
Format
(
OUTPUTFORMATTER
*
aFormatter
,
int
aNestLevel
,
int
aControlBits
)
const
throw
(
IO_ERROR
);
BASE_GRAPHIC
*
Clone
(
PART
*
aOwner
)
const
{
PIN
*
n
=
new
PIN
(
*
this
);
n
->
owner
=
aOwner
;
return
n
;
}
protected
:
POINT
pos
;
ANGLE
angle
;
...
...
@@ -533,7 +620,6 @@ public:
{
}
/**
* Function Lookup
* returns the PART that this LPID refers to. Never returns NULL, because
...
...
@@ -556,7 +642,6 @@ protected:
typedef
std
::
vector
<
PART_REF
>
PART_REFS
;
}
// namespace SCH
...
...
@@ -667,7 +752,7 @@ public:
* constructed by this function if need be.
* @param aPropertyId tells which field.
*/
PROPERTY
*
FieldLookup
(
PROP_ID
aPropertyId
);
PROPERTY
*
FieldLookup
(
PROP_ID
aPropertyId
);
/**
* Function PinFindByPad
...
...
@@ -675,7 +760,7 @@ public:
* @param aPad is the pin to find
* @return PIN* - the found PIN or NULL if not found.
*/
PIN
*
PinFindByPad
(
const
wxString
&
aPad
)
PIN
*
PinFindByPad
(
const
wxString
&
aPad
)
{
PINS
::
iterator
it
=
pinFindByPad
(
aPad
);
return
it
!=
pins
.
end
()
?
*
it
:
NULL
;
...
...
@@ -685,7 +770,7 @@ public:
* Function PinsFindBySignal
* fetches all the pins matching aSignal into aResults.
*/
void
PinsFindBySignal
(
PIN_LIST
*
aResults
,
const
wxString
&
aSignal
);
void
PinsFindBySignal
(
PIN_LIST
*
aResults
,
const
wxString
&
aSignal
);
/**
* Function PinDelete
...
...
@@ -766,17 +851,15 @@ protected: // not likely to have C++ descendants, but protected none-the-le
*/
PINS
::
iterator
pinFindByPad
(
const
wxString
&
aPad
);
POINT
anchor
;
//PART( LIB* aOwner );
LIB
*
owner
;
///< which LIB am I a part of (pun if you want)
int
contains
;
///< has bits from Enum PartParts
STRING
partNameAndRev
;
///< example "passives/R[/revN..]", immutable.
LPID
*
extends
;
///< of base part, NULL if none, otherwise I own it.
PART
*
base
;
///< which PART am I extending, if any. no ownership.
const
PART
*
base
;
///< which PART am I extending, if any. no ownership.
POINT
anchor
;
/// encapsulate the old version deletion, take ownership of @a aLPID
void
setExtends
(
LPID
*
aLPID
);
...
...
new/sch_sweet_parser.cpp
View file @
e737a308
...
...
@@ -346,7 +346,7 @@ void SWEET_PARSER::parseExtends( PART* me )
// we could be going in circles here, recursively, or too deep, set limits
// and disallow extending from self (even indirectly)
int
extendsDepth
=
0
;
for
(
PART
*
ancestor
=
base
;
ancestor
&&
extendsDepth
<
MAX_INHERITANCE_NESTING
;
for
(
const
PART
*
ancestor
=
base
;
ancestor
&&
extendsDepth
<
MAX_INHERITANCE_NESTING
;
++
extendsDepth
,
ancestor
=
ancestor
->
base
)
{
if
(
ancestor
==
me
)
...
...
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