Index: SWIG/mcbasket.i
===================================================================
--- SWIG/mcbasket.i	(revision 0)
+++ SWIG/mcbasket.i	(revision 0)
@@ -0,0 +1,180 @@
+
+/*
+ Copyright (C) 2010 Andrea Odetti
+
+ This file is part of QuantLib, a free-software/open-source library
+ for financial quantitative analysts and developers - http://quantlib.org/
+
+ QuantLib is free software: you can redistribute it and/or modify it
+ under the terms of the QuantLib license.  You should have received a
+ copy of the license along with this program; if not, please email
+ <quantlib-dev@lists.sf.net>. The license is also available online at
+ <http://quantlib.org/license.shtml>.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE.  See the license for more details.
+*/
+
+#ifndef quantlib_mcbasket_i
+#define quantlib_mcbasket_i
+
+%include common.i
+%include stochasticprocess.i
+%include stl.i
+%include linearalgebra.i
+%include instruments.i
+
+// pathpayoff
+
+%{
+    using QuantLib::Array;
+%}
+
+%feature("director") QuantLib::ExternalOption;
+
+%template(ArrayVector) std::vector<Array>;
+
+namespace QuantLib {
+
+    class ExternalOption {
+    public:
+        virtual ~ExternalOption() {}
+	
+        virtual void value(const Matrix       & path, 
+                           Array              & payments, 
+                           Array              & exercises, 
+                           std::vector<Array> & states) const = 0;
+        virtual std::vector<Date> fixingDates() const = 0;
+        virtual Size basisSystemDimension() const = 0;
+
+        boost::shared_ptr<Instrument> option() const;
+    };
+}
+
+%{
+    using QuantLib::MCAmericanPathEngine;
+    using QuantLib::MCPathBasketEngine;
+    using QuantLib::PseudoRandom;
+    using QuantLib::LowDiscrepancy;
+    typedef boost::shared_ptr<PricingEngine> MCAmericanPathEnginePtr;
+    typedef boost::shared_ptr<PricingEngine> MCPathBasketEnginePtr;
+%}
+
+%rename(MCAmericanPathEngine) MCAmericanPathEnginePtr;
+class MCAmericanPathEnginePtr : public boost::shared_ptr<PricingEngine> {
+    %feature("kwargs") MCAmericanPathEnginePtr;
+ public:
+    %extend {
+	MCAmericanPathEnginePtr(const StochasticProcessArrayPtr& process,
+				const std::string& traits,
+				intOrNull timeSteps = Null<Size>(),
+				intOrNull timeStepsPerYear = Null<Size>(),
+				bool brownianBridge = false,
+				bool antitheticVariate = false,
+				intOrNull requiredSamples = Null<Size>(),
+				doubleOrNull requiredTolerance = Null<Real>(),
+				intOrNull maxSamples = Null<Size>(),
+				BigInteger seed = 0,
+				intOrNull nCalibrationSamples = Null<Size>() ) {
+	    
+	    boost::shared_ptr<StochasticProcessArray> processArray =
+		boost::dynamic_pointer_cast<StochasticProcessArray>(process);
+	    QL_REQUIRE(processArray, "StochasticProcessArray required");
+	    
+	    std::string s = boost::algorithm::to_lower_copy(traits);
+	    QL_REQUIRE(Size(timeSteps) != Null<Size>() ||
+		       Size(timeStepsPerYear) != Null<Size>(),
+		       "number of steps not specified");
+	    
+	    bool controlVariate = false;
+
+	    if (s == "pseudorandom" || s == "pr")
+		return new MCAmericanPathEnginePtr(
+						   new MCAmericanPathEngine<PseudoRandom>(processArray,
+											  timeSteps,
+											  timeStepsPerYear,
+											  brownianBridge,
+											  antitheticVariate,
+											  controlVariate,
+											  requiredSamples,
+											  requiredTolerance,
+											  maxSamples,
+											  seed,
+											  nCalibrationSamples));
+	    else if (s == "lowdiscrepancy" || s == "ld")
+		return new MCAmericanPathEnginePtr(
+						   new MCAmericanPathEngine<LowDiscrepancy>(processArray,
+											    timeSteps,
+											    timeStepsPerYear,
+											    brownianBridge,
+											    antitheticVariate,
+											    controlVariate,
+											    requiredSamples,
+											    requiredTolerance,
+											    maxSamples,
+											    seed,
+											    nCalibrationSamples));
+	    else
+		QL_FAIL("unknown Monte Carlo engine type: "+s);
+	}
+    }
+};
+
+%rename(MCPathBasketEngine) MCPathBasketEnginePtr;
+class MCPathBasketEnginePtr : public boost::shared_ptr<PricingEngine> {
+    %feature("kwargs") MCPathBasketEnginePtr;
+ public:
+    %extend {
+	MCPathBasketEnginePtr(const StochasticProcessArrayPtr& process,
+			      const std::string& traits,
+			      intOrNull timeSteps = Null<Size>(),
+			      intOrNull timeStepsPerYear = Null<Size>(),
+			      bool brownianBridge = false,
+			      bool antitheticVariate = false,
+			      intOrNull requiredSamples = Null<Size>(),
+			      doubleOrNull requiredTolerance = Null<Real>(),
+			      intOrNull maxSamples = Null<Size>(),
+			      BigInteger seed = 0 ) {
+	    
+	    boost::shared_ptr<StochasticProcessArray> processArray =
+		boost::dynamic_pointer_cast<StochasticProcessArray>(process);
+	    QL_REQUIRE(processArray, "StochasticProcessArray required");
+	    
+	    std::string s = boost::algorithm::to_lower_copy(traits);
+	    QL_REQUIRE(Size(timeSteps) != Null<Size>(),
+		       "number of steps not specified");
+	    
+	    bool controlVariate = false;
+
+	    if (s == "pseudorandom" || s == "pr")
+		return new MCPathBasketEnginePtr(
+						   new MCPathBasketEngine<PseudoRandom>(processArray,
+											timeSteps,
+											timeStepsPerYear,
+											brownianBridge,
+											antitheticVariate,
+											controlVariate,
+											requiredSamples,
+											requiredTolerance,
+											maxSamples,
+											seed));
+	    else if (s == "lowdiscrepancy" || s == "ld")
+		return new MCPathBasketEnginePtr(
+						   new MCPathBasketEngine<LowDiscrepancy>(processArray,
+											  timeSteps,
+											  timeStepsPerYear,
+											  brownianBridge,
+											  antitheticVariate,
+											  controlVariate,
+											  requiredSamples,
+											  requiredTolerance,
+											  maxSamples,
+											  seed));
+	    else
+		QL_FAIL("unknown Monte Carlo engine type: "+s);
+	}
+    }
+};
+
+#endif
Index: SWIG/ql.i
===================================================================
--- SWIG/ql.i	(revision 16991)
+++ SWIG/ql.i	(working copy)
@@ -162,6 +162,7 @@
 %include interpolation.i
 %include linearalgebra.i
 %include marketelements.i
+%include mcbasket.i
 %include money.i
 %include montecarlo.i
 %include null.i
Index: SWIG/quantlib.i
===================================================================
--- SWIG/quantlib.i	(revision 16991)
+++ SWIG/quantlib.i	(working copy)
@@ -23,7 +23,7 @@
 #elif defined(SWIGCSHARP)
 %module NQuantLibc
 #else
-%module QuantLib
+%module (directors="1") QuantLib
 #endif
 
 %include exception.i
