cleanups
[lwes-ruby.git] / ext / lwes_ext / lwes_ruby.h
blob2f1f37d2b0265f725213e17914465042a2be091a
1 #ifndef LWES_RUBY_H
2 #define LWES_RUBY_H
4 #include <lwes.h>
5 #include <ruby.h>
6 #include <assert.h>
7 #include <stdint.h>
9 #define LWESRB_MKSYM(SYM) sym_##SYM = ID2SYM(rb_intern(#SYM))
10 #define LWESRB_MKID(NAME) id_##NAME = rb_intern(#NAME)
12 extern VALUE cLWES_TypeDB;
14 struct lwes_event_type_db * lwesrb_get_type_db(VALUE self);
16 void lwesrb_init_type_db(void);
18 void lwesrb_init_emitter(void);
20 void lwesrb_init_numeric(void);
22 void lwesrb_init_event(void);
24 void lwesrb_dump_type(LWES_BYTE type, LWES_BYTE_P buf, size_t *off);
26 void lwesrb_dump_num(LWES_BYTE type, VALUE val, LWES_BYTE_P buf, size_t *off);
28 void lwesrb_dump_num_ary(VALUE array, LWES_BYTE_P buf, size_t *off);
30 #ifndef RSTRING_PTR
31 # define RSTRING_PTR(s) (RSTRING(s)->ptr)
32 # define RSTRING_LEN(s) (RSTRING(s)->len)
33 #endif
35 #ifndef RARRAY_PTR
36 # define RARRAY_PTR(s) (RARRAY(s)->ptr)
37 # define RARRAY_LEN(s) (RARRAY(s)->len)
38 #endif
40 #define RAISE_INSPECT(v) RSTRING_PTR(raise_inspect = rb_inspect(v))
42 extern VALUE cLWES_Event;
44 struct lwes_event * lwesrb_get_event(VALUE self);
46 VALUE lwesrb_event_to_hash(struct lwes_event *e);
48 LWES_U_INT_16 lwesrb_uint16(VALUE val);
49 LWES_INT_16 lwesrb_int16(VALUE val);
50 LWES_U_INT_32 lwesrb_uint32(VALUE val);
51 LWES_INT_32 lwesrb_int32(VALUE val);
52 LWES_U_INT_64 lwesrb_uint64(VALUE val);
53 /* NUM2LL can raise RangeError */
54 #define lwesrb_int64(VAL) (LWES_INT_64)NUM2LL((VAL))
55 LWES_IP_ADDR lwesrb_ip_addr(VALUE val);
56 LWES_BOOLEAN lwesrb_boolean(VALUE val);
58 #endif /* LWES_RUBY_H */