Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
TOP = ../..
SWIGEXE = $(TOP)/../swig
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
CXXSRCS = example.cxx
TARGET = example
INTERFACE = example.i
check: build
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
build:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
clean:
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean

View File

@@ -0,0 +1,37 @@
/* File : example.c */
#include "example.h"
#include <stdio.h>
void Foo::enum_test(speed s) {
if (s == IMPULSE) {
printf("IMPULSE speed\n");
} else if (s == WARP) {
printf("WARP speed\n");
} else if (s == LUDICROUS) {
printf("LUDICROUS speed\n");
} else {
printf("Unknown speed\n");
}
}
void enum_test(color c, Foo::speed s) {
if (c == RED) {
printf("color = RED, ");
} else if (c == BLUE) {
printf("color = BLUE, ");
} else if (c == GREEN) {
printf("color = GREEN, ");
} else {
printf("color = Unknown color!, ");
}
if (s == Foo::IMPULSE) {
printf("speed = IMPULSE speed\n");
} else if (s == Foo::WARP) {
printf("speed = WARP speed\n");
} else if (s == Foo::LUDICROUS) {
printf("speed = LUDICROUS speed\n");
} else {
printf("speed = Unknown speed!\n");
}
}

View File

@@ -0,0 +1,13 @@
/* File : example.h */
enum color { RED, BLUE, GREEN };
class Foo {
public:
Foo() { }
enum speed { IMPULSE, WARP, LUDICROUS };
void enum_test(speed s);
};
void enum_test(color c, Foo::speed s);

View File

@@ -0,0 +1,10 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
%include "example.h"

View File

@@ -0,0 +1,36 @@
lines(0);
ilib_verbose(0);
ierr = exec('loader.sce', 'errcatch');
if ierr <> 0 then
disp(lasterror());
exit(ierr);
end
example_Init();
printf("\nTest enums\n");
printf("*** color ***\n");
printf(" RED_get() = %i\n", RED_get());
printf(" BLUE_get() = %i\n", BLUE_get());
printf(" GREEN_get() = %i\n", GREEN_get());
printf("\n*** Foo::speed ***\n")
printf(" Foo_IMPULSE = %i\n", Foo_IMPULSE_get());
printf(" Foo_WARP = %i\n", Foo_WARP_get());
printf(" Foo_LUDICROUS = %i\n", Foo_LUDICROUS_get());
printf("\nTest enums as argument of functions\n");
enum_test(RED_get(), Foo_IMPULSE_get());
enum_test(BLUE_get(), Foo_WARP_get());
enum_test(GREEN_get(), Foo_LUDICROUS_get());
enum_test(1234, 5678);
printf("\nTest enums as argument of class methods\n");
f = new_Foo();
Foo_enum_test(f, Foo_IMPULSE_get());
Foo_enum_test(f, Foo_WARP_get());
Foo_enum_test(f, Foo_LUDICROUS_get());
delete_Foo(f);
exit