Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » KiCAD
  • » [Kicad-developers] TokenList2DsnLexer.cmake [RSS Feed]

#1 June 15, 2010 07:52:09

Dick H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Kicad-developers] TokenList2DsnLexer.cmake


Wayne,

Attached is a patch against TokenList2DsnLexer.cmake that I would like
to commit.

The script takes an additional *optional* parameter named "enum" which
if provided will give the name of the enum which is declared. It seemed
like if multiple generated headers were included into a single source
file then you would have a collision on the formerly hard coded enum
name. This lets the invoker name the enum anything he/she wants.

Also changed the use case documentation to show the *.cpp file as an
OUTPUT. This is required for the calling CMake script to be happy WRT
how that *.cpp file comes into being.

OK to commit, or something very similar to it?

I thought I'd actually use it to hold the template fieldnames into a DSN
single line record that goes into the eeschema config file. It was a
way to handle variable length quantities of template fields, yet still
have them in the master config file.

Each record now holds fieldname, visibility and an optional initial
value, times an unlimited number of fields. wxConfig may break after a
few gillion fields, but this is my first plan. I will check the source
to wxConfig before I settle on this idea. I wanted an actual small use
case to use DSNLEXER and richio showing how to use them efficiently and
unobtrusively.

Dick=== modified file 'CMakeModules/TokenList2DsnLexer.cmake'
--- CMakeModules/TokenList2DsnLexer.cmake 2010-04-06 14:09:52 +0000
+++ CMakeModules/TokenList2DsnLexer.cmake 2010-06-14 21:22:06 +0000
@@ -39,23 +39,29 @@
# Usage:
#
# add_custom_command(
-# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_base.h
+# OUTPUT ${CMAKE_BINARY_DIR}/cmp_library_base.h
+# ${CMAKE_BINARY_DIR}/cmp_library_base.cpp
# COMMAND ${CMAKE_COMMAND}
-# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/token_list_file
+# -Denum=YOURTOK_T
+# -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
# -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.lst
# )
#
# Input parameters:
#
-# inputFile - The name of the token list file.
+# enum - The name of the enum to generate, defaults to DSN_T, but
+# you'll get collisions if you don't override it.
+# inputFile - The name of the token list file.
# outputPath - Optional output path to save the generated files. If not defined,
# the output path is the same path as the token list file path.
-#
+

set( tokens "" )
set( lineCount 0 )
set( dsnErrorMsg "DSN token file generator failure:" )
+
+
if( NOT EXISTS ${inputFile} )
message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." )
endif( NOT EXISTS ${inputFile} )
@@ -64,6 +70,12 @@
get_filename_component( outputPath "${inputFile}" PATH )
endif( NOT EXISTS ${outputPath} )

+if( NOT DEFINED enum )
+ set( enum DSN_T )
+endif()
+#message( STATUS "enum: ${enum}" )
+
+
# Separate the file name without extension from the full file path.
get_filename_component( result "${inputFile}" NAME_WE )

@@ -91,7 +103,7 @@

namespace DSN {

-enum DSN_T {
+enum ${enum} {

// these first few are negative special ones for syntax, and are
// inherited from DSNLEXER.
@@ -130,7 +142,6 @@
#define TOKDEF(x) { #x, T_##x }

const KEYWORD ${result}_keywords = {
-
"
)

@@ -194,7 +205,7 @@
"};


-} // End namespace DSN
+} // End namespace DSN


#endif // End ${headerTag}
@@ -208,6 +219,6 @@
const unsigned ${result}_keyword_count = DIM( ${result}_keywords );


-} // End namespace DSN
+} // End namespace DSN
"
)_______________________________________________
Mailing list:https://launchpad.net/~kicad-developersPost to : kicad-developers@lists.launchpad.net
Unsubscribe :https://launchpad.net/~kicad-developersMore help :https://help.launchpad.net/ListHelp

Offline

#2 June 15, 2010 14:35:58

Wayne S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Kicad-developers] TokenList2DsnLexer.cmake


On 6/15/2010 2:52 AM, Dick Hollenbeck wrote:
> Wayne,
>
> Attached is a patch against TokenList2DsnLexer.cmake that I would like
> to commit.
>
> The script takes an additional *optional* parameter named "enum" which
> if provided will give the name of the enum which is declared. It seemed
> like if multiple generated headers were included into a single source
> file then you would have a collision on the formerly hard coded enum
> name. This lets the invoker name the enum anything he/she wants.

I missed that one. Letting the user define the enum name makes sense to me.

>
> Also changed the use case documentation to show the *.cpp file as an
> OUTPUT. This is required for the calling CMake script to be happy WRT
> how that *.cpp file comes into being.
>
> OK to commit, or something very similar to it?

Thanks for asking. I can commit it this afternoon if this patch is what
you want committed. If you have it already queued up in your repo, feel
free to commit it.

>
> I thought I'd actually use it to hold the template fieldnames into a DSN
> single line record that goes into the eeschema config file. It was a
> way to handle variable length quantities of template fields, yet still
> have them in the master config file.

This is an interesting use case that I hadn't thought of when I wrote
the macro. This sounds like it might be useful elsewhere.

>
> Each record now holds fieldname, visibility and an optional initial
> value, times an unlimited number of fields. wxConfig may break after a
> few gillion fields, but this is my first plan. I will check the source
> to wxConfig before I settle on this idea. I wanted an actual small use
> case to use DSNLEXER and richio showing how to use them efficiently and
> unobtrusively.

I suspect that I won't be around when we hit a few gillion fields in a
configuration file so someone else will have to fix that bug :)

I apologize for being absent from the dev list recently. I have been
swamped both at work and at home. Hopefully, in the next couple of
weeks things will settle down and I'll have some more time to commit to
the project.

Wayne

>
> Dick
>
>
>
>
> _______________________________________________
> Mailing list:https://launchpad.net/~kicad-developers> Post to : kicad-develop***@*ists.launchpad.net
> Unsubscribe :https://launchpad.net/~kicad-developers> More help :https://help.launchpad.net/ListHelp_______________________________________________
Mailing list:https://launchpad.net/~kicad-developersPost to : kicad-developers@lists.launchpad.net
Unsubscribe :https://launchpad.net/~kicad-developersMore help :https://help.launchpad.net/ListHelp

Offline

#3 June 15, 2010 15:01:09

Dick H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Kicad-developers] TokenList2DsnLexer.cmake


On 06/15/2010 08:35 AM, Wayne Stambaugh wrote:
>
>> OK to commit, or something very similar to it?
>>
> Thanks for asking. I can commit it this afternoon if this patch is what
> you want committed. If you have it already queued up in your repo, feel
> free to commit it.
>

I will. I woke up this morning not liking the "_base" filename
appendages. If you want an appendage to the core filename, could you
live with "_keywords" instead of "_base"?

Dick


_______________________________________________
Mailing list:https://launchpad.net/~kicad-developersPost to : kicad-developers@lists.launchpad.net
Unsubscribe :https://launchpad.net/~kicad-developersMore help :https://help.launchpad.net/ListHelp

Offline

#4 June 15, 2010 15:18:12

Wayne S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Kicad-developers] TokenList2DsnLexer.cmake


On 6/15/2010 10:01 AM, Dick Hollenbeck wrote:
> On 06/15/2010 08:35 AM, Wayne Stambaugh wrote:
>>
>>> OK to commit, or something very similar to it?
>>>
>> Thanks for asking. I can commit it this afternoon if this patch is what
>> you want committed. If you have it already queued up in your repo, feel
>> free to commit it.
>>
>
> I will. I woke up this morning not liking the "_base" filename
> appendages. If you want an appendage to the core filename, could you
> live with "_keywords" instead of "_base"?

No problem. I used "_base" in keeping with the common practice in Kicad
of using "_base" for low level object classes. I know it's not quite
the same in this case and "_keywords" is more descriptive than "_base".

Wayne

>
> Dick
>
>
> _______________________________________________
> Mailing list:https://launchpad.net/~kicad-developers> Post to : kicad-develop***@*ists.launchpad.net
> Unsubscribe :https://launchpad.net/~kicad-developers> More help :https://help.launchpad.net/ListHelp>

_______________________________________________
Mailing list:https://launchpad.net/~kicad-developersPost to : kicad-developers@lists.launchpad.net
Unsubscribe :https://launchpad.net/~kicad-developersMore help :https://help.launchpad.net/ListHelp

Offline

#5 June 15, 2010 15:46:32

Dick H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Kicad-developers] TokenList2DsnLexer.cmake


>> I will. I woke up this morning not liking the "_base" filename
>> appendages. If you want an appendage to the core filename, could you
>> live with "_keywords" instead of "_base"?
>>
> No problem. I used "_base" in keeping with the common practice in Kicad
> of using "_base" for low level object classes. I know it's not quite
> the same in this case and "_keywords" is more descriptive than "_base".
>
> Wayne
>

Thanks for the flexibility. BTW after looking at the wx source, there
is no limits to the length of a line in the config file. But I think
the entire (dsn thingy) has to fit on a single text line, the
wxFileConfig class seems to want everything associated with a single
configuration keyword on a single line, but does not limit the line
length in any way.

So that path seems reasonable to take at this point.

Dick


_______________________________________________
Mailing list:https://launchpad.net/~kicad-developersPost to : kicad-developers@lists.launchpad.net
Unsubscribe :https://launchpad.net/~kicad-developersMore help :https://help.launchpad.net/ListHelp

Offline

  • Root
  • » KiCAD
  • » [Kicad-developers] TokenList2DsnLexer.cmake [RSS Feed]

Board footer

Moderator control

Enjoy the 19th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support