summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2009-06-23 13:04:20 +0000
committerRafael H. Schloming <rhs@apache.org>2009-06-23 13:04:20 +0000
commit04047a25c6813fca28da27439d901f6977e618e2 (patch)
treec79107847b8da58ce46a03b9ec965b386c575938
parent88b6b472b53db97defafe87d658f97ec0f78cd38 (diff)
downloadqpid-python-04047a25c6813fca28da27439d901f6977e618e2.tar.gz
renamed the type field of structs to st_type so it won't conflict with struct fields
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@787663 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--ruby/examples/hello-world.rb4
-rw-r--r--ruby/lib/qpid/codec.rb8
-rw-r--r--ruby/lib/qpid/datatypes.rb10
-rw-r--r--ruby/lib/qpid/delegates.rb2
-rw-r--r--ruby/lib/qpid/session.rb8
-rw-r--r--ruby/tests/connection.rb13
6 files changed, 29 insertions, 16 deletions
diff --git a/ruby/examples/hello-world.rb b/ruby/examples/hello-world.rb
index 755d13bd54..e8ef673316 100644
--- a/ruby/examples/hello-world.rb
+++ b/ruby/examples/hello-world.rb
@@ -36,7 +36,9 @@ ssn = conn.session("test")
# create a queue
ssn.queue_declare("test-queue")
-# publish a message
+ssn.exchange_declare("test-exchange", :type => "direct")
+
+# Publish a message
dp = ssn.delivery_properties(:routing_key => "test-queue")
mp = ssn.message_properties(:content_type => "text/plain")
msg = Qpid::Message.new(dp, mp, "Hello World!")
diff --git a/ruby/lib/qpid/codec.rb b/ruby/lib/qpid/codec.rb
index 009b1eef53..e63323158e 100644
--- a/ruby/lib/qpid/codec.rb
+++ b/ruby/lib/qpid/codec.rb
@@ -370,7 +370,7 @@ module Qpid
end
def write_struct32(value)
- type = value.type
+ type = value.st_type
sc = StringCodec.new(@spec)
sc.write_uint16(type.code)
type.encode_fields(sc, value)
@@ -383,7 +383,7 @@ module Qpid
end
def write_control(ctrl)
- type = ctrl.type
+ type = ctrl.st_type
write_uint16(type.code)
type.encode_fields(self, ctrl)
end
@@ -396,9 +396,9 @@ module Qpid
end
def write_command(hdr, cmd)
- type = cmd.type
+ type = cmd.st_type
write_uint16(type.code)
- hdr.type.encode(self, hdr)
+ hdr.st_type.encode(self, hdr)
type.encode_fields(self, cmd)
end
diff --git a/ruby/lib/qpid/datatypes.rb b/ruby/lib/qpid/datatypes.rb
index 96afe58dee..418388c73a 100644
--- a/ruby/lib/qpid/datatypes.rb
+++ b/ruby/lib/qpid/datatypes.rb
@@ -54,12 +54,12 @@ module Qpid
[type.name, unexpected]
end
- attrs[:type] = type
+ attrs[:st_type] = type
attrs[:id] = nil
name = "Qpid_" + type.name.to_s.capitalize
unless ::Struct.const_defined?(name)
- vars = type.fields.collect { |f| f.name } << :type << :id
+ vars = type.fields.collect { |f| f.name } << :st_type << :id
::Struct.new(name, *vars)
end
st = ::Struct.const_get(name)
@@ -90,13 +90,13 @@ module Qpid
def get(name)
if @headers
name = name.to_sym
- @headers.find { |h| h.type.name == name }
+ @headers.find { |h| h.st_type.name == name }
end
end
def set(header)
@headers ||= []
- if h = @headers.find { |h| h.type == header.type }
+ if h = @headers.find { |h| h.st_type == header.st_type }
ind = @headers.index(h)
@headers[ind] = header
else
@@ -107,7 +107,7 @@ module Qpid
def clear(name)
if @headers
name = name.to_sym
- @headers.delete_if { |h| h.type.name == name }
+ @headers.delete_if { |h| h.st_type.name == name }
end
end
diff --git a/ruby/lib/qpid/delegates.rb b/ruby/lib/qpid/delegates.rb
index 6d655067ef..f779047e05 100644
--- a/ruby/lib/qpid/delegates.rb
+++ b/ruby/lib/qpid/delegates.rb
@@ -44,7 +44,7 @@ module Qpid
if seg.track == @control
ctl = seg.decode(@spec)
log.debug("RECV %s", ctl) if log
- attr = ctl.type.name
+ attr = ctl.st_type.name
method(attr).call(ch, ctl)
elsif ssn.nil?
ch.session_detached
diff --git a/ruby/lib/qpid/session.rb b/ruby/lib/qpid/session.rb
index 1b4d78814a..d693b722c2 100644
--- a/ruby/lib/qpid/session.rb
+++ b/ruby/lib/qpid/session.rb
@@ -277,13 +277,13 @@ module Qpid
end
log.debug("RECV %s %s %s" % [cmd.id, hdr, cmd]) if log
- if cmd.type.payload
- result = @delegate.send(cmd.type.name, cmd, header, body)
+ if cmd.st_type.payload
+ result = @delegate.send(cmd.st_type.name, cmd, header, body)
else
- result = @delegate.send(cmd.type.name, cmd)
+ result = @delegate.send(cmd.st_type.name, cmd)
end
- unless cmd.type.result.nil?
+ unless cmd.st_type.result.nil?
execution_result(cmd.id, result)
end
diff --git a/ruby/tests/connection.rb b/ruby/tests/connection.rb
index ab892d8e53..c2a851ec0a 100644
--- a/ruby/tests/connection.rb
+++ b/ruby/tests/connection.rb
@@ -49,7 +49,7 @@ class MockSession < Qpid::Session::Delegate
end
def queue_query(qq)
- return qq.type.result.create(qq.queue)
+ return qq.st_type.result.create(qq.queue)
end
def message_transfer(cmd, headers, body)
@@ -64,6 +64,10 @@ class MockSession < Qpid::Session::Delegate
@queue.put([cmd, headers, body])
end
end
+
+ def exchange_declare(ed)
+ # do nothing
+ end
end
class TestConnectionTest < Test::Unit::TestCase
@@ -232,4 +236,11 @@ class TestConnectionTest < Test::Unit::TestCase
:message => Qpid::Message.new("test"))
s.sync(10)
end
+
+ def test_exchange_declare
+ c = connect
+ c.start(10)
+ s = c.session("test")
+ s.exchange_declare("test-exchange")
+ end
end