Skip to content

Declare flushBufferForReadback: and foldKeyboard: so their callers get a prototype #5779

Description

@shai-almog

The iOS warning census reports 4 instances of -Wobjc-method-access, covering
two selectors:

IOSNative.m                 instance method '-flushBufferForReadback:y:width:height:' not found (return type defaults to 'id')
CodenameOne_GLViewController.m   same
CN1TapGestureRecognizer.m   instance method '-foldKeyboard:' not found (return type defaults to 'id')   (x2)

Both methods exist -- CodenameOne_GLViewController.m:5520 and :5661 -- but
neither is declared in a header, so every caller in another translation unit
compiles against no prototype at all.

Why this is a defect and not noise. With no declaration clang assumes the
method returns id and infers parameter types from the call. foldKeyboard:
takes a CGPoint, a struct passed by value; CN1TapGestureRecognizer.m:268
and :313 call it cross-file with no prototype, so nothing checks that the
struct is passed the way the callee reads it. Nothing warns at runtime either
-- Objective-C dispatch succeeds, because the method really is implemented.

This is also the exact diagnostic the macOS template already promotes to an
error, with a comment explaining that a receiver whose class does not declare
the selector is a default-level warning and a runtime crash. The iOS template
does not, and adopting -Werror=objc-method-access there is blocked by these
four sites and nothing else.

Scope

  • Declare both methods in CodenameOne_GLViewController.h (or whichever header
    the callers already import).
  • Re-run the census and confirm -Wobjc-method-access reaches zero.
  • Then adopt WARNING_CFLAGS = ("-Werror=objc-method-access") in the iOS
    template, mirroring the macOS one. Note this changes customer builds, so it
    ships on its own.

Editing the iOS template pbxproj has three constraints worth reading before
touching it: never introduce a nested }; inside a buildSettings = { ... }
block (IPhoneBuilder.injectDevelopmentTeam matches it non-greedy with DOTALL
and truncates at the first one -- a parenthesised list is safe); do not move or
reformat the literal-matched anchor lines; and comments must not contain the
substring template, which replaceInFile rewrites to the application name.

Found by the native warning census (scripts/check-native-warnings.py).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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