Expose property of object as object not variant

Issue #91 new
Igor Chodelka created an issue

Hello, i recently start using and learning how to use dwscript. I didnt figure out yet how to expose property of class where property type is another object This is what I tried.

    TSubject = class
      private
       SubjectName: String;
       published
       [dwsPublished]
       property pSubjectName: String read SubjectName;
       public
      constructor Create;
      destructor Destroy;
    end;

   TPerson = class
     private
      Name: String;
      Subject:TSubject;
     public
      constructor Create;
      destructor Destroy;

      [dwsPublished]
      procedure SetName(paName: String);
     published
      [dwsPublished]
      property pName: String read Name;
       [dwsPublished]
      property pSubject: TSubject read Subject write Subject;

For exposing classes to script i use rtti expose

dwsUnit.ExposeRTTI(TSubject.ClassInfo);
dwsUnit.ExposeRTTI(TPerson.ClassInfo);

OnAfterInitUnitTable event i expose instance of person

dwsUnit.ExposeInstanceToUnit('p',TPerson.ClassName,myPerson);

When i write script

PrintLn(p.pSubject); // i got number(variant i think)
PrintLn(p.pSubject.pSubjectName); // error

I got compile error "no member expected" When i tried debug it, it shows that property pSubject is not TSubject but Variant.

Is it even possible to use property of some object type? What im doing wrong?

Thanks.

Comments (0)

  1. Log in to comment