Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

Commit

Permalink
ext gem conf
Browse files Browse the repository at this point in the history
  • Loading branch information
cice committed Feb 20, 2011
1 parent 43b48a9 commit 6af6251
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 225 deletions.
4 changes: 4 additions & 0 deletions ext/.gitignore
@@ -0,0 +1,4 @@
Makefile
.bundle
.o
.so
157 changes: 0 additions & 157 deletions ext/Makefile

This file was deleted.

20 changes: 0 additions & 20 deletions ext/conftest.dSYM/Contents/Info.plist

This file was deleted.

Binary file removed ext/conftest.dSYM/Contents/Resources/DWARF/conftest
Binary file not shown.
39 changes: 0 additions & 39 deletions ext/extconf.rb
Expand Up @@ -4,46 +4,7 @@
extension_name = 'ruby_cpickle'
dir_config extension_name

LIBDIR = Config::CONFIG['libdir']
INCLUDEDIR = Config::CONFIG['includedir']

HEADER_DIRS = [
# First search /opt/local for macports
'/opt/local/include',

# Then search /usr/local for people that installed from source
'/usr/local/include',

# Check the ruby install locations
INCLUDEDIR,

# Finally fall back to /usr
'/usr/include',
'/usr/include/libxml2',
]

LIB_DIRS = [
# First search /opt/local for macports
'/opt/local/lib',

# Then search /usr/local for people that installed from source
'/usr/local/lib',

# Check the ruby install locations
LIBDIR,

# Finally fall back to /usr
'/usr/lib',
]

XML2_HEADER_DIRS = [
'/opt/local/include/libxml2',
'/usr/local/include/libxml2',
File.join(INCLUDEDIR, "libxml2")
] + HEADER_DIRS

dir_config('iconv', HEADER_DIRS, LIB_DIRS)
have_func('iconv_open', 'iconv.h') or have_library('iconv', 'iconv_open', 'iconv.h')

create_makefile extension_name

Binary file removed ext/ruby_cpickle.bundle
Binary file not shown.
14 changes: 7 additions & 7 deletions ext/ruby_cpickle.c
Expand Up @@ -2,22 +2,24 @@
#include <ruby.h>
#include <stdio.h>
#include "util.h"
#include <iconv.h>

// Array to hold function pointers to all operations
static void(*dispatch[256])(VirtualMachine*, VALUE) = {};

// Hold a global Marker
static VALUE Marker;

static iconv_t iconv_cd;

uchar read_one(VALUE stream) {
VALUE byte = rb_funcall(stream, meth_read, 0);

return NUM2CHR(byte);
}

VALUE pack_to_utf8(VALUE ary) {
VALUE unicode = rb_str_new2("U*");
return rb_funcall(ary, meth_pack, 1, unicode);
}

VALUE read_to_nl(VALUE stream) {
VALUE string = rb_ary_new();

Expand All @@ -28,7 +30,7 @@ VALUE read_to_nl(VALUE stream) {
buf = read_one(stream);
}

string = rb_funcall(string, meth_pack, 1, rb_str_new2("U*"));
string = pack_to_utf8(string);
return string;
}

Expand Down Expand Up @@ -153,7 +155,6 @@ static void dispatcher(VirtualMachine *vm, uchar op_code, VALUE stream) {
}

static VALUE reader(VALUE self) {
iconv_cd = iconv_open("UTF-8", "UTF-16");
VALUE stream = rb_iv_get(self, "@stream");
rb_funcall(stream, meth_rewind, 0);

Expand All @@ -167,7 +168,6 @@ static VALUE reader(VALUE self) {
}
VALUE retval = vmpop(vm);

iconv_close(iconv_cd);
// free_vm(vm);
return retval;
}
Expand Down Expand Up @@ -463,7 +463,7 @@ static void load_unicode(VirtualMachine *vm, VALUE stream) {
buf = read_one(stream);
}

VALUE string = rb_funcall(bytes, meth_pack, 1, rb_str_new2("U*"));
VALUE string = pack_to_utf8(bytes);
vmpush(vm, string);
}

Expand Down
3 changes: 2 additions & 1 deletion ruby_pickle.gemspec
Expand Up @@ -18,7 +18,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.extensions << 'ext/extconf.rb'

s.add_dependency "activesupport", ">= 3.0.0"

s.add_development_dependency 'yard'
Expand Down
2 changes: 1 addition & 1 deletion spec/pickler/basic_types_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'

module RubyPickle
describe Unpickler do
describe Pickler do
include SpecHelper

it 'pickles Integers' do
Expand Down

0 comments on commit 6af6251

Please sign in to comment.