hruby 0.3.6 → 0.3.7
raw patch · 2 files changed
+26/−3 lines, 2 files
Files
- Foreign/Ruby/Bindings.hsc +24/−1
- hruby.cabal +2/−2
Foreign/Ruby/Bindings.hsc view
@@ -108,6 +108,8 @@ foreign import ccall unsafe "rb_iv_set" c_rb_iv_set :: RValue -> CString -> RValue -> IO RValue foreign import ccall safe "rb_define_class" c_rb_define_class :: CString -> RValue -> IO RValue foreign import ccall safe "rb_define_method" c_rb_define_method :: RValue -> CString -> FunPtr a -> Int -> IO ()+foreign import ccall safe "rb_define_singleton_method" c_rb_define_singleton_method :: RValue -> CString -> FunPtr a -> Int -> IO ()+foreign import ccall safe "rb_define_module_function" c_rb_define_module_function :: RValue -> CString -> FunPtr a -> Int -> IO () foreign import ccall safe "rb_define_global_function" c_rb_define_global_function :: CString -> FunPtr a -> Int -> IO () foreign import ccall unsafe "rb_const_get" rb_const_get :: RValue -> RID -> IO RValue foreign import ccall safe "&safeCall" safeCallback :: FunPtr (RValue -> IO RValue)@@ -186,8 +188,29 @@ -> IO () rb_define_global_function s f i = withCString s (\cs -> c_rb_define_global_function cs f i) -rb_define_method :: RValue -> String -> FunPtr a -> Int -> IO ()+-- | Defines an instance method.+--+-- The Haskell function must accept the receiver as the first argument.+-- If @argc >= 0@, the type of the arguments of the function must be `RValue`.+rb_define_method+ :: RValue -- ^ Object to which a method is added+ -> String -- ^ Name of the method+ -> FunPtr a -- ^ Pointer to the Haskell function (created with something like `mkRegistered1`)+ -> Int -- ^ @-1@, @-2@, or number of arguments the function accepts other than the receiver.+ -> IO () rb_define_method r s f i = withCString s (\cs -> c_rb_define_method r cs f i)++-- | Defines a singleton method.+--+-- Arguments are the same as 'rb_define_method'.+rb_define_singleton_method :: RValue -> String -> FunPtr a -> Int -> IO ()+rb_define_singleton_method r s f i = withCString s (\cs -> c_rb_define_singleton_method r cs f i)++-- | Defines a module function (@module_function@) to a module.+--+-- Arguments are the same as 'rb_define_method'.+rb_define_module_function :: RValue -> String -> FunPtr a -> Int -> IO ()+rb_define_module_function r s f i = withCString s (\cs -> c_rb_define_module_function r cs f i) rb_define_class :: String -> RValue -> IO RValue rb_define_class str rv = withCString str (\s -> c_rb_define_class s rv)
hruby.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.10 name: hruby-version: 0.3.6+version: 0.3.7 synopsis: Embed a Ruby intepreter in your Haskell program ! description: This doesn't work with Ruby 1.9. Everything you need should be in Foreign.Ruby.Safe. license: BSD3@@ -11,7 +11,7 @@ category: Language build-type: Custom extra-source-files: test/*.rb-Tested-With: GHC == 8.0.2, GHC == 8.2.2+Tested-With: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.4 custom-setup setup-depends: Cabal, base, process