mirror of https://github.com/apache/activemq.git
Applied Mats latest patches to get the openwire-cpp code compiling
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@382102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cc7678ee9b
commit
283549bae6
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2005-2006 The Apache Software Foundation
|
* Copyright 2005-2006 The Apache Software Foundation
|
||||||
*
|
*
|
||||||
|
@ -46,20 +46,37 @@ public abstract class OpenWireCppClassesScript extends OpenWireClassesScript {
|
||||||
if (name.equals("String")) {
|
if (name.equals("String")) {
|
||||||
return "p<string>";
|
return "p<string>";
|
||||||
}
|
}
|
||||||
|
else if (type.isArrayType()) {
|
||||||
|
if( name.equals("byte[]") )
|
||||||
|
name = "char[]" ;
|
||||||
|
else if( name.equals("DataStructure[]") )
|
||||||
|
name = "IDataStructure[]" ;
|
||||||
|
|
||||||
|
return "ap<" + name.substring(0, name.length()-2) + ">";
|
||||||
|
}
|
||||||
else if (name.equals("Throwable") || name.equals("Exception")) {
|
else if (name.equals("Throwable") || name.equals("Exception")) {
|
||||||
return "BrokerError";
|
return "p<BrokerError>";
|
||||||
}
|
}
|
||||||
else if (name.equals("ByteSequence")) {
|
else if (name.equals("ByteSequence")) {
|
||||||
return "void*";
|
return "char*";
|
||||||
}
|
}
|
||||||
else if (name.equals("boolean")) {
|
else if (name.equals("boolean")) {
|
||||||
return "bool";
|
return "bool";
|
||||||
}
|
}
|
||||||
else if (name.endsWith("Id")) {
|
else if (name.equals("long")) {
|
||||||
return "p<" + name + ">";
|
return "long long";
|
||||||
|
}
|
||||||
|
else if (name.equals("byte")) {
|
||||||
|
return "char";
|
||||||
|
}
|
||||||
|
else if( name.equals("Command") || name.equals("DataStructure") ) {
|
||||||
|
return "p<I" + name + ">" ;
|
||||||
|
}
|
||||||
|
else if( !type.isPrimitiveType() ) {
|
||||||
|
return "p<" + name + ">" ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return name;
|
return name ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +84,6 @@ public abstract class OpenWireCppClassesScript extends OpenWireClassesScript {
|
||||||
* Converts the Java type to a C++ default value
|
* Converts the Java type to a C++ default value
|
||||||
*/
|
*/
|
||||||
public String toCppDefaultValue(JClass type) {
|
public String toCppDefaultValue(JClass type) {
|
||||||
return "NULL";
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,121 +1,149 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2005-2006 The Apache Software Foundation
|
* Copyright 2005-2006 The Apache Software Foundation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import org.apache.activemq.openwire.tool.OpenWireCppHeadersScript
|
import org.apache.activemq.openwire.tool.OpenWireCppHeadersScript
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the C++ commands for the Open Wire Format
|
* Generates the C++ commands for the Open Wire Format
|
||||||
*
|
*
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class GenerateCppHeaders extends OpenWireCppHeadersScript {
|
class GenerateCppHeaders extends OpenWireCppHeadersScript {
|
||||||
|
|
||||||
void generateFile(PrintWriter out) {
|
void generateFile(PrintWriter out) {
|
||||||
out << """/*
|
out << """/*
|
||||||
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
* Copyright 2006 The Apache Software Foundation or its licensors, as
|
||||||
* applicable.
|
* applicable.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef ${className}_hpp_
|
#ifndef ${className}_hpp_
|
||||||
#define ${className}_hpp_
|
#define ${className}_hpp_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
"""
|
||||||
/* we could cut this down - for now include all possible headers */
|
if( baseClass.equals("BrokerError") )
|
||||||
#include "command/BaseCommand.hpp"
|
out << """#include "${baseClass}.hpp"
|
||||||
#include "command/BrokerId.hpp"
|
"""
|
||||||
#include "command/ConnectionId.hpp"
|
else
|
||||||
#include "command/ConsumerId.hpp"
|
out << """#include "command/${baseClass}.hpp"
|
||||||
#include "command/ProducerId.hpp"
|
|
||||||
#include "command/SessionId.hpp"
|
"""
|
||||||
|
for (property in properties)
|
||||||
#include "command/${baseClass}.hpp"
|
{
|
||||||
#include "util/ifr/p"
|
if( !property.type.isPrimitiveType() &&
|
||||||
|
property.type.simpleName != "String" &&
|
||||||
namespace apache
|
property.type.simpleName != "ByteSequence" )
|
||||||
{
|
{
|
||||||
namespace activemq
|
def includeName = toCppType(property.type)
|
||||||
{
|
if( property.type.isArrayType() )
|
||||||
namespace client
|
{
|
||||||
{
|
def arrayType = property.type.arrayComponentType ;
|
||||||
namespace command
|
if( arrayType.isPrimitiveType() )
|
||||||
{
|
continue ;
|
||||||
using namespace ifr;
|
}
|
||||||
using namespace apache::activemq::client;
|
if( includeName.startsWith("ap<") )
|
||||||
|
includeName = includeName.substring(3, includeName.length()-1) ;
|
||||||
/*
|
else if( includeName.startsWith("p<") )
|
||||||
*
|
includeName = includeName.substring(2, includeName.length()-1)
|
||||||
* Marshalling code for Open Wire Format for ${className}
|
|
||||||
*
|
if( includeName.equals("BrokerError") )
|
||||||
*
|
out << """#include "${includeName}.hpp"
|
||||||
* NOTE!: This file is autogenerated - do not modify!
|
"""
|
||||||
* if you need to make a change, please see the Groovy scripts in the
|
else
|
||||||
* activemq-core module
|
out << """#include "command/${includeName}.hpp"
|
||||||
*
|
"""
|
||||||
*/
|
}
|
||||||
class ${className} : public ${baseClass}
|
}
|
||||||
{
|
out << """
|
||||||
private:
|
#include "util/ifr/ap"
|
||||||
"""
|
#include "util/ifr/p"
|
||||||
for (property in properties) {
|
|
||||||
def type = toCppType(property.type)
|
namespace apache
|
||||||
def name = decapitalize(property.simpleName)
|
{
|
||||||
out << """ $type $name ;
|
namespace activemq
|
||||||
"""
|
{
|
||||||
}
|
namespace client
|
||||||
out << """
|
{
|
||||||
public:
|
namespace command
|
||||||
const static int TYPE = ${getOpenWireOpCode(jclass)};
|
{
|
||||||
|
using namespace ifr;
|
||||||
public:
|
using namespace std;
|
||||||
${className}() ;
|
using namespace apache::activemq::client;
|
||||||
virtual ~${className}() ;
|
|
||||||
|
/*
|
||||||
"""
|
*
|
||||||
for (property in properties) {
|
* Marshalling code for Open Wire Format for ${className}
|
||||||
def type = toCppType(property.type)
|
*
|
||||||
def propertyName = property.simpleName
|
*
|
||||||
def parameterName = decapitalize(propertyName)
|
* NOTE!: This file is autogenerated - do not modify!
|
||||||
out << """
|
* if you need to make a change, please see the Groovy scripts in the
|
||||||
virtual ${type} get${propertyName}() ;
|
* activemq-core module
|
||||||
virtual void set${propertyName}(${type} ${parameterName}) ;
|
*
|
||||||
"""
|
*/
|
||||||
}
|
class ${className} : public ${baseClass}
|
||||||
out << """
|
{
|
||||||
|
private:
|
||||||
} ;
|
"""
|
||||||
|
for (property in properties) {
|
||||||
/* namespace */
|
def type = toCppType(property.type)
|
||||||
}
|
def name = decapitalize(property.simpleName)
|
||||||
}
|
out << """ $type $name ;
|
||||||
}
|
"""
|
||||||
}
|
}
|
||||||
|
out << """
|
||||||
#endif /*${className}_hpp_*/
|
public:
|
||||||
"""
|
const static int TYPE = ${getOpenWireOpCode(jclass)};
|
||||||
}
|
|
||||||
|
public:
|
||||||
|
${className}() ;
|
||||||
|
virtual ~${className}() ;
|
||||||
|
|
||||||
|
virtual int getCommandType() ;
|
||||||
|
"""
|
||||||
|
for (property in properties) {
|
||||||
|
def type = toCppType(property.type)
|
||||||
|
def propertyName = property.simpleName
|
||||||
|
def parameterName = decapitalize(propertyName)
|
||||||
|
out << """
|
||||||
|
virtual ${type} get${propertyName}() ;
|
||||||
|
virtual void set${propertyName}(${type} ${parameterName}) ;
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
out << """
|
||||||
|
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/* namespace */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /*${className}_hpp_*/
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue