gir_ffi 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,8 @@ module GirFFI
6
6
 
7
7
  setup do
8
8
  gir = IRepository.default
9
- gir.require 'Everything', nil
10
- @info = gir.find_by_name 'Everything', 'TestObj'
9
+ gir.require 'Regress', nil
10
+ @info = gir.find_by_name 'Regress', 'TestObj'
11
11
  end
12
12
 
13
13
  should "find a vfunc by name" do
@@ -30,13 +30,13 @@ module GirFFI
30
30
 
31
31
  should "allow version to be nil" do
32
32
  assert_nothing_raised do
33
- IRepository.default.require 'Everything', nil
33
+ IRepository.default.require 'GObject', nil
34
34
  end
35
35
  end
36
36
 
37
37
  should "allow version to be left out" do
38
38
  assert_nothing_raised do
39
- IRepository.default.require 'Everything'
39
+ IRepository.default.require 'GObject'
40
40
  end
41
41
  end
42
42
  end
@@ -0,0 +1,30 @@
1
+ ACLOCAL_AMFLAGS = -I m4
2
+ AUTOMAKE_OPTIONS = 1.7
3
+
4
+ # We need to build a shared library, which can be dlopened
5
+ # it does not work with noinst_LTLIBRARIES
6
+ testlib_LTLIBRARIES = libregress.la
7
+
8
+ testlibdir = $(prefix)/unused
9
+ install-testlibLTLIBRARIES: # prevent it from being installed
10
+
11
+ libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
12
+ libregress_la_CFLAGS = $(GIO_CFLAGS) $(CAIRO_CFLAGS)
13
+ libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(CAIRO_LIBS)
14
+
15
+ # g-i doesn't ship these as shared libraries anymore; we build them here
16
+ Regress-1.0.gir: libregress.la Makefile
17
+ $(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \
18
+ --namespace=Regress --nsversion=1.0 \
19
+ --warn-all --warn-error \
20
+ --library=libregress.la \
21
+ --libtool="$(top_builddir)/libtool" \
22
+ --output $@ \
23
+ $(libregress_la_SOURCES)
24
+ Regress-1.0.typelib: Regress-1.0.gir Makefile
25
+ $(AM_V_GEN) g-ir-compiler $< -o $@
26
+
27
+ .la.so:
28
+ test -L $@ || $(LN_S) .libs/$@ $@
29
+
30
+ all: $(testlib_LTLIBRARIES:.la=.so) Regress-1.0.typelib
@@ -0,0 +1,87 @@
1
+ #!/bin/sh
2
+ # Run this to generate all the initial makefiles, etc.
3
+
4
+ PROJECT=GirFFITest
5
+
6
+ if test ! -f configure.ac ; then
7
+ echo "You must run this script in the top-level $PROJECT directory"
8
+ exit 1
9
+ fi
10
+
11
+ DIE=0
12
+
13
+ have_libtool=false
14
+ if libtoolize --version < /dev/null > /dev/null 2>&1 ; then
15
+ libtool_version=`libtoolize --version |
16
+ head -1 |
17
+ sed -e 's/^\(.*\)([^)]*)\(.*\)$/\1\2/g' \
18
+ -e 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
19
+ case $libtool_version in
20
+ 2.2*)
21
+ have_libtool=true
22
+ ;;
23
+ 2.4*)
24
+ have_libtool=true
25
+ ;;
26
+ esac
27
+ fi
28
+ if $have_libtool ; then : ; else
29
+ echo
30
+ echo "You must have libtool >= 2.2 installed to compile $PROJECT."
31
+ echo "Install the appropriate package for your distribution,"
32
+ echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
33
+ DIE=1
34
+ fi
35
+
36
+ if autoconf --version < /dev/null > /dev/null 2>&1 ; then : ; else
37
+ echo
38
+ echo "You must have autoconf installed to compile $PROJECT."
39
+ echo "Install the appropriate package for your distribution,"
40
+ echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
41
+ DIE=1
42
+ fi
43
+
44
+ if automake-1.11 --version < /dev/null > /dev/null 2>&1 ; then
45
+ AUTOMAKE=automake-1.11
46
+ ACLOCAL=aclocal-1.11
47
+ else if automake-1.10 --version < /dev/null > /dev/null 2>&1 ; then
48
+ AUTOMAKE=automake-1.10
49
+ ACLOCAL=aclocal-1.10
50
+ else
51
+ echo
52
+ echo "You must have automake 1.10.x or 1.11.x installed to compile $PROJECT."
53
+ echo "Install the appropriate package for your distribution,"
54
+ echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
55
+ DIE=1
56
+ fi
57
+ fi
58
+
59
+ if test "$DIE" -eq 1; then
60
+ exit 1
61
+ fi
62
+
63
+
64
+ libtoolize --force || exit $?
65
+
66
+ $ACLOCAL -I m4 || exit $?
67
+
68
+ autoconf || exit $?
69
+
70
+ $AUTOMAKE --add-missing || exit $?
71
+
72
+ # NOCONFIGURE is used by gnome-common; support both
73
+ if ! test -z "$AUTOGEN_SUBDIR_MODE"; then
74
+ NOCONFIGURE=1
75
+ fi
76
+
77
+ if test -z "$NOCONFIGURE"; then
78
+ if test -z "$*"; then
79
+ echo "I am going to run ./configure with no arguments - if you wish "
80
+ echo "to pass any to it, please specify them on the $0 command line."
81
+ fi
82
+
83
+ ./configure --enable-maintainer-mode $AUTOGEN_CONFIGURE_ARGS "$@" || exit $?
84
+
85
+ echo
86
+ echo "Now type 'make' to compile $PROJECT."
87
+ fi
@@ -0,0 +1,30 @@
1
+ # -*- Autoconf -*-
2
+ # Process this file with autoconf to produce a configure script.
3
+
4
+ AC_PREREQ(2.59)
5
+ AC_INIT(dummy_test_lib, 0.0.1)
6
+ AC_CONFIG_MACRO_DIR([m4])
7
+ AM_INIT_AUTOMAKE([1.7 foreign])
8
+ AM_MAINTAINER_MODE
9
+
10
+ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
11
+
12
+ # Checks for programs.
13
+ AC_PROG_CC
14
+ AM_PROG_CC_C_O
15
+ AC_PROG_LIBTOOL
16
+ PKG_PROG_PKG_CONFIG
17
+
18
+ if test "$GCC" = "yes"; then
19
+ JH_ADD_CFLAG([-Wall])
20
+ JH_ADD_CFLAG([-fno-strict-aliasing])
21
+ fi
22
+
23
+ PKG_CHECK_MODULES(GIO, [gio-2.0])
24
+ PKG_CHECK_MODULES(CAIRO, [cairo])
25
+
26
+ GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
27
+ AC_SUBST(GI_DATADIR)
28
+
29
+ AC_CONFIG_FILES([Makefile])
30
+ AC_OUTPUT
@@ -0,0 +1,21 @@
1
+ dnl
2
+ dnl JH_ADD_CFLAG(FLAG)
3
+ dnl checks whether the C compiler supports the given flag, and if so, adds
4
+ dnl it to $CFLAGS. If the flag is already present in the list, then the
5
+ dnl check is not performed.
6
+ AC_DEFUN([JH_ADD_CFLAG],
7
+ [
8
+ case " $CFLAGS " in
9
+ *@<:@\ \ @:>@$1@<:@\ \ @:>@*)
10
+ ;;
11
+ *)
12
+ save_CFLAGS="$CFLAGS"
13
+ CFLAGS="$CFLAGS $1"
14
+ AC_MSG_CHECKING([whether [$]CC understands $1])
15
+ AC_TRY_COMPILE([], [], [jh_has_option=yes], [jh_has_option=no])
16
+ AC_MSG_RESULT($jh_has_option)
17
+ if test $jh_has_option = no; then
18
+ CFLAGS="$save_CFLAGS"
19
+ fi
20
+ ;;
21
+ esac])
@@ -1,10 +1,10 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  class ModuleBuilderTest < Test::Unit::TestCase
4
- context "The ModuleBuilder" do
4
+ context "The Builder::Module object" do
5
5
  context "for Gtk" do
6
6
  setup do
7
- @mbuilder = GirFFI::ModuleBuilder.new('Gtk')
7
+ @mbuilder = GirFFI::Builder::Module.new('Gtk')
8
8
  end
9
9
 
10
10
  context "looking at Gtk.main" do
@@ -24,27 +24,27 @@ class ModuleBuilderTest < Test::Unit::TestCase
24
24
  @go = get_function_introspection_data 'Gtk', 'init'
25
25
  end
26
26
 
27
- should "delegate definition to FunctionDefinitionBuilder" do
27
+ should "delegate definition to Builder::Function" do
28
28
  code = @mbuilder.send :function_definition, @go, Lib
29
- expected = GirFFI::FunctionDefinitionBuilder.new(@go, Lib).generate
29
+ expected = GirFFI::Builder::Function.new(@go, Lib).generate
30
30
  assert_equal cws(expected), cws(code)
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
- context "for GObject" do
35
+ context "for Regress" do
36
36
  setup do
37
- @mbuilder = GirFFI::ModuleBuilder.new('GObject')
37
+ @mbuilder = GirFFI::Builder::Module.new('Regress')
38
38
  end
39
39
 
40
- context "looking at GObject.signal_connect_data" do
40
+ context "looking at Regress.test_callback_destroy_notify" do
41
41
  setup do
42
- @go = get_function_introspection_data 'GObject', 'signal_connect_data'
42
+ @go = get_function_introspection_data 'Regress', 'test_callback_destroy_notify'
43
43
  end
44
44
 
45
- should "delegate definition to FunctionDefinitionBuilder" do
45
+ should "delegate definition to Builder::Function" do
46
46
  code = @mbuilder.send :function_definition, @go, Lib
47
- expected = GirFFI::FunctionDefinitionBuilder.new(@go, Lib).generate
47
+ expected = GirFFI::Builder::Function.new(@go, Lib).generate
48
48
  assert_equal cws(expected), cws(code)
49
49
  end
50
50
  end
data/test/test_helper.rb CHANGED
@@ -12,21 +12,25 @@ if RUBY_PLATFORM == 'java'
12
12
  end
13
13
 
14
14
  # Since the tests will call Gtk+ functions, Gtk+ must be initialized.
15
- module DummyGtk
16
- module Lib
17
- extend FFI::Library
15
+ GirFFI.setup :Gtk
16
+ Gtk.init
18
17
 
19
- ffi_lib "gtk-x11-2.0"
20
- attach_function :gtk_init, [:pointer, :pointer], :void
21
- end
18
+ GirFFI::IRepository.prepend_search_path File.join(File.dirname(__FILE__), 'lib')
19
+ module GirFFI
20
+ class IRepository
21
+ def shared_library_with_regress namespace
22
+ if namespace == "Regress"
23
+ return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
24
+ else
25
+ return shared_library_without_regress namespace
26
+ end
27
+ end
22
28
 
23
- def self.init
24
- Lib.gtk_init nil, nil
29
+ alias shared_library_without_regress shared_library
30
+ alias shared_library shared_library_with_regress
25
31
  end
26
32
  end
27
33
 
28
- DummyGtk.init
29
-
30
34
  # Need a dummy module for some tests.
31
35
  module Lib
32
36
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gir_ffi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matijs van Zuijlen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-01 00:00:00 +01:00
18
+ date: 2011-04-01 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,10 @@ files:
87
87
  - lib/gir_ffi/g_error.rb
88
88
  - lib/gir_ffi/i_object_info.rb
89
89
  - lib/gir_ffi/builder.rb
90
+ - lib/gir_ffi/builder/module.rb
91
+ - lib/gir_ffi/builder/function.rb
92
+ - lib/gir_ffi/builder/class.rb
93
+ - lib/gir_ffi/builder/argument.rb
90
94
  - lib/gir_ffi/i_enum_info.rb
91
95
  - lib/gir_ffi/i_value_info.rb
92
96
  - lib/gir_ffi/module_base.rb
@@ -101,34 +105,35 @@ files:
101
105
  - lib/gir_ffi/class_base.rb
102
106
  - lib/gir_ffi/i_struct_info.rb
103
107
  - lib/gir_ffi/i_callable_info.rb
104
- - lib/gir_ffi/function_definition_builder.rb
105
108
  - lib/gir_ffi/i_function_info.rb
106
109
  - lib/gir_ffi/i_error_domain_info.rb
107
110
  - lib/gir_ffi/version.rb
111
+ - lib/gir_ffi/overrides/glib.rb
108
112
  - lib/gir_ffi/overrides/gtk.rb
109
113
  - lib/gir_ffi/overrides/gobject.rb
110
114
  - lib/gir_ffi/allocation_helper.rb
111
115
  - lib/gir_ffi/i_base_info.rb
112
- - lib/gir_ffi/module_builder.rb
113
116
  - lib/gir_ffi/arg_helper.rb
114
- - lib/gir_ffi/argument_builder.rb
115
117
  - lib/gir_ffi/g_object.rb
116
118
  - lib/gir_ffi/i_union_info.rb
117
- - lib/gir_ffi/class_builder.rb
118
119
  - lib/gir_ffi/i_interface_info.rb
119
120
  - lib/gir_ffi/i_arg_info.rb
120
121
  - lib/gir_ffi/i_type_info.rb
121
122
  - test/i_repository_test.rb
123
+ - test/generated_regress_test.rb
122
124
  - test/function_definition_builder_test.rb
123
125
  - test/g_object_test.rb
124
126
  - test/arg_helper_test.rb
127
+ - test/lib/Makefile.am
128
+ - test/lib/autogen.sh
129
+ - test/lib/configure.ac
130
+ - test/lib/m4/jhflags.m4
125
131
  - test/class_base_test.rb
126
132
  - test/test_helper.rb
127
133
  - test/class_builder_test.rb
128
134
  - test/girffi_test.rb
129
135
  - test/module_builder_test.rb
130
136
  - test/i_object_info_test.rb
131
- - test/generated_everything_test.rb
132
137
  - test/g_object_overrides_test.rb
133
138
  - test/generated_gtk_test.rb
134
139
  - test/builder_test.rb
@@ -138,6 +143,7 @@ files:
138
143
  - tasks/setup.rb
139
144
  - tasks/notes.rake
140
145
  - examples/demo_ffi_safe_inherited_layout.rb
146
+ - examples/04_webkit.rb
141
147
  - examples/demo_ffi_nested_struct.rb
142
148
  - examples/demo_ffi_inherited_layout.rb
143
149
  - examples/hard_coded.rb
@@ -180,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
186
  requirements: []
181
187
 
182
188
  rubyforge_project:
183
- rubygems_version: 1.3.7
189
+ rubygems_version: 1.6.2
184
190
  signing_key:
185
191
  specification_version: 3
186
192
  summary: Ruby-FFI-based binding of the GObject Introspection Repository
@@ -192,12 +198,16 @@ test_files:
192
198
  - test/function_definition_builder_test.rb
193
199
  - test/g_object_overrides_test.rb
194
200
  - test/g_object_test.rb
195
- - test/generated_everything_test.rb
196
201
  - test/generated_gio_test.rb
197
202
  - test/generated_gtk_test.rb
203
+ - test/generated_regress_test.rb
198
204
  - test/girffi_test.rb
199
205
  - test/gtk_overrides_test.rb
200
206
  - test/i_object_info_test.rb
201
207
  - test/i_repository_test.rb
208
+ - test/lib/Makefile.am
209
+ - test/lib/autogen.sh
210
+ - test/lib/configure.ac
211
+ - test/lib/m4/jhflags.m4
202
212
  - test/module_builder_test.rb
203
213
  - test/test_helper.rb