Closed Bug 156464 Opened 24 years ago Closed 24 years ago

Remove static strings from Transformiix

Categories

(Core :: XSLT, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: peterv, Assigned: peterv)

Details

(Whiteboard: TX_BRIDGE_1_1_FIXED 92284 92553)

Attachments

(2 files, 5 obsolete files)

We should get rid of most if not all static strings in Transformiix, most of them can be replaced by using atoms anyway.
Attached patch Convert some functions to atoms. (obsolete) — Splinter Review
Attached patch v2 (obsolete) — Splinter Review
merged to trunk, and added rv checks on qname.init. If that's ok with peterv, I call this a r=axel@pike.org
Attachment #90616 - Attachment is obsolete: true
Comment on attachment 91100 [details] [diff] [review] v2 record r=Pike.
Attachment #91100 - Flags: review+
Note: this bug will be fixed in several stages. I'll start by removing as much usage of the static strings as possible and then remove all the unused strings in a last patch.
Comment on attachment 91100 [details] [diff] [review] v2 +#define CHECK_ELEMENT(_name) qname.mLocalName == txXSLTAtoms::##_name + Eek, I'd much rather see you pass qname as an argument to this macro, I hate macro's that make assumptions about random locals being available where they're used. Any reason to not make this a static inline function in stead of a macro? Or even better, get the local name atom into a local variable and just use == in the if checks below, wouldn't that be the fastest and cleanest thing here? sr=jst either way.
Attachment #91100 - Flags: superreview+
Attached patch v2.1 (obsolete) — Splinter Review
Jst happy.
Attachment #91100 - Attachment is obsolete: true
Attachment #92222 - Flags: superreview+
Attachment #92222 - Flags: review+
Attached patch v2.2Splinter Review
Oops, wrong patch. Pike happy, Jst happy.
Attachment #92222 - Attachment is obsolete: true
Whiteboard: TX_BRIDGE_1_1_FIXED
Attached patch Second round v1 (obsolete) — Splinter Review
Comment on attachment 92405 [details] [diff] [review] Second round v1 Looks fine to me, could you change the comment on FunctionCall::toString to reflect that it just outputs the parameters?
adding the attachement number to the whiteboard, I'll be confused otherwise
Whiteboard: TX_BRIDGE_1_1_FIXED → TX_BRIDGE_1_1_FIXED 92284
Comment on attachment 92405 [details] [diff] [review] Second round v1 >+void BooleanFunctionCall::toString(String& aDest) >+{ >+ txAtom* functionName; >+ switch (mType) { >+ case TX_BOOLEAN: >+ functionName = txXPathAtoms::boolean; >+ break; >+ case TX_LANG: >+ functionName = txXPathAtoms::lang; >+ break; >+ case TX_NOT: >+ functionName = txXPathAtoms::_not; >+ break; >+ case TX_TRUE: >+ functionName = txXPathAtoms::_true; >+ break; >+ default: >+ functionName = txXPathAtoms::_false; >+ break; >+ } >+ if (TX_GET_ATOM_STRING(functionName, aDest)) { >+ FunctionCall::toString(aDest); >+ } >+} Another way to do this would be to have a private virtual function in FunctionCall called 'getNameAtom' or some such that all FunctionCall inheriters can override. Then FunctionCall::toString could call that and do the atom->string conversion so that we only do that once. Not a requirement, but it would IMHO be nice. Also, TX_GET_ATOM_STRING will set aDest, not append to it. >+// XXX This is ugly, but this is the last file to use them, >+// once we convert the parser to directly compare with >+// atoms we should remove these. I take it you want to wait with that until next patch. IMHO we don't have to wait until the lexer is atomized (and i know that Pike has some reservations wrt that) until we do this. >+void FunctionCall::toString(String& aDest) > { >- dest.append(this->name); >- dest.append('('); >- //-- add parameters >+ aDest.append('('); > txListIterator iter(&params); >- int argc = 0; >+ MBool addColon = MB_FALSE; > while (iter.hasNext()) { >- if (argc > 0) >- dest.append(','); >+ if (addColon) { >+ aDest.append(','); >+ } >+ else { >+ addColon = MB_TRUE; >+ } > Expr* expr = (Expr*)iter.next(); >- expr->toString(dest); >- ++argc; >+ expr->toString(aDest); > } >- dest.append(')'); >-} //-- toString >- >+ aDest.append(')'); >+} It seems that this will only add a ',' after every other expression, instead of ever one except the first? Also, wouldn't 'addComma' be a better name then 'addColon'?
Attached patch Second round v2 (obsolete) — Splinter Review
Attachment #92405 - Attachment is obsolete: true
Comment on attachment 92446 [details] [diff] [review] Second round v2 >+txAtom* BooleanFunctionCall::getNameAtom() >+{ >+ switch (mType) { >+ case TX_BOOLEAN: >+ return txXPathAtoms::boolean; >+ case TX_LANG: >+ return txXPathAtoms::lang; >+ case TX_NOT: >+ return txXPathAtoms::_not; >+ case TX_TRUE: >+ return txXPathAtoms::_true; >+ default: >+ return txXPathAtoms::_false; >+ } >+} It is kind'a ugly to return a non-addreffed atom, but if you're fine with it then so am I. I'm also pondering if the above might cause a 'no value returned' warning on some compilers? If it doesn't, r=sicking
Attachment #92446 - Flags: review+
Attachment #92446 - Attachment is obsolete: true
Comment on attachment 92553 [details] [diff] [review] Second round v2.1 Carrying over r=sicking.
Attachment #92553 - Flags: review+
Comment on attachment 92553 [details] [diff] [review] Second round v2.1 - In BooleanFunctionCall::getNameAtom(txAtom** aAtom): +{ + switch (mType) { ... + default: + { + return NS_ERROR_FAILURE; + } You should null out the out param before returning here. Same thing in NodeSetFunctionCall::getNameAtom(), NumberFunctionCall::getNameAtom(), and StringFunctionCall::getNameAtom(). sr=jst
Attachment #92553 - Flags: superreview+
Whiteboard: TX_BRIDGE_1_1_FIXED 92284 → TX_BRIDGE_1_1_FIXED 92284 92553
Landed the TX_BRIDGE_1_1_BRANCH to the trunk.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
we didn't verify for a long time. I really checked, so VERIFIED.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: