Made fedex_plus MSVC compatible.
* Selected correct PROTO define for __MSVC__.
* Renamed static function min to minimum to prevent conflict in MSVC.
* Added condition __MSVC__ when __attribute( ( unused ) ) was used.
* Added {} in classes.c to prevent local variable definitions which
are not allowed in MSVC for c files.
* Added xgetopt.cc/xgetopt.h for getopt functionality.
* Added SCL_EXPRESS_DLL_IMPORTS/SCL_EXPPP_DLL_IMPORTS to CMakeLists.txt.
This commit is contained in:
@@ -136,7 +136,7 @@ typedef int ( *intFuncptr )();
|
||||
# define PROTO(x) x
|
||||
# else
|
||||
|
||||
# ifdef __CLCC__
|
||||
# if defined(__CLCC__) || defined(__MSVC__)
|
||||
# define PROTO(x) x
|
||||
#else
|
||||
# define PROTO(x) ()
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
|
||||
#include "hash.h"
|
||||
#include "error.h"
|
||||
#include "dict.h"
|
||||
|
||||
/************/
|
||||
/* typedefs */
|
||||
|
||||
+2
-2
@@ -583,7 +583,7 @@ SCOPEalgs_out( Scope s, int level ) {
|
||||
}
|
||||
|
||||
static int
|
||||
min( int a, int b, int c ) {
|
||||
minimum( int a, int b, int c ) {
|
||||
if( a < b ) {
|
||||
return ( ( a < c ) ? a : c );
|
||||
} else {
|
||||
@@ -619,7 +619,7 @@ copy_file_chunk( char * filename, int start, int end, int level ) {
|
||||
/* copy the rest */
|
||||
for( i = end - start; i--; ) {
|
||||
fgets( buff, 255, infile );
|
||||
fix = min( undent, strlen( buff ), strspn( buff, " " ) );
|
||||
fix = minimum( undent, strlen( buff ), strspn( buff, " " ) );
|
||||
raw( "%*s%s", indent + fix, "", buff + fix );
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ char * EXPRESSversion( void ) {
|
||||
return( "Express Language, IS (N65), October 24, 1994" );
|
||||
}
|
||||
|
||||
int skip_exp_pause = false;
|
||||
SCL_EXPRESS_EXPORT int skip_exp_pause = false;
|
||||
void exp_pause() {
|
||||
if( !skip_exp_pause ) {
|
||||
#ifdef __WIN32__
|
||||
|
||||
+3
-2
@@ -72,6 +72,7 @@
|
||||
*/
|
||||
|
||||
#include <scl_cf.h>
|
||||
#include <scl_export.h>
|
||||
#include "scl_version_string.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -79,7 +80,7 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifndef HAVE_GETOPT
|
||||
# include <xgetopt.h>
|
||||
# include "xgetopt.h"
|
||||
#endif
|
||||
#include "express/error.h"
|
||||
#include "express/express.h"
|
||||
@@ -92,7 +93,7 @@ extern int yydbg_lower_limit;
|
||||
extern int yydbg_verbose;
|
||||
#endif /*YYDEBUG*/
|
||||
|
||||
extern int skip_exp_pause;
|
||||
extern SCL_EXPRESS_EXPORT int skip_exp_pause;
|
||||
char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:u:l:nrvz";
|
||||
int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */
|
||||
|
||||
|
||||
@@ -27,10 +27,18 @@ include_directories(
|
||||
${SCL_SOURCE_DIR}/include/express
|
||||
)
|
||||
|
||||
IF(MSVC)
|
||||
set(fedex_plus_MSVC_SOURCES
|
||||
xgetopt.cc
|
||||
)
|
||||
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
|
||||
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
|
||||
add_definitions( -DYYDEBUG ) #-Ddebugging )
|
||||
ENDIF()
|
||||
|
||||
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES}" "libexppp express")
|
||||
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_MSVC_SOURCES}" "libexppp express")
|
||||
|
||||
add_dependencies( fedex_plus version_string )
|
||||
+53
-44
@@ -1279,7 +1279,6 @@ void LIBmemberFunctionPrint( Entity entity, Linked_List nonInheritedAttrList, FI
|
||||
Linked_List attr_list;
|
||||
char entnm [BUFSIZ];
|
||||
|
||||
|
||||
strncpy( entnm, ENTITYget_classname( entity ), BUFSIZ ); /* assign entnm */
|
||||
|
||||
/* 1. put in member functions which belong to all entities */
|
||||
@@ -2230,53 +2229,63 @@ void ENTITYPrint( Entity entity, FILES * files, Schema schema ) {
|
||||
|
||||
// multiple inheritance
|
||||
// collect the non inherited attributes to add to the current element
|
||||
Linked_List nonInheritedAttrList = LISTcreate();
|
||||
if (multiple_inheritance) {
|
||||
// create list of attr inherited from the parents in C++
|
||||
Linked_List inheritedAttrList = LISTcreate();
|
||||
collectAttributes(inheritedAttrList, entity, 1);
|
||||
{
|
||||
Linked_List nonInheritedAttrList = LISTcreate();
|
||||
if (multiple_inheritance) {
|
||||
// create list of attr inherited from the parents in C++
|
||||
Linked_List inheritedAttrList = LISTcreate();
|
||||
collectAttributes(inheritedAttrList, entity, 1);
|
||||
|
||||
// create list of attr that have to be inherited in EXPRESS
|
||||
Linked_List allInheritedAttrList = LISTcreate();
|
||||
collectAttributes(allInheritedAttrList, entity, -1);
|
||||
{
|
||||
// create list of attr that have to be inherited in EXPRESS
|
||||
Linked_List allInheritedAttrList = LISTcreate();
|
||||
collectAttributes(allInheritedAttrList, entity, -1);
|
||||
|
||||
// check in the curList of attr if it has been inherited,
|
||||
// if not, add it to the list of non inherited attr
|
||||
LISTdo( allInheritedAttrList, a, Variable )
|
||||
int found = 0;
|
||||
// can't use ENTITYget_named_attribute because it loops on *all* supertypes
|
||||
LISTdo( inheritedAttrList, a2, Variable )
|
||||
if( streq( VARget_simple_name( a ), VARget_simple_name( a2 ) )) {
|
||||
found = 1;
|
||||
// check in the curList of attr if it has been inherited,
|
||||
// if not, add it to the list of non inherited attr
|
||||
LISTdo( allInheritedAttrList, a, Variable )
|
||||
{
|
||||
int found = 0;
|
||||
{
|
||||
// can't use ENTITYget_named_attribute because it loops on *all* supertypes
|
||||
LISTdo( inheritedAttrList, a2, Variable )
|
||||
{
|
||||
if( streq( VARget_simple_name( a ), VARget_simple_name( a2 ) )) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
LISTod;
|
||||
}
|
||||
if (!found) {
|
||||
LISTadd_first( nonInheritedAttrList, a );
|
||||
}
|
||||
}
|
||||
LISTod;
|
||||
// clean
|
||||
LIST_destroy (inheritedAttrList);
|
||||
LIST_destroy (allInheritedAttrList);
|
||||
}
|
||||
}
|
||||
LISTod;
|
||||
if (!found) {
|
||||
LISTadd_first( nonInheritedAttrList, a );
|
||||
}
|
||||
LISTod;
|
||||
// clean
|
||||
LIST_destroy (inheritedAttrList);
|
||||
LIST_destroy (allInheritedAttrList);
|
||||
|
||||
fprintf( files->inc, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYinc_print( entity, nonInheritedAttrList, files -> inc, schema );
|
||||
fprintf( files->inc, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->names, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYnames_print( entity, files -> names, schema );
|
||||
fprintf( files->names, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->lib, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYlib_print( entity, nonInheritedAttrList, files -> lib, schema );
|
||||
fprintf( files->lib, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->init, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYincode_print( entity, files -> init, schema );
|
||||
fprintf( files->init, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
DEBUG( "DONE ENTITYPrint\n" ) ;
|
||||
LIST_destroy (nonInheritedAttrList);
|
||||
}
|
||||
|
||||
fprintf( files->inc, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYinc_print( entity, nonInheritedAttrList, files -> inc, schema );
|
||||
fprintf( files->inc, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->names, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYnames_print( entity, files -> names, schema );
|
||||
fprintf( files->names, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->lib, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYlib_print( entity, nonInheritedAttrList, files -> lib, schema );
|
||||
fprintf( files->lib, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
fprintf( files->init, "\n///////// ENTITY %s\n", n );
|
||||
ENTITYincode_print( entity, files -> init, schema );
|
||||
fprintf( files->init, "///////// END_ENTITY %s\n", n );
|
||||
|
||||
DEBUG( "DONE ENTITYPrint\n" ) ;
|
||||
LIST_destroy (nonInheritedAttrList);
|
||||
}
|
||||
|
||||
void MODELPrintConstructorBody( Entity entity, FILES * files, Schema schema
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
// XGetopt.cpp Version 1.2
|
||||
//
|
||||
// Author: Hans Dietrich
|
||||
// hdietrich2@hotmail.com
|
||||
//
|
||||
// Description:
|
||||
// XGetopt.cpp implements getopt(), a function to parse command lines.
|
||||
//
|
||||
// History
|
||||
// Version 1.2 - 2003 May 17
|
||||
// - Added Unicode support
|
||||
//
|
||||
// Version 1.1 - 2002 March 10
|
||||
// - Added example to XGetopt.cpp module header
|
||||
//
|
||||
// This software is released into the public domain.
|
||||
// You are free to use it in any way you like.
|
||||
//
|
||||
// This software is provided "as is" with no expressed
|
||||
// or implied warranty. I accept no liability for any
|
||||
// damage or loss of business that this software may cause.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// if you are using precompiled headers then include this line:
|
||||
//#include "stdafx.h"
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// if you are not using precompiled headers then include these lines:
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "XGetopt.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// X G e t o p t . c p p
|
||||
//
|
||||
//
|
||||
// NAME
|
||||
// getopt -- parse command line options
|
||||
//
|
||||
// SYNOPSIS
|
||||
// int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
|
||||
//
|
||||
// extern TCHAR *optarg;
|
||||
// extern int optind;
|
||||
//
|
||||
// DESCRIPTION
|
||||
// The getopt() function parses the command line arguments. Its
|
||||
// arguments argc and argv are the argument count and array as
|
||||
// passed into the application on program invocation. In the case
|
||||
// of Visual C++ programs, argc and argv are available via the
|
||||
// variables __argc and __argv (double underscores), respectively.
|
||||
// getopt returns the next option letter in argv that matches a
|
||||
// letter in optstring. (Note: Unicode programs should use
|
||||
// __targv instead of __argv. Also, all character and string
|
||||
// literals should be enclosed in _T( ) ).
|
||||
//
|
||||
// optstring is a string of recognized option letters; if a letter
|
||||
// is followed by a colon, the option is expected to have an argument
|
||||
// that may or may not be separated from it by white space. optarg
|
||||
// is set to point to the start of the option argument on return from
|
||||
// getopt.
|
||||
//
|
||||
// Option letters may be combined, e.g., "-ab" is equivalent to
|
||||
// "-a -b". Option letters are case sensitive.
|
||||
//
|
||||
// getopt places in the external variable optind the argv index
|
||||
// of the next argument to be processed. optind is initialized
|
||||
// to 0 before the first call to getopt.
|
||||
//
|
||||
// When all options have been processed (i.e., up to the first
|
||||
// non-option argument), getopt returns EOF, optarg will point
|
||||
// to the argument, and optind will be set to the argv index of
|
||||
// the argument. If there are no non-option arguments, optarg
|
||||
// will be set to NULL.
|
||||
//
|
||||
// The special option "--" may be used to delimit the end of the
|
||||
// options; EOF will be returned, and "--" (and everything after it)
|
||||
// will be skipped.
|
||||
//
|
||||
// RETURN VALUE
|
||||
// For option letters contained in the string optstring, getopt
|
||||
// will return the option letter. getopt returns a question mark (?)
|
||||
// when it encounters an option letter not included in optstring.
|
||||
// EOF is returned when processing is finished.
|
||||
//
|
||||
// BUGS
|
||||
// 1) Long options are not supported.
|
||||
// 2) The GNU double-colon extension is not supported.
|
||||
// 3) The environment variable POSIXLY_CORRECT is not supported.
|
||||
// 4) The + syntax is not supported.
|
||||
// 5) The automatic permutation of arguments is not supported.
|
||||
// 6) This implementation of getopt() returns EOF if an error is
|
||||
// encountered, instead of -1 as the latest standard requires.
|
||||
//
|
||||
// EXAMPLE
|
||||
// BOOL CMyApp::ProcessCommandLine(int argc, TCHAR *argv[])
|
||||
// {
|
||||
// int c;
|
||||
//
|
||||
// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
|
||||
// {
|
||||
// switch (c)
|
||||
// {
|
||||
// case _T('a'):
|
||||
// TRACE(_T("option a\n"));
|
||||
// //
|
||||
// // set some flag here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('B'):
|
||||
// TRACE( _T("option B\n"));
|
||||
// //
|
||||
// // set some other flag here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('n'):
|
||||
// TRACE(_T("option n: value=%d\n"), atoi(optarg));
|
||||
// //
|
||||
// // do something with value here
|
||||
// //
|
||||
// break;
|
||||
//
|
||||
// case _T('?'):
|
||||
// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
|
||||
// return FALSE;
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// TRACE(_T("WARNING: no handler for option %c\n"), c);
|
||||
// return FALSE;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// //
|
||||
// // check for non-option args here
|
||||
// //
|
||||
// return TRUE;
|
||||
// }
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TCHAR *optarg; // global argument pointer
|
||||
int optind = 0; // global argv index
|
||||
|
||||
int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
|
||||
{
|
||||
static TCHAR *next = NULL;
|
||||
if (optind == 0)
|
||||
next = NULL;
|
||||
|
||||
optarg = NULL;
|
||||
|
||||
if (next == NULL || *next == _T('\0'))
|
||||
{
|
||||
if (optind == 0)
|
||||
optind++;
|
||||
|
||||
if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
|
||||
{
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (_tcscmp(argv[optind], _T("--")) == 0)
|
||||
{
|
||||
optind++;
|
||||
optarg = NULL;
|
||||
if (optind < argc)
|
||||
optarg = argv[optind];
|
||||
return EOF;
|
||||
}
|
||||
|
||||
next = argv[optind];
|
||||
next++; // skip past -
|
||||
optind++;
|
||||
}
|
||||
|
||||
TCHAR c = *next++;
|
||||
TCHAR *cp = _tcschr(optstring, c);
|
||||
|
||||
if (cp == NULL || c == _T(':'))
|
||||
return _T('?');
|
||||
|
||||
cp++;
|
||||
if (*cp == _T(':'))
|
||||
{
|
||||
if (*next != _T('\0'))
|
||||
{
|
||||
optarg = next;
|
||||
next = NULL;
|
||||
}
|
||||
else if (optind < argc)
|
||||
{
|
||||
optarg = argv[optind];
|
||||
optind++;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _T('?');
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// XGetopt.h Version 1.2
|
||||
//
|
||||
// Author: Hans Dietrich
|
||||
// hdietrich2@hotmail.com
|
||||
//
|
||||
// This software is released into the public domain.
|
||||
// You are free to use it in any way you like.
|
||||
//
|
||||
// This software is provided "as is" with no expressed
|
||||
// or implied warranty. I accept no liability for any
|
||||
// damage or loss of business that this software may cause.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef XGETOPT_H
|
||||
#define XGETOPT_H
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int optind, opterr;
|
||||
extern TCHAR *optarg;
|
||||
|
||||
int getopt(int argc, TCHAR *argv[], TCHAR *optstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //XGETOPT_H
|
||||
Reference in New Issue
Block a user