From 63b1293e1a760e0ce1a27208a5231e705c8f0f3b Mon Sep 17 00:00:00 2001 From: Erez Geva Date: Wed, 3 May 2023 12:09:15 +0200 Subject: Drop D version 1 See #2538 --- Examples/Makefile.in | 13 +- Examples/d/callback/d1/runme.d | 36 -- Examples/d/class/d1/runme.d | 58 -- Examples/d/constants/d1/runme.d | 28 - Examples/d/enum/d1/runme.d | 28 - Examples/d/example.mk.in | 36 +- Examples/d/extend/d1/runme.d | 75 --- Examples/d/funcptr/d1/runme.d | 42 -- Examples/d/simple/d1/runme.d | 27 - Examples/d/variables/d1/runme.d | 71 --- Examples/test-suite/d/Makefile.in | 40 +- Examples/test-suite/d/aggregate_runme.1.d | 25 - Examples/test-suite/d/allprotected_runme.1.d | 65 --- Examples/test-suite/d/apply_strings_runme.1.d | 12 - Examples/test-suite/d/bools_runme.1.d | 20 - Examples/test-suite/d/catches_runme.1.d | 33 -- Examples/test-suite/d/catches_strings_runme.1.d | 32 -- Examples/test-suite/d/char_strings_runme.1.d | 151 ------ Examples/test-suite/d/constover_runme.1.d | 31 -- .../test-suite/d/cpp11_move_typemaps_runme.1.d | 42 -- .../d/cpp11_rvalue_reference_move_runme.1.d | 86 --- .../test-suite/d/cpp11_std_unique_ptr_runme.1.d | 123 ----- Examples/test-suite/d/d_nativepointers_runme.1.d | 38 -- Examples/test-suite/d/default_args_runme.1.d | 127 ----- .../test-suite/d/default_constructor_runme.1.d | 17 - .../test-suite/d/director_alternating_runme.1.d | 7 - Examples/test-suite/d/director_basic_runme.1.d | 59 -- Examples/test-suite/d/director_classes_runme.1.d | 177 ------ Examples/test-suite/d/director_classic_runme.1.d | 207 ------- Examples/test-suite/d/director_ignore_runme.1.d | 39 -- .../test-suite/d/director_primitives_runme.1.d | 122 ----- Examples/test-suite/d/director_protected_runme.1.d | 50 -- Examples/test-suite/d/director_string_runme.1.d | 46 -- Examples/test-suite/d/enum_thorough_runme.1.d | 447 --------------- .../test-suite/d/inherit_target_language_runme.1.d | 29 - Examples/test-suite/d/li_attribute_runme.1.d | 75 --- .../d/li_boost_shared_ptr_bits_runme.1.d | 21 - .../test-suite/d/li_boost_shared_ptr_runme.1.d | 604 --------------------- Examples/test-suite/d/li_std_auto_ptr_runme.1.d | 123 ----- Examples/test-suite/d/li_std_except_runme.1.d | 40 -- Examples/test-suite/d/li_std_string_runme.1.d | 97 ---- Examples/test-suite/d/li_std_vector_runme.1.d | 219 -------- Examples/test-suite/d/li_typemaps_runme.1.d | 94 ---- Examples/test-suite/d/long_long_runme.1.d | 35 -- Examples/test-suite/d/member_pointer_runme.1.d | 43 -- Examples/test-suite/d/nspace_extend_runme.1.d | 32 -- Examples/test-suite/d/nspace_runme.1.d | 87 --- Examples/test-suite/d/operator_overload_runme.1.d | 89 --- .../test-suite/d/overload_complicated_runme.1.d | 50 -- Examples/test-suite/d/overload_template_runme.1.d | 146 ----- Examples/test-suite/d/pointer_reference_runme.1.d | 13 - .../test-suite/d/preproc_constants_c_runme.1.d | 69 --- Examples/test-suite/d/preproc_constants_runme.1.d | 68 --- Examples/test-suite/d/sizet_runme.1.d | 15 - Examples/test-suite/d/sneaky1_runme.1.d | 21 - .../test-suite/d/special_variable_macros_runme.1.d | 43 -- Examples/test-suite/d/threads_runme.1.d | 70 --- Examples/test-suite/d/throw_exception_runme.1.d | 30 - Examples/test-suite/d/typemap_namespace_runme.1.d | 13 - .../test-suite/d/typemap_out_optimal_runme.1.d | 10 - Examples/test-suite/d/varargs_runme.1.d | 20 - Examples/test-suite/d/virtual_poly_runme.1.d | 27 - Examples/test-suite/special_variable_macros.i | 8 - 63 files changed, 26 insertions(+), 4575 deletions(-) delete mode 100644 Examples/d/callback/d1/runme.d delete mode 100644 Examples/d/class/d1/runme.d delete mode 100644 Examples/d/constants/d1/runme.d delete mode 100644 Examples/d/enum/d1/runme.d delete mode 100644 Examples/d/extend/d1/runme.d delete mode 100644 Examples/d/funcptr/d1/runme.d delete mode 100644 Examples/d/simple/d1/runme.d delete mode 100644 Examples/d/variables/d1/runme.d delete mode 100644 Examples/test-suite/d/aggregate_runme.1.d delete mode 100644 Examples/test-suite/d/allprotected_runme.1.d delete mode 100644 Examples/test-suite/d/apply_strings_runme.1.d delete mode 100644 Examples/test-suite/d/bools_runme.1.d delete mode 100644 Examples/test-suite/d/catches_runme.1.d delete mode 100644 Examples/test-suite/d/catches_strings_runme.1.d delete mode 100644 Examples/test-suite/d/char_strings_runme.1.d delete mode 100644 Examples/test-suite/d/constover_runme.1.d delete mode 100644 Examples/test-suite/d/cpp11_move_typemaps_runme.1.d delete mode 100644 Examples/test-suite/d/cpp11_rvalue_reference_move_runme.1.d delete mode 100644 Examples/test-suite/d/cpp11_std_unique_ptr_runme.1.d delete mode 100644 Examples/test-suite/d/d_nativepointers_runme.1.d delete mode 100644 Examples/test-suite/d/default_args_runme.1.d delete mode 100644 Examples/test-suite/d/default_constructor_runme.1.d delete mode 100644 Examples/test-suite/d/director_alternating_runme.1.d delete mode 100644 Examples/test-suite/d/director_basic_runme.1.d delete mode 100644 Examples/test-suite/d/director_classes_runme.1.d delete mode 100644 Examples/test-suite/d/director_classic_runme.1.d delete mode 100644 Examples/test-suite/d/director_ignore_runme.1.d delete mode 100644 Examples/test-suite/d/director_primitives_runme.1.d delete mode 100644 Examples/test-suite/d/director_protected_runme.1.d delete mode 100644 Examples/test-suite/d/director_string_runme.1.d delete mode 100644 Examples/test-suite/d/enum_thorough_runme.1.d delete mode 100644 Examples/test-suite/d/inherit_target_language_runme.1.d delete mode 100644 Examples/test-suite/d/li_attribute_runme.1.d delete mode 100644 Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d delete mode 100644 Examples/test-suite/d/li_boost_shared_ptr_runme.1.d delete mode 100644 Examples/test-suite/d/li_std_auto_ptr_runme.1.d delete mode 100644 Examples/test-suite/d/li_std_except_runme.1.d delete mode 100644 Examples/test-suite/d/li_std_string_runme.1.d delete mode 100644 Examples/test-suite/d/li_std_vector_runme.1.d delete mode 100644 Examples/test-suite/d/li_typemaps_runme.1.d delete mode 100644 Examples/test-suite/d/long_long_runme.1.d delete mode 100644 Examples/test-suite/d/member_pointer_runme.1.d delete mode 100644 Examples/test-suite/d/nspace_extend_runme.1.d delete mode 100644 Examples/test-suite/d/nspace_runme.1.d delete mode 100644 Examples/test-suite/d/operator_overload_runme.1.d delete mode 100644 Examples/test-suite/d/overload_complicated_runme.1.d delete mode 100644 Examples/test-suite/d/overload_template_runme.1.d delete mode 100644 Examples/test-suite/d/pointer_reference_runme.1.d delete mode 100644 Examples/test-suite/d/preproc_constants_c_runme.1.d delete mode 100644 Examples/test-suite/d/preproc_constants_runme.1.d delete mode 100644 Examples/test-suite/d/sizet_runme.1.d delete mode 100644 Examples/test-suite/d/sneaky1_runme.1.d delete mode 100644 Examples/test-suite/d/special_variable_macros_runme.1.d delete mode 100644 Examples/test-suite/d/threads_runme.1.d delete mode 100644 Examples/test-suite/d/throw_exception_runme.1.d delete mode 100644 Examples/test-suite/d/typemap_namespace_runme.1.d delete mode 100644 Examples/test-suite/d/typemap_out_optimal_runme.1.d delete mode 100644 Examples/test-suite/d/varargs_runme.1.d delete mode 100644 Examples/test-suite/d/virtual_poly_runme.1.d (limited to 'Examples') diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5a4639076..9cbdeee78 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -280,17 +280,8 @@ csharp_clean: DLIBPREFIX = @DLIBPREFIX@ -ifeq (,$(D_VERSION)) - D_VERSION = @DDEFAULTVERSION@ -endif - -ifeq (2,$(D_VERSION)) - SWIGD = $(SWIG) -d -d2 - DCOMPILER = @D2COMPILER@ -else - SWIGD = $(SWIG) -d - DCOMPILER = @D1COMPILER@ -endif +SWIGD = $(SWIG) -d -d2 +DCOMPILER = @D2COMPILER@ D_RUNME = ./$(RUNME) diff --git a/Examples/d/callback/d1/runme.d b/Examples/d/callback/d1/runme.d deleted file mode 100644 index e34e09603..000000000 --- a/Examples/d/callback/d1/runme.d +++ /dev/null @@ -1,36 +0,0 @@ -module runme; - -import tango.io.Stdout; -import example; - -public class DCallback : Callback { - public override void run() { - Stdout( "DCallback.run()" ).newline; - } -} - -void main() { - auto caller = new Caller(); - - Stdout( "Adding and calling a normal C++ callback" ).newline; - Stdout( "----------------------------------------" ).newline; - { - scope auto callback = new Callback(); - caller.setCallback(callback); - caller.call(); - caller.resetCallback(); - } - - Stdout.newline; - Stdout( "Adding and calling a D callback" ).newline; - Stdout( "-------------------------------" ).newline; - { - scope auto callback = new DCallback(); - caller.setCallback(callback); - caller.call(); - caller.resetCallback(); - } - - Stdout.newline; - Stdout( "D exit" ).newline; -} diff --git a/Examples/d/class/d1/runme.d b/Examples/d/class/d1/runme.d deleted file mode 100644 index b0c4263a2..000000000 --- a/Examples/d/class/d1/runme.d +++ /dev/null @@ -1,58 +0,0 @@ -// This example illustrates how C++ classes can be used from D using SWIG. -// The D class gets mapped onto the C++ class and behaves as if it is a D class. -module runme; - -import tango.io.Stdout; -import example; - -void main() { - // ----- Object creation ----- - - Stdout( "Creating some objects:" ).newline; - - { - scope Square s = new Square(10); - scope Circle c = new Circle(10); - - // ----- Access a static member ----- - Stdout.format( "{} shapes were created.", Shape.nshapes ).newline; - - // ----- Member data access ----- - - // Notice how we can do this using functions specific to - // the 'Circle' class. - c.x = 20; - c.y = 30; - - // Now use the same functions in the base class - Shape shape = s; - shape.x = -10; - shape.y = 5; - - Stdout( "\nHere is their current position:" ).newline; - Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline; - Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline; - - // ----- Call some methods ----- - - Stdout( "\nHere are some properties of the shapes:" ).newline; - Shape[] shapes = [ cast(Shape) c, cast(Shape) s ]; - foreach ( currentShape; shapes ) - { - Stdout.format( " {}", currentShape.classinfo.name ).newline; - Stdout.format( " area = {}", currentShape.area() ).newline; - Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline; - } - - // Notice how the area() and perimeter() functions really - // invoke the appropriate virtual method on each object. - - // ----- Delete everything ----- - Stdout( "\nGuess I'll clean up now:" ).newline; - // Note: when this using scope is exited the D destructors are called which - // in turn call the C++ destructors. - } - - Stdout.format( "{} shapes remain", Shape.nshapes ).newline; - Stdout( "\nGoodbye!" ).newline; -} diff --git a/Examples/d/constants/d1/runme.d b/Examples/d/constants/d1/runme.d deleted file mode 100644 index 47362cbf3..000000000 --- a/Examples/d/constants/d1/runme.d +++ /dev/null @@ -1,28 +0,0 @@ -module runme; - -import tango.io.Stdout; -static import example; - -void main() { - Stdout.formatln("ICONST = {} (should be 42)", example.ICONST); - Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST); - Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST); - Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2); - Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST); - Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2); - Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR); - Stdout.formatln("iconst = {} (should be 37)", example.iconst); - Stdout.formatln("fconst = {} (should be 3.14)", example.fconst); - - static if (is(typeof(example.EXTERN))) { - Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN ); - } else { - Stdout.formatln("EXTERN isn't defined (good)"); - } - - static if (is(typeof(example.FOO))) { - Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO); - } else { - Stdout.formatln("FOO isn't defined (good)"); - } -} diff --git a/Examples/d/enum/d1/runme.d b/Examples/d/enum/d1/runme.d deleted file mode 100644 index d986986d1..000000000 --- a/Examples/d/enum/d1/runme.d +++ /dev/null @@ -1,28 +0,0 @@ -module runme; - -import tango.io.Stdout; -import example; - -void main() { - Stdout( "Printing out some enum values:" ).newline; - Stdout(" color:").newline; - Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED); - Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE); - Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN); - - Stdout("\n Foo.speed:").newline; - Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE); - Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP); - Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS); - - Stdout("\nTesting use of enums with functions:").newline; - example.enum_test(color.RED, Foo.speed.IMPULSE); - example.enum_test(color.BLUE, Foo.speed.WARP); - example.enum_test(color.GREEN, Foo.speed.LUDICROUS); - - Stdout( "\nTesting use of enum with class method:" ).newline; - scope f = new Foo(); - f.enum_test(Foo.speed.IMPULSE); - f.enum_test(Foo.speed.WARP); - f.enum_test(Foo.speed.LUDICROUS); -} diff --git a/Examples/d/example.mk.in b/Examples/d/example.mk.in index 84b3ceb09..766057f3f 100644 --- a/Examples/d/example.mk.in +++ b/Examples/d/example.mk.in @@ -1,26 +1,10 @@ # # Common Makefile code for building D examples. # -# We actually need to configure this to gain access to the default D version to -# use when D_VERSION is not set. Using Examples/Makefile.in is not enough, as -# the location of the source files (d1/ or d2/) depends on it. The alternative -# would be to add the functionality specific to Examples/d (as opposed to the -# test suite) directly to Examples/Makefile.in. -# # This file is supposed to be included from a Makefile in the subdirectory # corresponding to a specific example. # -ifeq (,$(D_VERSION)) - D_VERSION = @DDEFAULTVERSION@ -endif - -ifeq (1,$(D_VERSION)) - VERSION_DIR = d1/ -else - VERSION_DIR = d2/ -endif - EXAMPLES_TOP = ../../.. SWIG_TOP = ../../../.. SWIGEXE = $(SWIG_TOP)/swig @@ -35,32 +19,32 @@ DFLAGS = -ofrunme ifeq (,$(SRCDIR)) DSRCS = *.d else -DSRCS = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d) +DSRCS = *.d $(addprefix ../$(SRCDIR)d2/,runme.d) endif check: build - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run build: - mkdir -p $(VERSION_DIR) + mkdir -p d2/ if [ -f $(SRCDIR)example.cxx ]; then \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \ elif [ -f $(SRCDIR)example.c ]; then \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \ else \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \ fi - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile clean: - if [ -d $(VERSION_DIR) ]; then \ - $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \ + if [ -d d2/ ]; then \ + $(MAKE) -C d2/ -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \ fi - test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source + test -f d2/runme.d || rm -rf d2/ # Only delete dir if out of source diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d deleted file mode 100644 index 058432096..000000000 --- a/Examples/d/extend/d1/runme.d +++ /dev/null @@ -1,75 +0,0 @@ -/// This file illustrates the cross language polymorphism using directors. -module runme; - -import example; -import tango.io.Stdout; - -// CEO class, which overrides Employee.getPosition(). -class CEO : Manager { -public: - this( char[] name ) { - super( name ); - } - - override char[] getPosition() { - return "CEO"; - } - - // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. - void disownMemory() { - swigCMemOwn = false; - } -} - -void main() { - // Create an instance of CEO, a class derived from the D proxy of the - // underlying C++ class. The calls to getName() and getPosition() are standard, - // the call to getTitle() uses the director wrappers to call CEO.getPosition(). - - auto e = new CEO( "Alice" ); - Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() ); - Stdout.formatln( "Just call her '{}'.", e.getTitle() ); - Stdout( "----------------------" ).newline; - - { - // Create a new EmployeeList instance. This class does not have a C++ - // director wrapper, but can be used freely with other classes that do. - scope auto list = new EmployeeList(); - - // EmployeeList owns its items, so we must surrender ownership of objects we add. - e.disownMemory(); - list.addEmployee(e); - Stdout( "----------------------" ).newline; - - // Now we access the first four items in list (three are C++ objects that - // EmployeeList's constructor adds, the last is our CEO). The virtual - // methods of all these instances are treated the same. For items 0, 1, and - // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls - // getPosition which resolves in D. The call to getPosition is - // slightly different, however, because of the overridden getPosition() call, since - // now the object reference has been "laundered" by passing through - // EmployeeList as an Employee*. Previously, D resolved the call - // immediately in CEO, but now D thinks the object is an instance of - // class Employee. So the call passes through the - // Employee proxy class and on to the C wrappers and C++ director, - // eventually ending up back at the D CEO implementation of getPosition(). - // The call to getTitle() for item 3 runs the C++ Employee::getTitle() - // method, which in turn calls getPosition(). This virtual method call - // passes down through the C++ director class to the D implementation - // in CEO. All this routing takes place transparently. - - Stdout( "(position, title) for items 0-3:" ).newline; - Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() ); - Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() ); - Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() ); - Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() ); - Stdout( "----------------------" ).newline; - - // All Employees will be destroyed when the EmployeeList goes out of scope, - // including the CEO instance. - } - Stdout( "----------------------" ).newline; - - // All done. - Stdout( "Exiting cleanly from D code." ).newline; -} diff --git a/Examples/d/funcptr/d1/runme.d b/Examples/d/funcptr/d1/runme.d deleted file mode 100644 index 1461c1546..000000000 --- a/Examples/d/funcptr/d1/runme.d +++ /dev/null @@ -1,42 +0,0 @@ -module runme; - -import tango.io.Stdout; -static import example; - -extern(C) int add(int a, int b) { - return a + b; -} - -extern(C) int sub(int a, int b) { - return a - b; -} - -extern(C) int mul(int a, int b) { - return a * b; -} - -void main() { - int a = 37; - int b = 42; - - Stdout( "a = " )( a ).newline; - Stdout( "b = " )( b ).newline; - - Stdout( "Trying some C callback functions:" ).newline; - Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline; - Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline; - Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline; - - version (LDC) { - // Currently, there is no way to specify the calling convention for - // function pointer parameters in D, but LDC does strict typechecking for - // them (which is reasonable, but not covered by the language spec yet). - // As a result, there is no way to make the code below compile with LDC at - // the moment, so just skip it. - } else { - Stdout( "Now the same with callback functions defined in D:" ).newline; - Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline; - Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline; - Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline; - } -} diff --git a/Examples/d/simple/d1/runme.d b/Examples/d/simple/d1/runme.d deleted file mode 100644 index 1293f1839..000000000 --- a/Examples/d/simple/d1/runme.d +++ /dev/null @@ -1,27 +0,0 @@ -module runme; - -import tango.io.Stdout; -static import example; - -void main() { - /* - * Call our gcd() function. - */ - int x = 42; - int y = 105; - int g = example.gcd( x, y ); - Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline; - - /* - * Manipulate the Foo global variable. - */ - - // Output its current value - Stdout.format( "Foo = {}", example.Foo ).newline; - - // Change its value - example.Foo = 3.1415926; - - // See if the change took effect - Stdout.format( "Foo = {}", example.Foo ).newline; -} diff --git a/Examples/d/variables/d1/runme.d b/Examples/d/variables/d1/runme.d deleted file mode 100644 index 35c896bdc..000000000 --- a/Examples/d/variables/d1/runme.d +++ /dev/null @@ -1,71 +0,0 @@ -// This example illustrates global variable access from C#. -module runme; - -import tango.io.Stdout; -static import example; - -void main() { - // Try to set the values of some global variables - example.ivar = 42; - example.svar = -31000; - example.lvar = 65537; - example.uivar = 123456; - example.usvar = 61000; - example.ulvar = 654321; - example.scvar = -13; - example.ucvar = 251; - example.cvar = 'S'; - example.fvar = 3.14159f; - example.dvar = 2.1828; - example.strvar = "Hello World"; - example.iptrvar = example.new_int(37); - example.ptptr = example.new_Point(37,42); - example.name = "Bill"; - - // Now print out the values of the variables - Stdout.formatln( "Variables (printed from D):" ); - Stdout.formatln( "ivar = {}", example.ivar ); - Stdout.formatln( "svar = {}", example.svar ); - Stdout.formatln( "lvar = {}", example.lvar ); - Stdout.formatln( "uivar = {}", example.uivar ); - Stdout.formatln( "usvar = {}", example.usvar ); - Stdout.formatln( "ulvar = {}", example.ulvar ); - Stdout.formatln( "scvar = {}", example.scvar ); - Stdout.formatln( "ucvar = {}", example.ucvar ); - Stdout.formatln( "fvar = {}", example.fvar ); - Stdout.formatln( "dvar = {}", example.dvar ); - Stdout.formatln( "cvar = {}", example.cvar ); - Stdout.formatln( "strvar = {}", example.strvar ); - Stdout.formatln( "cstrvar = {}", example.cstrvar ); - Stdout.formatln( "iptrvar = {}", example.iptrvar ); - Stdout.formatln( "name = {}", example.name ); - Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) ); - Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) ); - Stdout.formatln( "status = {}", example.status ); - - Stdout.formatln( "\nVariables (printed from the C library):" ); - example.print_vars(); - - Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" ); - Stdout.formatln( "Checking that the read only variables are readonly..." ); - - Stdout( " 'path'..." ); - static if ( is( typeof( example.path = "a" ) ) ) - Stdout.formatln("Oh dear, this variable is not read only!"); - else - Stdout.formatln("Good."); - - Stdout( " 'status'..." ); - static if ( is( typeof( example.status = 2 ) ) ) - Stdout.formatln("Oh dear, this variable is not read only!"); - else - Stdout.formatln("Good."); - - Stdout.formatln( "\nI'm going to try and update a structure variable:" ); - - example.pt = example.ptptr; - - Stdout( "The new value is " ).flush; - example.pt_print(); - Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) ); -} diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in index d6486845c..8e8003dcd 100644 --- a/Examples/test-suite/d/Makefile.in +++ b/Examples/test-suite/d/Makefile.in @@ -12,18 +12,6 @@ srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ top_builddir = ../@top_builddir@ -ifeq (,$(D_VERSION)) - D_VERSION = @DDEFAULTVERSION@ -endif - -ifeq (2,$(D_VERSION)) - VERSIONSUFFIX = .2 -else - VERSIONSUFFIX = .1 -endif - -SCRIPTSUFFIX = _runme$(VERSIONSUFFIX).d - CPP_TEST_CASES = \ d_nativepointers \ exception_partial_info @@ -44,44 +32,44 @@ SWIGOPT+=-splitproxy -package $* # Rules for the different types of tests %.cpptest: $(setup) - +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_cpp)) + +(cd $*.2 && $(swig_and_compile_cpp)) +$(run_testcase) %.ctest: $(setup) - +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_c)) + +(cd $*.2 && $(swig_and_compile_c)) +$(run_testcase) %.multicpptest: $(setup) - +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_multi_cpp)) + +(cd $*.2 && $(swig_and_compile_multi_cpp)) +$(run_testcase) # Makes a directory for the testcase if it does not exist setup = \ - if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*_runme.2.d ]; then \ echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \ else \ echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \ fi; \ - if [ ! -d $*$(VERSIONSUFFIX) ]; then \ - mkdir $*$(VERSIONSUFFIX); \ + if [ ! -d $*.2 ]; then \ + mkdir $*.2; \ fi; \ - if [ ! -d $*$(VERSIONSUFFIX)/$* ]; then \ - mkdir $*$(VERSIONSUFFIX)/$*; \ + if [ ! -d $*.2/$* ]; then \ + mkdir $*.2/$*; \ fi # Compiles D files then runs the testcase. A testcase is only run if # a file is found which has _runme.d appended after the testcase name. run_testcase = \ - if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - cd $*$(VERSIONSUFFIX) && \ + if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*_runme.2.d ]; then \ + cd $*.2 && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ DFLAGS='-of$*_runme' \ - DSRCS='../$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) `find $* -name *.d`' d_compile && \ + DSRCS='../$(SCRIPTDIR)/$(SCRIPTPREFIX)$*_runme.2.d `find $* -name *.d`' d_compile && \ env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \ else \ - cd $*$(VERSIONSUFFIX) && \ + cd $*.2 && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ DFLAGS='-c' \ DSRCS='`find $* -name *.d`' d_compile && cd .. ; \ @@ -89,6 +77,6 @@ run_testcase = \ # Clean: remove testcase directories %.clean: - @if [ -d $*$(VERSIONSUFFIX) ]; then \ - rm -rf $*$(VERSIONSUFFIX); \ + @if [ -d $*.2 ]; then \ + rm -rf $*.2; \ fi diff --git a/Examples/test-suite/d/aggregate_runme.1.d b/Examples/test-suite/d/aggregate_runme.1.d deleted file mode 100644 index a00d34c25..000000000 --- a/Examples/test-suite/d/aggregate_runme.1.d +++ /dev/null @@ -1,25 +0,0 @@ -module aggregate_runme; - -import aggregate.aggregate; - -void main() { - // Confirm that move() returns correct results under normal use. - int result = move(UP); - if (result != UP) throw new Exception("UP failed"); - - result = move(DOWN); - if (result != DOWN) throw new Exception("DOWN failed"); - - result = move(LEFT); - if (result != LEFT) throw new Exception("LEFT failed"); - - result = move(RIGHT); - if (result != RIGHT) throw new Exception("RIGHT failed"); - - // Confirm that move() raises an exception when the contract is violated. - try { - move(0); - throw new Exception("0 test failed"); - } - catch (Exception e) {} -} diff --git a/Examples/test-suite/d/allprotected_runme.1.d b/Examples/test-suite/d/allprotected_runme.1.d deleted file mode 100644 index 82a180e66..000000000 --- a/Examples/test-suite/d/allprotected_runme.1.d +++ /dev/null @@ -1,65 +0,0 @@ -module allprotected_runme; - -import allprotected.Klass; -import allprotected.ProtectedBase; - -void main() { - auto mpb = new MyProtectedBase("MyProtectedBase"); - mpb.accessProtected(); -} - -class MyProtectedBase : ProtectedBase { -public: - this(char[] name) { - super(name); - } - - void accessProtected() { - char[] s = virtualMethod(); - if (s != "ProtectedBase") - throw new Exception("Failed"); - - Klass k = instanceMethod(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); - - k = instanceOverloaded(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); - - k = instanceOverloaded(new Klass("xyz"), "abc"); - if (k.getName() != "abc") - throw new Exception("Failed"); - - k = staticMethod(new Klass("abc")); - if (k.getName() != "abc") - throw new Exception("Failed"); - - k = staticOverloaded(new Klass("xyz")); - if (k.getName() != "xyz") - throw new Exception("Failed"); - - k = staticOverloaded(new Klass("xyz"), "abc"); - if (k.getName() != "abc") - throw new Exception("Failed"); - - instanceMemberVariable = 30; - int i = instanceMemberVariable; - if (i != 30) - throw new Exception("Failed"); - - staticMemberVariable = 40; - i = staticMemberVariable; - if (i != 40) - throw new Exception("Failed"); - - i = staticConstMemberVariable; - if (i != 20) - throw new Exception("Failed"); - - anEnum = ProtectedBase.AnEnum.EnumVal1; - ProtectedBase.AnEnum ae = anEnum; - if (ae != ProtectedBase.AnEnum.EnumVal1) - throw new Exception("Failed"); - } -} diff --git a/Examples/test-suite/d/apply_strings_runme.1.d b/Examples/test-suite/d/apply_strings_runme.1.d deleted file mode 100644 index 960caa4ca..000000000 --- a/Examples/test-suite/d/apply_strings_runme.1.d +++ /dev/null @@ -1,12 +0,0 @@ -module apply_strings_runme; - -import apply_strings.apply_strings; - -const char[] TEST_MESSAGE = "A message from target language to the C++ world and back again."; - -void main() { - if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed"); - if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed"); - auto pChar = CharFunction(null); - if (pChar !is null) throw new Exception("CharFunction failed"); -} diff --git a/Examples/test-suite/d/bools_runme.1.d b/Examples/test-suite/d/bools_runme.1.d deleted file mode 100644 index f501b0762..000000000 --- a/Examples/test-suite/d/bools_runme.1.d +++ /dev/null @@ -1,20 +0,0 @@ -/// This is the bool runtime testcase. It checks that the C++ bool type works. -module bools_runme; - -import bools.bools; - -void main() { - bool t = true; - bool f = false; - - check_bo(f); - check_bo(t); -} - -void check_bo(bool input) { - for (int i = 0; i < 1000; ++i) { - if (bo(input) != input) { - throw new Exception("Runtime test check_bo failed."); - } - } -} diff --git a/Examples/test-suite/d/catches_runme.1.d b/Examples/test-suite/d/catches_runme.1.d deleted file mode 100644 index 55b18132d..000000000 --- a/Examples/test-suite/d/catches_runme.1.d +++ /dev/null @@ -1,33 +0,0 @@ -module catches_runme; - -import catches.catches; - -void main() { - test({ test_catches(1); }, "C++ int exception thrown, value: 1"); - test({ test_catches(2); }, "two"); - test({ test_catches(3); }, "C++ ThreeException const & exception thrown"); - - test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1"); - test({ test_exception_specification(2); }, "unknown exception"); - test({ test_exception_specification(3); }, "unknown exception"); - - test({ test_catches_all(1); }, "unknown exception"); -} - -void test(void delegate() command, char[] expectedMessage) { - bool didntThrow; - try { - command(); - didntThrow = true; - } catch (Exception e) { - if (e.msg != expectedMessage) { - throw new Exception("Failed to propagate C++ exception. Expected '" ~ - expectedMessage ~ "', but received '" ~ e.msg ~ "'."); - } - } - - if (didntThrow) { - throw new Exception("Failed to propagate C++ exception. Expected '" ~ - expectedMessage ~ "', but no exception was thrown."); - } -} diff --git a/Examples/test-suite/d/catches_strings_runme.1.d b/Examples/test-suite/d/catches_strings_runme.1.d deleted file mode 100644 index 89108355b..000000000 --- a/Examples/test-suite/d/catches_strings_runme.1.d +++ /dev/null @@ -1,32 +0,0 @@ -module catches_strings_runme; - -import catches_strings.catches_strings; -import catches_strings.StringsThrower; -import std.algorithm; - -void main() { - { - bool exception_thrown = false; - try { - StringsThrower.charstring(); - } catch (Exception e) { - if (!canFind(e.msg, "charstring message")) - throw new Exception("incorrect exception message:" ~ e.msg); - exception_thrown = true; - } - if (!exception_thrown) - throw new Exception("Should have thrown an exception"); - } - { - bool exception_thrown = false; - try { - StringsThrower.stdstring(); - } catch (Exception e) { - if (!canFind(e.msg, "stdstring message")) - throw new Exception("incorrect exception message:" ~ e.msg); - exception_thrown = true; - } - if (!exception_thrown) - throw new Exception("Should have thrown an exception"); - } -} diff --git a/Examples/test-suite/d/char_strings_runme.1.d b/Examples/test-suite/d/char_strings_runme.1.d deleted file mode 100644 index cde6fe0f7..000000000 --- a/Examples/test-suite/d/char_strings_runme.1.d +++ /dev/null @@ -1,151 +0,0 @@ -module char_strings_runme; - -import tango.text.convert.Integer; -import char_strings.char_strings; - -const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; -const char[] OTHERLAND_MSG = "Little message from the safe world."; - -void main() { - const uint count = 10000; - uint i = 0; - - // get functions - for (i=0; i