Javascript examples.
This commit is contained in:
parent
ecf9f96079
commit
48af60d829
76 changed files with 1685 additions and 0 deletions
21
Examples/javascript/overload/Makefile
Executable file
21
Examples/javascript/overload/Makefile
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS = example.cxx
|
||||
JS_SCRIPT = runme.js
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
wrapper::
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp
|
||||
|
||||
build:: wrapper
|
||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_build
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile javascript_clean
|
||||
|
||||
check:: build
|
||||
$(MAKE) -f $(TOP)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TARGET='$(TARGET)' \
|
||||
TOP='$(TOP)' JS_SCRIPT='$(JS_SCRIPT)' javascript_run
|
||||
8
Examples/javascript/overload/binding.gyp
Normal file
8
Examples/javascript/overload/binding.gyp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "example",
|
||||
"sources": [ "example_wrap.cxx" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
28
Examples/javascript/overload/example.h
Normal file
28
Examples/javascript/overload/example.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include <iostream>
|
||||
|
||||
void f() {
|
||||
std::cout << "Called f()." << std::endl;
|
||||
}
|
||||
|
||||
void f(int val) {
|
||||
std::cout << "Called f(int)." << std::endl;
|
||||
}
|
||||
void f(int val1, int val2) {
|
||||
std::cout << "Called f(int, int)." << std::endl;
|
||||
}
|
||||
|
||||
void f(const char* s) {
|
||||
std::cout << "Called f(const char*)." << std::endl;
|
||||
}
|
||||
|
||||
void f(bool val) {
|
||||
std::cout << "Called f(bool)." << std::endl;
|
||||
}
|
||||
|
||||
void f(long val) {
|
||||
std::cout << "Called f(long)." << std::endl;
|
||||
}
|
||||
|
||||
void f(double val) {
|
||||
std::cout << "Called f(double)." << std::endl;
|
||||
}
|
||||
16
Examples/javascript/overload/example.i
Normal file
16
Examples/javascript/overload/example.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
/*
|
||||
Note: overloading is implemented in a sloppy way currently
|
||||
i.e., only the number of arguments is taken into conideration
|
||||
for dispatching.
|
||||
To solve the problem one has to rename such conflicting methods.
|
||||
*/
|
||||
%rename(f_double) f(double val);
|
||||
|
||||
%include "example.h"
|
||||
9
Examples/javascript/overload/runme.js
Normal file
9
Examples/javascript/overload/runme.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var example = require("./build/Release/example");
|
||||
|
||||
example.f();
|
||||
example.f(1);
|
||||
example.f(1, 2);
|
||||
example.f("bla");
|
||||
example.f(false);
|
||||
example.f(11111111111);
|
||||
example.f_double(1.0);
|
||||
0
Examples/javascript/overload/swig_gdb.log
Normal file
0
Examples/javascript/overload/swig_gdb.log
Normal file
Loading…
Add table
Add a link
Reference in a new issue