Merge with the master again.

Bring in the recent JavaScript changes.
This commit is contained in:
Vadim Zeitlin 2014-05-07 23:25:33 +02:00
commit c5e5978287
276 changed files with 11981 additions and 294 deletions

View file

@ -88,7 +88,7 @@ endif
##################################################################
CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# Solaris workshop 5.0
# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
@ -589,6 +589,117 @@ java_clean:
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@JAVASO@
##################################################################
##### JAVASCRIPT ######
##################################################################
# Note: These targets are also from within Makefiles in the Example directories.
# There is a common makefile, 'Examples/javascript/js_example.mk' to simplify
# create a configuration for a new example.
ROOT_DIR = @ROOT_DIR@
JSINCLUDES = @JSCOREINC@ @JSV8INC@
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
JSSO =@JSSO@
JSLDSHARED = @JSLDSHARED@
JSCXXSHARED = @JSCXXSHARED@
NODEJS = @NODEJS@
NODEGYP = @NODEGYP@
# ----------------------------------------------------------------
# Creating and building Javascript wrappers
# ----------------------------------------------------------------
javascript_wrapper:
$(SWIG) -javascript $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH)
javascript_wrapper_cpp: $(SRCS)
$(SWIG) -javascript -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH)
javascript_build: $(SRCS)
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
javascript_build_cpp: $(SRCS)
ifeq (node,$(JSENGINE))
$(NODEGYP) --loglevel=silent configure build 1>>/dev/null
else
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
endif
# These targets are used by the test-suite:
javascript: $(SRCS) javascript_custom_interpreter
$(SWIG) -javascript $(SWIGOPT) $(INTERFACEPATH)
ifeq (jsc, $(ENGINE))
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
else # (v8 | node) # v8 and node must be compiled as c++
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
endif
javascript_cpp: $(SRCS) javascript_custom_interpreter
$(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
# -----------------------------------------------------------------
# Running a Javascript example
# -----------------------------------------------------------------
javascript_custom_interpreter:
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)')
ifeq (node,$(JSENGINE))
javascript_run:
$(RUNTOOL) $(NODEJS) $(RUNME).js $(RUNPIPE)
else
javascript_run: javascript_custom_interpreter
$(RUNTOOL) $(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) $(RUNME).js $(RUNPIPE)
endif
# -----------------------------------------------------------------
# Version display
# -----------------------------------------------------------------
javascript_version:
ifeq (, $(ENGINE))
@if [ "$(NODEJS)" != "" ]; then \
echo "Node.js: `($(NODEJS) --version)`"; \
echo "node-gyp: `($(NODEGYP) --version)`"; \
else \
echo "Version depends on the interpreter"; \
fi
endif
ifeq (node, $(ENGINE))
echo "Node.js: `($(NODEJS) --version)`"
echo "node-gyp: `($(NODEGYP) --version)`"
endif
ifeq (jsc, $(ENGINE))
@if [ "@JSCOREVERSION@" != "" ]; then \
echo "@JSCOREVERSION@"; \
else \
echo "Unknown JavascriptCore version."; \
fi
endif
ifeq (v8, $(ENGINE))
echo "Unknown v8 version."
endif
# -----------------------------------------------------------------
# Cleaning the Javascript examples
# -----------------------------------------------------------------
javascript_clean:
rm -rf build
rm -f *_wrap* $(RUNME)
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
##################################################################
##### ANDROID ######
##################################################################
@ -1510,7 +1621,7 @@ R_SCRIPT=$(RUNME).R
r: $(SRCS)
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
ifneq ($(SRCS),)
$(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
$(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
endif
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
@ -1521,7 +1632,7 @@ endif
r_cpp: $(CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(CXXSRCS),)
$(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
$(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
endif
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : class.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

View file

@ -33,8 +33,8 @@ public:
}
virtual ~Shape() {
nshapes--;
};
double x, y;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
@ -45,7 +45,7 @@ class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { };
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
@ -54,7 +54,7 @@ class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { };
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};

View file

@ -1,4 +1,4 @@
/* File : example.c */
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
@ -11,18 +11,18 @@ void Shape::move(double dx, double dy) {
int Shape::nshapes = 0;
double Circle::area(void) {
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter(void) {
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area(void) {
double Square::area() {
return width*width;
}
double Square::perimeter(void) {
double Square::perimeter() {
return 4*width;
}

0
Examples/guile/matrix/runme.scm Executable file → Normal file
View file

View file

@ -0,0 +1,13 @@
class
constant
enum
exception
functor
nspace
operator
overload
pointer
#reference
simple
template
variables

View file

@ -0,0 +1,3 @@
SRCS = example.cxx
include ../example.mk

View file

@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "example",
"sources": [ "example.cxx", "example_wrap.cxx" ]
}
]
}

View file

@ -0,0 +1,28 @@
/* File : example.cxx */
#include "example.h"
#define M_PI 3.14159265358979323846
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
int Shape::nshapes = 0;
double Circle::area() {
return M_PI*radius*radius;
}
double Circle::perimeter() {
return 2*M_PI*radius;
}
double Square::area() {
return width*width;
}
double Square::perimeter() {
return 4*width;
}

View file

@ -0,0 +1,34 @@
/* File : example.h */
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
};
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
virtual double perimeter();
};
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};

View file

@ -0,0 +1,9 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"

View file

@ -0,0 +1 @@
module.exports = require("./build/Release/example");

View file

@ -0,0 +1,46 @@
var example = require("./example");
// ----- Object creation -----
console.log("Creating some objects:");
c = new example.Circle(10);
console.log("Created circle " + c);
s = new example.Square(10);
console.log("Created square " + s);
// ----- Access a static member -----
console.log("\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;
console.log("\nHere is their new position:");
console.log("Circle = (" + c.x + "," + c.y + ")");
console.log("Square = (" + s.x + "," + s.y + ")");
// ----- Call some methods -----
console.log("\nHere are some properties of the shapes:");
console.log("Circle:");
console.log("area = " + c.area() + "");
console.log("perimeter = " + c.perimeter() + "");
console.log("\n");
console.log("Square:");
console.log("area = " + s.area() + "");
console.log("perimeter = " + s.perimeter() + "");
// ----- Delete everything -----
console.log("\nGuess I'll clean up now");
// Note: this invokes the virtual destructor
delete c;
delete s;
console.log(example.Shape.nshapes + " shapes remain");
console.log("Goodbye");

View file

@ -0,0 +1,3 @@
SRCS =
include ../example.mk

View file

@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "example",
"sources": [ "example_wrap.cxx" ]
}
]
}

View file

@ -0,0 +1,8 @@
#define ICONST 42
#define FCONST 2.1828
#define CCONST 'x'
#define CCONST2 '\n'
#define SCONST "Hello World"
#define SCONST2 "\"Hello World\""
#define EXTERN extern
#define FOO (ICONST + BAR)

View file

@ -0,0 +1,24 @@
/* File : example.i */
%module example
/* A few preprocessor macros */
#define ICONST 42
#define FCONST 2.1828
#define CCONST 'x'
#define CCONST2 '\n'
#define SCONST "Hello World"
#define SCONST2 "\"Hello World\""
/* This should work just fine */
#define EXPR ICONST + 3*(FCONST)
/* This shouldn't do anything */
#define EXTERN extern
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
/* The following directives also produce constants */
%constant int iconst = 37;
%constant double fconst = 3.14;

Some files were not shown because too many files have changed in this diff Show more