summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/golang.org/x/text/collate/tools/colcmp/darwin.go
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/golang.org/x/text/collate/tools/colcmp/darwin.go')
-rw-r--r--vendor/golang.org/x/text/collate/tools/colcmp/darwin.go111
1 files changed, 0 insertions, 111 deletions
diff --git a/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go b/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go
deleted file mode 100644
index d2300e3e2..000000000
--- a/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build darwin
-
-package main
-
-/*
-#cgo LDFLAGS: -framework CoreFoundation
-#include <CoreFoundation/CFBase.h>
-#include <CoreFoundation/CoreFoundation.h>
-*/
-import "C"
-import (
- "unsafe"
-)
-
-func init() {
- AddFactory(CollatorFactory{"osx", newOSX16Collator,
- "OS X/Darwin collator, using native strings."})
- AddFactory(CollatorFactory{"osx8", newOSX8Collator,
- "OS X/Darwin collator for UTF-8."})
-}
-
-func osxUInt8P(s []byte) *C.UInt8 {
- return (*C.UInt8)(unsafe.Pointer(&s[0]))
-}
-
-func osxCharP(s []uint16) *C.UniChar {
- return (*C.UniChar)(unsafe.Pointer(&s[0]))
-}
-
-// osxCollator implements an Collator based on OS X's CoreFoundation.
-type osxCollator struct {
- loc C.CFLocaleRef
- opt C.CFStringCompareFlags
-}
-
-func (c *osxCollator) init(locale string) {
- l := C.CFStringCreateWithBytes(
- C.kCFAllocatorDefault,
- osxUInt8P([]byte(locale)),
- C.CFIndex(len(locale)),
- C.kCFStringEncodingUTF8,
- C.Boolean(0),
- )
- c.loc = C.CFLocaleCreate(C.kCFAllocatorDefault, l)
-}
-
-func newOSX8Collator(locale string) (Collator, error) {
- c := &osx8Collator{}
- c.init(locale)
- return c, nil
-}
-
-func newOSX16Collator(locale string) (Collator, error) {
- c := &osx16Collator{}
- c.init(locale)
- return c, nil
-}
-
-func (c osxCollator) Key(s Input) []byte {
- return nil // sort keys not supported by OS X CoreFoundation
-}
-
-type osx8Collator struct {
- osxCollator
-}
-
-type osx16Collator struct {
- osxCollator
-}
-
-func (c osx16Collator) Compare(a, b Input) int {
- sa := C.CFStringCreateWithCharactersNoCopy(
- C.kCFAllocatorDefault,
- osxCharP(a.UTF16),
- C.CFIndex(len(a.UTF16)),
- C.kCFAllocatorDefault,
- )
- sb := C.CFStringCreateWithCharactersNoCopy(
- C.kCFAllocatorDefault,
- osxCharP(b.UTF16),
- C.CFIndex(len(b.UTF16)),
- C.kCFAllocatorDefault,
- )
- _range := C.CFRangeMake(0, C.CFStringGetLength(sa))
- return int(C.CFStringCompareWithOptionsAndLocale(sa, sb, _range, c.opt, c.loc))
-}
-
-func (c osx8Collator) Compare(a, b Input) int {
- sa := C.CFStringCreateWithBytesNoCopy(
- C.kCFAllocatorDefault,
- osxUInt8P(a.UTF8),
- C.CFIndex(len(a.UTF8)),
- C.kCFStringEncodingUTF8,
- C.Boolean(0),
- C.kCFAllocatorDefault,
- )
- sb := C.CFStringCreateWithBytesNoCopy(
- C.kCFAllocatorDefault,
- osxUInt8P(b.UTF8),
- C.CFIndex(len(b.UTF8)),
- C.kCFStringEncodingUTF8,
- C.Boolean(0),
- C.kCFAllocatorDefault,
- )
- _range := C.CFRangeMake(0, C.CFStringGetLength(sa))
- return int(C.CFStringCompareWithOptionsAndLocale(sa, sb, _range, c.opt, c.loc))
-}