logs archiveBotHelp.net / Freenode / #43oh / 2015 / September / 1 / 6
Rickta59
it kind of is
Spirilis
I was thinking of java with its behavior parameterization sh*t like including a "new OnClickListener() { ... code goes here ... }" as an argument to a function
anonymous classes
Rickta59
right
kind of like that
Spirilis
ah k
yeah that is pretty mind blowing stuff for the most part
Rickta59
you could pass the type as an arg
the struct definition i mean
Spirilis
I have a java 8 book that's been twisting my brain lately, the lambda and stream system (not to be confused with I/O streams)
Rickta59
the lambda stuff is part of c++ too
although I've not gone down that path
Spirilis
ok, there's a lot of toys I just had no idea were available :-)
Rickta59
yeah i was blissfully ignoring templates for years :)
decades maybe
Spirilis
though frankly java has been a good experience for making me "get" some of this stuff intuitively
especially watching the myriad practical ways it gets used
Rickta59
i used to do a lot of java
Spirilis
and respecting the concept of superclasses-as-types or in Java, interfaces
Rickta59
not so much any more
the microsoft sun wars in the early 2000s pushed me away from it
Spirilis
heh yeah
Rickta59
as i got badly burnt having a bunch of stuff using M$Java and its awesome dll / ole implementation
it actually kicked suns implementations ass
Spirilis
ah nice
Rickta59
and then overnight .. gone
woosh
Spirilis
now my coworker was saying, it's as if C# is the more open source friendly option out there
just makes my skin crawl but I know he's right
Rickta59
java?
well oracle .. predatory stuff
Spirilis
java's all closed and under oracle's evil empire, and soon to be marginalized further as they campaign against google android
Rickta59
and microsoft is weak now
Spirilis
whereas microsoft's releasing .NET open source
yeah
(probably b/c they are weak and know it)
Rickta59
and no one cares as the world is going to phones
and they missed that boat a couple of times
i refuse to do c#
heh .. probably why i'm not working
Spirilis
heh there ya go
ok 17 template parameters outta be enough
Rickta59
32 so it can be a power of 2
Spirilis
well I could trim u8_SFR ucastat, cause I can check UCBUSY on the TX side by just watching TXIFG
and make it 16 :-)
but nah
Rickta59
or pass the base address and just add to that for the offsets
* not sure if that would work for the msp430
that is a good option with arm stuff
Spirilis
I do something like that in my arduino-1.6 port
but I wanna say... I found some gotchas with that
so I resolved to just make a huge array of all of those instead
Rickta59
http://www.stm32duino.com/viewtopic.php?f=18&t=303 i was messing with other approaches too
* basically using the base address
that worked out quite nicely ..
LED1 = 1 ...
to set
LED1 = 0 to clear
or functions
Spirilis
haha I like that
Rickta59
the code it generated was nice and small
Spirilis
good use of operator
that's another thing I need to grok
kinda get the idea of what it's about but dang
seems pretty powerful
Rickta59
that approach is less frightening to c++ template phobic people
Spirilis
okay, hm.
https://github.com/spirilis/AbstractWiring/blob/master/Implementations/msp430_value/UART_USCI.h
but then it complains loudly about: https://github.com/spirilis/AbstractWiring/blob/master/Implementations/msp430_value/UART_USCI.cpp
../UART_USCI.cpp:6:1: error: invalid use of template-name 'UART_USCI' without an argument list
UART_USCI::UART_USCI(void)
^
../UART_USCI.cpp:12:6: error: 'template<volatile uint8_t* ucactl0, volatile uint8_t* ucactl1, volatile uint8_t* ucamctl, volatile uint8_t* ucaabctl, volatile uint8_t* ucabr0, volatile uint8_t* ucabr1, volatile uint8_t* ucastat, volatile uint8_t* ucatxbuf, volatile uint8_t* ucarxbuf, volatile uint8_t* ucaie, unsigned char ucatxie, unsigned char ucarxie, volatile char* txbuffer, volatile char* rxbuffer, unsigned int tx_buffer_size, ...
... unsigned int rx_buffer_size, volatile uint8_t* pxsel, volatile uint8_t* pxsel2, PortselMode pxsel_specification, unsigned char pxbits> class UART_USCI' used without template parameters
so do I basically have to declare the whole codebase inside the .h?
or just carbon copy the template < > definition to the top of the .cpp ?
http://stackoverflow.com/questions/10263017/used-without-template-parameters
so, basically, yeah
could probably make a #define for it
Rickta59
you have to provide the parameters in the .cpp
Spirilis
just once at the top, or at each and every method specifier?
Rickta59
it is certainly easier if you have a single .h
if you put it into the .cpp
you have to provide the template args to each function
http://dpaste.com/3T6CKF9
see how i had to pass all the parameters on to the function?
template<const uint16_t timerid, enum timer_type tt, const uint16_t tick_count, typename user_funcs >
void Timer_TA3<timerid, tt, tick_count, user_funcs >::on_ccr0(void)
that is because it is in a .cpp ..
Spirilis
oh ok, but, not the types of each one
I think I can palate that
Rickta59
if it wasn't a interrupt handler, i would have just put it in the header
yeah that is the other downside about a sh*tload of arguments
any functions become onerous in a .cpp
which is why you see most of my code in a .h
so i don't have to repeat myself :)
but you can do things .. like
a typedef ...
so that one i pointed out early is an example
ypedef GPIO_PIN<BIT6,P2> P2_6;
« prev 1 2 3 4 5 6 7 8 next »