git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: fix issue with internal vector type (used with data)
35f079bAndy Arvanitis
pcc/include/purescript.cc+6
@@ -151,6 +151,12 @@ auto any::cast() const -> typename std::enable_if<std::is_same<T, map>::value, c
151}
151}
152template auto any::cast<any::map>() const -> const map&;
152template auto any::cast<any::map>() const -> const map&;
153
153
154+template <typename T>
155+auto any::cast() const -> typename std::enable_if<std::is_same<T, vector>::value, const T&>::type {
156+ RETURN_VALUE(Type::Vector, v, *)
157+}
158+template auto any::cast<any::vector>() const -> const vector&;
159+
154template <typename T>
160template <typename T>
155auto any::cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type {
161auto any::cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type {
156 RETURN_VALUE(Type::Array, a, *)
162 RETURN_VALUE(Type::Array, a, *)
pcc/include/purescript.hh+1−4
@@ -240,11 +240,8 @@ class any {
240 template <typename T>
240 template <typename T>
241 auto cast() const -> typename std::enable_if<std::is_same<T, map>::value, const T&>::type;
241 auto cast() const -> typename std::enable_if<std::is_same<T, map>::value, const T&>::type;
242
242
243− // These cannot be thunked
244 template <typename T>
243 template <typename T>
245− inline auto cast() const -> typename std::enable_if<std::is_same<T, vector>::value, const T&>::type {
244+ auto cast() const -> typename std::enable_if<std::is_same<T, vector>::value, const T&>::type;
246− return *v;
247− }
248
245
249 template <typename T>
246 template <typename T>
250 auto cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type;
247 auto cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type;
src/Language/PureScript/CodeGen/Cpp/File.hs+3−4
@@ -24,7 +24,6 @@ import Language.PureScript.CodeGen.Cpp.Types
24import Language.PureScript.Names
24import Language.PureScript.Names
25
25
26import qualified Language.PureScript.Pretty.Cpp as P
26import qualified Language.PureScript.Pretty.Cpp as P
27−import qualified Language.PureScript.Pretty.Common as P
28
27
29---------------------------------------------------------------------------------------------------
28---------------------------------------------------------------------------------------------------
30toHeader :: [Cpp] -> [Cpp]
29toHeader :: [Cpp] -> [Cpp]
@@ -34,7 +33,7 @@ toHeader = catMaybes . map go
34 go :: Cpp -> Maybe Cpp
33 go :: Cpp -> Maybe Cpp
35 go (CppNamespace name cpps) = Just (CppNamespace name (toHeader cpps))
34 go (CppNamespace name cpps) = Just (CppNamespace name (toHeader cpps))
36 go cpp@(CppUseNamespace{}) = Just cpp
35 go cpp@(CppUseNamespace{}) = Just cpp
37− go (CppFunction name args rtyp qs body)
36+ go (CppFunction _ _ _ qs _)
38 | CppInline `elem` qs = Just CppNoOp
37 | CppInline `elem` qs = Just CppNoOp
39 go (CppFunction _ [(_, atyp)] _ _ (CppBlock [CppReturn (CppApp _ [_])])) | atyp == Just CppAuto
38 go (CppFunction _ [(_, atyp)] _ _ (CppBlock [CppReturn (CppApp _ [_])])) | atyp == Just CppAuto
40 = Just CppNoOp
39 = Just CppNoOp
@@ -107,7 +106,7 @@ toBody = catMaybes . map go
107 isNoOp (CppRaw _) = True
106 isNoOp (CppRaw _) = True
108 isNoOp _ = False
107 isNoOp _ = False
109 go cpp@(CppUseNamespace{}) = Just cpp
108 go cpp@(CppUseNamespace{}) = Just cpp
110− go (CppFunction name args rtyp qs body)
109+ go (CppFunction _ _ _ qs _)
111 | CppInline `elem` qs = Just CppNoOp
110 | CppInline `elem` qs = Just CppNoOp
112 go cpp@(CppFunction {}) = Just cpp
111 go cpp@(CppFunction {}) = Just cpp
113 go (CppVariableIntroduction _ _ (Just CppNumericLiteral {})) =
112 go (CppVariableIntroduction _ _ (Just CppNumericLiteral {})) =
@@ -127,7 +126,7 @@ toBody = catMaybes . map go
127 addCaptures (CppObjectLiteral objs) = CppObjectLiteral (objlam <$> objs)
126 addCaptures (CppObjectLiteral objs) = CppObjectLiteral (objlam <$> objs)
128 where
127 where
129 objlam :: (String, Cpp) -> (String, Cpp)
128 objlam :: (String, Cpp) -> (String, Cpp)
130− objlam (name, (CppLambda _ args rty body)) = (name , CppLambda [] args rty $ addCaptures body)
129+ objlam (name', (CppLambda _ args rty body)) = (name' , CppLambda [] args rty $ addCaptures body)
131 objlam obj = obj
130 objlam obj = obj
132 addCaptures (CppApp (CppLambda _ [] rty body) []) = CppApp (CppLambda [] [] rty (addCaptures body)) []
131 addCaptures (CppApp (CppLambda _ [] rty body) []) = CppApp (CppLambda [] [] rty (addCaptures body)) []
133 addCaptures cpps' = everywhereOnCpp addCapture cpps'
132 addCaptures cpps' = everywhereOnCpp addCapture cpps'