Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
jeremy_c is currently offline  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 Go to previous message
jeremy_c is currently offline  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
Previous Topic: How to add global var to Esc from cpp-files?
Next Topic: SIC_ vs ESC_ prefixes?
Goto Forum:
  


Current Time: Thu Mar 28 11:27:17 CET 2024

Total time taken to generate the page: 0.01276 seconds