on dcbc28e help sign in
69 lines 2.0 kB history raw
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE FlexibleInstances #-}
3-----------------------------------------------------------------------------
4--
5-- Module : Language.Javascript.JSaddle.Properties
6-- Copyright : (c) Hamish Mackenzie
7-- License : MIT
8--
9-- Maintainer : Hamish Mackenzie <Hamish.K.Mackenzie@googlemail.com>
10--
11-- |
12--
13-----------------------------------------------------------------------------
15module Language.Javascript.JSaddle.Types (
16 JSVal
17 , MutableJSArray
18 , Object(..)
19 , JSPropertyNameArray
20 , JSPropertyAttributes
21 , JSContextRef
22 , JSString
23 , Index
24 , Nullable(..)
25 , JSM
26) where
28import Control.Monad.Trans.Reader (ReaderT(..))
29#ifdef ghcjs_HOST_OS
30import GHCJS.Types
31import JavaScript.Object.Internal (Object(..))
32import JavaScript.Array (MutableJSArray)
33import Data.Word (Word(..))
34import GHCJS.Nullable (Nullable(..))
35#else
36import Foreign.ForeignPtr (ForeignPtr)
37import Graphics.UI.Gtk.WebKit.JavaScriptCore.JSBase
38 (OpaqueJSString, JSValueRefRef,
39 JSContextRef, JSPropertyNameArrayRef, OpaqueJSValue)
40import Graphics.UI.Gtk.WebKit.JavaScriptCore.JSObjectRef (JSPropertyAttributes)
41import Foreign.C (CUInt(..))
42#endif
44#ifdef ghcjs_HOST_OS
45newtype JSPropertyNameArray = JSPropertyNameArray { unJSPropertyNameArrayRef :: JSVal }
46type JSPropertyAttributes = Word
47type JSContextRef = ()
48type Index = Int
49#else
50type JSVal = ForeignPtr OpaqueJSValue
51type MutableJSArray = JSValueRefRef
52type JSPropertyNameArray = JSPropertyNameArrayRef
53type Index = CUInt
54newtype Object = Object (ForeignPtr OpaqueJSValue)
55type JSString = ForeignPtr OpaqueJSString
56newtype Nullable a = Nullable a
57#endif
59-- | The @JSM@ monad keeps track of the JavaScript context.
60--
61-- Given a @JSM@ function and a 'JSContextRef' you can run the
62-- function like this...
63--
64-- > runReaderT jsmFunction javaScriptContext
65--
66-- For an example of how to set up WebKitGTK+ see tests/TestJSaddle.hs
67type JSM = ReaderT JSContextRef IO