fork download
  1. {$APPTYPE CONSOLE}
  2. {$IFDEF FPC}
  3. {$MODE DELPHI}
  4. {$ENDIF}
  5. uses SysUtils;
  6.  
  7. type
  8. users_t = (tarasB, superhackkiller1997, other_shit);
  9. say_ptr_t = class(TObject)
  10. anon_field1: users_t;
  11. constructor Create(usr: users_t);
  12. procedure anon_method(str: PChar);
  13. end;
  14. const
  15. users: array[users_t] of PChar = ('tarasB', 'superhackkiller1997', 'other_shit');
  16.  
  17. procedure say_ptr_t.anon_method(str: PChar);
  18. begin
  19. Writeln(ErrOutput, Format('%s: %s', [users[anon_field1], str]))
  20. end;
  21.  
  22. constructor say_ptr_t.Create(usr: users_t);
  23. begin
  24. inherited Create;
  25. anon_field1 := usr;
  26. end;
  27.  
  28. function bind1(usr: users_t): say_ptr_t; export;
  29. begin
  30. bind1 := say_ptr_t.Create(usr)
  31. end;
  32.  
  33. begin
  34. bind1(tarasB).anon_method('shit');
  35. bind1(superhackkiller1997).anon_method('i''m god');
  36. bind1(other_shit).anon_method('ko-ko-ko')
  37. end.
stdin
Standard input is empty
stdout
Standard output is empty
stderr
tarasB: shit
superhackkiller1997: i'm god
other_shit: ko-ko-ko