dart-lang / dart-lang/native

[ffigen] Parse `ns_returns_retained` and `ns_consumed` for blocks

Open
#1,490 0 comments 1 reaction 0 assignees View on GitHub
lang-objective_c package:ffigen
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 9h
Merged PRs (30d)
52

Description

We have all the infra for handling these annotations in ffigen, but libclang doesn't seem to have a way of accessing `__attribute__((ns_returns_retained))` and `__attribute__((ns_consumed))` annotations on blocks.

For methods and top level functions, these annotations are on the `CXCursor` of the declaration, but for blocks I only have a `CXType` with no declaration cursor. If I annotate a block with `NS_RETURNS_RETAINED`, the `CXType`'s kind changes from `FunctionProto` to `Unexposed`. If I annotate it with `__attribute__((ns_returns_retained))` the kind changes to `Attributed`, which is a bit more promising, but I can't find a way of getting the attribute. If I annotate one of the args with `__attribute__((ns_consumed))`, nothing happens at all.

Contributor guide

Open the contributing guide

Research direction

Start by tracing ffigen’s existing handling for ns_returns_retained and ns_consumed on methods and top-level functions. Investigate how libclang represents these annotations on block CXType values, including FunctionProto, Unexposed, and Attributed kinds; done means both block annotations can be parsed consistently with existing support.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.