journald-native 1.0.6 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +95 -0
- data/COPYING.md +450 -0
- data/README.md +60 -12
- data/ext/journald_native/extconf.rb +27 -7
- data/ext/journald_native/journald_dummy.c +9 -0
- data/ext/journald_native/journald_dummy.h +54 -0
- data/ext/journald_native/journald_native.c +121 -0
- data/ext/journald_native/journald_native.h +67 -8
- data/lib/journald/native.rb +25 -1
- data/lib/journald/native/version.rb +1 -1
- metadata +37 -24
- data/.gitignore +0 -29
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -9
- data/ext/journald_native/CMakeLists.txt +0 -9
- data/ext/journald_native/cpp14shiv.h +0 -78
- data/ext/journald_native/extinit.cpp +0 -7
- data/ext/journald_native/journald_native.cpp +0 -100
- data/ext/journald_native/ruby_exception_wrapper.cpp +0 -16
- data/ext/journald_native/ruby_exception_wrapper.h +0 -105
- data/ext/journald_native/sd_journal.h +0 -45
- data/ext/journald_native/sd_journal_dummy.h +0 -23
- data/journald-native.gemspec +0 -27
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: journald-native
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Smirnov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.6'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,35 +58,41 @@ dependencies:
|
|
52
58
|
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.4'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.4'
|
55
75
|
description:
|
56
76
|
email:
|
57
|
-
- sandfox@sandfox.
|
77
|
+
- sandfox@sandfox.me
|
58
78
|
executables: []
|
59
79
|
extensions:
|
60
80
|
- ext/journald_native/extconf.rb
|
61
81
|
extra_rdoc_files: []
|
62
82
|
files:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
- LICENSE.txt
|
83
|
+
- CHANGELOG.md
|
84
|
+
- COPYING.md
|
66
85
|
- README.md
|
67
|
-
- Rakefile
|
68
|
-
- ext/journald_native/CMakeLists.txt
|
69
|
-
- ext/journald_native/cpp14shiv.h
|
70
86
|
- ext/journald_native/extconf.rb
|
71
|
-
- ext/journald_native/
|
72
|
-
- ext/journald_native/
|
87
|
+
- ext/journald_native/journald_dummy.c
|
88
|
+
- ext/journald_native/journald_dummy.h
|
89
|
+
- ext/journald_native/journald_native.c
|
73
90
|
- ext/journald_native/journald_native.h
|
74
|
-
- ext/journald_native/ruby_exception_wrapper.cpp
|
75
|
-
- ext/journald_native/ruby_exception_wrapper.h
|
76
|
-
- ext/journald_native/sd_journal.h
|
77
|
-
- ext/journald_native/sd_journal_dummy.h
|
78
|
-
- journald-native.gemspec
|
79
91
|
- lib/journald/native.rb
|
80
92
|
- lib/journald/native/version.rb
|
81
|
-
homepage: https://github.com/
|
93
|
+
homepage: https://github.com/theforeman/journald-native
|
82
94
|
licenses:
|
83
|
-
-
|
95
|
+
- LGPL-2.1+
|
84
96
|
metadata: {}
|
85
97
|
post_install_message:
|
86
98
|
rdoc_options: []
|
@@ -90,15 +102,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
102
|
requirements:
|
91
103
|
- - ">="
|
92
104
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.9.
|
105
|
+
version: 1.9.3
|
94
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
107
|
requirements:
|
96
108
|
- - ">="
|
97
109
|
- !ruby/object:Gem::Version
|
98
110
|
version: '0'
|
99
|
-
requirements:
|
100
|
-
|
101
|
-
|
111
|
+
requirements:
|
112
|
+
- systemd-journal
|
113
|
+
- systemd development package
|
114
|
+
rubygems_version: 3.0.3
|
102
115
|
signing_key:
|
103
116
|
specification_version: 4
|
104
117
|
summary: systemd-journal logging native lib wrapper
|
data/.gitignore
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
23
|
-
Makefile
|
24
|
-
*.iml
|
25
|
-
*.ipr
|
26
|
-
*.iws
|
27
|
-
.rakeTasks
|
28
|
-
.idea
|
29
|
-
extconf.h
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Anton Smirnov
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# dummy cmake file for CLion
|
2
|
-
|
3
|
-
cmake_minimum_required(VERSION 2.8.4)
|
4
|
-
project(journald_native)
|
5
|
-
|
6
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
7
|
-
|
8
|
-
set(SOURCE_FILES extinit.cpp journald_native.cpp ruby_exception_wrapper.cpp)
|
9
|
-
add_executable(journald_native ${SOURCE_FILES})
|
@@ -1,78 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
unique_ptr from http://isocpp.org/files/papers/N3656.txt
|
3
|
-
index sequence from gcc 4.9 sources
|
4
|
-
*/
|
5
|
-
|
6
|
-
#include <cstddef>
|
7
|
-
#include <memory>
|
8
|
-
#include <type_traits>
|
9
|
-
#include <utility>
|
10
|
-
|
11
|
-
namespace std {
|
12
|
-
template<class T> struct _Unique_if {
|
13
|
-
typedef unique_ptr<T> _Single_object;
|
14
|
-
};
|
15
|
-
|
16
|
-
template<class T> struct _Unique_if<T[]> {
|
17
|
-
typedef unique_ptr<T[]> _Unknown_bound;
|
18
|
-
};
|
19
|
-
|
20
|
-
template<class T, size_t N> struct _Unique_if<T[N]> {
|
21
|
-
typedef void _Known_bound;
|
22
|
-
};
|
23
|
-
|
24
|
-
template<class T, class... Args>
|
25
|
-
typename _Unique_if<T>::_Single_object
|
26
|
-
make_unique(Args&&... args) {
|
27
|
-
return unique_ptr<T>(new T(std::forward<Args>(args)...));
|
28
|
-
}
|
29
|
-
|
30
|
-
template<class T>
|
31
|
-
typename _Unique_if<T>::_Unknown_bound
|
32
|
-
make_unique(size_t n) {
|
33
|
-
typedef typename remove_extent<T>::type U;
|
34
|
-
return unique_ptr<T>(new U[n]());
|
35
|
-
}
|
36
|
-
|
37
|
-
template<class T, class... Args>
|
38
|
-
typename _Unique_if<T>::_Known_bound
|
39
|
-
make_unique(Args&&...) = delete;
|
40
|
-
|
41
|
-
/// Class template integer_sequence
|
42
|
-
template<typename _Tp, _Tp... _Idx>
|
43
|
-
struct integer_sequence
|
44
|
-
{
|
45
|
-
typedef _Tp value_type;
|
46
|
-
static constexpr size_t size() { return sizeof...(_Idx); }
|
47
|
-
};
|
48
|
-
|
49
|
-
template<typename _Tp, _Tp _Num,
|
50
|
-
typename _ISeq = typename _Build_index_tuple<_Num>::__type>
|
51
|
-
struct _Make_integer_sequence;
|
52
|
-
|
53
|
-
template<typename _Tp, _Tp _Num, size_t... _Idx>
|
54
|
-
struct _Make_integer_sequence<_Tp, _Num, _Index_tuple<_Idx...>>
|
55
|
-
{
|
56
|
-
static_assert( _Num >= 0,
|
57
|
-
"Cannot make integer sequence of negative length" );
|
58
|
-
|
59
|
-
typedef integer_sequence<_Tp, static_cast<_Tp>(_Idx)...> __type;
|
60
|
-
};
|
61
|
-
|
62
|
-
/// Alias template make_integer_sequence
|
63
|
-
template<typename _Tp, _Tp _Num>
|
64
|
-
using make_integer_sequence
|
65
|
-
= typename _Make_integer_sequence<_Tp, _Num>::__type;
|
66
|
-
|
67
|
-
/// Alias template index_sequence
|
68
|
-
template<size_t... _Idx>
|
69
|
-
using index_sequence = integer_sequence<size_t, _Idx...>;
|
70
|
-
|
71
|
-
/// Alias template make_index_sequence
|
72
|
-
template<size_t _Num>
|
73
|
-
using make_index_sequence = make_integer_sequence<size_t, _Num>;
|
74
|
-
|
75
|
-
/// Alias template index_sequence_for
|
76
|
-
template<typename... _Types>
|
77
|
-
using index_sequence_for = make_index_sequence<sizeof...(_Types)>;
|
78
|
-
}
|
@@ -1,100 +0,0 @@
|
|
1
|
-
#include "journald_native.h"
|
2
|
-
#include "sd_journal.h"
|
3
|
-
|
4
|
-
#include <memory>
|
5
|
-
|
6
|
-
#include "ruby_exception_wrapper.h"
|
7
|
-
|
8
|
-
namespace journald_native {
|
9
|
-
|
10
|
-
namespace {
|
11
|
-
|
12
|
-
/* aux */
|
13
|
-
// just a short alias for ruby_raisable_call()
|
14
|
-
template <typename Func, typename... Args>
|
15
|
-
inline auto r(Func f, Args... args) -> decltype(f(args...))
|
16
|
-
{
|
17
|
-
return ruby_exception_wrapper::ruby_raisable_call(f, args...);
|
18
|
-
}
|
19
|
-
|
20
|
-
/* methods */
|
21
|
-
inline VALUE native_print(VALUE v_self, VALUE v_priority, VALUE v_message)
|
22
|
-
{
|
23
|
-
int priority = NUM2INT(v_priority);
|
24
|
-
std::string message = r(rb_string_value_cstr, &v_message);
|
25
|
-
|
26
|
-
int result = sd_journal_print(priority, "%s", message.c_str());
|
27
|
-
|
28
|
-
return INT2NUM(result);
|
29
|
-
}
|
30
|
-
|
31
|
-
inline VALUE native_send(int argc, VALUE* argv, VALUE v_self)
|
32
|
-
{
|
33
|
-
auto msgs = std::make_unique<iovec[]>((size_t)argc);
|
34
|
-
|
35
|
-
for (int i = 0; i < argc; i++) {
|
36
|
-
VALUE v = r(rb_string_value, &argv[i]);
|
37
|
-
|
38
|
-
msgs[i].iov_base = (char *)RSTRING_PTR(v);
|
39
|
-
msgs[i].iov_len = (size_t)RSTRING_LEN(v);
|
40
|
-
}
|
41
|
-
|
42
|
-
int result = sd_journal_sendv(msgs.get(), argc);
|
43
|
-
|
44
|
-
return INT2NUM(result);
|
45
|
-
}
|
46
|
-
|
47
|
-
inline VALUE native_perror(VALUE v_self, VALUE v_message)
|
48
|
-
{
|
49
|
-
std::string message = r(rb_string_value_cstr, &v_message);
|
50
|
-
|
51
|
-
int result = sd_journal_perror(message.c_str());
|
52
|
-
|
53
|
-
return INT2NUM(result);
|
54
|
-
}
|
55
|
-
|
56
|
-
VALUE is_dummy(VALUE v_self = Qnil)
|
57
|
-
{
|
58
|
-
constexpr VALUE dummy = JOURNALD_NATIVE_SD_JOURNAL_DUMMY ? Qtrue : Qfalse;
|
59
|
-
return dummy;
|
60
|
-
}
|
61
|
-
|
62
|
-
/* initializers */
|
63
|
-
inline void init_journald(VALUE module)
|
64
|
-
{
|
65
|
-
rb_define_const(module, "LOG_EMERG", INT2NUM(LOG_EMERG)); /* system is unusable */
|
66
|
-
rb_define_const(module, "LOG_ALERT", INT2NUM(LOG_ALERT)); /* action must be taken immediately */
|
67
|
-
rb_define_const(module, "LOG_CRIT", INT2NUM(LOG_CRIT)); /* critical conditions */
|
68
|
-
rb_define_const(module, "LOG_ERR", INT2NUM(LOG_ERR)); /* error conditions */
|
69
|
-
rb_define_const(module, "LOG_WARNING", INT2NUM(LOG_WARNING)); /* warning conditions */
|
70
|
-
rb_define_const(module, "LOG_NOTICE", INT2NUM(LOG_NOTICE)); /* normal but significant condition */
|
71
|
-
rb_define_const(module, "LOG_INFO", INT2NUM(LOG_INFO)); /* informational */
|
72
|
-
rb_define_const(module, "LOG_DEBUG", INT2NUM(LOG_DEBUG)); /* debug-level messages */
|
73
|
-
}
|
74
|
-
|
75
|
-
inline void init_native(VALUE module)
|
76
|
-
{
|
77
|
-
// methods
|
78
|
-
rb_define_singleton_method(module, "print", RXW_WRAPPED_METHOD_FUNC(native_print, VALUE, VALUE, VALUE), 2);
|
79
|
-
rb_define_singleton_method(module, "send", RXW_WRAPPED_METHOD_FUNC(native_send, int, VALUE*, VALUE), -1); /* -1 to pass as C array */
|
80
|
-
rb_define_singleton_method(module, "perror", RXW_WRAPPED_METHOD_FUNC(native_perror, VALUE, VALUE), 1);
|
81
|
-
|
82
|
-
// dummy detection
|
83
|
-
rb_define_const(module, "IS_DUMMY", is_dummy());
|
84
|
-
rb_define_singleton_method(module, "dummy?", RUBY_METHOD_FUNC(is_dummy), 0);
|
85
|
-
}
|
86
|
-
|
87
|
-
} // private namespace
|
88
|
-
|
89
|
-
void init_modules()
|
90
|
-
{
|
91
|
-
// no nontrivial destructors during initialization, no need for ruby catch
|
92
|
-
|
93
|
-
VALUE mJournald = rb_define_module("Journald");
|
94
|
-
VALUE mNative = rb_define_module_under(mJournald, "Native");
|
95
|
-
|
96
|
-
init_journald(mJournald); // add constants to Journald
|
97
|
-
init_native(mNative); // add methods to Journald::Native
|
98
|
-
}
|
99
|
-
|
100
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#include "ruby_exception_wrapper.h"
|
2
|
-
|
3
|
-
namespace ruby_exception_wrapper {
|
4
|
-
|
5
|
-
// callback for rb_rescue2 to catch ruby exception and wrap it by RbWrappedException
|
6
|
-
VALUE rethrow_as_cpp(VALUE put_exception_here_ptr, VALUE exception)
|
7
|
-
{
|
8
|
-
// cannot actually throw here, just pass the exception
|
9
|
-
VALUE* excptr = reinterpret_cast<VALUE*>(put_exception_here_ptr);
|
10
|
-
|
11
|
-
*excptr = exception;
|
12
|
-
|
13
|
-
return exception;
|
14
|
-
}
|
15
|
-
|
16
|
-
}
|
@@ -1,105 +0,0 @@
|
|
1
|
-
#ifndef RUBY_EXCEPTION_WRAPPER_H
|
2
|
-
#define RUBY_EXCEPTION_WRAPPER_H
|
3
|
-
|
4
|
-
#include <ruby.h>
|
5
|
-
|
6
|
-
#include <functional>
|
7
|
-
#include <type_traits>
|
8
|
-
#include <utility>
|
9
|
-
|
10
|
-
#include "cpp14shiv.h" // make this c++14 code c++11 compatible; remove for c++14
|
11
|
-
|
12
|
-
// wrap functions, prototype required, i.e. RXW_WRAPPED_METHOD_FUNC(native_send, int, VALUE*, VALUE)
|
13
|
-
// functions can be inline
|
14
|
-
#define RXW_WRAPPED_METHOD_FUNC(method, ...) ((VALUE (*)(ANYARGS))::ruby_exception_wrapper::method_wrapper_call<decltype(&method), method, __VA_ARGS__>)
|
15
|
-
|
16
|
-
namespace ruby_exception_wrapper {
|
17
|
-
|
18
|
-
class RbWrappedException: public std::exception {
|
19
|
-
VALUE ruby_exception;
|
20
|
-
public:
|
21
|
-
RbWrappedException(VALUE e): ruby_exception(e) {};
|
22
|
-
VALUE getRubyException() { return ruby_exception; }
|
23
|
-
};
|
24
|
-
|
25
|
-
// callback for rb_rescue2 to catch ruby exception and wrap it by RbWrappedException
|
26
|
-
VALUE rethrow_as_cpp(VALUE put_exception_here_ptr, VALUE exception);
|
27
|
-
|
28
|
-
namespace {
|
29
|
-
// do real call of function from template
|
30
|
-
template <typename FuncPointer, typename... Args>
|
31
|
-
inline VALUE call_wrapper_tuple_impl(FuncPointer& fp, Args... args)
|
32
|
-
{
|
33
|
-
// only pointers and VALUE permitted
|
34
|
-
// VALUE guaranteed to be able to contain pointer
|
35
|
-
return reinterpret_cast<VALUE>(fp(args...));
|
36
|
-
}
|
37
|
-
|
38
|
-
// unpack params to do real call
|
39
|
-
template <typename CallTuple, std::size_t... Is>
|
40
|
-
inline VALUE call_wrapper_tuple_unpack(CallTuple& call_tuple, std::index_sequence<Is...>)
|
41
|
-
{
|
42
|
-
return call_wrapper_tuple_impl(std::get<Is>(call_tuple)...);
|
43
|
-
}
|
44
|
-
|
45
|
-
// callback for rb_rescue2 for no exceptions
|
46
|
-
template <typename CallTuple>
|
47
|
-
VALUE call_wrapper_tuple(VALUE v_ct) {
|
48
|
-
CallTuple call_tuple = std::move(*reinterpret_cast<CallTuple*>(v_ct));
|
49
|
-
|
50
|
-
return call_wrapper_tuple_unpack(call_tuple, std::make_index_sequence<std::tuple_size<CallTuple>::value> {});
|
51
|
-
};
|
52
|
-
|
53
|
-
// safely call function
|
54
|
-
template <typename Func, typename... Args>
|
55
|
-
inline auto do_raisable_call(Func f, Args... args) -> decltype(f(args...))
|
56
|
-
{
|
57
|
-
typedef std::function<typename std::remove_pointer<Func>::type> FuncPointer;
|
58
|
-
typedef std::tuple<FuncPointer, Args...> CallTuple;
|
59
|
-
|
60
|
-
FuncPointer fp = f;
|
61
|
-
|
62
|
-
CallTuple call_tuple = std::make_tuple(fp, args...);
|
63
|
-
|
64
|
-
VALUE exception = 0; // get raised exception if any
|
65
|
-
|
66
|
-
VALUE result = rb_rescue2(
|
67
|
-
RUBY_METHOD_FUNC(call_wrapper_tuple<CallTuple>), reinterpret_cast<VALUE>(&call_tuple),
|
68
|
-
RUBY_METHOD_FUNC(rethrow_as_cpp), reinterpret_cast<VALUE>(&exception),
|
69
|
-
rb_eException, Qfalse
|
70
|
-
);
|
71
|
-
|
72
|
-
if (exception) { // nonzero here if rescue called unless some pervert throws Qfalse
|
73
|
-
throw RbWrappedException(exception);
|
74
|
-
}
|
75
|
-
|
76
|
-
return reinterpret_cast<decltype(f(args...))>(result);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
template <typename Func, typename... Args>
|
81
|
-
inline auto ruby_raisable_call(Func f, Args... args) -> decltype(f(args...))
|
82
|
-
{
|
83
|
-
static_assert(
|
84
|
-
std::is_same<decltype(f(args...)), VALUE>::value || std::is_pointer<decltype(f(args...))>::value,
|
85
|
-
"Only for funcs returning VALUE or pointer"
|
86
|
-
);
|
87
|
-
|
88
|
-
auto result = do_raisable_call(f, args...);
|
89
|
-
|
90
|
-
return result;
|
91
|
-
}
|
92
|
-
|
93
|
-
template <typename Func, Func func, typename... Args>
|
94
|
-
VALUE method_wrapper_call(Args... args)
|
95
|
-
{
|
96
|
-
try {
|
97
|
-
return func(args...);
|
98
|
-
} catch(RbWrappedException &e) {
|
99
|
-
rb_exc_raise(e.getRubyException());
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
#endif
|