Your Digital Media Has Never Looked So Good

 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

roXmlList implements ifArray, apparently (+ a mystery)

Wed Sep 03, 2014 9:21 pm

Just discovered that roXmlList supports ifArray methods:
BrightScript Debugger> rXL = createObject("roXmlList")
BrightScript Debugger> rXL.push("something")
BrightScript Debugger> ? type(rXL), rXL.count(), rXL[0]
roXMLList               1              something
BrightScript Debugger> ? getInterface(rXL, "ifArray")
<Interface: ifArray>

It is undocumented as of now. The significance is that array operations can be used to go over a roXmlList - and notably, .count().
Last edited by EnTerr on Mon Sep 08, 2014 12:06 pm, edited 1 time in total.
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: roXmlList implements ifArray, apparently

Mon Sep 08, 2014 12:49 am

EnTerr wrote:
The significance is that array operations can be used to go over a roXmlList - and notably, .count().

.Count() is an ifList method.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: roXmlList implements ifArray, apparently

Mon Sep 08, 2014 1:23 am

TheEndless wrote:
.Count() is an ifList method.

Hm, yeah - .count() is a method of both ifList and ifArray, good catch. But check this out - seems when you use count() on roXmlList, it's neither ifList's nor ifArray's:
BrightScript Debugger> ? rXL.count()
 1
BrightScript Debugger> ? rXL.ifList.count()
 0
BrightScript Debugger> ? rXL.ifArray.count()
 0

Huuuh? :shock:
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: roXmlList implements ifArray, apparently

Mon Sep 08, 2014 9:40 am

EnTerr wrote:
TheEndless wrote:
.Count() is an ifList method.

Hm, yeah - .count() is a method of both ifList and ifArray, good catch. But check this out - seems when you use count() on roXmlList, it's neither ifList's nor ifArray's:
BrightScript Debugger> ? rXL.count()
 1
BrightScript Debugger> ? rXL.ifList.count()
 0
BrightScript Debugger> ? rXL.ifArray.count()
 0

Huuuh? :shock:

From the BrightScript Language Reference:

specifying the interface with the dot operator is optional. If it is left out ,... , each interface in the object is searched for the member function. If there is a conflict (a member function with the same name appearing in two interfaces), then the interface should be specified.
https://github.com/belltown/
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: roXmlList implements ifArray, apparently

Mon Sep 08, 2014 12:00 pm

belltown wrote:
From the BrightScript Language Reference:
specifying the interface with the dot operator is optional. If it is left out ,... , each interface in the object is searched for the member function. If there is a conflict (a member function with the same name appearing in two interfaces), then the interface should be specified.

Right, i knew that. That is what i showed, "explicifying" the interface to use.

But which .count() returns 1 if it isn't ifList's nor ifArray's? ifXmlList has no .count()...
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: roXmlList implements ifArray, apparently (+ a mystery)

Mon Sep 08, 2014 1:33 pm

It's the mystery, undocumented Count().

Isn't it just a little annoying that the Roku docs don't tell the whole picture?

Speaking of undocumented features, I just found out a few minutes ago that roAudioPlayer supports live streaming AAC audio. For years, the documentation has been adamant that it only supports WMA and MP3.
https://github.com/belltown/
 
User avatar
RokuKC
Posts: 315
Joined: Wed Sep 10, 2014 10:44 am
Location: Roku HQ

Re: roXmlList implements ifArray, apparently

Thu Sep 18, 2014 4:28 pm

EnTerr wrote:
Hm, yeah - .count() is a method of both ifList and ifArray, good catch. But check this out - seems when you use count() on roXmlList, it's neither ifList's nor ifArray's:
BrightScript Debugger> ? rXL.count()
 1
BrightScript Debugger> ? rXL.ifList.count()
 0
BrightScript Debugger> ? rXL.ifArray.count()
 0



This isn't calling rXL interface methods, but instead returning the list of its children with those names.

From the BrightScript Language Reference:

3.7.2 Dot Operator

The dot operator can be used on any BrightScript Component. It also has special meaning when used on any roAssociativeArray, roXMLElement or roXMLList.
...
See the section on XML support for details on using the dot operator on xml objects.


4.5 BrightScript XML Support
...
Dot Operator

1.When applied to an roXMLElement, the dot operator returns an roXMLList of children that match the dot operand. If no tags match, an empty list is returned.
2.When applied to an roXMLList, the dot operator aggregates the results of performing the dot operator on each roXMLElement in the list.
...


Example:

BrightScript Debugger> xml = CreateObject("roXMLElement")
BrightScript Debugger> xml.Parse("<a> <ifArray>1</ifArray> <ifList>b</ifList> <ifArray>2</ifArray> <ifArray>3</ifArray> </a>")
BrightScript Debugger> ? xml.ifArray.Count()
 3
BrightScript Debugger> ? xml.ifList.Count()
 1
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: roXmlList implements ifArray, apparently

Fri Sep 19, 2014 10:34 am

RokuKC wrote:
EnTerr wrote:
Hm, yeah - .count() is a method of both ifList and ifArray, good catch. But check this out - seems when you use count() on roXmlList, it's neither ifList's nor ifArray's:
BrightScript Debugger> ? rXL.count()
 1
BrightScript Debugger> ? rXL.ifList.count()
 0
BrightScript Debugger> ? rXL.ifArray.count()
 0

This isn't calling rXL interface methods, but instead returning the list of its children with those names.

Oh wow, good catch!
Thank you, i assumed that dot-named interfaces always take precedence. To quote the relevant part of 3.7.2:
3.7.2 Dot Operator wrote:
...
When used on a BrightScript Component, it refers to an interface or a member function.
Example
i = CreateObject("roInt")
i.ifInt.SetInt(5)
i.SetInt(5)

"ifInt" is the interface, and "SetInt" is the member function. Every member function of a BrightScript Component is part of an interface. However, specifying the interface with the dot operator is optional. If it is left out, as in the last line of the example above, each interface in the object is searched for the member function. If there is a conflict (a member function with the same name appearing in two interfaces), then the interface should be specified.

Why is it that method resolution takes precedence over roXmlList-specific-dotting - but interface resolution does not? In other words, why "rXL.count()" works and "rXL.ifArray.count()" does not - when doco says both should work?

Because a component may implement 2 interfaces with overlapping method names (as the case is here - roXmlList implements both ifList and ifArray and both have .count()s ) - there should always be a way to "explicitate" which of the two methods i want, shouldn't it?!
 
destruk
Posts: 2720
Joined: Sat Dec 18, 2010 4:58 pm

Re: roXmlList implements ifArray, apparently (+ a mystery)

Fri Sep 19, 2014 3:02 pm

belltown wrote:
It's the mystery, undocumented Count().

Isn't it just a little annoying that the Roku docs don't tell the whole picture?

Speaking of undocumented features, I just found out a few minutes ago that roAudioPlayer supports live streaming AAC audio. For years, the documentation has been adamant that it only supports WMA and MP3.


" The component understands the following streamformat values: "mp3", "wma", "mp4", "hls", "es.aac-adts", "flac""
http://sdkdocs.roku.com/display/sdkdoc/roAudioPlayer

It's been updated
 
belltown
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm
Contact:

Re: roXmlList implements ifArray, apparently (+ a mystery)

Fri Sep 19, 2014 3:11 pm

destruk wrote:
belltown wrote:
It's the mystery, undocumented Count().

Isn't it just a little annoying that the Roku docs don't tell the whole picture?

Speaking of undocumented features, I just found out a few minutes ago that roAudioPlayer supports live streaming AAC audio. For years, the documentation has been adamant that it only supports WMA and MP3.


" The component understands the following streamformat values: "mp3", "wma", "mp4", "hls", "es.aac-adts", "flac""
http://sdkdocs.roku.com/display/sdkdoc/roAudioPlayer

It's been updated

Thanks. I just noticed that myself. AAC and FLAC don't seem to work on 3.1 fw though.
https://github.com/belltown/
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: roXmlList implements ifArray, apparently (+ a mystery)

Sun Sep 21, 2014 1:24 pm

belltown wrote:
It's the mystery, undocumented Count().
Isn't it just a little annoying that the Roku docs don't tell the whole picture?

It sure is annoying, to say the least. It is also counter-productive, having to spend time experimenting things that should be able to find with a glance at documentation. Or the cases when they fail to mention there are version issues (i.e. something not supported in fw3) - that is negligence.

I have proposed in the past, if RokuCo cannot muster the workforce to maintain the docs - then to give access to select few of the outside dev.community, so they can fix obvious mistakes and omissions. Sure it's a touchy subject but if the attitude is "we could do this ourselves", they should as well do it. As @squirreltown put it aptly elsewhere, "This is just embarrassing. Like people who bondo their dents but never paint them. So close to finishing the job and then....Squirrel!"

To the limited extent i could, i try to help - in two steps:
1. When i discover omission/issue in the docs, i post a separate thread on that (so a discussion or explanation may happen) and
2. Link to it in viewtopic.php?f=34&t=69731 , in hopes that some faithful day someone may start going over these and resolving them. (admittedly i have slacked recently on linking there, should catch up)

Sometimes attempts of Roku personnel to help may end up making things worse though. There is a case that still bothers me but i just couldn't figure mentioning it without being complete arse. Because the person who did the edit i am sure had good intent and probably acted to the best of their abilities but... their "fix" made things worse than they were. I was asking about ifGetMessagePort/ifSetMessagePort of roCaptionRenderer - why they were not returned by getInterface. And then someone apparently decided "solution" to that was to just delete ifGetMessagePort/ifSetMessagePort from the page. It feels as if i called the city water district to report a water mains leak and their solution ended being to turn off the water supply for the neighborhood... permanently. Doh.

PS. First step to fixing a problem is admitting there is a problem - but i don't know if even internally RokuCo admits there is one.
 
User avatar
RokuKC
Posts: 315
Joined: Wed Sep 10, 2014 10:44 am
Location: Roku HQ

Re: roXmlList implements ifArray, apparently (+ a mystery)

Tue Sep 23, 2014 5:28 pm

EnTerr wrote:
...
I was asking about ifGetMessagePort/ifSetMessagePort of roCaptionRenderer - why they were not returned by getInterface. And then someone apparently decided "solution" to that was to just delete ifGetMessagePort/ifSetMessagePort from the page.
...


That is correct. roCaptionRenderer does not support ifGetMessagePort/ifSetMessagePort.
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: roXmlList implements ifArray, apparently (+ a mystery)

Tue Sep 23, 2014 5:46 pm

RokuKC wrote:
EnTerr wrote:
...
I was asking about ifGetMessagePort/ifSetMessagePort of roCaptionRenderer - why they were not returned by getInterface. And then someone apparently decided "solution" to that was to just delete ifGetMessagePort/ifSetMessagePort from the page.
...


That is correct. roCaptionRenderer does not support ifGetMessagePort/ifSetMessagePort.

Err.. While whoever wrote the component may not have explicitly implemented the interfaces themselves, it should be pointed out that the roCaptionRenderer absolutely has (at least) a SetMessagePort() method. SetMessagePort() is required in order to get the roCaptionRenderEvents, which are kind of critical to the whole implementation. Implementing the method without implementing the interface is just an attempt to confuse us, I guess.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
EnTerr
** Valued Community Member **
Topic Author
Posts: 3834
Joined: Sun Jan 02, 2011 2:41 am

Re: roXmlList implements ifArray, apparently (+ a mystery)

Tue Sep 23, 2014 6:42 pm

TheEndless wrote:
Implementing the method without implementing the interface is just an attempt to confuse us, I guess.

Well if that was the goal - "Mission accomplished!" :twisted:

Because the above quoted 3.7.2 says
Every member function of a BrightScript Component is part of an interface.

"Every" method belongs to an interface, it said - not "most", "many" or "oftentimes".
And that made sense to me, seemed like a law of nature - until i saw this. Is that no longer true?
Could orphan methods exist or is roCaptionRenderer.setMessagePort() a member of a "secret" interface?

My point was that the cure was worse than the disease: if ifSetMessagePort was removed from roCaptionRenderer doco, mentioning setMessagePort() should have replaced it.
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: roXmlList implements ifArray, apparently (+ a mystery)

Tue Sep 23, 2014 7:12 pm

EnTerr wrote:
"Every" method belongs to an interface, it said - not "most", "many" or "oftentimes".
And that made sense to me, seemed like a law of nature - until i saw this. Is that no longer true?
Could orphan methods exist or is roCaptionRenderer.setMessagePort() a member of a "secret" interface?

My point was that the cure was worse than the disease: if ifSetMessagePort was removed from roCaptionRenderer doco, mentioning setMessagePort() should have replaced it.

SetMessagePort is there, and technically it is part of an interface... it was just, inexplicably, added to the ifCaptionRenderer interface instead: http://sdkdocs.roku.com/display/sdkdoc/ ... jectasVoid
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

Who is online

Users browsing this forum: No registered users and 7 guests