summaryrefslogtreecommitdiff
path: root/jni/ruby/enc/encinit.c.erb
blob: 70c2a1934cd329a4eeb74b0f8476fd45c984f52a (plain)
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
/* Copyright 2012 Google Inc. Some Rights Reserved.
 * Author: yugui@google.com (Yugui Sonoda)
 */
#include <stdio.h>

#define init(func, name) {      \
    extern void func(void);     \
    ruby_init_ext(name, func);  \
}

#define init_enc(name) init(Init_##name, "enc/"#name".so")
#define init_trans(name) init(Init_trans_##name, "enc/trans/"#name".so")
#define provide(func, name) { \
    extern void Init_##func(void); \
    Init_##func(); \
    rb_provide(name".so"); \
}

void ruby_init_ext(const char *name, void (*init)(void));
void rb_provide(const char *feature);

void
Init_enc(void)
{
    provide(encdb, "encdb");
% ENCS.each do |enc|
%   next if enc == 'encdb'
    init_enc(<%= enc %>);
% end

    provide(transdb, "trans/transdb");
% TRANS.each do |trans|
%   next if trans == 'trans/transdb'
    init_trans(<%= File.basename trans %>);
% end
}
<%# vim: set ft=eruby sw=2 : -%>