ffi 1.0.4-x86-mingw32 → 1.0.5-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/Rakefile +2 -2
- data/ext/ffi_c/AbstractMemory.c +1 -1
- data/ext/ffi_c/ArrayType.c +11 -19
- data/ext/ffi_c/ArrayType.h +11 -19
- data/ext/ffi_c/Buffer.c +2 -0
- data/ext/ffi_c/Call.h +12 -19
- data/ext/ffi_c/ClosurePool.h +19 -0
- data/ext/ffi_c/DynamicLibrary.h +18 -0
- data/ext/ffi_c/Function.c +12 -13
- data/ext/ffi_c/Function.h +12 -19
- data/ext/ffi_c/LastError.c +12 -19
- data/ext/ffi_c/LastError.h +20 -0
- data/ext/ffi_c/MappedType.c +12 -19
- data/ext/ffi_c/MappedType.h +12 -19
- data/ext/ffi_c/MemoryPointer.c +1 -0
- data/ext/ffi_c/MemoryPointer.h +23 -3
- data/ext/ffi_c/MethodHandle.h +15 -22
- data/ext/ffi_c/Platform.c +36 -9
- data/ext/ffi_c/Platform.h +23 -3
- data/ext/ffi_c/Pointer.c +2 -0
- data/ext/ffi_c/Pointer.h +11 -19
- data/ext/ffi_c/Struct.c +12 -19
- data/ext/ffi_c/Struct.h +11 -19
- data/ext/ffi_c/StructByValue.c +13 -19
- data/ext/ffi_c/StructByValue.h +12 -19
- data/ext/ffi_c/StructLayout.c +12 -19
- data/ext/ffi_c/Thread.c +36 -10
- data/ext/ffi_c/Thread.h +14 -5
- data/ext/ffi_c/Type.c +1 -0
- data/ext/ffi_c/Types.c +12 -19
- data/ext/ffi_c/Types.h +11 -19
- data/ext/ffi_c/Variadic.c +1 -1
- data/ext/ffi_c/compat.h +13 -19
- data/ext/ffi_c/endian.h +1 -0
- data/ext/ffi_c/extconf.rb +3 -1
- data/ext/ffi_c/ffi.c +12 -19
- data/ext/ffi_c/rbffi.h +23 -3
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/ffi/tools/const_generator.rb +1 -1
- data/spec/ffi/async_callback_spec.rb +35 -12
- data/spec/ffi/bool_spec.rb +16 -0
- data/spec/ffi/buffer_spec.rb +34 -21
- data/spec/ffi/callback_spec.rb +16 -0
- data/spec/ffi/custom_param_type.rb +16 -0
- data/spec/ffi/custom_type_spec.rb +16 -0
- data/spec/ffi/enum_spec.rb +16 -0
- data/spec/ffi/errno_spec.rb +16 -0
- data/spec/ffi/ffi_spec.rb +16 -0
- data/spec/ffi/library_spec.rb +16 -0
- data/spec/ffi/managed_struct_spec.rb +16 -0
- data/spec/ffi/number_spec.rb +16 -0
- data/spec/ffi/strptr_spec.rb +16 -0
- data/spec/ffi/struct_callback_spec.rb +16 -0
- data/spec/ffi/struct_initialize_spec.rb +1 -0
- data/spec/ffi/struct_packed_spec.rb +16 -0
- data/spec/ffi/struct_spec.rb +16 -0
- data/spec/ffi/typedef_spec.rb +16 -0
- data/spec/ffi/union_spec.rb +16 -0
- data/spec/ffi/variadic_spec.rb +16 -0
- data/tasks/extension.rake +1 -1
- metadata +11 -24
- data/lib/ffi_c.so +0 -0
data/ext/ffi_c/Thread.c
CHANGED
@@ -24,6 +24,8 @@
|
|
24
24
|
# include <pthread.h>
|
25
25
|
# include <errno.h>
|
26
26
|
# include <signal.h>
|
27
|
+
#else
|
28
|
+
# include <windows.h>
|
27
29
|
#endif
|
28
30
|
#include <fcntl.h>
|
29
31
|
#include "Thread.h"
|
@@ -36,26 +38,42 @@ rbffi_thread_t
|
|
36
38
|
rbffi_thread_self()
|
37
39
|
{
|
38
40
|
rbffi_thread_t self;
|
41
|
+
#ifdef _WIN32
|
42
|
+
self.id = GetCurrentThreadId();
|
43
|
+
#else
|
39
44
|
self.id = pthread_self();
|
45
|
+
#endif
|
40
46
|
self.valid = true;
|
41
47
|
|
42
48
|
return self;
|
43
49
|
}
|
44
50
|
|
45
51
|
bool
|
46
|
-
rbffi_thread_equal(rbffi_thread_t* lhs, rbffi_thread_t* rhs)
|
52
|
+
rbffi_thread_equal(const rbffi_thread_t* lhs, const rbffi_thread_t* rhs)
|
47
53
|
{
|
48
|
-
return lhs->valid && rhs->valid &&
|
54
|
+
return lhs->valid && rhs->valid &&
|
55
|
+
#ifdef _WIN32
|
56
|
+
lhs->id == rhs->id;
|
57
|
+
#else
|
58
|
+
pthread_equal(lhs->id, rhs->id);
|
59
|
+
#endif
|
49
60
|
}
|
50
61
|
|
51
62
|
bool
|
52
63
|
rbffi_thread_has_gvl_p(void)
|
53
64
|
{
|
65
|
+
#ifdef _WIN32
|
66
|
+
return rbffi_active_thread.valid && rbffi_active_thread.id == GetCurrentThreadId();
|
67
|
+
#else
|
54
68
|
return rbffi_active_thread.valid && pthread_equal(rbffi_active_thread.id, pthread_self());
|
69
|
+
#endif
|
55
70
|
}
|
56
71
|
#endif // HAVE_RUBY_THREAD_HAS_GVL_P
|
57
72
|
|
58
73
|
#ifndef HAVE_RB_THREAD_BLOCKING_REGION
|
74
|
+
|
75
|
+
#if !defined(_WIN32)
|
76
|
+
|
59
77
|
struct BlockingThread {
|
60
78
|
pthread_t tid;
|
61
79
|
VALUE (*fn)(void *);
|
@@ -67,13 +85,6 @@ struct BlockingThread {
|
|
67
85
|
int rdfd;
|
68
86
|
};
|
69
87
|
|
70
|
-
typedef struct BlockingCall_ {
|
71
|
-
void* function;
|
72
|
-
void* info;
|
73
|
-
void **ffiValues;
|
74
|
-
void* retval;
|
75
|
-
} BlockingCall;
|
76
|
-
|
77
88
|
static void*
|
78
89
|
rbffi_blocking_thread(void* args)
|
79
90
|
{
|
@@ -167,4 +178,19 @@ rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(voi
|
|
167
178
|
return thr->retval;
|
168
179
|
}
|
169
180
|
|
170
|
-
#
|
181
|
+
#else
|
182
|
+
|
183
|
+
/*
|
184
|
+
* FIXME: someone needs to implement something similar to the posix pipe based
|
185
|
+
* blocking region implementation above for ruby1.8.x on win32
|
186
|
+
*/
|
187
|
+
VALUE
|
188
|
+
rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(void *), void *data2)
|
189
|
+
{
|
190
|
+
return (*func)(data1);
|
191
|
+
}
|
192
|
+
|
193
|
+
#endif /* !_WIN32 */
|
194
|
+
|
195
|
+
#endif // HAVE_RB_THREAD_BLOCKING_REGION
|
196
|
+
|
data/ext/ffi_c/Thread.h
CHANGED
@@ -18,8 +18,8 @@
|
|
18
18
|
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
*/
|
20
20
|
|
21
|
-
#ifndef
|
22
|
-
#define
|
21
|
+
#ifndef RBFFI_THREAD_H
|
22
|
+
#define RBFFI_THREAD_H
|
23
23
|
|
24
24
|
#include <stdbool.h>
|
25
25
|
#include <ruby.h>
|
@@ -31,19 +31,28 @@ extern "C" {
|
|
31
31
|
|
32
32
|
|
33
33
|
#ifdef HAVE_RUBY_THREAD_HAS_GVL_P
|
34
|
+
extern int ruby_thread_has_gvl_p(void);
|
34
35
|
# define rbffi_thread_has_gvl_p ruby_thread_has_gvl_p
|
35
36
|
#else
|
36
37
|
|
37
|
-
#
|
38
|
+
#ifdef _WIN32
|
39
|
+
# include <windows.h>
|
40
|
+
#else
|
41
|
+
# include <pthread.h>
|
42
|
+
#endif
|
38
43
|
|
39
44
|
typedef struct {
|
45
|
+
#ifdef _WIN32
|
46
|
+
DWORD id;
|
47
|
+
#else
|
40
48
|
pthread_t id;
|
49
|
+
#endif
|
41
50
|
bool valid;
|
42
51
|
} rbffi_thread_t;
|
43
52
|
|
44
53
|
extern rbffi_thread_t rbffi_active_thread;
|
45
54
|
rbffi_thread_t rbffi_thread_self();
|
46
|
-
bool rbffi_thread_equal(rbffi_thread_t* lhs, rbffi_thread_t* rhs);
|
55
|
+
bool rbffi_thread_equal(const rbffi_thread_t* lhs, const rbffi_thread_t* rhs);
|
47
56
|
bool rbffi_thread_has_gvl_p(void);
|
48
57
|
|
49
58
|
#endif
|
@@ -60,5 +69,5 @@ VALUE rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ub
|
|
60
69
|
}
|
61
70
|
#endif
|
62
71
|
|
63
|
-
#endif /*
|
72
|
+
#endif /* RBFFI_THREAD_H */
|
64
73
|
|
data/ext/ffi_c/Type.c
CHANGED
data/ext/ffi_c/Types.c
CHANGED
@@ -2,29 +2,22 @@
|
|
2
2
|
* Copyright (c) 2009, Wayne Meissner
|
3
3
|
* Copyright (c) 2009, Luc Heinrich
|
4
4
|
* Copyright (c) 2009, Aman Gupta.
|
5
|
+
*
|
5
6
|
* All rights reserved.
|
6
7
|
*
|
7
|
-
*
|
8
|
-
*
|
8
|
+
* This file is part of ruby-ffi.
|
9
|
+
*
|
10
|
+
* This code is free software: you can redistribute it and/or modify it under
|
11
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
12
|
+
* published by the Free Software Foundation.
|
9
13
|
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* and/or other materials provided with the distribution.
|
15
|
-
* * The name of the author or authors may not be used to endorse or promote
|
16
|
-
* products derived from this software without specific prior written permission.
|
14
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
15
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
17
|
+
* version 3 for more details.
|
17
18
|
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
22
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
19
|
+
* You should have received a copy of the GNU Lesser General Public License
|
20
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
28
21
|
*/
|
29
22
|
|
30
23
|
#include <ruby.h>
|
data/ext/ffi_c/Types.h
CHANGED
@@ -4,27 +4,19 @@
|
|
4
4
|
*
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
*
|
8
|
-
* modification, are permitted provided that the following conditions are met:
|
7
|
+
* This file is part of ruby-ffi.
|
9
8
|
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
* this list of conditions and the following disclaimer in the documentation
|
14
|
-
* and/or other materials provided with the distribution.
|
15
|
-
* * The name of the author or authors may not be used to endorse or promote
|
16
|
-
* products derived from this software without specific prior written permission.
|
9
|
+
* This code is free software: you can redistribute it and/or modify it under
|
10
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
11
|
+
* published by the Free Software Foundation.
|
17
12
|
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
13
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
14
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
16
|
+
* version 3 for more details.
|
17
|
+
*
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
19
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
28
20
|
*/
|
29
21
|
|
30
22
|
#ifndef RBFFI_TYPES_H
|
data/ext/ffi_c/Variadic.c
CHANGED
@@ -229,7 +229,7 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues)
|
|
229
229
|
rbffi_active_thread = rbffi_thread_self();
|
230
230
|
#endif
|
231
231
|
|
232
|
-
ffi_call(&cif, invoker->function, retval, ffiValues);
|
232
|
+
ffi_call(&cif, FFI_FN(invoker->function), retval, ffiValues);
|
233
233
|
|
234
234
|
#ifndef HAVE_RUBY_THREAD_HAS_GVL_P
|
235
235
|
rbffi_active_thread = oldThread;
|
data/ext/ffi_c/compat.h
CHANGED
@@ -1,28 +1,21 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright (c) 2008, 2009, Wayne Meissner
|
3
|
+
*
|
3
4
|
* All rights reserved.
|
4
5
|
*
|
5
|
-
*
|
6
|
-
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
7
11
|
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* and/or other materials provided with the distribution.
|
13
|
-
* * The name of the author or authors may not be used to endorse or promote
|
14
|
-
* products derived from this software without specific prior written permission.
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
15
16
|
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
20
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
26
19
|
*/
|
27
20
|
|
28
21
|
#ifndef RBFFI_COMPAT_H
|
@@ -70,3 +63,4 @@
|
|
70
63
|
#endif
|
71
64
|
|
72
65
|
#endif /* RBFFI_COMPAT_H */
|
66
|
+
|
data/ext/ffi_c/endian.h
CHANGED
data/ext/ffi_c/extconf.rb
CHANGED
@@ -27,7 +27,9 @@ create_header
|
|
27
27
|
|
28
28
|
$CFLAGS << " -mwin32 " if RbConfig::CONFIG['host_os'] =~ /cygwin/
|
29
29
|
#$CFLAGS << " -Werror -Wunused -Wformat -Wimplicit -Wreturn-type "
|
30
|
-
|
30
|
+
if (ENV['CC'] || RbConfig::MAKEFILE_CONFIG['CC']) =~ /gcc/
|
31
|
+
$CFLAGS << " -Wno-declaration-after-statement "
|
32
|
+
end
|
31
33
|
|
32
34
|
create_makefile("ffi_c")
|
33
35
|
unless libffi_ok
|
data/ext/ffi_c/ffi.c
CHANGED
@@ -1,28 +1,21 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright (c) 2008, 2009, Wayne Meissner
|
3
|
+
*
|
3
4
|
* All rights reserved.
|
4
5
|
*
|
5
|
-
*
|
6
|
-
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
7
11
|
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* and/or other materials provided with the distribution.
|
13
|
-
* * The name of the author or authors may not be used to endorse or promote
|
14
|
-
* products derived from this software without specific prior written permission.
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
15
16
|
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
20
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
26
19
|
*/
|
27
20
|
|
28
21
|
#include <sys/types.h>
|
data/ext/ffi_c/rbffi.h
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2008, 2009, Wayne Meissner
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifndef RBFFI_RBFFI_H
|
22
|
+
#define RBFFI_RBFFI_H
|
3
23
|
|
4
24
|
#include <ruby.h>
|
5
25
|
|
@@ -23,5 +43,5 @@ extern int rbffi_type_size(VALUE type);
|
|
23
43
|
}
|
24
44
|
#endif
|
25
45
|
|
26
|
-
#endif /*
|
46
|
+
#endif /* RBFFI_RBFFI_H */
|
27
47
|
|
data/lib/1.8/ffi_c.so
ADDED
Binary file
|
data/lib/1.9/ffi_c.so
ADDED
Binary file
|
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# This file is part of ruby-ffi.
|
3
|
+
#
|
4
|
+
# This code is free software: you can redistribute it and/or modify it under
|
5
|
+
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
+
# published by the Free Software Foundation.
|
7
|
+
#
|
8
|
+
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
+
# version 3 for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License
|
14
|
+
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
1
17
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
18
|
|
3
19
|
describe "async callback" do
|
@@ -6,18 +22,25 @@ describe "async callback" do
|
|
6
22
|
ffi_lib TestLibrary::PATH
|
7
23
|
AsyncIntCallback = callback [ :int ], :void
|
8
24
|
|
9
|
-
|
10
|
-
attach_function :testAsyncCallback, [ AsyncIntCallback, :int ], :void
|
25
|
+
@blocking = true
|
26
|
+
attach_function :testAsyncCallback, [ AsyncIntCallback, :int ], :void
|
11
27
|
end
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
it ":int (0x7fffffff) argument" do
|
30
|
+
v = 0xdeadbeef
|
31
|
+
called = false
|
32
|
+
cb = Proc.new {|i| v = i; called = true }
|
33
|
+
LibTest.testAsyncCallback(cb, 0x7fffffff)
|
34
|
+
called.should be_true
|
35
|
+
v.should == 0x7fffffff
|
36
|
+
end
|
37
|
+
|
38
|
+
it "called a second time" do
|
39
|
+
v = 0xdeadbeef
|
40
|
+
called = false
|
41
|
+
cb = Proc.new {|i| v = i; called = true }
|
42
|
+
LibTest.testAsyncCallback(cb, 0x7fffffff)
|
43
|
+
called.should be_true
|
44
|
+
v.should == 0x7fffffff
|
45
|
+
end
|
23
46
|
end
|
data/spec/ffi/bool_spec.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# This file is part of ruby-ffi.
|
3
|
+
#
|
4
|
+
# This code is free software: you can redistribute it and/or modify it under
|
5
|
+
# the terms of the GNU Lesser General Public License version 3 only, as
|
6
|
+
# published by the Free Software Foundation.
|
7
|
+
#
|
8
|
+
# This code is distributed in the hope that it will be useful, but WITHOUT
|
9
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
11
|
+
# version 3 for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License
|
14
|
+
# version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
1
17
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
18
|
describe "Function with primitive boolean arguments and return values" do
|
3
19
|
module LibTest
|