dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
157 stars 44 forks source link

`jnigen` 0.12.1 generates invalid code #1721

Closed brianquinlan closed 1 week ago

brianquinlan commented 1 week ago

You can see the generated code here: https://github.com/dart-lang/http/pull/1405/files#diff-c82a307090995edb15ccb1b80470e4c3bf5517bd517271de258f7806d5ea4e1a

The first few errors:


../lib/src/jni/bindings.dart:126:16: Error: Expected ';' after this.
  static final _id_-deprecated_url = _class.instanceMethodId(
               ^^^^
../lib/src/jni/bindings.dart:126:20: Error: Operator declarations must be preceded by the keyword 'operator'.
Try adding the keyword 'operator'.
  static final _id_-deprecated_url = _class.instanceMethodId(
                   ^
../lib/src/jni/bindings.dart:126:20: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  static final _id_-deprecated_url = _class.instanceMethodId(
                   ^
../lib/src/jni/bindings.dart:126:21: Error: Expected '{' before this.
  static final _id_-deprecated_url = _class.instanceMethodId(
                    ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:126:21: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
  static final _id_-deprecated_url = _class.instanceMethodId(
                    ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:131:16: Error: Expected ';' after this.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
               ^
../lib/src/jni/bindings.dart:131:17: Error: Operator declarations must be preceded by the keyword 'operator'.
Try adding the keyword 'operator'.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                ^
../lib/src/jni/bindings.dart:131:17: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                ^
../lib/src/jni/bindings.dart:131:18: Error: Expected '{' before this.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:131:17: Error: 'unary-' is already declared in this scope.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                ^^^^^^
../lib/src/jni/bindings.dart:126:20: Context: Previous declaration of 'unary-'.
  static final _id_-deprecated_url = _class.instanceMethodId(
                   ^^^^^^
../lib/src/jni/bindings.dart:131:18: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:131:18: Error: 'deprecated_url' is already declared in this scope.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:126:21: Context: Previous declaration of 'deprecated_url'.
  static final _id_-deprecated_url = _class.instanceMethodId(
                    ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:136:3: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  _$jni.JObject -deprecated_url(){
  ^^^^^
../lib/src/jni/bindings.dart:136:17: Error: Expected '{' before this.
  _$jni.JObject -deprecated_url(){
                ^
../lib/src/jni/bindings.dart:136:3: Error: The name of a constructor must match the name of the enclosing class.
  _$jni.JObject -deprecated_url(){
  ^^^^^
../lib/src/jni/bindings.dart:136:17: Error: Operator declarations must be preceded by the keyword 'operator'.
Try adding the keyword 'operator'.
  _$jni.JObject -deprecated_url(){
                ^
../lib/src/jni/bindings.dart:136:17: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
  _$jni.JObject -deprecated_url(){
                ^
../lib/src/jni/bindings.dart:136:18: Error: Expected '{' before this.
  _$jni.JObject -deprecated_url(){
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:136:17: Error: 'unary-' is already declared in this scope.
  _$jni.JObject -deprecated_url(){
                ^^^^^^
../lib/src/jni/bindings.dart:131:17: Context: Previous declaration of 'unary-'.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                ^^^^^^
../lib/src/jni/bindings.dart:136:18: Error: 'deprecated_url' is already declared in this scope.
  _$jni.JObject -deprecated_url(){
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:131:18: Context: Previous declaration of 'deprecated_url'.
  static final _-deprecated_url = _$jni.ProtectedJniExtensions
                 ^^^^^^^^^^^^^^
../lib/src/jni/bindings.dart:141:16: Error: Expected ';' after this.
  static final _id_-deprecated_method = _class.instanceMethodId(
               ^^^^
../lib/src/jni/bindings.dart:141:16: Error: '_id_' is already declared in this scope.
  static final _id_-deprecated_method = _class.instanceMethodId(
...
`
HosseinYousefi commented 1 week ago

This is fixed on the main branch. I just exclude all non valid identifiers by default.

brianquinlan commented 1 week ago

When are you planning on doing a release?

HosseinYousefi commented 1 week ago

When are you planning on doing a release?

I'll release one today.