Skip to content

Unknown scope type "forever" on glib >= 2.79.0 #425

@dashea

Description

@dashea

glib-2.79.0 starting using (scope forever) annotations in gerror, gboxed, and gsignal, which is not currently supported by the gir parser.

Things build with the following patch but I haven't tried out any of the functions with forever annotations yet, and I'm not real familiar with how the generated bindings work. If it looks correct enough I can convert it to a PR.

diff --git a/lib/Data/GI/CodeGen/Callable.hs b/lib/Data/GI/CodeGen/Callable.hs
index 52a23c2..157c450 100644
--- a/lib/Data/GI/CodeGen/Callable.hs
+++ b/lib/Data/GI/CodeGen/Callable.hs
@@ -573,6 +573,7 @@ prepareClosures callable nameMap = do
                     n -> let destroyName = escapedArgName $ (args callable)!!n
                          in line $ "let " <> destroyName <> " = FP.nullFunPtr"
                 ScopeTypeCall -> line $ "let " <> closureName <> " = nullPtr"
+                ScopeTypeForever -> line $ "let " <> closureName <> " = castFunPtrToPtr " <> n'
             _ -> badIntroError $ "Closure \"" <> n <> "\" is not a callback."
 
 freeCallCallbacks :: Callable -> Map.Map Text Text -> ExcCodeGen ()
diff --git a/lib/Data/GI/GIR/Arg.hs b/lib/Data/GI/GIR/Arg.hs
index 6d6f379..cbe2e55 100644
--- a/lib/Data/GI/GIR/Arg.hs
+++ b/lib/Data/GI/GIR/Arg.hs
@@ -24,6 +24,7 @@ data Scope = ScopeTypeInvalid
            | ScopeTypeCall
            | ScopeTypeAsync
            | ScopeTypeNotified
+           | ScopeTypeForever
              deriving (Show, Eq, Ord)
 
 data Arg = Arg {
@@ -54,6 +55,7 @@ parseScope :: Text -> Parser Scope
 parseScope "call" = return ScopeTypeCall
 parseScope "async" = return ScopeTypeAsync
 parseScope "notified" = return ScopeTypeNotified
+parseScope "forever" = return ScopeTypeForever
 parseScope s = parseError $ "Unknown scope type \"" <> s <> "\""
 
 parseDirection :: Text -> Parser Direction

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions