Hi all

I found recently that binding had stopped working when we were using private 
variables, for example:
  <test:TestComponent id="testing" width="100" height="20"  
boundValue="{_model.value}">
where we declare:
private var _model : Model = Model.getModel();

However it works with protected/public variables..

The reason is clear when you look at the generated _bindings array, which 
contains:
  function() { return this.test_MainView__model.value; },
and then
  "_model",
  "valueChange",

So basically the watcher list is using "_model" whereas the property is 
actually generated as "test_MainView__model".

Looking at the compiler code, there's a function on the emitter which does this 
translation:
      public String formatPrivateName(String className, String name) {
            return className.replace(".", "_") + "_" + name;
      }

However I can't work out how to get the watcher analyser class to access the 
emitter.. I think this is where the logic should go, because within 
"WatcherAnalyzer. analyzeIdentifierNode" we're getting the name as a string and 
creating the watcher object based on this string. So I want to do:
            name = def.getBaseName();
            if (def.isPrivate() && project.getAllowPrivateNameConflicts())
            {
                  name = 
getEmitter().formatPrivateName(def.getParent().getQualifiedName(), name);
            }

My issue is that there's no access that I can see to the Emitter.

So I thought I'd ask:

  1.  does anyone know how I could actually get a valid reference to the 
emitter from this point in the code? i.e. just through the JSRoyaleProject 
object from what I can see..
  2.  or is there a better place where this should be? e.g. within getBaseName 
itself, or where the base name is set up on the definition..?
  3.  or could we move the "formatPrivateName" method to somewhere more 
accessible?
  4.  or can I just reproduce the "formatPrivateName" functionality here, and 
add comments so that future maintainers know to update two locations in case 
this changes?

The last option is simplest but very hacky.. but would appreciate thoughts on 
the best approach.


thanks

   Andrew



Reply via email to