Loading new/eeschema_part_sexpr_format_EN.odt +4 B (20.6 KiB) File changed.No diff preview for this file type. View original file View changed file new/make-dir-lib-source-test-data.sh +5 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ PROP1=" (effects (at 1 34 270)(font (size .5 1) italic bold)(visible no)) )" KEYWORDS=" (keywords varistor batcave einstein)" for C in ${CATEGORIES}; do Loading @@ -79,6 +82,7 @@ for C in ${CATEGORIES}; do $PIN1 $PIN2 $PROP1 $KEYWORDS )" > $BASEDIR/$C/$P.part.$R done # also make the part without a rev: Loading @@ -93,6 +97,7 @@ for C in ${CATEGORIES}; do $PIN1 $PIN2 $PROP1 $KEYWORDS )" > $BASEDIR/$C/$P.part done done Loading new/sch_part.cpp +66 −5 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ #include <sch_sweet_parser.h> #include <sch_lpid.h> #include <sch_lib_table.h> //#include <richio.h> using namespace SCH; Loading Loading @@ -74,6 +74,11 @@ void PART::clear() delete *it; properties.clear(); keywords.clear(); contains = 0; // @todo clear the mandatory fields } Loading Loading @@ -120,12 +125,68 @@ void PART::Parse( SWEET_PARSER* aParser, LIB_TABLE* aTable ) throw( IO_ERROR, PA } #if 0 && defined(DEBUG) void PART::PropertyDelete( const wxString& aPropertyName ) throw( IO_ERROR ) { PROPERTIES::iterator it = propertyFind( aPropertyName ); if( it == properties.end() ) { wxString msg; msg.Printf( _( "Unable to find property: %s" ), aPropertyName.GetData() ); THROW_IO_ERROR( msg ); } delete *it; properties.erase( it ); return; } int main( int argc, char** argv ) PROPERTIES::iterator PART::propertyFind( const wxString& aPropertyName ) { PROPERTIES::iterator it; for( it = properties.begin(); it!=properties.end(); ++it ) if( (*it)->name == aPropertyName ) break; return it; } void PART::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const throw( IO_ERROR ) { return 0; out->Print( indent, "(part %s", partNameAndRev.c_str() ); if( extends ) out->Print( 0, " inherits %s", extends->Format().c_str() ); out->Print( 0, "\n" ); /* @todo for( int i=0; i<MANDATORY_FIELDS; ++i ) { } */ for( PROPERTIES::const_iterator it = properties.begin(); it != properties.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } if( anchor.x || anchor.y ) { out->Print( indent+1, "(anchor (at %.6g %.6g))\n", InternalToLogical( anchor.x ), InternalToLogical( anchor.y ) ); } for( GRAPHICS::const_iterator it = graphics.begin(); it != graphics.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } for( PINS::const_iterator it = pins.begin(); it != pins.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } } #endif new/sch_part.h +37 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ #include <wx/gdicmn.h> #include <deque> #include <vector> #include <set> #include <sweet_lexer.h> class OUTPUTFORMATTER; namespace SCH { Loading Loading @@ -114,6 +116,10 @@ public: {} virtual ~BASE_GRAPHIC() {} virtual void Format( OUTPUTFORMATTER* aOutputFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ) {} }; typedef std::deque<POINT> POINTS; Loading Loading @@ -278,6 +284,11 @@ public: isVisible( true ) {} /* void Format( OUTPUTFORMATTER* aOutputFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ); */ protected: PART* birthplace; ///< at which PART in inheritance chain was this PIN added POINT pos; Loading Loading @@ -309,6 +320,7 @@ namespace SCH { typedef std::vector< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< PIN* > PINS; typedef std::vector< PROPERTY* > PROPERTIES; typedef std::set< wxString > KEYWORDS; class LPID; class SWEET_PARSER; Loading Loading @@ -347,6 +359,14 @@ protected: // not likely to have C++ descendants, but protected none-the-le */ void inherit( const PART& aBasePart ); /** * Function propertyFind * searches for aPropertyName and returns a PROPERTIES::iterator which * is the found item or properties.end() if not found. */ PROPERTIES::iterator propertyFind( const wxString& aPropertyName ); POINT anchor; //PART( LIB* aOwner ); Loading Loading @@ -396,7 +416,7 @@ protected: // not likely to have C++ descendants, but protected none-the-le /// Alternate body forms. //ALTERNATES alternates; wxString keywords; KEYWORDS keywords; public: Loading Loading @@ -424,6 +444,21 @@ public: */ void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR ); /** * Function Format * outputs this PART in UTF8 encoded s-expression format to @a aFormatter. * @param aFormatter is the output sink to write to. * @param aNestLevel is the initial indent level * @param aControlBits are bit flags ORed together which control how the output * is done. */ void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits = 0 ) const throw( IO_ERROR ); void PropertyDelete( const wxString& aPropertyName ) throw( IO_ERROR ); /* void SetValue( const wxString& aValue ) { Loading new/sch_sweet_parser.cpp +227 −204 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ using namespace PR; #define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger #define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit /** Loading Loading @@ -174,10 +173,8 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E for( ; tok!=T_RIGHT; tok = NextTok() ) { if( tok==T_EOF ) Unexpected( T_EOF ); if( tok == T_LEFT ) { tok = NextTok(); // because exceptions are thrown, any 'new' allocation has to be stored Loading Loading @@ -369,6 +366,12 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E Expecting( ") | effects" ); break; case T_property_del: NeedSYMBOLorNUMBER(); me->PropertyDelete( FromUTF8() ); NeedRIGHT(); break; case T_pin: PIN* pin; pin = new PIN( me ); Loading @@ -376,18 +379,17 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E parsePin( pin ); break; case T_keywords: parseKeywords( me ); break; /* @todo case T_keywords: break; // do we want to inherit alternates? case T_alternates: break; case T_property_del: break; case T_pin_merge: break; Loading @@ -407,12 +409,37 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } } else { switch( tok ) { default: Unexpected( tok ); } } } contains |= PB(PARSED); me->contains |= contains; } void SWEET_PARSER::parseKeywords( PART* me ) { T tok; while( ( tok = NextTok() ) != T_RIGHT ) { if( !IsSymbol( tok ) && tok!=T_NUMBER ) Expecting( "symbol|number" ); // just insert them, duplicates are silently removed and tossed. me->keywords.insert( FromUTF8() ); } } void SWEET_PARSER::parseFont( FONT* me ) { /* Loading @@ -436,7 +463,7 @@ void SWEET_PARSER::parseFont( FONT* me ) tok = NextTok(); } while( tok != T_RIGHT ) for( ; tok != T_RIGHT; tok = NextTok() ) { if( tok == T_LEFT ) { Loading Loading @@ -483,8 +510,6 @@ void SWEET_PARSER::parseFont( FONT* me ) Unexpected( "bold|italic" ); } } tok = NextTok(); } } Loading Loading @@ -681,7 +706,7 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) /* (effects [PROPERTY] # Position requires an X and Y coordinates. Position coordinates can be # Position requires X and Y coordinates. Position coordinates can be # non-intergr. Angle is in degrees and defaults to 0 if not defined. (at X Y [ANGLE]) Loading Loading @@ -709,7 +734,7 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) tok = NextTok(); } while( tok != T_RIGHT ) for( ; tok != T_RIGHT; tok = NextTok() ) { if( tok != T_LEFT ) Expecting( T_LEFT ); Loading Loading @@ -743,8 +768,6 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) default: Expecting( "at|font|visible" ); } tok = NextTok(); } } Loading Loading
new/eeschema_part_sexpr_format_EN.odt +4 B (20.6 KiB) File changed.No diff preview for this file type. View original file View changed file
new/make-dir-lib-source-test-data.sh +5 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,9 @@ PROP1=" (effects (at 1 34 270)(font (size .5 1) italic bold)(visible no)) )" KEYWORDS=" (keywords varistor batcave einstein)" for C in ${CATEGORIES}; do Loading @@ -79,6 +82,7 @@ for C in ${CATEGORIES}; do $PIN1 $PIN2 $PROP1 $KEYWORDS )" > $BASEDIR/$C/$P.part.$R done # also make the part without a rev: Loading @@ -93,6 +97,7 @@ for C in ${CATEGORIES}; do $PIN1 $PIN2 $PROP1 $KEYWORDS )" > $BASEDIR/$C/$P.part done done Loading
new/sch_part.cpp +66 −5 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ #include <sch_sweet_parser.h> #include <sch_lpid.h> #include <sch_lib_table.h> //#include <richio.h> using namespace SCH; Loading Loading @@ -74,6 +74,11 @@ void PART::clear() delete *it; properties.clear(); keywords.clear(); contains = 0; // @todo clear the mandatory fields } Loading Loading @@ -120,12 +125,68 @@ void PART::Parse( SWEET_PARSER* aParser, LIB_TABLE* aTable ) throw( IO_ERROR, PA } #if 0 && defined(DEBUG) void PART::PropertyDelete( const wxString& aPropertyName ) throw( IO_ERROR ) { PROPERTIES::iterator it = propertyFind( aPropertyName ); if( it == properties.end() ) { wxString msg; msg.Printf( _( "Unable to find property: %s" ), aPropertyName.GetData() ); THROW_IO_ERROR( msg ); } delete *it; properties.erase( it ); return; } int main( int argc, char** argv ) PROPERTIES::iterator PART::propertyFind( const wxString& aPropertyName ) { PROPERTIES::iterator it; for( it = properties.begin(); it!=properties.end(); ++it ) if( (*it)->name == aPropertyName ) break; return it; } void PART::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const throw( IO_ERROR ) { return 0; out->Print( indent, "(part %s", partNameAndRev.c_str() ); if( extends ) out->Print( 0, " inherits %s", extends->Format().c_str() ); out->Print( 0, "\n" ); /* @todo for( int i=0; i<MANDATORY_FIELDS; ++i ) { } */ for( PROPERTIES::const_iterator it = properties.begin(); it != properties.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } if( anchor.x || anchor.y ) { out->Print( indent+1, "(anchor (at %.6g %.6g))\n", InternalToLogical( anchor.x ), InternalToLogical( anchor.y ) ); } for( GRAPHICS::const_iterator it = graphics.begin(); it != graphics.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } for( PINS::const_iterator it = pins.begin(); it != pins.end(); ++it ) { (*it)->Format( out, indent+1, ctl ); } } #endif
new/sch_part.h +37 −2 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ #include <wx/gdicmn.h> #include <deque> #include <vector> #include <set> #include <sweet_lexer.h> class OUTPUTFORMATTER; namespace SCH { Loading Loading @@ -114,6 +116,10 @@ public: {} virtual ~BASE_GRAPHIC() {} virtual void Format( OUTPUTFORMATTER* aOutputFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ) {} }; typedef std::deque<POINT> POINTS; Loading Loading @@ -278,6 +284,11 @@ public: isVisible( true ) {} /* void Format( OUTPUTFORMATTER* aOutputFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ); */ protected: PART* birthplace; ///< at which PART in inheritance chain was this PIN added POINT pos; Loading Loading @@ -309,6 +320,7 @@ namespace SCH { typedef std::vector< BASE_GRAPHIC* > GRAPHICS; typedef std::vector< PIN* > PINS; typedef std::vector< PROPERTY* > PROPERTIES; typedef std::set< wxString > KEYWORDS; class LPID; class SWEET_PARSER; Loading Loading @@ -347,6 +359,14 @@ protected: // not likely to have C++ descendants, but protected none-the-le */ void inherit( const PART& aBasePart ); /** * Function propertyFind * searches for aPropertyName and returns a PROPERTIES::iterator which * is the found item or properties.end() if not found. */ PROPERTIES::iterator propertyFind( const wxString& aPropertyName ); POINT anchor; //PART( LIB* aOwner ); Loading Loading @@ -396,7 +416,7 @@ protected: // not likely to have C++ descendants, but protected none-the-le /// Alternate body forms. //ALTERNATES alternates; wxString keywords; KEYWORDS keywords; public: Loading Loading @@ -424,6 +444,21 @@ public: */ void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR ); /** * Function Format * outputs this PART in UTF8 encoded s-expression format to @a aFormatter. * @param aFormatter is the output sink to write to. * @param aNestLevel is the initial indent level * @param aControlBits are bit flags ORed together which control how the output * is done. */ void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits = 0 ) const throw( IO_ERROR ); void PropertyDelete( const wxString& aPropertyName ) throw( IO_ERROR ); /* void SetValue( const wxString& aValue ) { Loading
new/sch_sweet_parser.cpp +227 −204 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ using namespace PR; #define MAX_INHERITANCE_NESTING 6 ///< max depth of inheritance, no problem going larger #define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit /** Loading Loading @@ -174,10 +173,8 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E for( ; tok!=T_RIGHT; tok = NextTok() ) { if( tok==T_EOF ) Unexpected( T_EOF ); if( tok == T_LEFT ) { tok = NextTok(); // because exceptions are thrown, any 'new' allocation has to be stored Loading Loading @@ -369,6 +366,12 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E Expecting( ") | effects" ); break; case T_property_del: NeedSYMBOLorNUMBER(); me->PropertyDelete( FromUTF8() ); NeedRIGHT(); break; case T_pin: PIN* pin; pin = new PIN( me ); Loading @@ -376,18 +379,17 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E parsePin( pin ); break; case T_keywords: parseKeywords( me ); break; /* @todo case T_keywords: break; // do we want to inherit alternates? case T_alternates: break; case T_property_del: break; case T_pin_merge: break; Loading @@ -407,12 +409,37 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E } } else { switch( tok ) { default: Unexpected( tok ); } } } contains |= PB(PARSED); me->contains |= contains; } void SWEET_PARSER::parseKeywords( PART* me ) { T tok; while( ( tok = NextTok() ) != T_RIGHT ) { if( !IsSymbol( tok ) && tok!=T_NUMBER ) Expecting( "symbol|number" ); // just insert them, duplicates are silently removed and tossed. me->keywords.insert( FromUTF8() ); } } void SWEET_PARSER::parseFont( FONT* me ) { /* Loading @@ -436,7 +463,7 @@ void SWEET_PARSER::parseFont( FONT* me ) tok = NextTok(); } while( tok != T_RIGHT ) for( ; tok != T_RIGHT; tok = NextTok() ) { if( tok == T_LEFT ) { Loading Loading @@ -483,8 +510,6 @@ void SWEET_PARSER::parseFont( FONT* me ) Unexpected( "bold|italic" ); } } tok = NextTok(); } } Loading Loading @@ -681,7 +706,7 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) /* (effects [PROPERTY] # Position requires an X and Y coordinates. Position coordinates can be # Position requires X and Y coordinates. Position coordinates can be # non-intergr. Angle is in degrees and defaults to 0 if not defined. (at X Y [ANGLE]) Loading Loading @@ -709,7 +734,7 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) tok = NextTok(); } while( tok != T_RIGHT ) for( ; tok != T_RIGHT; tok = NextTok() ) { if( tok != T_LEFT ) Expecting( T_LEFT ); Loading Loading @@ -743,8 +768,6 @@ void SWEET_PARSER::parseTextEffects( TEXT_EFFECTS* me ) default: Expecting( "at|font|visible" ); } tok = NextTok(); } } Loading