tonylukasavage / triple

REPL for Titanium
MIT License
96 stars 21 forks source link

Use "apiName" to help list proxy properties #65

Open tonylukasavage opened 10 years ago

tonylukasavage commented 10 years ago

If you attempt to inspect a Titanium namespace or Titanium proxy, you get some pretty lackluster results due to the nature of Titanium proxies:

≫ triple
[launching app]
> typeof Titanium.XML
'object'
> Ti.XML.apiName
'Ti.XML'
> Ti.XML
undefined

So we know it's an object and that it has an apiName, but beyond that, normal inspection just doesn't work.

It would be awesome when returning the inspection value if we did the following:

  1. checked to see if it is a Titanium proxy (weak check for apiName will work for now)
  2. If it's not, then just return the value as usual
  3. If it is a proxy, use the apiName and the api.jsca file (which we're already loading for tab completion) to create a proxy of the proxy (yikes) which has all the appropriate properties and values attached to it, via manual assignments based on the api.jsca data.
  4. Now that we have a real JS object and not a Titanium proxy, we can pass it through the normal inspection return value function and we should get a full listing of all properties and values.
  5. Voila, full inspection of Titanium proxies