tatumizer / pigeon_map Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I use this ISSUE simply as a draft copy of posts I'm going to send elsewhere.
Alex, thanks for this extremely useful package, it is working very well right out of the box. I wanted to echo Andrés Viedma's comments from the Dart-Misc mailing list and ask if it would be easy for you to add support for missing fields in Pigeon Structs.
I'm not sure about Andrés but I would be alright with these fields deserializing into uninitialized null values. I took a quick try at hacking it in but I was unable to cope with all the downstream effects of my edits. During serialization, it would be preferable for me to have null struct fields disappear entirely, although your package may be doing this already, I have not tested.
The use case for me is with wrapper messages that can hold a number of different content types. My current workaround is to use a list for each field but If I need to store a large number of these structs as JSON, having all of these fields with no values will get expensive. However, if null fields disappear when serialized and non-existent fields are set as null during deserialization then my storage and transfer costs can be minimized.
The other workaround that comes to mind is using the standard dart library to deserialize the JSON into a map, check for existence, and then convert fields into PigeonStructs if they exist but then I'm paying for two parses.
Please let me know if that makes sense, I can provide an example, or if there's some easier approach you know of that I'm not seeing. Thanks again!
This is a notebook on dart mirrors
print("location ${declaration.location} isClass=${declaration is ClassMirror}");
if (declaration is ClassMirror) {
if (declaration.simpleName.name == "X") {
declaration.invoke(#staticMethod, []);
}
} else if (declaration is MethodMirror) { // for top-level functions
if (declaration.simpleName == Symbol("foo")) {
library.invoke(Symbol("foo"), []);
}
}
extension SymbolNameExt on Symbol {
String get name {
var str = this.toString();
if (!str.startsWith('Symbol("')) throw 'Weird symbol $str - BUG!';
return str.substring(str.indexOf('"') + 1, str.lastIndexOf('"'));
}
}
reading annotations
for (var meta in declaration.metadata) {
if (meta.type == reflectClass(ExampleAnnotation)) {
//print("simple name: ${declaration.simpleName.name}");
//print(meta.getField(#value));
}
}
}
computing effective file name with a default directory
extension on Options {
String get effectiveFileName {
if (this.destinationFilePath != null) return this.destinationFilePath!;
String scriptPath = Platform.script.toFilePath();
String dirname = path.dirname(scriptPath);
String mainFileName = path.basenameWithoutExtension(scriptPath);
return '$dirname/$mainFileName.g.dart';
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.