Skip to content

Commit

Permalink
Daco's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liamappelbe committed Apr 17, 2024
1 parent 9fe667d commit 2e79e23
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
13 changes: 9 additions & 4 deletions pkgs/ffigen/lib/src/code_generator/imports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import 'writer.dart';
class LibraryImport {
final String name;
final String _importPath;
final String? importPathWhenImportedByPackageObjC;
final String? _importPathWhenImportedByPackageObjC;

String prefix;

LibraryImport(this.name, this._importPath,
{this.importPathWhenImportedByPackageObjC})
: prefix = name;
{String? importPathWhenImportedByPackageObjC})
: _importPathWhenImportedByPackageObjC =
importPathWhenImportedByPackageObjC,
prefix = name;

@override
bool operator ==(other) {
Expand All @@ -24,9 +27,11 @@ class LibraryImport {
@override
int get hashCode => name.hashCode;

// The import path, which may be different if this library is being imported
// into package:objective_c's generated code.
String importPath(bool generateForPackageObjectiveC) {
if (!generateForPackageObjectiveC) return _importPath;
return importPathWhenImportedByPackageObjC ?? _importPath;
return _importPathWhenImportedByPackageObjC ?? _importPath;
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/objective_c/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
- tool/extra_methods.dart
- tool/data/extra_methods.dart
language:
strict-casts: true
strict-inference: true
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Extra methods inserted into NSString by generate_code.dart.
// Extra methods inserted into NSString by tool/generate_code.dart.
class NSString extends NSObject {
factory NSString(String str) {
final cstr = str.toNativeUtf16();
Expand Down
6 changes: 3 additions & 3 deletions pkgs/objective_c/tool/generate_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Runs the ffigen configs, then merges extra_methods.dart into the Objective C
// bindings.
// Runs the ffigen configs, then merges tool/data/extra_methods.dart into the
// Objective C bindings.

// ignore_for_file: avoid_print

Expand All @@ -15,7 +15,7 @@ const cConfig = 'ffigen_c.yaml';
const objcConfig = 'ffigen_objc.yaml';
const cBindings = 'lib/src/c_bindings_generated.dart';
const objcBindings = 'lib/src/objective_c_bindings_generated.dart';
const extraMethodsFile = 'tool/extra_methods.dart';
const extraMethodsFile = 'tool/data/extra_methods.dart';

void dartCmd(List<String> args) {
final exec = Platform.resolvedExecutable;
Expand Down

0 comments on commit 2e79e23

Please sign in to comment.