-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathruby_cxx.h
47 lines (38 loc) · 1.01 KB
/
ruby_cxx.h
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
#ifndef RUBY_CXX_H
#define RUBY_CXX_H
#include <pthread.h>
#include <QString>
// #include "fix_clang_undef_eai.h"
extern "C" {
#include <ruby.h>
}; /* satisfy cc-mode */
#include "macrolib.h"
/*
实现ruby.h的C++封装
auto rbx = RubyCXX::inst();
*/
// like static call
class RubyCXX;
static RubyCXX *rbi = NULL;
class RubyCXX : public Singleton<RubyCXX>
{
// DECL_SINGLETON_CLASS(RubyCXX);
public:
// static RubyCXX *inst();
RubyCXX() { rbi = this;}
virtual ~RubyCXX();
inline int type(VALUE v) { return rb_type(v); }
inline bool isObject(VALUE v) { return rb_type(v) == T_OBJECT;}
inline bool isSymbol(VALUE v) { return rb_type(v) == T_SYMBOL;}
inline bool isClass(VALUE v) { return rb_type(v) == T_CLASS;}
QString className(VALUE v);
QString rbClassName(VALUE v);
QString qtClassname(VALUE v);
/*
private:
RubyCXX();
static RubyCXX *m_inst; // = NULL;
static pthread_mutex_t m_mutex;// = PTHREAD_MUTEX_INITIALIZER;
*/
};
#endif /* RUBY_CXX_H */