source: webkit/trunk/JavaScriptCore/kjs/lookup.cpp@ 13089

Last change on this file since 13089 was 13089, checked in by mjs, 19 years ago

JavaScriptCore:

Reviewed by Darin.


  • Set up new prototype macros and avoid using #if without defined() in JSC


Added new PLATFORM macros and related, to make sure #if's all check if relevant macros
are defined, and to separate core OS-level dependencies from operating environment
dependencies so you can, e.g., build KDE on Mac or Windows.

  • kxmlcore/Platform.h: Added.


  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/jni/jni_utility.cpp: (KJS::Bindings::convertValueToJValue):
  • bindings/objc/WebScriptObject.mm:
  • bindings/objc/objc_instance.mm: (ObjcInstance::end):
  • bindings/softlinking.h:
  • bindings/testbindings.mm: (main):
  • kjs/JSLock.cpp:
  • kjs/collector.cpp: (KJS::Collector::markCurrentThreadConservatively): (KJS::Collector::markOtherThreadConservatively): (KJS::Collector::markStackObjectsConservatively):
  • kjs/config.h:
  • kjs/date_object.cpp: (gmtoffset): (KJS::formatTime): (KJS::DateProtoFunc::callAsFunction): (KJS::DateObjectImp::construct): (KJS::makeTime):
  • kjs/dtoa.cpp:
  • kjs/fpconst.cpp: (KJS::sizeof): (KJS::):
  • kjs/grammar.y:
  • kjs/identifier.cpp:
  • kjs/internal.cpp:
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate): (KJS::Interpreter::createLanguageInstanceForValue):
  • kjs/interpreter.h:
  • kjs/lookup.cpp:
  • kjs/lookup.h:
  • kjs/math_object.cpp:
  • kjs/object.cpp:
  • kjs/object.h:
  • kjs/operations.cpp: (KJS::isNaN): (KJS::isInf): (KJS::isPosInf): (KJS::isNegInf):
  • kjs/operations.h:
  • kjs/regexp.cpp: (KJS::RegExp::RegExp): (KJS::RegExp::~RegExp): (KJS::RegExp::match):
  • kjs/regexp.h:
  • kjs/testkjs.cpp: (StopWatch::start): (StopWatch::stop): (StopWatch::getElapsedMS):
  • kjs/ustring.cpp:
  • kjs/ustring.h:
  • kxmlcore/AlwaysInline.h:
  • kxmlcore/Assertions.cpp:
  • kxmlcore/Assertions.h:
  • kxmlcore/FastMalloc.cpp: (KXMLCore::):
  • kxmlcore/FastMalloc.h:
  • kxmlcore/FastMallocInternal.h:
  • kxmlcore/HashTable.h:
  • kxmlcore/TCPageMap.h:
  • kxmlcore/TCSpinLock.h: (TCMalloc_SpinLock::Lock): (TCMalloc_SpinLock::Unlock): (TCMalloc_SlowLock):
  • kxmlcore/TCSystemAlloc.cpp: (TCMalloc_SystemAlloc):
  • os-win32/stdint.h:

JavaScriptGlue:

Not reviewed, but I noticed these trivial extra changes were needed to avoid
breaking the build with my reviewed patch for:


http://bugzilla.opendarwin.org/show_bug.cgi?id=7387


Add config.h, includes of it, and Platform.h forwarding header.

  • JSBase.cpp:
  • JSObject.cpp:
  • JSRun.cpp:
  • JSUtils.cpp:
  • JSValueWrapper.cpp:
  • JavaScriptGlue.cpp:
  • UserObjectImp.cpp:
  • config.h: Added.
  • kxmlcore/Platform.h: Added.

WebCore:

Reviewed by Darin.


Add Platform.h

  • ForwardingHeaders/kxmlcore/Platform.h: Added.
  • bridge/mac/WebCoreFrameNamespaces.m:
  • bridge/mac/WebCoreViewFactory.m:
  • bridge/mac/WebDashboardRegion.m:
  • config.h:
  • platform/Logging.cpp:
  • platform/mac/ScrollViewMac.mm: (WebCore::ScrollView::addChild):
  • platform/mac/WebCoreCookieAdapter.m:
  • platform/mac/WebCoreGraphicsBridge.m:
  • platform/mac/WebCoreHistory.m:
  • platform/mac/WebCoreImageRendererFactory.m:
  • platform/mac/WebCoreKeyGenerator.m:
  • platform/mac/WebCoreView.m:
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten ([email protected])
5 * Copyright (C) 2003 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23#include "config.h"
24#include <stdio.h>
25#include <string.h>
26
27#include "lookup.h"
28
29using namespace KJS;
30
31static inline bool keysMatch(const UChar *c, unsigned len, const char *s)
32{
33 const char* end = s + len;
34 for (; s != end; c++, s++)
35 if (c->uc != (unsigned char)*s)
36 return false;
37 return *s == 0;
38}
39
40static inline const HashEntry* findEntry(const struct HashTable *table, unsigned int hash,
41 const UChar *c, unsigned int len )
42{
43#ifndef NDEBUG
44 if (table->type != 2) {
45 fprintf(stderr, "KJS: Unknown hash table version.\n");
46 return 0;
47 }
48#endif
49 hash %= table->hashSize;
50
51 const HashEntry *e = &table->entries[hash];
52
53 // empty bucket ?
54 if (!e->s)
55 return 0;
56
57 do {
58 // compare strings
59 if (keysMatch(c, len, e->s))
60 return e;
61
62 // try next bucket
63 e = e->next;
64 } while (e);
65 return 0;
66}
67
68const HashEntry* Lookup::findEntry(const struct HashTable *table,
69 const Identifier &s )
70{
71 const HashEntry* entry = ::findEntry(table, s.ustring().rep()->hash(), s.data(), s.size());
72 return entry;
73}
74
75int Lookup::find(const struct HashTable *table,
76 const UChar *c, unsigned int len)
77{
78 const HashEntry *entry = ::findEntry(table, UString::Rep::computeHash(c, len), c, len);
79 if (entry)
80 return entry->value;
81 return -1;
82}
83
84int Lookup::find(const struct HashTable *table, const Identifier &s)
85{
86 //printf("looking for:%s\n", s.ascii());
87 const HashEntry *entry = ::findEntry(table, s.ustring().rep()->hash(), s.data(), s.size());
88 if (entry)
89 return entry->value;
90 return -1;
91}
Note: See TracBrowser for help on using the repository browser.