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
9f9e7fd5
Commit
9f9e7fd5
authored
Jan 09, 2011
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enhance DIR_LIB_SOURCE:ReadPart() and GetRevisions() to work in the un versioned mode.
parent
b752cfde
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
50 deletions
+81
-50
richio.cpp
common/richio.cpp
+1
-1
make-dir-lib-source-test-data.sh
new/make-dir-lib-source-test-data.sh
+4
-1
sch_dir_lib_source.cpp
new/sch_dir_lib_source.cpp
+69
-45
sch_lib.h
new/sch_lib.h
+4
-1
sch_lib_table.cpp
new/sch_lib_table.cpp
+2
-1
sch_part.cpp
new/sch_part.cpp
+1
-1
No files found.
common/richio.cpp
View file @
9f9e7fd5
...
...
@@ -230,7 +230,7 @@ int OUTPUTFORMATTER::vprint( const char* fmt, va_list ap ) throw( IO_ERROR )
int
ret
=
vsnprintf
(
&
buffer
[
0
],
buffer
.
size
(),
fmt
,
ap
);
if
(
ret
>=
(
int
)
buffer
.
size
()
)
{
buffer
.
res
erve
(
ret
+
2
00
);
buffer
.
res
ize
(
ret
+
20
00
);
ret
=
vsnprintf
(
&
buffer
[
0
],
buffer
.
size
(),
fmt
,
ap
);
}
...
...
new/make-dir-lib-source-test-data.sh
View file @
9f9e7fd5
...
...
@@ -16,7 +16,10 @@ for C in ${CATEGORIES}; do
for
P
in
${
PARTS
}
;
do
for
R
in
${
REVS
}
;
do
(
part
$C
/
$P
/
$R
extends
$P
/
$R
(
value 22
)(
footprint SM0805
))
>
$BASEDIR
/
$C
/
$P
.part.
$R
echo
"(part
$C
/
$P
(value 22)(footprint SM0805))"
>
$BASEDIR
/
$C
/
$P
.part.
$R
done
# also make the part without a rev:
echo
"(part
$C
/
$P
(value 22)(footprint SM0805))"
>
$BASEDIR
/
$C
/
$P
.part
done
done
new/sch_dir_lib_source.cpp
View file @
9f9e7fd5
...
...
@@ -59,16 +59,6 @@ using namespace std;
using
namespace
SCH
;
/* __func__ is C99 prescribed, but just in case:
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=338
#if defined(__GNUG__) // The GNU C++ compiler defines this
#define FUNC_NAME(x) // nothing, GNU C++ defines __func__ just fine.
#else
#define FUNC_NAME(x) static const char __func__[] = #x;
#endif
*/
/**
* Class DIR_WRAP
* provides a destructor which is invoked if an exception is thrown.
...
...
@@ -466,36 +456,37 @@ void DIR_LIB_SOURCE::GetRevisions( STRINGS* aResults, const STRING& aPartName )
aResults
->
push_back
(
it
->
substr
(
rev
-
it
->
c_str
()
)
);
}
}
else
{
// In non-version mode, there were no revisions read in, only part
// files without a revision. But clients higher up expect to see
// at least one revision in order for the API to work, so we return
// a revision ""
aResults
->
push_back
(
""
);
}
}
void
DIR_LIB_SOURCE
::
ReadPart
(
STRING
*
aResult
,
const
STRING
&
aPartName
,
const
STRING
&
aRev
)
throw
(
IO_ERROR
)
{
STRING
partName
=
aPartName
;
// appended with aRev too if not empty
const
char
*
rev
=
endsWithRev
(
partName
);
STRING
partName
=
aPartName
;
const
char
*
hasRev
=
endsWithRev
(
partName
);
if
(
!
useVersioning
&&
(
aRev
.
size
()
||
rev
)
)
if
(
useVersioning
)
{
STRING
msg
=
"this type 'dir' LIB_SOURCE not using 'useVersioning' option, cannot ask for a revision"
;
THROW_IO_ERROR
(
msg
);
}
if
(
aRev
.
size
()
)
{
if
(
rev
)
// a supplied rev replaces any in aPartName
partName
.
resize
(
rev
-
partName
.
c_str
()
-
1
);
// a supplied rev replaces any in aPartName
if
(
hasRev
)
partName
.
resize
(
hasRev
-
partName
.
c_str
()
-
1
);
partName
+=
"/"
+
aRev
;
partName
+=
'/'
;
partName
+
aRev
;
rev
=
endsWithRev
(
partName
);
}
// partName is the exact part name we need here, or if rev is NULL,
// then look for the highest numbered revision.
// find this exact revision
if
(
rev
)
{
PN_ITER
it
=
partnames
.
find
(
partName
);
if
(
it
==
partnames
.
end
()
)
// part not found
...
...
@@ -506,8 +497,13 @@ void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const S
readString
(
aResult
,
makeFileName
(
partName
)
);
}
else
{
// There's no rev on partName string. Find the most recent rev, i.e. highest,
// which will be first because of the BY_REV compare method, which treats
// higher numbered revs as first.
STRING
search
=
partName
+
'/'
;
// There's no rev on partName string. Find the most recent rev, i.e. highest,
...
...
@@ -517,15 +513,43 @@ void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const S
// verify that this one that is greater than partName is a match and not
// some unrelated name that is larger.
if
(
it
==
partnames
.
end
()
||
it
->
compare
(
0
,
search
.
size
(),
search
)
!=
0
)
if
(
it
==
partnames
.
end
()
||
it
->
compare
(
0
,
search
.
size
(),
search
)
!=
0
)
{
partName
.
insert
(
partName
.
begin
(),
'\''
);
partName
+=
"' is not present without a revision."
;
partName
+=
" is not present without a revision."
;
THROW_IO_ERROR
(
partName
);
}
readString
(
aResult
,
makeFileName
(
*
it
)
);
}
}
else
// !useVersioning
{
#if 1
if
(
hasRev
||
aRev
.
size
()
)
{
STRING
msg
=
"this type 'dir' LIB_SOURCE not using 'useVersioning' option, cannot ask for a revision"
;
THROW_IO_ERROR
(
msg
);
}
#else
// no revisions allowed, strip it
if
(
hasRev
)
partName
.
resize
(
hasRev
-
partName
.
c_str
()
-
1
);
#endif
// find the part name without any revision
PN_ITER
it
=
partnames
.
find
(
partName
);
if
(
it
==
partnames
.
end
()
)
// part not found
{
partName
+=
" not found."
;
THROW_IO_ERROR
(
partName
);
}
readString
(
aResult
,
makeFileName
(
partName
)
);
}
}
...
...
new/sch_lib.h
View file @
9f9e7fd5
...
...
@@ -107,7 +107,10 @@ protected: ///< derived classes must implement
* fetches all revisions for @a aPartName into @a aResults. Revisions are strings
* like "rev12", "rev279", and are library source agnostic. These do not have to be
* in a contiguous order, but the first 3 characters must be "rev" and subsequent
* characters must consist of at least one decimal digit.
* characters must consist of at least one decimal digit. If the LIB_SOURCE
* does not support revisions, it is allowed to return a single "" string as
* the only result. This means aPartName is present in the libsource, only once
* without a revision. This is a special case.
*/
virtual
void
GetRevisions
(
STRINGS
*
aResults
,
const
STRING
&
aPartName
)
throw
(
IO_ERROR
)
=
0
;
...
...
new/sch_lib_table.cpp
View file @
9f9e7fd5
...
...
@@ -355,6 +355,7 @@ void LIB_TABLE::Test()
"(lib_table
\n
"
" (lib (logical www) (type http) (full_uri http://kicad.org/libs) (options
\"
\"
))
\n
"
" (lib (logical meparts) (type dir) (full_uri /tmp/eeschema-lib) (options useVersioning))
\n
"
// " (lib (logical meparts) (type dir) (full_uri /tmp/eeschema-lib) (options \" \"))\n"
" (lib (logical old-project) (type schematic)(full_uri /tmp/old-schematic.sch) (options
\"
\"
))
\n
"
")
\n
"
,
...
...
@@ -399,7 +400,7 @@ void LIB_TABLE::Test()
}
// find a part
LPID
lpid
(
"meparts:tigers/ears
/rev10
"
);
LPID
lpid
(
"meparts:tigers/ears"
);
LookupPart
(
lpid
);
}
...
...
new/sch_part.cpp
View file @
9f9e7fd5
...
...
@@ -31,7 +31,7 @@
using
namespace
SCH
;
#define MAX_INHERITANCE_NESTING
10
// no problem going larger
#define MAX_INHERITANCE_NESTING
6
// no problem going larger
//-----<temporary home for PART sub objects, move after stable>------------------
...
...
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