|
From: Frank V. C. <fr...@co...> - 2001-02-23 03:01:28
|
It might be helpful to reiterate why the MetaType/MetaClass information
is alive in the first place:
1. It enables developers a way to reason with objects without knowing
the details of the class itself. This is enabled through the use of the
method and type information, as well as subclass (parent/child)
relationships.
2. The ability to provide the frameworks (Library, Persist, etc.) the
means to be more effective in the capability it can deliver. By removing
the bond between interface and compilation time, the frameworks are more
flexible.
3. It is similar to the work I was progressing with in knowledge
representation, so I thought it cool (mainly for the above two reasons).
And some facts:
1. You can build the metatype/metaclass instance at run-time. We did it
at implementation time because it was convenient to me (as it was in my
head and clear as a bell). It is messy and convuluted, and Christophe is
headed in the very right direction.
2. There is a slight overlap between metatype and metaclass, and there
is probably a implementation error in there as well.
3. We are missing a way to describe a relationship (composition or
aggregate) between two or more metaclasses. Without them we are unable
to express semantics that exist on the class (for any number of
reasons), and prevent a full Meta Object Protocol enablement (classless
programming).
So, here is some of what I am proposing and why:
* The MetaClass parser should not generate the C++ class interwoven with
the MetaClass information, but instead stick to the MetaClass
declarations and definitions as extra files. This implies that the
developer has provided the C++ class and has used that information in
formulating the MetaClass declaration file.
For example:
SomeClass.hpp
-------------
class SomeClass
{
DECLARE_METACLASS( SomeClass );
public:
int getValue( void ) const;
void setValue( const int & );
private:
int theValue;
//
};
SomeClass.cpp
-------------
DEFINE_METACLASS( SomeClass );
// Start user code
SomeClass.clmc (my own syntax for the moment)
--------------
(defclass corelinux::SomeClass
(defproperty "Value" : native=int)
(defmetaproperty "Parents" {MetaClassRoot})
)
the parser reads the clmc file and generates an mci (metaclass include)
and mcd (metaclass definition), such that when DECLARE_METACLASS expands
to (for example)
#include <MetaClassSomeClass.mci>
// which expands to a inner class and SomeClass statics (such as class
pointer and accessors for it)
And DEFINE_METACLASS expands to include the "mcd" file which is
fundementally what we now have in macros, with the addition that the
initializer adds itself to the Ontology target (in this example
corelinux).
Note1: See the defproperty and defmetaproperty? The former refers to
properties as declared by the user for the class instances, whereas the
defmetaproperty is a relationship for the metaclass instance only. Other
metaproperties could be added that would enable implementation level
semantics to be integrated in for use by the end-user applications.
This is the first point, I will wait before raising any others.
Thoughts?
--
Frank V. Castellucci
http://corelinux.sourceforge.net
OOA/OOD/C++ Standards and Guidelines for Linux
http://PythPat.sourceforge.net
Pythons Pattern Package
|
|
From: Christophe Prud'h. <pru...@MI...> - 2001-02-23 10:22:52
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> (defclass corelinux::SomeClass
> =09(defproperty "Value" : native=3Dint)
> =09(defmetaproperty "Parents" {MetaClassRoot})
> )
Ok sounds cool !
actually I was thinking about doing this through macros
PROPERTY( int Value READ getValue WRITE setValue );
getValue() and setValue() are getters and setters
> the parser reads the clmc file and generates an mci (metaclass include)
> and mcd (metaclass definition), such that when DECLARE_METACLASS expand=
s
> to (for example)
>
> #include=09<MetaClassSomeClass.mci>
> // which expands to a inner class and SomeClass statics (such as class
> pointer and accessors for it)
>
> And DEFINE_METACLASS expands to include the "mcd" file which is
> fundementally what we now have in macros, with the addition that the
> initializer adds itself to the Ontology target (in this example
> corelinux).
yes that was wht I wanted to do with parser+macros
the DEFINE_METACLASS would have been only META_CLASS and used inside the =
class
then the parser recognise the symbol and generate the meta class informat=
ion
Now if new properties are defined they are parsed also and the mcd is=20
generated automatically.
> This is the first point, I will wait before raising any others.
> Thoughts?
Your system seems to be cleaner/simpler.
However in the system I was thinking the parser would have been a strippe=
d=20
c++ parser therefore the DEFINE_METACLASS( class ); would be only=20
DEFINE_METACLASS (no arg) and the parser would generate the basic meta=20
informations (class::getClassName() for example ) on the class directly f=
rom=20
the header file. So any changes in the header file is caugth.
Moreover what if the class is a template for example? don't you need a c+=
+=20
parser to ensure that the class definition is correct when you generate t=
he=20
mcd file ?
template<typename T>
class A
{
DEFINE_METACLASS( A<T> );
blah.
};
now how do you deal with this in the clmc file ? that is how do you=20
synchronize the class definition with the clmc file and generated mcd fil=
e ?
best regards
C.
- --=20
Christophe Prud'homme |
MIT, 77, Mass Ave, Rm 3-243 | A classic is something that
Cambridge MA 02139 | everyone wants to have read an=
d
Tel (Office) : (00 1) (617) 253 0229 | nobody wants to read.
Fax (Office) : (00 1) (617) 258 8559 | -- Mark Twain,
http://augustine.mit.edu/~prudhomm | "The Disappearance of Literatu=
re"
ICQ UIN: 24560867 Alias: Jesunix |
Following the hacker spirit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjqWOjoACgkQoY+0C9S+FFCkVACfTRGVHgAttgCcn2Ftg0aWcuJN
jhEAmgOHfbNF178GWIwfxprujwlO1yqI
=3DUMer
-----END PGP SIGNATURE-----
|
|
From: Frank V. C. <fr...@co...> - 2001-02-23 12:30:44
|
Christophe Prud'homme wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> > (defclass corelinux::SomeClass
> > (defproperty "Value" : native=int)
> > (defmetaproperty "Parents" {MetaClassRoot})
> > )
> Ok sounds cool !
> actually I was thinking about doing this through macros
>
> PROPERTY( int Value READ getValue WRITE setValue );
> getValue() and setValue() are getters and setters
My assumption was that ALL values have get and set methods (making the
declaration redundant). There needs to be a consistent reflection
interface for frameworks (such as Persist) to do their thing. This would
be no different than generating the "getXXXX" and "setXXXX" expansions
found in MetaType.hpp today. We can use a form of name mangling to
ensure we have the interface standards for property types without
colliding with interface the developer has declared/defined.
>
> > the parser reads the clmc file and generates an mci (metaclass include)
> > and mcd (metaclass definition), such that when DECLARE_METACLASS expands
> > to (for example)
> >
> > #include <MetaClassSomeClass.mci>
> > // which expands to a inner class and SomeClass statics (such as class
> > pointer and accessors for it)
> >
> > And DEFINE_METACLASS expands to include the "mcd" file which is
> > fundementally what we now have in macros, with the addition that the
> > initializer adds itself to the Ontology target (in this example
> > corelinux).
> yes that was wht I wanted to do with parser+macros
> the DEFINE_METACLASS would have been only META_CLASS and used inside the class
> then the parser recognise the symbol and generate the meta class information
> Now if new properties are defined they are parsed also and the mcd is
> generated automatically.
>
> > This is the first point, I will wait before raising any others.
> > Thoughts?
> Your system seems to be cleaner/simpler.
> However in the system I was thinking the parser would have been a stripped
> c++ parser therefore the DEFINE_METACLASS( class ); would be only
> DEFINE_METACLASS (no arg) and the parser would generate the basic meta
> informations (class::getClassName() for example ) on the class directly from
> the header file. So any changes in the header file is caugth.
I'm against parsing the C++ stuff at all, personally. The reasons being
that:
* It removes control of what data members or methods are "exposed" in
the reflective declaration unless we require them to add more macros to
the header files, which is what I thought we wanted to get away from?
* It allows us to get VERY expressive in the clmc file declarations:
(defmethod (virtual | static | none) ....)
(defmetamethod (virtual | static | none) ....)
etc.
Also, note in the example that I gave that "SomeClass" was NOT derived
from anything, but the "(defclass SomeClass)" had a "Parents" defined.
MetaClasses don't neccessarily follow C++ class derivation graphs, and
while I anticipate that most WILL, it is not implicit. Come to think of
it, you would propably want something like:
(MetaSomeClassClass associates SomeClass
(property "Value" : native=int)
(metaproperty "Parents" {MetaClassRoot})
)
which would make MetaSomeClassClass a first class object that SomeClass
would use through the minor macro expansions, instead of making it a
nested class. (Note the lack of namespace assumes "corelinux::").
There may also be cases where we want PURE metaclasses defined, that
will live in the ontology for various reasons. For this refer to classes
programming.
>
> Moreover what if the class is a template for example? don't you need a c++
> parser to ensure that the class definition is correct when you generate the
> mcd file ?
>
> template<typename T>
> class A
> {
> DEFINE_METACLASS( A<T> );
> blah.
> };
>
> now how do you deal with this in the clmc file ? that is how do you
> synchronize the class definition with the clmc file and generated mcd file ?
>
I would need to research meta object protocol with the use of templated
classes. My first thought is that we don't work with templatized classes
at this point.
> best regards
> C.
> - --
> Christophe Prud'homme |
> MIT, 77, Mass Ave, Rm 3-243 | A classic is something that
> Cambridge MA 02139 | everyone wants to have read and
> Tel (Office) : (00 1) (617) 253 0229 | nobody wants to read.
> Fax (Office) : (00 1) (617) 258 8559 | -- Mark Twain,
> http://augustine.mit.edu/~prudhomm | "The Disappearance of Literature"
> ICQ UIN: 24560867 Alias: Jesunix |
> Following the hacker spirit
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.4 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iEYEARECAAYFAjqWOjoACgkQoY+0C9S+FFCkVACfTRGVHgAttgCcn2Ftg0aWcuJN
> jhEAmgOHfbNF178GWIwfxprujwlO1yqI
> =UMer
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Corelinux-develop mailing list
> Cor...@li...
> http://lists.sourceforge.net/lists/listinfo/corelinux-develop
--
Frank V. Castellucci
http://corelinux.sourceforge.net
OOA/OOD/C++ Standards and Guidelines for Linux
http://PythPat.sourceforge.net
Pythons Pattern Package
|