Hello community,

here is the log from the commit of package rubygem-ffi for openSUSE:Factory 
checked in at 2017-01-25 23:28:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-ffi (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-ffi.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-ffi"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-ffi/rubygem-ffi.changes  2016-07-20 
09:26:05.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-ffi.new/rubygem-ffi.changes     
2017-01-25 23:28:24.376906847 +0100
@@ -1,0 +2,6 @@
+Sat Jan 14 05:31:31 UTC 2017 - co...@suse.com
+
+- updated to version 1.9.17
+ see installed ChangeLog
+
+-------------------------------------------------------------------

Old:
----
  ffi-1.9.14.gem

New:
----
  ffi-1.9.17.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-ffi.spec ++++++
--- /var/tmp/diff_new_pack.OZfdLp/_old  2017-01-25 23:28:24.820839928 +0100
+++ /var/tmp/diff_new_pack.OZfdLp/_new  2017-01-25 23:28:24.824839326 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-ffi
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-ffi
-Version:        1.9.14
+Version:        1.9.17
 Release:        0
 %define mod_name ffi
 %define mod_full_name %{mod_name}-%{version}

++++++ ffi-1.9.14.gem -> ffi-1.9.17.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2016-07-12 00:05:13.000000000 +0200
+++ new/README.md       2017-01-13 20:44:08.000000000 +0100
@@ -43,6 +43,8 @@
 * A C compiler (e.g. Xcode on OSX, gcc on everything else)
 * libffi development library - this is commonly in the libffi-dev or 
libffi-devel
 
+On Linux systems running with [PaX](https://en.wikipedia.org/wiki/PaX) 
(Gentoo, Alpine, etc.) FFI may trigger `mprotrect` errors. You may need to 
disable 
[mprotect](https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options#Restrict_mprotect.28.29)
 for ruby (`paxctl -m [/path/to/ruby]`) for the time being until a solution is 
found.
+
 ## Installation
 
 From rubygems:
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/ffi_c/AbstractMemory.c 
new/ext/ffi_c/AbstractMemory.c
--- old/ext/ffi_c/AbstractMemory.c      2016-07-12 00:05:13.000000000 +0200
+++ new/ext/ffi_c/AbstractMemory.c      2017-01-13 20:44:08.000000000 +0100
@@ -49,6 +49,9 @@
 #include "Function.h"
 #include "LongDouble.h"
 
+#ifndef PRIsVALUE
+# define PRIsVALUE "s"
+#endif
 
 static inline char* memory_address(VALUE self);
 VALUE rbffi_AbstractMemoryClass = Qnil;
@@ -310,7 +313,7 @@
  * @return [Numeric]
  */
 static VALUE
-memory_size(VALUE self) 
+memory_size(VALUE self)
 {
     AbstractMemory* ptr;
 
@@ -320,6 +323,72 @@
 }
 
 /*
+ * call-seq: memory.get(type, offset)
+ * Return data of given type contained in memory.
+ * @param [Symbol, Type] type_name type of data to get
+ * @param [Numeric] offset point in buffer to start from
+ * @return [Object]
+ * @raise {ArgumentError} if type is not supported
+ */
+static VALUE
+memory_get(VALUE self, VALUE type_name, VALUE offset)
+{
+    AbstractMemory* ptr;
+    VALUE nType;
+    Type *type;
+
+    nType = rbffi_Type_Lookup(type_name);
+    if(NIL_P(nType)) goto undefined_type;
+
+    Data_Get_Struct(self, AbstractMemory, ptr);
+    Data_Get_Struct(nType, Type, type);
+
+    MemoryOp *op = get_memory_op(type);
+    if(op == NULL) goto undefined_type;
+
+    return op->get(ptr, NUM2LONG(offset));
+
+undefined_type: {
+    VALUE msg = rb_sprintf("undefined type '%" PRIsVALUE "'", type_name);
+    rb_exc_raise(rb_exc_new3(rb_eArgError, msg));
+    return Qnil;
+  }
+}
+
+/*
+ * call-seq: memory.put(type, offset, value)
+ * @param [Symbol, Type] type_name type of data to put
+ * @param [Numeric] offset point in buffer to start from
+ * @return [nil]
+ * @raise {ArgumentError} if type is not supported
+ */
+static VALUE
+memory_put(VALUE self, VALUE type_name, VALUE offset, VALUE value)
+{
+    AbstractMemory* ptr;
+    VALUE nType;
+    Type *type;
+
+    nType = rbffi_Type_Lookup(type_name);
+    if(NIL_P(nType)) goto undefined_type;
+
+    Data_Get_Struct(self, AbstractMemory, ptr);
+    Data_Get_Struct(nType, Type, type);
+
+    MemoryOp *op = get_memory_op(type);
+    if(op == NULL) goto undefined_type;
+
+    op->put(ptr, NUM2LONG(offset), value);
+    return Qnil;
+
+undefined_type: {
+    VALUE msg = rb_sprintf("unsupported type '%" PRIsVALUE "'", type_name);
+    rb_exc_raise(rb_exc_new3(rb_eArgError, msg));
+    return Qnil;
+  }
+}
+
+/*
  * call-seq: memory.get_string(offset, length=nil)
  * Return string contained in memory.
  * @param [Numeric] offset point in buffer to start from
@@ -1018,6 +1087,9 @@
     rb_define_method(classMemory, "write_bytes", memory_write_bytes, -1);
     rb_define_method(classMemory, "get_array_of_string", 
memory_get_array_of_string, -1);
 
+    rb_define_method(classMemory, "get", memory_get, 2);
+    rb_define_method(classMemory, "put", memory_put, 3);
+
     rb_define_method(classMemory, "clear", memory_clear, 0);
     rb_define_method(classMemory, "total", memory_size, 0);
     rb_define_alias(classMemory, "size", "total");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/ffi/platform/x86_64-openbsd/types.conf 
new/lib/ffi/platform/x86_64-openbsd/types.conf
--- old/lib/ffi/platform/x86_64-openbsd/types.conf      2016-07-12 
00:05:14.000000000 +0200
+++ new/lib/ffi/platform/x86_64-openbsd/types.conf      2017-01-13 
20:44:08.000000000 +0100
@@ -26,44 +26,48 @@
 rbx.platform.typedef.__uintptr_t = ulong
 rbx.platform.typedef.__intmax_t = long_long
 rbx.platform.typedef.__uintmax_t = ulong_long
-rbx.platform.typedef.__register_t = int
+rbx.platform.typedef.__register_t = long
 rbx.platform.typedef.__vaddr_t = ulong
 rbx.platform.typedef.__paddr_t = ulong
 rbx.platform.typedef.__vsize_t = ulong
 rbx.platform.typedef.__psize_t = ulong
-rbx.platform.typedef.__clock_t = int
-rbx.platform.typedef.__clockid_t = int
-rbx.platform.typedef.__off_t = long_long
 rbx.platform.typedef.__ptrdiff_t = long
 rbx.platform.typedef.__size_t = ulong
 rbx.platform.typedef.__ssize_t = long
-rbx.platform.typedef.__time_t = int
-rbx.platform.typedef.__timer_t = int
 rbx.platform.typedef.__wchar_t = int
 rbx.platform.typedef.__wint_t = int
 rbx.platform.typedef.__rune_t = int
 rbx.platform.typedef.__wctrans_t = pointer
 rbx.platform.typedef.__wctype_t = pointer
+rbx.platform.typedef.__blkcnt_t = long_long
+rbx.platform.typedef.__blksize_t = int
+rbx.platform.typedef.__clock_t = long_long
+rbx.platform.typedef.__clockid_t = int
 rbx.platform.typedef.__cpuid_t = ulong
 rbx.platform.typedef.__dev_t = int
 rbx.platform.typedef.__fixpt_t = uint
+rbx.platform.typedef.__fsblkcnt_t = ulong_long
+rbx.platform.typedef.__fsfilcnt_t = ulong_long
 rbx.platform.typedef.__gid_t = uint
 rbx.platform.typedef.__id_t = uint
 rbx.platform.typedef.__in_addr_t = uint
 rbx.platform.typedef.__in_port_t = ushort
-rbx.platform.typedef.__ino_t = uint
+rbx.platform.typedef.__ino_t = ulong_long
 rbx.platform.typedef.__key_t = long
 rbx.platform.typedef.__mode_t = uint
 rbx.platform.typedef.__nlink_t = uint
+rbx.platform.typedef.__off_t = long_long
 rbx.platform.typedef.__pid_t = int
 rbx.platform.typedef.__rlim_t = ulong_long
 rbx.platform.typedef.__sa_family_t = uchar
 rbx.platform.typedef.__segsz_t = int
 rbx.platform.typedef.__socklen_t = uint
+rbx.platform.typedef.__suseconds_t = long
 rbx.platform.typedef.__swblk_t = int
+rbx.platform.typedef.__time_t = long_long
+rbx.platform.typedef.__timer_t = int
 rbx.platform.typedef.__uid_t = uint
 rbx.platform.typedef.__useconds_t = uint
-rbx.platform.typedef.__suseconds_t = int
 rbx.platform.typedef.u_char = uchar
 rbx.platform.typedef.u_short = ushort
 rbx.platform.typedef.u_int = uint
@@ -73,7 +77,7 @@
 rbx.platform.typedef.uint = uint
 rbx.platform.typedef.ulong = ulong
 rbx.platform.typedef.cpuid_t = ulong
-rbx.platform.typedef.register_t = int
+rbx.platform.typedef.register_t = long
 rbx.platform.typedef.int8_t = char
 rbx.platform.typedef.uint8_t = uchar
 rbx.platform.typedef.int16_t = short
@@ -82,8 +86,6 @@
 rbx.platform.typedef.uint32_t = uint
 rbx.platform.typedef.int64_t = long_long
 rbx.platform.typedef.uint64_t = ulong_long
-rbx.platform.typedef.intptr_t = long
-rbx.platform.typedef.uintptr_t = ulong
 rbx.platform.typedef.u_int8_t = uchar
 rbx.platform.typedef.u_int16_t = ushort
 rbx.platform.typedef.u_int32_t = uint
@@ -95,34 +97,38 @@
 rbx.platform.typedef.paddr_t = ulong
 rbx.platform.typedef.vsize_t = ulong
 rbx.platform.typedef.psize_t = ulong
+rbx.platform.typedef.blkcnt_t = long_long
+rbx.platform.typedef.blksize_t = int
 rbx.platform.typedef.caddr_t = string
-rbx.platform.typedef.daddr_t = int
 rbx.platform.typedef.daddr32_t = int
-rbx.platform.typedef.daddr64_t = long_long
+rbx.platform.typedef.daddr_t = long_long
 rbx.platform.typedef.dev_t = int
 rbx.platform.typedef.fixpt_t = uint
 rbx.platform.typedef.gid_t = uint
 rbx.platform.typedef.id_t = uint
-rbx.platform.typedef.ino_t = uint
+rbx.platform.typedef.ino_t = ulong_long
 rbx.platform.typedef.key_t = long
 rbx.platform.typedef.mode_t = uint
 rbx.platform.typedef.nlink_t = uint
-rbx.platform.typedef.pid_t = int
 rbx.platform.typedef.rlim_t = ulong_long
 rbx.platform.typedef.segsz_t = int
 rbx.platform.typedef.swblk_t = int
 rbx.platform.typedef.uid_t = uint
 rbx.platform.typedef.useconds_t = uint
-rbx.platform.typedef.suseconds_t = int
+rbx.platform.typedef.suseconds_t = long
+rbx.platform.typedef.fsblkcnt_t = ulong_long
+rbx.platform.typedef.fsfilcnt_t = ulong_long
 rbx.platform.typedef.in_addr_t = uint
 rbx.platform.typedef.in_port_t = ushort
-rbx.platform.typedef.sa_family_t = uchar
-rbx.platform.typedef.socklen_t = uint
-rbx.platform.typedef.clock_t = int
+rbx.platform.typedef.clock_t = long_long
 rbx.platform.typedef.clockid_t = int
+rbx.platform.typedef.pid_t = int
 rbx.platform.typedef.size_t = ulong
 rbx.platform.typedef.ssize_t = long
-rbx.platform.typedef.time_t = int
+rbx.platform.typedef.time_t = long_long
 rbx.platform.typedef.timer_t = int
 rbx.platform.typedef.off_t = long_long
-rbx.platform.typedef.__fd_mask = int
+rbx.platform.typedef.__fd_mask = uint
+rbx.platform.typedef.sigset_t = uint
+rbx.platform.typedef.socklen_t = uint
+rbx.platform.typedef.sa_family_t = uchar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/ffi/pointer.rb new/lib/ffi/pointer.rb
--- old/lib/ffi/pointer.rb      2016-07-12 00:05:14.000000000 +0200
+++ new/lib/ffi/pointer.rb      2017-01-13 20:44:08.000000000 +0100
@@ -130,5 +130,31 @@
       }
       self
     end
+
+    # @return [self]
+    def to_ptr
+      self
+    end
+
+    # @param [Symbol,Type] type of data to read
+    # @return [Object]
+    # Read pointer's contents as +type+
+    #
+    # Same as:
+    #  ptr.get(type, 0)
+    def read(type)
+      get(type, 0)
+    end
+
+    # @param [Symbol,Type] type of data to read
+    # @param [Object] value to write
+    # @return [nil]
+    # Write +value+ of type +type+ to pointer's content
+    #
+    # Same as:
+    #  ptr.put(type, 0)
+    def write(type, value)
+      put(type, 0, value)
+    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/ffi/version.rb new/lib/ffi/version.rb
--- old/lib/ffi/version.rb      2016-07-12 00:05:14.000000000 +0200
+++ new/lib/ffi/version.rb      2017-01-13 20:44:08.000000000 +0100
@@ -1,4 +1,4 @@
 module FFI
-  VERSION = '1.9.14'
+  VERSION = '1.9.17'
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2016-07-12 00:05:13.000000000 +0200
+++ new/metadata        2017-01-13 20:44:08.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: ffi
 version: !ruby/object:Gem::Version
-  version: 1.9.14
+  version: 1.9.17
 platform: ruby
 authors:
 - Wayne Meissner
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2016-07-11 00:00:00.000000000 Z
+date: 2017-01-13 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: rake
@@ -570,7 +570,7 @@
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.5.1
+rubygems_version: 2.6.8
 signing_key: 
 specification_version: 4
 summary: Ruby FFI
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/ffi/pointer_spec.rb new/spec/ffi/pointer_spec.rb
--- old/spec/ffi/pointer_spec.rb        2016-07-12 00:05:14.000000000 +0200
+++ new/spec/ffi/pointer_spec.rb        2017-01-13 20:44:08.000000000 +0100
@@ -62,6 +62,13 @@
     expect { PointerTestLib.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.to 
raise_error
   end
 
+  it "#to_ptr" do
+    memory = FFI::MemoryPointer.new :pointer
+    expect(memory.to_ptr).to eq(memory)
+
+    expect(FFI::Pointer::NULL.to_ptr).to eq(FFI::Pointer::NULL)
+  end
+
   describe "pointer type methods" do
 
     it "#read_pointer" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/ffi/rbx/memory_pointer_spec.rb 
new/spec/ffi/rbx/memory_pointer_spec.rb
--- old/spec/ffi/rbx/memory_pointer_spec.rb     2016-07-12 00:05:14.000000000 
+0200
+++ new/spec/ffi/rbx/memory_pointer_spec.rb     2017-01-13 20:44:08.000000000 
+0100
@@ -52,12 +52,76 @@
     m = FFI::MemoryPointer.new(:int)
     m.write_int(1)
     expect(m.read_int).to eq(1)
+    expect(m.read :int).to eq(1)
+    expect(m.read FFI::Type::INT).to eq(1)
   end
-  
+
+  it "allows writing as a sized int" do
+    m = FFI::MemoryPointer.new(:uint32)
+    m.write_uint32(1)
+    expect(m.read_uint32).to eq(1)
+    expect(m.read :uint32).to eq(1)
+    expect(m.read FFI::Type::UINT32).to eq(1)
+
+    m = FFI::MemoryPointer.new(:uint32)
+    m.write :uint32, 1
+    expect(m.read :uint32).to eq(1)
+
+    m = FFI::MemoryPointer.new(:int64)
+    m.write_int64(1)
+    expect(m.read_int64).to eq(1)
+    expect(m.read :int64).to eq(1)
+    expect(m.read FFI::Type::INT64).to eq(1)
+
+    m = FFI::MemoryPointer.new(:int64)
+    m.write :int64, 1
+    expect(m.read :int64).to eq(1)
+  end
+
   it "allows writing as a long" do
     m = FFI::MemoryPointer.new(:long)
     m.write_long(10)
     expect(m.read_long).to eq(10)
+    expect(m.read :long).to eq(10)
+    expect(m.read FFI::Type::LONG).to eq(10)
+
+    m.write :long, 10
+    expect(m.read :long).to eq(10)
+  end
+
+  it "allows writing as a size_t" do
+    m = FFI::MemoryPointer.new(:size_t)
+    m.write(:size_t, 10)
+    expect(m.read :size_t).to eq(10)
+  end
+
+  it "allows writing as a bool" do
+    m = FFI::MemoryPointer.new(:bool)
+    m.write(:bool, true)
+    expect(m.read :bool).to eq(true)
+    expect(m.read FFI::Type::BOOL).to eq(true)
+
+    m.write(:bool, false)
+    expect(m.read :bool).to eq(false)
+    expect(m.read FFI::Type::BOOL).to eq(false)
+  end
+
+  it "allows writing a custom typedef" do
+    FFI.typedef :uint, :fubar_t
+    FFI.typedef :size_t, :fubar2_t
+
+    m = FFI::MemoryPointer.new(:fubar_t)
+    m.write(:fubar_t, 10)
+    expect(m.read :fubar_t).to eq(10)
+
+    m = FFI::MemoryPointer.new(:fubar2_t)
+    m.write(:fubar2_t, 10)
+    expect(m.read :fubar2_t).to eq(10)
+  end
+
+  it "raises an error if you try to read an undefined type" do
+    m = FFI::MemoryPointer.new(:long)
+    expect { m.read(:undefined_type) }.to raise_error(ArgumentError)
   end
   
   it "raises an error if you try putting a long into a pointer of size 1" do


Reply via email to