Safe Haskell | None |
---|
- class FromRuby a where
- class ToRuby a where
- fromRubyIntegral :: Integral n => RValue -> IO (Maybe n)
- toRubyIntegral :: Integral n => n -> IO RValue
- fromRubyArray :: FromRuby a => RValue -> IO (Maybe [a])
- embedHaskellValue :: a -> IO RValue
- freeHaskellValue :: RValue -> IO ()
- extractHaskellValue :: RValue -> IO a
- runscript :: String -> IO (Either String ())
- defineGlobalClass :: String -> IO RValue
- safeMethodCall :: String -> String -> [RValue] -> IO (Either (String, RValue) RValue)
- showErrorStack :: IO String
- setGC :: Bool -> IO (Either (String, RValue) RValue)
- startGC :: IO ()
- freezeGC :: IO a -> IO a
Documentation
The class of things that can be converted from Ruby values. Note that
there are a ton of stuff that are Ruby values, hence the Maybe
type,
as the instances will probably be incomplete.
fromRuby :: RValue -> IO (Maybe a)Source
To define more instances, please look at the instances defined in Foreign.Ruby.Helpers.
FromRuby Double | |
FromRuby Int | |
FromRuby Integer | |
FromRuby ByteString | |
FromRuby Text | |
FromRuby Value | This is the most complete instance that is provided in this module.
Please note that it is far from being sufficient for even basic
requirements. For example, the |
FromRuby a => FromRuby [a] |
toRubyIntegral :: Integral n => n -> IO RValueSource
embedHaskellValue :: a -> IO RValueSource
This transforms any Haskell value into a Ruby big integer encoding the
address of the corresponding StablePtr
. This is useful when you want
to pass such values to a Ruby program that will call Haskell functions.
This is probably a bad idea to do this. The use case is for calling Haskell functions from Ruby, using values generated from the Haskell world. If your main program is in Haskell, you should probably wrap a function partially applied with the value you would want to embed.
freeHaskellValue :: RValue -> IO ()Source
Frees the Haskell value represented by the corresponding RValue
.
This is probably extremely unsafe to do, and will most certainly lead to
exploitable security bug if you use something modified from Ruby land.
You should always free the RValue
you generated from
embedHaskellValue
.
extractHaskellValue :: RValue -> IO aSource
This is unsafe as hell, so you'd better be certain this RValue has not been tempered with : GC frozen, bugfree Ruby scripts.
If it has been tempered by an attacker, you are probably looking at a good vector for arbitrary code execution.
:: String | Class name. |
-> String | Method name. |
-> [RValue] | Arguments. Please note that the maximum number of arguments is 16. |
-> IO (Either (String, RValue) RValue) | Returns either an error message / value couple, or the value returned by the function. |
Runs a Ruby method, capturing errors.
showErrorStack :: IO StringSource
Gives a (multiline) error friendly string representation of the last error.
Sets the current GC operation. Please note that this could be modified from Ruby scripts.