Created
January 12, 2010 23:44
-
-
Save larrytheliquid/275766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
larrytheliquid@netbooktheliquid:~/src/testhubris$ Hubrify foo2.hs --module Bar --output foo2.bundle | |
Candidates: ["l"] | |
Language.Ruby.Hubris.wrap Bar.l (fromIntegral $ fromEnum $ Language.Ruby.Hubris.Binding.RUBY_Qtrue) | |
type of wrap.l is "Language.Ruby.Hubris.Binding.Value" | |
Exportable: ["l"] | |
{-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables #-} | |
module Language.Ruby.Hubris.Exports.Bar where | |
import Language.Ruby.Hubris | |
import qualified Prelude as P() | |
import Language.Ruby.Hubris.Binding | |
import qualified Bar | |
l :: Value -> Value | |
l b = (Language.Ruby.Hubris.wrap Bar.l) b | |
foreign export ccall "hubrish_l" l :: Value -> Value | |
C: | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define HAVE_STRUCT_TIMESPEC 1 | |
#include <ruby.h> | |
#ifdef DEBUG | |
#define eprintf printf | |
#else | |
int eprintf(const char *f, ...){} | |
#endif | |
VALUE hubrish_l(VALUE); | |
VALUE l(VALUE mod, VALUE v){ | |
eprintf("l has been called\n"); | |
VALUE res = hubrish_l(v); | |
if (rb_obj_is_kind_of(res,rb_eException)) { | |
eprintf("l has provoked an exception\n"); | |
rb_exc_raise(res); | |
} else { | |
eprintf("returning from l\n"); | |
return res; | |
} | |
} | |
extern void safe_hs_init(); | |
extern VALUE Exports; | |
void Init_Bar(){ | |
eprintf("loading\n"); | |
VALUE Fake = Qnil; | |
safe_hs_init(); | |
Fake = rb_define_module_under(Exports, "Bar"); | |
eprintf("defined module Hubris::Exports::Bar:%p\n", Fake); | |
eprintf("Defining |l|\n"); | |
rb_define_method(Fake, "l",l, 1); | |
} | |
/usr/local/bin/ghc --make -shared -dynamic -o foo2.bundle -optl-Wl,-rpath,/usr/local/stow/ghc-6.12.1/lib/ghc-6.12.1 -lHSrts-ghc6.12.1 /tmp/hubris_XXXXX9747.hs -I/usr/lib/ruby/1.8/x86_64-linux/ foo2.hs /tmp/hubris_interface_XXXXX9747.c | |
Failed: code: ExitFailure 1 | |
err:output: | |
error: [1 of 2] Compiling Bar ( foo2.hs, foo2.o ) | |
[2 of 2] Compiling Language.Ruby.Hubris.Exports.Bar ( /tmp/hubris_XXXXX9747.hs, /tmp/hubris_XXXXX9747.o ) | |
Linking foo2.bundle ... | |
/usr/bin/ld: /tmp/hubris_XXXXX9747.o: relocation R_X86_64_PC32 against undefined symbol `newCAF' can not be used when making a shared object; recompile with -fPIC | |
/usr/bin/ld: final link failed: Bad value | |
collect2: ld returned 1 exit status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment