[ffigen] Fix size_t and wchar_t default dart types. (#274)

diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md
index fd75d43..93663e8 100644
--- a/pkgs/ffigen/CHANGELOG.md
+++ b/pkgs/ffigen/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 5.0.0-dev.1
+- Fixed invalid default dart types being generated for `size_t` and `wchar_t`.
+
 # 5.0.0-dev.0
 - Added support for generating ABI Specific integers.
 - Breaking: removed config keys - `size-map` and `typedef-map`.
diff --git a/pkgs/ffigen/example/c_json/pubspec.yaml b/pkgs/ffigen/example/c_json/pubspec.yaml
index f4180fb..9493d21 100644
--- a/pkgs/ffigen/example/c_json/pubspec.yaml
+++ b/pkgs/ffigen/example/c_json/pubspec.yaml
@@ -26,13 +26,6 @@
     include-directives:
       - '**cJSON.h'
   comments: false
-  type-map:
-    typedefs:
-      'size_t':
-        lib: 'pkg_ffi'
-        c-type: 'Size'
-        dart-type: 'int'
-
   preamble: |
     // Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
     //
diff --git a/pkgs/ffigen/lib/src/code_generator/imports.dart b/pkgs/ffigen/lib/src/code_generator/imports.dart
index 7a92aa3..ab5e6c0 100644
--- a/pkgs/ffigen/lib/src/code_generator/imports.dart
+++ b/pkgs/ffigen/lib/src/code_generator/imports.dart
@@ -49,7 +49,5 @@
 final floatType = ImportedType(ffiImport, 'Float', 'double');
 final doubleType = ImportedType(ffiImport, 'Double', 'double');
 
-final sizeType = ImportedType(ffiPkgImport, 'Size', 'Size');
-final sSizeType = ImportedType(ffiPkgImport, 'SSize', 'SSize');
-final offType = ImportedType(ffiPkgImport, 'Off', 'Off');
-final wCharType = ImportedType(ffiPkgImport, 'WChar', 'WChar');
+final sizeType = ImportedType(ffiPkgImport, 'Size', 'int');
+final wCharType = ImportedType(ffiPkgImport, 'WChar', 'int');
diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml
index e0e03b0..967ccdf 100644
--- a/pkgs/ffigen/pubspec.yaml
+++ b/pkgs/ffigen/pubspec.yaml
@@ -3,7 +3,7 @@
 # BSD-style license that can be found in the LICENSE file.
 
 name: ffigen
-version: 5.0.0-dev.0
+version: 5.0.0-dev.1
 homepage: https://github.com/dart-lang/ffigen
 description: Generator for FFI bindings, using LibClang to parse C header files.
 
diff --git a/pkgs/ffigen/test/example_tests/cjson_example_test.dart b/pkgs/ffigen/test/example_tests/cjson_example_test.dart
index 65d5611..15d0c54 100644
--- a/pkgs/ffigen/test/example_tests/cjson_example_test.dart
+++ b/pkgs/ffigen/test/example_tests/cjson_example_test.dart
@@ -27,12 +27,6 @@
   ${strings.includeDirectives}:
     - '**cJSON.h'
 ${strings.comments}: false
-${strings.typeMap}:
-  ${strings.typeMapTypedefs}:
-    'size_t':
-      lib: 'pkg_ffi'
-      c-type: 'Size'
-      dart-type: 'int'
 ${strings.preamble}: |
   // Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
   //
diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_imported_types_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_imported_types_bindings.dart
new file mode 100644
index 0000000..dc8ca23
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_imported_types_bindings.dart
@@ -0,0 +1,82 @@
+// ignore_for_file: camel_case_types
+
+// AUTO GENERATED FILE, DO NOT EDIT.
+//
+// Generated by `package:ffigen`.
+import 'dart:ffi' as ffi;
+import 'package:ffi/ffi.dart' as pkg_ffi;
+
+/// Imported types test
+class NativeLibrary {
+  /// Holds the symbol lookup function.
+  final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
+      _lookup;
+
+  /// The symbols are looked up in [dynamicLibrary].
+  NativeLibrary(ffi.DynamicLibrary dynamicLibrary)
+      : _lookup = dynamicLibrary.lookup;
+
+  /// The symbols are looked up with [lookup].
+  NativeLibrary.fromLookup(
+      ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
+          lookup)
+      : _lookup = lookup;
+
+  void default_imported_types(
+    int arg0,
+    int arg1,
+    int arg2,
+    int arg3,
+    int arg4,
+    int arg5,
+    int arg6,
+    int arg7,
+    int arg8,
+    int arg9,
+    int arg10,
+    double arg11,
+    double arg12,
+    int arg13,
+    int arg14,
+  ) {
+    return _default_imported_types(
+      arg0,
+      arg1,
+      arg2,
+      arg3,
+      arg4,
+      arg5,
+      arg6,
+      arg7,
+      arg8,
+      arg9,
+      arg10,
+      arg11,
+      arg12,
+      arg13,
+      arg14,
+    );
+  }
+
+  late final _default_imported_typesPtr = _lookup<
+      ffi.NativeFunction<
+          ffi.Void Function(
+              pkg_ffi.UnsignedChar,
+              pkg_ffi.SignedChar,
+              pkg_ffi.Char,
+              pkg_ffi.UnsignedShort,
+              pkg_ffi.Short,
+              pkg_ffi.UnsignedInt,
+              pkg_ffi.Int,
+              pkg_ffi.UnsignedLong,
+              pkg_ffi.Long,
+              pkg_ffi.UnsignedLongLong,
+              pkg_ffi.LongLong,
+              ffi.Float,
+              ffi.Double,
+              pkg_ffi.Size,
+              pkg_ffi.WChar)>>('default_imported_types');
+  late final _default_imported_types = _default_imported_typesPtr.asFunction<
+      void Function(int, int, int, int, int, int, int, int, int, int, int,
+          double, double, int, int)>();
+}
diff --git a/pkgs/ffigen/test/header_parser_tests/imported_types.h b/pkgs/ffigen/test/header_parser_tests/imported_types.h
new file mode 100644
index 0000000..685e47c
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/imported_types.h
@@ -0,0 +1,23 @@
+// Copyright (c) 2022, 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.
+
+#include <stddef.h>
+
+void default_imported_types(
+  unsigned char,
+  signed char,
+  char,
+  unsigned short,
+  short,
+  unsigned int,
+  int,
+  unsigned long,
+  long,
+  unsigned long long,
+  long long,
+  float,
+  double,
+  size_t,
+  wchar_t
+);
diff --git a/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart b/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart
new file mode 100644
index 0000000..a018af2
--- /dev/null
+++ b/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2022, 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.
+
+import 'package:ffigen/src/code_generator.dart';
+import 'package:ffigen/src/config_provider.dart';
+import 'package:ffigen/src/header_parser.dart' as parser;
+import 'package:ffigen/src/strings.dart' as strings;
+import 'package:test/test.dart';
+import 'package:yaml/yaml.dart' as yaml;
+
+import '../test_utils.dart';
+
+late Library actual, expected;
+
+void main() {
+  group('imported_types_test', () {
+    setUpAll(() {
+      logWarnings();
+      actual = parser.parse(
+        Config.fromYaml(yaml.loadYaml('''
+${strings.name}: 'NativeLibrary'
+${strings.description}: 'Imported types test'
+${strings.output}: 'unused'
+
+${strings.headers}:
+  ${strings.entryPoints}:
+    - 'test/header_parser_tests/imported_types.h'
+  ${strings.includeDirectives}:
+    - '**imported_types.h'
+
+${strings.preamble}: |
+  // ignore_for_file: camel_case_types
+        ''') as yaml.YamlMap),
+      );
+    });
+    test('Expected Bindings', () {
+      matchLibraryWithExpected(actual, [
+        'test',
+        'debug_generated',
+        'header_parser_imported_types_test_output.dart'
+      ], [
+        'test',
+        'header_parser_tests',
+        'expected_bindings',
+        '_expected_imported_types_bindings.dart'
+      ]);
+    });
+  });
+}