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