w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

data.h
Go to the documentation of this file.
1 /**
2 ** @file mruby/data.h - Data class
3 **
4 ** See Copyright Notice in mruby.h
5 */
6 
7 #ifndef MRUBY_DATA_H
8 #define MRUBY_DATA_H
9 
10 #include "common.h"
11 
12 /**
13  * Custom C wrapped data.
14  *
15  * Defining Ruby wrappers around native objects.
16  */
18 
19 /**
20  * Custom data type description.
21  */
22 typedef struct mrb_data_type {
23  /** data type name */
24  const char *struct_name;
25 
26  /** data type release function pointer */
27  void (*dfree)(mrb_state *mrb, void*);
29 
30 struct RData {
32  struct iv_tbl *iv;
34  void *data;
35 };
36 
37 MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *datap, const mrb_data_type *type);
38 
39 #define Data_Wrap_Struct(mrb,klass,type,ptr)\
40  mrb_data_object_alloc(mrb,klass,ptr,type)
41 
42 #define Data_Make_Struct(mrb,klass,strct,type,sval,data_obj) do { \
43  (data_obj) = Data_Wrap_Struct(mrb,klass,type,NULL);\
44  (sval) = (strct *)mrb_malloc(mrb, sizeof(strct)); \
45  { static const strct zero = { 0 }; *(sval) = zero; };\
46  (data_obj)->data = (sval);\
47 } while (0)
48 
49 #define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
50 #define DATA_PTR(d) (RDATA(d)->data)
51 #define DATA_TYPE(d) (RDATA(d)->type)
54 #define DATA_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_get_ptr(mrb,obj,dtype)
56 #define DATA_CHECK_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_check_get_ptr(mrb,obj,dtype)
57 
58 /* obsolete functions and macros */
59 #define mrb_data_check_and_get(mrb,obj,dtype) mrb_data_get_ptr(mrb,obj,dtype)
60 #define mrb_get_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
61 #define mrb_check_datatype(mrb,val,type) mrb_data_get_ptr(mrb, val, type)
62 #define Data_Get_Struct(mrb,obj,type,sval) do {\
63  *(void**)&sval = mrb_data_get_ptr(mrb, obj, type); \
64 } while (0)
65 
66 MRB_INLINE void
68 {
70  DATA_PTR(v) = ptr;
71  DATA_TYPE(v) = type;
72 }
73 
75 
76 #endif /* MRUBY_DATA_H */
#define type(a)
Definition: aptex-macros.h:171
#define mrb_data_p(o)
Definition: boxing_word.h:166
void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type *)
Definition: etc.c:26
struct RData * mrb_data_object_alloc(mrb_state *mrb, struct RClass *klass, void *datap, const mrb_data_type *type)
Definition: etc.c:14
#define DATA_TYPE(d)
Definition: data.h:51
struct mrb_data_type mrb_data_type
#define DATA_PTR(d)
Definition: data.h:50
void * mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type *)
Definition: etc.c:46
static void mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type)
Definition: data.h:67
void * mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type *)
Definition: etc.c:58
int v
Definition: dviconv.c:10
static void
Definition: fpif.c:118
#define mrb_assert(p)
Definition: mruby.h:65
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
#define MRB_INLINE
Definition: common.h:62
#define MRB_END_DECL
Definition: common.h:28
#define MRB_BEGIN_DECL
Definition: common.h:26
#define MRB_API
Definition: common.h:73
Definition: class.h:17
Definition: data.h:30
MRB_OBJECT_HEADER
Definition: data.h:31
void * data
Definition: data.h:34
struct iv_tbl * iv
Definition: data.h:32
const mrb_data_type * type
Definition: data.h:33
const char * struct_name
Definition: data.h:24
void(* dfree)(mrb_state *mrb, void *)
Definition: data.h:27