early work on DLL exports for sweet lib, stop using <cstdio> which mingw seems not to like cuz snprintf()

This commit is contained in:
Dick Hollenbeck 2011-02-03 20:40:47 -06:00
parent 77c641618c
commit 2cda6f4b4f
14 changed files with 104 additions and 116 deletions

View File

@ -50,7 +50,10 @@ macro(perform_feature_checks)
# mean won't fail somewhere down the line.
check_include_file("iso646.h" HAVE_ISO646_H)
check_include_file("strings.h" HAVE_STRINGS_H)
# no place is this used, and "HAVE_STRINGS_H", if present in config.h then
# conflicts with /usr/include/python2.6/Python.h. Please rename the macro if
# re-introduce this.
# check_include_file("strings.h" HAVE_STRINGS_H)
include(CheckSymbolExists)
check_symbol_exists(strcasecmp "string.h" HAVE_STRCASECMP)
@ -68,7 +71,7 @@ macro(perform_feature_checks)
check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)
# Generate config.h.
configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/config.h.cmake
configure_file(${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
${CMAKE_BINARY_DIR}/config.h)
endmacro(perform_feature_checks)

View File

@ -35,8 +35,6 @@
#include <iso646.h>
#endif
#cmakedefine HAVE_STRINGS_H
#if defined( HAVE_STRCASECMP )
#define stricmp strcasecmp
#elif defined( HAVE_ISO_STRICMP )

View File

@ -25,7 +25,7 @@
#ifndef DSNLEXER_H_
#define DSNLEXER_H_
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>

View File

@ -37,7 +37,7 @@
// I really did not want to be dependent on wxWidgets in richio
// but the errorText needs to be wide char so wxString rules.
#include <wx/wx.h>
#include <cstdio>
#include <stdio.h>
/**
@ -56,7 +56,7 @@
// use one of the following __LOC__ defs, depending on whether your
// compiler supports __func__ or not, and how it handles __LINE__
#define __LOC__ ((std::string(__func__) + " : ") + TOSTRING(__LINE__)).c_str()
#define __LOC__ ((std::string(__func__) + "() : line ") + TOSTRING(__LINE__)).c_str()
//#define __LOC__ TOSTRING(__LINE__)
/// macro which captures the "call site" values of __FILE_ & __LOC__

View File

@ -24,6 +24,10 @@ if( STAND_ALONE )
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
# make config.h
include(PerformFeatureChecks)
perform_feature_checks()
# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )
@ -59,6 +63,7 @@ endif()
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_BINARY_DIR} )
#=====<on standby for possible C++ unit testing>================================
if( false )
@ -95,6 +100,7 @@ make_lexer(
PR
)
add_library( sweet SHARED
sch_lib_table.cpp
sch_lib_table_keywords.cpp
@ -108,7 +114,17 @@ add_library( sweet SHARED
)
target_link_libraries( sweet ${wxWidgets_LIBRARIES} )
# talk to import_export.h
set_target_properties( sweet PROPERTIES
DEFINE_SYMBOL COMPILING_DLL
)
add_executable( test_sch_lib_table test_sch_lib_table.cpp )
if( MINGW )
set_target_properties( test_sch_lib_table PROPERTIES
LINK_FLAGS -Wl,--enable-auto-import
)
endif()
target_link_libraries( test_sch_lib_table sweet )
@ -116,7 +132,7 @@ target_link_libraries( test_sch_lib_table sweet )
# if you want a Python scripting layer on top for unit testing or driving.
# reference: http://www.swig.org/Doc1.3/Introduction.html#Introduction_build_system
option( USE_SWIG "Use SWIG to build a python scripting interface (default ON)." ON)
option( USE_SWIG "Use SWIG to build a python scripting interface (default OFF)." OFF)
if( USE_SWIG )
find_package( SWIG REQUIRED )

60
new/import_export.h Normal file
View File

@ -0,0 +1,60 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef IMPORT_EXPORT_H_
#define IMPORT_EXPORT_H_
// macros which export functions from a DLL/DSO. Not yet important with GCC,
// (either linux or mingw maybe OSX), until you compile with the hidden attribute:
// -fvisibility=hidden -fvisibility-inlines-hidden, which we are not yet.
// GCC >= 4.x
#if defined(__GNUC__) && __GNUC__ >= 4
# define APIEXPORT __attribute__ ((visibility("default")))
# define APIIMPORT __attribute__ ((visibility("default")))
# define APILOCAL __attribute__ ((visibility("hidden")))
// windows
#elif (defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32))
# define APIEXPORT __declspec(dllexport)
# define APIIMPORT __declspec(dllimport)
# define APILOCAL
#else // not windows nor GCC >= 4.x
# define APIEXPORT
# define APIIMPORT
# define APILOCAL
#endif
#ifdef COMPILING_DLL // by CMake magically when compiling implementation.
# define MY_API APIEXPORT
#else
# define MY_API APIIMPORT
#endif
#define MY_LOCAL APILOCAL
#endif // IMPORT_EXPORTS_H_

View File

@ -27,6 +27,7 @@
#include <utf8.h>
#include <richio.h>
#include <import_export.h>
namespace SCH {
@ -199,7 +200,7 @@ class PARTS;
*
* @author Dick Hollenbeck
*/
class LIB
class MY_API LIB
{
friend class LIB_TABLE; ///< protected constructor, LIB_TABLE may construct

View File

@ -44,7 +44,7 @@ LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ) :
}
void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR )
void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR )
{
/* grammar:

View File

@ -28,10 +28,12 @@
#include <string>
#include <boost/ptr_container/ptr_map.hpp>
#include <import_export.h>
#include <sch_lib.h>
class SCH_LIB_TABLE_LEXER; // outside namespace SCH, since make_lexer() Functions.cmake can't do namespace
class OUTPUTFORMATTER;
class SCH_LIB_TABLE_LEXER;
namespace SCH {
@ -80,7 +82,7 @@ class PART;
*
* @author Dick Hollenbeck
*/
class LIB_TABLE
class MY_API LIB_TABLE
{
public:
@ -213,7 +215,7 @@ public:
/**
* Function Parse
* fills this table fragment from information in the input stream \a aLexer, which
* fills this table fragment from information in the input stream \a aParser, which
* is a DSNLEXER customized for the grammar needed to describe instances of this object.
* The entire textual element spec is <br>
*
@ -225,14 +227,15 @@ public:
* )
* </pre>
*
* When this function is called, the input token stream given by \a aLexer
* is assumed to be positioned at the '^' in the following example, i.e. just after the
* identifying keyword and before the content specifying stuff.<br>
* When this function is called, the input token stream given by \a aParser
* is assumed to be positioned at the '^' in the following example, i.e. just
* after the identifying keyword and before the content specifying stuff.
* <br>
* (lib_table ^ (....) )
*
* @param aLexer is the input token stream of keywords and symbols.
* @param aParser is the input token stream of keywords and symbols.
*/
void Parse( SCH_LIB_TABLE_LEXER* aLexer ) throw( IO_ERROR );
void Parse( SCH_LIB_TABLE_LEXER* aParser ) throw( IO_ERROR, PARSE_ERROR );
/**
* Function Format

View File

@ -1,15 +0,0 @@
/**
* Function GetPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to load a new LIB as given in the library table.
*/
static PART* SCH_LIBS::GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR )
{
}

View File

@ -1,81 +0,0 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef SCH_LIBS_H_
#define SCH_LIBS_H_
#include <sch_lib.h>
/**
* Class LIBS
* houses a handful of functions that manage all the RAM resident LIBs, and
* provide for a global part lookup function, GetPart(), which can be the basis
* of a cross LIB hyperlink.
*/
class LIBS
{
public:
/**
* Function GetPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to load a new LIB as given in the library table.
*/
static PART* GetPart( const LPID& aLogicalPartID ) throw( IO_ERROR );
/**
* Function GetLib
* is first a lookup function and then if needed, a factory function.
* If aLogicalLibraryName has been opened, then return the already opened
* LIB. If not, then instantiate the library and fill the initial
* library PARTs (unparsed) and categories, and add it to LIB::libraries
* for future reference.
*/
static LIB* GetLib( const STRING& aLogicalLibraryName ) throw( IO_ERROR );
/**
* Function GetOpenedLibNames
* returns the logical library names of LIBs that are already opened.
* @see LPID::GetLogicalLibraries()
*/
static STRINGS GetOpendedLogicalLibNames();
/**
* Function CloseLibrary
* closes an open library @a aLibrary and removes it from class LIBS.
*/
static void CloseLibrary( LIB* aLibrary ) throw( IO_ERROR );
private:
/// collection of LIBs, searchable by logical name.
static std::map< STRING, LIB* > libraries; // owns the LIBs.
};
#endif // SCH_LIBS_H_

View File

@ -26,6 +26,7 @@ namespace SCH {
%ignore PART::operator=( const PART& other );
}
%include "import_export.h"
%include "richio.h"
%include "dsnlexer.h"
//%include "sch_lib_table_lexer.h"

View File

@ -28,6 +28,8 @@
using namespace SCH;
// If LIB_TABLE::Test() is conditioned on DEBUG being defined, build with
// CMAKE_BUILD_TYPE=Debug, otherwise don't worry about it, because it will work
// on any CMAKE_BUILD_TYPE, including Release.

View File

@ -14,7 +14,7 @@ set( CMAKE_SYSTEM_NAME Linux )
# configure only the lines within this <configure> block, typically
# default is specific to Dick's machine, again for testing only:
set( WX_MINGW_BASE /opt/wx2.8-mingw )
set( WX_MINGW_BASE /opt/wx2.9-mingw )
# specify the cross compiler
set( CMAKE_C_COMPILER i586-mingw32msvc-gcc )
@ -37,4 +37,4 @@ set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
# try and pre-load this variable, or do it later in ccmake
set( wxWidgets_CONFIG_EXECUTABLE ${WX_MINGW_BASE}/bin/wx-config )
set( wxWidgets_CONFIG_EXECUTABLE ${WX_MINGW_BASE}/bin/wx-config )