Description
Hi I am studying the code generation - in order to make function calls safe - where necessary.
This ticket is a follow up - to provide a PR for ghcjs/ghcjs-dom#78
I have had a look at the idl-files in webkitgtk-2.17.2, as well as some of hdirect-0.21.
To make the unsafe
foreign function calls safe - I guess one would have to modify
domconv-webkit-jsffi.hs
701: H.HsForeignImport nullLoc (if promise then "javascript interruptible" else "javascript") H.HsUnsafe jsimpl (H.HsIdent defop) tpsig
952: H.HsForeignImport nullLoc (if promise then "javascript interruptible" else "javascript") H.HsUnsafe jsimpl (H.HsIdent defop) tpsig
(maybe a few more) and change the H.HsUnsafe
- dependently if there are *MayThrowException
annotations in the idl-files, which are used to genereate the Haskell bindings.
Status of DOMCONV
If I understood correctly there is
domconv-webkit/domconv-webkit-jsffi.hs
889: constructorRaises | I.ExtAttr (I.Id "ConstructorRaisesException") [] `elem` at = [I.Raises ["RaisesException"]]
domconv-webkit/domconv-webkit-jsaddle.hs
879: constructorRaises | I.ExtAttr (I.Id "ConstructorRaisesException") [] `elem` at = [I.Raises ["RaisesException"]]
and in the syntax/parser files
domconv-webkit/hdirect-0.21/OmgParser.y
556:getter_decl :: { (Id, [Param], [Raises], Maybe Context) }
562:setter_decl :: { (Id, [Param], [Raises], Maybe Context) }
568:deleter_decl :: { (Id, [Param], [Raises], Maybe Context) }
616:raises_expr :: { Raises }
617: : RAISES '(' scoped_name_list ')' { Raises (reverse $3) }
618: | GETTER RAISES '(' scoped_name_list ')' { GetRaises (reverse $4) }
619: | SETTER RAISES '(' scoped_name_list ')' { SetRaises (reverse $4) }
621:raises_exprs :: { [Raises] }
domconv-webkit/hdirect-0.21/IDLSyn.lhs
30: | Attribute [Id] Bool Type [Raises] [ExtAttribute]
31: | DictionaryAttribute [Id] Bool Type [Raises] [ExtAttribute]
32: | Operation Id Type {-[Param]-} [Raises] (Maybe Context) [ExtAttribute]
139:data Raises = GetRaises [Name] | SetRaises [Name] | Raises [Name] deriving ( Eq, Ord, Show )
140:getterRaises = filter isGet
142: isGet (SetRaises _) = False
144:setterRaises = filter isSet
146: isSet (GetRaises _) = False
domconv-webkit/hdirect-0.21/OmgParser.hs
63: | HappyAbsSyn80 (Maybe Raises)
that relate to exception parsing.
But I do not understand which parts in the idl-files they resemble - I tried to > ack "ConstructorRaisesException"
in the webkit-2.17.2 directory (ack) without any results.
Status of IDL-Files
On the other hand searching for MayThrowException
which can be found in for example in Websocket.idl.
[SetterMayThrowException] attribute DOMString binaryType;
[MayThrowException] void send(ArrayBuffer data);
[MayThrowException] void send(ArrayBufferView data);
[MayThrowException] void send(Blob data);
[MayThrowException] void send(USVString data);
[MayThrowException] void close(optional [Clamp] unsigned short code, optional DOMString reason);
There is yields no result in the domconv-webkit files.
The only idl files where I found "ConstructorRaisesException - is some ancient webkit repository of adobe adobe/webkit from 2012.
Questions
- Could you give me some info how to modify the parsers to incude the
MayThrowException
? - What are the
RaisesException
statements in the existing parsers for?