back2dos / tinkerbell

MIT License
83 stars 8 forks source link

@:require metadata not honoured in @:forward. #58

Open 0b1kn00b opened 10 years ago

0b1kn00b commented 10 years ago

Using syntactic delegation on TextField in flash triggers a compiler error even when using (field0,field1...fieldn). I assume it's the TextInteractionMode field, but it may be something further up the class hierarchy.

Accessing this field requires flash version 11 (use -swf-version 11)
0b1kn00b commented 10 years ago
import tink.lang.Cls;

import flash.text.TextField;
import flash.display.InteractiveObject;
import flash.display.DisplayObject;
import flash.display.Sprite;

class Text extends Sprite implements Cls{
  @:forward(
    /*alwaysShowSelection,antiAliasType,autoSize,background,
    backgroundColor,border,borderColor,bottomScrollV,
    caretIndex,condenseWhite,defaultTextFormat,
    displayAsPassword,embedFonts,gridFitType,htmlText,
    length,maxChars,maxScrollH,maxScrollV,mouseWheelEnabled,
    multiline,numLines,restrict,scrollH,scrollV,selectable,
    selectedText,selectionBeginIndex,selectionEndIndex,sharpness,
    styleSheet,textColor,textHeight,textWidth,
    thickness,type,useRichTextClipboard,wordWrap,appendText,
    copyRichText,getCharBoundaries,getCharIndexAtPoint,
    getFirstCharInParagraph,getImageReference,getLineIndexAtPoint,
    getLineIndexOfChar,getLineLength,getLineMetrics,getLineOffset,
    getLineText,getParagraphLength,getRawText,getTextFormat,getTextRuns,
    getXMLText,insertXMLText,pasteRichText,
    replaceSelectedText,replaceText,setSelection,setTextFormat*/
  ) var __text_field__ : TextField;

  public function new(){
    super();
  }
  public var text(get,set):String;

  private function get_text(){
    return this.__text_field__.text;
  }
  private function set_text(text:String):String{
    return this.__text_field__.text = text;
  }
/*
  @:require(flash11) var textInteractionMode(get,set) : TextInteractionMode;

  @:require(flash11) private function get_textInteractionMode():TextInteractionMode{
    return __text_field__.textInteractionMode;
  }
  @:require(flash11) private function set_textInteractionMode(v:TextInteractionMode):TextInteractionMode{
    return __text_field__.textInteractionMode = v;
  }*/
}
back2dos commented 10 years ago

Ah yes. I ran into this once. Will look into it. For the time being I suggest using @:forward(!textInteractionMode) instead of listing all fields ;)

0b1kn00b commented 10 years ago

Didn't know you could use the negation operator here, but even with that field excluded (and requestSoftKeyboard up the chain), the error remains.

back2dos commented 10 years ago

Well now you know you can and I know it's not enough :D

back2dos commented 10 years ago

Ok, the problem comes from an underlying layer. In some sense the whole way in which @:require is handled is rather problematic. I would have liked to just generate the @:require on the forwarded methods, but the compiler will then reject the method bodies.