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
fb0bb79a
Commit
fb0bb79a
authored
Aug 09, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TokenList2DsnLexer.cmake, netform.cpp enhancements
parent
ac2fd246
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
287 additions
and
137 deletions
+287
-137
CHANGELOG.txt
CHANGELOG.txt
+14
-0
TokenList2DsnLexer.cmake
CMakeModules/TokenList2DsnLexer.cmake
+115
-15
CMakeLists.txt
common/CMakeLists.txt
+14
-0
netlist.keywords
common/netlist.keywords
+2
-0
richio.cpp
common/richio.cpp
+3
-3
CMakeLists.txt
eeschema/CMakeLists.txt
+6
-6
eeschema_config.cpp
eeschema/eeschema_config.cpp
+2
-5
netform.cpp
eeschema/netform.cpp
+12
-2
template_fieldnames.cpp
eeschema/template_fieldnames.cpp
+10
-10
template_fieldnames.h
eeschema/template_fieldnames.h
+6
-7
dsnlexer.h
include/dsnlexer.h
+56
-50
richio.h
include/richio.h
+40
-28
xnode.h
include/xnode.h
+2
-3
specctra.cpp
pcbnew/specctra.cpp
+1
-4
specctra.h
pcbnew/specctra.h
+2
-2
specctra_export.cpp
pcbnew/specctra_export.cpp
+1
-1
specctra_import.cpp
pcbnew/specctra_import.cpp
+1
-1
No files found.
CHANGELOG.txt
View file @
fb0bb79a
...
...
@@ -4,6 +4,20 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-Aug-8 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++CMakeModules:
Revise TokenList2DsnLexer.cmake to make an entire derived lexer class that
returns the proper enum type for superior debugging.
++eeschema
* netform.cpp now outputs the allowed footprint filters for a given library
component.
* There is an auto-generated class called NETLIST_LEXER which is defined in
from netlist.keywords by TokenList2DsnLexer.cmake into netlist_lexer.h, that
may be the basis of loading a S-expression form of the generic netlist format
which is written from netform.cpp.
2010-Aug-7 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++common
...
...
CMakeModules/TokenList2DsnLexer.cmake
View file @
fb0bb79a
...
...
@@ -82,18 +82,17 @@ get_filename_component( result "${inputFile}" NAME_WE )
message
(
STATUS
"Extracted file name
${
result
}
from path
${
inputFile
}
"
)
# Create include and source file name from the list file name.
set
(
includeFileName
"
${
outputPath
}
/
${
result
}
_
keywords
.h"
)
set
(
includeFileName
"
${
outputPath
}
/
${
result
}
_
lexer
.h"
)
set
(
sourceFileName
"
${
outputPath
}
/
${
result
}
_keywords.cpp"
)
# Create tag for generating header file.
string
(
TOUPPER
"
${
result
}
"
fileNameTag
)
set
(
headerTag
"_
${
fileNameTag
}
_H_"
)
string
(
TOUPPER
"
${
result
}
"
RESULT
)
set
(
headerTag
"_
${
RESULT
}
_H_"
)
set
(
includeFileHeader
"
/*
* Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
* script.
/* Do not modify this file it was automatically generated by the
* TokenList2DsnLexer CMake script.
*/
#ifndef
${
headerTag
}
...
...
@@ -124,18 +123,17 @@ enum ${enum} {
set
(
sourceFileHeader
"
/*
* Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
* script.
/* Do not modify this file it was automatically generated by the
* TokenList2DsnLexer CMake script.
*
* Include this file in your lexer class to provide the keywords for you DSN lexer.
* Include this file in your lexer class to provide the keywords for
* your DSN lexer.
*/
#include
\"
fctsys.h
\"
#include
\"
macros.h
\"
#include
\"
${
result
}
_keywords.h
\"
#include
\"
${
result
}
_lexer.h
\"
namespace DSN {
...
...
@@ -209,18 +207,120 @@ extern const unsigned ${result}_keyword_count;
} // End namespace DSN
using namespace DSN; // enum
${
enum
}
is in this namespace
class
${
RESULT
}
_LEXER : public DSNLEXER
{
public:
/**
* Constructor
${
RESULT
}
_LEXER
* @param aClipboartTxt is std::string (8 bit) text possibly from the
* clipboard that you want to parse.
*/
${
RESULT
}
_LEXER( const std::string& aClipboardTxt ) :
DSNLEXER( aClipboardTxt,
DSN::
${
result
}
_keywords,
DSN::
${
result
}
_keyword_count )
{
}
/**
* Constructor
${
RESULT
}
_LEXER
* takes @a aFile already opened for reading and @a aFilename as parameters.
* The opened file is not closed by this class, and is assumed to be positioned
* at the beginning of the file for purposes of accurate line number reporting
* in error messages.
* @param aFile is a FILE already opened for reading.
* @param aFilename is the name of the opened file, needed for error reporting.
*/
${
RESULT
}
_LEXER( FILE* aFile, const wxString& aFilename ) :
DSNLEXER( aFile, aFilename,
DSN::
${
result
}
_keywords,
DSN::
${
result
}
_keyword_count )
{
}
/**
* Function NextTok
* returns the next token found in the input file or T_EOF when reaching
* the end of file. Users should wrap this function to return an enum
* to aid in grammar debugging while running under a debugger, but leave
* this lower level function returning an int (so the enum does not collide
* with another usage).
* @return
${
enum
}
- the type of token found next.
* @throw IOError - only if the LINE_READER throws it.
*/
${
enum
}
NextTok() throw (IOError)
{
return (
${
enum
}
) DSNLEXER::NextTok();
}
/**
* Function NeedSYMBOL
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol().
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy IsSymbol()
*/
${
enum
}
NeedSYMBOL() throw( IOError )
{
return (
${
enum
}
) DSNLEXER::NeedSYMBOL();
}
/**
* Function NeedSYMBOLorNUMBER
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol() or tok==T_NUMBER.
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy the above test
*/
${
enum
}
NeedSYMBOLorNUMBER() throw( IOError )
{
return (
${
enum
}
) DSNLEXER::NeedSYMBOLorNUMBER();
}
/**
* Function CurTok
* returns whatever NextTok() returned the last time it was called.
*/
${
enum
}
CurTok()
{
return (
${
enum
}
) DSNLEXER::CurTok();
}
/**
* Function PrevTok
* returns whatever NextTok() returned the 2nd to last time it was called.
*/
${
enum
}
PrevTok()
{
return (
${
enum
}
) DSNLEXER::PrevTok();
}
};
// example usage
/**
* Class
${
RESULT
}
_PARSER
* holds data and functions pertinent to parsing a S-expression file .
*
class
${
RESULT
}
_PARSER : public
${
RESULT
}
_LEXER
{
};
*/
#endif //
End
${
headerTag
}
#endif //
${
headerTag
}
"
)
file
(
APPEND
"
${
sourceFileName
}
"
"};
const unsigned
${
result
}
_keyword_count = DIM(
${
result
}
_keywords );
} // End namespace DSN
"
)
common/CMakeLists.txt
View file @
fb0bb79a
...
...
@@ -43,6 +43,7 @@ set(COMMON_SRCS
gr_basic.cpp
hotkeys_basic.cpp
msgpanel.cpp
netlist_keywords.cpp
newstroke_font.cpp
../pcbnew/class_drc_item.cpp
projet_config.cpp
...
...
@@ -91,6 +92,19 @@ set(PCB_COMMON_SRCS
add_library
(
pcbcommon
${
PCB_COMMON_SRCS
}
)
# auto-generate netlist_lexer.h and netlist_keywords.cpp
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist_lexer.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist_keywords.cpp
COMMAND
${
CMAKE_COMMAND
}
-Denum=NL_T
-DinputFile=
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist.keywords
-P
${
CMAKE_MODULE_PATH
}
/TokenList2DsnLexer.cmake
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist.keywords
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist_{lexer.h,keywords.cpp}
from
${
CMAKE_CURRENT_SOURCE_DIR
}
/netlist.keywords"
)
# The dsntest may not build properly using MS Visual Studio.
if
(
NOT MSVC
)
# This one gets made only when testing.
...
...
eeschema
/netlist.keywords
→
common
/netlist.keywords
View file @
fb0bb79a
...
...
@@ -10,6 +10,8 @@ export
field
fields
footprint
footprints
fp
lib
libpart
libraries
...
...
common/richio.cpp
View file @
fb0bb79a
...
...
@@ -204,14 +204,14 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError
}
//-----<STRINGFORMATTER>----------------------------------------------------
//-----<STRING
_
FORMATTER>----------------------------------------------------
void
STRINGFORMATTER
::
write
(
const
char
*
aOutBuf
,
int
aCount
)
throw
(
IOError
)
void
STRING
_
FORMATTER
::
write
(
const
char
*
aOutBuf
,
int
aCount
)
throw
(
IOError
)
{
mystring
.
append
(
aOutBuf
,
aCount
);
}
void
STRINGFORMATTER
::
StripUseless
()
void
STRING
_
FORMATTER
::
StripUseless
()
{
std
::
string
copy
=
mystring
;
...
...
eeschema/CMakeLists.txt
View file @
fb0bb79a
...
...
@@ -157,34 +157,34 @@ endif(APPLE)
# Generate DSN lexer header and source files for the component library file
# format.
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
keywords
.h
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
lexer
.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_keywords.cpp
COMMAND
${
CMAKE_COMMAND
}
-DinputFile=
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.keywords
-P
${
CMAKE_MODULE_PATH
}
/TokenList2DsnLexer.cmake
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.keywords
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
keywords.h(.cpp)
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
{lexer.h,keywords.cpp}
from
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library.keywords"
)
set_source_files_properties
(
cmp_library_lexer.cpp
PROPERTIES
OBJECT_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
keywords
.h
OBJECT_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmp_library_
lexer
.h
)
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_
keywords
.h
OUTPUT
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_
lexer
.h
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_keywords.cpp
COMMAND
${
CMAKE_COMMAND
}
-Denum=TFIELD_T
-DinputFile=
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.keywords
-P
${
CMAKE_MODULE_PATH
}
/TokenList2DsnLexer.cmake
DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.keywords
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_
keywords.h(.cpp)
COMMENT
"creating
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames_
{lexer.h,keywords.cpp}
from
${
CMAKE_CURRENT_SOURCE_DIR
}
/template_fieldnames.keywords"
)
add_executable
(
eeschema WIN32 MACOSX_BUNDLE
${
EESCHEMA_SRCS
}
${
EESCHEMA_EXTRA_SRCS
}
${
EESCHEMA_RESOURCES
}
)
...
...
eeschema/eeschema_config.cpp
View file @
fb0bb79a
...
...
@@ -654,10 +654,7 @@ void WinEDA_SchematicFrame::LoadSettings()
if
(
!
templateFieldNames
.
IsEmpty
()
)
{
std
::
string
dsnTxt
=
CONV_TO_UTF8
(
templateFieldNames
);
DSNLEXER
lexer
(
dsnTxt
,
DSN
::
template_fieldnames_keywords
,
DSN
::
template_fieldnames_keyword_count
);
TEMPLATE_FIELDNAMES_LEXER
lexer
(
CONV_TO_UTF8
(
templateFieldNames
)
);
try
{
m_TemplateFieldNames
.
Parse
(
&
lexer
);
...
...
@@ -735,7 +732,7 @@ void WinEDA_SchematicFrame::SaveSettings()
}
// Save template fieldnames
STRINGFORMATTER
sf
;
STRING
_
FORMATTER
sf
;
m_TemplateFieldNames
.
Format
(
&
sf
,
0
);
...
...
eeschema/netform.cpp
View file @
fb0bb79a
...
...
@@ -655,6 +655,8 @@ XNODE* EXPORT_HELP::makeGenericLibParts()
wxString
sFields
=
wxT
(
"fields"
);
wxString
sDescr
=
wxT
(
"description"
);
wxString
sDocs
=
wxT
(
"docs"
);
wxString
sFprints
=
wxT
(
"footprints"
);
wxString
sFp
=
wxT
(
"fp"
);
LIB_PIN_LIST
pinList
;
LIB_FIELD_LIST
fieldList
;
...
...
@@ -680,9 +682,17 @@ XNODE* EXPORT_HELP::makeGenericLibParts()
if
(
!
lcomp
->
GetDocFileName
().
IsEmpty
()
)
xlibpart
->
AddChild
(
node
(
sDocs
,
lcomp
->
GetDocFileName
()
)
);
// @todo show the footprints here.
// (*it)->m_FootprintList
// Write the footprint list
if
(
lcomp
->
m_FootprintList
.
GetCount
()
)
{
XNODE
*
xfootprints
;
xlibpart
->
AddChild
(
xfootprints
=
node
(
sFprints
)
);
for
(
unsigned
i
=
0
;
i
<
lcomp
->
m_FootprintList
.
GetCount
();
++
i
)
{
xfootprints
->
AddChild
(
node
(
sFp
,
lcomp
->
m_FootprintList
[
i
]
)
);
}
}
//----- show the fields here ----------------------------------
fieldList
.
clear
();
...
...
eeschema/template_fieldnames.cpp
View file @
fb0bb79a
...
...
@@ -46,13 +46,13 @@ void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const thr
}
void
TEMPLATE_FIELDNAME
::
Parse
(
DSN
LEXER
*
in
)
throw
(
IOError
)
void
TEMPLATE_FIELDNAME
::
Parse
(
TEMPLATE_FIELDNAMES_
LEXER
*
in
)
throw
(
IOError
)
{
TFIELD_T
tok
;
in
->
NeedLEFT
();
// begin (name ...)
if
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
())
!=
T_name
)
if
(
(
tok
=
in
->
NextTok
())
!=
T_name
)
in
->
Expecting
(
T_name
);
in
->
NeedSYMBOLorNUMBER
();
...
...
@@ -61,11 +61,11 @@ void TEMPLATE_FIELDNAME::Parse( DSNLEXER* in ) throw( IOError )
in
->
NeedRIGHT
();
// end (name ...)
while
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
while
(
(
tok
=
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
{
// "visible" has no '(' prefix, "value" does, so T_LEFT is optional.
if
(
tok
==
T_LEFT
)
tok
=
(
TFIELD_T
)
in
->
NextTok
();
tok
=
in
->
NextTok
();
switch
(
tok
)
{
...
...
@@ -89,28 +89,28 @@ void TEMPLATE_FIELDNAME::Parse( DSNLEXER* in ) throw( IOError )
void
TEMPLATES
::
Format
(
OUTPUTFORMATTER
*
out
,
int
nestLevel
)
const
throw
(
IOError
)
{
// We'll keep this general
even though the only know use at this time
// will not want the newlines or the indentation.
// We'll keep this general
, and include the \n, even though the only known
//
use at this time
will not want the newlines or the indentation.
out
->
Print
(
nestLevel
,
"(templatefields"
);
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
m_Fields
[
i
].
Format
(
out
,
nestLevel
+
1
);
out
->
Print
(
0
,
")
\n
"
);
}
void
TEMPLATES
::
Parse
(
DSN
LEXER
*
in
)
throw
(
IOError
)
void
TEMPLATES
::
Parse
(
TEMPLATE_FIELDNAMES_
LEXER
*
in
)
throw
(
IOError
)
{
TFIELD_T
tok
;
while
(
(
tok
=
(
TFIELD_T
)
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
while
(
(
tok
=
in
->
NextTok
()
)
!=
T_RIGHT
&&
tok
!=
T_EOF
)
{
if
(
tok
==
T_LEFT
)
tok
=
(
TFIELD_T
)
in
->
NextTok
();
tok
=
in
->
NextTok
();
switch
(
tok
)
{
case
T_templatefields
:
// a token indicating class TEMPLATES.
// Be flexible regarding the starting point of the
DSN
LEXER
// Be flexible regarding the starting point of the
TEMPLATE_FIELDNAMES_
LEXER
// stream. Caller may not have read the first two tokens out of the
// stream: T_LEFT and T_templatefields, so ignore them if seen here.
break
;
...
...
eeschema/template_fieldnames.h
View file @
fb0bb79a
...
...
@@ -5,9 +5,9 @@
#include "richio.h"
#include "wxstruct.h"
#include "macros.h"
#include "template_fieldnames_
keywords
.h"
#include "template_fieldnames_
lexer
.h"
class
DSN
LEXER
;
class
TEMPLATE_FIELDNAMES_
LEXER
;
/**
...
...
@@ -71,7 +71,7 @@ struct TEMPLATE_FIELDNAME
/**
* Function Parse
* fills this object from information in the input stream \a aSpec, which
* is a
DSN
LEXER. The entire textual element spec is <br>
* is a
TEMPLATE_FIELDNAMES_
LEXER. The entire textual element spec is <br>
* (field (name _yourfieldname_)(value _yourvalue_) visible)) <br>
* The presence of value is optional, the presence of visible is optional.
* When this function is called, the input token stream given by \a aSpec
...
...
@@ -81,7 +81,7 @@ struct TEMPLATE_FIELDNAME
*
* @param aSpec is the input token stream of keywords and symbols.
*/
void
Parse
(
DSN
LEXER
*
aSpec
)
throw
(
IOError
);
void
Parse
(
TEMPLATE_FIELDNAMES_
LEXER
*
aSpec
)
throw
(
IOError
);
/**
* Function GetDefaultFieldName
...
...
@@ -110,9 +110,9 @@ public:
/**
* Function Parse
* fills this object from information in the input stream handled by
DSN
LEXER
* fills this object from information in the input stream handled by
TEMPLATE_FIELDNAMES_
LEXER
*/
void
Parse
(
DSN
LEXER
*
in
)
throw
(
IOError
);
void
Parse
(
TEMPLATE_FIELDNAMES_
LEXER
*
in
)
throw
(
IOError
);
/**
...
...
@@ -148,4 +148,3 @@ public:
};
#endif // _TEMPLATE_FIELDNAME_H_
include/dsnlexer.h
View file @
fb0bb79a
...
...
@@ -167,6 +167,62 @@ public:
delete
reader
;
}
// Some functions whose return value is best overloaded to return an enum
// in a derived class.
//-----<overload return values to tokens>------------------------------
/**
* Function NextTok
* returns the next token found in the input file or DSN_EOF when reaching
* the end of file. Users should wrap this function to return an enum
* to aid in grammar debugging while running under a debugger, but leave
* this lower level function returning an int (so the enum does not collide
* with another usage).
* @return int - the type of token found next.
* @throw IOError - only if the LINE_READER throws it.
*/
int
NextTok
()
throw
(
IOError
);
/**
* Function NeedSYMBOL
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol().
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy IsSymbol()
*/
int
NeedSYMBOL
()
throw
(
IOError
);
/**
* Function NeedSYMBOLorNUMBER
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol() or tok==DSN_NUMBER.
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy the above test
*/
int
NeedSYMBOLorNUMBER
()
throw
(
IOError
);
/**
* Function CurTok
* returns whatever NextTok() returned the last time it was called.
*/
int
CurTok
()
{
return
curTok
;
}
/**
* Function PrevTok
* returns whatever NextTok() returned the 2nd to last time it was called.
*/
int
PrevTok
()
{
return
prevTok
;
}
//-----</overload return values to tokens>-----------------------------
/**
* Function SetStringDelimiter
...
...
@@ -208,18 +264,6 @@ public:
return
old
;
}
/**
* Function NextTok
* returns the next token found in the input file or DSN_EOF when reaching
* the end of file. Users should wrap this function to return an enum
* to aid in grammar debugging while running under a debugger, but leave
* this lower level function returning an int (so the enum does not collide
* with another usage).
* @return int - the type of token found next.
* @throw IOError - only if the LINE_READER throws it.
*/
int
NextTok
()
throw
(
IOError
);
/**
* Function IsSymbol
* tests a token to see if it is a symbol. This means it cannot be a
...
...
@@ -286,26 +330,6 @@ public:
*/
void
NeedRIGHT
()
throw
(
IOError
);
/**
* Function NeedSYMBOL
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol().
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy IsSymbol()
*/
int
NeedSYMBOL
()
throw
(
IOError
);
/**
* Function NeedSYMBOLorNUMBER
* calls NextTok() and then verifies that the token read in
* satisfies bool IsSymbol() or tok==DSN_NUMBER.
* If not, an IOError is thrown.
* @return int - the actual token read in.
* @throw IOError, if the next token does not satisfy the above test
*/
int
NeedSYMBOLorNUMBER
()
throw
(
IOError
);
/**
* Function GetTokenText
* returns the C string representation of a DSN_T value.
...
...
@@ -329,15 +353,6 @@ public:
return
curText
.
c_str
();
}
/**
* Function CurTok
* returns whatever NextTok() returned the last time it was called.
*/
int
CurTok
()
{
return
curTok
;
}
/**
* Function CurLineNumber
* returns the current line number within my LINE_READER
...
...
@@ -357,15 +372,6 @@ public:
return
filename
;
}
/**
* Function PrevTok
* returns whatever NextTok() returned the 2nd to last time it was called.
*/
int
PrevTok
()
{
return
prevTok
;
}
/**
* Function CurOffset
* returns the char offset within the current line, using a 1 based index.
...
...
include/richio.h
View file @
fb0bb79a
...
...
@@ -76,7 +76,6 @@ protected:
unsigned
maxLineLength
;
unsigned
capacity
;
public
:
LINE_READER
(
unsigned
aMaxLineLength
);
...
...
@@ -85,7 +84,6 @@ public:
delete
[]
line
;
}
/**
* Function ReadLine
* reads a line of text into the buffer and increments the line number
...
...
@@ -125,7 +123,6 @@ protected:
FILE
*
fp
;
///< no ownership, no close on destruction
public
:
/**
* Constructor LINE_READER
* takes an open FILE and the size of the desired line buffer.
...
...
@@ -134,7 +131,6 @@ public:
*/
FILE_LINE_READER
(
FILE
*
aFile
,
unsigned
aMaxLineLength
);
/**
* Function ReadLine
* reads a line of text into the buffer and increments the line number
...
...
@@ -155,7 +151,6 @@ public:
rewind
(
fp
);
lineNum
=
0
;
}
};
...
...
@@ -228,6 +223,21 @@ protected:
{
}
virtual
~
OUTPUTFORMATTER
()
{}
/**
* Function GetQuoteChar
* performs quote character need determination according to the Specctra DSN
* specification.
* @param wrapee A string that might need wrapping on each end.
* @param quote_char A single character C string which provides the current
* quote character, should it be needed by the wrapee.
*
* @return const char* - the quote_char as a single character string, or ""
* if the wrapee does not need to be wrapped.
*/
static
const
char
*
GetQuoteChar
(
const
char
*
wrapee
,
const
char
*
quote_char
);
/**
* Function write
...
...
@@ -241,10 +251,10 @@ protected:
#if defined(__GNUG__) // The GNU C++ compiler defines this
// When used on a C++ function, we must account for the "this" pointer,
// so increase the STRING-INDEX and FIRST-TO_CHECK by one.
// See http://docs.freebsd.org/info/gcc/gcc.info.Function_Attributes.html
// Then to get format checking during the compile, compile with -Wall or -Wformat
// When used on a C++ function, we must account for the "this" pointer,
// so increase the STRING-INDEX and FIRST-TO_CHECK by one.
// See http://docs.freebsd.org/info/gcc/gcc.info.Function_Attributes.html
// Then to get format checking during the compile, compile with -Wall or -Wformat
#define PRINTF_FUNC __attribute__ ((format (printf, 3, 4)))
#else
...
...
@@ -253,6 +263,8 @@ protected:
public
:
//-----<interface functions>------------------------------------------
/**
* Function Print
* formats and writes text to the output stream.
...
...
@@ -287,40 +299,43 @@ public:
return
GetQuoteChar
(
wrapee
,
"
\"
"
);
}
virtual
~
OUTPUTFORMATTER
()
{}
/**
* Function GetQuoteChar
* performs quote character need determination according to the Specctra DSN
* specification.
* @param wrapee A string that might need wrapping on each end.
* @param quote_char A single character C string which provides the current
* quote character, should it be needed by the wrapee.
* Function Quoted
* checks \a aWrappee input string for a need to be quoted
* (e.g. contains a ')' character or a space), and for \" double quotes
* within the string that need to be doubled up such that the DSNLEXER
* will correctly parse the string from a file later.
*
* @return const char* - the quote_char as a single character string, or ""
* if the wrapee does not need to be wrapped.
* @param aWrapee is a string that might need wraping in double quotes,
* and it might need to have its internal quotes doubled up, or not.
* Caller's copy may be modified, or not.
*
* @return const char* - useful for passing to printf() style functions that
* must output utf8 streams.
virtual const char* Quoted( std::string* aWrapee );
thinking about using wxCharBuffer* instead.
*/
static
const
char
*
GetQuoteChar
(
const
char
*
wrapee
,
const
char
*
quote_char
);
//-----</interface functions>-----------------------------------------
};
/**
* Class STRINGFORMATTER
* Class STRING
_
FORMATTER
* implements OUTPUTFORMATTER to a memory buffer. After Print()ing the
* string is available through GetString()
*/
class
STRINGFORMATTER
:
public
OUTPUTFORMATTER
class
STRING
_
FORMATTER
:
public
OUTPUTFORMATTER
{
std
::
string
mystring
;
public
:
/**
* Constructor STRINGFORMATTER
* Constructor STRING
_
FORMATTER
* reserves space in the buffer
*/
STRINGFORMATTER
(
int
aReserve
=
300
)
:
STRING
_
FORMATTER
(
int
aReserve
=
300
)
:
OUTPUTFORMATTER
(
aReserve
)
{
}
...
...
@@ -363,7 +378,6 @@ class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
char
quoteChar
[
2
];
public
:
/**
* Constructor STREAM_OUTPUTFORMATTER
* can take any number of wxOutputStream derivations, so it can write
...
...
@@ -384,6 +398,4 @@ protected:
//-----</OUTPUTFORMATTER>-----------------------------------------------
};
#endif // RICHIO_H_
include/xnode.h
View file @
fb0bb79a
...
...
@@ -26,7 +26,6 @@
*/
#include "richio.h"
// #define WXUSINGDLL
#include <wx/xml/xml.h>
...
...
@@ -50,7 +49,7 @@ public:
/**
* Function Format
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression
.
* @param out The formatter to write to.
* @param nestLevel A multiple of the number of spaces to preceed the output with.
* @throw IOError if a system error writing the output, such as a full disk.
...
...
@@ -59,7 +58,7 @@ public:
/**
* Function FormatContents
* writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression
* writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression
.
* This is the same as Format() except that the outer wrapper is not included.
* @param out The formatter to write to.
* @param nestLevel A multiple of the number of spaces to preceed the output with.
...
...
pcbnew/specctra.cpp
View file @
fb0bb79a
...
...
@@ -51,11 +51,8 @@
#include <cstdio>
#include "specctra.h"
//#include <wx/ffile.h>
#include <wx/wfstream.h> // wxFFileOutputStream
#include "build_version.h"
...
...
@@ -3979,7 +3976,7 @@ int ELEM_HOLDER::FindElem( DSN_T aType, int instanceNum )
// a reasonably small memory price to pay for improved performance
STRINGFORMATTER
ELEM
::
sf
;
STRING
_
FORMATTER
ELEM
::
sf
;
//-----<UNIT_RES>---------------------------------------------------------
...
...
pcbnew/specctra.h
View file @
fb0bb79a
...
...
@@ -626,7 +626,7 @@ protected:
}
// avoid creating this for every compare, make static.
static
STRINGFORMATTER
sf
;
static
STRING
_
FORMATTER
sf
;
public
:
...
...
@@ -3985,7 +3985,7 @@ class SPECCTRA_DB
bool
modulesAreFlipped
;
STRINGFORMATTER
sf
;
STRING
_
FORMATTER
sf
;
STRINGS
layerIds
;
///< indexed by PCB layer number
...
...
pcbnew/specctra_export.cpp
View file @
fb0bb79a
...
...
@@ -848,7 +848,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IOErr
}
#if 0 && defined(DEBUG)
STRINGFORMATTER sf;
STRING
_
FORMATTER sf;
path->Format( &sf, 0 );
printf( "%s\n", sf.GetString().c_str() );
#endif
...
...
pcbnew/specctra_import.cpp
View file @
fb0bb79a
...
...
@@ -531,7 +531,7 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IOError )
// padstack from its name as a work around.
// Could use a STRINGFORMATTER here and convert the entire
// Could use a STRING
_
FORMATTER here and convert the entire
// wire_via to text and put that text into the exception.
wxString
psid
(
CONV_FROM_UTF8
(
wire_via
->
GetPadstackId
().
c_str
()
)
);
...
...
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