kernaux 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kernaux might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.rubocop.yml +77 -0
- data/.simplecov +9 -0
- data/.yardopts +4 -0
- data/Gemfile +8 -0
- data/README.md +29 -0
- data/Rakefile +80 -0
- data/bin/console +8 -0
- data/bin/setup +7 -0
- data/ext/default/assert.c +62 -0
- data/ext/default/cmdline.c +95 -0
- data/ext/default/dynarg.c +45 -0
- data/ext/default/dynarg.h +35 -0
- data/ext/default/extconf.rb +31 -0
- data/ext/default/main.c +28 -0
- data/ext/default/ntoa.c +191 -0
- data/ext/default/printf.c +120 -0
- data/kernaux.gemspec +57 -0
- data/lib/kernaux/version.rb +6 -0
- data/lib/kernaux.rb +238 -0
- metadata +222 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '078f989c6f70ebb33c1ff245a798297a7a49cc4ba74d85419fc96b95b10cbdac'
|
4
|
+
data.tar.gz: 721beddda4f2298c0ca5dc3def0f89433233bde20e81d132c6d9837e7e6618dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddf579b82989bd3a934d77decdef1abf0b7a0bb8efbe6aea31413da8408bc896b12eed1c5062e03d40df5104ed9a80e195ab26d952d8b570bd045c753cc7045d
|
7
|
+
data.tar.gz: 867170c6daa04632b286ecd91855d9a4cd5b407d63e433eb37e99cd68d56c4ae247e0e98424df8377bf2a7604f409f83db580d11b80663a3bbffeff9f681372d
|
data/.gitignore
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
*.so
|
4
|
+
|
5
|
+
/.byebug_history
|
6
|
+
/.config/
|
7
|
+
/.rake_tasks~
|
8
|
+
/InstalledFiles/
|
9
|
+
/pkg/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
# Used by dotenv library to load environment variables.
|
13
|
+
/.env
|
14
|
+
|
15
|
+
# RSpec configuration and generated files.
|
16
|
+
/.rspec
|
17
|
+
/coverage/
|
18
|
+
/spec/examples.txt
|
19
|
+
/spec/reports/
|
20
|
+
/test/tmp/
|
21
|
+
/test/version_tmp/
|
22
|
+
|
23
|
+
# Documentation cache and generated files.
|
24
|
+
/.yardoc/
|
25
|
+
/_yardoc/
|
26
|
+
/doc/
|
27
|
+
/rdoc/
|
28
|
+
|
29
|
+
# Environment normalization.
|
30
|
+
/.bundle/
|
31
|
+
/vendor/bundle/
|
32
|
+
/lib/bundler/man/
|
33
|
+
|
34
|
+
# For a library or gem, you might want to ignore these files since the code is
|
35
|
+
# intended to run in multiple environments; otherwise, check them in.
|
36
|
+
/Gemfile.lock
|
37
|
+
/.ruby-version
|
38
|
+
/.ruby-gemset
|
39
|
+
|
40
|
+
# Unless supporting rvm < 1.11.0 or doing something fancy, ignore this.
|
41
|
+
/.rvmrc
|
42
|
+
|
43
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
44
|
+
/.rubocop-https?--*
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 3.0
|
8
|
+
DisplayCopNames: true
|
9
|
+
NewCops: enable
|
10
|
+
|
11
|
+
Layout/AccessModifierIndentation:
|
12
|
+
EnforcedStyle: outdent
|
13
|
+
|
14
|
+
Layout/LineLength:
|
15
|
+
Max: 80
|
16
|
+
Exclude:
|
17
|
+
- 'spec/lib/kernaux/sprintf_spec.rb'
|
18
|
+
|
19
|
+
Lint/AmbiguousOperatorPrecedence:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Lint/ReturnInVoidContext:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Metrics/BlockLength:
|
26
|
+
Exclude:
|
27
|
+
- '*.gemspec'
|
28
|
+
- 'Rakefile'
|
29
|
+
- 'spec/**/*_spec.rb'
|
30
|
+
|
31
|
+
RSpec/ContextWording:
|
32
|
+
Prefixes:
|
33
|
+
- 'and'
|
34
|
+
- 'for'
|
35
|
+
- 'using'
|
36
|
+
- 'when'
|
37
|
+
- 'with'
|
38
|
+
- 'without'
|
39
|
+
|
40
|
+
RSpec/FilePath:
|
41
|
+
CustomTransform:
|
42
|
+
KernAux: kernaux
|
43
|
+
|
44
|
+
RSpec/ExampleLength:
|
45
|
+
CountAsOne: ['array', 'hash', 'heredoc']
|
46
|
+
|
47
|
+
Style/AndOr:
|
48
|
+
EnforcedStyle: conditionals
|
49
|
+
|
50
|
+
Style/Documentation:
|
51
|
+
Exclude:
|
52
|
+
- 'Rakefile'
|
53
|
+
|
54
|
+
Style/DoubleNegation:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Style/GlobalVars:
|
58
|
+
Exclude:
|
59
|
+
- 'ext/*/extconf.rb'
|
60
|
+
|
61
|
+
Style/HashAsLastArrayItem:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/PerlBackrefs:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/TrailingCommaInArguments:
|
68
|
+
EnforcedStyleForMultiline: comma
|
69
|
+
|
70
|
+
Style/TrailingCommaInArrayLiteral:
|
71
|
+
EnforcedStyleForMultiline: comma
|
72
|
+
|
73
|
+
Style/TrailingCommaInHashLiteral:
|
74
|
+
EnforcedStyleForMultiline: comma
|
75
|
+
|
76
|
+
Style/VariableInterpolation:
|
77
|
+
Enabled: false
|
data/.simplecov
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
::KernAux
|
2
|
+
=========
|
3
|
+
|
4
|
+
[![Build status](https://github.com/tailix/libkernaux/actions/workflows/ruby.yml/badge.svg)](https://github.com/tailix/libkernaux/actions/workflows/ruby.yml)
|
5
|
+
[![Build status (FreeBSD)](https://api.cirrus-ci.com/github/tailix/libkernaux.svg?task=Ruby%20(FreeBSD))](https://cirrus-ci.com/github/tailix/libkernaux)
|
6
|
+
|
7
|
+
Binding to [libkernaux](https://github.com/tailix/libkernaux) - auxiliary
|
8
|
+
library for kernel development.
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
Install
|
13
|
+
-------
|
14
|
+
|
15
|
+
Add the following to your `Gemfile`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'kernaux', '~> 0.3.0'
|
19
|
+
```
|
20
|
+
|
21
|
+
Or add the following to your `*.gemspec`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Gem::Specification.new do |spec|
|
25
|
+
# ...
|
26
|
+
spec.add_runtime_dependency 'kernaux', '~> 0.3.0'
|
27
|
+
# ...
|
28
|
+
end
|
29
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
class GemHelper
|
7
|
+
def tag_version(*)
|
8
|
+
yield if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def git_push(*); end
|
12
|
+
|
13
|
+
def perform_git_push(*); end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
CLEAN << '.yardoc'
|
18
|
+
CLEAN << 'coverage'
|
19
|
+
CLEAN << 'doc'
|
20
|
+
CLEAN << 'spec/examples.txt'
|
21
|
+
|
22
|
+
desc 'Run default checks'
|
23
|
+
task default: %i[test lint yard:cov]
|
24
|
+
|
25
|
+
desc 'Run tests'
|
26
|
+
task test: :spec
|
27
|
+
|
28
|
+
desc 'Run code analysis tools'
|
29
|
+
task lint: :rubocop
|
30
|
+
|
31
|
+
desc 'Fix code style (rubocop --auto-correct)'
|
32
|
+
task fix: 'rubocop:auto_correct'
|
33
|
+
|
34
|
+
begin
|
35
|
+
require 'rspec/core/rake_task'
|
36
|
+
RSpec::Core::RakeTask.new
|
37
|
+
rescue LoadError
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
require 'rubocop/rake_task'
|
43
|
+
RuboCop::RakeTask.new
|
44
|
+
rescue LoadError
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
require 'yard'
|
50
|
+
YARD::Rake::YardocTask.new
|
51
|
+
rescue LoadError
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
require 'rake/extensiontask'
|
57
|
+
Rake::ExtensionTask.new 'default' do |ext|
|
58
|
+
ext.lib_dir = 'lib/kernaux'
|
59
|
+
end
|
60
|
+
rescue LoadError
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'Open development console'
|
65
|
+
task :console do
|
66
|
+
sh 'bundle', 'exec', File.expand_path(File.join('bin', 'console'), __dir__)
|
67
|
+
end
|
68
|
+
|
69
|
+
namespace :yard do
|
70
|
+
desc 'Measure documentation coverage'
|
71
|
+
task :cov do
|
72
|
+
result = `bundle exec yard stats`.lines.last.strip.freeze
|
73
|
+
m = result.match(/\A(\d+(\.\d+)?)% documented\z/)
|
74
|
+
raise 'Invalid result' if m.nil?
|
75
|
+
|
76
|
+
coverage = m[1].to_f.round(2)
|
77
|
+
puts "Documentation coverage: #{coverage}%"
|
78
|
+
raise 'Not fully documented!' if coverage != 100
|
79
|
+
end
|
80
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#include <kernaux.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
static void assert_cb(const char *file, int line, const char *msg);
|
5
|
+
|
6
|
+
static VALUE rb_KernAux_assert_cb(VALUE self);
|
7
|
+
static VALUE rb_KernAux_assert_cb_EQ(VALUE self, VALUE assert_cb);
|
8
|
+
static
|
9
|
+
VALUE rb_KernAux_assert_do(VALUE self, VALUE file, VALUE line, VALUE msg);
|
10
|
+
|
11
|
+
static ID rb_intern_call = Qnil;
|
12
|
+
static VALUE rb_KernAux = Qnil;
|
13
|
+
|
14
|
+
void init_assert()
|
15
|
+
{
|
16
|
+
rb_gc_register_mark_object(ID2SYM(rb_intern_call = rb_intern("call")));
|
17
|
+
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
18
|
+
|
19
|
+
kernaux_assert_cb = assert_cb;
|
20
|
+
|
21
|
+
rb_define_singleton_method(rb_KernAux, "assert_cb",
|
22
|
+
rb_KernAux_assert_cb, 0);
|
23
|
+
rb_define_singleton_method(rb_KernAux, "assert_cb=",
|
24
|
+
rb_KernAux_assert_cb_EQ, 1);
|
25
|
+
rb_define_singleton_method(rb_KernAux, "assert_do",
|
26
|
+
rb_KernAux_assert_do, 3);
|
27
|
+
}
|
28
|
+
|
29
|
+
void assert_cb(const char *const file, const int line, const char *const msg)
|
30
|
+
{
|
31
|
+
const VALUE assert_cb_rb = rb_iv_get(rb_KernAux, "@assert_cb");
|
32
|
+
if (assert_cb_rb == Qnil) return;
|
33
|
+
const VALUE file_rb = rb_str_new2(file);
|
34
|
+
const VALUE line_rb = INT2FIX(line);
|
35
|
+
const VALUE msg_rb = rb_str_new2(msg);
|
36
|
+
rb_funcall(assert_cb_rb, rb_intern_call, 3, file_rb, line_rb, msg_rb);
|
37
|
+
}
|
38
|
+
|
39
|
+
VALUE rb_KernAux_assert_cb(const VALUE self)
|
40
|
+
{
|
41
|
+
return rb_iv_get(self, "@assert_cb");
|
42
|
+
}
|
43
|
+
|
44
|
+
VALUE rb_KernAux_assert_cb_EQ(const VALUE self, const VALUE assert_cb_rb)
|
45
|
+
{
|
46
|
+
return rb_iv_set(self, "@assert_cb", assert_cb_rb);
|
47
|
+
}
|
48
|
+
|
49
|
+
VALUE rb_KernAux_assert_do(
|
50
|
+
const VALUE self_rb __attribute__((unused)),
|
51
|
+
VALUE file_rb,
|
52
|
+
const VALUE line_rb,
|
53
|
+
VALUE msg_rb
|
54
|
+
) {
|
55
|
+
const char *const file = StringValueCStr(file_rb);
|
56
|
+
const int line = FIX2INT(line_rb);
|
57
|
+
const char *const msg = StringValueCStr(msg_rb);
|
58
|
+
|
59
|
+
kernaux_assert_do(file, line, msg);
|
60
|
+
|
61
|
+
return Qnil;
|
62
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#include <kernaux.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
#ifdef HAVE_KERNAUX_CMDLINE
|
5
|
+
|
6
|
+
#define ARGV_COUNT_MAX 256
|
7
|
+
#define BUFFER_SIZE 4096
|
8
|
+
|
9
|
+
struct Data {
|
10
|
+
char error_msg[KERNAUX_CMDLINE_ERROR_MSG_SIZE_MAX];
|
11
|
+
char *argv[ARGV_COUNT_MAX];
|
12
|
+
char buffer[BUFFER_SIZE];
|
13
|
+
};
|
14
|
+
|
15
|
+
static VALUE rb_ANON_Data_ALLOC(VALUE klass);
|
16
|
+
static VALUE rb_KernAux_cmdline(VALUE self, VALUE cmdline);
|
17
|
+
|
18
|
+
static const struct rb_data_type_struct info = {
|
19
|
+
.wrap_struct_name = "cmdline",
|
20
|
+
.function = {
|
21
|
+
.dmark = NULL,
|
22
|
+
.dfree = RUBY_DEFAULT_FREE,
|
23
|
+
.dsize = NULL,
|
24
|
+
.dcompact = NULL,
|
25
|
+
.reserved = { 0 },
|
26
|
+
},
|
27
|
+
.parent = NULL,
|
28
|
+
.data = NULL,
|
29
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
30
|
+
};
|
31
|
+
|
32
|
+
static ID rb_intern_freeze = Qnil;
|
33
|
+
static ID rb_intern_new = Qnil;
|
34
|
+
|
35
|
+
static VALUE rb_KernAux = Qnil;
|
36
|
+
static VALUE rb_KernAux_Error = Qnil;
|
37
|
+
static VALUE rb_KernAux_CmdlineError = Qnil;
|
38
|
+
static VALUE rb_ANON_Data = Qnil;
|
39
|
+
|
40
|
+
void init_cmdline()
|
41
|
+
{
|
42
|
+
rb_gc_register_mark_object(ID2SYM(rb_intern_freeze = rb_intern("freeze")));
|
43
|
+
rb_gc_register_mark_object(ID2SYM(rb_intern_new = rb_intern("new")));
|
44
|
+
|
45
|
+
rb_gc_register_mark_object(rb_KernAux = rb_define_module("KernAux"));
|
46
|
+
rb_gc_register_mark_object(rb_KernAux_Error =
|
47
|
+
rb_define_class_under(rb_KernAux, "Error", rb_eRuntimeError));
|
48
|
+
rb_gc_register_mark_object(rb_KernAux_CmdlineError =
|
49
|
+
rb_define_class_under(rb_KernAux, "CmdlineError", rb_KernAux_Error));
|
50
|
+
rb_gc_register_mark_object(rb_ANON_Data =
|
51
|
+
rb_funcall(rb_cClass, rb_intern_new, 1, rb_cObject));
|
52
|
+
|
53
|
+
rb_define_alloc_func(rb_ANON_Data, rb_ANON_Data_ALLOC);
|
54
|
+
rb_define_singleton_method(rb_KernAux, "cmdline", rb_KernAux_cmdline, 1);
|
55
|
+
}
|
56
|
+
|
57
|
+
VALUE rb_ANON_Data_ALLOC(const VALUE klass)
|
58
|
+
{
|
59
|
+
struct Data *data;
|
60
|
+
return TypedData_Make_Struct(klass, struct Data, &info, data);
|
61
|
+
}
|
62
|
+
|
63
|
+
VALUE rb_KernAux_cmdline(const VALUE self_rb, VALUE cmdline_rb)
|
64
|
+
{
|
65
|
+
const char *const cmdline = StringValueCStr(cmdline_rb);
|
66
|
+
size_t argc;
|
67
|
+
|
68
|
+
const VALUE data_rb = rb_funcall(rb_ANON_Data, rb_intern_new, 0);
|
69
|
+
struct Data *data;
|
70
|
+
TypedData_Get_Struct(data_rb, struct Data, &info, data);
|
71
|
+
if (!data) rb_raise(rb_KernAux_CmdlineError, "internal error");
|
72
|
+
|
73
|
+
const bool result = kernaux_cmdline(
|
74
|
+
cmdline,
|
75
|
+
data->error_msg,
|
76
|
+
&argc,
|
77
|
+
data->argv,
|
78
|
+
data->buffer,
|
79
|
+
ARGV_COUNT_MAX,
|
80
|
+
BUFFER_SIZE
|
81
|
+
);
|
82
|
+
|
83
|
+
if (!result) rb_raise(rb_KernAux_CmdlineError, "%s", data->error_msg);
|
84
|
+
|
85
|
+
VALUE result_rb = rb_ary_new2(argc);
|
86
|
+
for (size_t index = 0; index < argc; ++index) {
|
87
|
+
rb_ary_push(
|
88
|
+
result_rb,
|
89
|
+
rb_funcall(rb_str_new2(data->argv[index]), rb_intern_freeze, 0)
|
90
|
+
);
|
91
|
+
}
|
92
|
+
return rb_funcall(result_rb, rb_intern_freeze, 0);
|
93
|
+
}
|
94
|
+
|
95
|
+
#endif // HAVE_KERNAUX_CMDLINE
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#include "dynarg.h"
|
2
|
+
|
3
|
+
struct DynArg DynArg_create()
|
4
|
+
{
|
5
|
+
struct DynArg dynarg;
|
6
|
+
DynArg_init(&dynarg);
|
7
|
+
return dynarg;
|
8
|
+
}
|
9
|
+
|
10
|
+
void DynArg_init(struct DynArg *const dynarg)
|
11
|
+
{
|
12
|
+
dynarg->use_dbl = false;
|
13
|
+
dynarg->dbl = 0.0;
|
14
|
+
dynarg->arg.str = "";
|
15
|
+
}
|
16
|
+
|
17
|
+
void DynArg_use_char(struct DynArg *const dynarg, const char chr)
|
18
|
+
{
|
19
|
+
dynarg->use_dbl = false;
|
20
|
+
dynarg->arg.chr = chr;
|
21
|
+
}
|
22
|
+
|
23
|
+
void DynArg_use_double(struct DynArg *const dynarg, const double dbl)
|
24
|
+
{
|
25
|
+
dynarg->use_dbl = true;
|
26
|
+
dynarg->dbl = dbl;
|
27
|
+
}
|
28
|
+
|
29
|
+
void DynArg_use_long_long(struct DynArg *const dynarg, const long long ll)
|
30
|
+
{
|
31
|
+
dynarg->use_dbl = false;
|
32
|
+
dynarg->arg.ll = ll;
|
33
|
+
}
|
34
|
+
|
35
|
+
void DynArg_use_str(struct DynArg *const dynarg, const char *const str)
|
36
|
+
{
|
37
|
+
dynarg->use_dbl = false;
|
38
|
+
dynarg->arg.str = str;
|
39
|
+
}
|
40
|
+
|
41
|
+
void DynArg_use_unsigned_long_long(struct DynArg *const dynarg, const unsigned long long ull)
|
42
|
+
{
|
43
|
+
dynarg->use_dbl = false;
|
44
|
+
dynarg->arg.ull = ull;
|
45
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#ifndef INCLUDED_DYNARG
|
2
|
+
#define INCLUDED_DYNARG
|
3
|
+
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
8
|
+
#include <stdbool.h>
|
9
|
+
|
10
|
+
struct DynArg {
|
11
|
+
bool use_dbl;
|
12
|
+
double dbl;
|
13
|
+
// TODO: check if this will work on different endianness.
|
14
|
+
union {
|
15
|
+
char chr;
|
16
|
+
long long ll;
|
17
|
+
const char *str;
|
18
|
+
unsigned long long ull;
|
19
|
+
} __attribute__((packed)) arg;
|
20
|
+
};
|
21
|
+
|
22
|
+
struct DynArg DynArg_create();
|
23
|
+
void DynArg_init(struct DynArg *dynarg);
|
24
|
+
|
25
|
+
void DynArg_use_char(struct DynArg *dynarg, char chr);
|
26
|
+
void DynArg_use_double(struct DynArg *dynarg, double dbl);
|
27
|
+
void DynArg_use_long_long(struct DynArg *dynarg, long long ll);
|
28
|
+
void DynArg_use_str(struct DynArg *dynarg, const char *str);
|
29
|
+
void DynArg_use_unsigned_long_long(struct DynArg *dynarg, unsigned long long ull);
|
30
|
+
|
31
|
+
#ifdef __cplusplus
|
32
|
+
}
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#endif
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
|
5
|
+
$CFLAGS += ' -pedantic -Wall -Wextra'
|
6
|
+
|
7
|
+
raise 'libkernaux not found' unless have_library 'kernaux'
|
8
|
+
|
9
|
+
raise 'kernaux_assert_do not found' unless have_func 'kernaux_assert_do'
|
10
|
+
unless have_var 'kernaux_assert_cb', 'kernaux.h'
|
11
|
+
raise 'kernaux_assert_cb not found'
|
12
|
+
end
|
13
|
+
|
14
|
+
have_func 'kernaux_utoa'
|
15
|
+
have_func 'kernaux_itoa'
|
16
|
+
have_func 'kernaux_utoa10'
|
17
|
+
have_func 'kernaux_itoa10'
|
18
|
+
have_func 'kernaux_utoa16'
|
19
|
+
have_func 'kernaux_itoa16'
|
20
|
+
|
21
|
+
have_func 'kernaux_snprintf'
|
22
|
+
|
23
|
+
# TODO: do something if not found?
|
24
|
+
have_func 'KernAux_PrintfFmt_Spec_create'
|
25
|
+
have_func 'KernAux_PrintfFmt_Spec_parse'
|
26
|
+
have_func 'KernAux_PrintfFmt_Spec_set_width'
|
27
|
+
have_func 'KernAux_PrintfFmt_Spec_set_precision'
|
28
|
+
|
29
|
+
have_func 'kernaux_cmdline'
|
30
|
+
|
31
|
+
raise 'can\'t create Makefile' unless create_makefile 'kernaux/default'
|
data/ext/default/main.c
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#include <stdbool.h>
|
2
|
+
#include <stddef.h>
|
3
|
+
#include <stdint.h>
|
4
|
+
#include <stdlib.h>
|
5
|
+
|
6
|
+
#include <kernaux.h>
|
7
|
+
#include <ruby.h>
|
8
|
+
|
9
|
+
void init_assert();
|
10
|
+
void init_ntoa();
|
11
|
+
#ifdef HAVE_KERNAUX_SNPRINTF
|
12
|
+
void init_printf();
|
13
|
+
#endif // HAVE_KERNAUX_SNPRINTF
|
14
|
+
#ifdef HAVE_KERNAUX_CMDLINE
|
15
|
+
void init_cmdline();
|
16
|
+
#endif // HAVE_KERNAUX_CMDLINE
|
17
|
+
|
18
|
+
void Init_default()
|
19
|
+
{
|
20
|
+
init_assert();
|
21
|
+
init_ntoa();
|
22
|
+
#ifdef HAVE_KERNAUX_SNPRINTF
|
23
|
+
init_printf();
|
24
|
+
#endif // HAVE_KERNAUX_SNPRINTF
|
25
|
+
#ifdef HAVE_KERNAUX_CMDLINE
|
26
|
+
init_cmdline();
|
27
|
+
#endif // HAVE_KERNAUX_CMDLINE
|
28
|
+
}
|