8000 Delegate refactoring for same ordering of member functions between sp… · dok-net/arduino-esp8266@70859c8 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 70859c8

Browse files
committed
Delegate refactoring for same ordering of member functions between specializations. Portability fix for Non-ESP Arduino.
1 parent e1bde9b commit 70859c8

File tree

1 file changed

+78
-22
lines changed

1 file changed

+78
-22
lines changed

cores/esp8266/Delegate.h

Lines changed: 78 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,12 @@ namespace detail
445445
DelegatePImpl::fn = fn;
446446
}
447447

448+
template<typename F> DelegatePImpl(const F& fn)
449+
{
450+
kind = FP;
451+
DelegatePImpl::fn = fn;
452+
}
453+
448454
DelegatePImpl& operator=(const DelegatePImpl& del)
449455
{
450456
if (this == &del) return *this;
@@ -502,6 +508,17 @@ namespace detail
502508
return *this;
503509
}
504510

511+
template<typename F> DelegatePImpl& operator=(const F& fn)
512+
{
513+
if (FPA == kind)
514+
{
515+
obj = {};
516+
}
517+
kind = FP;
518+
this->fn = fn;
519+
return *this;
520+
}
521+
505522
DelegatePImpl& IRAM_ATTR operator=(std::nullptr_t)
506523
{
507524
if (FPA == kind)
@@ -694,6 +711,17 @@ namespace detail
694711
return *this;
695712
}
696713

714+
DelegatePImpl& operator=(FunPtr fn)
715+
{
716+
if (FUNC == kind)
717+
{
718+
functional.~FunctionType();
719+
kind = FP;
720+
}
721+
DelegatePImpl::fn = fn;
722+
return *this;
723+
}
724+
697725
template<typename F> DelegatePImpl& operator=(const F& functional)
698726
{
699727
if (FUNC != kind)
@@ -716,17 +744,6 @@ namespace detail
716744
return *this;
717745
}
718746

719-
DelegatePImpl& operator=(FunPtr fn)
720-
{
721-
if (FUNC == kind)
722-
{
723-
functional.~FunctionType();
724-
kind = FP;
725-
}
726-
DelegatePImpl::fn = fn;
727-
return *this;
728-
}
729-
730747
DelegatePImpl& IRAM_ATTR operator=(std::nullptr_t)
731748
{
732749
if (FUNC == kind)
@@ -842,6 +859,11 @@ namespace detail
842859
DelegatePImpl::fn = fn;
843860
}
844861

862+
template<typename F> DelegatePImpl(const F& fn)
863+
{
864+
DelegatePImpl::fn = fn;
865+
}
866+
845867
DelegatePImpl& operator=(const DelegatePImpl& del)
846868
{
847869
if (this == &del) return *this;
@@ -862,6 +884,12 @@ namespace detail
862884
return *this;
863885
}
864886

887+
template<typename F> DelegatePImpl& operator=(const F& fn)
888+
{
889+
DelegatePImpl::fn = fn;
890+
return *this;
891+
}
892+
865893
DelegatePImpl& IRAM_ATTR operator=(std::nullptr_t)
866894
{
867895
fn = nullptr;
@@ -1292,6 +1320,12 @@ namespace detail
12921320
DelegateImpl::fn = fn;
12931321
}
12941322

1323+
template<typename F> DelegateImpl(const F& fn)
1324+
{
1325+
kind = FP;
1326+
DelegateImpl::fn = fn;
1327+
}
1328+
12951329
DelegateImpl& operator=(const DelegateImpl& del)
12961330
{
12971331
if (this == &del) return *this;
@@ -1349,6 +1383,17 @@ namespace detail
13491383
return *this;
13501384
}
13511385

1386+
template<typename F> DelegateImpl& operator=(const F& fn)
1387+
{
1388+
if (FPA == kind)
1389+
{
1390+
obj = {};
1391+
}
1392+
kind = FP;
1393+
this->fn = fn;
1394+
return *this;
1395+
}
1396+
13521397
DelegateImpl& IRAM_ATTR operator=(std::nullptr_t)
13531398
{
13541399
if (FPA == kind)
@@ -1540,6 +1585,17 @@ namespace detail
15401585
return *this;
15411586
}
15421587

1588+
DelegateImpl& operator=(FunPtr fn)
1589+
{
1590+
if (FUNC == kind)
1591+
{
1592+
functional.~FunctionType();
1593+
kind = FP;
1594+
}
1595+
DelegateImpl::fn = fn;
1596+
return *this;
1597+
}
1598+
15431599
template<typename F> DelegateImpl& operator=(const F& functional)
15441600
{
15451601
if (FUNC != kind)
@@ -1562,17 +1618,6 @@ namespace detail
15621618
return *this;
15631619
}
15641620

1565-
DelegateImpl& operator=(FunPtr fn)
1566-
{
1567-
if (FUNC == kind)
1568-
{
1569-
functional.~FunctionType();
1570-
kind = FP;
1571-
}
1572-
DelegateImpl::fn = fn;
1573-
return *this;
1574-
}
1575-
15761621
DelegateImpl& IRAM_ATTR operator=(std::nullptr_t)
15771622
{
15781623
if (FUNC == kind)
@@ -1688,6 +1733,11 @@ namespace detail
16881733
DelegateImpl::fn = fn;
16891734
}
16901735

1736+
template<typename F> DelegateImpl(const F& fn)
1737+
{
1738+
DelegateImpl::fn = fn;
1739+
}
1740+
16911741
DelegateImpl& operator=(const DelegateImpl& del)
16921742
{
16931743
if (this == &del) return *this;
@@ -1708,6 +1758,12 @@ namespace detail
17081758
return *this;
17091759
}
17101760

1761+
template<typename F> DelegateImpl& operator=(const F& fn)
1762+
{
1763+
DelegateImpl::fn = fn;
1764+
return *this;
1765+
}
1766+
17111767
DelegateImpl& IRAM_ATTR operator=(std::nullptr_t)
17121768
{
17131769
fn = nullptr;

0 commit comments

Comments
 (0)
0