Merge branch 'devel' of https://github.com/Neha03/gsoc2012-javascript into devel
Conflicts: .project COPYRIGHT Doc/Manual/style.css Examples/Makefile.in Examples/test-suite/common.mk Lib/typemaps/strings.swg Makefile.in Source/DOH/fio.c Source/Makefile.am Source/Modules/emit.cxx Source/Modules/javascript.cxx configure.in git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13764 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
360ef44e09
commit
050219d998
136 changed files with 7987 additions and 141 deletions
51
Examples/javascript/class/runme.js
Executable file
51
Examples/javascript/class/runme.js
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
// file: runme.js
|
||||
|
||||
// ----- Object creation -----
|
||||
|
||||
print("Creating some objects:");
|
||||
c = new example.Circle(10);
|
||||
print("Created circle " + c);
|
||||
s = new example.Square(10);
|
||||
print("Created square " + s);
|
||||
|
||||
// ----- Access a static member -----
|
||||
print("\nA total of " + example.Shape.nshapes + " shapes were created"); // access static member as properties of the class object
|
||||
|
||||
// ----- Member data access -----
|
||||
// Set the location of the object.
|
||||
// Note: methods in the base class Shape are used since
|
||||
// x and y are defined there.
|
||||
|
||||
c.x = 20;
|
||||
c.y = 30;
|
||||
s.x = -10;
|
||||
s.y = 5;
|
||||
|
||||
print("\nHere is their current position:");
|
||||
print("Circle = (" + c.x + "," + c.y + ")");
|
||||
print("Square = (" + s.x + "," + s.y + ")");
|
||||
|
||||
print("\nHere is their new position:");
|
||||
print("Circle = (" + c.x + "," + c.y + ")");
|
||||
print("Square = (" + s.x + "," + s.y + ")");
|
||||
|
||||
|
||||
// ----- Call some methods -----
|
||||
print("\nHere are some properties of the shapes:");
|
||||
print("Circle:");
|
||||
print("area = " + c.area() + "");
|
||||
print("perimeter = " + c.perimeter() + "");
|
||||
print("\n");
|
||||
print("Square:");
|
||||
print("area = " + s.area() + "");
|
||||
print("perimeter = " + s.perimeter() + "");
|
||||
|
||||
// ----- Delete everything -----
|
||||
print("\nGuess I'll clean up now");
|
||||
// Note: this invokes the virtual destructor
|
||||
delete c;
|
||||
delete s;
|
||||
|
||||
print (example.Shape.nshapes + " shapes remain");
|
||||
|
||||
print("Goodbye");
|
||||
Loading…
Add table
Add a link
Reference in a new issue