summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-08-09 00:03:43 +0000
committerAlan Conway <aconway@apache.org>2007-08-09 00:03:43 +0000
commitba57e373864d44cfae17ec8c2c9de7a55f0b4113 (patch)
treebb16616df6e2a48b9cf164a52ca30fa99f90e1fd /cpp
parentb3eb629f662dc2df11ce3981a7c4cc8ab58a8c28 (diff)
downloadqpid-python-ba57e373864d44cfae17ec8c2c9de7a55f0b4113.tar.gz
Moved Proxy generation to rubygen.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@564051 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/bootstrap3
-rw-r--r--cpp/gentools/src/org/apache/qpid/gentools/Main.java4
-rw-r--r--cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl52
-rw-r--r--cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl59
-rw-r--r--cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl51
-rw-r--r--cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl59
-rwxr-xr-xcpp/rubygen/amqpgen.rb6
-rwxr-xr-xcpp/rubygen/cppgen.rb6
-rwxr-xr-xcpp/rubygen/templates/Proxy.rb (renamed from cpp/rubygen/samples/Proxy.rb)56
-rw-r--r--cpp/src/Makefile.am55
-rwxr-xr-xcpp/src/generate.sh4
-rw-r--r--cpp/src/qpid/framing/Proxy.h1
12 files changed, 59 insertions, 297 deletions
diff --git a/cpp/bootstrap b/cpp/bootstrap
index d56ae5bef4..978aab0968 100755
--- a/cpp/bootstrap
+++ b/cpp/bootstrap
@@ -14,6 +14,9 @@ export JAVA JAVAC
perl -ne '/^(include |if |else|endif)/ or print' Makefile.am \
| make -f - abs_srcdir=`dirname $(pwd)` gen.mk > /dev/null )
+# Create initial empty Makefile include files, make will generate the real contents.
+touch src/rubygen.mk src/generate.mk
+
automake
autoconf
diff --git a/cpp/gentools/src/org/apache/qpid/gentools/Main.java b/cpp/gentools/src/org/apache/qpid/gentools/Main.java
index f1728ab290..74e1ce1ab9 100644
--- a/cpp/gentools/src/org/apache/qpid/gentools/Main.java
+++ b/cpp/gentools/src/org/apache/qpid/gentools/Main.java
@@ -233,10 +233,6 @@ public class Main
{
new File(tmplDir + Utils.fileSeparator + "AMQP_ServerOperations.h.tmpl"),
new File(tmplDir + Utils.fileSeparator + "AMQP_ClientOperations.h.tmpl"),
- new File(tmplDir + Utils.fileSeparator + "AMQP_ServerProxy.h.tmpl"),
- new File(tmplDir + Utils.fileSeparator + "AMQP_ClientProxy.h.tmpl"),
- new File(tmplDir + Utils.fileSeparator + "AMQP_ServerProxy.cpp.tmpl"),
- new File(tmplDir + Utils.fileSeparator + "AMQP_ClientProxy.cpp.tmpl"),
new File(tmplDir + Utils.fileSeparator + "AMQP_Constants.h.tmpl"),
new File(tmplDir + Utils.fileSeparator + "AMQP_MethodVersionMap.h.tmpl"),
new File(tmplDir + Utils.fileSeparator + "AMQP_MethodVersionMap.cpp.tmpl"),
diff --git a/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl b/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl
deleted file mode 100644
index 4fb49af330..0000000000
--- a/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl
+++ /dev/null
@@ -1,52 +0,0 @@
-&{AMQP_ClientProxy.cpp}
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/*
- * This file is auto-generated by ${GENERATOR} - do not modify.
- * Supported AMQP versions:
-%{VLIST} * ${major}-${minor}
- */
-#include <sstream>
-#include "AMQP_ClientProxy.h"
-#include "qpid/framing/ChannelAdapter.h"
-#include "qpid/framing/amqp_types_full.h"
-
-%{MLIST} ${cpc_method_body_include}
-
-namespace qpid {
-namespace framing {
-
-
-AMQP_ClientProxy::AMQP_ClientProxy(ChannelAdapter& ch) :
- Proxy(ch)%{CLIST} ${cpc_constructor_initializer}
- {}
-
- // Inner class instance get methods
-
-%{CLIST} ${cpc_inner_class_get_method}
-
- // Inner class implementation
-
-%{CLIST} ${cpc_inner_class_impl}
-
-}} // namespae qpid::framing
-
diff --git a/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl b/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl
deleted file mode 100644
index b6b8a19c44..0000000000
--- a/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl
+++ /dev/null
@@ -1,59 +0,0 @@
-&{AMQP_ClientProxy.h}
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/*
- * This file is auto-generated by ${GENERATOR} - do not modify.
- * Supported AMQP versions:
-%{VLIST} * ${major}-${minor}
- */
-
-#ifndef qpid_framing_AMQP_ClientProxy__
-#define qpid_framing_AMQP_ClientProxy__
-
-#include "qpid/framing/Proxy.h"
-
-namespace qpid {
-namespace framing {
-
-class AMQP_ClientProxy : public Proxy
-{
-public:
- AMQP_ClientProxy(ChannelAdapter& ch);
-
- // Inner class definitions
-
-%{CLIST} ${cph_inner_class_defn}
-
- // Inner class instance get methods
-
-%{CLIST} ${cph_inner_class_get_method}
-
-private:
- // Inner class instances
-
-%{CLIST} ${cph_inner_class_instance}
-}; /* class AMQP_ClientProxy */
-
-} /* namespace framing */
-} /* namespace qpid */
-
-#endif
diff --git a/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl b/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl
deleted file mode 100644
index 44411491db..0000000000
--- a/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl
+++ /dev/null
@@ -1,51 +0,0 @@
-&{AMQP_ServerProxy.cpp}
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/*
- * This file is auto-generated by ${GENERATOR} - do not modify.
- * Supported AMQP versions:
-%{VLIST} * ${major}-${minor}
- */
-
-#include <sstream>
-#include "AMQP_ServerProxy.h"
-#include "qpid/framing/ChannelAdapter.h"
-#include "qpid/framing/amqp_types_full.h"
-
-%{MLIST} ${spc_method_body_include}
-
-namespace qpid {
-namespace framing {
-
-AMQP_ServerProxy::AMQP_ServerProxy(ChannelAdapter& ch) :
- Proxy(ch)%{CLIST} ${spc_constructor_initializer}
- {}
-
- // Inner class instance get methods
-
-%{CLIST} ${spc_inner_class_get_method}
-
- // Inner class implementation
-
-%{CLIST} ${spc_inner_class_impl}
-
-}} // namespae qpid::framing
diff --git a/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl b/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl
deleted file mode 100644
index 454317c76f..0000000000
--- a/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl
+++ /dev/null
@@ -1,59 +0,0 @@
-&{AMQP_ServerProxy.h}
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-/*
- * This file is auto-generated by ${GENERATOR} - do not modify.
- * Supported AMQP versions:
-%{VLIST} * ${major}-${minor}
- */
-
-#ifndef qpid_framing_AMQP_ServerProxy__
-#define qpid_framing_AMQP_ServerProxy__
-
-#include "qpid/framing/Proxy.h"
-
-namespace qpid {
-namespace framing {
-
-class AMQP_ServerProxy : public Proxy
-{
-public:
- AMQP_ServerProxy(ChannelAdapter& ch);
-
- // Inner class definitions
-
-%{CLIST} ${sph_inner_class_defn}
-
- // Inner class instance get methods
-
-%{CLIST} ${sph_inner_class_get_method}
-
-private:
- // Inner class instances
-
-%{CLIST} ${sph_inner_class_instance}
-}; /* class AMQP_ServerProxy */
-
-} /* namespace framing */
-} /* namespace qpid */
-
-#endif
diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb
index 31f7544011..ae8e4c5d1c 100755
--- a/cpp/rubygen/amqpgen.rb
+++ b/cpp/rubygen/amqpgen.rb
@@ -114,7 +114,8 @@ class AmqpClass < AmqpElement
# chassis should be "client" or "server"
def methods_on(chassis)
- elements.collect("method/chassis[@name='#{chassis}']/..") { |m|
+ @cache_methods_on ||= { }
+ @cache_methods_on[chassis] ||= elements.collect("method/chassis[@name='#{chassis}']/..") { |m|
AmqpMethod.new(m,self)
}.sort_by_name
end
@@ -147,7 +148,8 @@ class AmqpRoot < AmqpElement
# Return all methods on chassis for all classes.
def methods_on(chassis)
- classes.collect { |c| c.methods_on(chassis) }.flatten
+ @cache_methods_on ||= { }
+ @cache_methods_on[chassis] ||= classes.collect { |c| c.methods_on(chassis) }.flatten
end
# Merge contents of elements.
diff --git a/cpp/rubygen/cppgen.rb b/cpp/rubygen/cppgen.rb
index 371cc7cd05..86783b4e14 100755
--- a/cpp/rubygen/cppgen.rb
+++ b/cpp/rubygen/cppgen.rb
@@ -69,8 +69,8 @@ end
# Additional methods for AmqpMethod
class AmqpMethod
def cppname() name.lcaps.cppsafe; end
- def param_names() fields.collect { |f| f.cppname }; end
- def signature() fields.collect { |f| f.cpptype+" "+f.cppname }; end
+ def param_names() @param_names ||= fields.collect { |f| f.cppname }; end
+ def signature() @signature ||= fields.collect { |f| f.cpptype+" "+f.cppname }; end
def body_name() amqp_parent.name.caps+name.caps+"Body"; end
end
@@ -96,7 +96,7 @@ class AmqpRoot
"table"=>["FieldTable", "const FieldTable&", "const FieldTable&"],
"content"=>["Content", "const Content&", "const Content&"],
"rfc1982-long-set"=>["SequenceNumberSet", "const SequenceNumberSet&", "const SequenceNumberSet&"],
- "uuid"=>["Uuid", "const Uuid&", "const Uuid&"]
+ "uuid"=>["string", "const string&"] # FIXME should be: ["Uuid", "const Uuid&", "const Uuid&"]
}
def lookup(amqptype)
diff --git a/cpp/rubygen/samples/Proxy.rb b/cpp/rubygen/templates/Proxy.rb
index f7765f3729..16824b3083 100755
--- a/cpp/rubygen/samples/Proxy.rb
+++ b/cpp/rubygen/templates/Proxy.rb
@@ -8,10 +8,9 @@ class ProxyGen < CppGen
super(outdir, amqp)
@chassis=chassis
@classname="AMQP_#{@chassis.caps}Proxy"
+ @filename="qpid/framing/#{@classname}"
end
- def include(m) gen "#include \"#{m.body_name}.h\"\n"; end
-
def proxy_member(c) c.name.lcaps+"Proxy"; end
def inner_class_decl(c)
@@ -22,6 +21,7 @@ class ProxyGen < CppGen
{
private:
ChannelAdapter& channel;
+ RequestId responseTo;
public:
// Constructors and destructors
@@ -31,7 +31,9 @@ class ProxyGen < CppGen
virtual ~#{cname}() {}
static #{cname}& get(#{@classname}& proxy) { return proxy.get#{cname}();}
-
+ // set for response correlation
+ void setResponseTo(RequestId r) { responseTo = r; }
+
// Protocol methods
EOS
indent(2) { c.methods_on(@chassis).each { |m| inner_method_decl(m) } }
@@ -39,7 +41,8 @@ EOS
end
def inner_method_decl(m)
- gen "virtual void #{m.cppname}(#{m.signature.join(",\n ")})\n\n";
+ genl "virtual RequestId #{m.cppname}(#{m.signature.join(",\n ")});"
+ genl
end
def inner_class_defn(c)
@@ -49,30 +52,16 @@ EOS
end
def inner_method_defn(m,cname)
- if m.response?
- rettype="void"
- ret=""
- sigadd=["RequestId responseTo"]
- paramadd=["channel.getVersion(), responseTo"]
- else
- rettype="RequestId"
- ret="return "
- sigadd=[]
- paramadd=["channel.getVersion()"]
- end
- sig=(m.signature+sigadd).join(", ")
- params=(paramadd+m.param_names).join(",\n ")
- gen <<EOS
-#{rettype} #{@classname}::#{cname}::#{m.cppname}(#{sig}) {
- #{ret}channel.send(new #{m.body_name}(#{params}));
-}
-
-EOS
+ genl "RequestId #{@classname}::#{cname}::#{m.cppname}(#{m.signature.join(", ")})"
+ scope {
+ params=(["channel.getVersion()"]+m.param_names).join(", ")
+ genl "return channel.send(make_shared_ptr(new #{m.body_name}(#{params})));"
+ }
end
def get_decl(c)
cname=c.name.caps
- gen " #{cname}& #{@classname}::get#{cname}();\n"
+ gen " #{cname}& get#{cname}();\n"
end
def get_defn(c)
@@ -87,7 +76,7 @@ EOS
def generate
# .h file
- h_file(@classname+".h") {
+ h_file(@filename) {
gen <<EOS
#include "qpid/framing/Proxy.h"
@@ -118,14 +107,13 @@ EOS
}
# .cpp file
- cpp_file(@classname+".cpp") {
- gen <<EOS
-#include <sstream>
-#include "#{@classname}.h"
-#include "qpid/framing/ChannelAdapter.h"
-#include "qpid/framing/amqp_types_full.h"
-EOS
- @amqp.methods_on(@chassis).each { |m| include(m) }
+ cpp_file(@filename) {
+ include "<sstream>"
+ include "#{@classname}.h"
+ include "qpid/framing/ChannelAdapter.h"
+ include "qpid/framing/amqp_types_full.h"
+ @amqp.methods_on(@chassis).each {
+ |m| include "qpid/framing/#{m.body_name}.h" }
gen <<EOS
namespace qpid {
namespace framing {
@@ -142,7 +130,7 @@ EOS
@amqp.classes.each { |c| get_defn(c) }
gen " // Inner class implementation\n\n"
@amqp.classes.each { |c| inner_class_defn(c) }
- gen "}} // namespae qpid::framing"
+ genl "}} // namespae qpid::framing"
}
end
end
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index 9018b7cb35..28b2ce04af 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -15,10 +15,10 @@ EXTRA_DIST += gen/generate.mk generate.sh $(generated_cpp) $(generated_h) \
specs=@AMQP_XML@ $(top_srcdir)/xml/cluster.xml
# Makefiles are either generated or copied from $srcdir.
-sinclude gen/generate.mk
-sinclude rubygen.mk
+include generate.mk
+include rubygen.mk
-DISTCLEANFILES=gen/generate.mk rubygen.mk
+DISTCLEANFILES=generate.mk rubygen.mk
if GENERATE
@@ -28,10 +28,10 @@ if GENERATE
gentools_dir=$(top_srcdir)/gentools
-gen/generate.mk: generate.sh $(specs) $(generator)
+generate.mk $(generated_cpp) $(generated_h): generate.timestamp
+generate.timestamp: generate.sh $(specs) $(generator)
env gentools_dir=$(gentools_dir) specs="$(specs)" $(srcdir)/generate.sh
-
-gen $(generated_cpp) $(generated_h): gen/generate.mk
+ touch $@
# Empty rule in case a generator file is renamed/removed.
$(generator):
@@ -43,21 +43,26 @@ maintainer-clean-local:
rgen_dir=$(top_srcdir)/rubygen
rgen_tdir=$(rgen_dir)/templates
-rgen_generator=$(rgen_dir)/generate $(rgen_dir)/amqpgen.rb $(rgen_dir)/cppgen.rb
-
rgen_cmd=ruby -I $(rgen_dir) $(rgen_dir)/generate
-rgen_templates=$(rgen_tdir)/method_variants.rb $(rgen_tdir)/frame_body_lists.rb $(rgen_tdir)/Session.rb
-
-rubygen.mk: $(rgen_generator) $(specs) $(rgen_templates)
- { echo "rgen_srcs= \\"; \
- for f in `$(rgen_cmd) . $(specs) $(rgen_templates) `; do echo " $$f \\"; done; \
- echo; } > $@
-
-$(rgen_srcs): rubygen.mk
+rgen_templates=$(rgen_tdir)/method_variants.rb \
+ $(rgen_tdir)/frame_body_lists.rb \
+ $(rgen_tdir)/Session.rb \
+ $(rgen_tdir)/Proxy.rb
+
+rgen_generator=$(rgen_dir)/generate \
+ $(rgen_dir)/amqpgen.rb \
+ $(rgen_dir)/cppgen.rb
+
+rubygen.mk $(rgen_srcs): rubygen.timestamp
+rubygen.timestamp: $(rgen_generator) $(specs) $(rgen_templates)
+ { echo -n "rgen_srcs= "; \
+ for f in `$(rgen_cmd) . $(specs) $(rgen_templates) `; do echo "\\"; echo -n " $$f "; done; \
+ echo; } > rubygen.mk
+ touch $@
else # !GENERATE
# If not generating, copy generated makefiles from source dir to build dir.
-gen/generate.mk:
+generate.mk:
cp $(srcdir)/$@ $@
rubygen.mk:
cp $(srcdir)/$@ $@
@@ -150,10 +155,10 @@ libqpidcommon_la_SOURCES = \
qpid/framing/Handler.h \
qpid/framing/FrameHandler.h \
qpid/framing/HandlerUpdater.h \
- gen/qpid/framing/AMQP_ClientProxy.cpp \
+ qpid/framing/AMQP_ClientProxy.cpp \
+ qpid/framing/AMQP_ServerProxy.cpp \
gen/qpid/framing/AMQP_HighestVersion.h \
gen/qpid/framing/AMQP_MethodVersionMap.cpp \
- gen/qpid/framing/AMQP_ServerProxy.cpp \
qpid/Exception.cpp \
qpid/Plugin.h \
qpid/Plugin.cpp \
@@ -413,15 +418,3 @@ nobase_include_HEADERS = \
# Force build of qpidd during dist phase so help2man will work.
dist-hook: qpidd
-# FIXME aconway 2007-08-06: Use of gch should be conditional on gcc version.
-
-# Pre compiled headers - use BUILT_SOURCES to get them built first.
-BUILT_SOURCES=qpid/framing/method_variants.h.gch
-sinclude qpid/framing/method_variants.h.gch.deps
-CLEANFILES=qpid/framing/method_variants.h.gch qpid/framing/method_variants.h.gch.deps
-
-SUFFIXES=.h.gch
-.h.h.gch:
- rm -f $@
- $(CXXCOMPILE) -MT $@ -MD -MP -MF $@.deps -fPIC -DPIC -x c++-header -c -o $@ $<
-
diff --git a/cpp/src/generate.sh b/cpp/src/generate.sh
index 2cc31ff922..3869696bc7 100755
--- a/cpp/src/generate.sh
+++ b/cpp/src/generate.sh
@@ -40,8 +40,8 @@ make_assign() {
make_assign "generator" "" $specs \
`find ../gentools \( -name '*.java' -o -name '*.tmpl' \) -print`
fi
-) > gen/generate.mk-t
-mv gen/generate.mk-t gen/generate.mk
+) > generate.mk-t
+mv generate.mk-t generate.mk
diff --git a/cpp/src/qpid/framing/Proxy.h b/cpp/src/qpid/framing/Proxy.h
index 4af496387b..279f219ddd 100644
--- a/cpp/src/qpid/framing/Proxy.h
+++ b/cpp/src/qpid/framing/Proxy.h
@@ -28,6 +28,7 @@ namespace framing {
class ChannelAdapter;
class FieldTable;
class Content;
+class Uuid;
/**
* Base class for proxies.