@@ -279,181 +279,6 @@ struct InitFunc {
279
279
280
280
} // end namespace internal
281
281
282
- // //////////////////////////////////////////////////////////////////////////////
283
- // POLICIES
284
- // //////////////////////////////////////////////////////////////////////////////
285
-
286
- template <int Index>
287
- struct arg {
288
- static constexpr int index = Index + 1 ;
289
- };
290
-
291
- struct ret_val {
292
- static constexpr int index = 0 ;
293
- };
294
-
295
- /*
296
- template<typename Slot>
297
- struct allow_raw_pointer {
298
- template<typename InputType, int Index>
299
- struct Transform {
300
- typedef typename std::conditional<
301
- Index == Slot::index,
302
- internal::AllowedRawPointer<typename std::remove_pointer<InputType>::type>,
303
- InputType
304
- >::type type;
305
- };
306
- };
307
- */
308
-
309
- // allow all raw pointers
310
- struct allow_raw_pointers {
311
- template <typename InputType, int Index>
312
- struct Transform {
313
- // Use decay to handle references to pointers e.g.(T*&)->(T*).
314
- typedef typename std::decay<InputType>::type DecayedType;
315
- typedef typename std::conditional<
316
- std::is_pointer<DecayedType>::value,
317
- internal::AllowedRawPointer<typename std::remove_pointer<DecayedType>::type>,
318
- InputType
319
- >::type type;
320
- };
321
- };
322
-
323
- // this is temporary until arg policies are reworked
324
- template <typename Slot>
325
- struct allow_raw_pointer : public allow_raw_pointers {
326
- };
327
-
328
- struct async {
329
- template <typename InputType, int Index>
330
- struct Transform {
331
- typedef InputType type;
332
- };
333
- };
334
-
335
- struct pure_virtual {
336
- template <typename InputType, int Index>
337
- struct Transform {
338
- typedef InputType type;
339
- };
340
- };
341
-
342
- template <typename Slot>
343
- struct nonnull {
344
- static_assert (std::is_same<Slot, ret_val>::value, " Only nonnull return values are currently supported." );
345
- template <typename InputType, int Index>
346
- struct Transform {
347
- typedef InputType type;
348
- };
349
- };
350
-
351
- namespace return_value_policy {
352
-
353
- struct take_ownership : public allow_raw_pointers {};
354
- struct reference : public allow_raw_pointers {};
355
-
356
- } // end namespace return_value_policy
357
-
358
- namespace internal {
359
-
360
- #if __cplusplus >= 201703L
361
- template <typename ... Args> using conjunction = std::conjunction<Args...>;
362
- template <typename ... Args> using disjunction = std::disjunction<Args...>;
363
- #else
364
- // Helper available in C++14.
365
- template <bool _Test, class _T1 , class _T2 >
366
- using conditional_t = typename std::conditional<_Test, _T1, _T2>::type;
367
-
368
- template <class ...> struct conjunction : std::true_type {};
369
- template <class B1 > struct conjunction <B1> : B1 {};
370
- template <class B1 , class ... Bn>
371
- struct conjunction <B1, Bn...>
372
- : conditional_t <bool (B1::value), conjunction<Bn...>, B1> {};
373
-
374
- template <class ...> struct disjunction : std::false_type {};
375
- template <class B1 > struct disjunction <B1> : B1 {};
376
- template <class B1 , class ... Bn>
377
- struct disjunction <B1, Bn...>
378
- : conditional_t <bool (B1::value), disjunction<Bn...>, B1> {};
379
- #endif
380
-
381
- template <typename ... Policies>
382
- struct isPolicy ;
383
-
384
- template <typename ... Rest>
385
- struct isPolicy <return_value_policy::take_ownership, Rest...> {
386
- static constexpr bool value = true ;
387
- };
388
-
389
- template <typename ... Rest>
390
- struct isPolicy <return_value_policy::reference, Rest...> {
391
- static constexpr bool value = true ;
392
- };
393
-
394
- template <typename ... Rest>
395
- struct isPolicy <emscripten::async, Rest...> {
396
- static constexpr bool value = true ;
397
- };
398
-
399
- template <typename T, typename ... Rest>
400
- struct isPolicy <emscripten::allow_raw_pointer<T>, Rest...> {
401
- static constexpr bool value = true ;
402
- };
403
-
404
- template <typename ... Rest>
405
- struct isPolicy <allow_raw_pointers, Rest...> {
406
- static constexpr bool value = true ;
407
- };
408
-
409
- template <typename ... Rest>
410
- struct isPolicy <emscripten::pure_virtual, Rest...> {
411
- static constexpr bool value = true ;
412
- };
413
-
414
- template <typename T, typename ... Rest>
415
- struct isPolicy <emscripten::nonnull<T>, Rest...> {
416
- static constexpr bool value = true ;
417
- };
418
-
419
- template <typename T, typename ... Rest>
420
- struct isPolicy <T, Rest...> {
421
- static constexpr bool value = isPolicy<Rest...>::value;
422
- };
423
-
424
- template <>
425
- struct isPolicy <> {
426
- static constexpr bool value = false ;
427
- };
428
-
429
- template <typename ReturnType, typename ... Rest>
430
- struct GetReturnValuePolicy {
431
- using tag = rvp::default_tag;
432
- };
433
-
434
- template <typename ReturnType, typename ... Rest>
435
- struct GetReturnValuePolicy <ReturnType, return_value_policy::take_ownership, Rest...> {
436
- using tag = rvp::take_ownership;
437
- };
438
-
439
- template <typename ReturnType, typename ... Rest>
440
- struct GetReturnValuePolicy <ReturnType, return_value_policy::reference, Rest...> {
441
- using tag = rvp::reference;
442
- };
443
-
444
- template <typename ReturnType, typename T, typename ... Rest>
445
- struct GetReturnValuePolicy <ReturnType, T, Rest...> {
446
- using tag = GetReturnValuePolicy<ReturnType, Rest...>::tag;
447
- };
448
-
449
- template <typename ... Policies>
450
- using isAsync = disjunction<std::is_same<async, Policies>...>;
451
-
452
- template <typename ... Policies>
453
- using isNonnullReturn = disjunction<std::is_same<nonnull<ret_val>, Policies>...>;
454
-
455
- }
456
-
457
282
// //////////////////////////////////////////////////////////////////////////////
458
283
// select_overload and select_const
459
284
// //////////////////////////////////////////////////////////////////////////////
0 commit comments