old_string_hash 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/old_string_hash/extconf.rb +5 -0
- data/ext/old_string_hash/old_string_hash.c +33 -0
- metadata +58 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
// Include the Ruby headers and goodies
|
2
|
+
#include <ruby.h>
|
3
|
+
#include <stdio.h>
|
4
|
+
|
5
|
+
// Defining a space for information and references about the module to be stored internally
|
6
|
+
VALUE OldStringHash = Qnil;
|
7
|
+
|
8
|
+
// Prototype for the initialization method - Ruby calls this, not you
|
9
|
+
void Init_old_string_hash();
|
10
|
+
|
11
|
+
// Prototype for our method 'hash_code' - methods are prefixed by 'method_' here
|
12
|
+
VALUE method_hash_code(VALUE self, VALUE str);
|
13
|
+
|
14
|
+
// The initialization method for this module
|
15
|
+
void Init_old_string_hash() {
|
16
|
+
printf("here");
|
17
|
+
OldStringHash = rb_define_module("OldStringHash");
|
18
|
+
rb_define_method(OldStringHash, "hash_code", method_hash_code, 1);
|
19
|
+
}
|
20
|
+
|
21
|
+
// Our 'test1' method.. it simply returns a value of '10' for now.
|
22
|
+
VALUE method_hash_code(VALUE self, VALUE str) {
|
23
|
+
register int key = 0;
|
24
|
+
register long len = RSTRING_LEN(str);
|
25
|
+
register char *p = RSTRING_PTR(str);
|
26
|
+
|
27
|
+
while (len--) {
|
28
|
+
key = key*65599 + *p;
|
29
|
+
p++;
|
30
|
+
}
|
31
|
+
key = key + (key>>5);
|
32
|
+
return INT2FIX(key);
|
33
|
+
}
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: old_string_hash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Surendra Singhi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake-compiler
|
16
|
+
requirement: &70309496626400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70309496626400
|
25
|
+
description:
|
26
|
+
email:
|
27
|
+
executables: []
|
28
|
+
extensions:
|
29
|
+
- ext/old_string_hash/extconf.rb
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- ext/old_string_hash/old_string_hash.c
|
33
|
+
- ext/old_string_hash/extconf.rb
|
34
|
+
homepage:
|
35
|
+
licenses: []
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.17
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Old Ruby String hash
|
58
|
+
test_files: []
|