xot 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +0 -0
- data/README +0 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/include/xot/defs.h +37 -0
- data/include/xot/string.h +28 -0
- data/include/xot.h +11 -0
- data/lib/xot/module.rb +38 -0
- data/lib/xot/rake/helpers.rb +69 -0
- data/src/string.cpp +76 -0
- data/task/gem.rake +45 -0
- data/task/git.rake +27 -0
- data/task/lib.rake +94 -0
- data/xot.gemspec +53 -0
- metadata +88 -0
data/ChangeLog
ADDED
File without changes
|
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
%w[.].map {|s| "#{s}/lib"}.each do |path|
|
5
|
+
$: << File.expand_path(File.join File.dirname(__FILE__), *path.split('/'))
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'xot/rake/helpers'
|
10
|
+
require 'xot/module'
|
11
|
+
|
12
|
+
include Xot::Rake
|
13
|
+
|
14
|
+
|
15
|
+
MODULE = Xot
|
16
|
+
|
17
|
+
|
18
|
+
task :default => :build
|
19
|
+
|
20
|
+
task :build => :lib
|
21
|
+
|
22
|
+
task :rebuild => [:clean, :build]
|
23
|
+
|
24
|
+
task :lib => 'lib:build'
|
25
|
+
|
26
|
+
task :doc => 'ext:doc'
|
27
|
+
|
28
|
+
task :gem => 'gem:build'
|
29
|
+
|
30
|
+
task :install => 'gem:install'
|
31
|
+
|
32
|
+
task :uninstall => 'gem:uninstall'
|
33
|
+
|
34
|
+
task :clean => ['lib:clean', 'gem:clean']
|
35
|
+
|
36
|
+
|
37
|
+
Xot.load_tasks
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.3
|
data/include/xot/defs.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __XOT_DEFS_H__
|
4
|
+
#define __XOT_DEFS_H__
|
5
|
+
|
6
|
+
|
7
|
+
namespace Xot
|
8
|
+
{
|
9
|
+
|
10
|
+
|
11
|
+
namespace Types
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
typedef unsigned char uchar;
|
16
|
+
|
17
|
+
typedef unsigned short ushort;
|
18
|
+
|
19
|
+
typedef unsigned int uint;
|
20
|
+
|
21
|
+
typedef unsigned long ulong;
|
22
|
+
|
23
|
+
typedef long long longlong;
|
24
|
+
|
25
|
+
typedef unsigned long long ulonglong;
|
26
|
+
|
27
|
+
|
28
|
+
}// Types
|
29
|
+
|
30
|
+
|
31
|
+
enum {UNKNOWN = 0};
|
32
|
+
|
33
|
+
|
34
|
+
}// Xot
|
35
|
+
|
36
|
+
|
37
|
+
#endif//EOH
|
@@ -0,0 +1,28 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __XOT_STRING_H__
|
4
|
+
#define __XOT_STRING_H__
|
5
|
+
|
6
|
+
|
7
|
+
#include <stdarg.h>
|
8
|
+
#include <string>
|
9
|
+
|
10
|
+
|
11
|
+
namespace Xot
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
typedef std::string String;
|
16
|
+
|
17
|
+
|
18
|
+
String stringf (const char* format, ...);
|
19
|
+
|
20
|
+
String stringf (const char* format, va_list args);
|
21
|
+
|
22
|
+
template <typename T> String to_s (const T& val);
|
23
|
+
|
24
|
+
|
25
|
+
}// Xot
|
26
|
+
|
27
|
+
|
28
|
+
#endif//EOH
|
data/include/xot.h
ADDED
data/lib/xot/module.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
module Xot
|
5
|
+
|
6
|
+
|
7
|
+
extend module ClassMethods
|
8
|
+
|
9
|
+
def root_dir ()
|
10
|
+
File.expand_path(File.join File.dirname(__FILE__), '..', '..')
|
11
|
+
end
|
12
|
+
|
13
|
+
def include_dirs ()
|
14
|
+
[File.join(root_dir, 'include')]
|
15
|
+
end
|
16
|
+
|
17
|
+
def library_dirs ()
|
18
|
+
%w[lib].map {|dir| File.join root_dir, dir}
|
19
|
+
end
|
20
|
+
|
21
|
+
def task_dir ()
|
22
|
+
File.join root_dir, 'task'
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_tasks ()
|
26
|
+
Dir["#{task_dir}/**/*.rake"].each {|path| load path}
|
27
|
+
end
|
28
|
+
|
29
|
+
def version ()
|
30
|
+
open(File.join root_dir, 'VERSION') {|f| f.readline.chomp}
|
31
|
+
end
|
32
|
+
|
33
|
+
self
|
34
|
+
|
35
|
+
end# ClassMethods
|
36
|
+
|
37
|
+
|
38
|
+
end# Xot
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'erb'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
|
8
|
+
module Xot
|
9
|
+
|
10
|
+
|
11
|
+
module Rake
|
12
|
+
|
13
|
+
|
14
|
+
def glob (*patterns)
|
15
|
+
paths = []
|
16
|
+
patterns.each do |pattern|
|
17
|
+
paths.concat Dir.glob(pattern)
|
18
|
+
end
|
19
|
+
paths
|
20
|
+
end
|
21
|
+
|
22
|
+
def erb (str)
|
23
|
+
ERB.new(str, nil, "%").result binding
|
24
|
+
end
|
25
|
+
|
26
|
+
def compile (path, out)
|
27
|
+
open(path) do |input|
|
28
|
+
open(out, "w") do |output|
|
29
|
+
output.write erb(input.read)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
#rescue
|
33
|
+
end
|
34
|
+
|
35
|
+
def params (n, sep = "", &block)
|
36
|
+
raise "block not given." unless block
|
37
|
+
return "" if n == 0
|
38
|
+
(1..n).map(&block).join(sep)
|
39
|
+
end
|
40
|
+
|
41
|
+
def convertions (paths, convs)
|
42
|
+
raise "empty conversion." if convs.empty?
|
43
|
+
paths = paths.map do |path|
|
44
|
+
convpath = path
|
45
|
+
convs.each do |from, to|
|
46
|
+
convpath = convpath.sub(/#{from.gsub('.', '\.')}$/, to)
|
47
|
+
end
|
48
|
+
[path, convpath]
|
49
|
+
end
|
50
|
+
Hash[*paths.flatten]
|
51
|
+
end
|
52
|
+
|
53
|
+
def env (name, defval = nil)
|
54
|
+
Object.const_get(name) rescue ENV[name.to_s] || defval
|
55
|
+
end
|
56
|
+
|
57
|
+
def win32? ()
|
58
|
+
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
59
|
+
end
|
60
|
+
|
61
|
+
def cocoa? ()
|
62
|
+
RUBY_PLATFORM =~ /darwin/
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end# Rake
|
67
|
+
|
68
|
+
|
69
|
+
end# Xot
|
data/src/string.cpp
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#include "xot/string.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <stdio.h>
|
5
|
+
#include <boost/scoped_array.hpp>
|
6
|
+
|
7
|
+
|
8
|
+
namespace Xot
|
9
|
+
{
|
10
|
+
|
11
|
+
|
12
|
+
String
|
13
|
+
stringf (const char* format, ...)
|
14
|
+
{
|
15
|
+
va_list args;
|
16
|
+
va_start(args, format);
|
17
|
+
String ret = stringf(format, args);
|
18
|
+
va_end(args);
|
19
|
+
return ret;
|
20
|
+
}
|
21
|
+
|
22
|
+
String
|
23
|
+
stringf (const char* format, va_list args)
|
24
|
+
{
|
25
|
+
enum {BUFSIZE = 256};
|
26
|
+
char stack[BUFSIZE];
|
27
|
+
if (vsnprintf(&stack[0], BUFSIZE, format, args) <= BUFSIZE)
|
28
|
+
return &stack[0];
|
29
|
+
|
30
|
+
int bufsize = BUFSIZE;// vscprintf(format, args);
|
31
|
+
boost::scoped_array<char> heap;
|
32
|
+
while (true)
|
33
|
+
{
|
34
|
+
bufsize *= 2;
|
35
|
+
heap.reset(new char[bufsize]);
|
36
|
+
if (vsnprintf(&heap[0], bufsize, format, args) <= bufsize)
|
37
|
+
return &heap[0];
|
38
|
+
}
|
39
|
+
|
40
|
+
return NULL;
|
41
|
+
}
|
42
|
+
|
43
|
+
template <> String
|
44
|
+
to_s<int> (const int& val)
|
45
|
+
{
|
46
|
+
return stringf("%d", val);
|
47
|
+
}
|
48
|
+
|
49
|
+
template <> String
|
50
|
+
to_s<float> (const float& val)
|
51
|
+
{
|
52
|
+
return stringf("%f", val);
|
53
|
+
}
|
54
|
+
|
55
|
+
template <> String
|
56
|
+
to_s<double> (const double& val)
|
57
|
+
{
|
58
|
+
return stringf("%f", val);
|
59
|
+
}
|
60
|
+
|
61
|
+
typedef const char* const_char_p;
|
62
|
+
|
63
|
+
template <> String
|
64
|
+
to_s<const_char_p> (const const_char_p& val)
|
65
|
+
{
|
66
|
+
return val;
|
67
|
+
}
|
68
|
+
|
69
|
+
template <> String
|
70
|
+
to_s<String> (const String& val)
|
71
|
+
{
|
72
|
+
return val;
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
}// Xot
|
data/task/gem.rake
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
namespace :ext do
|
5
|
+
task :rdoc => "ext"
|
6
|
+
directory "ext"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
namespace :gem do
|
11
|
+
|
12
|
+
|
13
|
+
mod = MODULE
|
14
|
+
name = env :NAME, MODULE.name.downcase
|
15
|
+
gem = env :GEM, 'gem'
|
16
|
+
|
17
|
+
gemspec = "#{name}.gemspec"
|
18
|
+
gemname = env :GEMNAME, name
|
19
|
+
gemfile = "#{gemname}-#{mod.version}.gem"
|
20
|
+
|
21
|
+
|
22
|
+
task :build => gemfile
|
23
|
+
|
24
|
+
task :install => gemfile do
|
25
|
+
sh %( #{gem} install #{gemfile} )
|
26
|
+
end
|
27
|
+
|
28
|
+
task :uninstall do
|
29
|
+
sh %( #{gem} uninstall #{name} )
|
30
|
+
end
|
31
|
+
|
32
|
+
task :clean do
|
33
|
+
sh %( rm -f #{gemfile} )
|
34
|
+
end
|
35
|
+
|
36
|
+
task :upload => gemfile do
|
37
|
+
sh %( #{gem} push #{gemfile} )
|
38
|
+
end
|
39
|
+
|
40
|
+
file gemfile => ["lib:build", "ext:rdoc"] do
|
41
|
+
sh %( #{gem} build #{gemspec} )
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end# :gem
|
data/task/git.rake
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
namespace :git do
|
5
|
+
|
6
|
+
|
7
|
+
git = env :GIT, 'git'
|
8
|
+
|
9
|
+
|
10
|
+
task :status do
|
11
|
+
sh %( #{git} status )
|
12
|
+
end
|
13
|
+
|
14
|
+
task :diff do
|
15
|
+
sh %( #{git} diff | cat )
|
16
|
+
end
|
17
|
+
|
18
|
+
task :push do
|
19
|
+
sh %( #{git} push )
|
20
|
+
end
|
21
|
+
|
22
|
+
task :pull do
|
23
|
+
sh %( #{git} pull )
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end# :git
|
data/task/lib.rake
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'rake/loaders/makefile'
|
6
|
+
|
7
|
+
|
8
|
+
namespace :lib do
|
9
|
+
|
10
|
+
|
11
|
+
rbconf = RbConfig::CONFIG
|
12
|
+
|
13
|
+
mod = MODULE
|
14
|
+
name = env :NAME, MODULE.name.downcase
|
15
|
+
incdir = env :INCDIR, 'include'
|
16
|
+
srcdir = env :SRCDIR, 'src'
|
17
|
+
libdir = env :LIBDIR, 'lib'
|
18
|
+
cc = env :CC, rbconf['CC'] || 'g++'
|
19
|
+
ar = env :AR, 'ar'
|
20
|
+
defs = env :DEFS, []
|
21
|
+
incdirs = env(:INCDIRS) ? env(:INCDIRS) : []
|
22
|
+
cflags = env(:CFLAGS, '-Wall -O -g').dup
|
23
|
+
arflags = env(:ARFLAGS, 'crs').dup
|
24
|
+
|
25
|
+
outname = "lib#{name}.a"
|
26
|
+
out = File.join libdir, outname
|
27
|
+
|
28
|
+
rbs = glob '**/*.rb'
|
29
|
+
erbs = convertions glob("**/*.erb"), {".erb" => ""}
|
30
|
+
headers = glob("include/**/*.h") | erbs.values.grep(/\.h$/)
|
31
|
+
srcs = glob("src/**/*.cpp") | erbs.values.grep(/\.cpp$/)
|
32
|
+
srcs += glob("src/**/*.mm") if cocoa?
|
33
|
+
srcs = srcs.reject {|s| s =~ %r(/win32/)} unless win32?
|
34
|
+
srcs = srcs.reject {|s| s =~ %r(/cocoa/)} unless cocoa?
|
35
|
+
|
36
|
+
incroot = rbconf['rubyhdrdir']
|
37
|
+
incdirs.concat Xot.include_dirs + [
|
38
|
+
incroot,
|
39
|
+
"#{incroot}/#{RUBY_PLATFORM}",
|
40
|
+
'/opt/local/include',
|
41
|
+
'/opt/include'
|
42
|
+
]
|
43
|
+
incdirs.uniq!
|
44
|
+
|
45
|
+
defs << 'WIN32' if win32?
|
46
|
+
defs << 'COCOA' if cocoa?
|
47
|
+
cflags << defs.map{|s| " -D#{s}"}.join
|
48
|
+
cflags << incdirs.map{|s| " -I#{s}"}.join
|
49
|
+
|
50
|
+
depend = 'depend.mf'
|
51
|
+
objs = convertions srcs, {".cpp" => ".o", ".mm" => ".o"}
|
52
|
+
tmps = (objs.values | erbs.values) + [depend]
|
53
|
+
|
54
|
+
|
55
|
+
task :build => out
|
56
|
+
|
57
|
+
task :compile => objs.values
|
58
|
+
|
59
|
+
task :erb => erbs.values
|
60
|
+
|
61
|
+
task :clean do
|
62
|
+
sh %( rm -rf #{tmps.join " "} #{out} )
|
63
|
+
end
|
64
|
+
|
65
|
+
file out => objs.values do
|
66
|
+
sh %( #{ar} #{arflags} #{out} #{objs.values.join " "} )
|
67
|
+
end
|
68
|
+
|
69
|
+
file depend => erbs.values do
|
70
|
+
sh %( #{cc} -M #{cflags} #{srcs.join ' '} > #{depend} )
|
71
|
+
input = open(depend) {|f| f.read}
|
72
|
+
open(depend, 'w') do |output|
|
73
|
+
output << input.gsub(/\w+\.o/, srcdir + '/\0')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
import depend if File.exist? depend
|
78
|
+
|
79
|
+
objs.each do |(src, obj)|
|
80
|
+
file obj => [depend, src] + erbs.values do
|
81
|
+
sh %( #{cc} -c #{cflags} -o #{obj} #{src} )
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
erbs.each do |(erb, out)|
|
86
|
+
file out => [erb] + rbs do
|
87
|
+
print "#{erb}: compiling to #{out}..."
|
88
|
+
compile erb, out
|
89
|
+
puts "ok"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end# :lib
|
data/xot.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
$: << File.join(File.dirname(__FILE__), 'lib')
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'xot/module'
|
8
|
+
|
9
|
+
|
10
|
+
MODULE = Xot
|
11
|
+
NAME = MODULE.name.downcase
|
12
|
+
|
13
|
+
|
14
|
+
FILES = FileList[*%W[
|
15
|
+
README
|
16
|
+
ChangeLog
|
17
|
+
Rakefile
|
18
|
+
#{NAME}.gemspec
|
19
|
+
VERSION
|
20
|
+
task/**/*.rake
|
21
|
+
include/**/*.h
|
22
|
+
lib/**/*.rb
|
23
|
+
src/**/*.h
|
24
|
+
src/**/*.cpp
|
25
|
+
]]
|
26
|
+
|
27
|
+
RDOCS = FileList[*%W[
|
28
|
+
README
|
29
|
+
]]
|
30
|
+
|
31
|
+
|
32
|
+
Gem::Specification.new do |s|
|
33
|
+
s.name = NAME
|
34
|
+
s.summary = 'A Utility library for C++ developemt.'
|
35
|
+
s.description = 'This library include some useful utility classes and functions for development with C++.'
|
36
|
+
s.version = MODULE.version
|
37
|
+
|
38
|
+
s.authors = %w[snori]
|
39
|
+
s.email = 'snori@xord.org'
|
40
|
+
s.homepage = "http://github.com/xord/#{NAME}"
|
41
|
+
|
42
|
+
s.platform = Gem::Platform::RUBY
|
43
|
+
|
44
|
+
s.add_development_dependency 'rake'
|
45
|
+
s.add_development_dependency 'gemcutter'
|
46
|
+
|
47
|
+
s.files = FILES.to_a
|
48
|
+
|
49
|
+
s.has_rdoc = true
|
50
|
+
s.extra_rdoc_files = RDOCS.to_a
|
51
|
+
|
52
|
+
s.extensions << 'Rakefile'
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.3
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- snori
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-19 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: gemcutter
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
description: This library include some useful utility classes and functions for development with C++.
|
38
|
+
email: snori@xord.org
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions:
|
42
|
+
- Rakefile
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README
|
45
|
+
files:
|
46
|
+
- README
|
47
|
+
- ChangeLog
|
48
|
+
- Rakefile
|
49
|
+
- xot.gemspec
|
50
|
+
- VERSION
|
51
|
+
- task/gem.rake
|
52
|
+
- task/git.rake
|
53
|
+
- task/lib.rake
|
54
|
+
- include/xot/defs.h
|
55
|
+
- include/xot/string.h
|
56
|
+
- include/xot.h
|
57
|
+
- lib/xot/module.rb
|
58
|
+
- lib/xot/rake/helpers.rb
|
59
|
+
- src/string.cpp
|
60
|
+
homepage: http://github.com/xord/xot
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: A Utility library for C++ developemt.
|
87
|
+
test_files: []
|
88
|
+
|