| |
| Posted by Chris Wright | PermalinkReply |
|
Chris Wright
| http://d.puremagic.com/issues/show_bug.cgi?id=4477
Summary: JSON output for function definitions includes
insufficient type information
Product: D
Version: D1 & D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody@puremagic.com
ReportedBy: dhasenan@gmail.com
--- Comment #0 from Chris Wright <dhasenan@gmail.com> 2010-07-17 09:35:15 PDT ---
Consider:
---
class A {}
void foo(A a) {}
void bar(ref A a) {}
void frob(A a = null) {}
---
dmd -X on this outputs the following type information for functions foo, bar,
and frob:
"type": "void(A a)" // foo
"type": "void(ref A a)" // bar
"type": "void(A a = cast(A)null)" // frob
There are a few issues with this:
- To determine what the arguments are, I need to parse a string. This is
undesirable. (Additionally, I can't parse it with regular expressions, since a
function might take a delegate or templated type as a parameter.)
- Even if I go through the trouble of parsing the string, I *still* only have
the type name. Not even the fully qualified name. So I have no idea where to
locate the type definition.
- The names of function parameters are included, making it harder to find the
types.
- Default parameters are also included here.
Suggested solution: change "type" property to an object. For user-defined types, include at a minimum the fully qualified name, as given by demangle(T.mangleof). For function types, include an array of parameter objects, each of which can include a name, a type, a storage class, and a default value.
{
"name": "frob",
"type": {
"return-value:" "void",
"parameters": [
{
"name": "a",
"type": "test.A",
"storage-class": "in",
"default-value": "cast(test.A)null"
}
]
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
|