Open source my OIOIC, a completely new object-oriented mechanism forthe C.

P

pervise.zhao

OIOIC is a completely new object-oriented mechanism for the C
programming language.

Using OIOIC, you can describe the flower, birds, grass, insects,
trees, houses ...
Using OIOIC, you can describe the elements, atoms, protons,
electrons ...
Using OIOIC, you can describe the earth, the sun, the Milky Way
galaxy, collapsar ...
Using OIOIC, you can describe ...

1. OIOIC perfectly supplies the gap of object-oriented technology for
the C programming language;
2. OIOIC perfectly solved the multiple inheritance problem in the
Software World;
3. OIOIC perfectly objectivizes multithreading access control of
object;
4. OIOIC unifies the norm of components in the Software World;
5. OIOIC unifies the structure of code tree in the Software World;
6. OIOIC unifies the thinking of object-oriented programming in the
Software World;
7. OIOIC unifies all advanced programming languages in the Software
World, to make the C programming language as the preferred.

For further information, please download the "OIOIC-Primer-2nd-Edition-
English.tar.gz". (the English version of << OIOIC Primer >> )
http://code.google.com/p/oioic/downloads/list

Welcome your advice!
 
C

chunpulee

I like oo, but I don't like C++, I like encapsulation, but I don't like
inheritance.

[main.c]
#include <stdio.h>
#include "o.h"

int main()
{
ABC *a;

a = con_a();
a->set_p(a, 100);
a->display(a);
dec_a(a);

return 0;
}

[o_p.h]
#ifndef __O_P_H__
#define __O_P_H__

typedef struct abc ABC;

struct abc
{
/* public */
void (*set_p)(ABC *, int);
int (*get_p)(ABC *);
void (*display)(ABC *);

/* private */
int p;
void (*calc)(ABC *);
};

ABC *con_a();
void dec_a(ABC *);

void set_p(ABC *, int);
int get_p(ABC *);
void display(ABC *);
void calc(ABC *);

#endif /* __O_P_H__ */

[o.h]
#ifndef __O_H__
#define __O_H__

typedef struct abc ABC;

struct abc
{
/* public */
void (*set_p)(ABC *, int);
int (*get_p)(ABC *);
void (*display)(ABC *);
};

ABC *con_a();
void dec_a(ABC *);

#endif /* __O_H__ */

[o.c]
#include <stdio.h>
#include "o_p.h"

ABC *con_a()
{
ABC *a0 = NULL;

a0 = (ABC *)malloc(sizeof(ABC));
memset((char *)a0, 0, sizeof(ABC));

/* init public */
a0->set_p = set_p;
a0->get_p = get_p;
a0->display = display;

/* init private */
a0->p = 0;
a0->calc = calc;

return a0;
}

void dec_a(ABC *a0)
{
free(a0);
}

void set_p(ABC *a0, int p0)
{
a0->p = p0;
}

int get_p(ABC *a0)
{
return a0->p;
}

void display(ABC *a0)
{
a0->calc(a0);
printf("display p : %d\n", a0->p);
}

void calc(ABC *a0)
{
printf("calc()\n");
a0->p *= 2;
}
 
U

user923005

I like oo, but I don't like C++, I like encapsulation, but I don't like
inheritance.

[main.c]
#include <stdio.h>
#include "o.h"

int main()
{
    ABC *a;

    a = con_a();
    a->set_p(a, 100);
    a->display(a);
    dec_a(a);

    return 0;

}

[o_p.h]
#ifndef __O_P_H__
#define __O_P_H__

typedef struct abc ABC;

struct abc
{
 /* public */
 void (*set_p)(ABC *, int);
 int (*get_p)(ABC *);
 void (*display)(ABC *);

 /* private */
 int p;
 void (*calc)(ABC *);

};

ABC *con_a();
void dec_a(ABC *);

void set_p(ABC *, int);
int get_p(ABC *);
void display(ABC *);
void calc(ABC *);

#endif /* __O_P_H__ */

[o.h]
#ifndef __O_H__
#define __O_H__

typedef struct abc ABC;

struct abc
{
 /* public */
 void (*set_p)(ABC *, int);
 int (*get_p)(ABC *);
 void (*display)(ABC *);

};

ABC *con_a();
void dec_a(ABC *);

#endif /* __O_H__ */

[o.c]
#include <stdio.h>
#include "o_p.h"

ABC *con_a()
{
 ABC *a0 = NULL;

 a0 = (ABC *)malloc(sizeof(ABC));
 memset((char *)a0, 0, sizeof(ABC));

 /* init public */
 a0->set_p = set_p;
 a0->get_p = get_p;
 a0->display = display;

    /* init private */
 a0->p = 0;
 a0->calc = calc;

 return a0;

}

void dec_a(ABC *a0)
{
 free(a0);

}

void set_p(ABC *a0, int p0)
{
 a0->p = p0;

}

int get_p(ABC *a0)
{
 return a0->p;

}

void display(ABC *a0)
{
 a0->calc(a0);
 printf("display p : %d\n", a0->p);

}

void calc(ABC *a0)
{
 printf("calc()\n");
 a0->p *= 2;



}

What a nifty idea. All you have to do is remember to call the
constructor every time you declare an object and remember to call the
destructor whenever it passes out of scope.
I am amazed someone else has not come up with this.
We also avoid that nasty encapsulation stuff. Self discipline was
always much better anyway.
I like the little 'public' tag. Its a nice contrast to private or
protected. How will you achieve those, by the way? Or is it just a
gag of some kind?

I can see why you like OO but not inheritance. Wait a minute, no I
can't.

P.S.
The casts to malloc() are a nice touch and sure to gather brownie
points with the regulars here.

P.P.S.
If you want to write OO code, I don't recommend C.
If you want to write procedural code I do recommend C.
Others may feel differently and your actual mileage may vary.
 
P

pervise.zhao

Attention,please! OIOIC starts from philosophy (the Philosophy of
Dialectical Materialism), not language, and is designed all through on
the high level of the philosophy, not merely on the level of language.

Welcome everyone to continue the discussion, express your views on
OIOIC.
 
J

JosephKK

Attention,please! OIOIC starts from philosophy (the Philosophy of
Dialectical Materialism), not language, and is designed all through on
the high level of the philosophy, not merely on the level of language.

Welcome everyone to continue the discussion, express your views on
OIOIC.

You are 5 days early. ;=P
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top