ffi 1.0.9 → 1.0.10
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 +4 -4
- data/ext/ffi_c/AbstractMemory.c +367 -14
- data/ext/ffi_c/AbstractMemory.h +4 -0
- data/ext/ffi_c/ArrayType.c +28 -0
- data/ext/ffi_c/Buffer.c +101 -25
- data/ext/ffi_c/Call.c +8 -5
- data/ext/ffi_c/ClosurePool.c +9 -8
- data/ext/ffi_c/DataConverter.c +29 -0
- data/ext/ffi_c/DynamicLibrary.c +64 -1
- data/ext/ffi_c/Function.c +111 -10
- data/ext/ffi_c/FunctionInfo.c +13 -1
- data/ext/ffi_c/LastError.c +16 -0
- data/ext/ffi_c/MappedType.c +22 -0
- data/ext/ffi_c/MemoryPointer.c +11 -1
- data/ext/ffi_c/MethodHandle.c +18 -11
- data/ext/ffi_c/Platform.c +9 -3
- data/ext/ffi_c/Pointer.c +98 -0
- data/ext/ffi_c/Struct.c +4 -4
- data/ext/ffi_c/Struct.h +2 -1
- data/ext/ffi_c/StructLayout.c +2 -2
- data/ext/ffi_c/Thread.c +124 -1
- data/ext/ffi_c/Type.c +108 -17
- data/ext/ffi_c/Types.c +9 -2
- data/ext/ffi_c/Variadic.c +5 -4
- data/ext/ffi_c/compat.h +8 -0
- data/ext/ffi_c/endian.h +7 -1
- data/ext/ffi_c/extconf.rb +46 -35
- data/ext/ffi_c/ffi.c +5 -0
- data/ext/ffi_c/libffi.darwin.mk +15 -15
- data/ext/ffi_c/libffi.gnu.mk +3 -3
- data/ext/ffi_c/libffi.mk +4 -4
- data/lib/ffi.rb +13 -9
- data/lib/ffi/autopointer.rb +88 -26
- data/lib/ffi/enum.rb +42 -0
- data/lib/ffi/errno.rb +6 -1
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/io.rb +13 -2
- data/lib/ffi/library.rb +212 -19
- data/lib/ffi/memorypointer.rb +1 -33
- data/lib/ffi/platform.rb +23 -7
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +126 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
- data/lib/ffi/pointer.rb +44 -0
- data/lib/ffi/struct.rb +1 -1
- data/lib/ffi/struct_layout_builder.rb +2 -1
- data/lib/ffi/tools/const_generator.rb +72 -17
- data/lib/ffi/types.rb +21 -1
- data/spec/ffi/rbx/memory_pointer_spec.rb +4 -2
- data/spec/ffi/struct_spec.rb +10 -0
- data/spec/ffi/typedef_spec.rb +11 -0
- data/tasks/extension.rake +0 -1
- data/tasks/gem.rake +0 -1
- data/tasks/yard.rake +11 -0
- metadata +15 -8
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ require 'rbconfig'
|
|
14
14
|
|
15
15
|
load 'tasks/setup.rb'
|
16
16
|
|
17
|
-
LIBEXT = case
|
17
|
+
LIBEXT = case RbConfig::CONFIG['host_os'].downcase
|
18
18
|
when /darwin/
|
19
19
|
"dylib"
|
20
20
|
when /mswin|mingw/
|
@@ -23,7 +23,7 @@ LIBEXT = case Config::CONFIG['host_os'].downcase
|
|
23
23
|
Config::CONFIG['DLEXT']
|
24
24
|
end
|
25
25
|
|
26
|
-
CPU = case
|
26
|
+
CPU = case RbConfig::CONFIG['host_cpu'].downcase
|
27
27
|
when /i[3456]86/
|
28
28
|
# Darwin always reports i686, even when running in 64bit mode
|
29
29
|
if Config::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
|
@@ -64,7 +64,7 @@ OS = case Config::CONFIG['host_os'].downcase
|
|
64
64
|
|
65
65
|
CC=ENV['CC'] || Config::CONFIG['CC'] || "gcc"
|
66
66
|
|
67
|
-
GMAKE =
|
67
|
+
GMAKE = system('which gmake >/dev/null') && 'gmake' || 'make'
|
68
68
|
|
69
69
|
LIBTEST = "build/libtest.#{LIBEXT}"
|
70
70
|
BUILD_DIR = "build"
|
@@ -75,7 +75,7 @@ PROJ.name = 'ffi'
|
|
75
75
|
PROJ.authors = 'Wayne Meissner'
|
76
76
|
PROJ.email = 'wmeissner@gmail.com'
|
77
77
|
PROJ.url = 'http://wiki.github.com/ffi/ffi'
|
78
|
-
PROJ.version = '1.0.
|
78
|
+
PROJ.version = '1.0.10'
|
79
79
|
PROJ.rubyforge.name = 'ffi'
|
80
80
|
PROJ.readme_file = 'README.rdoc'
|
81
81
|
|
data/ext/ffi_c/AbstractMemory.c
CHANGED
@@ -256,6 +256,26 @@ get_pointer_value(VALUE value)
|
|
256
256
|
|
257
257
|
NUM_OP(pointer, void *, get_pointer_value, rbffi_Pointer_NewInstance, NOSWAP);
|
258
258
|
|
259
|
+
static inline uint8_t
|
260
|
+
rbffi_bool_value(VALUE value)
|
261
|
+
{
|
262
|
+
return RTEST(value);
|
263
|
+
}
|
264
|
+
|
265
|
+
static inline VALUE
|
266
|
+
rbffi_bool_new(uint8_t value)
|
267
|
+
{
|
268
|
+
return (value & 1) != 0 ? Qtrue : Qfalse;
|
269
|
+
}
|
270
|
+
|
271
|
+
NUM_OP(bool, unsigned char, rbffi_bool_value, rbffi_bool_new, NOSWAP);
|
272
|
+
|
273
|
+
|
274
|
+
/*
|
275
|
+
* call-seq: memory.clear
|
276
|
+
* Set the memory to all-zero.
|
277
|
+
* @return [self]
|
278
|
+
*/
|
259
279
|
static VALUE
|
260
280
|
memory_clear(VALUE self)
|
261
281
|
{
|
@@ -264,6 +284,11 @@ memory_clear(VALUE self)
|
|
264
284
|
return self;
|
265
285
|
}
|
266
286
|
|
287
|
+
/*
|
288
|
+
* call-seq: memory.size
|
289
|
+
* Return memory size in bytes (alias: #total)
|
290
|
+
* @return [Numeric]
|
291
|
+
*/
|
267
292
|
static VALUE
|
268
293
|
memory_size(VALUE self)
|
269
294
|
{
|
@@ -274,6 +299,15 @@ memory_size(VALUE self)
|
|
274
299
|
return LONG2NUM(ptr->size);
|
275
300
|
}
|
276
301
|
|
302
|
+
/*
|
303
|
+
* call-seq: memory.get_string(offset, length=nil)
|
304
|
+
* Return string contained in memory.
|
305
|
+
* @param [Numeric] offset point in buffer to start from
|
306
|
+
* @param [Numeric] length string's length in bytes. If nil, a (memory size - offset) length string is returned).
|
307
|
+
* @return [String]
|
308
|
+
* @raise {IndexError} if +length+ is too great
|
309
|
+
* @raise {NullPointerError} if memory not initialized
|
310
|
+
*/
|
277
311
|
static VALUE
|
278
312
|
memory_get_string(int argc, VALUE* argv, VALUE self)
|
279
313
|
{
|
@@ -293,6 +327,15 @@ memory_get_string(int argc, VALUE* argv, VALUE self)
|
|
293
327
|
(end != NULL ? end - ptr->address - off : len));
|
294
328
|
}
|
295
329
|
|
330
|
+
/*
|
331
|
+
* call-seq: memory.get_array_of_string(offset, count=nil)
|
332
|
+
* Return an array of strings contained in memory.
|
333
|
+
* @param [Numeric] offset point in memory to start from
|
334
|
+
* @param [Numeric] count number of strings to get. If nil, return all strings
|
335
|
+
* @return [Array<String>]
|
336
|
+
* @raise {IndexError} if +offset+ is too great
|
337
|
+
* @raise {NullPointerError} if memory not initialized
|
338
|
+
*/
|
296
339
|
static VALUE
|
297
340
|
memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
298
341
|
{
|
@@ -333,6 +376,13 @@ memory_get_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
333
376
|
return retVal;
|
334
377
|
}
|
335
378
|
|
379
|
+
/*
|
380
|
+
* call-seq: memory.read_array_of_string(count=nil)
|
381
|
+
* Return an array of strings contained in memory. Same as:
|
382
|
+
* memory.get_array_of_string(0, count)
|
383
|
+
* @param [Numeric] count number of strings to get. If nil, return all strings
|
384
|
+
* @return [Array<String>]
|
385
|
+
*/
|
336
386
|
static VALUE
|
337
387
|
memory_read_array_of_string(int argc, VALUE* argv, VALUE self)
|
338
388
|
{
|
@@ -348,6 +398,16 @@ memory_read_array_of_string(int argc, VALUE* argv, VALUE self)
|
|
348
398
|
}
|
349
399
|
|
350
400
|
|
401
|
+
/*
|
402
|
+
* call-seq: memory.put_string(offset, str)
|
403
|
+
* @param [Numeric] offset
|
404
|
+
* @param [String] str
|
405
|
+
* @return [self]
|
406
|
+
* @raise {SecurityError} when writing unsafe string to memory
|
407
|
+
* @raise {IndexError} if +offset+ is too great
|
408
|
+
* @raise {NullPointerError} if memory not initialized
|
409
|
+
* Put a string in memory.
|
410
|
+
*/
|
351
411
|
static VALUE
|
352
412
|
memory_put_string(VALUE self, VALUE offset, VALUE str)
|
353
413
|
{
|
@@ -372,6 +432,15 @@ memory_put_string(VALUE self, VALUE offset, VALUE str)
|
|
372
432
|
return self;
|
373
433
|
}
|
374
434
|
|
435
|
+
/*
|
436
|
+
* call-seq: memory.get_bytes(offset, length)
|
437
|
+
* Return string contained in memory.
|
438
|
+
* @param [Numeric] offset point in buffer to start from
|
439
|
+
* @param [Numeric] length string's length in bytes.
|
440
|
+
* @return [String]
|
441
|
+
* @raise {IndexError} if +length+ is too great
|
442
|
+
* @raise {NullPointerError} if memory not initialized
|
443
|
+
*/
|
375
444
|
static VALUE
|
376
445
|
memory_get_bytes(VALUE self, VALUE offset, VALUE length)
|
377
446
|
{
|
@@ -387,6 +456,19 @@ memory_get_bytes(VALUE self, VALUE offset, VALUE length)
|
|
387
456
|
return rb_tainted_str_new((char *) ptr->address + off, len);
|
388
457
|
}
|
389
458
|
|
459
|
+
/*
|
460
|
+
* call-seq: memory.put_bytes(offset, str, index=0, length=nil)
|
461
|
+
* Put a string in memory.
|
462
|
+
* @param [Numeric] offset point in buffer to start from
|
463
|
+
* @param [String] str string to put to memory
|
464
|
+
* @param [Numeric] index
|
465
|
+
* @param [Numeric] length string's length in bytes. If nil, a (memory size - offset) length string is returned).
|
466
|
+
* @return [self]
|
467
|
+
* @raise {IndexError} if +length+ is too great
|
468
|
+
* @raise {NullPointerError} if memory not initialized
|
469
|
+
* @raise {RangeError} if +index+ is negative, or if index+length is greater than size of string
|
470
|
+
* @raise {SecurityError} when writing unsafe string to memory
|
471
|
+
*/
|
390
472
|
static VALUE
|
391
473
|
memory_put_bytes(int argc, VALUE* argv, VALUE self)
|
392
474
|
{
|
@@ -421,12 +503,28 @@ memory_put_bytes(int argc, VALUE* argv, VALUE self)
|
|
421
503
|
return self;
|
422
504
|
}
|
423
505
|
|
506
|
+
/*
|
507
|
+
* call-seq: memory.read_bytes(length)
|
508
|
+
* @param [Numeric] length of string to return
|
509
|
+
* @return [String]
|
510
|
+
* equivalent to :
|
511
|
+
* memory.get_bytes(0, length)
|
512
|
+
*/
|
424
513
|
static VALUE
|
425
514
|
memory_read_bytes(VALUE self, VALUE length)
|
426
515
|
{
|
427
516
|
return memory_get_bytes(self, INT2FIX(0), length);
|
428
517
|
}
|
429
518
|
|
519
|
+
/*
|
520
|
+
* call-seq: memory.write_bytes(str, index=0, length=nil)
|
521
|
+
* @param [String] str string to put to memory
|
522
|
+
* @param [Numeric] index
|
523
|
+
* @param [Numeric] length string's length in bytes. If nil, a (memory size - offset) length string is returned).
|
524
|
+
* @return [self]
|
525
|
+
* equivalent to :
|
526
|
+
* memory.put_bytes(0, str, index, length)
|
527
|
+
*/
|
430
528
|
static VALUE
|
431
529
|
memory_write_bytes(int argc, VALUE* argv, VALUE self)
|
432
530
|
{
|
@@ -441,6 +539,11 @@ memory_write_bytes(int argc, VALUE* argv, VALUE self)
|
|
441
539
|
return memory_put_bytes(argc + 1, wargv, self);
|
442
540
|
}
|
443
541
|
|
542
|
+
/*
|
543
|
+
* call-seq: memory.type_size
|
544
|
+
* @return [Numeric] type size in bytes
|
545
|
+
* Get the memory's type size.
|
546
|
+
*/
|
444
547
|
static VALUE
|
445
548
|
memory_type_size(VALUE self)
|
446
549
|
{
|
@@ -451,6 +554,13 @@ memory_type_size(VALUE self)
|
|
451
554
|
return INT2NUM(ptr->typeSize);
|
452
555
|
}
|
453
556
|
|
557
|
+
/*
|
558
|
+
* Document-method: []
|
559
|
+
* call-seq: memory[idx]
|
560
|
+
* @param [Numeric] idx index to access in memory
|
561
|
+
* @return
|
562
|
+
* Memory read accessor.
|
563
|
+
*/
|
454
564
|
static VALUE
|
455
565
|
memory_aref(VALUE self, VALUE idx)
|
456
566
|
{
|
@@ -521,31 +631,64 @@ static MemoryOp memory_op_strptr = { memory_op_get_strptr, memory_op_put_strptr
|
|
521
631
|
//static MemoryOp memory_op_pointer = { memory_op_get_pointer, memory_op_put_pointer };
|
522
632
|
|
523
633
|
MemoryOps rbffi_AbstractMemoryOps = {
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
634
|
+
&memory_op_int8, //.int8
|
635
|
+
&memory_op_uint8, //.uint8
|
636
|
+
&memory_op_int16, //.int16
|
637
|
+
&memory_op_uint16, //.uint16
|
638
|
+
&memory_op_int32, //.int32
|
639
|
+
&memory_op_uint32, //.uint32
|
640
|
+
&memory_op_int64, //.int64
|
641
|
+
&memory_op_uint64, //.uint64
|
642
|
+
&memory_op_long, //.slong
|
643
|
+
&memory_op_ulong, //.uslong
|
644
|
+
&memory_op_float32, //.float32
|
645
|
+
&memory_op_float64, //.float64
|
646
|
+
&memory_op_pointer, //.pointer
|
647
|
+
&memory_op_strptr, //.strptr
|
648
|
+
NULL //.boolOp
|
538
649
|
};
|
539
650
|
|
540
651
|
void
|
541
652
|
rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
542
653
|
{
|
654
|
+
/*
|
655
|
+
* Document-class: FFI::AbstractMemory
|
656
|
+
*
|
657
|
+
* {AbstractMemory} is the base class for many memory management classes such as {Buffer}.
|
658
|
+
*
|
659
|
+
* This class has a lot of methods to work with integers :
|
660
|
+
* * put_int<i>size</i>(offset, value)
|
661
|
+
* * get_int<i>size</i>(offset)
|
662
|
+
* * put_uint<i>size</i>(offset, value)
|
663
|
+
* * get_uint<i>size</i>(offset)
|
664
|
+
* * writeuint<i>size</i>(value)
|
665
|
+
* * read_int<i>size</i>
|
666
|
+
* * write_uint<i>size</i>(value)
|
667
|
+
* * read_uint<i>size</i>
|
668
|
+
* * put_array_of_int<i>size</i>(offset, ary)
|
669
|
+
* * get_array_of_int<i>size</i>(offset, length)
|
670
|
+
* * put_array_of_uint<i>size</i>(offset, ary)
|
671
|
+
* * get_array_of_uint<i>size</i>(offset, length)
|
672
|
+
* * write_array_of_int<i>size</i>(ary)
|
673
|
+
* * read_array_of_int<i>size</i>(length)
|
674
|
+
* * write_array_of_uint<i>size</i>(ary)
|
675
|
+
* * read_array_of_uint<i>size</i>(length)
|
676
|
+
* where _size_ is 8, 16, 32 or 64. Same methods exist for long type.
|
677
|
+
*
|
678
|
+
* Aliases exist : _char_ for _int8_, _short_ for _int16_, _int_ for _int32_ and <i>long_long</i> for _int64_.
|
679
|
+
*
|
680
|
+
* Others methods are listed below.
|
681
|
+
*/
|
543
682
|
VALUE classMemory = rb_define_class_under(moduleFFI, "AbstractMemory", rb_cObject);
|
544
683
|
rbffi_AbstractMemoryClass = classMemory;
|
684
|
+
/*
|
685
|
+
* Document-variable: FFI::AbstractMemory
|
686
|
+
*/
|
545
687
|
rb_global_variable(&rbffi_AbstractMemoryClass);
|
546
688
|
rb_define_alloc_func(classMemory, memory_allocate);
|
547
689
|
|
548
690
|
NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
|
691
|
+
/* Document-variable: NullPointerError */
|
549
692
|
rb_global_variable(&NullPointerErrorClass);
|
550
693
|
|
551
694
|
|
@@ -597,37 +740,247 @@ rbffi_AbstractMemory_Init(VALUE moduleFFI)
|
|
597
740
|
ALIAS(int, int32);
|
598
741
|
ALIAS(long_long, int64);
|
599
742
|
|
743
|
+
/*
|
744
|
+
* Document-method: put_float32
|
745
|
+
* call-seq: memory.put_float32offset, value)
|
746
|
+
* @param [Numeric] offset
|
747
|
+
* @param [Numeric] value
|
748
|
+
* @return [self]
|
749
|
+
* Put +value+ as a 32-bit float in memory at offset +offset+ (alias: #put_float).
|
750
|
+
*/
|
600
751
|
rb_define_method(classMemory, "put_float32", memory_put_float32, 2);
|
752
|
+
/*
|
753
|
+
* Document-method: get_float32
|
754
|
+
* call-seq: memory.get_float32(offset)
|
755
|
+
* @param [Numeric] offset
|
756
|
+
* @return [Float]
|
757
|
+
* Get a 32-bit float from memory at offset +offset+ (alias: #get_float).
|
758
|
+
*/
|
601
759
|
rb_define_method(classMemory, "get_float32", memory_get_float32, 1);
|
602
760
|
rb_define_alias(classMemory, "put_float", "put_float32");
|
603
761
|
rb_define_alias(classMemory, "get_float", "get_float32");
|
762
|
+
/*
|
763
|
+
* Document-method: write_float
|
764
|
+
* call-seq: memory.write_float(value)
|
765
|
+
* @param [Numeric] value
|
766
|
+
* @return [self]
|
767
|
+
* Write +value+ as a 32-bit float in memory.
|
768
|
+
*
|
769
|
+
* Same as:
|
770
|
+
* memory.put_float(0, value)
|
771
|
+
*/
|
604
772
|
rb_define_method(classMemory, "write_float", memory_write_float32, 1);
|
773
|
+
/*
|
774
|
+
* Document-method: read_float
|
775
|
+
* call-seq: memory.read_float
|
776
|
+
* @return [Float]
|
777
|
+
* Read a 32-bit float from memory.
|
778
|
+
*
|
779
|
+
* Same as:
|
780
|
+
* memory.get_float(0)
|
781
|
+
*/
|
605
782
|
rb_define_method(classMemory, "read_float", memory_read_float32, 0);
|
783
|
+
/*
|
784
|
+
* Document-method: put_array_of_float32
|
785
|
+
* call-seq: memory.put_array_of_float32(offset, ary)
|
786
|
+
* @param [Numeric] offset
|
787
|
+
* @param [Array<Numeric>] ary
|
788
|
+
* @return [self]
|
789
|
+
* Put values from +ary+ as 32-bit floats in memory from offset +offset+ (alias: #put_array_of_float).
|
790
|
+
*/
|
606
791
|
rb_define_method(classMemory, "put_array_of_float32", memory_put_array_of_float32, 2);
|
792
|
+
/*
|
793
|
+
* Document-method: get_array_of_float32
|
794
|
+
* call-seq: memory.get_array_of_float32(offset, length)
|
795
|
+
* @param [Numeric] offset
|
796
|
+
* @param [Numeric] length number of Float to get
|
797
|
+
* @return [Array<Float>]
|
798
|
+
* Get 32-bit floats in memory from offset +offset+ (alias: #get_array_of_float).
|
799
|
+
*/
|
607
800
|
rb_define_method(classMemory, "get_array_of_float32", memory_get_array_of_float32, 2);
|
801
|
+
/*
|
802
|
+
* Document-method: write_array_of_float
|
803
|
+
* call-seq: memory.write_array_of_float(ary)
|
804
|
+
* @param [Array<Numeric>] ary
|
805
|
+
* @return [self]
|
806
|
+
* Write values from +ary+ as 32-bit floats in memory.
|
807
|
+
*
|
808
|
+
* Same as:
|
809
|
+
* memory.put_array_of_float(0, ary)
|
810
|
+
*/
|
608
811
|
rb_define_method(classMemory, "write_array_of_float", memory_write_array_of_float32, 1);
|
812
|
+
/*
|
813
|
+
* Document-method: read_array_of_float
|
814
|
+
* call-seq: memory.read_array_of_float(length)
|
815
|
+
* @param [Numeric] length number of Float to read
|
816
|
+
* @return [Array<Float>]
|
817
|
+
* Read 32-bit floats from memory.
|
818
|
+
*
|
819
|
+
* Same as:
|
820
|
+
* memory.get_array_of_float(0, ary)
|
821
|
+
*/
|
609
822
|
rb_define_method(classMemory, "read_array_of_float", memory_read_array_of_float32, 1);
|
610
823
|
rb_define_alias(classMemory, "put_array_of_float", "put_array_of_float32");
|
611
824
|
rb_define_alias(classMemory, "get_array_of_float", "get_array_of_float32");
|
825
|
+
/*
|
826
|
+
* Document-method: put_float64
|
827
|
+
* call-seq: memory.put_float64(offset, value)
|
828
|
+
* @param [Numeric] offset
|
829
|
+
* @param [Numeric] value
|
830
|
+
* @return [self]
|
831
|
+
* Put +value+ as a 64-bit float (double) in memory at offset +offset+ (alias: #put_double).
|
832
|
+
*/
|
612
833
|
rb_define_method(classMemory, "put_float64", memory_put_float64, 2);
|
834
|
+
/*
|
835
|
+
* Document-method: get_float64
|
836
|
+
* call-seq: memory.get_float64(offset)
|
837
|
+
* @param [Numeric] offset
|
838
|
+
* @return [Float]
|
839
|
+
* Get a 64-bit float (double) from memory at offset +offset+ (alias: #get_double).
|
840
|
+
*/
|
613
841
|
rb_define_method(classMemory, "get_float64", memory_get_float64, 1);
|
614
842
|
rb_define_alias(classMemory, "put_double", "put_float64");
|
615
843
|
rb_define_alias(classMemory, "get_double", "get_float64");
|
844
|
+
/*
|
845
|
+
* Document-method: write_double
|
846
|
+
* call-seq: memory.write_double(value)
|
847
|
+
* @param [Numeric] value
|
848
|
+
* @return [self]
|
849
|
+
* Write +value+ as a 64-bit float (double) in memory.
|
850
|
+
*
|
851
|
+
* Same as:
|
852
|
+
* memory.put_double(0, value)
|
853
|
+
*/
|
616
854
|
rb_define_method(classMemory, "write_double", memory_write_float64, 1);
|
855
|
+
/*
|
856
|
+
* Document-method: read_double
|
857
|
+
* call-seq: memory.read_double
|
858
|
+
* @return [Float]
|
859
|
+
* Read a 64-bit float (double) from memory.
|
860
|
+
*
|
861
|
+
* Same as:
|
862
|
+
* memory.get_double(0)
|
863
|
+
*/
|
617
864
|
rb_define_method(classMemory, "read_double", memory_read_float64, 0);
|
865
|
+
/*
|
866
|
+
* Document-method: put_array_of_float64
|
867
|
+
* call-seq: memory.put_array_of_float64(offset, ary)
|
868
|
+
* @param [Numeric] offset
|
869
|
+
* @param [Array<Numeric>] ary
|
870
|
+
* @return [self]
|
871
|
+
* Put values from +ary+ as 64-bit floats (doubles) in memory from offset +offset+ (alias: #put_array_of_double).
|
872
|
+
*/
|
618
873
|
rb_define_method(classMemory, "put_array_of_float64", memory_put_array_of_float64, 2);
|
874
|
+
/*
|
875
|
+
* Document-method: get_array_of_float64
|
876
|
+
* call-seq: memory.get_array_of_float64(offset, length)
|
877
|
+
* @param [Numeric] offset
|
878
|
+
* @param [Numeric] length number of Float to get
|
879
|
+
* @return [Array<Float>]
|
880
|
+
* Get 64-bit floats (doubles) in memory from offset +offset+ (alias: #get_array_of_double).
|
881
|
+
*/
|
619
882
|
rb_define_method(classMemory, "get_array_of_float64", memory_get_array_of_float64, 2);
|
883
|
+
/*
|
884
|
+
* Document-method: write_array_of_double
|
885
|
+
* call-seq: memory.write_array_of_double(ary)
|
886
|
+
* @param [Array<Numeric>] ary
|
887
|
+
* @return [self]
|
888
|
+
* Write values from +ary+ as 64-bit floats (doubles) in memory.
|
889
|
+
*
|
890
|
+
* Same as:
|
891
|
+
* memory.put_array_of_double(0, ary)
|
892
|
+
*/
|
620
893
|
rb_define_method(classMemory, "write_array_of_double", memory_write_array_of_float64, 1);
|
894
|
+
/*
|
895
|
+
* Document-method: read_array_of_double
|
896
|
+
* call-seq: memory.read_array_of_double(length)
|
897
|
+
* @param [Numeric] length number of Float to read
|
898
|
+
* @return [Array<Float>]
|
899
|
+
* Read 64-bit floats (doubles) from memory.
|
900
|
+
*
|
901
|
+
* Same as:
|
902
|
+
* memory.get_array_of_double(0, ary)
|
903
|
+
*/
|
621
904
|
rb_define_method(classMemory, "read_array_of_double", memory_read_array_of_float64, 1);
|
622
905
|
rb_define_alias(classMemory, "put_array_of_double", "put_array_of_float64");
|
623
906
|
rb_define_alias(classMemory, "get_array_of_double", "get_array_of_float64");
|
907
|
+
/*
|
908
|
+
* Document-method: put_pointer
|
909
|
+
* call-seq: memory.put_pointer(offset, value)
|
910
|
+
* @param [Numeric] offset
|
911
|
+
* @param [nil,Pointer, Integer, #to_ptr] value
|
912
|
+
* @return [self]
|
913
|
+
* Put +value+ in memory from +offset+..
|
914
|
+
*/
|
624
915
|
rb_define_method(classMemory, "put_pointer", memory_put_pointer, 2);
|
916
|
+
/*
|
917
|
+
* Document-method: get_pointer
|
918
|
+
* call-seq: memory.get_pointer(offset)
|
919
|
+
* @param [Numeric] offset
|
920
|
+
* @return [Pointer]
|
921
|
+
* Get a {Pointer} to the memory from +offset+.
|
922
|
+
*/
|
625
923
|
rb_define_method(classMemory, "get_pointer", memory_get_pointer, 1);
|
924
|
+
/*
|
925
|
+
* Document-method: write_pointer
|
926
|
+
* call-seq: memory.write_pointer(value)
|
927
|
+
* @param [nil,Pointer, Integer, #to_ptr] value
|
928
|
+
* @return [self]
|
929
|
+
* Write +value+ in memory.
|
930
|
+
*
|
931
|
+
* Equivalent to:
|
932
|
+
* memory.put_pointer(0, value)
|
933
|
+
*/
|
626
934
|
rb_define_method(classMemory, "write_pointer", memory_write_pointer, 1);
|
935
|
+
/*
|
936
|
+
* Document-method: read_pointer
|
937
|
+
* call-seq: memory.read_pointer
|
938
|
+
* @return [Pointer]
|
939
|
+
* Get a {Pointer} to the memory from base address.
|
940
|
+
*
|
941
|
+
* Equivalent to:
|
942
|
+
* memory.get_pointer(0)
|
943
|
+
*/
|
627
944
|
rb_define_method(classMemory, "read_pointer", memory_read_pointer, 0);
|
945
|
+
/*
|
946
|
+
* Document-method: put_array_of_pointer
|
947
|
+
* call-seq: memory.put_array_of_pointer(offset, ary)
|
948
|
+
* @param [Numeric] offset
|
949
|
+
* @param [Array<#to_ptr>] ary
|
950
|
+
* @return [self]
|
951
|
+
* Put an array of {Pointer} into memory from +offset+.
|
952
|
+
*/
|
628
953
|
rb_define_method(classMemory, "put_array_of_pointer", memory_put_array_of_pointer, 2);
|
954
|
+
/*
|
955
|
+
* Document-method: get_array_of_pointer
|
956
|
+
* call-seq: memory.get_array_of_pointer(offset, length)
|
957
|
+
* @param [Numeric] offset
|
958
|
+
* @param [Numeric] length
|
959
|
+
* @return [Array<Pointer>]
|
960
|
+
* Get an array of {Pointer} of length +length+ from +offset+.
|
961
|
+
*/
|
629
962
|
rb_define_method(classMemory, "get_array_of_pointer", memory_get_array_of_pointer, 2);
|
963
|
+
/*
|
964
|
+
* Document-method: write_array_of_pointer
|
965
|
+
* call-seq: memory.write_array_of_pointer(ary)
|
966
|
+
* @param [Array<#to_ptr>] ary
|
967
|
+
* @return [self]
|
968
|
+
* Write an array of {Pointer} into memory from +offset+.
|
969
|
+
*
|
970
|
+
* Same as :
|
971
|
+
* memory.put_array_of_pointer(0, ary)
|
972
|
+
*/
|
630
973
|
rb_define_method(classMemory, "write_array_of_pointer", memory_write_array_of_pointer, 1);
|
974
|
+
/*
|
975
|
+
* Document-method: read_array_of_pointer
|
976
|
+
* call-seq: memory.read_array_of_pointer(length)
|
977
|
+
* @param [Numeric] length
|
978
|
+
* @return [Array<Pointer>]
|
979
|
+
* Read an array of {Pointer} of length +length+.
|
980
|
+
*
|
981
|
+
* Same as:
|
982
|
+
* memory.get_array_of_pointer(0, length)
|
983
|
+
*/
|
631
984
|
rb_define_method(classMemory, "read_array_of_pointer", memory_read_array_of_pointer, 1);
|
632
985
|
|
633
986
|
rb_define_method(classMemory, "get_string", memory_get_string, -1);
|