dart-gde/chrome_gen.dart — pull request #117 by financeCoding (2013-11-23 06:54:55+00:00)
Title: generating classes for the object bags

Not bad but two things are fishy. The way in choosing the class names is prone to collisions in the library namespace. Only happens with extensions. Class names are generated as `ParamsObject`. Example `create1ParamsObject` if `createParamsObject` was already taken.

The other issue is dealing with very specific json/javascript api design. I've only seen this in a one or two places so far. An example can be seen with `setIcon` function. The parameter value is `choice` could be of a "type $ref" or of another javascript object that has members and values. Its very specific cases like this that could be a good reason to refactor the IDL. I guess one way we could handle it is to generate some kind of special function.

```
{
"name": "setIcon",
"type": "function",
"description": "Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the path or the imageData property must be specified.",
"parameters": [
{
"name": "details",
"type": "object",
"properties": {
"imageData": {
"choices": [
{ "$ref": "ImageDataType" },
{
"type": "object",
"properties": {
"19": {"$ref": "ImageDataType", "optional": true},
"38": {"$ref": "ImageDataType", "optional": true}
}
}
],
"optional": true,
"description": "Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}'"
},
"path": {
"choices": [
{ "type": "string" },
{
"type": "object",
"properties": {
"19": {"type": "string", "optional": true},
"38": {"type": "string", "optional": true}
}
}
],
"optional": true,
"description": "Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals scale, then image with size scale * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'"
},
"tabId": {
"type": "integer",
"optional": true,
"description": "Limits the change to when a particular tab is selected. Automatically resets when the tab is closed."
}
}
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": []
}
]
}
```