varint_pb 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2db03a7c2b35702188cb2e4fc0c79bf50a2c0c11
4
+ data.tar.gz: d083f77cf39abcaf99398bd8410cc132f905b6ef
5
+ SHA512:
6
+ metadata.gz: 05960bf253789a39b1281e5a61c5882cd7544a04d5942d10351063c789597ae1bfe76802f7e70c7e2a16d8a6665098efb05038aa0d435e9cf41faf126153fb33
7
+ data.tar.gz: 85f8bfa8d8a03b67182e0b3f7781b3bd962082f67769142b7ae6ea8a19bf17f9f4188abb1c951c4cca4336a40a65cc74dc2ef6959151e04a5215a9ce55ce54d9
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rvmrc
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in varint.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2009, Decho Corporation
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of Decho Corporation nor the names of its contributors
12
+ may be used to endorse or promote products derived from this software
13
+ without specific prior written permission.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Varint
2
+
3
+ A small C extension to speed up varint in protocol buffers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'varint'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install varint
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir['tasks/**/*.rake'].each { |t| load t }
4
+
5
+ task :default => [:spec]
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+
3
+ create_makefile "varint_pb/varint_pb"
@@ -0,0 +1,61 @@
1
+ #include "ruby.h"
2
+
3
+ static VALUE VarintPB;
4
+ static ID getbyte, putbyte;
5
+
6
+ static
7
+ VALUE varint_pb_encode(VALUE module, VALUE io, VALUE int_valV)
8
+ {
9
+ /* unsigned for the bit shifting ops */
10
+ unsigned long long int_val = (unsigned long long)NUM2LL(int_valV);
11
+ unsigned char byte;
12
+ while (1)
13
+ {
14
+ byte = int_val & 0x7f;
15
+ int_val >>= 7;
16
+ if (int_val == 0)
17
+ {
18
+ rb_funcall(io, putbyte, 1, INT2FIX(byte));
19
+ return Qnil;
20
+ }
21
+ else
22
+ {
23
+ rb_funcall(io, putbyte, 1, INT2FIX(byte | 0x80));
24
+ }
25
+ }
26
+ }
27
+
28
+ static
29
+ VALUE varint_pb_decode(VALUE module, VALUE io)
30
+ {
31
+ unsigned long long int_val = 0;
32
+ unsigned shift = 0;
33
+ unsigned char byte;
34
+
35
+ while (1)
36
+ {
37
+ if (shift >= 64)
38
+ {
39
+ rb_raise(rb_eArgError, "too many bytes when decoding varint");
40
+ }
41
+ byte = (unsigned char)FIX2INT(rb_funcall(io, getbyte, 0));
42
+ int_val |= ((unsigned long long)(byte & 0x7f)) << shift;
43
+ shift += 7;
44
+ if ((byte & 0x80) == 0)
45
+ {
46
+ /* return ULL2NUM(int_val); */
47
+ return LL2NUM((long long)int_val);
48
+ }
49
+ }
50
+ }
51
+
52
+ void Init_varint_pb()
53
+ {
54
+ VarintPB = rb_define_module("VarintPB");
55
+
56
+ getbyte = rb_intern("getbyte");
57
+ putbyte = rb_intern("putc");
58
+
59
+ rb_define_method(VarintPB, "encode", varint_pb_encode, 2);
60
+ rb_define_method(VarintPB, "decode", varint_pb_decode, 1);
61
+ }
@@ -0,0 +1,3 @@
1
+ module VarintPB
2
+ VERSION = "0.1.0"
3
+ end
data/lib/varint_pb.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'varint_pb/version'
2
+
3
+ module VarintPB
4
+
5
+ end
data/varint_pb.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'varint_pb'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "varint_pb"
8
+ gem.version = VarintPB::VERSION
9
+ gem.authors = ["Brian Palmer", "Benedikt Boehm", "Rob Marable", "Paulo Luis Franchini Casaretto", "Vaibhav Yenamandra"]
10
+ gem.email = ["brian@codekitchen.net", "bb@xnull.de", ""]
11
+ gem.summary = %q{Fork of varint C extension by https://github.com/liquidm/varint}
12
+ gem.homepage = "https://github.com/vaibhav-y/varint"
13
+ gem.license = "BSD"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.extensions = ["ext/varint_pb/extconf.rb"]
21
+
22
+ gem.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: varint_pb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Palmer
8
+ - Benedikt Boehm
9
+ - Rob Marable
10
+ - Paulo Luis Franchini Casaretto
11
+ - Vaibhav Yenamandra
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2014-11-15 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rake
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ description:
32
+ email:
33
+ - brian@codekitchen.net
34
+ - bb@xnull.de
35
+ - ''
36
+ executables: []
37
+ extensions:
38
+ - ext/varint_pb/extconf.rb
39
+ extra_rdoc_files: []
40
+ files:
41
+ - .gitignore
42
+ - Gemfile
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - ext/varint_pb/extconf.rb
47
+ - ext/varint_pb/varint_pb.c
48
+ - lib/varint_pb.rb
49
+ - lib/varint_pb/version.rb
50
+ - varint_pb.gemspec
51
+ homepage: https://github.com/vaibhav-y/varint
52
+ licenses:
53
+ - BSD
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.0.14
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Fork of varint C extension by https://github.com/liquidm/varint
75
+ test_files: []
76
+ has_rdoc: