Menu

#12 RTTI

open
nobody
None
5
2003-03-24
2003-03-24
Anonymous
No

Runtime type information (RTTI) alows "investigate" a
object "published" properties and events, so, an "object
inspector" can be build.
Also, "Classname" and "inheritsFrom" are a nice thing.

Discussion

  • A.H. Banen

    A.H. Banen - 2003-03-26

    Logged In: YES
    user_id=423153

    I can't help on how to investigate an object's published
    properties and functions :( , but I made a try at a
    Classname and an Inheritsfrom that work on class
    instances:

    class examplegrandparent
    endclass

    class exampleparent(examplegrandparent)
    endclass

    class exampleclass( exampleparent )
    endclass

    x = exampleclass()

    classname = func( ci )
    return type(ci)
    endfunc

    inheritsfrom = func( ci )
    return split( (unparse( ci.inherited ))[2->-2], "=")
    [2]
    endfunc

    print classname( x ), cr # works on
    class instance
    print inheritsfrom(x), cr # works on
    class instance

    print inheritsfrom(inheritsfrom(x)),cr # doesn't work
    on a class

    dummy = eval( inheritsfrom(x))() # So
    sometimes a trick works...
    print inheritsfrom(dummy ), cr

    Andr

     
  • Rodrigo Ruiz

    Rodrigo Ruiz - 2003-04-07

    Logged In: YES
    user_id=742111

    Every time you create a new "CORE_OBJECT" in
    a "CORE_MODULE" you must register it classname and all
    methods and properties. It seems to be stored in a table,
    well, we can search in this table to retrieve all registered
    props/methods.
    This could be very handy when creating visual environments
    for dialect (i have seen a "visual dialect" request :) )

     
  • Rodrigo Ruiz

    Rodrigo Ruiz - 2003-04-07

    Logged In: YES
    user_id=742111

    Every time you create a new "CORE_OBJECT" in
    a "CORE_MODULE" you must register it classname and all
    methods and properties. It seems to be stored in a table,
    well, we can search in this table to retrieve all registered
    props/methods.
    This could be very handy when creating visual environments
    for dialect (i have seen a "visual dialect" request :) )

     
  • A.H. Banen

    A.H. Banen - 2003-04-08

    Logged In: YES
    user_id=423153

    Rodrigo,
    You already can search the table you talk about. Run e.g.
    the following:
    import "gui"
    print gui

    There is however a practical limit: the frame you can search
    contains only names of classes, functions, properties and
    constants. The additional information , what's in a class,
    parameters needed, ranges allowed, etc. is not available.
    These would need to be added to be able to 'browse
    objects'...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.