Home » Extra libraries, Code snippets, applications etc. » U++ Esc Interpreter, Esc Macros and templates » Creating classes for Esc and using in Esc.
Creating classes for Esc and using in Esc. [message #27850] |
Fri, 06 August 2010 18:41 |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I have the following code for Esc. It's obviously for learning purposes. Once I get this figured out I'll move on to more complex classes.
struct SlescPerson : public EscHandle
{
String mName;
void GetName(EscEscape& e)
{
Exclamation("Getting Name");
e = mName;
}
void SetName(EscEscape& e)
{
Exclamation("Setting Name");
mName = e[0];
}
typedef SlescPerson CLASSNAME;
SlescPerson(EscValue& v)
{
Exclamation("Constructing Person");
v.Escape("GetName()", this, THISBACK(GetName));
v.Escape("SetName(value)", this, THISBACK(SetName));
}
};
Then, I have this in my application to run it:
ArrayMap<String, EscValue> global;
StdLib(global);
Escape(global, "Exclamation(value)", SLESC_Exclamation);
Escape(global, "Person()", SLESC_Person);
Evaluate("p = Person(); p.SetName(\"John\"); Exclamation(p.GetName());", global);
I get the initial exclamation "Constructing Person" but after that I get nothing.
Can someone point me to what I'm doing wrong?
Thanks,
Jeremy
|
|
|
Re: Creating classes for Esc and using in Esc. [message #27853 is a reply to message #27850] |
Fri, 06 August 2010 20:06 |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
Never mind, I figured it out. I can only use Evaluate to eval the first statement it seems?
Scan(global,
"main() {\n"
" p = Person();\n"
" p.SetName(\"John\");\n"
" Exclamation(p.GetName());\n"
"}");
Upp::Execute(global, "main");
caused my "Person" example to work.
Jeremy
|
|
|
Goto Forum:
Current Time: Thu Mar 28 11:27:17 CET 2024
Total time taken to generate the page: 0.01276 seconds
|