Skip to content

Commit

Permalink
Fix the templates in the header and make the extconf 2.0 ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanmac committed Apr 18, 2013
1 parent e450261 commit 9375c78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 39 deletions.
6 changes: 2 additions & 4 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
require 'mkmf'



dir_config("archive")
with_cflags("-x c++"){

pkg_config("libarchive")
unless(find_library("archive","main") && find_header("archive.h"))
abort("libarchive dev files")
Expand All @@ -42,9 +41,8 @@
have_func("rb_proc_arity","ruby.h")
have_func("archive_read_support_format_raw","archive.h")

}
$CFLAGS += "-x c++ -Wall"

$CFLAGS += " -Wall"

create_header

Expand Down
45 changes: 10 additions & 35 deletions ext/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,23 @@ struct rarchive_entry{
};

template <>
inline VALUE wrap< rarchive >(rarchive *file )
{
return Data_Wrap_Struct(rb_cArchive, NULL, free, file);
}
VALUE wrap< rarchive >(rarchive *file );


template <>
inline rarchive* wrap< rarchive* >(const VALUE &vfile)
{
if ( ! rb_obj_is_kind_of(vfile, rb_cArchive) )
return NULL;
rarchive *file;
Data_Get_Struct( vfile, rarchive, file);
return file;
}
rarchive* wrap< rarchive* >(const VALUE &vfile);

template <>
inline VALUE wrap< archive_entry >(struct archive_entry *entry )
{
rarchive_entry *temp = new rarchive_entry;
//archive_entry other = archive_entry_clone(entry);
temp->entry = archive_entry_clone(entry);
return Data_Wrap_Struct(rb_cArchiveEntry, NULL, free, temp);
}
VALUE wrap< archive_entry >(struct archive_entry *entry );

template <>
inline archive_entry* wrap< archive_entry* >(const VALUE &vfile)
{
if ( ! rb_obj_is_kind_of(vfile, rb_cArchiveEntry) )
return NULL;
rarchive_entry *file;
Data_Get_Struct( vfile, rarchive_entry, file);
return file->entry;
}
archive_entry* wrap< archive_entry* >(const VALUE &vfile);

template <>
inline VALUE wrap< const char >(const char *str )
{
return str == NULL? Qnil : rb_str_new2(str);
}
VALUE wrap< const char >(const char *str );

template <>
const char* wrap< const char* >(const VALUE &vfile)
{
return NIL_P(vfile) ? NULL : StringValueCStr((volatile VALUE&)vfile);
}
const char* wrap< const char* >(const VALUE &vfile);

#endif /* __RubyAchiveMain_H__ */

0 comments on commit 9375c78

Please sign in to comment.