/* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. 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 GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "AsyncMethodCall.h" /* These classes build on the basic templates declared in AsyncMethodCall.h * * They wrap C++ Method calls * * We require one set of wrappers for "const" methods, and a separate set * for non-const methods. */ template class NativeDestructorCall : public NativeVoidMethodCall { public: /* Constructor */ NativeDestructorCall(const Arguments &args) : NativeVoidMethodCall(args, 0) { } /* Method */ void run() { DEBUG_PRINT_DETAIL("NativeDestructorCall: Async destructor %p", NativeVoidMethodCall::native_obj); delete NativeVoidMethodCall::native_obj; } }; /** Template class with: * wrapped class C * no arguments & void return */ template class NativeVoidMethodCall_0_ : public NativeVoidMethodCall { public: /* Member variables */ typedef void (C::*Method_T)(void); Method_T method; /* Constructors */ NativeVoidMethodCall_0_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 0), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method))(); } }; /** Template class with: * wrapped class C * no arguments * return value of type R */ template class NativeMethodCall_0_ : public NativeMethodCall { public: /* Member variables */ typedef R (C::*Method_T)(void); Method_T method; /* Constructors */ NativeMethodCall_0_(Method_T m, const Arguments &args) : NativeMethodCall(args, 0), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))(); } }; /** Template class with: * wrapped class C * one argument of type A0 * return value of type R */ template class NativeMethodCall_1_ : public NativeMethodCall, public Call_1_ { public: /* Member variables */ typedef R (C::*Method_T)(A0); Method_T method; /* Constructors */ NativeMethodCall_1_(Method_T m, const Arguments &args) : NativeMethodCall(args, 1), Call_1_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))(Call_1_::arg0); } }; /** Template class with: * wrapped class C * one argument of type A0 * Wrapped native method call returning void * The javascript return value is integer 0. */ template class NativeVoidMethodCall_1_ : public NativeVoidMethodCall , public Call_1_ { public: /* Member variables */ typedef void (C::*Method_T)(A0); Method_T method; /* Constructor */ NativeVoidMethodCall_1_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 1), Call_1_(args), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method))(Call_1_::arg0); } }; /** Template class with: * wrapped class C * two arguments of type A0 and A1 * return type R */ template class NativeMethodCall_2_ : public NativeMethodCall, public Call_2_ { public: /* Member variables */ typedef R (C::*Method_T)(A0, A1); // "method" is pointer to member function Method_T method; /* Constructor */ NativeMethodCall_2_(Method_T m, const Arguments &args) : NativeMethodCall(args, 2), Call_2_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_2_::arg0, Call_2_::arg1); } }; /** Template class with * Method returning void; 2 arguments */ template class NativeVoidMethodCall_2_ : public NativeVoidMethodCall , public Call_2_ { public: /* Member variables */ typedef void (C::*Method_T)(A0, A1); Method_T method; /* Constructor */ NativeVoidMethodCall_2_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 2), Call_2_(args), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method)) (Call_2_::arg0, Call_2_::arg1); } }; /** Template class with: * wrapped class C * three arguments of type A0, A1, and A2 * return type R */ template class NativeMethodCall_3_ : public NativeMethodCall , public Call_3_ { public: /* Member variables */ typedef R (C::*Method_T)(A0, A1, A2); Method_T method; /* Constructor */ NativeMethodCall_3_(Method_T m, const Arguments &args) : NativeMethodCall(args, 3), Call_3_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_3_::arg0, Call_3_::arg1, Call_3_::arg2 ); } }; /** Template class with: * wrapped class C * three arguments of type A0, A1, and A2 * void return */ template class NativeVoidMethodCall_3_ : public NativeVoidMethodCall, public Call_3_ { public: /* Member variables */ typedef void (C::*Method_T)(A0, A1, A2); Method_T method; /* Constructor */ NativeVoidMethodCall_3_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 3), Call_3_(args), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method))( Call_3_::arg0, Call_3_::arg1, Call_3_::arg2 ); } }; /** Template class with: * 4 arguments * return value of type R */ template class NativeMethodCall_4_ : public NativeMethodCall , public Call_4_ { public: /* Member variables */ typedef R (C::*Method_T)(A0,A1,A2,A3); Method_T method; /* Constructor */ NativeMethodCall_4_(Method_T m, const Arguments &args) : NativeMethodCall(args, 4), Call_4_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_4_::arg0, Call_4_::arg1, Call_4_::arg2, Call_4_::arg3 ); } }; /** Template class with: * wrapped class C * 4 arguments of type A0, A1, A2, A3 * void return */ template class NativeVoidMethodCall_4_ : public NativeVoidMethodCall, public Call_4_ { public: /* Member variables */ typedef void (C::*Method_T)(A0, A1, A2, A3); Method_T method; /* Constructor */ NativeVoidMethodCall_4_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 4), Call_4_(args), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method))( Call_4_::arg0, Call_4_::arg1, Call_4_::arg2, Call_4_::arg3 ); } }; /** Template class with: * 5 arguments * return value of type R */ template class NativeMethodCall_5_ : public NativeMethodCall, public Call_5_ { public: /* Member variables */ typedef R (C::*Method_T)(A0,A1,A2,A3,A4); Method_T method; /* Constructor */ NativeMethodCall_5_(Method_T m, const Arguments &args) : NativeMethodCall(args, 5), Call_5_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_5_::arg0, Call_5_::arg1, Call_5_::arg2, Call_5_::arg3, Call_5_::arg4 ); } }; /** Template class with: * 6 arguments * return value of type R */ template class NativeMethodCall_6_ : public NativeMethodCall , public Call_6_ { public: /* Member variables */ typedef R (C::*Method_T)(A0,A1,A2,A3,A4,A5); Method_T method; /* Constructor */ NativeMethodCall_6_(Method_T m, const Arguments &args) : NativeMethodCall(args, 6), Call_6_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_6_::arg0, Call_6_::arg1, Call_6_::arg2, Call_6_::arg3, Call_6_::arg4, Call_6_::arg5 ); } }; /** Template class with: * 7 arguments * return value of type R */ template class NativeMethodCall_7_ : public NativeMethodCall, public Call_7_ { public: /* Member variables */ typedef R (C::*Method_T)(A0,A1,A2,A3,A4,A5,A6); Method_T method; /* Constructor */ NativeMethodCall_7_(Method_T m, const Arguments &args) : NativeMethodCall(args, 7), Call_7_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_7_::arg0, Call_7_::arg1, Call_7_::arg2, Call_7_::arg3, Call_7_::arg4, Call_7_::arg5, Call_7_::arg6 ); } }; /** Template class with: * 8 arguments * return value of type R */ template class NativeMethodCall_8_ : public NativeMethodCall, public Call_8_ { public: /* Member variables */ typedef R (C::*Method_T)(A0,A1,A2,A3,A4,A5,A6,A7); Method_T method; /* Constructor */ NativeMethodCall_8_(Method_T m, const Arguments &args) : NativeMethodCall(args, 8), Call_8_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_8_::arg0, Call_8_::arg1, Call_8_::arg2, Call_8_::arg3, Call_8_::arg4, Call_8_::arg5, Call_8_::arg6, Call_8_::arg7 ); } }; /* Const versions */ /** Template class with * Return type R; no arguments */ template class NativeConstMethodCall_0_ : public NativeMethodCall { public: /* Member variables */ typedef R (C::*Method_T)(void) const; Method_T method; /* Constructors */ NativeConstMethodCall_0_(Method_T m, const Arguments &args) : NativeMethodCall(args, 0), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))(); } }; /** Template class with: * return value of type R * one argument of type A0 */ template class NativeConstMethodCall_1_ : public NativeMethodCall, public Call_1_ { public: /* Member variables */ typedef R (C::*Method_T)(A0) const; Method_T method; /* Constructors */ NativeConstMethodCall_1_(Method_T m, const Arguments &args) : NativeMethodCall(args, 1), Call_1_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))(Call_1_::arg0); } }; /** Template class with * Method returning void; 2 arguments */ template class NativeVoidConstMethodCall_2_ : public NativeVoidMethodCall , public Call_2_ { public: /* Member variables */ typedef void (C::*Method_T)(A0, A1) const; Method_T method; /* Constructor */ NativeVoidConstMethodCall_2_(Method_T m, const Arguments &args) : NativeVoidMethodCall(args, 2), Call_2_(args), method(m) { } /* Methods */ void run() { ((NativeVoidMethodCall::native_obj)->*(method)) (Call_2_::arg0, Call_2_::arg1); } }; /** Template class with * Method returning R; 2 arguments */ template class NativeConstMethodCall_2_ : public NativeMethodCall, public Call_2_ { public: /* Member variables */ typedef R (C::*Method_T)(A0, A1) const; Method_T method; /* Constructor */ NativeConstMethodCall_2_(Method_T m, const Arguments &args) : NativeMethodCall(args, 2), Call_2_(args), method(m) { } /* Methods */ void run() { NativeMethodCall::return_val = ((NativeMethodCall::native_obj)->*(method))( Call_2_::arg0, Call_2_::arg1); } };