mirror of
https://github.com/vidarh/ruby-x11
synced 2024-12-27 09:59:21 +01:00
ruby-x11 now successfully established a connection
This commit is contained in:
parent
6f281d14ff
commit
336a418a6a
2 changed files with 24 additions and 3 deletions
|
@ -5,10 +5,28 @@
|
|||
#
|
||||
# EXAMPLE:
|
||||
# Int8.call(255) => "\xFF"
|
||||
# String8.call("hello") => "hxello\u0000\u0000\u0000"
|
||||
# String8.call("hello") => "hello"
|
||||
|
||||
module X11
|
||||
module Encode
|
||||
|
||||
# List.of(Foo)
|
||||
# In this document the List.of notation strictly means some number of
|
||||
# repetitions of the FOO encoding; the actual length of the list is encoded
|
||||
# elsewhere
|
||||
|
||||
class List
|
||||
class << self
|
||||
def of(type)
|
||||
lambda do |data|
|
||||
# X11 has other List.of(Foo) for different data types right now
|
||||
# will just throw an error until we've implemented them all.
|
||||
throw "dont know how to handle this yet"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Takes an object and uses Array#pack to
|
||||
# convert it into binary data
|
||||
def self.pack(a)
|
||||
|
@ -19,12 +37,15 @@ module X11
|
|||
# For instance, C<pack(padded('Hello'), 'Hello')> gives C<"Hello\0\0\0">.
|
||||
def self.pad(x); x + "\0"*(-x.length & 3); end
|
||||
|
||||
# Primitive Types
|
||||
Int8 = pack("c")
|
||||
Int16 = pack("s")
|
||||
Int32 = pack("l")
|
||||
Uint8 = pack("C")
|
||||
Uint16 = pack("S")
|
||||
Uint32 = pack("L")
|
||||
String8 = lambda {|a| pad(a)}
|
||||
|
||||
# LISTofFOO
|
||||
String8 = lambda{|x| self.pad(x)} # equivalent to List.of(Uint8) /w padding
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,7 +83,7 @@ module X11
|
|||
field :protocol_minor_version, Uint16
|
||||
length :auth_proto_name, Uint16
|
||||
length :auth_proto_data, Uint16
|
||||
unused 1
|
||||
unused 2
|
||||
field :auth_proto_name, String8
|
||||
field :auth_proto_data, String8
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue