Scripting interface

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Scripting interface

lasconic
Administrator
Hi,
I just see that some work has been done on the scripting interface. What is the plan ?
I see that a new proxy object ScScore has been introduced. Probably stupid question, but why a proxy object and not using the score directly by restricting the available functions ?

Lasconic

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer
Reply | Threaded
Open this post in threaded view
|

Re: Scripting interface

wschweer
Administrator
Hi,

the qt scripting interface is a complicated beast i just started learning. In
addition i'm also new to java script and just learned that its very different
from conventional languages like java or c++. So i am not sure using a proxy
class is the best solution for what i want to do. It was the only way i found
to be able to create new scores in the c++ domain. It also gives detailed
control over script actions (set/get properties). There are also some mscore
classes which are not derived from QObject (and cannot be form some reason) i
think this is the way to go.
Short time goal is to implement a framework for the following script test
code:

      print("script: set note names");
      var cursor = new Cursor(curScore);
      cursor.staff = 0;
      cursor.voice = 0;
      cursor.rewind();
      while (!cursor.eos()) {
            var chord = cursor.chord();
            var note  = chord.topNote();
            var noteName = note.name();
            cursor.putStaffText(noteName);  // create note name text
            cursor.next();
            }

A Cursor object is used to move over the chord/rest objects and to inspect
values and create new score objects.

/Werner


 
On Friday 13 February 2009 12:41:33 Lasconic wrote:
> Hi,
> I just see that some work has been done on the scripting interface. What is
> the plan ?
> I see that a new proxy object ScScore has been introduced. Probably stupid
> question, but why a proxy object and not using the score directly by
> restricting the available functions ?
>
> Lasconic


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer
Reply | Threaded
Open this post in threaded view
|

Re: Scripting interface

lasconic
Administrator
Ok, My past experiment with Qtscript and musescore was quite good without that. That's why I ask.
I was able to get the score and call methods on it if declared Q_INVOKABLE. (like saveXML() or nbstaves() in score.h).
I was also able to instantiate QFile or QByteArray with

var musicXMLfile = new QFile(pathToMusicXML);


Regarding QtScript itself, I know that Canorus uses another scripting engine, and enables the use of other languages like ruby, python.
During my investigation I read about SWIG as well. http://www.swig.org/
Why the choice of QtScript ?

Lasconic


2009/2/13 Werner Schweer <[hidden email]>
Hi,

the qt scripting interface is a complicated beast i just started learning. In
addition i'm also new to java script and just learned that its very different
from conventional languages like java or c++. So i am not sure using a proxy
class is the best solution for what i want to do. It was the only way i found
to be able to create new scores in the c++ domain. It also gives detailed
control over script actions (set/get properties). There are also some mscore
classes which are not derived from QObject (and cannot be form some reason) i
think this is the way to go.
Short time goal is to implement a framework for the following script test
code:

     print("script: set note names");
     var cursor = new Cursor(curScore);
     cursor.staff = 0;
     cursor.voice = 0;
     cursor.rewind();
     while (!cursor.eos()) {
           var chord = cursor.chord();
           var note  = chord.topNote();
           var noteName = note.name();
           cursor.putStaffText(noteName);  // create note name text
           cursor.next();
           }

A Cursor object is used to move over the chord/rest objects and to inspect
values and create new score objects.

/Werner



On Friday 13 February 2009 12:41:33 Lasconic wrote:
> Hi,
> I just see that some work has been done on the scripting interface. What is
> the plan ?
> I see that a new proxy object ScScore has been introduced. Probably stupid
> question, but why a proxy object and not using the score directly by
> restricting the available functions ?
>
> Lasconic


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer
Reply | Threaded
Open this post in threaded view
|

Re: Scripting interface

wschweer
Administrator
When you instantiate a qt object like QFile in the interpreter, this object
exists in the interpreter domain, not in the c++ domain. That's ok but if you
want to manipulate the mscore data structures, all data exists in the c++
domain. I think I its not feasible to move all data to qscript on script start
and back on script end so the script interface has to act like a proxy to the
real data.
Regarding qt script this obviously works best with scripting qt guis. I don't
have special emotions with qt script or any other scripting languages. But it
should be clear that i don't want to (and cannot) support different languages
(through swig for example).
What i can imagine is a binary(c++) plugin interface which can access the
"real thing". This could be implemented very straight forward as the necessary
things are already implemented in qt (and should be platform independent).

On Friday 13 February 2009 15:54:01 Lasconic wrote:

> Ok, My past experiment with Qtscript and musescore was quite good without
> that. That's why I ask.
> I was able to get the score and call methods on it if declared Q_INVOKABLE.
> (like saveXML() or nbstaves() in score.h).
> I was also able to instantiate QFile or QByteArray with
>
> var musicXMLfile = new QFile(pathToMusicXML);
>
>
> Regarding QtScript itself, I know that Canorus uses another scripting
> engine, and enables the use of other languages like ruby, python.
> During my investigation I read about SWIG as well. http://www.swig.org/
> Why the choice of QtScript ?
>
> Lasconic
>
>
> 2009/2/13 Werner Schweer <[hidden email]>
>
> > Hi,
> >
> > the qt scripting interface is a complicated beast i just started
> > learning. In
> > addition i'm also new to java script and just learned that its very
> > different
> > from conventional languages like java or c++. So i am not sure using a
> > proxy
> > class is the best solution for what i want to do. It was the only way i
> > found
> > to be able to create new scores in the c++ domain. It also gives detailed
> > control over script actions (set/get properties). There are also some
> > mscore
> > classes which are not derived from QObject (and cannot be form some
> > reason) i
> > think this is the way to go.
> > Short time goal is to implement a framework for the following script test
> > code:
> >
> >      print("script: set note names");
> >      var cursor = new Cursor(curScore);
> >      cursor.staff = 0;
> >      cursor.voice = 0;
> >      cursor.rewind();
> >      while (!cursor.eos()) {
> >            var chord = cursor.chord();
> >            var note  = chord.topNote();
> >            var noteName = note.name();
> >            cursor.putStaffText(noteName);  // create note name text
> >            cursor.next();
> >            }
> >
> > A Cursor object is used to move over the chord/rest objects and to
> > inspect values and create new score objects.
> >
> > /Werner
> >
> > On Friday 13 February 2009 12:41:33 Lasconic wrote:
> > > Hi,
> > > I just see that some work has been done on the scripting interface.
> > > What
> >
> > is
> >
> > > the plan ?
> > > I see that a new proxy object ScScore has been introduced. Probably
> >
> > stupid
> >
> > > question, but why a proxy object and not using the score directly by
> > > restricting the available functions ?
> > >
> > > Lasconic
> >
> > -------------------------------------------------------------------------
> >----- Open Source Business Conference (OSBC), March 24-25, 2009, San
> > Francisco, CA
> > -OSBC tackles the biggest issue in open source: Open Sourcing the
> > Enterprise
> > -Strategies to boost innovation and cut costs with open source
> > participation
> > -Receive a $600 discount off the registration fee with the source code:
> > SFAD
> > http://p.sf.net/sfu/XcvMzF8H
> > _______________________________________________
> > Mscore-developer mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/mscore-developer


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer
Reply | Threaded
Open this post in threaded view
|

Re: Scripting interface

lasconic
Administrator
Thanks for the explanation !
It makes sense indeed to don't support several languages.
And it can make sense as well to provide the model as simple as possible to the plugin writers.
Regarding QtScript, I don't have emotions neither. My first impression is just that it's quite new and not used a lot. But as it is the official Qt way, indeed it should work best.


Regarding the C++ plugin interface

2009/2/13 Werner Schweer <[hidden email]>
When you instantiate a qt object like QFile in the interpreter, this object
exists in the interpreter domain, not in the c++ domain. That's ok but if you
want to manipulate the mscore data structures, all data exists in the c++
domain. I think I its not feasible to move all data to qscript on script start
and back on script end so the script interface has to act like a proxy to the
real data.
Regarding qt script this obviously works best with scripting qt guis. I don't
have special emotions with qt script or any other scripting languages. But it
should be clear that i don't want to (and cannot) support different languages
(through swig for example).
What i can imagine is a binary(c++) plugin interface which can access the
"real thing". This could be implemented very straight forward as the necessary
things are already implemented in qt (and should be platform independent).

On Friday 13 February 2009 15:54:01 Lasconic wrote:
> Ok, My past experiment with Qtscript and musescore was quite good without
> that. That's why I ask.
> I was able to get the score and call methods on it if declared Q_INVOKABLE.
> (like saveXML() or nbstaves() in score.h).
> I was also able to instantiate QFile or QByteArray with
>
> var musicXMLfile = new QFile(pathToMusicXML);
>
>
> Regarding QtScript itself, I know that Canorus uses another scripting
> engine, and enables the use of other languages like ruby, python.
> During my investigation I read about SWIG as well. http://www.swig.org/
> Why the choice of QtScript ?
>
> Lasconic
>
>
> 2009/2/13 Werner Schweer <[hidden email]>
>
> > Hi,
> >
> > the qt scripting interface is a complicated beast i just started
> > learning. In
> > addition i'm also new to java script and just learned that its very
> > different
> > from conventional languages like java or c++. So i am not sure using a
> > proxy
> > class is the best solution for what i want to do. It was the only way i
> > found
> > to be able to create new scores in the c++ domain. It also gives detailed
> > control over script actions (set/get properties). There are also some
> > mscore
> > classes which are not derived from QObject (and cannot be form some
> > reason) i
> > think this is the way to go.
> > Short time goal is to implement a framework for the following script test
> > code:
> >
> >      print("script: set note names");
> >      var cursor = new Cursor(curScore);
> >      cursor.staff = 0;
> >      cursor.voice = 0;
> >      cursor.rewind();
> >      while (!cursor.eos()) {
> >            var chord = cursor.chord();
> >            var note  = chord.topNote();
> >            var noteName = note.name();
> >            cursor.putStaffText(noteName);  // create note name text
> >            cursor.next();
> >            }
> >
> > A Cursor object is used to move over the chord/rest objects and to
> > inspect values and create new score objects.
> >
> > /Werner
> >
> > On Friday 13 February 2009 12:41:33 Lasconic wrote:
> > > Hi,
> > > I just see that some work has been done on the scripting interface.
> > > What
> >
> > is
> >
> > > the plan ?
> > > I see that a new proxy object ScScore has been introduced. Probably
> >
> > stupid
> >
> > > question, but why a proxy object and not using the score directly by
> > > restricting the available functions ?
> > >
> > > Lasconic
> >
> > -------------------------------------------------------------------------
> >----- Open Source Business Conference (OSBC), March 24-25, 2009, San
> > Francisco, CA
> > -OSBC tackles the biggest issue in open source: Open Sourcing the
> > Enterprise
> > -Strategies to boost innovation and cut costs with open source
> > participation
> > -Receive a $600 discount off the registration fee with the source code:
> > SFAD
> > http://p.sf.net/sfu/XcvMzF8H
> > _______________________________________________
> > Mscore-developer mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/mscore-developer


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mscore-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mscore-developer