alinta-ffi 1.9.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +49 -0
- data/LICENSE +24 -0
- data/README.md +112 -0
- data/Rakefile +243 -0
- data/ext/ffi_c/AbstractMemory.c +1109 -0
- data/ext/ffi_c/AbstractMemory.h +175 -0
- data/ext/ffi_c/ArrayType.c +162 -0
- data/ext/ffi_c/ArrayType.h +59 -0
- data/ext/ffi_c/Buffer.c +365 -0
- data/ext/ffi_c/Call.c +517 -0
- data/ext/ffi_c/Call.h +110 -0
- data/ext/ffi_c/ClosurePool.c +283 -0
- data/ext/ffi_c/ClosurePool.h +57 -0
- data/ext/ffi_c/DataConverter.c +91 -0
- data/ext/ffi_c/DynamicLibrary.c +339 -0
- data/ext/ffi_c/DynamicLibrary.h +98 -0
- data/ext/ffi_c/Function.c +998 -0
- data/ext/ffi_c/Function.h +87 -0
- data/ext/ffi_c/FunctionInfo.c +271 -0
- data/ext/ffi_c/LastError.c +184 -0
- data/ext/ffi_c/LastError.h +47 -0
- data/ext/ffi_c/LongDouble.c +63 -0
- data/ext/ffi_c/LongDouble.h +51 -0
- data/ext/ffi_c/MappedType.c +168 -0
- data/ext/ffi_c/MappedType.h +59 -0
- data/ext/ffi_c/MemoryPointer.c +197 -0
- data/ext/ffi_c/MemoryPointer.h +53 -0
- data/ext/ffi_c/MethodHandle.c +358 -0
- data/ext/ffi_c/MethodHandle.h +55 -0
- data/ext/ffi_c/Platform.c +129 -0
- data/ext/ffi_c/Platform.h +45 -0
- data/ext/ffi_c/Pointer.c +508 -0
- data/ext/ffi_c/Pointer.h +63 -0
- data/ext/ffi_c/Struct.c +829 -0
- data/ext/ffi_c/Struct.h +106 -0
- data/ext/ffi_c/StructByReference.c +190 -0
- data/ext/ffi_c/StructByReference.h +50 -0
- data/ext/ffi_c/StructByValue.c +150 -0
- data/ext/ffi_c/StructByValue.h +55 -0
- data/ext/ffi_c/StructLayout.c +698 -0
- data/ext/ffi_c/Thread.c +352 -0
- data/ext/ffi_c/Thread.h +95 -0
- data/ext/ffi_c/Type.c +397 -0
- data/ext/ffi_c/Type.h +62 -0
- data/ext/ffi_c/Types.c +139 -0
- data/ext/ffi_c/Types.h +89 -0
- data/ext/ffi_c/Variadic.c +304 -0
- data/ext/ffi_c/compat.h +78 -0
- data/ext/ffi_c/extconf.rb +71 -0
- data/ext/ffi_c/ffi.c +98 -0
- data/ext/ffi_c/libffi.bsd.mk +40 -0
- data/ext/ffi_c/libffi.darwin.mk +105 -0
- data/ext/ffi_c/libffi.gnu.mk +32 -0
- data/ext/ffi_c/libffi.mk +18 -0
- data/ext/ffi_c/libffi.vc.mk +26 -0
- data/ext/ffi_c/libffi.vc64.mk +26 -0
- data/ext/ffi_c/rbffi.h +57 -0
- data/ext/ffi_c/rbffi_endian.h +59 -0
- data/ext/ffi_c/win32/stdbool.h +8 -0
- data/ext/ffi_c/win32/stdint.h +201 -0
- data/ffi.gemspec +23 -0
- data/gen/Rakefile +30 -0
- data/lib/ffi.rb +20 -0
- data/lib/ffi/autopointer.rb +203 -0
- data/lib/ffi/buffer.rb +4 -0
- data/lib/ffi/callback.rb +4 -0
- data/lib/ffi/enum.rb +296 -0
- data/lib/ffi/errno.rb +43 -0
- data/lib/ffi/ffi.rb +44 -0
- data/lib/ffi/io.rb +62 -0
- data/lib/ffi/library.rb +590 -0
- data/lib/ffi/managedstruct.rb +84 -0
- data/lib/ffi/memorypointer.rb +1 -0
- data/lib/ffi/platform.rb +164 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/lib/ffi/platform/arm-linux/types.conf +104 -0
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips-linux/types.conf +102 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
- data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
- data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +120 -0
- data/lib/ffi/pointer.rb +161 -0
- data/lib/ffi/struct.rb +371 -0
- data/lib/ffi/struct_layout_builder.rb +227 -0
- data/lib/ffi/tools/const_generator.rb +229 -0
- data/lib/ffi/tools/generator.rb +60 -0
- data/lib/ffi/tools/generator_task.rb +36 -0
- data/lib/ffi/tools/struct_generator.rb +194 -0
- data/lib/ffi/tools/types_generator.rb +134 -0
- data/lib/ffi/types.rb +194 -0
- data/lib/ffi/union.rb +43 -0
- data/lib/ffi/variadic.rb +78 -0
- data/lib/ffi/version.rb +4 -0
- data/libtest/Benchmark.c +52 -0
- data/libtest/BoolTest.c +34 -0
- data/libtest/BufferTest.c +31 -0
- data/libtest/ClosureTest.c +205 -0
- data/libtest/EnumTest.c +51 -0
- data/libtest/FunctionTest.c +70 -0
- data/libtest/GNUmakefile +149 -0
- data/libtest/GlobalVariable.c +62 -0
- data/libtest/LastErrorTest.c +21 -0
- data/libtest/NumberTest.c +132 -0
- data/libtest/PointerTest.c +63 -0
- data/libtest/ReferenceTest.c +23 -0
- data/libtest/StringTest.c +34 -0
- data/libtest/StructTest.c +243 -0
- data/libtest/UnionTest.c +43 -0
- data/libtest/VariadicTest.c +99 -0
- data/spec/ffi/LICENSE.SPECS +22 -0
- data/spec/ffi/async_callback_spec.rb +35 -0
- data/spec/ffi/bitmask_spec.rb +575 -0
- data/spec/ffi/bool_spec.rb +32 -0
- data/spec/ffi/buffer_spec.rb +279 -0
- data/spec/ffi/callback_spec.rb +773 -0
- data/spec/ffi/custom_param_type.rb +37 -0
- data/spec/ffi/custom_type_spec.rb +74 -0
- data/spec/ffi/dup_spec.rb +52 -0
- data/spec/ffi/enum_spec.rb +423 -0
- data/spec/ffi/errno_spec.rb +20 -0
- data/spec/ffi/ffi_spec.rb +28 -0
- data/spec/ffi/fixtures/Benchmark.c +52 -0
- data/spec/ffi/fixtures/BitmaskTest.c +51 -0
- data/spec/ffi/fixtures/BoolTest.c +34 -0
- data/spec/ffi/fixtures/BufferTest.c +31 -0
- data/spec/ffi/fixtures/ClosureTest.c +205 -0
- data/spec/ffi/fixtures/EnumTest.c +51 -0
- data/spec/ffi/fixtures/FunctionTest.c +142 -0
- data/spec/ffi/fixtures/GNUmakefile +149 -0
- data/spec/ffi/fixtures/GlobalVariable.c +62 -0
- data/spec/ffi/fixtures/LastErrorTest.c +21 -0
- data/spec/ffi/fixtures/NumberTest.c +132 -0
- data/spec/ffi/fixtures/PipeHelper.h +21 -0
- data/spec/ffi/fixtures/PipeHelperPosix.c +41 -0
- data/spec/ffi/fixtures/PipeHelperWindows.c +72 -0
- data/spec/ffi/fixtures/PointerTest.c +63 -0
- data/spec/ffi/fixtures/ReferenceTest.c +23 -0
- data/spec/ffi/fixtures/StringTest.c +34 -0
- data/spec/ffi/fixtures/StructTest.c +243 -0
- data/spec/ffi/fixtures/UnionTest.c +43 -0
- data/spec/ffi/fixtures/VariadicTest.c +99 -0
- data/spec/ffi/fixtures/classes.rb +438 -0
- data/spec/ffi/function_spec.rb +97 -0
- data/spec/ffi/io_spec.rb +16 -0
- data/spec/ffi/library_spec.rb +286 -0
- data/spec/ffi/long_double.rb +30 -0
- data/spec/ffi/managed_struct_spec.rb +68 -0
- data/spec/ffi/memorypointer_spec.rb +78 -0
- data/spec/ffi/number_spec.rb +247 -0
- data/spec/ffi/platform_spec.rb +114 -0
- data/spec/ffi/pointer_spec.rb +285 -0
- data/spec/ffi/rbx/attach_function_spec.rb +34 -0
- data/spec/ffi/rbx/memory_pointer_spec.rb +198 -0
- data/spec/ffi/rbx/spec_helper.rb +6 -0
- data/spec/ffi/rbx/struct_spec.rb +18 -0
- data/spec/ffi/spec_helper.rb +93 -0
- data/spec/ffi/string_spec.rb +118 -0
- data/spec/ffi/strptr_spec.rb +50 -0
- data/spec/ffi/struct_by_ref_spec.rb +43 -0
- data/spec/ffi/struct_callback_spec.rb +69 -0
- data/spec/ffi/struct_initialize_spec.rb +35 -0
- data/spec/ffi/struct_packed_spec.rb +50 -0
- data/spec/ffi/struct_spec.rb +882 -0
- data/spec/ffi/typedef_spec.rb +91 -0
- data/spec/ffi/union_spec.rb +67 -0
- data/spec/ffi/variadic_spec.rb +132 -0
- data/spec/spec.opts +4 -0
- metadata +309 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- makefile -*-
|
2
|
+
#
|
3
|
+
# Makefile for msvc
|
4
|
+
#
|
5
|
+
|
6
|
+
# Tack the extra deps onto the autogenerated variables
|
7
|
+
INCFLAGS = $(INCFLAGS) -I$(LIBFFI_BUILD_DIR)/include -I$(LIBFFI_BUILD_DIR)/src/x86
|
8
|
+
LOCAL_LIBS = $(LOCAL_LIBS) $(LIBFFI)
|
9
|
+
BUILD_DIR = $(MAKEDIR)
|
10
|
+
LIBFFI_BUILD_DIR = $(BUILD_DIR)/libffi
|
11
|
+
|
12
|
+
!IF "$(srcdir)" == "."
|
13
|
+
LIBFFI_SRC_DIR = $(MAKEDIR)/libffi
|
14
|
+
!ELSE
|
15
|
+
LIBFFI_SRC_DIR = $(srcdir)/libffi
|
16
|
+
!ENDIF
|
17
|
+
|
18
|
+
LIBFFI = $(LIBFFI_BUILD_DIR)/.libs/libffi_convenience.lib
|
19
|
+
|
20
|
+
$(OBJS): $(LIBFFI)
|
21
|
+
|
22
|
+
$(LIBFFI):
|
23
|
+
@$(MAKEDIRS) $(LIBFFI_BUILD_DIR)
|
24
|
+
@cd $(LIBFFI_BUILD_DIR) && $(MAKE) -f Makefile.vc
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- makefile -*-
|
2
|
+
#
|
3
|
+
# Makefile for msvc
|
4
|
+
#
|
5
|
+
|
6
|
+
# Tack the extra deps onto the autogenerated variables
|
7
|
+
INCFLAGS = $(INCFLAGS) -I$(LIBFFI_BUILD_DIR)/include -I$(LIBFFI_BUILD_DIR)/src/x86
|
8
|
+
LOCAL_LIBS = $(LOCAL_LIBS) $(LIBFFI)
|
9
|
+
BUILD_DIR = $(MAKEDIR)
|
10
|
+
LIBFFI_BUILD_DIR = $(BUILD_DIR)/libffi
|
11
|
+
|
12
|
+
!IF "$(srcdir)" == "."
|
13
|
+
LIBFFI_SRC_DIR = $(MAKEDIR)/libffi
|
14
|
+
!ELSE
|
15
|
+
LIBFFI_SRC_DIR = $(srcdir)/libffi
|
16
|
+
!ENDIF
|
17
|
+
|
18
|
+
LIBFFI = $(LIBFFI_BUILD_DIR)/.libs/libffi_convenience.lib
|
19
|
+
|
20
|
+
$(OBJS): $(LIBFFI)
|
21
|
+
|
22
|
+
$(LIBFFI):
|
23
|
+
@$(MAKEDIRS) $(LIBFFI_BUILD_DIR)
|
24
|
+
@cd $(LIBFFI_BUILD_DIR) && $(MAKE) -f Makefile.vc64
|
25
|
+
|
26
|
+
|
data/ext/ffi_c/rbffi.h
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2008, 2009, Wayne Meissner
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008-2013, Ruby FFI project contributors
|
5
|
+
* All rights reserved.
|
6
|
+
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
9
|
+
* * Redistributions of source code must retain the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
11
|
+
* * Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
* * Neither the name of the Ruby FFI project nor the
|
15
|
+
* names of its contributors may be used to endorse or promote products
|
16
|
+
* derived from this software without specific prior written permission.
|
17
|
+
*
|
18
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
* DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
22
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
23
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
24
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
25
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
27
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
*/
|
29
|
+
|
30
|
+
#ifndef RBFFI_RBFFI_H
|
31
|
+
#define RBFFI_RBFFI_H
|
32
|
+
|
33
|
+
#include <ruby.h>
|
34
|
+
|
35
|
+
#ifdef __cplusplus
|
36
|
+
extern "C" {
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#define MAX_PARAMETERS (32)
|
40
|
+
|
41
|
+
extern VALUE rbffi_FFIModule;
|
42
|
+
|
43
|
+
extern void rbffi_Type_Init(VALUE ffiModule);
|
44
|
+
extern void rbffi_Buffer_Init(VALUE ffiModule);
|
45
|
+
extern void rbffi_Invoker_Init(VALUE ffiModule);
|
46
|
+
extern void rbffi_Variadic_Init(VALUE ffiModule);
|
47
|
+
extern void rbffi_DataConverter_Init(VALUE ffiModule);
|
48
|
+
extern VALUE rbffi_AbstractMemoryClass, rbffi_InvokerClass;
|
49
|
+
extern int rbffi_type_size(VALUE type);
|
50
|
+
extern void rbffi_Thread_Init(VALUE moduleFFI);
|
51
|
+
|
52
|
+
#ifdef __cplusplus
|
53
|
+
}
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#endif /* RBFFI_RBFFI_H */
|
57
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#ifndef JFFI_ENDIAN_H
|
2
|
+
#define JFFI_ENDIAN_H
|
3
|
+
|
4
|
+
#ifndef _MSC_VER
|
5
|
+
#include <sys/param.h>
|
6
|
+
#endif
|
7
|
+
|
8
|
+
#include <sys/types.h>
|
9
|
+
|
10
|
+
#if defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || defined(__GLIBC__) || defined(__HAIKU__)
|
11
|
+
# include <endian.h>
|
12
|
+
# if !defined(LITTLE_ENDIAN) && defined(__LITTLE_ENDIAN)
|
13
|
+
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
14
|
+
# endif
|
15
|
+
# if !defined(BIG_ENDIAN) && defined(__BIG_ENDIAN)
|
16
|
+
# define BIG_ENDIAN __BIG_ENDIAN
|
17
|
+
# endif
|
18
|
+
# if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
19
|
+
# define BYTE_ORDER __BYTE_ORDER
|
20
|
+
# endif
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifdef __sun
|
24
|
+
# include <sys/byteorder.h>
|
25
|
+
# define LITTLE_ENDIAN 1234
|
26
|
+
# define BIG_ENDIAN 4321
|
27
|
+
# if defined(_BIG_ENDIAN)
|
28
|
+
# define BYTE_ORDER BIG_ENDIAN
|
29
|
+
# elif defined(_LITTLE_ENDIAN)
|
30
|
+
# define BYTE_ORDER LITTLE_ENDIAN
|
31
|
+
# else
|
32
|
+
# error "Cannot determine endian-ness"
|
33
|
+
# endif
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#if defined(_AIX) && !defined(BYTE_ORDER)
|
37
|
+
# define LITTLE_ENDIAN 1234
|
38
|
+
# define BIG_ENDIAN 4321
|
39
|
+
# if defined(__BIG_ENDIAN__)
|
40
|
+
# define BYTE_ORDER BIG_ENDIAN
|
41
|
+
# elif defined(__LITTLE_ENDIAN__)
|
42
|
+
# define BYTE_ORDER LITTLE_ENDIAN
|
43
|
+
# else
|
44
|
+
# error "Cannot determine endian-ness"
|
45
|
+
# endif
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#if defined(_WIN32)
|
49
|
+
# define LITTLE_ENDIAN 1234
|
50
|
+
# define BIG_ENDIAN 4321
|
51
|
+
# define BYTE_ORDER LITTLE_ENDIAN
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
|
55
|
+
# error "Cannot determine the endian-ness of this platform"
|
56
|
+
#endif
|
57
|
+
|
58
|
+
#endif /* JFFI_ENDIAN_H */
|
59
|
+
|
@@ -0,0 +1,201 @@
|
|
1
|
+
/* stdint.h standard header */
|
2
|
+
#if !defined(_MSC_VER) && !defined(INT8_MIN)
|
3
|
+
#pragma once
|
4
|
+
#ifndef _STDINT
|
5
|
+
#define _STDINT
|
6
|
+
#ifndef RC_INVOKED
|
7
|
+
#include <yvals.h>
|
8
|
+
|
9
|
+
/* NB: assumes
|
10
|
+
byte has 8 bits
|
11
|
+
long is 32 bits
|
12
|
+
pointer can convert to and from long long
|
13
|
+
long long is longest type
|
14
|
+
*/
|
15
|
+
|
16
|
+
_C_STD_BEGIN
|
17
|
+
/* TYPE DEFINITIONS */
|
18
|
+
typedef signed char int8_t;
|
19
|
+
typedef short int16_t;
|
20
|
+
typedef int int32_t;
|
21
|
+
|
22
|
+
typedef unsigned char uint8_t;
|
23
|
+
typedef unsigned short uint16_t;
|
24
|
+
typedef unsigned int uint32_t;
|
25
|
+
|
26
|
+
typedef signed char int_least8_t;
|
27
|
+
typedef short int_least16_t;
|
28
|
+
typedef int int_least32_t;
|
29
|
+
|
30
|
+
typedef unsigned char uint_least8_t;
|
31
|
+
typedef unsigned short uint_least16_t;
|
32
|
+
typedef unsigned int uint_least32_t;
|
33
|
+
|
34
|
+
typedef char int_fast8_t;
|
35
|
+
typedef int int_fast16_t;
|
36
|
+
typedef int int_fast32_t;
|
37
|
+
|
38
|
+
typedef unsigned char uint_fast8_t;
|
39
|
+
typedef unsigned int uint_fast16_t;
|
40
|
+
typedef unsigned int uint_fast32_t;
|
41
|
+
|
42
|
+
#ifndef _INTPTR_T_DEFINED
|
43
|
+
#define _INTPTR_T_DEFINED
|
44
|
+
#ifdef _WIN64
|
45
|
+
typedef __int64 intptr_t;
|
46
|
+
#else /* _WIN64 */
|
47
|
+
typedef _W64 int intptr_t;
|
48
|
+
#endif /* _WIN64 */
|
49
|
+
#endif /* _INTPTR_T_DEFINED */
|
50
|
+
|
51
|
+
#ifndef _UINTPTR_T_DEFINED
|
52
|
+
#define _UINTPTR_T_DEFINED
|
53
|
+
#ifdef _WIN64
|
54
|
+
typedef unsigned __int64 uintptr_t;
|
55
|
+
#else /* _WIN64 */
|
56
|
+
typedef _W64 unsigned int uintptr_t;
|
57
|
+
#endif /* _WIN64 */
|
58
|
+
#endif /* _UINTPTR_T_DEFINED */
|
59
|
+
|
60
|
+
typedef _Longlong int64_t;
|
61
|
+
typedef _ULonglong uint64_t;
|
62
|
+
|
63
|
+
typedef _Longlong int_least64_t;
|
64
|
+
typedef _ULonglong uint_least64_t;
|
65
|
+
|
66
|
+
typedef _Longlong int_fast64_t;
|
67
|
+
typedef _ULonglong uint_fast64_t;
|
68
|
+
|
69
|
+
typedef _Longlong intmax_t;
|
70
|
+
typedef _ULonglong uintmax_t;
|
71
|
+
|
72
|
+
/* LIMIT MACROS */
|
73
|
+
#define INT8_MIN (-0x7f - _C2)
|
74
|
+
#define INT16_MIN (-0x7fff - _C2)
|
75
|
+
#define INT32_MIN (-0x7fffffff - _C2)
|
76
|
+
|
77
|
+
#define INT8_MAX 0x7f
|
78
|
+
#define INT16_MAX 0x7fff
|
79
|
+
#define INT32_MAX 0x7fffffff
|
80
|
+
#define UINT8_MAX 0xff
|
81
|
+
#define UINT16_MAX 0xffff
|
82
|
+
#define UINT32_MAX 0xffffffff
|
83
|
+
|
84
|
+
#define INT_LEAST8_MIN (-0x7f - _C2)
|
85
|
+
#define INT_LEAST16_MIN (-0x7fff - _C2)
|
86
|
+
#define INT_LEAST32_MIN (-0x7fffffff - _C2)
|
87
|
+
|
88
|
+
#define INT_LEAST8_MAX 0x7f
|
89
|
+
#define INT_LEAST16_MAX 0x7fff
|
90
|
+
#define INT_LEAST32_MAX 0x7fffffff
|
91
|
+
#define UINT_LEAST8_MAX 0xff
|
92
|
+
#define UINT_LEAST16_MAX 0xffff
|
93
|
+
#define UINT_LEAST32_MAX 0xffffffff
|
94
|
+
|
95
|
+
#define INT_FAST8_MIN (-0x7f - _C2)
|
96
|
+
#define INT_FAST16_MIN (-0x7fff - _C2)
|
97
|
+
#define INT_FAST32_MIN (-0x7fffffff - _C2)
|
98
|
+
|
99
|
+
#define INT_FAST8_MAX 0x7f
|
100
|
+
#define INT_FAST16_MAX 0x7fff
|
101
|
+
#define INT_FAST32_MAX 0x7fffffff
|
102
|
+
#define UINT_FAST8_MAX 0xff
|
103
|
+
#define UINT_FAST16_MAX 0xffff
|
104
|
+
#define UINT_FAST32_MAX 0xffffffff
|
105
|
+
|
106
|
+
#if _INTPTR == 0 || _INTPTR == 1
|
107
|
+
#define INTPTR_MAX 0x7fffffff
|
108
|
+
#define INTPTR_MIN (-INTPTR_MAX - _C2)
|
109
|
+
#define UINTPTR_MAX 0xffffffff
|
110
|
+
|
111
|
+
#else /* _INTPTR == 2 */
|
112
|
+
#define INTPTR_MIN (-_LLONG_MAX - _C2)
|
113
|
+
#define INTPTR_MAX _LLONG_MAX
|
114
|
+
#define UINTPTR_MAX _ULLONG_MAX
|
115
|
+
#endif /* _INTPTR */
|
116
|
+
|
117
|
+
#define INT8_C(x) (x)
|
118
|
+
#define INT16_C(x) (x)
|
119
|
+
#define INT32_C(x) ((x) + (INT32_MAX - INT32_MAX))
|
120
|
+
|
121
|
+
#define UINT8_C(x) (x)
|
122
|
+
#define UINT16_C(x) (x)
|
123
|
+
#define UINT32_C(x) ((x) + (UINT32_MAX - UINT32_MAX))
|
124
|
+
|
125
|
+
#ifdef _WIN64
|
126
|
+
#define PTRDIFF_MIN INT64_MIN
|
127
|
+
#define PTRDIFF_MAX INT64_MAX
|
128
|
+
#else /* _WIN64 */
|
129
|
+
#define PTRDIFF_MIN INT32_MIN
|
130
|
+
#define PTRDIFF_MAX INT32_MAX
|
131
|
+
#endif /* _WIN64 */
|
132
|
+
|
133
|
+
#define SIG_ATOMIC_MIN INT32_MIN
|
134
|
+
#define SIG_ATOMIC_MAX INT32_MAX
|
135
|
+
|
136
|
+
#ifndef SIZE_MAX
|
137
|
+
#ifdef _WIN64
|
138
|
+
#define SIZE_MAX UINT64_MAX
|
139
|
+
#else /* _WIN64 */
|
140
|
+
#define SIZE_MAX UINT32_MAX
|
141
|
+
#endif /* _WIN64 */
|
142
|
+
#endif /* SIZE_MAX */
|
143
|
+
|
144
|
+
#define WCHAR_MIN 0x0000
|
145
|
+
#define WCHAR_MAX 0xffff
|
146
|
+
|
147
|
+
#define WINT_MIN 0x0000
|
148
|
+
#define WINT_MAX 0xffff
|
149
|
+
|
150
|
+
#define INT64_MIN (-0x7fffffffffffffff - _C2)
|
151
|
+
#define INT64_MAX 0x7fffffffffffffff
|
152
|
+
#define UINT64_MAX 0xffffffffffffffffU
|
153
|
+
|
154
|
+
#define INT_LEAST64_MIN (-0x7fffffffffffffff - _C2)
|
155
|
+
#define INT_LEAST64_MAX 0x7fffffffffffffff
|
156
|
+
#define UINT_LEAST64_MAX 0xffffffffffffffffU
|
157
|
+
|
158
|
+
#define INT_FAST64_MIN (-0x7fffffffffffffff - _C2)
|
159
|
+
#define INT_FAST64_MAX 0x7fffffffffffffff
|
160
|
+
#define UINT_FAST64_MAX 0xffffffffffffffffU
|
161
|
+
|
162
|
+
#define INTMAX_MIN (-0x7fffffffffffffff - _C2)
|
163
|
+
#define INTMAX_MAX 0x7fffffffffffffff
|
164
|
+
#define UINTMAX_MAX 0xffffffffffffffffU
|
165
|
+
|
166
|
+
#define INT64_C(x) ((x) + (INT64_MAX - INT64_MAX))
|
167
|
+
#define UINT64_C(x) ((x) + (UINT64_MAX - UINT64_MAX))
|
168
|
+
#define INTMAX_C(x) INT64_C(x)
|
169
|
+
#define UINTMAX_C(x) UINT64_C(x)
|
170
|
+
_C_STD_END
|
171
|
+
#endif /* RC_INVOKED */
|
172
|
+
#endif /* _STDINT */
|
173
|
+
|
174
|
+
#if defined(_STD_USING)
|
175
|
+
using _CSTD int8_t; using _CSTD int16_t;
|
176
|
+
using _CSTD int32_t; using _CSTD int64_t;
|
177
|
+
|
178
|
+
using _CSTD uint8_t; using _CSTD uint16_t;
|
179
|
+
using _CSTD uint32_t; using _CSTD uint64_t;
|
180
|
+
|
181
|
+
using _CSTD int_least8_t; using _CSTD int_least16_t;
|
182
|
+
using _CSTD int_least32_t; using _CSTD int_least64_t;
|
183
|
+
using _CSTD uint_least8_t; using _CSTD uint_least16_t;
|
184
|
+
using _CSTD uint_least32_t; using _CSTD uint_least64_t;
|
185
|
+
|
186
|
+
using _CSTD intmax_t; using _CSTD uintmax_t;
|
187
|
+
|
188
|
+
using _CSTD uintptr_t;
|
189
|
+
using _CSTD intptr_t;
|
190
|
+
|
191
|
+
using _CSTD int_fast8_t; using _CSTD int_fast16_t;
|
192
|
+
using _CSTD int_fast32_t; using _CSTD int_fast64_t;
|
193
|
+
using _CSTD uint_fast8_t; using _CSTD uint_fast16_t;
|
194
|
+
using _CSTD uint_fast32_t; using _CSTD uint_fast64_t;
|
195
|
+
#endif /* defined(_STD_USING) */
|
196
|
+
|
197
|
+
/*
|
198
|
+
* Copyright (c) 1992-2009 by P.J. Plauger. ALL RIGHTS RESERVED.
|
199
|
+
* Consult your license regarding permissions and restrictions.
|
200
|
+
V5.20:0009 */
|
201
|
+
#endif /* !defined(_MSC_VER) && !defined(INT8_MIN) */
|
data/ffi.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path("../lib/#{File.basename(__FILE__, '.gemspec')}/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'alinta-ffi'
|
5
|
+
s.version = FFI::VERSION
|
6
|
+
s.author = 'Wayne Meissner'
|
7
|
+
s.email = 'wmeissner@gmail.com'
|
8
|
+
s.homepage = 'http://wiki.github.com/ffi/ffi'
|
9
|
+
s.summary = 'Ruby FFI'
|
10
|
+
s.description = 'Ruby FFI library'
|
11
|
+
s.files = %w(ffi.gemspec LICENSE COPYING README.md Rakefile) + Dir.glob("{ext,gen,lib,spec,libtest}/**/*").reject { |f| f =~ /(lib\/[12]\.[089]|\.s?[ao]$|\.bundle|\.dylib$)/ }
|
12
|
+
s.extensions << 'ext/ffi_c/extconf.rb'
|
13
|
+
s.has_rdoc = false
|
14
|
+
s.rdoc_options = %w[--exclude=ext/ffi_c/.*\.o$ --exclude=ffi_c\.(bundle|so)$]
|
15
|
+
s.license = 'BSD-3-Clause'
|
16
|
+
s.require_paths << 'ext/ffi_c'
|
17
|
+
s.required_ruby_version = '>= 1.9'
|
18
|
+
s.add_development_dependency 'rake', '~> 10.1'
|
19
|
+
s.add_development_dependency 'rake-compiler', '~> 1.0'
|
20
|
+
s.add_development_dependency 'rake-compiler-dock', '~> 0.6.2'
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.14.1'
|
22
|
+
s.add_development_dependency 'rubygems-tasks', "~> 0.2.4"
|
23
|
+
end
|
data/gen/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require 'fileutils'
|
3
|
+
require 'ffi'
|
4
|
+
require 'ffi/platform'
|
5
|
+
require 'ffi/tools/types_generator'
|
6
|
+
types_conf = File.expand_path(File.join(FFI::Platform::CONF_DIR, 'types.conf'))
|
7
|
+
|
8
|
+
logfile = File.join(File.dirname(__FILE__), 'log')
|
9
|
+
|
10
|
+
file types_conf do |task|
|
11
|
+
options = {}
|
12
|
+
FileUtils.mkdir_p(File.dirname(task.name), { :mode => 0755 })
|
13
|
+
File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
|
14
|
+
f.puts FFI::TypesGenerator.generate(options)
|
15
|
+
end
|
16
|
+
File.open(logfile, 'w') do |log|
|
17
|
+
log.puts(types_conf)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => types_conf do
|
22
|
+
end
|
23
|
+
|
24
|
+
task :clean do
|
25
|
+
File.readlines(logfile).each do |file|
|
26
|
+
file.strip!
|
27
|
+
rm_f file
|
28
|
+
end
|
29
|
+
rm_f logfile
|
30
|
+
end
|
data/lib/ffi.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
|
2
|
+
Object.send(:remove_const, :FFI) if defined?(::FFI)
|
3
|
+
begin
|
4
|
+
require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c'
|
5
|
+
rescue Exception
|
6
|
+
require 'ffi_c'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'ffi/ffi'
|
10
|
+
|
11
|
+
elsif defined?(RUBY_ENGINE)
|
12
|
+
# Remove the ffi gem dir from the load path, then reload the internal ffi implementation
|
13
|
+
$LOAD_PATH.delete(File.dirname(__FILE__))
|
14
|
+
$LOAD_PATH.delete(File.join(File.dirname(__FILE__), 'ffi'))
|
15
|
+
unless $LOADED_FEATURES.nil?
|
16
|
+
$LOADED_FEATURES.delete(__FILE__)
|
17
|
+
$LOADED_FEATURES.delete('ffi.rb')
|
18
|
+
end
|
19
|
+
require 'ffi.rb'
|
20
|
+
end
|