Closed
Bug 372971
Opened 18 years ago
Closed 6 years ago
Convert macros to inline functions
Categories
(Core :: General, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: taras.mozilla, Assigned: taras.mozilla)
References
Details
Attachments
(2 files, 5 obsolete files)
32.60 KB,
text/plain
|
Details | |
30.02 KB,
patch
|
Details | Diff | Splinter Review |
PR_MAX|MIN, and similar functions can cause unintended code expansion and make automated analysis more difficult.
Other macros contain large amounts of code and also prevent parsing tools from refactoring code.
Updated•18 years ago
|
Assignee: tglek → nobody
Product: Firefox → Core
QA Contact: general → general
Can't you define some additional PR_MIN/PR_MAX overloads so that (float,int) combinations work without requiring caller changes?
Assignee | ||
Comment 2•18 years ago
|
||
The patch is a bit smaller after providing the overloads. It would be even smaller if there were overloads to mix signed/unsigned types, but that seems like a bad idea.
Context diff please?
Assignee | ||
Comment 4•18 years ago
|
||
Use constructor-style casts instead of C-style casts.
+ PRInt32 beginIn = PR_MAX(0ll, blockOffset - p->mOffset);
+ PRInt32 beginOut = PR_MAX(0ll, p->mOffset - blockOffset);
Could you use constructor casts here instead? 0ll looks really strange to me and looks a lot like 011.
The only other thing I'm worried about is whether we can change stuff in nsprpub. I'm not sure who owns that actually.
Comment 6•18 years ago
|
||
0LL is more legible.
/be
Assignee | ||
Comment 7•18 years ago
|
||
I still don't have a good idea on how to deal with the
NS_IMPL_HTMLBODY_COLOR_ATTR macro in nsHtmlBodyElement.cpp. Should we just
leave it and hope that squash doesn't run into problems with it?
It gets used 4 times. Why don't you just create the 8 generated functions explicitly. For the Get versions, you can use a helper function that takes the attribute nsIAtom* and the default nsColor, so each Get implementation is just
NS_IMETHODIMP
nsHTMLBodyElement::GetVLink(nsAString& aColor)
{
return GetColorHelper(nsGkAtoms::vlink, GetPresContext()->DefaultVisitedLinkColor(), aColor);
}
Comment 9•18 years ago
|
||
Comment on attachment 257712 [details] [diff] [review]
Overloaded min|max. used -u this time
If this patch requires adding the typecasts to some of the arguments
to PR_MAX and PR_MIN, this will break "source compatibility".
Many products other than the Mozilla clients use NSPR, and some of
them are also C++ applications. Could you come up with a patch
that maintain source compatibility?
That's not really possible as far as I know. Can we have some kind of configure option that enables this feature for Mozilla but is off by default?
Assignee | ||
Comment 11•18 years ago
|
||
Use 0LL instead of 0ll, static casts.
Changed PR_ABS to be a function too.
Using typedefs instead of underlying types in the definitions.
Attachment #257712 -
Attachment is obsolete: true
Assignee | ||
Comment 12•18 years ago
|
||
(In reply to comment #10)
> That's not really possible as far as I know. Can we have some kind of configure
> option that enables this feature for Mozilla but is off by default?
>
Or we could change PR_MAX|MIN in the source code to call a function with a new name instead... Such as the std:: C++ one. But I guess that's more of a Mozilla 2 scope.
Assignee | ||
Comment 13•18 years ago
|
||
Not sure if the helper method needs to be private too.
Comment on attachment 257776 [details] [diff] [review]
nsHTMLBodyElement macro expansion
+ if (!aElement->GetAttr(kNameSpaceID_None, aAtom, color)) {
+ NS_RGBToHex(defaultAttrColor, aColor);
Fix indent
Make GetColorHelper just be a nonvirtual method that returns nsresult, not an NS_IMETHOD (that makes it virtual which is unnecessary). Yes, make it private too.
Attachment #257776 -
Flags: superreview+
Attachment #257776 -
Flags: review+
Assignee | ||
Comment 15•18 years ago
|
||
Fixed indent, changed signature. I accidentally left an extra parameter in the last patch, that's gone now.
Attachment #257776 -
Attachment is obsolete: true
Comment 16•18 years ago
|
||
Landed attachment 257778 [details] [diff] [review] on the trunk.
mozilla/content/html/content/src/nsHTMLBodyElement.cpp 1.162
Assignee | ||
Comment 17•18 years ago
|
||
Missed a null check
Attachment #257778 -
Attachment is obsolete: true
Assignee | ||
Comment 18•18 years ago
|
||
Comment on attachment 258470 [details] [diff] [review]
missing null check
This is very wrong
Attachment #258470 -
Attachment is obsolete: true
Comment 19•6 years ago
|
||
Probably not relevant anymore (and the wrong component)
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•