Skip to content

Commit 0a16c09

Browse files
[interop] Support Classes and Interfaces (#415)
* Added files for test cases * Implemented Classes and Interfaces * spelling error with "hierarchy" :) * implemented optional methods and made fixes * fixed union issue with `typeMap` * removed redundant/completed TODOs * Spelling typo in "variadic" from "variardic" * refactored `getMemberHierarchy` and some other changes * completed typo fix * fixed config gen test * resolved all standing issues
1 parent 7e0853d commit 0a16c09

16 files changed

+2245
-191
lines changed

web_generator/lib/src/ast/base.dart

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ import '../interop_gen/namer.dart';
88
import 'types.dart';
99

1010
class GlobalOptions {
11-
static int variardicArgsCount = 4;
11+
static int variadicArgsCount = 4;
1212
static bool shouldEmitJsTypes = false;
13+
static bool redeclareOverrides = true;
1314
}
1415

1516
class Options {}
1617

17-
// TODO(nikeokoronkwo): Remove this once we address isNullable
1818
class DeclarationOptions extends Options {
19-
DeclarationOptions();
19+
bool override;
20+
21+
DeclarationOptions({this.override = false});
2022

2123
TypeOptions toTypeOptions({bool nullable = false}) =>
2224
TypeOptions(nullable: nullable);
@@ -31,11 +33,11 @@ class TypeOptions extends Options {
3133
class ASTOptions {
3234
bool parameter;
3335
bool emitJSTypes;
34-
int variardicArgsCount;
36+
int variadicArgsCount;
3537

3638
ASTOptions(
3739
{this.parameter = false,
38-
this.variardicArgsCount = 4,
40+
this.variadicArgsCount = 4,
3941
this.emitJSTypes = false});
4042
}
4143

@@ -74,3 +76,39 @@ abstract class Type extends Node {
7476
@override
7577
Reference emit([covariant TypeOptions? options]);
7678
}
79+
80+
abstract class FieldDeclaration extends NamedDeclaration {
81+
abstract final Type type;
82+
}
83+
84+
abstract class CallableDeclaration extends NamedDeclaration {
85+
abstract final List<ParameterDeclaration> parameters;
86+
87+
abstract final List<GenericType> typeParameters;
88+
89+
abstract final Type returnType;
90+
}
91+
92+
enum DeclScope { private, protected, public }
93+
94+
class ParameterDeclaration {
95+
final String name;
96+
97+
final bool optional;
98+
99+
final Type type;
100+
101+
final bool variadic;
102+
103+
ParameterDeclaration(
104+
{required this.name,
105+
this.optional = false,
106+
required this.type,
107+
this.variadic = false});
108+
109+
Parameter emit([DeclarationOptions? options]) {
110+
return Parameter((p) => p
111+
..name = name
112+
..type = type.emit(TypeOptions(nullable: optional)));
113+
}
114+
}

0 commit comments

Comments
 (0)