]> icculus.org git repositories - duncan/yast2-ruby-bindings.git/blob - src/ruby/YRuby.h
- Lot of fixes and support for the UI!!!
[duncan/yast2-ruby-bindings.git] / src / ruby / YRuby.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                                                                      |
10 | ruby language support                              (C) Novell Inc.   |
11 \----------------------------------------------------------------------/
12
13 Author: Duncan Mac-Vicar <dmacvicar@suse.de>
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License
17 as published by the Free Software Foundation; either version
18 2 of the License, or (at your option) any later version.
19
20 */
21
22 #ifndef YRuby_h
23 #define YRuby_h
24
25 // Ruby stuff
26 #include <ruby.h>
27
28 #include <ycp/YCPList.h>
29 #include <ycp/Type.h>
30
31 // make the compiler happy when
32 // calling rb_define_method()
33 typedef VALUE (ruby_method)(...);
34
35 // more useful macros
36 #define RB_FINALIZER(func) ((void (*)(...))func)
37
38 // this macro saves us from typing
39 // (ruby_method*) & method_name
40 // in rb_define_method
41 #define RB_METHOD(func) ((VALUE (*)(...))func)
42
43 class YRuby
44 {
45 public:
46
47     /**
48      * Load a Ruby module - equivalent to "use" in Ruby.
49      *
50      * Returns a YCPError on failure, YCPVoid on success.
51      **/
52     static YCPValue loadModule( YCPList argList );
53
54     /**
55      * Access the static (singleton) YRuby object. Create it if it isn't
56      * created yet.
57      *
58      * Returns 0 on error.
59      **/
60     static YRuby * yRuby();
61
62     /**
63      * Destroy the static (singleton) YRuby object and unload the embedded Ruby
64      * interpreter.
65      *
66      * Returns YCPVoid().
67      **/
68     static YCPValue destroy();
69
70     
71 protected:
72
73     /**
74      * Protected constructor. Use one of the static methods rather than
75      * instantiate an object of this class yourself.
76      **/
77     YRuby();
78
79     /**
80      * Protected constructor. Use one of the static methods rather than
81      * instantiate an object of this class yourself.
82      **/
83     
84     /**
85      * Destructor.
86      **/
87     ~YRuby();
88
89     /**
90      * Returns the internal embedded Ruby interpreter.
91      **/
92
93
94 public:
95     /**
96      * Generic Ruby call.
97      **/
98     YCPValue callInner (string module, string function, bool method,
99                         YCPList argList, constTypePtr wanted_result_type);
100     
101 protected:
102     
103 public:
104     static YRuby *      _yRuby;
105 };
106
107 #endif  // YRuby_h