* How to add a class to the tree
@ 2009-08-01 9:11 Klesk
2009-08-01 13:57 ` Amittai Aviram
2009-08-01 17:59 ` John (Eljay) Love-Jensen
0 siblings, 2 replies; 4+ messages in thread
From: Klesk @ 2009-08-01 9:11 UTC (permalink / raw)
To: gcc-help
Let's say I have code like this:
SampleClass object;
which of course fails to compile because there is no SampleClass.
How to programmically create a class named SampleClass to make it
possible to complie ?
--
Klesk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to add a class to the tree
2009-08-01 9:11 How to add a class to the tree Klesk
@ 2009-08-01 13:57 ` Amittai Aviram
2009-08-01 15:08 ` Klesk
2009-08-01 17:59 ` John (Eljay) Love-Jensen
1 sibling, 1 reply; 4+ messages in thread
From: Amittai Aviram @ 2009-08-01 13:57 UTC (permalink / raw)
To: gcc-help
On Aug 1, 2009, at 5:11 AM, Klesk wrote:
> Let's say I have code like this:
>
> SampleClass object;
>
> which of course fails to compile because there is no SampleClass.
>
> How to programmically create a class named SampleClass to make it
> possible to complie ?
>
>
> --
> Klesk
Hi, Kiesk!
#include <iostream>
class SampleClass {
private:
int id;
public:
SampleClass() {
id = 42;
}
int get_id() {
return id;
}
};
int main(int argc, char ** argv) {
SampleClass object;
std::cout << object.get_id() << std::endl;
return EXIT_SUCCESS;
}
Do you mean something else? By "programmatically create," do you mean
create dynamically at runtime, as you would using the reflection
mechanisms of Java or C#?
Thanks.
Amittai Aviram
Graduate Student in Computer Science
Yale University
646 483 2639
amittai.aviram@yale.edu
http://www.amittai.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to add a class to the tree
2009-08-01 13:57 ` Amittai Aviram
@ 2009-08-01 15:08 ` Klesk
0 siblings, 0 replies; 4+ messages in thread
From: Klesk @ 2009-08-01 15:08 UTC (permalink / raw)
To: Amittai Aviram; +Cc: gcc-help
Hi
I would like something else... I think I wasn't specific enough..
let's try again :)
I have:
SampleClass object;
While parsing gcc will try to find what 'SampleClass' is, but because
it was not defined by user it will signal an error. Generally I would
like to avoid getting an error without modifying source given above,
so I would like to create programmically a simple class when it's
impossible to find it.
By 'create programmically' I mean: write a function which will create
a tree_node (I think it's needed) representing a class named
'SampleClass' and then add it to the tree representing source code.
Function would called when there's no definition for 'SampleClass'.
2009/8/1 Amittai Aviram <amittai.aviram@yale.edu>:
> On Aug 1, 2009, at 5:11 AM, Klesk wrote:
>
>> Let's say I have code like this:
>>
>> SampleClass object;
>>
>> which of course fails to compile because there is no SampleClass.
>>
>> How to programmically create a class named SampleClass to make it
>> possible to complie ?
>>
>>
>> -- Klesk
>
>
> Hi, Kiesk!
>
> #include <iostream>
>
> class SampleClass {
> private:
> int id;
> public:
> SampleClass() {
> id = 42;
> }
> int get_id() {
> return id;
> }
> };
>
> int main(int argc, char ** argv) {
>
> SampleClass object;
> std::cout << object.get_id() << std::endl;
> return EXIT_SUCCESS;
> }
>
>
> Do you mean something else? By "programmatically create," do you mean
> create dynamically at runtime, as you would using the reflection mechanisms
> of Java or C#?
>
> Thanks.
>
>
> Amittai Aviram
> Graduate Student in Computer Science
> Yale University
> 646 483 2639
> amittai.aviram@yale.edu
> http://www.amittai.com
>
>
--
Klesk
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: How to add a class to the tree
2009-08-01 9:11 How to add a class to the tree Klesk
2009-08-01 13:57 ` Amittai Aviram
@ 2009-08-01 17:59 ` John (Eljay) Love-Jensen
1 sibling, 0 replies; 4+ messages in thread
From: John (Eljay) Love-Jensen @ 2009-08-01 17:59 UTC (permalink / raw)
To: Klesk, gcc-help
Hi Klesk,
For an opaque object, you'll need a creator and destructor function for SampleClass.
class SampleClass;
extern SampleClass* CreateSampleClass();
extern void DestroySampleClass(SampleClass*);
Then you'll be able to do:
SampleClass* object = CreateSampleClass();
Sincerely,
--Eljay
________________________________________
From: gcc-help-owner@gcc.gnu.org [gcc-help-owner@gcc.gnu.org] On Behalf Of Klesk [kleskmail@gmail.com]
Sent: Saturday, August 01, 2009 4:11 AM
To: gcc-help@gcc.gnu.org
Subject: How to add a class to the tree
Let's say I have code like this:
SampleClass object;
which of course fails to compile because there is no SampleClass.
How to programmically create a class named SampleClass to make it
possible to complie ?
--
Klesk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-08-01 17:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-01 9:11 How to add a class to the tree Klesk
2009-08-01 13:57 ` Amittai Aviram
2009-08-01 15:08 ` Klesk
2009-08-01 17:59 ` John (Eljay) Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).