[ top ] [ prev ] [ up ] [ next ]

TPicture.Bitmap

Format
public property A: TA read GetA write SetA;
Params
A = Bitmap
Delphi
    TPicture = class(TInterfacedPersistent, IStreamPersist)
    public
      property Bitmap: TBitmap read GetBitmap write SetBitmap;
    end;
Apollo
function Picture_get_bitmap(This: Tvalue): Tvalue; cdecl;
var
  real: TPicture;
begin
  real := ap_data_get_struct(This);
  result := ap_iBitmap(real.Bitmap, This);
end;

function Picture_set_bitmap(This, v: Tvalue): Tvalue; cdecl;
var
  real: TPicture;
  bitmap: TBitmap;
begin
  real := ap_data_get_struct(This);
  ap_data_get_object(v, TBitmap, bitmap);
  real.Bitmap := bitmap;
  result := v;
end;

procedure Init_Picture;
begin
  DefineAttrGet(cPicture, 'bitmap', Picture_get_bitmap);
  DefineAttrSet(cPicture, 'bitmap', Picture_set_bitmap);
end;
悪い例
プロパティを読むときに新たなオブジェクトを生成する可能性がある場合は、事前に変換することはできない。
procedure Picture_setup(obj: Tvalue; real: TPicture);
begin
? rb_iv_set(obj, '@bitmap', ap_iBitmap(real.Bitmap, obj));
end;
[ top ] [ prev ] [ up ] [ next ]