To make smart pointers a part of library.
- From: "Ilnur Quellendil" <ilnur tut by>
- To: gtk-devel-list gnome org
- Subject: To make smart pointers a part of library.
- Date: Mon, 19 Aug 2002 01:39:03 +0300
Title: Letter
Good Day Everybody,
I have an idea, and the idea is, to create a hierarchy
of smart poinerts straight into the Gtk header files, the
hierarchy that grows together with the hierarchy of
objects. Why it's better than using additional C++
libraries? Because such wrappers will always be up-to-date,
and also... well, I just like this idea very much.
Now, that's what I meen:
For example, we have:
/* parent.h */
#ifndef __PARENT_H
#define __PARENT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _Parent Parent;
struct _Parent
{
int X;
};
int Parent_Play(Parent *p, int a);
#ifdef __cplusplus
}
#endif
#endif // __PARENT_H
|
and
/* child.h */
#ifndef __CHILD_H
#define __CHILD_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _Child Child;
struct _Child;
{
Parent parent;
int Y;
};
int Child_Sing(Child *c, int a);
#ifdef __cplusplus
}
#endif
#endif // __CHILD_H
|
And I'd like this files to look like that:
/* parent.h */
#ifndef __PARENT_H
#define __PARENT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _Parent Parent;
struct _Parent
{
int X;
};
int Parent_Play(Parent *p, int a);
#ifdef __cplusplus
}
#ifndef _PROHIBIT_WRAPPERS_
struct ParentPtr
{
Parent *ptr;
ParentPtr() {};
ParentPtr(Parent *src) { ptr = src; }
Parent *operator-> () { return ptr; }
int Play(int a) { return
Parent_Play(ptr, a); }
};
#endif //
_PROHIBIT_WRAPPERS_
#endif // __cplusplus
#endif // __PARENT_H
|
and
/* child.h */
#ifndef __CHILD_H
#define __CHILD_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _Child Child;
struct _Child;
{
Parent parent;
int Y;
};
int Child_func(Child *c, int a);
#ifdef __cplusplus
}
#ifndef _PROHIBIT_WRAPPERS_
struct ChildPtr: public ParentPtr
{
ChildPtr() {};
ChildPtr(Child *src) { ptr = src; }
Child *operator-> () { return
reinterpret_cast<Child*>(ptr); }
int Sing(int a) { return
Child_Sing(reinterpret_cast<Child*>(ptr),
a); }
};
#endif //
_PROHIBIT_WRAPPERS_
#endif // __cplusplus
#endif // __CHILD_H
|
Also there may be CPP-style typecast functions,
namespaces and everything...
Anton A. Bryl.
ilnur tut by
------
В связи с официальным открытием, интернет-кафе "СоюзONline", расположенное в
Центральном доме офицеров, делает подарок своим клиентам - 20%-ю скидку на
свои услуги до 15 сентября. Час работы в интернет от 1060 руб! Тел. 226-02-79
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]