2014-08-10 08:59:50 +00:00
|
|
|
// This file was GENERATED by command:
|
|
|
|
// pump.py constructor.h.pump
|
|
|
|
// DO NOT EDIT BY HAND!!!
|
|
|
|
|
2014-04-15 07:30:46 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE.chromium file.
|
|
|
|
|
|
|
|
#ifndef NATIVE_MATE_WRAPPABLE_CLASS_H_
|
|
|
|
#define NATIVE_MATE_WRAPPABLE_CLASS_H_
|
|
|
|
|
2014-04-16 01:50:51 +00:00
|
|
|
#include "base/bind.h"
|
|
|
|
#include "native_mate/function_template.h"
|
2014-04-15 07:30:46 +00:00
|
|
|
|
|
|
|
namespace mate {
|
|
|
|
|
2014-04-16 01:50:51 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// This set of templates invokes a base::Callback by converting the Arguments
|
|
|
|
// into native types. It relies on the function_template.h to provide helper
|
|
|
|
// templates.
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*()>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run();
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
2014-08-10 08:59:50 +00:00
|
|
|
if (!GetNextArgument(args, 0, true, &a1))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1, typename P2>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1, P2)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
|
|
|
typename CallbackParamTraits<P2>::LocalType a2;
|
|
|
|
if (!GetNextArgument(args, 0, true, &a1) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a2))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1, a2);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1, typename P2, typename P3>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1, P2, P3)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
|
|
|
typename CallbackParamTraits<P2>::LocalType a2;
|
|
|
|
typename CallbackParamTraits<P3>::LocalType a3;
|
|
|
|
if (!GetNextArgument(args, 0, true, &a1) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a2) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a3))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1, a2, a3);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1, typename P2, typename P3, typename P4>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1, P2, P3, P4)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
|
|
|
typename CallbackParamTraits<P2>::LocalType a2;
|
|
|
|
typename CallbackParamTraits<P3>::LocalType a3;
|
|
|
|
typename CallbackParamTraits<P4>::LocalType a4;
|
|
|
|
if (!GetNextArgument(args, 0, true, &a1) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a2) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a3) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a4))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1, a2, a3, a4);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1, typename P2, typename P3, typename P4, typename P5>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1, P2, P3, P4, P5)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
|
|
|
typename CallbackParamTraits<P2>::LocalType a2;
|
|
|
|
typename CallbackParamTraits<P3>::LocalType a3;
|
|
|
|
typename CallbackParamTraits<P4>::LocalType a4;
|
|
|
|
typename CallbackParamTraits<P5>::LocalType a5;
|
|
|
|
if (!GetNextArgument(args, 0, true, &a1) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a2) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a3) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a4) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a5))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1, a2, a3, a4, a5);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename P1, typename P2, typename P3, typename P4, typename P5,
|
|
|
|
typename P6>
|
2016-04-25 01:17:39 +00:00
|
|
|
inline WrappableBase* InvokeFactory(
|
2014-04-16 01:50:51 +00:00
|
|
|
Arguments* args,
|
2016-04-25 01:17:39 +00:00
|
|
|
const base::Callback<WrappableBase*(P1, P2, P3, P4, P5, P6)>& callback) {
|
2014-04-16 01:50:51 +00:00
|
|
|
typename CallbackParamTraits<P1>::LocalType a1;
|
|
|
|
typename CallbackParamTraits<P2>::LocalType a2;
|
|
|
|
typename CallbackParamTraits<P3>::LocalType a3;
|
|
|
|
typename CallbackParamTraits<P4>::LocalType a4;
|
|
|
|
typename CallbackParamTraits<P5>::LocalType a5;
|
|
|
|
typename CallbackParamTraits<P6>::LocalType a6;
|
|
|
|
if (!GetNextArgument(args, 0, true, &a1) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a2) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a3) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a4) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a5) ||
|
|
|
|
!GetNextArgument(args, 0, false, &a6))
|
2016-04-25 01:17:39 +00:00
|
|
|
return nullptr;
|
2014-04-16 01:50:51 +00:00
|
|
|
return callback.Run(a1, a2, a3, a4, a5, a6);
|
|
|
|
};
|
|
|
|
|
2016-08-02 08:01:19 +00:00
|
|
|
template<typename Sig>
|
|
|
|
MATE_METHOD_RETURN_TYPE InvokeNew(const base::Callback<Sig>& factory,
|
|
|
|
v8::Isolate* isolate, Arguments* args) {
|
|
|
|
if (!args->IsConstructCall()) {
|
|
|
|
args->ThrowError("Requires constructor call");
|
|
|
|
MATE_METHOD_RETURN_UNDEFINED();
|
2014-04-16 01:50:51 +00:00
|
|
|
}
|
2014-04-15 07:30:46 +00:00
|
|
|
|
2016-08-02 08:01:19 +00:00
|
|
|
WrappableBase* object;
|
|
|
|
{
|
|
|
|
// Don't continue if the constructor throws an exception.
|
|
|
|
v8::TryCatch try_catch;
|
|
|
|
object = internal::InvokeFactory(args, factory);
|
|
|
|
if (try_catch.HasCaught()) {
|
|
|
|
try_catch.ReThrow();
|
2014-10-30 13:54:29 +00:00
|
|
|
MATE_METHOD_RETURN_UNDEFINED();
|
|
|
|
}
|
2014-04-16 01:50:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 08:01:19 +00:00
|
|
|
if (!object)
|
|
|
|
args->ThrowError();
|
2014-04-15 07:30:46 +00:00
|
|
|
|
2016-08-02 08:01:19 +00:00
|
|
|
MATE_METHOD_RETURN_UNDEFINED();
|
2014-04-16 01:50:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 08:01:19 +00:00
|
|
|
} // namespace internal
|
|
|
|
|
2014-04-15 07:30:46 +00:00
|
|
|
} // namespace mate
|
|
|
|
|
|
|
|
#endif // NATIVE_MATE_WRAPPABLE_CLASS_H_
|