Smoke is a package that exposes a reduced reflective system API. This API includes accessing objects in a dynamic fashion (read properties, write properties, and call methods), inspecting types (for example, whether a method exists), and symbol/string convertion.
The package provides a default implementation of this API that uses the system's mirrors, but additionally provides mechanisms for statically generating code that can replace the mirror-based implementation.
The intention of this package is to allow frameworks to use mirrors in a way that will not impose on their users. The idea is that users will not worry about how to preserve symbols when compiling with dart2js (for instance, using the MirrorsUsed annotation). Instead, this package provides the building blocks to autogenerate whatever is needed for dart2js to be happy and to generate reasonable code.
Note this package alone doesn't know how to generate everything, but it provides a simple API that different frameworks can use to define what needs to be generated.
package:smoke/smoke.dart in your framework to read and write objects and
to inspect type information. Read the Dart-docs for more details.
package:smoke/codegen/recorder.dart in your transformer to create a static
initialization that can be used by smoke. The test under
test/codegen/end_to_end_test.dart is a good illustrating example to learn how
to use these APIs.
dynamictype appeared in the output. Smoke will now use
Add this to your package's pubspec.yaml file:
dependencies: smoke: "^0.3.2"
You can install packages from the command line:
$ pub get
Alternatively, your editor might support
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|0.3.6+3||May 2, 2017|
|0.3.6+2||Mar 29, 2016|
|0.3.6+1||Mar 18, 2016|
|0.3.6||Dec 11, 2015|
|0.3.5||Aug 19, 2015|
|0.3.4||Jul 8, 2015|
|0.3.3+1||May 11, 2015|
|0.3.3||Apr 30, 2015|
|0.3.2||Mar 25, 2015|
|0.3.1+1||Mar 18, 2015|
We analyzed this package, and provided a score, details, and suggestions below.
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Error(s) in lib/codegen/recorder.dart: The getter 'metadata' isn't defined for the class 'AstNode'.
Strong-mode analysis of
lib/codegen/recorder.dartfailed with the following error:
line: 260 col: 17
The getter 'metadata' isn't defined for the class 'AstNode'.
Strong-mode analysis of
lib/mirrors.dartfailed with the following error:
line: 78 col: 30
The getter 'declarations' isn't defined for the class 'TypeMirror'.
Fix further 1 Dart files.
Similar analysis of the following files failed: