From 6cb197ee036143a671456a1999b1b6c68186062f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 9 Aug 2007 00:03:43 +0000 Subject: Moved Proxy generation to rubygen. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@564051 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/bootstrap | 3 + .../src/org/apache/qpid/gentools/Main.java | 4 - .../gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl | 52 ------- .../cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl | 59 -------- .../gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl | 51 ------- .../cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl | 59 -------- qpid/cpp/rubygen/amqpgen.rb | 6 +- qpid/cpp/rubygen/cppgen.rb | 6 +- qpid/cpp/rubygen/samples/Proxy.rb | 153 --------------------- qpid/cpp/rubygen/templates/Proxy.rb | 141 +++++++++++++++++++ qpid/cpp/src/Makefile.am | 55 ++++---- qpid/cpp/src/generate.sh | 4 +- qpid/cpp/src/qpid/framing/Proxy.h | 1 + 13 files changed, 178 insertions(+), 416 deletions(-) delete mode 100644 qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl delete mode 100644 qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl delete mode 100644 qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl delete mode 100644 qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl delete mode 100755 qpid/cpp/rubygen/samples/Proxy.rb create mode 100755 qpid/cpp/rubygen/templates/Proxy.rb (limited to 'qpid/cpp') diff --git a/qpid/cpp/bootstrap b/qpid/cpp/bootstrap index d56ae5bef4..978aab0968 100755 --- a/qpid/cpp/bootstrap +++ b/qpid/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/qpid/cpp/gentools/src/org/apache/qpid/gentools/Main.java b/qpid/cpp/gentools/src/org/apache/qpid/gentools/Main.java index f1728ab290..74e1ce1ab9 100644 --- a/qpid/cpp/gentools/src/org/apache/qpid/gentools/Main.java +++ b/qpid/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/qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl b/qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.cpp.tmpl deleted file mode 100644 index 4fb49af330..0000000000 --- a/qpid/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 -#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/qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl b/qpid/cpp/gentools/templ.cpp/AMQP_ClientProxy.h.tmpl deleted file mode 100644 index b6b8a19c44..0000000000 --- a/qpid/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/qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl b/qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.cpp.tmpl deleted file mode 100644 index 44411491db..0000000000 --- a/qpid/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 -#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/qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl b/qpid/cpp/gentools/templ.cpp/AMQP_ServerProxy.h.tmpl deleted file mode 100644 index 454317c76f..0000000000 --- a/qpid/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/qpid/cpp/rubygen/amqpgen.rb b/qpid/cpp/rubygen/amqpgen.rb index 31f7544011..ae8e4c5d1c 100755 --- a/qpid/cpp/rubygen/amqpgen.rb +++ b/qpid/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/qpid/cpp/rubygen/cppgen.rb b/qpid/cpp/rubygen/cppgen.rb index 371cc7cd05..86783b4e14 100755 --- a/qpid/cpp/rubygen/cppgen.rb +++ b/qpid/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/qpid/cpp/rubygen/samples/Proxy.rb b/qpid/cpp/rubygen/samples/Proxy.rb deleted file mode 100755 index f7765f3729..0000000000 --- a/qpid/cpp/rubygen/samples/Proxy.rb +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env ruby -$: << ".." # Include .. in load path -require 'cppgen' - -class ProxyGen < CppGen - - def initialize(chassis, outdir, amqp) - super(outdir, amqp) - @chassis=chassis - @classname="AMQP_#{@chassis.caps}Proxy" - 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) - cname=c.name.caps - gen < -#include "#{@classname}.h" -#include "qpid/framing/ChannelAdapter.h" -#include "qpid/framing/amqp_types_full.h" -EOS - @amqp.methods_on(@chassis).each { |m| include(m) } - gen <" + 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 < $@ - -$(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/qpid/cpp/src/generate.sh b/qpid/cpp/src/generate.sh index 2cc31ff922..3869696bc7 100755 --- a/qpid/cpp/src/generate.sh +++ b/qpid/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/qpid/cpp/src/qpid/framing/Proxy.h b/qpid/cpp/src/qpid/framing/Proxy.h index 4af496387b..279f219ddd 100644 --- a/qpid/cpp/src/qpid/framing/Proxy.h +++ b/qpid/cpp/src/qpid/framing/Proxy.h @@ -28,6 +28,7 @@ namespace framing { class ChannelAdapter; class FieldTable; class Content; +class Uuid; /** * Base class for proxies. -- cgit v1.2.1