File: compat.h

package info (click to toggle)
ruby-dataobjects-sqlite3 0.10.17-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 332 kB
  • sloc: ansic: 991; ruby: 322; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 939 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef RUBY_COMPAT_H
#define RUBY_COMPAT_H

/*
 * Rules for better ruby C extensions:
 *
 * Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
 *
 * Never compare with RBASIC(obj)->klass, always use
 *   rb_obj_is_instance_of()
 *
 * Never use RHASH(obj)->tbl or RHASH_TBL().
 *
 */


// Array
#ifndef RARRAY_PTR
#define RARRAY_PTR(obj) RARRAY(obj)->ptr
#endif

#ifndef RARRAY_LEN
#define RARRAY_LEN(obj) RARRAY(obj)->len
#endif

// String
#ifndef RSTRING_PTR
#define RSTRING_PTR(obj) RSTRING(obj)->ptr
#endif

#ifndef RSTRING_LEN
#define RSTRING_LEN(obj) RSTRING(obj)->len
#endif

#ifndef rb_str_ptr
#define rb_str_ptr(str) RSTRING_PTR(str)
#endif

#ifndef rb_str_ptr_readonly
#define rb_str_ptr_readonly(str) RSTRING_PTR(str)
#endif

#ifndef rb_str_flush
#define rb_str_flush(str)
#endif

#ifndef rb_str_update
#define rb_str_update(str)
#endif

#ifndef rb_str_len
#define rb_str_len(str) RSTRING_LEN(str)
#endif

#endif