Fri, 18 Aug 2000 00:07:54 +1000, Manuel M. T. Chakravarty <[EMAIL PROTECTED]> pisze:

> Hehe - just forbid passing ForeignObjs as parameters to external
> functions.  This would force everybody to use foreignPtrToAddr,
> which again would make the need for touch more obvious.

My framework makes it easy :-)

instance ForeignArg (Ptr ()) ForeignObj where
    convertArg f x = withForeignObj x f

Ugh, it cannot be (Ptr a) because it overlaps with another instance
(does not matter that ForeignObj is not Storable).

You see, the previous order of withForeignObj was not that bad :-)

The above instance is now in QForeign. Of course instances for custom
newtypes must be written manually:

instance ForeignArg (Ptr GCTag) GC where
    convertArg f (GC obj) = withForeignObj obj f

And then:

gcCopy:: Window -> GC -> IO GC
gcCopy win source = do
    dest <- gcNew win
    call gc_copy dest source
    return dest
foreign import unsafe gc_copy :: Ptr GCTag -> Ptr GCTag -> IO ()

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZAST�PCZA
QRCZAK


Reply via email to