Skip to content

Add support for castxml and MSVC #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 1.4)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

IF (CMAKE_MAJOR_VERSION MATCHES "^1$")
IF (CMAKE_MINOR_VERSION MATCHES "^[56]$")
Expand Down
7 changes: 5 additions & 2 deletions Cable/CxxTypes/cxxArrayType.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ String ArrayType::GenerateDeclaration(const String& name,
*/
String ArrayType::GenerateLengthString() const
{
char buf[128];
sprintf(buf, "%lu", m_Length);
char buf[128] = "";
if (m_Length > 0)
{
sprintf(buf, "%lu", m_Length);
}
return buf;
}

Expand Down
2 changes: 1 addition & 1 deletion Cable/CxxTypes/cxxUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

// Visual C++ for-loop scoping hack.
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1700
#ifndef for
#define for if(false) {} else for
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was back from the VS 6 days (_MSC_VER < 1300). We can drop the whole block.

Expand Down
13 changes: 13 additions & 0 deletions Cable/Parsers/cableFunctionType.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ unsigned int FunctionType::GetNumberOfRequiredArguments() const
return m_RequiredArguments;
}

//----------------------------------------------------------------------------
int FunctionType::GetIndexOf(const std::string& argname) const
{
int result = -1;
std::vector<std::string>::iterator iterator = std::find(m_ArgumentNameVector.begin(), m_ArgumentNameVector.end(), argname);
if (iterator != m_ArgumentNameVector.end())
{
result = iterator - m_ArgumentNameVector.begin();
}

return result;
}

//----------------------------------------------------------------------------
Type* FunctionType::GetArgument(unsigned int index) const
{
Expand Down
5 changes: 4 additions & 1 deletion Cable/Parsers/cableFunctionType.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class CABLE_PARSERS_EXPORT FunctionType: public Type

/** Get the number of arguments without default values. */
unsigned int GetNumberOfRequiredArguments() const;


/** Get the index of an argument by name */
int GetIndexOf(const std::string& argname) const;

/** Get the argument with the given index. */
Type* GetArgument(unsigned int index) const;

Expand Down
12 changes: 12 additions & 0 deletions Cable/Parsers/cableMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ void Method::SetPureVirtual(bool s)
m_PureVirtual = s;
}

//----------------------------------------------------------------------------
bool Method::GetOverride() const
{
return m_Override;
}

//----------------------------------------------------------------------------
void Method::SetOverride(bool s)
{
m_Override = s;
}

//----------------------------------------------------------------------------
void Method::Print(std::ostream& os, Indent indent) const
{
Expand Down
7 changes: 7 additions & 0 deletions Cable/Parsers/cableMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class CABLE_PARSERS_EXPORT Method: public Function
bool GetPureVirtual() const;
void SetPureVirtual(bool s);

/** Get/Set whether the method is overridden. */
bool GetOverride() const;
void SetOverride(bool s);

/** Get/Set whether the method is const. */
bool GetConst() const;
void SetConst(bool c);
Expand All @@ -61,6 +65,9 @@ class CABLE_PARSERS_EXPORT Method: public Function
// Whether or not the method is virtual.
bool m_Virtual;

// Whether or not the method is overridden.
bool m_Override;

// Whether or not the method is static.
bool m_Static;

Expand Down
2 changes: 1 addition & 1 deletion Cable/Parsers/cableUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

// Visual C++ for-loop scoping hack. We can use this inside the CABLE
// application without interfering with user code.
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1700
#ifndef for
#define for if(false) {} else for
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was back from the VS 6 days (_MSC_VER < 1300). We can drop the whole block.

Expand Down
40 changes: 33 additions & 7 deletions Cable/Parsers/cableXMLSourceParser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@ bool XMLSourceParser::SetupNamed(XMLSourceElement* element, Named* named)
{
named->SetName("{anonymous-constructor}");
}
else if (Destructor::SafeDownCast(named))
{
named->SetName("{anonymous-destructor}");
}
else if (Converter::SafeDownCast(named))
{
named->SetName("{operator}");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please match the existing indentation scheme (2 spaces instead of a TAB).

else
{
cableErrorMacro("No name on Named object " << named->GetNameOfClass());
Expand Down Expand Up @@ -700,13 +708,24 @@ bool XMLSourceParser::SetupFunctionType(XMLSourceElement* element,
XMLSourceElement* argElement = element->GetNestedElement(i);
if(String(argElement->GetName()) == "Argument")
{
const char* typeId = argElement->GetAttribute("type");
if(!typeId)
{
cableErrorMacro("No type attribute on Argument " << i << " in "
<< element->GetName() << " " << element->GetId());
return false;
}
const char* typeId;
const char* originaltypeId = argElement->GetAttribute("original_type");
if (originaltypeId)
{
//when arrays and functions decay to a pointer type, then swap the type for the original
typeId = originaltypeId;
}
else
{
typeId = argElement->GetAttribute("type");
if (!typeId)
{
cableErrorMacro("No type attribute on Argument " << i << " in "
<< element->GetName() << " " << element->GetId());
return false;
}
}

Type* argType = this->GetTypeFromId(typeId);
if(!argType)
{
Expand Down Expand Up @@ -1348,9 +1367,15 @@ SourceObject* XMLSourceParser::AddMethod(XMLSourceElement* element)
bool isStatic = false;
bool isVirtual = false;
bool isPureVirtual = false;
bool isOverride = false;

const char* virtualAttr = element->GetAttribute("virtual");
if(virtualAttr && (String(virtualAttr) == "1")) { isVirtual = true; }
if (isVirtual)
{
const char* overridesAttr = element->GetAttribute("overrides");
if (overridesAttr && (String(overridesAttr) != "")) { isOverride = true; }
}
const char* pureVirtualAttr = element->GetAttribute("pure_virtual");
if(pureVirtualAttr && (String(pureVirtualAttr) == "1")) { isPureVirtual = true; }

Expand Down Expand Up @@ -1381,6 +1406,7 @@ SourceObject* XMLSourceParser::AddMethod(XMLSourceElement* element)
m->SetStatic(isStatic);
m->SetVirtual(isVirtual);
m->SetPureVirtual(isPureVirtual);
m->SetOverride(isOverride);

// Add the FunctionType element with a dummy id.
String fid = element->GetId();
Expand Down
2 changes: 1 addition & 1 deletion GCC_XML/KWSys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
KWSYS_IN_SOURCE_BUILD)
IF(NOT KWSYS_IN_SOURCE_BUILD)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
ENDIF(NOT KWSYS_IN_SOURCE_BUILD)

# Select plugin module file name convention.
Expand Down
12 changes: 6 additions & 6 deletions GCC_XML/KWSys/kwsysPlatformTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SET(KWSYS_PLATFORM_TEST_FILE_C kwsysPlatformTestsC.c)
SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)

MACRO(KWSYS_PLATFORM_TEST lang var description invert)
IF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
IF(${var}_COMPILED MATCHES ^${var}_COMPILED$)
MESSAGE(STATUS "${description}")
TRY_COMPILE(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -42,7 +42,7 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert)
MESSAGE(STATUS "${description} - no")
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDIF("${var}_COMPILED" MATCHES "^${var}_COMPILED$")
ENDIF(${var}_COMPILED MATCHES ^${var}_COMPILED$)
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
SET(${var} 0)
Expand All @@ -59,7 +59,7 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert)
ENDMACRO(KWSYS_PLATFORM_TEST)

MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
IF("${var}" MATCHES "^${var}$")
IF(${var} MATCHES ^${var}$)
MESSAGE(STATUS "${description}")
TRY_RUN(${var} ${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -106,7 +106,7 @@ MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
MESSAGE(STATUS "${description} - failed to compile")
ENDIF(${var}_COMPILED)
ENDIF(${invert} MATCHES INVERT)
ENDIF("${var}" MATCHES "^${var}$")
ENDIF(${var} MATCHES ^${var}$)

IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
Expand Down Expand Up @@ -150,15 +150,15 @@ ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN)
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST(CXX "${var}" "${description}" "${invert}")
KWSYS_PLATFORM_TEST(CXX ${var} ${description} ${invert})
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST)

MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS ${KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS})
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
KWSYS_PLATFORM_TEST_RUN(CXX ${var} ${description} ${invert})
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN)
Expand Down