blend2d-bindings 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/examples/test.rb +46 -0
- data/examples/util/setup_blend2d.rb +46 -0
- data/lib/blend2d.rb +95 -0
- data/lib/blend2d_api.rb +255 -0
- data/lib/blend2d_array.rb +319 -0
- data/lib/blend2d_bitarray.rb +275 -0
- data/lib/blend2d_bitset.rb +311 -0
- data/lib/blend2d_context.rb +1613 -0
- data/lib/blend2d_filesystem.rb +211 -0
- data/lib/blend2d_font.rb +281 -0
- data/lib/blend2d_fontdata.rb +209 -0
- data/lib/blend2d_fontdefs.rb +552 -0
- data/lib/blend2d_fontface.rb +345 -0
- data/lib/blend2d_fontfeaturesettings.rb +210 -0
- data/lib/blend2d_fontmanager.rb +187 -0
- data/lib/blend2d_fontvariationsettings.rb +210 -0
- data/lib/blend2d_format.rb +112 -0
- data/lib/blend2d_geometry.rb +424 -0
- data/lib/blend2d_glyphbuffer.rb +141 -0
- data/lib/blend2d_glyphrun.rb +101 -0
- data/lib/blend2d_gradient.rb +429 -0
- data/lib/blend2d_image.rb +291 -0
- data/lib/blend2d_imagecodec.rb +219 -0
- data/lib/blend2d_imagedecoder.rb +168 -0
- data/lib/blend2d_imageencoder.rb +159 -0
- data/lib/blend2d_matrix.rb +132 -0
- data/lib/blend2d_object.rb +326 -0
- data/lib/blend2d_path.rb +511 -0
- data/lib/blend2d_pattern.rb +202 -0
- data/lib/blend2d_pixelconverter.rb +109 -0
- data/lib/blend2d_random.rb +77 -0
- data/lib/blend2d_rgba.rb +95 -0
- data/lib/blend2d_runtime.rb +259 -0
- data/lib/blend2d_string.rb +245 -0
- data/lib/blend2d_var.rb +294 -0
- data/lib/libblend2d.aarch64.so +0 -0
- data/lib/libblend2d.arm64.dylib +0 -0
- data/lib/libblend2d.dll +0 -0
- data/lib/libblend2d.x86_64.dylib +0 -0
- data/lib/libblend2d.x86_64.so +0 -0
- metadata +99 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
# Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/blend2d-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
require_relative 'blend2d_imagecodec'
|
9
|
+
require_relative 'blend2d_object'
|
10
|
+
require_relative 'blend2d_string'
|
11
|
+
|
12
|
+
module Blend2D
|
13
|
+
extend FFI::Library
|
14
|
+
# Define/Macro
|
15
|
+
|
16
|
+
|
17
|
+
# Enum
|
18
|
+
|
19
|
+
|
20
|
+
# Typedef
|
21
|
+
|
22
|
+
|
23
|
+
# Struct
|
24
|
+
|
25
|
+
class BLImageEncoderCore < FFI::Struct
|
26
|
+
layout(
|
27
|
+
:_d, BLObjectDetail,
|
28
|
+
)
|
29
|
+
def _d = self[:_d]
|
30
|
+
def _d=(v) self[:_d] = v end
|
31
|
+
def init() = blImageEncoderInit(self)
|
32
|
+
def self.create()
|
33
|
+
instance = BLImageEncoderCore.new
|
34
|
+
blImageEncoderInit(instance)
|
35
|
+
instance
|
36
|
+
end
|
37
|
+
def initMove(other) = blImageEncoderInitMove(self, other)
|
38
|
+
def initWeak(other) = blImageEncoderInitWeak(self, other)
|
39
|
+
def destroy() = blImageEncoderDestroy(self)
|
40
|
+
def reset() = blImageEncoderReset(self)
|
41
|
+
def assignMove(other) = blImageEncoderAssignMove(self, other)
|
42
|
+
def assignWeak(other) = blImageEncoderAssignWeak(self, other)
|
43
|
+
def restart() = blImageEncoderRestart(self)
|
44
|
+
def writeFrame(dst, image) = blImageEncoderWriteFrame(self, dst, image)
|
45
|
+
end
|
46
|
+
|
47
|
+
class BLImageEncoderVirt < FFI::Struct
|
48
|
+
layout(
|
49
|
+
:base, BLObjectVirtBase,
|
50
|
+
:restart, :pointer,
|
51
|
+
:writeFrame, :pointer,
|
52
|
+
)
|
53
|
+
def base = self[:base]
|
54
|
+
def base=(v) self[:base] = v end
|
55
|
+
def restart = self[:restart]
|
56
|
+
def restart=(v) self[:restart] = v end
|
57
|
+
def writeFrame = self[:writeFrame]
|
58
|
+
def writeFrame=(v) self[:writeFrame] = v end
|
59
|
+
def self.create_as(_base_, _restart_, _writeFrame_)
|
60
|
+
instance = BLImageEncoderVirt.new
|
61
|
+
instance[:base] = _base_
|
62
|
+
instance[:restart] = _restart_
|
63
|
+
instance[:writeFrame] = _writeFrame_
|
64
|
+
instance
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class BLImageEncoderImpl < FFI::Struct
|
69
|
+
layout(
|
70
|
+
:virt, :pointer,
|
71
|
+
:codec, BLImageCodecCore,
|
72
|
+
:lastResult, :uint,
|
73
|
+
:handle, :pointer,
|
74
|
+
:frameIndex, :ulong_long,
|
75
|
+
:bufferIndex, :ulong_long,
|
76
|
+
)
|
77
|
+
def virt = self[:virt]
|
78
|
+
def virt=(v) self[:virt] = v end
|
79
|
+
def codec = self[:codec]
|
80
|
+
def codec=(v) self[:codec] = v end
|
81
|
+
def lastResult = self[:lastResult]
|
82
|
+
def lastResult=(v) self[:lastResult] = v end
|
83
|
+
def handle = self[:handle]
|
84
|
+
def handle=(v) self[:handle] = v end
|
85
|
+
def frameIndex = self[:frameIndex]
|
86
|
+
def frameIndex=(v) self[:frameIndex] = v end
|
87
|
+
def bufferIndex = self[:bufferIndex]
|
88
|
+
def bufferIndex=(v) self[:bufferIndex] = v end
|
89
|
+
def self.create_as(_virt_, _codec_, _lastResult_, _handle_, _frameIndex_, _bufferIndex_)
|
90
|
+
instance = BLImageEncoderImpl.new
|
91
|
+
instance[:virt] = _virt_
|
92
|
+
instance[:codec] = _codec_
|
93
|
+
instance[:lastResult] = _lastResult_
|
94
|
+
instance[:handle] = _handle_
|
95
|
+
instance[:frameIndex] = _frameIndex_
|
96
|
+
instance[:bufferIndex] = _bufferIndex_
|
97
|
+
instance
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# Function
|
103
|
+
|
104
|
+
def self.setup_imageencoder_symbols(output_error = false)
|
105
|
+
symbols = [
|
106
|
+
:blImageEncoderInit,
|
107
|
+
:blImageEncoderInitMove,
|
108
|
+
:blImageEncoderInitWeak,
|
109
|
+
:blImageEncoderDestroy,
|
110
|
+
:blImageEncoderReset,
|
111
|
+
:blImageEncoderAssignMove,
|
112
|
+
:blImageEncoderAssignWeak,
|
113
|
+
:blImageEncoderRestart,
|
114
|
+
:blImageEncoderWriteFrame,
|
115
|
+
]
|
116
|
+
apis = {
|
117
|
+
:blImageEncoderInit => :blImageEncoderInit,
|
118
|
+
:blImageEncoderInitMove => :blImageEncoderInitMove,
|
119
|
+
:blImageEncoderInitWeak => :blImageEncoderInitWeak,
|
120
|
+
:blImageEncoderDestroy => :blImageEncoderDestroy,
|
121
|
+
:blImageEncoderReset => :blImageEncoderReset,
|
122
|
+
:blImageEncoderAssignMove => :blImageEncoderAssignMove,
|
123
|
+
:blImageEncoderAssignWeak => :blImageEncoderAssignWeak,
|
124
|
+
:blImageEncoderRestart => :blImageEncoderRestart,
|
125
|
+
:blImageEncoderWriteFrame => :blImageEncoderWriteFrame,
|
126
|
+
}
|
127
|
+
args = {
|
128
|
+
:blImageEncoderInit => [:pointer],
|
129
|
+
:blImageEncoderInitMove => [:pointer, :pointer],
|
130
|
+
:blImageEncoderInitWeak => [:pointer, :pointer],
|
131
|
+
:blImageEncoderDestroy => [:pointer],
|
132
|
+
:blImageEncoderReset => [:pointer],
|
133
|
+
:blImageEncoderAssignMove => [:pointer, :pointer],
|
134
|
+
:blImageEncoderAssignWeak => [:pointer, :pointer],
|
135
|
+
:blImageEncoderRestart => [:pointer],
|
136
|
+
:blImageEncoderWriteFrame => [:pointer, :pointer, :pointer],
|
137
|
+
}
|
138
|
+
retvals = {
|
139
|
+
:blImageEncoderInit => :uint,
|
140
|
+
:blImageEncoderInitMove => :uint,
|
141
|
+
:blImageEncoderInitWeak => :uint,
|
142
|
+
:blImageEncoderDestroy => :uint,
|
143
|
+
:blImageEncoderReset => :uint,
|
144
|
+
:blImageEncoderAssignMove => :uint,
|
145
|
+
:blImageEncoderAssignWeak => :uint,
|
146
|
+
:blImageEncoderRestart => :uint,
|
147
|
+
:blImageEncoderWriteFrame => :uint,
|
148
|
+
}
|
149
|
+
symbols.each do |sym|
|
150
|
+
begin
|
151
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
152
|
+
rescue FFI::NotFoundError => error
|
153
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/blend2d-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
require_relative 'blend2d_geometry'
|
9
|
+
|
10
|
+
module Blend2D
|
11
|
+
extend FFI::Library
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
|
15
|
+
# Enum
|
16
|
+
|
17
|
+
BL_TRANSFORM_TYPE_IDENTITY = 0
|
18
|
+
BL_TRANSFORM_TYPE_TRANSLATE = 1
|
19
|
+
BL_TRANSFORM_TYPE_SCALE = 2
|
20
|
+
BL_TRANSFORM_TYPE_SWAP = 3
|
21
|
+
BL_TRANSFORM_TYPE_AFFINE = 4
|
22
|
+
BL_TRANSFORM_TYPE_INVALID = 5
|
23
|
+
BL_TRANSFORM_TYPE_MAX_VALUE = 5
|
24
|
+
BL_MATRIX2D_TYPE_FORCE_UINT = -1
|
25
|
+
BL_TRANSFORM_OP_RESET = 0
|
26
|
+
BL_TRANSFORM_OP_ASSIGN = 1
|
27
|
+
BL_TRANSFORM_OP_TRANSLATE = 2
|
28
|
+
BL_TRANSFORM_OP_SCALE = 3
|
29
|
+
BL_TRANSFORM_OP_SKEW = 4
|
30
|
+
BL_TRANSFORM_OP_ROTATE = 5
|
31
|
+
BL_TRANSFORM_OP_ROTATE_PT = 6
|
32
|
+
BL_TRANSFORM_OP_TRANSFORM = 7
|
33
|
+
BL_TRANSFORM_OP_POST_TRANSLATE = 8
|
34
|
+
BL_TRANSFORM_OP_POST_SCALE = 9
|
35
|
+
BL_TRANSFORM_OP_POST_SKEW = 10
|
36
|
+
BL_TRANSFORM_OP_POST_ROTATE = 11
|
37
|
+
BL_TRANSFORM_OP_POST_ROTATE_PT = 12
|
38
|
+
BL_TRANSFORM_OP_POST_TRANSFORM = 13
|
39
|
+
BL_TRANSFORM_OP_MAX_VALUE = 13
|
40
|
+
BL_TRANSFORM_OP_FORCE_UINT = -1
|
41
|
+
|
42
|
+
# Typedef
|
43
|
+
|
44
|
+
|
45
|
+
class BLMatrix2D_Contents_Elements < FFI::Struct
|
46
|
+
layout(
|
47
|
+
:m00, :double,
|
48
|
+
:m01, :double,
|
49
|
+
:m10, :double,
|
50
|
+
:m11, :double,
|
51
|
+
:m20, :double,
|
52
|
+
:m21, :double,
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
class BLMatrix2D_Contents < FFI::Union
|
57
|
+
layout(
|
58
|
+
:m, [:double, 6],
|
59
|
+
:elements, BLMatrix2D_Contents_Elements,
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
class BLMatrix2D < FFI::Struct
|
64
|
+
layout(
|
65
|
+
:contents, BLMatrix2D_Contents,
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
typedef :int, :BLTransformType
|
70
|
+
typedef :int, :BLTransformOp
|
71
|
+
|
72
|
+
# Struct
|
73
|
+
|
74
|
+
|
75
|
+
# Function
|
76
|
+
|
77
|
+
def self.setup_matrix_symbols(output_error = false)
|
78
|
+
symbols = [
|
79
|
+
:blMatrix2DSetIdentity,
|
80
|
+
:blMatrix2DSetTranslation,
|
81
|
+
:blMatrix2DSetScaling,
|
82
|
+
:blMatrix2DSetSkewing,
|
83
|
+
:blMatrix2DSetRotation,
|
84
|
+
:blMatrix2DApplyOp,
|
85
|
+
:blMatrix2DInvert,
|
86
|
+
:blMatrix2DGetType,
|
87
|
+
:blMatrix2DMapPointDArray,
|
88
|
+
]
|
89
|
+
apis = {
|
90
|
+
:blMatrix2DSetIdentity => :blMatrix2DSetIdentity,
|
91
|
+
:blMatrix2DSetTranslation => :blMatrix2DSetTranslation,
|
92
|
+
:blMatrix2DSetScaling => :blMatrix2DSetScaling,
|
93
|
+
:blMatrix2DSetSkewing => :blMatrix2DSetSkewing,
|
94
|
+
:blMatrix2DSetRotation => :blMatrix2DSetRotation,
|
95
|
+
:blMatrix2DApplyOp => :blMatrix2DApplyOp,
|
96
|
+
:blMatrix2DInvert => :blMatrix2DInvert,
|
97
|
+
:blMatrix2DGetType => :blMatrix2DGetType,
|
98
|
+
:blMatrix2DMapPointDArray => :blMatrix2DMapPointDArray,
|
99
|
+
}
|
100
|
+
args = {
|
101
|
+
:blMatrix2DSetIdentity => [:pointer],
|
102
|
+
:blMatrix2DSetTranslation => [:pointer, :double, :double],
|
103
|
+
:blMatrix2DSetScaling => [:pointer, :double, :double],
|
104
|
+
:blMatrix2DSetSkewing => [:pointer, :double, :double],
|
105
|
+
:blMatrix2DSetRotation => [:pointer, :double, :double, :double],
|
106
|
+
:blMatrix2DApplyOp => [:pointer, :int, :pointer],
|
107
|
+
:blMatrix2DInvert => [:pointer, :pointer],
|
108
|
+
:blMatrix2DGetType => [:pointer],
|
109
|
+
:blMatrix2DMapPointDArray => [:pointer, :pointer, :pointer, :ulong_long],
|
110
|
+
}
|
111
|
+
retvals = {
|
112
|
+
:blMatrix2DSetIdentity => :uint,
|
113
|
+
:blMatrix2DSetTranslation => :uint,
|
114
|
+
:blMatrix2DSetScaling => :uint,
|
115
|
+
:blMatrix2DSetSkewing => :uint,
|
116
|
+
:blMatrix2DSetRotation => :uint,
|
117
|
+
:blMatrix2DApplyOp => :uint,
|
118
|
+
:blMatrix2DInvert => :uint,
|
119
|
+
:blMatrix2DGetType => :int,
|
120
|
+
:blMatrix2DMapPointDArray => :uint,
|
121
|
+
}
|
122
|
+
symbols.each do |sym|
|
123
|
+
begin
|
124
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
125
|
+
rescue FFI::NotFoundError => error
|
126
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
@@ -0,0 +1,326 @@
|
|
1
|
+
# Ruby-Blend2D : Yet another Blend2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/blend2d-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
require_relative 'blend2d_rgba'
|
9
|
+
|
10
|
+
module Blend2D
|
11
|
+
extend FFI::Library
|
12
|
+
# Define/Macro
|
13
|
+
|
14
|
+
|
15
|
+
# Enum
|
16
|
+
|
17
|
+
BL_OBJECT_INFO_P_SHIFT = 0
|
18
|
+
BL_OBJECT_INFO_Q_SHIFT = 8
|
19
|
+
BL_OBJECT_INFO_C_SHIFT = 8
|
20
|
+
BL_OBJECT_INFO_B_SHIFT = 12
|
21
|
+
BL_OBJECT_INFO_A_SHIFT = 16
|
22
|
+
BL_OBJECT_INFO_TYPE_SHIFT = 22
|
23
|
+
BL_OBJECT_INFO_R_SHIFT = 29
|
24
|
+
BL_OBJECT_INFO_D_SHIFT = 30
|
25
|
+
BL_OBJECT_INFO_M_SHIFT = 31
|
26
|
+
BL_OBJECT_INFO_SHIFT_FORCE_UINT = -1
|
27
|
+
BL_OBJECT_INFO_P_MASK = 255
|
28
|
+
BL_OBJECT_INFO_Q_MASK = 65280
|
29
|
+
BL_OBJECT_INFO_C_MASK = 3840
|
30
|
+
BL_OBJECT_INFO_B_MASK = 61440
|
31
|
+
BL_OBJECT_INFO_A_MASK = 4128768
|
32
|
+
BL_OBJECT_INFO_FIELDS_MASK = 4194303
|
33
|
+
BL_OBJECT_INFO_TYPE_MASK = 532676608
|
34
|
+
BL_OBJECT_INFO_R_FLAG = 536870912
|
35
|
+
BL_OBJECT_INFO_D_FLAG = 1073741824
|
36
|
+
BL_OBJECT_INFO_M_FLAG = -2147483648
|
37
|
+
BL_OBJECT_INFO_MD_FLAGS = -1073741824
|
38
|
+
BL_OBJECT_INFO_MDR_FLAGS = -536870912
|
39
|
+
BL_OBJECT_INFO_BITS_FORCE_UINT = -1
|
40
|
+
BL_OBJECT_TYPE_RGBA = 0
|
41
|
+
BL_OBJECT_TYPE_RGBA32 = 1
|
42
|
+
BL_OBJECT_TYPE_RGBA64 = 2
|
43
|
+
BL_OBJECT_TYPE_NULL = 3
|
44
|
+
BL_OBJECT_TYPE_PATTERN = 4
|
45
|
+
BL_OBJECT_TYPE_GRADIENT = 5
|
46
|
+
BL_OBJECT_TYPE_IMAGE = 9
|
47
|
+
BL_OBJECT_TYPE_PATH = 10
|
48
|
+
BL_OBJECT_TYPE_FONT = 16
|
49
|
+
BL_OBJECT_TYPE_FONT_FEATURE_SETTINGS = 17
|
50
|
+
BL_OBJECT_TYPE_FONT_VARIATION_SETTINGS = 18
|
51
|
+
BL_OBJECT_TYPE_BIT_ARRAY = 25
|
52
|
+
BL_OBJECT_TYPE_BIT_SET = 26
|
53
|
+
BL_OBJECT_TYPE_BOOL = 28
|
54
|
+
BL_OBJECT_TYPE_INT64 = 29
|
55
|
+
BL_OBJECT_TYPE_UINT64 = 30
|
56
|
+
BL_OBJECT_TYPE_DOUBLE = 31
|
57
|
+
BL_OBJECT_TYPE_STRING = 32
|
58
|
+
BL_OBJECT_TYPE_ARRAY_OBJECT = 33
|
59
|
+
BL_OBJECT_TYPE_ARRAY_INT8 = 34
|
60
|
+
BL_OBJECT_TYPE_ARRAY_UINT8 = 35
|
61
|
+
BL_OBJECT_TYPE_ARRAY_INT16 = 36
|
62
|
+
BL_OBJECT_TYPE_ARRAY_UINT16 = 37
|
63
|
+
BL_OBJECT_TYPE_ARRAY_INT32 = 38
|
64
|
+
BL_OBJECT_TYPE_ARRAY_UINT32 = 39
|
65
|
+
BL_OBJECT_TYPE_ARRAY_INT64 = 40
|
66
|
+
BL_OBJECT_TYPE_ARRAY_UINT64 = 41
|
67
|
+
BL_OBJECT_TYPE_ARRAY_FLOAT32 = 42
|
68
|
+
BL_OBJECT_TYPE_ARRAY_FLOAT64 = 43
|
69
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_1 = 44
|
70
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_2 = 45
|
71
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_3 = 46
|
72
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_4 = 47
|
73
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_6 = 48
|
74
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_8 = 49
|
75
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_10 = 50
|
76
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_12 = 51
|
77
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_16 = 52
|
78
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_20 = 53
|
79
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_24 = 54
|
80
|
+
BL_OBJECT_TYPE_ARRAY_STRUCT_32 = 55
|
81
|
+
BL_OBJECT_TYPE_CONTEXT = 100
|
82
|
+
BL_OBJECT_TYPE_IMAGE_CODEC = 101
|
83
|
+
BL_OBJECT_TYPE_IMAGE_DECODER = 102
|
84
|
+
BL_OBJECT_TYPE_IMAGE_ENCODER = 103
|
85
|
+
BL_OBJECT_TYPE_FONT_FACE = 104
|
86
|
+
BL_OBJECT_TYPE_FONT_DATA = 105
|
87
|
+
BL_OBJECT_TYPE_FONT_MANAGER = 106
|
88
|
+
BL_OBJECT_TYPE_MIN_ARRAY = 33
|
89
|
+
BL_OBJECT_TYPE_MAX_ARRAY = 55
|
90
|
+
BL_OBJECT_TYPE_MIN_STYLE = 0
|
91
|
+
BL_OBJECT_TYPE_MAX_STYLE = 5
|
92
|
+
BL_OBJECT_TYPE_MIN_VIRTUAL = 100
|
93
|
+
BL_OBJECT_TYPE_MAX_VIRTUAL = 127
|
94
|
+
BL_OBJECT_TYPE_MAX_VALUE = 127
|
95
|
+
BL_OBJECT_TYPE_FORCE_UINT = -1
|
96
|
+
|
97
|
+
# Typedef
|
98
|
+
|
99
|
+
|
100
|
+
class BLObjectInfo < FFI::Struct
|
101
|
+
layout(
|
102
|
+
:bits, :uint,
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
class BLObjectDetail_struct < FFI::Struct
|
107
|
+
layout(
|
108
|
+
:u32_data_overlap, [:uint, 2],
|
109
|
+
:impl_payload, :uint,
|
110
|
+
:info, BLObjectInfo,
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
class BLObjectDetail < FFI::Union
|
115
|
+
layout(
|
116
|
+
:impl, :pointer,
|
117
|
+
:char_data, [:char, 16],
|
118
|
+
:i8_data, [:char, 16],
|
119
|
+
:u8_data, [:uchar, 16],
|
120
|
+
:i16_data, [:short, 8],
|
121
|
+
:u16_data, [:ushort, 8],
|
122
|
+
:i32_data, [:int, 4],
|
123
|
+
:u32_data, [:uint, 4],
|
124
|
+
:i64_data, [:long_long, 2],
|
125
|
+
:u64_data, [:ulong_long, 2],
|
126
|
+
:f32_data, [:float, 4],
|
127
|
+
:f64_data, [:double, 2],
|
128
|
+
:rgba, BLRgba,
|
129
|
+
:rgba32, BLRgba32,
|
130
|
+
:rgba64, BLRgba64,
|
131
|
+
:struct, BLObjectDetail_struct,
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
typedef :int, :BLObjectInfoShift
|
136
|
+
typedef :int, :BLObjectInfoBits
|
137
|
+
typedef :int, :BLObjectType
|
138
|
+
callback :BLDestroyExternalDataFunc, [:pointer, :pointer, :pointer], :void
|
139
|
+
|
140
|
+
# Struct
|
141
|
+
|
142
|
+
class BLObjectVirtBase < FFI::Struct
|
143
|
+
layout(
|
144
|
+
:destroy, :pointer,
|
145
|
+
:getProperty, :pointer,
|
146
|
+
:setProperty, :pointer,
|
147
|
+
)
|
148
|
+
def destroy = self[:destroy]
|
149
|
+
def destroy=(v) self[:destroy] = v end
|
150
|
+
def getProperty = self[:getProperty]
|
151
|
+
def getProperty=(v) self[:getProperty] = v end
|
152
|
+
def setProperty = self[:setProperty]
|
153
|
+
def setProperty=(v) self[:setProperty] = v end
|
154
|
+
def self.create_as(_destroy_, _getProperty_, _setProperty_)
|
155
|
+
instance = BLObjectVirtBase.new
|
156
|
+
instance[:destroy] = _destroy_
|
157
|
+
instance[:getProperty] = _getProperty_
|
158
|
+
instance[:setProperty] = _setProperty_
|
159
|
+
instance
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
class BLObjectVirt < FFI::Struct
|
164
|
+
layout(
|
165
|
+
:base, BLObjectVirtBase,
|
166
|
+
)
|
167
|
+
def base = self[:base]
|
168
|
+
def base=(v) self[:base] = v end
|
169
|
+
def self.create_as(_base_)
|
170
|
+
instance = BLObjectVirt.new
|
171
|
+
instance[:base] = _base_
|
172
|
+
instance
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class BLObjectCore < FFI::Struct
|
177
|
+
layout(
|
178
|
+
:_d, BLObjectDetail,
|
179
|
+
)
|
180
|
+
def _d = self[:_d]
|
181
|
+
def _d=(v) self[:_d] = v end
|
182
|
+
def allocImpl(objectInfo, implSize) = blObjectAllocImpl(self, objectInfo, implSize)
|
183
|
+
def allocImplAligned(objectInfo, implSize, implAlignment) = blObjectAllocImplAligned(self, objectInfo, implSize, implAlignment)
|
184
|
+
def allocImplExternal(objectInfo, implSize, immutable, destroyFunc, userData) = blObjectAllocImplExternal(self, objectInfo, implSize, immutable, destroyFunc, userData)
|
185
|
+
def freeImpl() = blObjectFreeImpl(impl)
|
186
|
+
def initMove(other) = blObjectInitMove(self, other)
|
187
|
+
def initWeak(other) = blObjectInitWeak(self, other)
|
188
|
+
def reset() = blObjectReset(self)
|
189
|
+
def assignMove(other) = blObjectAssignMove(self, other)
|
190
|
+
def assignWeak(other) = blObjectAssignWeak(self, other)
|
191
|
+
def getProperty(name, nameSize, valueOut) = blObjectGetProperty(self, name, nameSize, valueOut)
|
192
|
+
def getPropertyBool(name, nameSize, valueOut) = blObjectGetPropertyBool(self, name, nameSize, valueOut)
|
193
|
+
def getPropertyInt32(name, nameSize, valueOut) = blObjectGetPropertyInt32(self, name, nameSize, valueOut)
|
194
|
+
def getPropertyInt64(name, nameSize, valueOut) = blObjectGetPropertyInt64(self, name, nameSize, valueOut)
|
195
|
+
def getPropertyUInt32(name, nameSize, valueOut) = blObjectGetPropertyUInt32(self, name, nameSize, valueOut)
|
196
|
+
def getPropertyUInt64(name, nameSize, valueOut) = blObjectGetPropertyUInt64(self, name, nameSize, valueOut)
|
197
|
+
def getPropertyDouble(name, nameSize, valueOut) = blObjectGetPropertyDouble(self, name, nameSize, valueOut)
|
198
|
+
def setProperty(name, nameSize, value) = blObjectSetProperty(self, name, nameSize, value)
|
199
|
+
def setPropertyBool(name, nameSize, value) = blObjectSetPropertyBool(self, name, nameSize, value)
|
200
|
+
def setPropertyInt32(name, nameSize, value) = blObjectSetPropertyInt32(self, name, nameSize, value)
|
201
|
+
def setPropertyInt64(name, nameSize, value) = blObjectSetPropertyInt64(self, name, nameSize, value)
|
202
|
+
def setPropertyUInt32(name, nameSize, value) = blObjectSetPropertyUInt32(self, name, nameSize, value)
|
203
|
+
def setPropertyUInt64(name, nameSize, value) = blObjectSetPropertyUInt64(self, name, nameSize, value)
|
204
|
+
def setPropertyDouble(name, nameSize, value) = blObjectSetPropertyDouble(self, name, nameSize, value)
|
205
|
+
def self.create_as(__d_)
|
206
|
+
instance = BLObjectCore.new
|
207
|
+
instance[:_d] = __d_
|
208
|
+
instance
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
# Function
|
214
|
+
|
215
|
+
def self.setup_object_symbols(output_error = false)
|
216
|
+
symbols = [
|
217
|
+
:blObjectAllocImpl,
|
218
|
+
:blObjectAllocImplAligned,
|
219
|
+
:blObjectAllocImplExternal,
|
220
|
+
:blObjectFreeImpl,
|
221
|
+
:blObjectInitMove,
|
222
|
+
:blObjectInitWeak,
|
223
|
+
:blObjectReset,
|
224
|
+
:blObjectAssignMove,
|
225
|
+
:blObjectAssignWeak,
|
226
|
+
:blObjectGetProperty,
|
227
|
+
:blObjectGetPropertyBool,
|
228
|
+
:blObjectGetPropertyInt32,
|
229
|
+
:blObjectGetPropertyInt64,
|
230
|
+
:blObjectGetPropertyUInt32,
|
231
|
+
:blObjectGetPropertyUInt64,
|
232
|
+
:blObjectGetPropertyDouble,
|
233
|
+
:blObjectSetProperty,
|
234
|
+
:blObjectSetPropertyBool,
|
235
|
+
:blObjectSetPropertyInt32,
|
236
|
+
:blObjectSetPropertyInt64,
|
237
|
+
:blObjectSetPropertyUInt32,
|
238
|
+
:blObjectSetPropertyUInt64,
|
239
|
+
:blObjectSetPropertyDouble,
|
240
|
+
]
|
241
|
+
apis = {
|
242
|
+
:blObjectAllocImpl => :blObjectAllocImpl,
|
243
|
+
:blObjectAllocImplAligned => :blObjectAllocImplAligned,
|
244
|
+
:blObjectAllocImplExternal => :blObjectAllocImplExternal,
|
245
|
+
:blObjectFreeImpl => :blObjectFreeImpl,
|
246
|
+
:blObjectInitMove => :blObjectInitMove,
|
247
|
+
:blObjectInitWeak => :blObjectInitWeak,
|
248
|
+
:blObjectReset => :blObjectReset,
|
249
|
+
:blObjectAssignMove => :blObjectAssignMove,
|
250
|
+
:blObjectAssignWeak => :blObjectAssignWeak,
|
251
|
+
:blObjectGetProperty => :blObjectGetProperty,
|
252
|
+
:blObjectGetPropertyBool => :blObjectGetPropertyBool,
|
253
|
+
:blObjectGetPropertyInt32 => :blObjectGetPropertyInt32,
|
254
|
+
:blObjectGetPropertyInt64 => :blObjectGetPropertyInt64,
|
255
|
+
:blObjectGetPropertyUInt32 => :blObjectGetPropertyUInt32,
|
256
|
+
:blObjectGetPropertyUInt64 => :blObjectGetPropertyUInt64,
|
257
|
+
:blObjectGetPropertyDouble => :blObjectGetPropertyDouble,
|
258
|
+
:blObjectSetProperty => :blObjectSetProperty,
|
259
|
+
:blObjectSetPropertyBool => :blObjectSetPropertyBool,
|
260
|
+
:blObjectSetPropertyInt32 => :blObjectSetPropertyInt32,
|
261
|
+
:blObjectSetPropertyInt64 => :blObjectSetPropertyInt64,
|
262
|
+
:blObjectSetPropertyUInt32 => :blObjectSetPropertyUInt32,
|
263
|
+
:blObjectSetPropertyUInt64 => :blObjectSetPropertyUInt64,
|
264
|
+
:blObjectSetPropertyDouble => :blObjectSetPropertyDouble,
|
265
|
+
}
|
266
|
+
args = {
|
267
|
+
:blObjectAllocImpl => [:pointer, :uint, :ulong_long],
|
268
|
+
:blObjectAllocImplAligned => [:pointer, :uint, :ulong_long, :ulong_long],
|
269
|
+
:blObjectAllocImplExternal => [:pointer, :uint, :ulong_long, :bool, :BLDestroyExternalDataFunc, :pointer],
|
270
|
+
:blObjectFreeImpl => [:pointer],
|
271
|
+
:blObjectInitMove => [:pointer, :pointer],
|
272
|
+
:blObjectInitWeak => [:pointer, :pointer],
|
273
|
+
:blObjectReset => [:pointer],
|
274
|
+
:blObjectAssignMove => [:pointer, :pointer],
|
275
|
+
:blObjectAssignWeak => [:pointer, :pointer],
|
276
|
+
:blObjectGetProperty => [:pointer, :pointer, :ulong_long, :pointer],
|
277
|
+
:blObjectGetPropertyBool => [:pointer, :pointer, :ulong_long, :pointer],
|
278
|
+
:blObjectGetPropertyInt32 => [:pointer, :pointer, :ulong_long, :pointer],
|
279
|
+
:blObjectGetPropertyInt64 => [:pointer, :pointer, :ulong_long, :pointer],
|
280
|
+
:blObjectGetPropertyUInt32 => [:pointer, :pointer, :ulong_long, :pointer],
|
281
|
+
:blObjectGetPropertyUInt64 => [:pointer, :pointer, :ulong_long, :pointer],
|
282
|
+
:blObjectGetPropertyDouble => [:pointer, :pointer, :ulong_long, :pointer],
|
283
|
+
:blObjectSetProperty => [:pointer, :pointer, :ulong_long, :pointer],
|
284
|
+
:blObjectSetPropertyBool => [:pointer, :pointer, :ulong_long, :bool],
|
285
|
+
:blObjectSetPropertyInt32 => [:pointer, :pointer, :ulong_long, :int],
|
286
|
+
:blObjectSetPropertyInt64 => [:pointer, :pointer, :ulong_long, :long_long],
|
287
|
+
:blObjectSetPropertyUInt32 => [:pointer, :pointer, :ulong_long, :uint],
|
288
|
+
:blObjectSetPropertyUInt64 => [:pointer, :pointer, :ulong_long, :ulong_long],
|
289
|
+
:blObjectSetPropertyDouble => [:pointer, :pointer, :ulong_long, :double],
|
290
|
+
}
|
291
|
+
retvals = {
|
292
|
+
:blObjectAllocImpl => :uint,
|
293
|
+
:blObjectAllocImplAligned => :uint,
|
294
|
+
:blObjectAllocImplExternal => :uint,
|
295
|
+
:blObjectFreeImpl => :uint,
|
296
|
+
:blObjectInitMove => :uint,
|
297
|
+
:blObjectInitWeak => :uint,
|
298
|
+
:blObjectReset => :uint,
|
299
|
+
:blObjectAssignMove => :uint,
|
300
|
+
:blObjectAssignWeak => :uint,
|
301
|
+
:blObjectGetProperty => :uint,
|
302
|
+
:blObjectGetPropertyBool => :uint,
|
303
|
+
:blObjectGetPropertyInt32 => :uint,
|
304
|
+
:blObjectGetPropertyInt64 => :uint,
|
305
|
+
:blObjectGetPropertyUInt32 => :uint,
|
306
|
+
:blObjectGetPropertyUInt64 => :uint,
|
307
|
+
:blObjectGetPropertyDouble => :uint,
|
308
|
+
:blObjectSetProperty => :uint,
|
309
|
+
:blObjectSetPropertyBool => :uint,
|
310
|
+
:blObjectSetPropertyInt32 => :uint,
|
311
|
+
:blObjectSetPropertyInt64 => :uint,
|
312
|
+
:blObjectSetPropertyUInt32 => :uint,
|
313
|
+
:blObjectSetPropertyUInt64 => :uint,
|
314
|
+
:blObjectSetPropertyDouble => :uint,
|
315
|
+
}
|
316
|
+
symbols.each do |sym|
|
317
|
+
begin
|
318
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
319
|
+
rescue FFI::NotFoundError => error
|
320
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
end
|
326
|
+
|