diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/JavaScriptCore/wtf/brew | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/JavaScriptCore/wtf/brew')
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/MainThreadBrew.cpp | 45 | ||||
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp | 81 | ||||
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/RefPtrBrew.h | 59 | ||||
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/ShellBrew.h | 70 | ||||
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/StringBrew.cpp | 43 | ||||
-rw-r--r-- | Source/JavaScriptCore/wtf/brew/SystemMallocBrew.h | 65 |
6 files changed, 363 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/wtf/brew/MainThreadBrew.cpp b/Source/JavaScriptCore/wtf/brew/MainThreadBrew.cpp new file mode 100644 index 0000000..2690ea5 --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/MainThreadBrew.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MainThread.h" + +namespace WTF { + +void initializeMainThreadPlatform() +{ + // not implemented +} + +void scheduleDispatchFunctionsOnMainThread() +{ + // not implemented +} + +} // namespace WTF + diff --git a/Source/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp b/Source/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp new file mode 100644 index 0000000..ce10fc3 --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2010 Company 100 Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "OwnPtr.h" + +#include <AEEBitmap.h> +#include <AEEFile.h> +#include <AEEIMemGroup.h> +#include <AEEIMemSpace.h> +#include <AEENet.h> +#include <AEESSL.h> +#include <AEEStdLib.h> + +namespace WTF { + +void deleteOwnedPtr(IFileMgr* ptr) +{ + if (ptr) + IFILEMGR_Release(ptr); +} + +void deleteOwnedPtr(IFile* ptr) +{ + if (ptr) + IFILE_Release(ptr); +} + +void deleteOwnedPtr(IBitmap* ptr) +{ + if (ptr) + IBitmap_Release(ptr); +} + +void deleteOwnedPtr(ISSL* ptr) +{ + if (ptr) + ISSL_Release(ptr); +} + +void deleteOwnedPtr(IMemGroup* ptr) +{ + if (ptr) + IMemGroup_Release(ptr); +} + +void deleteOwnedPtr(IMemSpace* ptr) +{ + if (ptr) + IMemSpace_Release(ptr); +} + +void deleteOwnedPtr(ISocket* ptr) +{ + if (ptr) + ISOCKET_Release(ptr); +} + +} diff --git a/Source/JavaScriptCore/wtf/brew/RefPtrBrew.h b/Source/JavaScriptCore/wtf/brew/RefPtrBrew.h new file mode 100644 index 0000000..40e257b --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/RefPtrBrew.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2009 Martin Robinson + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef RefPtrBrew_h +#define RefPtrBrew_h + +#include "RefPtr.h" +#include <AEEIBase.h> + +namespace WTF { + +// All Brew MP classes are derived from either IBase or IQI. +template<> void refIfNotNull(IBase* ptr) +{ + if (LIKELY(ptr != 0)) + IBase_AddRef(ptr); +} + +template<> void derefIfNotNull(IBase* ptr) +{ + if (LIKELY(ptr != 0)) + IBase_Release(ptr); +} + +template<> void refIfNotNull(IQI* ptr) +{ + if (LIKELY(ptr != 0)) + IQI_AddRef(ptr); +} + +template<> void derefIfNotNull(IQI* ptr) +{ + if (LIKELY(ptr != 0)) + IQI_Release(ptr); +} + +} // namespace WTF + +#endif // RefPtrBrew_h diff --git a/Source/JavaScriptCore/wtf/brew/ShellBrew.h b/Source/JavaScriptCore/wtf/brew/ShellBrew.h new file mode 100644 index 0000000..8047631 --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/ShellBrew.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2010 Company 100 Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ShellBrew_h +#define ShellBrew_h + +#include <AEEAppGen.h> +#include <AEEStdLib.h> + +#include <wtf/Assertions.h> +#include <wtf/PassOwnPtr.h> +#include <wtf/RefPtr.h> + +namespace WTF { + +template <typename T> +static inline PassOwnPtr<T> createInstance(AEECLSID cls) +{ + T* instance = 0; + + IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; + ISHELL_CreateInstance(shell, cls, reinterpret_cast<void**>(&instance)); + ASSERT(instance); + + return instance; +} + +template <typename T> +static inline RefPtr<T> createRefPtrInstance(AEECLSID cls) +{ + T* instance = 0; + + IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; + ISHELL_CreateInstance(shell, cls, reinterpret_cast<void**>(&instance)); + ASSERT(instance); + + return adoptRef(instance); +} + +} // namespace WTF + +using WTF::createInstance; +using WTF::createRefPtrInstance; + +#endif // ShellBrew_h diff --git a/Source/JavaScriptCore/wtf/brew/StringBrew.cpp b/Source/JavaScriptCore/wtf/brew/StringBrew.cpp new file mode 100644 index 0000000..d8f2e59 --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/StringBrew.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PlatformString.h" + +#include <AEEstd.h> + +namespace WTF { + +// String conversions +String::String(const AECHAR* string) +{ + // It is safe to cast AECHAR to UChar as both of them use 16 bits representation. + const UChar* str = reinterpret_cast<const UChar*>(string); + const size_t len = std_wstrlen(string); + + m_impl = StringImpl::create(str, len); +} + +} // namespace WTF diff --git a/Source/JavaScriptCore/wtf/brew/SystemMallocBrew.h b/Source/JavaScriptCore/wtf/brew/SystemMallocBrew.h new file mode 100644 index 0000000..c973b30 --- /dev/null +++ b/Source/JavaScriptCore/wtf/brew/SystemMallocBrew.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SystemMallocBrew_h +#define SystemMallocBrew_h + +#include <AEEStdLib.h> + +static inline void* mallocBrew(size_t n) +{ + // By default, memory allocated using MALLOC() is initialized + // to zero. This behavior can be disabled by performing a bitwise + // OR of the flag ALLOC_NO_ZMEM with the dwSize parameter. + return MALLOC(n | ALLOC_NO_ZMEM); +} + +static inline void* callocBrew(size_t numElements, size_t elementSize) +{ + return MALLOC(numElements * elementSize); +} + +static inline void freeBrew(void* p) +{ + return FREE(p); +} + +static inline void* reallocBrew(void* p, size_t n) +{ + return REALLOC(p, n | ALLOC_NO_ZMEM); +} + +// Use MALLOC macro instead of the standard malloc function. +// Although RVCT provides malloc, we can't use it in BREW +// because the loader does not initialize the base address properly. +#define malloc(n) mallocBrew(n) +#define calloc(n, s) callocBrew(n, s) +#define realloc(p, n) reallocBrew(p, n) +#define free(p) freeBrew(p) + +#endif // SystemMallocBrew_h |