Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: Source/core/xml/XPathFunctions.cpp

Issue 1324133002: Make XPathFunction map use non-static table of FunctionMapping (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org>
3 * Copyright (C) 2006, 2009 Apple Inc. 3 * Copyright (C) 2006, 2009 Apple Inc.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 return round(arg(0)->evaluate(context).toNumber()); 700 return round(arg(0)->evaluate(context).toNumber());
701 } 701 }
702 702
703 struct FunctionMapping { 703 struct FunctionMapping {
704 const char* name; 704 const char* name;
705 FunctionRec function; 705 FunctionRec function;
706 }; 706 };
707 707
708 static void createFunctionMap() 708 static void createFunctionMap()
709 { 709 {
710 static const FunctionMapping functions[] = { 710 ASSERT(!functionMap);
711 const FunctionMapping functions[] = {
711 { "boolean", { &createFunBoolean, 1 } }, 712 { "boolean", { &createFunBoolean, 1 } },
712 { "ceiling", { &createFunCeiling, 1 } }, 713 { "ceiling", { &createFunCeiling, 1 } },
713 { "concat", { &createFunConcat, Interval(2, Interval::Inf) } }, 714 { "concat", { &createFunConcat, Interval(2, Interval::Inf) } },
714 { "contains", { &createFunContains, 2 } }, 715 { "contains", { &createFunContains, 2 } },
715 { "count", { &createFunCount, 1 } }, 716 { "count", { &createFunCount, 1 } },
716 { "false", { &createFunFalse, 0 } }, 717 { "false", { &createFunFalse, 0 } },
717 { "floor", { &createFunFloor, 1 } }, 718 { "floor", { &createFunFloor, 1 } },
718 { "id", { &createFunId, 1 } }, 719 { "id", { &createFunId, 1 } },
719 { "lang", { &createFunLang, 1 } }, 720 { "lang", { &createFunLang, 1 } },
720 { "last", { &createFunLast, 0 } }, 721 { "last", { &createFunLast, 0 } },
(...skipping 23 matching lines...) Expand all
744 745
745 746
746 Function* createFunction(const String& name) 747 Function* createFunction(const String& name)
747 { 748 {
748 HeapVector<Member<Expression>> args; 749 HeapVector<Member<Expression>> args;
749 return createFunction(name, args); 750 return createFunction(name, args);
750 } 751 }
751 752
752 Function* createFunction(const String& name, HeapVector<Member<Expression>>& arg s) 753 Function* createFunction(const String& name, HeapVector<Member<Expression>>& arg s)
753 { 754 {
754 if (!functionMap) 755 if (!functionMap)
vivekg 2015/09/02 10:15:40 The check here makes sure the function |createFunc
755 createFunctionMap(); 756 createFunctionMap();
756 757
757 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n ame); 758 HashMap<String, FunctionRec>::iterator functionMapIter = functionMap->find(n ame);
758 FunctionRec* functionRec = nullptr; 759 FunctionRec* functionRec = nullptr;
759 760
760 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte r->value)->args.contains(args.size())) 761 if (functionMapIter == functionMap->end() || !(functionRec = &functionMapIte r->value)->args.contains(args.size()))
761 return nullptr; 762 return nullptr;
762 763
763 Function* function = functionRec->factoryFn(); 764 Function* function = functionRec->factoryFn();
764 function->setArguments(args); 765 function->setArguments(args);
765 function->setName(name); 766 function->setName(name);
766 return function; 767 return function;
767 } 768 }
768 769
769 } 770 }
770 } 771 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698