summaryrefslogtreecommitdiff
path: root/scripts/kconfig/kconfig.i
Unidiff
Diffstat (limited to 'scripts/kconfig/kconfig.i') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/kconfig.i133
1 files changed, 133 insertions, 0 deletions
diff --git a/scripts/kconfig/kconfig.i b/scripts/kconfig/kconfig.i
new file mode 100644
index 0000000..699cb13
--- a/dev/null
+++ b/scripts/kconfig/kconfig.i
@@ -0,0 +1,133 @@
1%module kconfig
2%{
3#include "kconfig_load.c"
4%}
5
6%init %{
7 kconfig_load();
8%}
9
10%nodefault;
11
12#ifdef SWIGRUBY
13%typemap (out) char * {
14 if ($1 == NULL)
15 $result = Qnil;
16 else
17 $result = rb_str_new2($1);
18}
19%typemap (in) char * {
20 if ($input == Qnil)
21 $1 = NULL;
22 else
23 $1 = STR2CSTR($input);
24}
25
26%{
27static void expr_to_s_help(void *data, const char *str)
28{
29 rb_str_cat((VALUE)data, str, strlen(str));
30}
31%}
32#endif
33
34%immutable;
35%include "expr.h"
36#define P(name,type,arg) extern type name arg
37%include "lkc_proto.h"
38%mutable;
39
40#ifdef SWIGRUBY
41%predicate menu::isVisible;
42%predicate symbol::isChangable;
43%predicate symbol::isChoice;
44%predicate symbol::isChoiceValue;
45#endif
46
47%extend menu {
48 bool isVisible(void) {
49 return menu_is_visible(self);
50 }
51#ifdef SWIGRUBY
52 void each(void) {
53 struct menu *child;
54 for (child = self->list; child; child = child->next)
55 rb_yield(SWIG_NewPointerObj(child, SWIGTYPE_p_menu, 0));
56 }
57 static void each_menu(void) {
58 struct menu *child;
59 for (child = rootmenu.list; child; child = child->next)
60 rb_yield(SWIG_NewPointerObj(child, SWIGTYPE_p_menu, 0));
61 }
62#endif
63}
64
65%extend symbol {
66 void calc_value(void) {
67 sym_calc_value(self);
68 }
69 tristate set_tristate(tristate val) {
70 return sym_set_tristate_value(self, val);
71 }
72 bool set_string(char *val) {
73 return sym_set_string_value(self, val);
74 }
75 const char *get_string(void) {
76 return sym_get_string_value(self);
77 }
78 bool isChangable(void) {
79 return sym_is_changable(self);
80 }
81 bool isChoice(void) {
82 return sym_is_choice(self);
83 }
84 bool isChoiceValue(void) {
85 return sym_is_choice_value(self);
86 }
87 static struct symbol *lookup(const char *name) {
88 return sym_lookup(name, 0);
89 }
90 static struct symbol *find(const char *name) {
91 return sym_find(name);
92 }
93 static const char *type_name(enum symbol_type type) {
94 return sym_type_name(type);
95 }
96#ifdef SWIGRUBY
97 void each(void) {
98 struct property *prop;
99 for (prop = self->prop; prop; prop = prop->next)
100 rb_yield(SWIG_NewPointerObj(prop, SWIGTYPE_p_property, 0));
101 }
102 static void each_sym(void) {
103 struct symbol *sym;
104 int i;
105 for (i = 0; i < SYMBOL_HASHSIZE; i++) {
106 for (sym = symbol_hash[i]; sym; sym = sym->next) {
107 if (sym->flags & SYMBOL_CONST)
108 continue;
109 rb_yield(SWIG_NewPointerObj(sym, SWIGTYPE_p_symbol, 0));
110 }
111 }
112 }
113#endif
114}
115
116%extend property {
117 static const char *type_name(enum prop_type type) {
118 return prop_get_type_name(type);
119 }
120}
121
122%extend expr {
123 static int comp_type(enum expr_type t1, enum expr_type t2) {
124 return expr_compare_type(t1, t2);
125 }
126#ifdef SWIGRUBY
127 VALUE __str__(void) {
128 VALUE str = rb_str_new2("");
129 expr_print(self, expr_to_s_help, (void*)str, E_NONE);
130 return str;
131 }
132#endif
133}