tatara 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1268bb136f3184f85b96809e40e4ab571f563bf3fd4642d9addfb80c00ea9302
4
+ data.tar.gz: 3ad328e25cefdefbd10cd38cc9b93d98a5da91e402317a77dccb56f9c50d3fb9
5
+ SHA512:
6
+ metadata.gz: 9f01b88a1ba64c2863f3b927de8ee056c3f33bcdbf2d6a74e77e5ffd7ce16dce7592c109bd7a1b71636f76d62f973ba391b044bc3f8add79ee8984626d181986
7
+ data.tar.gz: 8f289f3ac4b1d940e71020683f596470e71a07568de3611033caa017a75ffa54c6f744c83f97aab391cedc3940791a55f9a474df908239943567120ec7d1eeb1
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /lib/tatara/tatara.so
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tatara.gemspec
4
+ gemspec
5
+
6
+ gem "rice"
7
+ gem "rake-compiler"
8
+
9
+ # Using Benchmark Driver
10
+ gem "benchmark_driver"
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tatara (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ benchmark_driver (0.15.5)
10
+ minitest (5.11.3)
11
+ rake (10.5.0)
12
+ rake-compiler (1.0.7)
13
+ rake
14
+ rice (2.1.3)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ benchmark_driver
21
+ bundler (~> 2.0)
22
+ minitest (~> 5.0)
23
+ rake (~> 10.0)
24
+ rake-compiler
25
+ rice
26
+ tatara!
27
+
28
+ BUNDLED WITH
29
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 S.H.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,328 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ ECHO1 = $(V:1=@ :)
9
+ ECHO = $(ECHO1:0=@ echo)
10
+ NULLCMD = :
11
+
12
+ #### Start of system configuration section. ####
13
+
14
+ srcdir = ext/tatara
15
+ topdir = /home/sh/.rbenv/versions/2.6.3/include/ruby-2.6.0
16
+ hdrdir = $(topdir)
17
+ arch_hdrdir = /home/sh/.rbenv/versions/2.6.3/include/ruby-2.6.0/x86_64-linux
18
+ PATH_SEPARATOR = :
19
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
20
+
21
+ prefix = $(DESTDIR)/home/sh/.rbenv/versions/2.6.3
22
+
23
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
24
+
25
+ rubyarchprefix = $(rubylibprefix)/$(arch)
26
+
27
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
28
+
29
+ exec_prefix = $(prefix)
30
+
31
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
32
+
33
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
34
+
35
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
36
+
37
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
38
+
39
+ sitehdrdir = $(rubyhdrdir)/site_ruby
40
+
41
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
42
+
43
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
44
+
45
+ vendorlibdir = $(vendordir)/$(ruby_version)
46
+
47
+ vendordir = $(rubylibprefix)/vendor_ruby
48
+
49
+ sitearchdir = $(sitelibdir)/$(sitearch)
50
+
51
+ sitelibdir = $(sitedir)/$(ruby_version)
52
+
53
+ sitedir = $(rubylibprefix)/site_ruby
54
+
55
+ rubyarchdir = $(rubylibdir)/$(arch)
56
+
57
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
58
+
59
+ sitearchincludedir = $(includedir)/$(sitearch)
60
+
61
+ archincludedir = $(includedir)/$(arch)
62
+
63
+ sitearchlibdir = $(libdir)/$(sitearch)
64
+
65
+ archlibdir = $(libdir)/$(arch)
66
+
67
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
68
+
69
+ mandir = $(datarootdir)/man
70
+
71
+ localedir = $(datarootdir)/locale
72
+
73
+ libdir = $(exec_prefix)/lib
74
+
75
+ psdir = $(docdir)
76
+
77
+ pdfdir = $(docdir)
78
+
79
+ dvidir = $(docdir)
80
+
81
+ htmldir = $(docdir)
82
+
83
+ infodir = $(datarootdir)/info
84
+
85
+ docdir = $(datarootdir)/doc/$(PACKAGE)
86
+
87
+ oldincludedir = $(DESTDIR)/usr/include
88
+
89
+ includedir = $(prefix)/include
90
+
91
+ localstatedir = $(prefix)/var
92
+
93
+ sharedstatedir = $(prefix)/com
94
+
95
+ sysconfdir = $(prefix)/etc
96
+
97
+ datadir = $(datarootdir)
98
+
99
+ datarootdir = $(prefix)/share
100
+
101
+ libexecdir = $(exec_prefix)/libexec
102
+
103
+ sbindir = $(exec_prefix)/sbin
104
+
105
+ bindir = $(exec_prefix)/bin
106
+
107
+ archdir = $(rubyarchdir)
108
+
109
+
110
+
111
+ CC_WRAPPER =
112
+ CC = gcc
113
+ CXX = g++
114
+ LIBRUBY = $(LIBRUBY_SO)
115
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
116
+ LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
117
+ LIBRUBYARG_STATIC = -Wl,-rpath,/home/sh/.rbenv/versions/2.6.3/lib -L/home/sh/.rbenv/versions/2.6.3/lib -lruby-static -lz -lpthread -lrt -lrt -ldl -lcrypt -lm
118
+ empty =
119
+ OUTFLAG = -o $(empty)
120
+ COUTFLAG = -o $(empty)
121
+ CSRCFLAG = $(empty)
122
+
123
+ RUBY_EXTCONF_H =
124
+ cflags = $(optflags) $(debugflags) $(warnflags)
125
+ cxxflags = $(optflags) $(debugflags) $(warnflags)
126
+ optflags = -O3
127
+ debugflags = -ggdb3
128
+ warnflags = -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wrestrict -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable
129
+ cppflags =
130
+ CCDLFLAGS = -fPIC
131
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
132
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
133
+ DEFS =
134
+ CPPFLAGS = -I/home/sh/.rbenv/versions/2.6.3/include $(DEFS) $(cppflags) -I/home/sh/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rice-2.1.3/ruby/lib/include
135
+ CXXFLAGS = $(CFLAGS) -Wall -g
136
+ ldflags = -L. -L/home/sh/.rbenv/versions/2.6.3/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -L/home/sh/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rice-2.1.3/ruby/lib/lib -lrice
137
+ dldflags = -L/home/sh/.rbenv/versions/2.6.3/lib -Wl,--compress-debug-sections=zlib
138
+ ARCH_FLAG =
139
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
140
+ LDSHARED = g++ -shared
141
+ LDSHAREDXX = $(CXX) -shared
142
+ AR = ar
143
+ EXEEXT =
144
+
145
+
146
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
147
+
148
+ RUBY_SO_NAME = ruby
149
+
150
+ RUBYW_INSTALL_NAME =
151
+
152
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
153
+
154
+ RUBYW_BASE_NAME = rubyw
155
+
156
+ RUBY_BASE_NAME = ruby
157
+
158
+
159
+ arch = x86_64-linux
160
+ sitearch = $(arch)
161
+ ruby_version = 2.6.0
162
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
163
+ RUBY = $(ruby)
164
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
165
+
166
+ RM = rm -f
167
+ RM_RF = $(RUBY) -run -e rm -- -rf
168
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
169
+ MAKEDIRS = /bin/mkdir -p
170
+ INSTALL = /usr/bin/install -c
171
+ INSTALL_PROG = $(INSTALL) -m 0755
172
+ INSTALL_DATA = $(INSTALL) -m 644
173
+ COPY = cp
174
+ TOUCH = exit >
175
+
176
+ #### End of system configuration section. ####
177
+
178
+ preload =
179
+
180
+
181
+ CXX = g++
182
+ libpath = . $(libdir)
183
+ LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir)
184
+ DEFFILE =
185
+
186
+ CLEANFILES = mkmf.log
187
+ DISTCLEANFILES =
188
+ DISTCLEANDIRS =
189
+
190
+ extout =
191
+ extout_prefix =
192
+ target_prefix = /tatara
193
+ LOCAL_LIBS =
194
+ LIBS = -Wl,-rpath,/home/sh/.rbenv/versions/2.6.3/lib -L/home/sh/.rbenv/versions/2.6.3/lib -lruby -lm -lc
195
+ ORIG_SRCS = tatara.cpp
196
+ SRCS = $(ORIG_SRCS)
197
+ OBJS = tatara.o
198
+ HDRS =
199
+ LOCAL_HDRS =
200
+ TARGET = tatara
201
+ TARGET_NAME = tatara
202
+ TARGET_ENTRY = Init_$(TARGET_NAME)
203
+ DLLIB = $(TARGET).so
204
+ EXTSTATIC =
205
+ STATIC_LIB =
206
+
207
+ TIMESTAMP_DIR = .
208
+
209
+ BINDIR = $(bindir)
210
+
211
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
212
+
213
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
214
+
215
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
216
+
217
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
218
+
219
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
220
+
221
+ TARGET_SO_DIR =
222
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
223
+ CLEANLIBS = $(TARGET_SO)
224
+ CLEANOBJS = *.o *.bak
225
+
226
+
227
+ all: $(DLLIB)
228
+ static: $(STATIC_LIB)
229
+ .PHONY: all install static install-so install-rb
230
+ .PHONY: clean clean-so clean-static clean-rb
231
+
232
+ clean-static::
233
+ clean-rb-default::
234
+ clean-rb::
235
+ clean-so::
236
+ clean: clean-so clean-static clean-rb-default clean-rb
237
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
238
+
239
+ distclean-rb-default::
240
+ distclean-rb::
241
+ distclean-so::
242
+ distclean-static::
243
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
244
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
245
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
246
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
247
+
248
+ realclean: distclean
249
+ install: install-so install-rb
250
+
251
+ install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.tatara.time
252
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
253
+ clean-static::
254
+ -$(Q)$(RM) $(STATIC_LIB)
255
+ install-rb: pre-install-rb do-install-rb install-rb-default
256
+ install-rb-default: pre-install-rb-default do-install-rb-default
257
+ pre-install-rb: Makefile
258
+ pre-install-rb-default: Makefile
259
+ do-install-rb:
260
+ do-install-rb-default:
261
+ pre-install-rb-default:
262
+ @$(NULLCMD)
263
+ $(TIMESTAMP_DIR)/.sitearchdir.-.tatara.time:
264
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
265
+ $(Q) $(TOUCH) $@
266
+
267
+ site-install: site-install-so site-install-rb
268
+ site-install-so: install-so
269
+ site-install-rb: install-rb
270
+
271
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
272
+
273
+ .cc.o:
274
+ $(ECHO) compiling $(<)
275
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
276
+
277
+ .cc.S:
278
+ $(ECHO) translating $(<)
279
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
280
+
281
+ .mm.o:
282
+ $(ECHO) compiling $(<)
283
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
284
+
285
+ .mm.S:
286
+ $(ECHO) translating $(<)
287
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
288
+
289
+ .cxx.o:
290
+ $(ECHO) compiling $(<)
291
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
292
+
293
+ .cxx.S:
294
+ $(ECHO) translating $(<)
295
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
296
+
297
+ .cpp.o:
298
+ $(ECHO) compiling $(<)
299
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
300
+
301
+ .cpp.S:
302
+ $(ECHO) translating $(<)
303
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
304
+
305
+ .c.o:
306
+ $(ECHO) compiling $(<)
307
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
308
+
309
+ .c.S:
310
+ $(ECHO) translating $(<)
311
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
312
+
313
+ .m.o:
314
+ $(ECHO) compiling $(<)
315
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
316
+
317
+ .m.S:
318
+ $(ECHO) translating $(<)
319
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
320
+
321
+ $(TARGET_SO): $(OBJS) Makefile
322
+ $(ECHO) linking shared-object tatara/$(DLLIB)
323
+ -$(Q)$(RM) $(@)
324
+ $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
325
+
326
+
327
+
328
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,41 @@
1
+ # Tatara
2
+
3
+ Add Type to Ruby!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tatara'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install tatara
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ @integer = Tatara::Integer.new # => This type is Integer!
25
+ @integer.value = 42
26
+ puts @integer.value # => 42 and type is Integer!
27
+ @integer.value = "42" #=> Error!
28
+ ```
29
+
30
+ `Tatara` supported `Integer`, `Float`, `String`.
31
+ And, Container for `Vector`, `Array`, `Map`!
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tatara.
@@ -0,0 +1,20 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "rake/extensiontask"
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "test"
7
+ t.libs << "lib"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ end
10
+
11
+ task :default => :test
12
+
13
+ Rake::ExtensionTask.new "tatara" do |ext|
14
+ ext.lib_dir = "lib/tatara"
15
+ end
16
+
17
+ desc 'Benchmark Task'
18
+ task :benchmark do
19
+ system("ruby benchmark/benchmark.rb")
20
+ end
@@ -0,0 +1,14 @@
1
+ require 'benchmark_driver'
2
+
3
+ Benchmark.driver do |x|
4
+ x.prelude <<~RUBY
5
+ require 'tatara/tatara'
6
+ RUBY
7
+
8
+ x.report %{ Tatara::String.new }
9
+ x.report %{ Tatara::Integer.new }
10
+ x.report %{ Tatara::Float.new }
11
+ x.report %{ Tatara::StringVector.new }
12
+ x.report %{ Tatara::IntVector.new }
13
+ x.report %{ Tatara::FloatVector.new }
14
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tatara"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,62 @@
1
+ #ifndef ARRAY__TEMPLATE_H_
2
+ #define ARRAY__TEMPLATE_H_
3
+
4
+ #include <vector>
5
+
6
+ template <class T>
7
+ class CppArray {
8
+ std::vector<T> container;
9
+ public:
10
+ constexpr CppArray();
11
+ ~CppArray();
12
+ constexpr T first();
13
+ constexpr T last();
14
+ constexpr T bracket(const int index);
15
+ constexpr T bracket_equal(const int index, const T var);
16
+ constexpr void emplace_back(const T var);
17
+ constexpr int size();
18
+ constexpr void clear();
19
+ };
20
+
21
+ template <class T>
22
+ constexpr CppArray<T>::CppArray() {}
23
+
24
+ template <class T>
25
+ CppArray<T>::~CppArray() {}
26
+
27
+ template <class T>
28
+ constexpr T CppArray<T>::first() {
29
+ return this->container.front();
30
+ }
31
+
32
+ template <class T>
33
+ constexpr T CppArray<T>::last(){
34
+ return this->container.back();
35
+ }
36
+
37
+ template <class T>
38
+ constexpr T CppArray<T>::bracket(const int index) {
39
+ return this->container[index];
40
+ }
41
+
42
+ template <class T>
43
+ constexpr T CppArray<T>::bracket_equal(const int index, const T var) {
44
+ return this->container[index] = var;
45
+ }
46
+
47
+ template <class T>
48
+ constexpr void CppArray<T>::emplace_back(const T var) {
49
+ this->container.emplace_back(var);
50
+ }
51
+
52
+ template <class T>
53
+ constexpr int CppArray<T>::size() {
54
+ return this->container.size();
55
+ }
56
+
57
+ template <class T>
58
+ constexpr void CppArray<T>::clear() {
59
+ this->container.clear();
60
+ }
61
+
62
+ #endif
@@ -0,0 +1,6 @@
1
+
2
+ require "mkmf-rice"
3
+
4
+ $CXXFLAGS = '-Ofast -mtune=native -march=native -mfpmath=both -std=c++17'
5
+
6
+ create_makefile("tatara/tatara")
@@ -0,0 +1,68 @@
1
+ #ifndef FLOAT_H_
2
+ #define FLOAT_H_
3
+
4
+ #include <string>
5
+ #include <regex>
6
+
7
+ class Float {
8
+ double value = 0.0;
9
+ public:
10
+ constexpr Float();
11
+ ~Float();
12
+ constexpr double assignment(const double var);
13
+ constexpr double return_value();
14
+ constexpr double increment_value();
15
+ constexpr double decrement_value();
16
+ std::string to_string();
17
+ constexpr int to_integer();
18
+ constexpr double plus_equal(const double var);
19
+ constexpr double clear();
20
+ constexpr bool equal(const double var);
21
+ };
22
+
23
+ constexpr Float::Float() {}
24
+
25
+ Float::~Float() {}
26
+
27
+ constexpr double Float::assignment(const double var) {
28
+ return this->value = var;
29
+ }
30
+
31
+ constexpr double Float::return_value() {
32
+ return this->value;
33
+ }
34
+
35
+ constexpr double Float::increment_value() {
36
+ return this->value++;
37
+ }
38
+
39
+ constexpr double Float::decrement_value() {
40
+ return this->value--;
41
+ }
42
+
43
+ std::string Float::to_string() {
44
+
45
+ std::string null = "";
46
+
47
+ std::regex re("0+");
48
+
49
+ return std::regex_replace(std::to_string(this->value), re, null);
50
+ }
51
+
52
+ constexpr int Float::to_integer() {
53
+ return static_cast<int>(this->value);
54
+ }
55
+
56
+ constexpr double Float::plus_equal(const double var) {
57
+ return this->value += var;
58
+ }
59
+
60
+ constexpr double Float::clear() {
61
+ return this->value = 0.0;
62
+ }
63
+
64
+ constexpr bool Float::equal(const double var) {
65
+ return this->value == var;
66
+ }
67
+
68
+ #endif
@@ -0,0 +1,58 @@
1
+ #ifndef INTEGER_H_
2
+ #define INTEGER_H_
3
+
4
+ #include <string>
5
+
6
+ class Integer {
7
+ int value = 0;
8
+
9
+ public:
10
+ constexpr Integer();
11
+ ~Integer();
12
+ constexpr int assignment(const int var);
13
+ constexpr int return_value();
14
+ constexpr int increment_value();
15
+ constexpr int decrement_value();
16
+ std::string to_string();
17
+ constexpr int plus_equal(int var);
18
+ constexpr int clear();
19
+ constexpr bool equal(const int var);
20
+ };
21
+
22
+ constexpr Integer::Integer() {}
23
+
24
+ Integer::~Integer(){}
25
+
26
+ constexpr int Integer::assignment(const int var) {
27
+ return this->value = var;
28
+ }
29
+
30
+ constexpr int Integer::return_value() {
31
+ return this->value;
32
+ }
33
+
34
+ constexpr int Integer::increment_value() {
35
+ return this->value++;
36
+ }
37
+
38
+ constexpr int Integer::decrement_value() {
39
+ return this->value--;
40
+ }
41
+
42
+ std::string Integer::to_string() {
43
+ return std::to_string(this->value);
44
+ }
45
+
46
+ constexpr int Integer::plus_equal(int var) {
47
+ return this->value += var;
48
+ }
49
+
50
+ constexpr int Integer::clear() {
51
+ return this->value = 0;
52
+ }
53
+
54
+ constexpr bool Integer::equal(const int var) {
55
+ return this->value == var;
56
+ }
57
+
58
+ #endif
@@ -0,0 +1,32 @@
1
+ #ifndef MAP_H_
2
+ #define MAP_H_
3
+
4
+ #include <unordered_map>
5
+
6
+ template <class K, class V>
7
+ class Map {
8
+ std::unordered_map<K, V> container;
9
+ public:
10
+ constexpr Map();
11
+ ~Map();
12
+ constexpr V bracket(const K key);
13
+ constexpr V bracket_equal(const K key, const V value);
14
+ };
15
+
16
+ template <class K, class V>
17
+ constexpr Map<K, V>::Map() {}
18
+
19
+ template <class K, class V>
20
+ Map<K, V>::~Map() {}
21
+
22
+ template <class K, class V>
23
+ constexpr V Map<K, V>::bracket(const K key) {
24
+ return this->container[key];
25
+ }
26
+
27
+ template <class K, class V>
28
+ constexpr V Map<K, V>::bracket_equal(const K key, const V value) {
29
+ return this->container[key] = value;
30
+ }
31
+
32
+ #endif
@@ -0,0 +1,47 @@
1
+ #ifndef STRING_H_
2
+ #define STRING_H_
3
+
4
+ #include <string>
5
+
6
+ class CppString {
7
+ std::string value = "";
8
+ public:
9
+ CppString();
10
+ ~CppString();
11
+ std::string assignment(const std::string var);
12
+ std::string return_value();
13
+ int to_integer();
14
+ std::string plus_equal(const std::string var);
15
+ std::string clear();
16
+ bool equal(const std::string var);
17
+ };
18
+
19
+ CppString::CppString() {}
20
+
21
+ CppString::~CppString() {}
22
+
23
+ std::string CppString::assignment(const std::string var) {
24
+ return this->value = var;
25
+ }
26
+
27
+ std::string CppString::return_value() {
28
+ return this->value;
29
+ }
30
+
31
+ int CppString::to_integer() {
32
+ return std::stoi(this->value);
33
+ }
34
+
35
+ std::string CppString::plus_equal(const std::string var) {
36
+ return this->value += var;
37
+ }
38
+
39
+ std::string CppString::clear() {
40
+ return this->value = "";
41
+ }
42
+
43
+ bool CppString::equal(const std::string var) {
44
+ return this->value == var;
45
+ }
46
+
47
+ #endif
@@ -0,0 +1,127 @@
1
+ #include <string>
2
+ #include <rice/Data_Type.hpp>
3
+ #include <rice/Constructor.hpp>
4
+ #include "vector/vector.hpp"
5
+ #include "array/array.hpp"
6
+ #include "map/map.hpp"
7
+ #include "integer/integer.hpp"
8
+ #include "float/float.hpp"
9
+ #include "string/string.hpp"
10
+
11
+ using namespace Rice;
12
+
13
+ extern "C" {
14
+ void Init_tatara() {
15
+ Rice::Module rb_mTatara = define_module("Tatara");
16
+
17
+ Data_Type<Integer> rbcInteger = define_class_under<Integer>(rb_mTatara, "Integer")
18
+ .define_constructor(Constructor<Integer>())
19
+ .define_method("value", &Integer::return_value)
20
+ .define_method("value=", &Integer::assignment)
21
+ .define_method("value+=", &Integer::plus_equal)
22
+ .define_method("inc", &Integer::increment_value)
23
+ .define_method("dec", &Integer::decrement_value)
24
+ .define_method("to_s", &Integer::to_string)
25
+ .define_method("clear", &Integer::clear)
26
+ .define_method("value==", &Integer::equal);
27
+
28
+ Data_Type<Float> rbcFloat = define_class_under<Float>(rb_mTatara, "Float")
29
+ .define_constructor(Constructor<Float>())
30
+ .define_method("value", &Float::return_value)
31
+ .define_method("value=", &Float::assignment)
32
+ .define_method("value+=", &Float::plus_equal)
33
+ .define_method("inc", &Float::increment_value)
34
+ .define_method("dec", &Float::decrement_value)
35
+ .define_method("to_s", &Float::to_string)
36
+ .define_method("to_i", &Float::to_integer)
37
+ .define_method("clear", &Float::clear)
38
+ .define_method("value==", &Float::equal);
39
+
40
+ Data_Type<CppString> rbcString = define_class_under<CppString>(rb_mTatara, "String")
41
+ .define_constructor(Constructor<CppString>())
42
+ .define_method("value", &CppString::return_value)
43
+ .define_method("value=", &CppString::assignment)
44
+ .define_method("value+=", &CppString::plus_equal)
45
+ .define_method("to_i", &CppString::to_integer)
46
+ .define_method("clear", &CppString::clear)
47
+ .define_method("value==", &CppString::equal);
48
+
49
+ Data_Type<Vector<int>> rb_cIntVector = define_class_under<Vector<int>>(rb_mTatara, "IntVector")
50
+ .define_constructor(Constructor<Vector<int>>())
51
+ .define_method("first", &Vector<int>::first)
52
+ .define_method("last", &Vector<int>::last)
53
+ .define_method("[]", &Vector<int>::bracket)
54
+ .define_method("[]=", &Vector<int>::bracket_equal)
55
+ .define_method("emplace_back", &Vector<int>::emplace_back)
56
+ .define_method("size", &Vector<int>::size)
57
+ .define_method("clear", &Vector<int>::clear)
58
+ .define_method("sum", &Vector<int>::sum);
59
+
60
+ Data_Type<Vector<double>> rb_cFloatVector = define_class_under<Vector<double>>(rb_mTatara, "FloatVector")
61
+ .define_constructor(Constructor<Vector<double>>())
62
+ .define_method("first", &Vector<double>::first)
63
+ .define_method("last", &Vector<double>::last)
64
+ .define_method("[]", &Vector<double>::bracket)
65
+ .define_method("[]=", &Vector<double>::bracket_equal)
66
+ .define_method("emplace_back", &Vector<double>::emplace_back)
67
+ .define_method("size", &Vector<double>::size)
68
+ .define_method("clear", &Vector<double>::clear)
69
+ .define_method("sum", &Vector<double>::sum);
70
+
71
+ Data_Type<Vector<std::string>> rb_cStringVector = define_class_under<Vector<std::string>>(rb_mTatara, "StringVector")
72
+ .define_constructor(Constructor<Vector<std::string>>())
73
+ .define_method("first", &Vector<std::string>::first)
74
+ .define_method("last", &Vector<std::string>::last)
75
+ .define_method("[]", &Vector<std::string>::bracket)
76
+ .define_method("[]=", &Vector<std::string>::bracket_equal)
77
+ .define_method("emplace_back", & Vector<std::string>::emplace_back)
78
+ .define_method("size", &Vector<std::string>::size)
79
+ .define_method("clear", &Vector<std::string>::clear)
80
+ .define_method("sum", &Vector<std::string>::sum);
81
+
82
+ Data_Type<CppArray<int>> rb_cIntArray = define_class_under<CppArray<int>>(rb_mTatara, "IntArray")
83
+ .define_constructor(Constructor<CppArray<int>>())
84
+ .define_method("first", &CppArray<int>::first)
85
+ .define_method("last", &CppArray<int>::last)
86
+ .define_method("[]", &CppArray<int>::bracket)
87
+ .define_method("[]=", &CppArray<int>::bracket_equal)
88
+ .define_method("push", &CppArray<int>::emplace_back)
89
+ .define_method("size", &CppArray<int>::size)
90
+ .define_method("clear", &CppArray<int>::clear);
91
+
92
+ Data_Type<CppArray<double>> rb_cFloatArray = define_class_under<CppArray<double>>(rb_mTatara, "FloatArray")
93
+ .define_constructor(Constructor<CppArray<double>>())
94
+ .define_method("first", &CppArray<double>::first)
95
+ .define_method("last", &CppArray<double>::last)
96
+ .define_method("[]", &CppArray<double>::bracket)
97
+ .define_method("[]=", &CppArray<double>::bracket_equal)
98
+ .define_method("push", &CppArray<double>::emplace_back)
99
+ .define_method("size", &CppArray<double>::size)
100
+ .define_method("clear", &CppArray<double>::clear);
101
+
102
+ Data_Type<CppArray<std::string>> rb_cStringArray = define_class_under<CppArray<std::string>>(rb_mTatara, "StringArray")
103
+ .define_constructor(Constructor<CppArray<std::string>>())
104
+ .define_method("first", &CppArray<std::string>::first)
105
+ .define_method("last", &CppArray<std::string>::last)
106
+ .define_method("[]", &CppArray<std::string>::bracket)
107
+ .define_method("[]=", &CppArray<std::string>::bracket_equal)
108
+ .define_method("push", &CppArray<std::string>::emplace_back)
109
+ .define_method("size", &CppArray<std::string>::size)
110
+ .define_method("clear", &CppArray<std::string>::clear);
111
+
112
+ Data_Type<Map<std::string, int>> rb_cStringIntMap = define_class_under<Map<std::string, int>>(rb_mTatara, "StringIntMap")
113
+ .define_constructor(Constructor<Map<std::string, int>>())
114
+ .define_method("[]", &Map<std::string, int>::bracket)
115
+ .define_method("[]=", &Map<std::string, int>::bracket_equal);
116
+
117
+ Data_Type<Map<std::string, double>> rb_cStringFloatMap = define_class_under<Map<std::string, double>>(rb_mTatara, "StringFloatMap")
118
+ .define_constructor(Constructor<Map<std::string, double>>())
119
+ .define_method("[]", &Map<std::string, double>::bracket)
120
+ .define_method("[]=", &Map<std::string, double>::bracket_equal);
121
+
122
+ Data_Type<Map<std::string, std::string>> rb_cStringStringMap = define_class_under<Map<std::string, std::string>>(rb_mTatara, "StringStringMap")
123
+ .define_constructor(Constructor<Map<std::string, std::string>>())
124
+ .define_method("[]", &Map<std::string, std::string>::bracket)
125
+ .define_method("[]=", &Map<std::string, std::string>::bracket_equal);
126
+ }
127
+ }
@@ -0,0 +1,74 @@
1
+ #ifndef VEC_TEMPLATE_H_
2
+ #define VEC_TEMPLATE_H_
3
+
4
+ #include <vector>
5
+
6
+ template <class T>
7
+ class Vector {
8
+ std::vector<T> container;
9
+
10
+ public:
11
+ constexpr Vector();
12
+ ~Vector();
13
+ constexpr T first();
14
+ constexpr T last();
15
+ constexpr T bracket(const int index);
16
+ constexpr T bracket_equal(const int index, const T var);
17
+ constexpr void emplace_back(const T var);
18
+ constexpr int size();
19
+ constexpr void clear();
20
+ T sum();
21
+ };
22
+
23
+ template <class T>
24
+ constexpr Vector<T>::Vector() {}
25
+
26
+ template <class T>
27
+ Vector<T>::~Vector() {}
28
+
29
+ template <class T>
30
+ constexpr T Vector<T>::first() {
31
+ return this->container.front();
32
+ }
33
+
34
+ template <class T>
35
+ constexpr T Vector<T>::last() {
36
+ return this->container.back();
37
+ }
38
+
39
+ template <class T>
40
+ constexpr T Vector<T>::bracket(const int index) {
41
+ return this->container[index];
42
+ }
43
+
44
+ template <class T>
45
+ constexpr T Vector<T>::bracket_equal(const int index, const T var) {
46
+ return this->container[index] = var;
47
+ }
48
+
49
+ template <class T>
50
+ constexpr void Vector<T>::emplace_back(const T var) {
51
+ this->container.emplace_back(std::move(var));
52
+ }
53
+
54
+ template <class T>
55
+ constexpr int Vector<T>::size() {
56
+ return this->container.size();
57
+ }
58
+
59
+ template <class T>
60
+ constexpr void Vector<T>::clear() {
61
+ this->container.clear();
62
+ }
63
+
64
+ template <class T>
65
+ T Vector<T>::sum() {
66
+ T sum;
67
+
68
+ for (auto&& c : this->container)
69
+ sum += c;
70
+
71
+ return sum;
72
+ }
73
+
74
+ #endif
@@ -0,0 +1,6 @@
1
+ require "tatara/version"
2
+
3
+ module Tatara
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,3 @@
1
+ module Tatara
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "tatara/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tatara"
8
+ spec.version = Tatara::VERSION
9
+ spec.authors = ["S-H-GAMELINKS"]
10
+ spec.email = ["gamelinks007@gmail.com"]
11
+
12
+ spec.summary = %q{Simple type declaration lib}
13
+ spec.description = %q{Simple type declaration lib}
14
+ spec.homepage = "https://github.com/S-H-GAMELINKS/tatara"
15
+ spec.extensions = %w[ext/tatara/extconf.rb]
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ #
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "https://github.com/S-H-GAMELINKS/tatara"
24
+ # spec.metadata["changelog_uri"] = "https://github.com/S-H-GAMELINKS/tatara"
25
+ #else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ #end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "minitest", "~> 5.0"
42
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tatara
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - S-H-GAMELINKS
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Simple type declaration lib
56
+ email:
57
+ - gamelinks007@gmail.com
58
+ executables: []
59
+ extensions:
60
+ - ext/tatara/extconf.rb
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE
68
+ - Makefile
69
+ - README.md
70
+ - Rakefile
71
+ - benchmark/benchmark.rb
72
+ - bin/console
73
+ - bin/setup
74
+ - ext/tatara/array/array.hpp
75
+ - ext/tatara/extconf.rb
76
+ - ext/tatara/float/float.hpp
77
+ - ext/tatara/integer/integer.hpp
78
+ - ext/tatara/map/map.hpp
79
+ - ext/tatara/string/string.hpp
80
+ - ext/tatara/tatara.cpp
81
+ - ext/tatara/vector/vector.hpp
82
+ - lib/tatara.rb
83
+ - lib/tatara/version.rb
84
+ - tatara.gemspec
85
+ homepage: https://github.com/S-H-GAMELINKS/tatara
86
+ licenses: []
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.0.4
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Simple type declaration lib
107
+ test_files: []