simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] [PATCH] use static callbacks instead of template pa


From: Klaus Rudolph
Subject: Re: [Simulavr-devel] [PATCH] use static callbacks instead of template param for IOReg
Date: Fri, 16 Jun 2017 22:50:17 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.1.0

Hi,

I only have taken a very short look over your mail. But it sounds not very good to me because replacing a clear templated structure with: void pointers, c macros, casting, exclude stuff for swig, etc


Sorry that I have very very less time to dig into your proposal, but only from the given excerpt here in the mail I tend to NOT change the existing code.

Regards
 Klaus


static void SetPcifr(void *this_ptr, unsigned pcifrBit) throw() {
     static_cast<HWPcir*>(this_ptr)->SetPcifr(pcifrBit);
}

that use a void* as first parameter and then simply wrap the object
methods. In IOReg class we can now drop to explicitly mention the target
type (and instantiate a template class).

In most cases, it is not necessary to manually wrap the getter/setters;
I defined some handy macros for this:

IOREG_SETGET_UCHAR(HWPort, Pin)

which, in this case, defines two static/class methods (GetPin and
SetPin) in class HWPort.

All the static methods are excluded via #ifndef from SWIG.
I had to rename the GetPin method due to a name ambiguity to GetPhysPin
(returns a Pin& instead of normal GetPin method returning the PINx
register).

(make check runs fine, after fixing a rounfing bug in two ADC test cases)

It would be nice if this change could be added...

Cheers,
panic



_______________________________________________
Simulavr-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/simulavr-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]