tioga 1.4 → 1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Tioga_README +177 -139
- data/split/Dtable/dtable.c +3 -0
- data/split/Dtable/namespace.h +7 -3
- data/split/Dtable/symbols.h +2 -2
- data/split/Dvector/dvector.c +3 -2
- data/split/Dvector/namespace.h +7 -3
- data/split/Dvector/symbols.h +2 -2
- data/split/Flate/flate.c +2 -1
- data/split/Flate/namespace.h +7 -3
- data/split/Flate/symbols.h +2 -2
- data/split/Function/extconf.rb +1 -1
- data/split/Function/function.c +38 -6
- data/split/Function/joint_qsort.c +1 -2
- data/split/Function/namespace.h +7 -3
- data/split/Function/symbols.h +2 -2
- data/split/Tioga/axes.c +4 -5
- data/split/Tioga/figures.c +1 -0
- data/split/Tioga/figures.h +5 -3
- data/split/Tioga/lib/Arcs_and_Circles.rb +1 -1
- data/split/Tioga/lib/ColorConstants.rb +9 -9
- data/split/Tioga/lib/Creating_Paths.rb +1 -1
- data/split/Tioga/lib/FigMkr.rb +25 -23
- data/split/Tioga/lib/FigureConstants.rb +2 -2
- data/split/Tioga/lib/Figures_and_Plots.rb +6 -6
- data/split/Tioga/lib/Images.rb +2 -2
- data/split/Tioga/lib/MarkerConstants.rb +3 -3
- data/split/Tioga/lib/Markers.rb +6 -6
- data/split/Tioga/lib/Page_Frame_Bounds.rb +1 -1
- data/split/Tioga/lib/Rectangles.rb +1 -1
- data/split/Tioga/lib/Shading.rb +2 -2
- data/split/Tioga/lib/Special_Paths.rb +5 -5
- data/split/Tioga/lib/Strokes.rb +2 -2
- data/split/Tioga/lib/TeX_Text.rb +5 -5
- data/split/Tioga/lib/TexPreamble.rb +116 -116
- data/split/Tioga/lib/Transparency.rb +2 -2
- data/split/Tioga/lib/Using_Paths.rb +1 -1
- data/split/Tioga/lib/X_and_Y_Axes.rb +19 -15
- data/split/Tioga/lib/irb_tioga.rb +36 -11
- data/split/Tioga/lib/maker.rb +201 -0
- data/split/Tioga/lib/tioga_ui_cmds.rb +6 -2
- data/split/Tioga/namespace.h +7 -3
- data/split/Tioga/pdfcoords.c +20 -2
- data/split/Tioga/pdfs.h +1 -1
- data/split/Tioga/symbols.h +2 -2
- data/split/extconf.rb +7 -5
- data/split/namespace.h +7 -3
- data/split/symbols.c +1 -9
- data/split/symbols.h +2 -2
- metadata +19 -23
- data/split/Dtable/symbols.c +0 -92
- data/split/Dvector/symbols.c +0 -92
- data/split/Flate/symbols.c +0 -92
- data/split/Function/symbols.c +0 -92
- data/split/Tioga/symbols.c +0 -92
data/split/Tioga/pdfs.h
CHANGED
|
@@ -221,7 +221,7 @@ extern void End_Axis_Standard_State(void);
|
|
|
221
221
|
extern void Write_gsave(void);
|
|
222
222
|
extern void Write_grestore(void);
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
extern void c_private_set_default_font_size(FM *p, double size);
|
|
225
225
|
|
|
226
226
|
void Init_Font_Dictionary(void);
|
|
227
227
|
|
data/split/Tioga/symbols.h
CHANGED
|
@@ -22,10 +22,10 @@ PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
|
22
22
|
|
|
23
23
|
#define DECLARE_SYMBOL(ret_type,name,args) \
|
|
24
24
|
typedef ret_type (*rb_export_##name##_type) args;\
|
|
25
|
-
|
|
25
|
+
INTERN rb_export_##name##_type name
|
|
26
26
|
|
|
27
27
|
#define IMPLEMENT_SYMBOL(name)\
|
|
28
|
-
|
|
28
|
+
INTERN rb_export_##name##_type name = 0;
|
|
29
29
|
|
|
30
30
|
#define RB_IMPORT_SYMBOL(module, name) \
|
|
31
31
|
name = (rb_export_##name##_type) rb_import_symbol(module, #name)
|
data/split/extconf.rb
CHANGED
|
@@ -14,22 +14,22 @@ end
|
|
|
14
14
|
# and builds Dvector.so
|
|
15
15
|
setup_dir("Dvector", "Dobjects",
|
|
16
16
|
"Dobjects/Dvector", include) do |l,b,i|
|
|
17
|
-
b.add_sources("symbols.c")
|
|
17
|
+
# b.add_sources("symbols.c")
|
|
18
18
|
end
|
|
19
19
|
# the same for Dtable
|
|
20
20
|
setup_dir("Dtable", "Dobjects",
|
|
21
21
|
"Dobjects/Dtable", include) do |l,b,i|
|
|
22
|
-
b.add_sources("symbols.c")
|
|
22
|
+
# b.add_sources("symbols.c")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
setup_dir("Flate", "", "Flate", include) do |l,b,i|
|
|
26
|
-
b.add_sources("symbols.c")
|
|
26
|
+
# b.add_sources("symbols.c")
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
setup_dir("Function", "Dobjects",
|
|
31
31
|
"Dobjects/Function", include) do |l,b,i|
|
|
32
|
-
b.add_sources("symbols.c")
|
|
32
|
+
# b.add_sources("symbols.c")
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
|
|
@@ -41,6 +41,7 @@ declare_library("Tioga",
|
|
|
41
41
|
"Tioga/lib/FigMkr.rb",
|
|
42
42
|
"Tioga/lib/FigureConstants.rb",
|
|
43
43
|
"Tioga/lib/MarkerConstants.rb",
|
|
44
|
+
"Tioga/lib/maker.rb",
|
|
44
45
|
"Tioga/lib/irb_tioga.rb",
|
|
45
46
|
"Tioga/lib/tioga_ui_cmds.rb",
|
|
46
47
|
"Tioga/lib/tioga_ui.rb",
|
|
@@ -48,7 +49,7 @@ declare_library("Tioga",
|
|
|
48
49
|
"Tioga/lib/TexPreamble.rb")
|
|
49
50
|
|
|
50
51
|
declare_binary_library("Tioga/FigureMaker",
|
|
51
|
-
"Tioga/**/*.c"
|
|
52
|
+
"Tioga/**/*.c")
|
|
52
53
|
|
|
53
54
|
# The preamble stuff:
|
|
54
55
|
custom_rule("Tioga/lib/TexPreamble.rb",
|
|
@@ -84,6 +85,7 @@ have_func("isnan","math.h")
|
|
|
84
85
|
|
|
85
86
|
# Installing scripts
|
|
86
87
|
declare_exec 'scripts/tioga'
|
|
88
|
+
declare_exec 'scripts/irb_tioga'
|
|
87
89
|
|
|
88
90
|
|
|
89
91
|
if Config::CONFIG["target"] =~ /darwin/i
|
data/split/namespace.h
CHANGED
|
@@ -34,14 +34,18 @@
|
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
#ifdef __APPLE__
|
|
37
|
-
# define
|
|
37
|
+
# define INTERN __private_extern__
|
|
38
38
|
# define PUBLIC
|
|
39
39
|
#elif __GNUC__ >= 4 /* we have the visibility attribute */
|
|
40
|
-
# define
|
|
40
|
+
# define INTERN __attribute__ ((visibility ("hidden")))
|
|
41
41
|
# define PUBLIC __attribute__ ((visibility ("default")))
|
|
42
42
|
#else /* not really good */
|
|
43
|
-
# define
|
|
43
|
+
# define INTERN
|
|
44
44
|
# define PUBLIC
|
|
45
45
|
#endif /* __APPLE__ and __GNU_C_ >= 4*/
|
|
46
46
|
|
|
47
|
+
/* In any case, PRIVATE is static */
|
|
48
|
+
|
|
49
|
+
#define PRIVATE static
|
|
50
|
+
|
|
47
51
|
#endif
|
data/split/symbols.c
CHANGED
|
@@ -39,11 +39,7 @@ static VALUE get_symbol_hash(VALUE module)
|
|
|
39
39
|
VALUE hash;
|
|
40
40
|
ID mv_id = rb_intern(MV_SYMBOLS);
|
|
41
41
|
if(RTEST(rb_ivar_defined(module, mv_id)))
|
|
42
|
-
|
|
43
|
-
hash = rb_ivar_get(module, mv_id);
|
|
44
|
-
Check_Type(hash, T_HASH);
|
|
45
|
-
return hash;
|
|
46
|
-
}
|
|
42
|
+
return rb_ivar_get(module, mv_id);
|
|
47
43
|
else
|
|
48
44
|
{
|
|
49
45
|
/* module variable uninitialized, we need to make sure it's here */
|
|
@@ -66,10 +62,6 @@ PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
|
66
62
|
const char * symbol_name)
|
|
67
63
|
{
|
|
68
64
|
VALUE hash = rb_iv_get(module, MV_SYMBOLS);
|
|
69
|
-
if(TYPE(hash) != T_HASH)
|
|
70
|
-
return NULL; /* doesn't fail, but the importing module
|
|
71
|
-
should definitely check the return value. Beware
|
|
72
|
-
of segfaults ! */
|
|
73
65
|
VALUE symbol = rb_hash_aref(hash, rb_str_new2(symbol_name));
|
|
74
66
|
|
|
75
67
|
if(TYPE(symbol) == T_FIXNUM || TYPE(symbol) == T_BIGNUM)
|
data/split/symbols.h
CHANGED
|
@@ -22,10 +22,10 @@ PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
|
22
22
|
|
|
23
23
|
#define DECLARE_SYMBOL(ret_type,name,args) \
|
|
24
24
|
typedef ret_type (*rb_export_##name##_type) args;\
|
|
25
|
-
|
|
25
|
+
INTERN rb_export_##name##_type name
|
|
26
26
|
|
|
27
27
|
#define IMPLEMENT_SYMBOL(name)\
|
|
28
|
-
|
|
28
|
+
INTERN rb_export_##name##_type name = 0;
|
|
29
29
|
|
|
30
30
|
#define RB_IMPORT_SYMBOL(module, name) \
|
|
31
31
|
name = (rb_export_##name##_type) rb_import_symbol(module, #name)
|
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: tioga
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: "1.
|
|
7
|
-
date: 2007-
|
|
6
|
+
version: "1.5"
|
|
7
|
+
date: 2007-03-17 00:00:00 +01:00
|
|
8
8
|
summary: Tioga - a powerful scientific plotting library
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -29,7 +29,6 @@ post_install_message:
|
|
|
29
29
|
authors: []
|
|
30
30
|
|
|
31
31
|
files:
|
|
32
|
-
- split/symbols.c
|
|
33
32
|
- split/Tioga/pdfcoords.c
|
|
34
33
|
- split/Tioga/makers.c
|
|
35
34
|
- split/Tioga/axes.c
|
|
@@ -40,22 +39,14 @@ files:
|
|
|
40
39
|
- split/Tioga/pdf_font_dicts.c
|
|
41
40
|
- split/Tioga/pdfimage.c
|
|
42
41
|
- split/Tioga/pdftext.c
|
|
43
|
-
- split/Tioga/symbols.c
|
|
44
42
|
- split/Tioga/pdfpath.c
|
|
45
43
|
- split/Tioga/texout.c
|
|
46
|
-
- split/Function/symbols.c
|
|
47
44
|
- split/Function/function.c
|
|
48
45
|
- split/Function/joint_qsort.c
|
|
49
46
|
- split/Dvector/dvector.c
|
|
50
|
-
- split/Dvector/symbols.c
|
|
51
|
-
- split/Dtable/symbols.c
|
|
52
47
|
- split/Dtable/dtable.c
|
|
53
|
-
- split/Flate/symbols.c
|
|
54
48
|
- split/Flate/flate.c
|
|
55
|
-
- split/
|
|
56
|
-
- split/defs.h
|
|
57
|
-
- split/symbols.h
|
|
58
|
-
- split/safe_double.h
|
|
49
|
+
- split/symbols.c
|
|
59
50
|
- split/Tioga/pdfs.h
|
|
60
51
|
- split/Tioga/figures.h
|
|
61
52
|
- split/Tioga/symbols.h
|
|
@@ -65,34 +56,35 @@ files:
|
|
|
65
56
|
- split/Tioga/dvector.h
|
|
66
57
|
- split/Tioga/dtable.h
|
|
67
58
|
- split/Tioga/flate.h
|
|
68
|
-
- split/Function/defs.h
|
|
69
59
|
- split/Function/symbols.h
|
|
60
|
+
- split/Function/defs.h
|
|
70
61
|
- split/Function/safe_double.h
|
|
71
62
|
- split/Function/namespace.h
|
|
72
63
|
- split/Function/dvector.h
|
|
64
|
+
- split/namespace.h
|
|
65
|
+
- split/Dvector/include/dvector.h
|
|
73
66
|
- split/Dvector/dvector_intern.h
|
|
74
67
|
- split/Dvector/symbols.h
|
|
75
68
|
- split/Dvector/defs.h
|
|
76
69
|
- split/Dvector/safe_double.h
|
|
77
70
|
- split/Dvector/namespace.h
|
|
78
|
-
- split/
|
|
71
|
+
- split/Dtable/include/dtable.h
|
|
79
72
|
- split/Dtable/dtable_intern.h
|
|
80
73
|
- split/Dtable/symbols.h
|
|
81
74
|
- split/Dtable/defs.h
|
|
82
75
|
- split/Dtable/safe_double.h
|
|
83
76
|
- split/Dtable/namespace.h
|
|
84
77
|
- split/Dtable/dvector.h
|
|
85
|
-
- split/
|
|
78
|
+
- split/defs.h
|
|
79
|
+
- split/Flate/include/flate.h
|
|
86
80
|
- split/Flate/flate_intern.h
|
|
87
81
|
- split/Flate/symbols.h
|
|
88
82
|
- split/Flate/defs.h
|
|
89
83
|
- split/Flate/safe_double.h
|
|
90
84
|
- split/Flate/namespace.h
|
|
91
|
-
- split/
|
|
92
|
-
- split/
|
|
93
|
-
- split/mkmf2.rb
|
|
85
|
+
- split/symbols.h
|
|
86
|
+
- split/safe_double.h
|
|
94
87
|
- split/Tioga/mk_tioga_sty.rb
|
|
95
|
-
- split/Tioga/extconf.rb
|
|
96
88
|
- split/Tioga/lib/Rectangles.rb
|
|
97
89
|
- split/Tioga/lib/Colorbars.rb
|
|
98
90
|
- split/Tioga/lib/Shading.rb
|
|
@@ -109,6 +101,7 @@ files:
|
|
|
109
101
|
- split/Tioga/lib/X_and_Y_Axes.rb
|
|
110
102
|
- split/Tioga/lib/irb_tioga.rb
|
|
111
103
|
- split/Tioga/lib/Colormaps.rb
|
|
104
|
+
- split/Tioga/lib/maker.rb
|
|
112
105
|
- split/Tioga/lib/tioga_ui.rb
|
|
113
106
|
- split/Tioga/lib/Utils.rb
|
|
114
107
|
- split/Tioga/lib/Figures_and_Plots.rb
|
|
@@ -120,18 +113,21 @@ files:
|
|
|
120
113
|
- split/Tioga/lib/tioga_ui_cmds.rb
|
|
121
114
|
- split/Tioga/lib/Images.rb
|
|
122
115
|
- split/Tioga/lib/Doc.rb
|
|
123
|
-
- split/Tioga/lib/TexPreamble.rb
|
|
124
116
|
- split/Tioga/lib/Titles_and_Labels.rb
|
|
125
117
|
- split/Tioga/lib/Transparency.rb
|
|
126
118
|
- split/Tioga/lib/ColorConstants.rb
|
|
127
|
-
- split/
|
|
119
|
+
- split/Tioga/lib/TexPreamble.rb
|
|
120
|
+
- split/Tioga/extconf.rb
|
|
128
121
|
- split/Function/lib/Function_extras.rb
|
|
129
|
-
- split/
|
|
122
|
+
- split/Function/extconf.rb
|
|
130
123
|
- split/Dvector/lib/Numeric_extras.rb
|
|
131
124
|
- split/Dvector/lib/Dvector_extras.rb
|
|
132
|
-
- split/
|
|
125
|
+
- split/Dvector/extconf.rb
|
|
133
126
|
- split/Dtable/lib/Dtable_extras.rb
|
|
127
|
+
- split/Dtable/extconf.rb
|
|
134
128
|
- split/Flate/extconf.rb
|
|
129
|
+
- split/extconf.rb
|
|
130
|
+
- split/mkmf2.rb
|
|
135
131
|
- tests/dvector_test.data
|
|
136
132
|
- tests/dtable_test.data
|
|
137
133
|
- tests/tc_Dtable.rb
|
data/split/Dtable/symbols.c
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2006 Vincent Fourmond
|
|
3
|
-
|
|
4
|
-
Symbols is free software; you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU General Library Public License as published
|
|
6
|
-
by the Free Software Foundation; either version 2 of the License, or
|
|
7
|
-
(at your option) any later version.
|
|
8
|
-
|
|
9
|
-
Symbols is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Library General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Library General Public License
|
|
15
|
-
along with Dvector; if not, write to the Free Software
|
|
16
|
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* Simple code for sharing C symbols across different Ruby libraries */
|
|
21
|
-
|
|
22
|
-
#include <ruby.h>
|
|
23
|
-
#include <intern.h>
|
|
24
|
-
|
|
25
|
-
#include <namespace.h>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* MV stands for Module Variable */
|
|
29
|
-
#define MV_SYMBOLS "@_exported_C_symbols"
|
|
30
|
-
/* modified to use instance variables instead of global class variables:
|
|
31
|
-
this way, children don't overwrite the parent's export table
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/* makes sure that the hash is registered for the given
|
|
36
|
-
module and returns it */
|
|
37
|
-
static VALUE get_symbol_hash(VALUE module)
|
|
38
|
-
{
|
|
39
|
-
VALUE hash;
|
|
40
|
-
ID mv_id = rb_intern(MV_SYMBOLS);
|
|
41
|
-
if(RTEST(rb_ivar_defined(module, mv_id)))
|
|
42
|
-
{
|
|
43
|
-
hash = rb_ivar_get(module, mv_id);
|
|
44
|
-
Check_Type(hash, T_HASH);
|
|
45
|
-
return hash;
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
{
|
|
49
|
-
/* module variable uninitialized, we need to make sure it's here */
|
|
50
|
-
hash = rb_hash_new();
|
|
51
|
-
rb_ivar_set(module, mv_id, hash);
|
|
52
|
-
return hash;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* registers a symbol in the given module. This one is the internal
|
|
57
|
-
function */
|
|
58
|
-
PRIVATE void rb_export_symbol(VALUE module, const char * symbol_name,
|
|
59
|
-
void * symbol)
|
|
60
|
-
{
|
|
61
|
-
VALUE hash = get_symbol_hash(module);
|
|
62
|
-
rb_hash_aset(hash, rb_str_new2(symbol_name),LONG2NUM((long) symbol));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
66
|
-
const char * symbol_name)
|
|
67
|
-
{
|
|
68
|
-
VALUE hash = rb_iv_get(module, MV_SYMBOLS);
|
|
69
|
-
if(TYPE(hash) != T_HASH)
|
|
70
|
-
return NULL; /* doesn't fail, but the importing module
|
|
71
|
-
should definitely check the return value. Beware
|
|
72
|
-
of segfaults ! */
|
|
73
|
-
VALUE symbol = rb_hash_aref(hash, rb_str_new2(symbol_name));
|
|
74
|
-
|
|
75
|
-
if(TYPE(symbol) == T_FIXNUM || TYPE(symbol) == T_BIGNUM)
|
|
76
|
-
return (void *) NUM2LONG(symbol);
|
|
77
|
-
return NULL;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* same as before, but raises something is the return value is NULL,
|
|
81
|
-
which is probably best as a default behavior*/
|
|
82
|
-
PRIVATE void * rb_import_symbol(VALUE module, const char * symbol_name)
|
|
83
|
-
{
|
|
84
|
-
void * symbol = rb_import_symbol_no_raise(module, symbol_name);
|
|
85
|
-
if(symbol)
|
|
86
|
-
return symbol;
|
|
87
|
-
/* we get the name of the module: */
|
|
88
|
-
VALUE module_name = rb_funcall(module, rb_intern("to_s"), 0);
|
|
89
|
-
rb_raise(rb_eRuntimeError, "The symbol %s was not found in "
|
|
90
|
-
"module %s", symbol_name,
|
|
91
|
-
rb_string_value_cstr(&module_name));
|
|
92
|
-
}
|
data/split/Dvector/symbols.c
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2006 Vincent Fourmond
|
|
3
|
-
|
|
4
|
-
Symbols is free software; you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU General Library Public License as published
|
|
6
|
-
by the Free Software Foundation; either version 2 of the License, or
|
|
7
|
-
(at your option) any later version.
|
|
8
|
-
|
|
9
|
-
Symbols is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Library General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Library General Public License
|
|
15
|
-
along with Dvector; if not, write to the Free Software
|
|
16
|
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* Simple code for sharing C symbols across different Ruby libraries */
|
|
21
|
-
|
|
22
|
-
#include <ruby.h>
|
|
23
|
-
#include <intern.h>
|
|
24
|
-
|
|
25
|
-
#include <namespace.h>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* MV stands for Module Variable */
|
|
29
|
-
#define MV_SYMBOLS "@_exported_C_symbols"
|
|
30
|
-
/* modified to use instance variables instead of global class variables:
|
|
31
|
-
this way, children don't overwrite the parent's export table
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/* makes sure that the hash is registered for the given
|
|
36
|
-
module and returns it */
|
|
37
|
-
static VALUE get_symbol_hash(VALUE module)
|
|
38
|
-
{
|
|
39
|
-
VALUE hash;
|
|
40
|
-
ID mv_id = rb_intern(MV_SYMBOLS);
|
|
41
|
-
if(RTEST(rb_ivar_defined(module, mv_id)))
|
|
42
|
-
{
|
|
43
|
-
hash = rb_ivar_get(module, mv_id);
|
|
44
|
-
Check_Type(hash, T_HASH);
|
|
45
|
-
return hash;
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
{
|
|
49
|
-
/* module variable uninitialized, we need to make sure it's here */
|
|
50
|
-
hash = rb_hash_new();
|
|
51
|
-
rb_ivar_set(module, mv_id, hash);
|
|
52
|
-
return hash;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* registers a symbol in the given module. This one is the internal
|
|
57
|
-
function */
|
|
58
|
-
PRIVATE void rb_export_symbol(VALUE module, const char * symbol_name,
|
|
59
|
-
void * symbol)
|
|
60
|
-
{
|
|
61
|
-
VALUE hash = get_symbol_hash(module);
|
|
62
|
-
rb_hash_aset(hash, rb_str_new2(symbol_name),LONG2NUM((long) symbol));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
66
|
-
const char * symbol_name)
|
|
67
|
-
{
|
|
68
|
-
VALUE hash = rb_iv_get(module, MV_SYMBOLS);
|
|
69
|
-
if(TYPE(hash) != T_HASH)
|
|
70
|
-
return NULL; /* doesn't fail, but the importing module
|
|
71
|
-
should definitely check the return value. Beware
|
|
72
|
-
of segfaults ! */
|
|
73
|
-
VALUE symbol = rb_hash_aref(hash, rb_str_new2(symbol_name));
|
|
74
|
-
|
|
75
|
-
if(TYPE(symbol) == T_FIXNUM || TYPE(symbol) == T_BIGNUM)
|
|
76
|
-
return (void *) NUM2LONG(symbol);
|
|
77
|
-
return NULL;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* same as before, but raises something is the return value is NULL,
|
|
81
|
-
which is probably best as a default behavior*/
|
|
82
|
-
PRIVATE void * rb_import_symbol(VALUE module, const char * symbol_name)
|
|
83
|
-
{
|
|
84
|
-
void * symbol = rb_import_symbol_no_raise(module, symbol_name);
|
|
85
|
-
if(symbol)
|
|
86
|
-
return symbol;
|
|
87
|
-
/* we get the name of the module: */
|
|
88
|
-
VALUE module_name = rb_funcall(module, rb_intern("to_s"), 0);
|
|
89
|
-
rb_raise(rb_eRuntimeError, "The symbol %s was not found in "
|
|
90
|
-
"module %s", symbol_name,
|
|
91
|
-
rb_string_value_cstr(&module_name));
|
|
92
|
-
}
|
data/split/Flate/symbols.c
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2006 Vincent Fourmond
|
|
3
|
-
|
|
4
|
-
Symbols is free software; you can redistribute it and/or modify
|
|
5
|
-
it under the terms of the GNU General Library Public License as published
|
|
6
|
-
by the Free Software Foundation; either version 2 of the License, or
|
|
7
|
-
(at your option) any later version.
|
|
8
|
-
|
|
9
|
-
Symbols is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
GNU Library General Public License for more details.
|
|
13
|
-
|
|
14
|
-
You should have received a copy of the GNU Library General Public License
|
|
15
|
-
along with Dvector; if not, write to the Free Software
|
|
16
|
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/* Simple code for sharing C symbols across different Ruby libraries */
|
|
21
|
-
|
|
22
|
-
#include <ruby.h>
|
|
23
|
-
#include <intern.h>
|
|
24
|
-
|
|
25
|
-
#include <namespace.h>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* MV stands for Module Variable */
|
|
29
|
-
#define MV_SYMBOLS "@_exported_C_symbols"
|
|
30
|
-
/* modified to use instance variables instead of global class variables:
|
|
31
|
-
this way, children don't overwrite the parent's export table
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/* makes sure that the hash is registered for the given
|
|
36
|
-
module and returns it */
|
|
37
|
-
static VALUE get_symbol_hash(VALUE module)
|
|
38
|
-
{
|
|
39
|
-
VALUE hash;
|
|
40
|
-
ID mv_id = rb_intern(MV_SYMBOLS);
|
|
41
|
-
if(RTEST(rb_ivar_defined(module, mv_id)))
|
|
42
|
-
{
|
|
43
|
-
hash = rb_ivar_get(module, mv_id);
|
|
44
|
-
Check_Type(hash, T_HASH);
|
|
45
|
-
return hash;
|
|
46
|
-
}
|
|
47
|
-
else
|
|
48
|
-
{
|
|
49
|
-
/* module variable uninitialized, we need to make sure it's here */
|
|
50
|
-
hash = rb_hash_new();
|
|
51
|
-
rb_ivar_set(module, mv_id, hash);
|
|
52
|
-
return hash;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* registers a symbol in the given module. This one is the internal
|
|
57
|
-
function */
|
|
58
|
-
PRIVATE void rb_export_symbol(VALUE module, const char * symbol_name,
|
|
59
|
-
void * symbol)
|
|
60
|
-
{
|
|
61
|
-
VALUE hash = get_symbol_hash(module);
|
|
62
|
-
rb_hash_aset(hash, rb_str_new2(symbol_name),LONG2NUM((long) symbol));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
PRIVATE void * rb_import_symbol_no_raise(VALUE module,
|
|
66
|
-
const char * symbol_name)
|
|
67
|
-
{
|
|
68
|
-
VALUE hash = rb_iv_get(module, MV_SYMBOLS);
|
|
69
|
-
if(TYPE(hash) != T_HASH)
|
|
70
|
-
return NULL; /* doesn't fail, but the importing module
|
|
71
|
-
should definitely check the return value. Beware
|
|
72
|
-
of segfaults ! */
|
|
73
|
-
VALUE symbol = rb_hash_aref(hash, rb_str_new2(symbol_name));
|
|
74
|
-
|
|
75
|
-
if(TYPE(symbol) == T_FIXNUM || TYPE(symbol) == T_BIGNUM)
|
|
76
|
-
return (void *) NUM2LONG(symbol);
|
|
77
|
-
return NULL;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* same as before, but raises something is the return value is NULL,
|
|
81
|
-
which is probably best as a default behavior*/
|
|
82
|
-
PRIVATE void * rb_import_symbol(VALUE module, const char * symbol_name)
|
|
83
|
-
{
|
|
84
|
-
void * symbol = rb_import_symbol_no_raise(module, symbol_name);
|
|
85
|
-
if(symbol)
|
|
86
|
-
return symbol;
|
|
87
|
-
/* we get the name of the module: */
|
|
88
|
-
VALUE module_name = rb_funcall(module, rb_intern("to_s"), 0);
|
|
89
|
-
rb_raise(rb_eRuntimeError, "The symbol %s was not found in "
|
|
90
|
-
"module %s", symbol_name,
|
|
91
|
-
rb_string_value_cstr(&module_name));
|
|
92
|
-
}
|