Skip to content

Instantly share code, notes, and snippets.

fficxx issues:
1. simpleBuilder hard coded snappy specific code. -- Patched but not tested
2. resource management issue in C shim code(returned objects and references are converted to pointers, then use ForeignPtr on the Haskell), this probably will cause a critical bug.
3. fficxx currently doesn't deal with global variables
4. Multiple packages for one C++ project
5. enumeration and class support is not implemented (in swig branch)
6. interface to C++ in the C shim code is not fully implemented
7. need to support function pointers
8. finish top-level functions
*** Class2.hs 2013-07-30 17:30:58.000000000 -0400
--- Class.hs 2013-07-09 13:30:42.000000000 -0400
*************** import System.FilePath
*** 24,186 ****
import FFICXX.Generate.Util
-- | C types
! data PrimitiveTypes c = CPTChar
! | CPTInt
! | CPTLong
module FFICXX.SWIG.TypeString where
import Text.ParserCombinators.Parsec
import qualified FFICXX.Generate.Type.Class as FFICXX
import qualified Data.Map.Strict as Map
import Data.Functor ((<$>))
import Data.Map ((!))
import Text.StringLike (StringLike)
import Control.Applicative ((<*>), (<*), liftA2)
{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses,
FlexibleInstances, TypeSynonymInstances,
EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables,
GADTs #-}
-----------------------------------------------------------------------------
-- |
-- Module : FFICXX.Runtime.Cast
-- Copyright : (c) 2011-2013 Ian-Woo Kim
class Foo;
Foo* newFooSingleton();
Foo* global_foo_ptr_;
const Foo* global_const_foo_ptr_ = newFooSingleton();
const Foo& global_const_foo_ref_ = *global_const_foo_ptr_;
class Bar;
// Class definition here
class Foo {
"const char * char_const_p_;" will give:
<cdecl id="376" addr="0x101780ac0" >
<attributelist id="377" addr="0x101780ac0" >
...
// Difference
<attribute name="decl" value="p." id="380" addr="0x1017823c0" />
<attribute name="type" value="q(const).char" id="382" addr="0x1017823c0" />
...
</attributelist >
</cdecl >
@ofan
ofan / gist:5921893
Created July 3, 2013 19:22
snappy error
esolving dependencies...
Configuring Snappy-0.0...
Building Snappy-0.0...
Preprocessing library Snappy-0.0...
[ 1 of 31] Compiling Snappy.UncheckedByteArraySink.RawType ( src/Snappy/UncheckedByteArraySink/RawType.hs, dist/build/Snappy/UncheckedByteArraySink/RawType.o )
[ 2 of 31] Compiling Snappy.UncheckedByteArraySink.FFI ( dist/build/Snappy/UncheckedByteArraySink/FFI.hs, dist/build/Snappy/UncheckedByteArraySink/FFI.o )
[ 3 of 31] Compiling Snappy.ByteArraySource.RawType ( src/Snappy/ByteArraySource/RawType.hs, dist/build/Snappy/ByteArraySource/RawType.o )
[ 4 of 31] Compiling Snappy.ByteArraySource.FFI ( dist/build/Snappy/ByteArraySource/FFI.hs, dist/build/Snappy/ByteArraySource/FFI.o )
[ 5 of 31] Compiling Snappy.CppString.RawType ( src/Snappy/CppString/RawType.hs, dist/build/Snappy/CppString/RawType.o )
[ 6 of 31] Compiling Snappy.CppString.Interface ( src/Snappy/CppString/Interface.hs, dist/build/Snappy/CppString/Interface.o )
@ofan
ofan / .zshrc
Last active December 19, 2015 04:39
#!/bin/zsh
load_profile
load_zsh_rc
unset -f load_profile
unset -f load_zsh_rc
TMUX_MOD=`[ -z "$TMUX" ] && echo 1`
TMUX_TERM_LIST=(Apple_Terminal iTerm.app rxvt-unicode-256color xterm-256color)
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
class YesNo a where
yesno :: a -> Bool
instance (Num a, Eq a) => YesNo a where
yesno 0 = False
yesno _ = True
#include <iostream>
#include <functional>
template <typename Arg>
struct ArgPack{
decltype(std::placeholders::_1) noarg = std::placeholders::_1;
};
template <typename ... Args>
inline auto expand() -> decltype(std::placeholders::_1) { return std::placeholders::_1; }