Loading a class by name

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

Loading a class by name

Joachim Baran
Hi!

Is it possible to instantiate an object just by its classname?

I would like to dynamically load classes into my application that are
given under "build-script"/"settings" in config.json. Right now, I am
trying to see of the class is available in general by calling
'qx.Class.isDefined("test.Contribution");'. Surprisingly (to me) the
method returns 'false' unless I explicitly create an object with 'new
test.Contribution();' first. Of course, I would like to avoid that,
because I want do not want to modify my application and instead only
"plug-in" objects by just giving their classnames.

Thanks,
Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

florian_im-conepts
Hello Joachim!

Did you try this with the source or build version of your qooxdoo application? In the buid version only classes are loaded which are used by your script (I don't know, how the source version behaves. Maybe you can use a generator option like --source-all. See the "Generator" section in the qooxdoo manual). IMHO this is one of the main optimisations the generator performs. 

You should have a look at the package loading system. With this you can load packages (and the included classes) on demand at runtime (http://qooxdoo.org/documentation/1.0/parts_using). 


Regards, Florian


On 13 April 2010 20:24, Joachim Baran <[hidden email]> wrote:
Hi!

Is it possible to instantiate an object just by its classname?

I would like to dynamically load classes into my application that are
given under "build-script"/"settings" in config.json. Right now, I am
trying to see of the class is available in general by calling
'qx.Class.isDefined("test.Contribution");'. Surprisingly (to me) the
method returns 'false' unless I explicitly create an object with 'new
test.Contribution();' first. Of course, I would like to avoid that,
because I want do not want to modify my application and instead only
"plug-in" objects by just giving their classnames.

Thanks,
Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Alexander Steitz
In reply to this post by Joachim Baran
Hi Joachmin,

On Tuesday April 13 2010 20:24:54 Joachim Baran wrote:

> Is it possible to instantiate an object just by its classname?
>
> I would like to dynamically load classes into my application that are
> given under "build-script"/"settings" in config.json. Right now, I am
> trying to see of the class is available in general by calling
> 'qx.Class.isDefined("test.Contribution");'. Surprisingly (to me) the
> method returns 'false' unless I explicitly create an object with 'new
> test.Contribution();' first. Of course, I would like to avoid that,
> because I want do not want to modify my application and instead only
> "plug-in" objects by just giving their classnames.
The generator need to have knowledge about the classes you want to use. If the
necessary classes can't be obtained by analyzing the source code you have to
add these classes manually so the generator knows them.

You can do this by either adding an "include" block into a job in your
config.json or you place a "#require" hint at the source code files.

--snip--
/* ******************************************
#require(namespace.class)
****************************************** */
--snip--

This way the generator resolves these classes and you can use them at runtime.

cheers,
  Alex

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Joachim Baran
Hi,

Thanks Alexander and Florian, but unfortunately I cannot get it to work.

> #require(namespace.class)
I have tried #require(mylib.Contribution) in both the application's
class as well as the contribution's class without any luck.

I then modified my config.json like this:
  "jobs" :
  {
    "source" :
    {
      "require" :
      {
        "myapp.Application" : [ "mylib.Contribution" ]
      }
    }
  }
Unfortunately, this did not work either.

The manual on qooxdoo.org is a bit sparse on this issue, so perhaps
you could give me another hint how to fix this?

The actual code, qx.Class.isDefined("mylib.Contribution"), is called
in the main function of myapp.Application, which I compile with
'build'.

Thanks for the help,
Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Werner Thie
Hi

Digging through the source made me aware of the #use statement.

So, use like this for fine tuning availability of whatever code in
source and build mode in your Application.js or deeper down the
hierarchy file:

#use(qx.ui.root.Inline)
#use(qx.ui.layout.VBox)
#use(qx.ui.form.Button)
#use(qx.fx.effect.core.Move)

Works like a charm!

HTH, Werner

On 14.04.2010 16:38, Joachim Baran wrote:

> Hi,
>
> Thanks Alexander and Florian, but unfortunately I cannot get it to work.
>
>> #require(namespace.class)
> I have tried #require(mylib.Contribution) in both the application's
> class as well as the contribution's class without any luck.
>
> I then modified my config.json like this:
>    "jobs" :
>    {
>      "source" :
>      {
>        "require" :
>        {
>          "myapp.Application" : [ "mylib.Contribution" ]
>        }
>      }
>    }
> Unfortunately, this did not work either.
>
> The manual on qooxdoo.org is a bit sparse on this issue, so perhaps
> you could give me another hint how to fix this?
>
> The actual code, qx.Class.isDefined("mylib.Contribution"), is called
> in the main function of myapp.Application, which I compile with
> 'build'.
>
> Thanks for the help,
> Joachim
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

werner.vcf (311 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Alexander Steitz
In reply to this post by Joachim Baran
Hi Joachim,

On Wednesday April 14 2010 16:38:55 Joachim Baran wrote:

> I have tried #require(mylib.Contribution) in both the application's
> class as well as the contribution's class without any luck.
>
> I then modified my config.json like this:
>   "jobs" :
>   {
>     "source" :
>     {
>       "require" :
>       {
>         "myapp.Application" : [ "mylib.Contribution" ]
>       }
>     }
>   }
> Unfortunately, this did not work either.
>
> The manual on qooxdoo.org is a bit sparse on this issue, so perhaps
> you could give me another hint how to fix this?
>
> The actual code, qx.Class.isDefined("mylib.Contribution"), is called
> in the main function of myapp.Application, which I compile with
> 'build'.
Do you added the "mylib.*" classes as a library in your applications
config.json file? For the generator every top-level namespace is represented by
a library and this library has to be inlcuded with the "libraries" key into
your application configuration.

Can you please post your "config.json" so we can take a look at it?

cheers,
  Alex

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Joachim Baran
Hello,

On 14 April 2010 16:04, Alexander Steitz <[hidden email]> wrote:
> Can you please post your "config.json" so we can take a look at it?
The whole thing? Oh well.. here it comes:
{
  "name"    : "Gazebo",

  "include" :
  [
    {
      "path" : "${QOOXDOO_PATH}/tool/data/config/application.json"
    }
  ],

  "export" :
  [
    "api",
    "build",
    "clean",
    "distclean",
    "fix",
    "info",
    "inspector",
    "lint",
    "migration",
    "pretty",
    "profiling",
    "source",
    "source-all",
    "test",
    "test-source",
    "translation"
  ],

  "let" :
  {
    "APPLICATION"  : "gazebo",
    "QOOXDOO_PATH" : "../support/qooxdoo",
    "QXTHEME"      : "gazebo.theme.Theme",
    "API_EXCLUDE"  : ["qx.test.*", "${APPLICATION}.theme.*",
"${APPLICATION}.test.*"],
    "LOCALES"      : [ "en" ],
    "CACHE"        : "${TMPDIR}/cache",
    "ROOT"         : "."
  },

  "jobs" :
  {
    "libraries" :
    {
      "library" :
      [
        {
          "manifest" : "../../Fly/fly/trunk/Manifest.json"
        }
      ]
    },

    "build-script" :
    {
      "settings" :
      {
        "gazebo.contributions" : [ "fly.Contribution" ]
      }
    },

    "source" :
    {
      "require" :
      {
        "gazebo.Application" : [ "fly.Contribution" ]
      }
    }
  }

}

Gazebo is the name of my application that I am building and the
contribution 'fly.Contribution' is supposed to be a plug-in that
extends Gazebo (it was created via 'create-application.py -t
contribution -n fly').

Thanks,
Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Thomas Herchenroeder
In reply to this post by Joachim Baran
>> #require(namespace.class)
> I have tried #require(mylib.Contribution) in both the application's
> class as well as the contribution's class without any luck.
>
> I then modified my config.json like this:
>   "jobs" :
>   {
>     "source" :
>     {
>       "require" :
>       {
>         "myapp.Application" : [ "mylib.Contribution" ]
>       }
>     }
>   }

I suggest to take one step at a time :). So try to get this dynamical
thing running within a single application, and without adding additional
libraries.

Secondly, both methods, using #require or the "require" config key, are
equivalent. #use, suggested elsewhere, does about the same, but does not
influence the load order. For your purpose, all three should work.

Thirdly, it should work in both source and build versions, so you can
choose which version you want to look at; 'source' might actually be
better for other reasons.

Fourthly, you can check the availability of a class by either adding
'-v' to the generate.py invocation and check that the desired class is
in the (long) list of included classes printed to the console. Or, in
the browser open a console, like Firebug, and enter the class name,
which should return something sensible (like an object ref).

If you still fail, then yes, send in the config.json of your app.

T.


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Werner Thie
Hi

on an other note - I spent the last two days with a nasty problem
occurring with WebKit. If using JS in a multifile situation you can
easily observe that WebKit (Safari, Chrome) does NOT in order loading of
given JS files, meaning you end up in a situation where JS code might
sometimes run and sometimes fail dependent on server/local situations. I
don't know where the WebKit guys got this crazy idea that evaluating JS
source out of order might speed up things, but they clearly did it that
way which is in my opinion violating the specs.

Werner

On 14.04.2010 17:28, thron7 wrote:

>>> #require(namespace.class)
>> I have tried #require(mylib.Contribution) in both the application's
>> class as well as the contribution's class without any luck.
>>
>> I then modified my config.json like this:
>>    "jobs" :
>>    {
>>      "source" :
>>      {
>>        "require" :
>>        {
>>          "myapp.Application" : [ "mylib.Contribution" ]
>>        }
>>      }
>>    }
>
> I suggest to take one step at a time :). So try to get this dynamical
> thing running within a single application, and without adding additional
> libraries.
>
> Secondly, both methods, using #require or the "require" config key, are
> equivalent. #use, suggested elsewhere, does about the same, but does not
> influence the load order. For your purpose, all three should work.
>
> Thirdly, it should work in both source and build versions, so you can
> choose which version you want to look at; 'source' might actually be
> better for other reasons.
>
> Fourthly, you can check the availability of a class by either adding
> '-v' to the generate.py invocation and check that the desired class is
> in the (long) list of included classes printed to the console. Or, in
> the browser open a console, like Firebug, and enter the class name,
> which should return something sensible (like an object ref).
>
> If you still fail, then yes, send in the config.json of your app.
>
> T.
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

werner.vcf (311 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Thomas Herchenroeder
Werner,

could you re-post this in its own thread?! It's worth it, and this makes
it easier to keep topics on focus.

Thanks,
T.

On 04/14/2010 05:45 PM, Werner Thie wrote:

> Hi
>
> on an other note - I spent the last two days with a nasty problem
> occurring with WebKit. If using JS in a multifile situation you can
> easily observe that WebKit (Safari, Chrome) does NOT in order loading of
> given JS files, meaning you end up in a situation where JS code might
> sometimes run and sometimes fail dependent on server/local situations. I
> don't know where the WebKit guys got this crazy idea that evaluating JS
> source out of order might speed up things, but they clearly did it that
> way which is in my opinion violating the specs.
>
> Werner
>
> On 14.04.2010 17:28, thron7 wrote:
>>>> #require(namespace.class)
>>> I have tried #require(mylib.Contribution) in both the application's
>>> class as well as the contribution's class without any luck.
>>>
>>> I then modified my config.json like this:
>>>    "jobs" :
>>>    {
>>>      "source" :
>>>      {
>>>        "require" :
>>>        {
>>>          "myapp.Application" : [ "mylib.Contribution" ]
>>>        }
>>>      }
>>>    }
>>
>> I suggest to take one step at a time :). So try to get this dynamical
>> thing running within a single application, and without adding additional
>> libraries.
>>
>> Secondly, both methods, using #require or the "require" config key, are
>> equivalent. #use, suggested elsewhere, does about the same, but does not
>> influence the load order. For your purpose, all three should work.
>>
>> Thirdly, it should work in both source and build versions, so you can
>> choose which version you want to look at; 'source' might actually be
>> better for other reasons.
>>
>> Fourthly, you can check the availability of a class by either adding
>> '-v' to the generate.py invocation and check that the desired class is
>> in the (long) list of included classes printed to the console. Or, in
>> the browser open a console, like Firebug, and enter the class name,
>> which should return something sensible (like an object ref).
>>
>> If you still fail, then yes, send in the config.json of your app.
>>
>> T.
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
>
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Thomas Herchenroeder
In reply to this post by Joachim Baran
>     "build-script" :
>     {
>       "settings" :
>       {
>         "gazebo.contributions" : [ "fly.Contribution" ]
>       }
>     },
>
>     "source" :
>     {
>       "require" :
>       {
>         "gazebo.Application" : [ "fly.Contribution" ]
>       }

Well, these two are not the same, right?! For your source version you
require a class named "fly.Contribution", but in the build version you
don't. On the other hand, for the build version you set a setting
("gazebo.contributions"), but in the source version you don't.

For one thing, this explains why your build version doesn't contain
fly.Contribution.

T.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Joachim Baran
On 14 April 2010 17:26, Thomas Herchenroeder
<[hidden email]> wrote:
> Well, these two are not the same, right?!
> For one thing, this explains why your build version doesn't contain
> fly.Contribution.
Oh my.. you are right! I always mess up these things up. Sorry about that..

However, I have now everything under "build" and it works when I say:
  "require" : { "gazebo.Application" : [ "gazebo.test.DemoTest" ] }
but when I put there
  "require" : { "gazebo.Application" : [ "fly.Contribution" ] }
I see the following error messages in the JavaScript console:
  Uncaught ReferenceError: fly is not defined
  Uncaught TypeError: Object qx.event.type.Event[4] has no method
'getReturnValue'

How do I make 'fly' known to qooxdoo? When I compile with -v, it tells
me "Detected namespace: fly", but I assume that does not carry over to
runtime?

Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

WebKit loads separate JS files NOT in order

Werner Thie
In reply to this post by Thomas Herchenroeder
Hi

I spent the last two days with a nasty problem
occurring with WebKit. If using JS in a multifile situation you can
easily observe (just put a debugger; or alert statement at the beginning
of the file) that WebKit (Safari, Chrome) does NOT in order loading of
given JS files, meaning you end up in a situation where JS code might
sometimes run and sometimes fail dependent on server/local situations. I
don't know where the WebKit guys got this crazy idea that evaluating JS
source out of order might speed up things, but they clearly did it that
way which is in my opinion violating the specs.

Solving the problem means you have to introduce a system of guaranteeing
that code you depend on is loaded when the file in question is evaluated
(see code below)

Werner

Assuming that a file yyy.js containing JS code injects a top level
object with the filename yyy and is dependent on xxx.js:

//// code goes someplace early, like Application.js
modulesWaiting = {};

function moduleLoaded(module) {
   modulesWaiting[module] = null;
}

function waitForModules(module, f) {
   modulesWaiting[module] = f;
   for (var m in modulesWaiting) {
     if (modulesWaiting[m])
       modulesWaiting[m]();
   }
}

//// code of a single file yyy.js dependant on code in file xxx.js
waitForModules('yyy', function() {
   var deps = ['xxx'];  //comma separated list of modules
   var loaded = true;
   for (var i=0; i<deps.length; i++)
     loaded = loaded && (deps[i] != null);
   if (loaded) {
     //here comes the source, Luke
     //your source code

     yyy = {};          //signal readyness by defining this object
     moduleLoaded('yyy');
   }
});


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

werner.vcf (311 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: WebKit loads separate JS files NOT in order

Thomas Herchenroeder
Werner, thanks for making the effort with the changed subject. But for
most mail clients this will not suffice as they are tracking message
id's, and these are retained when you *reply* to an existing post. To
really start a new thread you have to write a fresh message to the
mailing list. Will you give it another try?!

T.

On 04/14/2010 06:52 PM, Werner Thie wrote:

> Hi
>
> I spent the last two days with a nasty problem
> occurring with WebKit. If using JS in a multifile situation you can
> easily observe (just put a debugger; or alert statement at the beginning
> of the file) that WebKit (Safari, Chrome) does NOT in order loading of
> given JS files, meaning you end up in a situation where JS code might
> sometimes run and sometimes fail dependent on server/local situations. I
> don't know where the WebKit guys got this crazy idea that evaluating JS
> source out of order might speed up things, but they clearly did it that
> way which is in my opinion violating the specs.
>
> Solving the problem means you have to introduce a system of guaranteeing
> that code you depend on is loaded when the file in question is evaluated
> (see code below)
>
> Werner
>
> Assuming that a file yyy.js containing JS code injects a top level
> object with the filename yyy and is dependent on xxx.js:
>
> //// code goes someplace early, like Application.js
> modulesWaiting = {};
>
> function moduleLoaded(module) {
>   modulesWaiting[module] = null;
> }
>
> function waitForModules(module, f) {
>   modulesWaiting[module] = f;
>   for (var m in modulesWaiting) {
>     if (modulesWaiting[m])
>       modulesWaiting[m]();
>   }
> }
>
> //// code of a single file yyy.js dependant on code in file xxx.js
> waitForModules('yyy', function() {
>   var deps = ['xxx'];  //comma separated list of modules
>   var loaded = true;
>   for (var i=0; i<deps.length; i++)
>     loaded = loaded && (deps[i] != null);
>   if (loaded) {
>     //here comes the source, Luke
>     //your source code
>
>     yyy = {};          //signal readyness by defining this object
>     moduleLoaded('yyy');
>   }
> });
>
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
>
>
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Loading a class by name

Joachim Baran
In reply to this post by Thomas Herchenroeder
It works now.

I changed 'fly.Contribution' to 'gazebo.fly.Contribution' and now the
class is found.

Is there some documentation on how I can create an instance of said
class from its Class object though?

Thanks a lot,
Joachim

--
B.1079 Michael Smith Building
Faculty of Life Sciences
The University of Manchester
Oxford Road
Manchester
M13 9PT
United Kingdom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel