← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #205906]: How does toJythonRegion in Region work and is it important?

 

Question #205906 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/205906

    Status: Open => Answered

RaiMan proposed the following answer:
Together with X-rc3, the developers started to streamline/consolidate
the 2 API levels (Jython/Python and Java): a method should exist on the
Python level only, if there are some Python specifics to handle. In all
other cases the Jython level should use the Java API directly.

One of the changes is in the Region classes (Python and Java), so that
the Java static Region() methods are deprecated on the Java level and
the Java programmers are advised to use Region.create() instead, so that
the calls to Region() are "reserved" for the Python users to create a
new Region object.

But the implementation is odd and incomplete, so that in any case (Python level or Java level) a Jython Region object is created, though this is not necessary, when being on the Java level as you are. And on top it makes problems, when you want to use observe() on the Java level (it simply does not work).
A comment in the source marks a TODO: ... determine if the caller is Jython 
... my addition: to avoid calling toJythonRegion, if caller is not Jython

So your finding is correct: the problem lies in toJythonRegion ...
... and to finally answer your question: ... and is it important?

If you stay on the Java level: no, it is not.

If you are interested: I made a version of the Region class for someone else who wanted to get observe() running on the Java level, so that toJythonRegion is not called, when you use Region.create() and is only used, when the deprecated Region() methods are called, which should only be from Jython.
https://dl.dropbox.com/u/42895525/sikuli-script-update_01.zip
I use this modified sikuli-script.jar and yes, the startup is a little bit faster.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.