// Copyright 2009 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 ingore

// Package log implements a simple logging package. It defines a type, Logger,
// with methods for formatting output. It also has a predefined 'standard'
// Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and
// Panic[f|ln], which are easier to use than creating a Logger manually.
// That logger writes to standard error and prints the date and time
// of each logged message.
// The Fatal functions call os.Exit(1) after writing the log message.
// The Panic functions call panic after writing the log message.

// log包实现了简单的日志服务。本包定义了Logger类型，该类型提供了一些格式化输出的
// 方法。本包也提供了一个预定义的“标准”Logger，可以通过辅助函数Print[f|ln]、
// Fatal[f|ln]和Panic[f|ln]访问，比手工创建一个Logger对象更容易使用。Logger会打
// 印每条日志信息的日期、时间，默认输出到标准错误。Fatal系列函数会在写入日志信息
// 后调用os.Exit(1)。Panic系列函数会在写入日志信息后panic。
package log

import (
	"fmt"
	"io"
	"os"
	"runtime"
	"sync"
	"time"
)

// These flags define which text to prefix to each log entry generated by the
// Logger.

// 这些选项定义Logger类型如何生成用于每条日志的前缀文本。
const (
	// Bits or'ed together to control what's printed.
	// There is no control over the order they appear (the order listed
	// here) or the format they present (as described in the comments).
	// The prefix is followed by a colon only when Llongfile or Lshortfile
	// is specified.
	// For example, flags Ldate | Ltime (or LstdFlags) produce,
	// 	2009/01/23 01:23:23 message
	// while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,
	// 	2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message

	// Bits or'ed together to control what's printed. There is no control over
	// the order they appear (the order listed here) or the format they present
	// (as described in the comments). A colon appears after these items:
	//
	// 	2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

// A Logger represents an active logging object that generates lines of
// output to an io.Writer. Each logging operation makes a single call to
// the Writer's Write method. A Logger can be used simultaneously from
// multiple goroutines; it guarantees to serialize access to the Writer.

// Logger类型表示一个活动状态的记录日志的对象，它会生成一行行的输出写入一个
// io.Writer接口。每一条日志操作会调用一次io.Writer接口的Write方法。Logger类型的
// 对象可以被多个线程安全的同时使用，它会保证对io.Writer接口的顺序访问。
type Logger struct {
}

// Fatal is equivalent to Print() followed by a call to os.Exit(1).

// Fatal等价于{Print(v...); os.Exit(1)}
func Fatal(v ...interface{})

// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

// Fatalf等价于{Printf(v...); os.Exit(1)}
func Fatalf(format string, v ...interface{})

// Fatalln is equivalent to Println() followed by a call to os.Exit(1).

// Fatalln等价于{Println(v...); os.Exit(1)}
func Fatalln(v ...interface{})

// Flags returns the output flags for the standard logger.

// Flags返回标准logger的输出选项。
func Flags() int

// New creates a new Logger. The out variable sets the
// destination to which log data will be written.
// The prefix appears at the beginning of each generated log line.
// The flag argument defines the logging properties.

// New creates a new Logger. The out variable sets the destination to which log
// data will be written. The prefix appears at the beginning of each generated
// log line. The flag argument defines the logging properties.
func New(out io.Writer, prefix string, flag int) *Logger

// Output writes the output for a logging event. The string s contains
// the text to print after the prefix specified by the flags of the
// Logger. A newline is appended if the last character of s is not
// already a newline. Calldepth is the count of the number of
// frames to skip when computing the file name and line number
// if Llongfile or Lshortfile is set; a value of 1 will print the details
// for the caller of Output.
func Output(calldepth int, s string) error

// Panic is equivalent to Print() followed by a call to panic().

// Panic等价于{Print(v...); panic(...)}
func Panic(v ...interface{})

// Panicf is equivalent to Printf() followed by a call to panic().

// Panicf等价于{Printf(v...); panic(...)}
func Panicf(format string, v ...interface{})

// Panicln is equivalent to Println() followed by a call to panic().

// Panicln等价于{Println(v...); panic(...)}
func Panicln(v ...interface{})

// Prefix returns the output prefix for the standard logger.

// Prefix返回标准logger的输出前缀。
func Prefix() string

// Print calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Print.

// Print调用Output将生成的格式化字符串输出到标准logger，参数用和fmt.Print相同的
// 方法处理。
func Print(v ...interface{})

// Printf calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Printf.

// Printf调用Output将生成的格式化字符串输出到标准logger，参数用和fmt.Printf相同
// 的方法处理。
func Printf(format string, v ...interface{})

// Println calls Output to print to the standard logger.
// Arguments are handled in the manner of fmt.Println.

// Println调用Output将生成的格式化字符串输出到标准logger，参数用和fmt.Println相
// 同的方法处理。
func Println(v ...interface{})

// SetFlags sets the output flags for the standard logger.

// SetFlags设置标准logger的输出选项。
func SetFlags(flag int)

// SetOutput sets the output destination for the standard logger.

// SetOutput设置标准logger的输出目的地，默认是标准错误输出。
func SetOutput(w io.Writer)

// SetPrefix sets the output prefix for the standard logger.

// SetPrefix设置标准logger的输出前缀。
func SetPrefix(prefix string)

// Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func (l *Logger) Fatal(v ...interface{})

// Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
func (l *Logger) Fatalf(format string, v ...interface{})

// Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func (l *Logger) Fatalln(v ...interface{})

// Flags returns the output flags for the logger.
func (l *Logger) Flags() int

// Output writes the output for a logging event. The string s contains
// the text to print after the prefix specified by the flags of the
// Logger. A newline is appended if the last character of s is not
// already a newline. Calldepth is used to recover the PC and is
// provided for generality, although at the moment on all pre-defined
// paths it will be 2.

// Output writes the output for a logging event. The string s contains the text
// to print after the prefix specified by the flags of the Logger. A newline is
// appended if the last character of s is not already a newline. Calldepth is
// used to recover the PC and is provided for generality, although at the moment
// on all pre-defined paths it will be 2.
func (l *Logger) Output(calldepth int, s string) error

// Panic is equivalent to l.Print() followed by a call to panic().
func (l *Logger) Panic(v ...interface{})

// Panicf is equivalent to l.Printf() followed by a call to panic().
func (l *Logger) Panicf(format string, v ...interface{})

// Panicln is equivalent to l.Println() followed by a call to panic().
func (l *Logger) Panicln(v ...interface{})

// Prefix returns the output prefix for the logger.
func (l *Logger) Prefix() string

// Print calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Print.

// Print calls l.Output to print to the logger. Arguments are handled in the
// manner of fmt.Print.
func (l *Logger) Print(v ...interface{})

// Printf calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Printf.

// Printf calls l.Output to print to the logger. Arguments are handled in the
// manner of fmt.Printf.
func (l *Logger) Printf(format string, v ...interface{})

// Println calls l.Output to print to the logger.
// Arguments are handled in the manner of fmt.Println.

// Println calls l.Output to print to the logger. Arguments are handled in the
// manner of fmt.Println.
func (l *Logger) Println(v ...interface{})

// SetFlags sets the output flags for the logger.
func (l *Logger) SetFlags(flag int)

// SetOutput sets the output destination for the logger.
func (l *Logger) SetOutput(w io.Writer)

// SetPrefix sets the output prefix for the logger.
func (l *Logger) SetPrefix(prefix string)

{'repo_name': 'golang-china/golangdoc.translations', 'stars': '147', 'repo_language': 'Go', 'file_name': 'codewalk.css', 'mime_type': 'text/x-asm', 'hash': -8199185989751282539, 'source_dataset': 'data'}


/******************************************************************************
 *
 * Module Name: exconvrt - Object conversion routines
 *
 *****************************************************************************/

/*
 * Copyright (C) 2000 - 2016, Intel Corp.
 * 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,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    substantially similar to the "NO WARRANTY" disclaimer below
 *    ("Disclaimer") and any redistribution must be conditioned upon
 *    including a substantially similar Disclaimer requirement for further
 *    binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES.
 */

#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acinterp.h>
#include <contrib/dev/acpica/include/amlcode.h>

#define _COMPONENT          ACPI_EXECUTER
        ACPI_MODULE_NAME    ("exconvrt")

/* Local prototypes */

static UINT32
AcpiExConvertToAscii (
    UINT64                  Integer,
    UINT16                  Base,
    UINT8                   *String,
    UINT8                   MaxLength);

/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToInteger
 *
 * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
 *                                Integer, Buffer, or String
 *              ResultDesc      - Where the new Integer object is returned
 *              Flags           - Used for string conversion
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert an ACPI Object to an integer.
 *
 ******************************************************************************/

ACPI_STATUS
AcpiExConvertToInteger (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc,
    UINT32                  Flags)
{
    ACPI_OPERAND_OBJECT     *ReturnDesc;
    UINT8                   *Pointer;
    UINT64                  Result;
    UINT32                  i;
    UINT32                  Count;
    ACPI_STATUS             Status;

    ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);

    switch (ObjDesc->Common.Type)
    {
    case ACPI_TYPE_INTEGER:

        /* No conversion necessary */

        *ResultDesc = ObjDesc;
        return_ACPI_STATUS (AE_OK);

    case ACPI_TYPE_BUFFER:
    case ACPI_TYPE_STRING:

        /* Note: Takes advantage of common buffer/string fields */

        Pointer = ObjDesc->Buffer.Pointer;
        Count   = ObjDesc->Buffer.Length;
        break;

    default:

        return_ACPI_STATUS (AE_TYPE);
    }

    /*
     * Convert the buffer/string to an integer. Note that both buffers and
     * strings are treated as raw data - we don't convert ascii to hex for
     * strings.
     *
     * There are two terminating conditions for the loop:
     * 1) The size of an integer has been reached, or
     * 2) The end of the buffer or string has been reached
     */
    Result = 0;

    /* String conversion is different than Buffer conversion */

    switch (ObjDesc->Common.Type)
    {
    case ACPI_TYPE_STRING:
        /*
         * Convert string to an integer - for most cases, the string must be
         * hexadecimal as per the ACPI specification. The only exception (as
         * of ACPI 3.0) is that the ToInteger() operator allows both decimal
         * and hexadecimal strings (hex prefixed with "0x").
         */
        Status = AcpiUtStrtoul64 ((char *) Pointer, Flags,
            AcpiGbl_IntegerByteWidth, &Result);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
        break;

    case ACPI_TYPE_BUFFER:

        /* Check for zero-length buffer */

        if (!Count)
        {
            return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
        }

        /* Transfer no more than an integer's worth of data */

        if (Count > AcpiGbl_IntegerByteWidth)
        {
            Count = AcpiGbl_IntegerByteWidth;
        }

        /*
         * Convert buffer to an integer - we simply grab enough raw data
         * from the buffer to fill an integer
         */
        for (i = 0; i < Count; i++)
        {
            /*
             * Get next byte and shift it into the Result.
             * Little endian is used, meaning that the first byte of the buffer
             * is the LSB of the integer
             */
            Result |= (((UINT64) Pointer[i]) << (i * 8));
        }
        break;

    default:

        /* No other types can get here */

        break;
    }

    /* Create a new integer */

    ReturnDesc = AcpiUtCreateIntegerObject (Result);
    if (!ReturnDesc)
    {
        return_ACPI_STATUS (AE_NO_MEMORY);
    }

    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
        ACPI_FORMAT_UINT64 (Result)));

    /* Save the Result */

    (void) AcpiExTruncateFor32bitTable (ReturnDesc);
    *ResultDesc = ReturnDesc;
    return_ACPI_STATUS (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToBuffer
 *
 * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
 *                                Integer, Buffer, or String
 *              ResultDesc      - Where the new buffer object is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert an ACPI Object to a Buffer
 *
 ******************************************************************************/

ACPI_STATUS
AcpiExConvertToBuffer (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc)
{
    ACPI_OPERAND_OBJECT     *ReturnDesc;
    UINT8                   *NewBuf;

    ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc);

    switch (ObjDesc->Common.Type)
    {
    case ACPI_TYPE_BUFFER:

        /* No conversion necessary */

        *ResultDesc = ObjDesc;
        return_ACPI_STATUS (AE_OK);

    case ACPI_TYPE_INTEGER:
        /*
         * Create a new Buffer object.
         * Need enough space for one integer
         */
        ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }

        /* Copy the integer to the buffer, LSB first */

        NewBuf = ReturnDesc->Buffer.Pointer;
        memcpy (NewBuf, &ObjDesc->Integer.Value, AcpiGbl_IntegerByteWidth);
        break;

    case ACPI_TYPE_STRING:
        /*
         * Create a new Buffer object
         * Size will be the string length
         *
         * NOTE: Add one to the string length to include the null terminator.
         * The ACPI spec is unclear on this subject, but there is existing
         * ASL/AML code that depends on the null being transferred to the new
         * buffer.
         */
        ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE)
            ObjDesc->String.Length + 1);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }

        /* Copy the string to the buffer */

        NewBuf = ReturnDesc->Buffer.Pointer;
        strncpy ((char *) NewBuf, (char *) ObjDesc->String.Pointer,
            ObjDesc->String.Length);
        break;

    default:

        return_ACPI_STATUS (AE_TYPE);
    }

    /* Mark buffer initialized */

    ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID;
    *ResultDesc = ReturnDesc;
    return_ACPI_STATUS (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToAscii
 *
 * PARAMETERS:  Integer         - Value to be converted
 *              Base            - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
 *              String          - Where the string is returned
 *              DataWidth       - Size of data item to be converted, in bytes
 *
 * RETURN:      Actual string length
 *
 * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
 *
 ******************************************************************************/

static UINT32
AcpiExConvertToAscii (
    UINT64                  Integer,
    UINT16                  Base,
    UINT8                   *String,
    UINT8                   DataWidth)
{
    UINT64                  Digit;
    UINT32                  i;
    UINT32                  j;
    UINT32                  k = 0;
    UINT32                  HexLength;
    UINT32                  DecimalLength;
    UINT32                  Remainder;
    BOOLEAN                 SupressZeros;

    ACPI_FUNCTION_ENTRY ();

    switch (Base)
    {
    case 10:

        /* Setup max length for the decimal number */

        switch (DataWidth)
        {
        case 1:

            DecimalLength = ACPI_MAX8_DECIMAL_DIGITS;
            break;

        case 4:

            DecimalLength = ACPI_MAX32_DECIMAL_DIGITS;
            break;

        case 8:
        default:

            DecimalLength = ACPI_MAX64_DECIMAL_DIGITS;
            break;
        }

        SupressZeros = TRUE;     /* No leading zeros */
        Remainder = 0;

        for (i = DecimalLength; i > 0; i--)
        {
            /* Divide by nth factor of 10 */

            Digit = Integer;
            for (j = 0; j < i; j++)
            {
                (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder);
            }

            /* Handle leading zeros */

            if (Remainder != 0)
            {
                SupressZeros = FALSE;
            }

            if (!SupressZeros)
            {
                String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder);
                k++;
            }
        }
        break;

    case 16:

        /* HexLength: 2 ascii hex chars per data byte */

        HexLength = ACPI_MUL_2 (DataWidth);
        for (i = 0, j = (HexLength-1); i < HexLength; i++, j--)
        {
            /* Get one hex digit, most significant digits first */

            String[k] = (UINT8)
                AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j));
            k++;
        }
        break;

    default:
        return (0);
    }

    /*
     * Since leading zeros are suppressed, we must check for the case where
     * the integer equals 0
     *
     * Finally, null terminate the string and return the length
     */
    if (!k)
    {
        String [0] = ACPI_ASCII_ZERO;
        k = 1;
    }

    String [k] = 0;
    return ((UINT32) k);
}

/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToString
 *
 * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
 *                                Integer, Buffer, or String
 *              ResultDesc      - Where the string object is returned
 *              Type            - String flags (base and conversion type)
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Convert an ACPI Object to a string
 *
 ******************************************************************************/

ACPI_STATUS
AcpiExConvertToString (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc,
    UINT32                  Type)
{
    ACPI_OPERAND_OBJECT     *ReturnDesc;
    UINT8                   *NewBuf;
    UINT32                  i;
    UINT32                  StringLength = 0;
    UINT16                  Base = 16;
    UINT8                   Separator = ',';

    ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc);

    switch (ObjDesc->Common.Type)
    {
    case ACPI_TYPE_STRING:

        /* No conversion necessary */

        *ResultDesc = ObjDesc;
        return_ACPI_STATUS (AE_OK);

    case ACPI_TYPE_INTEGER:

        switch (Type)
        {
        case ACPI_EXPLICIT_CONVERT_DECIMAL:

            /* Make room for maximum decimal number */

            StringLength = ACPI_MAX_DECIMAL_DIGITS;
            Base = 10;
            break;

        default:

            /* Two hex string characters for each integer byte */

            StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth);
            break;
        }

        /*
         * Create a new String
         * Need enough space for one ASCII integer (plus null terminator)
         */
        ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }

        NewBuf = ReturnDesc->Buffer.Pointer;

        /* Convert integer to string */

        StringLength = AcpiExConvertToAscii (
            ObjDesc->Integer.Value, Base, NewBuf, AcpiGbl_IntegerByteWidth);

        /* Null terminate at the correct place */

        ReturnDesc->String.Length = StringLength;
        NewBuf [StringLength] = 0;
        break;

    case ACPI_TYPE_BUFFER:

        /* Setup string length, base, and separator */

        switch (Type)
        {
        case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */
            /*
             * From ACPI: "If Data is a buffer, it is converted to a string of
             * decimal values separated by commas."
             */
            Base = 10;

            /*
             * Calculate the final string length. Individual string values
             * are variable length (include separator for each)
             */
            for (i = 0; i < ObjDesc->Buffer.Length; i++)
            {
                if (ObjDesc->Buffer.Pointer[i] >= 100)
                {
                    StringLength += 4;
                }
                else if (ObjDesc->Buffer.Pointer[i] >= 10)
                {
                    StringLength += 3;
                }
                else
                {
                    StringLength += 2;
                }
            }
            break;

        case ACPI_IMPLICIT_CONVERT_HEX:
            /*
             * From the ACPI spec:
             *"The entire contents of the buffer are converted to a string of
             * two-character hexadecimal numbers, each separated by a space."
             */
            Separator = ' ';
            StringLength = (ObjDesc->Buffer.Length * 3);
            break;

        case ACPI_EXPLICIT_CONVERT_HEX:     /* Used by ToHexString */
            /*
             * From ACPI: "If Data is a buffer, it is converted to a string of
             * hexadecimal values separated by commas."
             */
            StringLength = (ObjDesc->Buffer.Length * 3);
            break;

        default:
            return_ACPI_STATUS (AE_BAD_PARAMETER);
        }

        /*
         * Create a new string object and string buffer
         * (-1 because of extra separator included in StringLength from above)
         * Allow creation of zero-length strings from zero-length buffers.
         */
        if (StringLength)
        {
            StringLength--;
        }

        ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength);
        if (!ReturnDesc)
        {
            return_ACPI_STATUS (AE_NO_MEMORY);
        }

        NewBuf = ReturnDesc->Buffer.Pointer;

        /*
         * Convert buffer bytes to hex or decimal values
         * (separated by commas or spaces)
         */
        for (i = 0; i < ObjDesc->Buffer.Length; i++)
        {
            NewBuf += AcpiExConvertToAscii (
                (UINT64) ObjDesc->Buffer.Pointer[i], Base, NewBuf, 1);
            *NewBuf++ = Separator; /* each separated by a comma or space */
        }

        /*
         * Null terminate the string
         * (overwrites final comma/space from above)
         */
        if (ObjDesc->Buffer.Length)
        {
            NewBuf--;
        }
        *NewBuf = 0;
        break;

    default:

        return_ACPI_STATUS (AE_TYPE);
    }

    *ResultDesc = ReturnDesc;
    return_ACPI_STATUS (AE_OK);
}

/*******************************************************************************
 *
 * FUNCTION:    AcpiExConvertToTargetType
 *
 * PARAMETERS:  DestinationType     - Current type of the destination
 *              SourceDesc          - Source object to be converted.
 *              ResultDesc          - Where the converted object is returned
 *              WalkState           - Current method state
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Implements "implicit conversion" rules for storing an object.
 *
 ******************************************************************************/

ACPI_STATUS
AcpiExConvertToTargetType (
    ACPI_OBJECT_TYPE        DestinationType,
    ACPI_OPERAND_OBJECT     *SourceDesc,
    ACPI_OPERAND_OBJECT     **ResultDesc,
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_STATUS             Status = AE_OK;

    ACPI_FUNCTION_TRACE (ExConvertToTargetType);

    /* Default behavior */

    *ResultDesc = SourceDesc;

    /*
     * If required by the target,
     * perform implicit conversion on the source before we store it.
     */
    switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs))
    {
    case ARGI_SIMPLE_TARGET:
    case ARGI_FIXED_TARGET:
    case ARGI_INTEGER_REF:      /* Handles Increment, Decrement cases */

        switch (DestinationType)
        {
        case ACPI_TYPE_LOCAL_REGION_FIELD:
            /*
             * Named field can always handle conversions
             */
            break;

        default:

            /* No conversion allowed for these types */

            if (DestinationType != SourceDesc->Common.Type)
            {
                ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
                    "Explicit operator, will store (%s) over existing type (%s)\n",
                    AcpiUtGetObjectTypeName (SourceDesc),
                    AcpiUtGetTypeName (DestinationType)));
                Status = AE_TYPE;
            }
        }
        break;

    case ARGI_TARGETREF:
    case ARGI_STORE_TARGET:

        switch (DestinationType)
        {
        case ACPI_TYPE_INTEGER:
        case ACPI_TYPE_BUFFER_FIELD:
        case ACPI_TYPE_LOCAL_BANK_FIELD:
        case ACPI_TYPE_LOCAL_INDEX_FIELD:
            /*
             * These types require an Integer operand. We can convert
             * a Buffer or a String to an Integer if necessary.
             */
            Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, 16);
            break;

        case ACPI_TYPE_STRING:
            /*
             * The operand must be a String. We can convert an
             * Integer or Buffer if necessary
             */
            Status = AcpiExConvertToString (SourceDesc, ResultDesc,
                ACPI_IMPLICIT_CONVERT_HEX);
            break;

        case ACPI_TYPE_BUFFER:
            /*
             * The operand must be a Buffer. We can convert an
             * Integer or String if necessary
             */
            Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc);
            break;

        default:

            ACPI_ERROR ((AE_INFO,
                "Bad destination type during conversion: 0x%X",
                DestinationType));
            Status = AE_AML_INTERNAL;
            break;
        }
        break;

    case ARGI_REFERENCE:
        /*
         * CreateXxxxField cases - we are storing the field object into the name
         */
        break;

    default:

        ACPI_ERROR ((AE_INFO,
            "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s",
            GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs),
            WalkState->Opcode, AcpiUtGetTypeName (DestinationType)));
        Status = AE_AML_INTERNAL;
    }

    /*
     * Source-to-Target conversion semantics:
     *
     * If conversion to the target type cannot be performed, then simply
     * overwrite the target with the new object and type.
     */
    if (Status == AE_TYPE)
    {
        Status = AE_OK;
    }

    return_ACPI_STATUS (Status);
}

{'repo_name': 'F-Stack/f-stack', 'stars': '2519', 'repo_language': 'C', 'file_name': 'muldi3.c', 'mime_type': 'text/x-c', 'hash': -6299571516567415220, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Kotlin2JsCompilerArguments">
    <option name="sourceMapEmbedSources" />
  </component>
</project>

{'repo_name': 'kawaiiDango/pScrobbler', 'stars': '141', 'repo_language': 'Kotlin', 'file_name': 'avd_heart_make.xml', 'mime_type': 'text/plain', 'hash': -2875554657005613744, 'source_dataset': 'data'}


/*
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.cloud.bigtable.hbase.adapters.filters;

import static com.google.cloud.bigtable.data.v2.models.Filters.FILTERS;

import com.google.api.core.InternalApi;
import com.google.cloud.bigtable.data.v2.models.Filters.Filter;
import java.io.IOException;
import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;

/**
 * Adapter for the ColumnCountGetFilter. This filter does not work properly with Scans.
 *
 * <p>For internal use only - public for technical reasons.
 */
@InternalApi("For internal usage only")
public class ColumnCountGetFilterAdapter extends TypedFilterAdapterBase<ColumnCountGetFilter> {

  /** {@inheritDoc} */
  @Override
  public Filter adapt(FilterAdapterContext context, ColumnCountGetFilter filter)
      throws IOException {
    // This is fairly broken for all scans, but I'm simply going for bug-for-bug
    // compatible with string reader expressions.
    return FILTERS
        .chain()
        .filter(FILTERS.limit().cellsPerColumn(1))
        .filter(FILTERS.limit().cellsPerRow(filter.getLimit()));
  }

  /** {@inheritDoc} */
  @Override
  public FilterSupportStatus isFilterSupported(
      FilterAdapterContext context, ColumnCountGetFilter filter) {
    return FilterSupportStatus.SUPPORTED;
  }
}

{'repo_name': 'googleapis/java-bigtable-hbase', 'stars': '130', 'repo_language': 'Java', 'file_name': 'ResultSerialization.java', 'mime_type': 'text/x-java', 'hash': -7719198885364923257, 'source_dataset': 'data'}


<?php
/*
The MIT License (MIT)

Copyright (c) 2015 Twitter Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

namespace Twitter\WordPress\JavaScriptLoaders;

/**
 * Load the remotely hosted Vine embed JavaScript
 *
 * @since 1.3.0
 */
class VineEmbed extends AsyncJavaScript
{
	/**
	 * Vine embed JavaScript handle
	 *
	 * Used in WordPress JavaScript queue
	 *
	 * @since 1.3.0
	 *
	 * @type string
	 */
	const QUEUE_HANDLE = 'vine-embed-js';

	/**
	 * Vine embed JavaScript fully-qualified domain name
	 *
	 * Used to prefetch DNS lookup
	 *
	 * @since 1.3.0
	 *
	 * @type string
	 */
	const FQDN = 'platform.vine.co';

	/**
	 * Vine embed JavaScript absolute URI
	 *
	 * @since 1.3.0
	 *
	 * @type string
	 */
	const URI = 'https://platform.vine.co/static/scripts/embed.js';
}

{'repo_name': 'twitter/wordpress', 'stars': '247', 'repo_language': 'PHP', 'file_name': 'OnAir.php', 'mime_type': 'text/x-php', 'hash': 5212077090588742099, 'source_dataset': 'data'}


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

			<title></title>
			<link rel="stylesheet" href="media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>

Root interface IException

IException

Root class phery

phery

Root class phery_response

phery_response

Root class Exception

CustomException (implements IException)

phery_exception

		Documentation generated on Fri, 08 Jul 2011 23:01:34 -0300 by phpDocumentor 1.4.3

{'repo_name': 'pheryjs/phery', 'stars': '133', 'repo_language': 'PHP', 'file_name': 'CustomException.html', 'mime_type': 'text/xml', 'hash': -3385063169207814677, 'source_dataset': 'data'}


<?php

class TestAssertEmpty
{
    public function test()
    {
        $this->assertNotEmpty($x);
        $this->assertNotEmpty($x);
        $this->assertEmpty($x);
        $this->assertEmpty($x);
    }

    public function testWithMessages()
    {
        $this->assertNotEmpty($x, '');
        $this->assertNotEmpty($x, '');
        $this->assertEmpty($x, '');
        $this->assertEmpty($x, '');
    }
}

{'repo_name': 'kalessil/phpinspectionsea', 'stars': '1136', 'repo_language': 'Java', 'file_name': 'OneLinerFormatter.java', 'mime_type': 'text/x-java', 'hash': -4671380415451063518, 'source_dataset': 'data'}


require 'plugin_test_helper'

class PluginLocatorTest < Test::Unit::TestCase
  def test_should_require_subclasses_to_implement_the_plugins_method
    assert_raise(RuntimeError) do
      Rails::Plugin::Locator.new(nil).plugins
    end
  end

  def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each
    locator = Rails::Plugin::Locator.new(nil)
    locator.stubs(:plugins).returns([:a, :b, :c])
    plugin_consumer = mock
    plugin_consumer.expects(:consume).with(:a)
    plugin_consumer.expects(:consume).with(:b)
    plugin_consumer.expects(:consume).with(:c)

    locator.each do |plugin|
      plugin_consumer.consume(plugin)
    end
  end
end

class PluginFileSystemLocatorTest < Test::Unit::TestCase
  def setup
    @configuration = Rails::Configuration.new
    # We need to add our testing plugin directory to the plugin paths so
    # the locator knows where to look for our plugins
    @configuration.plugin_paths << plugin_fixture_root_path
    @initializer       = Rails::Initializer.new(@configuration)
    @locator           = Rails::Plugin::FileSystemLocator.new(@initializer)
    @valid_plugin_path = plugin_fixture_path('default/stubby')
    @empty_plugin_path = plugin_fixture_path('default/empty')
  end

  def test_should_return_rails_plugin_instances_when_calling_create_plugin_with_a_valid_plugin_directory
    assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path)
  end

  def test_should_return_nil_when_calling_create_plugin_with_an_invalid_plugin_directory
    assert_nil @locator.send(:create_plugin, @empty_plugin_path)
  end

  def test_should_return_all_plugins_found_under_the_set_plugin_paths
    assert_equal ["a", "acts_as_chunky_bacon", "engine", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
  end

  def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
    @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
    assert_equal ["acts_as_chunky_bacon", "gemlike", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort

    @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
    assert_equal ["a"], @locator.plugins.map(&:name)
  end

  def test_should_not_raise_any_error_and_return_no_plugins_if_the_plugin_path_value_does_not_exist
    @configuration.plugin_paths = ["some_missing_directory"]
    assert_nothing_raised do
      assert @locator.plugins.empty?
    end
  end
end

{'repo_name': 'binarylogic/authlogic_example', 'stars': '577', 'repo_language': 'Ruby', 'file_name': 'dragdrop.js', 'mime_type': 'text/plain', 'hash': 8436974034811851406, 'source_dataset': 'data'}


[package]
name = "grammartec"
version = "0.1.0"
authors = ["coco <coco@hexgolems.com>"]

[dependencies]
regex = "0.2"
lazy_static= "*"
rand = "^0.3"
hash_by_ref = "0.1.0"
afl_mutator = {path = "../afl_mutator"}
forksrv = {path = "../forksrv"}
serde_derive = "1.0"
serde = "1.0"
loaded_dice = "*"
num = "*"

{'repo_name': 'RUB-SysSec/nautilus', 'stars': '139', 'repo_language': 'Rust', 'file_name': 'rule.rs', 'mime_type': 'text/plain', 'hash': -6956895983459537845, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<VerifySignatureResponse xmlns="http://fps.amazonaws.com/doc/2008-09-17/">
  <!--Optional:-->
  <VerifySignatureResult>
    <!--Optional:-->
    <VerificationStatus>string</VerificationStatus>
  </VerifySignatureResult>
  <ResponseMetadata>
    <RequestId>string</RequestId>
  </ResponseMetadata>
</VerifySignatureResponse>

{'repo_name': 'tylerhunt/remit', 'stars': '158', 'repo_language': 'Ruby', 'file_name': 'get_total_prepaid_liability.rb', 'mime_type': 'text/x-ruby', 'hash': 8182408611851844162, 'source_dataset': 'data'}


<component name="libraryTable">
  <library name="Maven: com.github.jsqlparser:jsqlparser:0.9.5">
    <CLASSES>
      <root url="jar://$MAVEN_REPOSITORY$/com/github/jsqlparser/jsqlparser/0.9.5/jsqlparser-0.9.5.jar!/" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$MAVEN_REPOSITORY$/com/github/jsqlparser/jsqlparser/0.9.5/jsqlparser-0.9.5-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$MAVEN_REPOSITORY$/com/github/jsqlparser/jsqlparser/0.9.5/jsqlparser-0.9.5-sources.jar!/" />
    </SOURCES>
  </library>
</component>

{'repo_name': 'hlk-1135/squirrel', 'stars': '128', 'repo_language': 'JavaScript', 'file_name': 'jdbc.properties', 'mime_type': 'text/plain', 'hash': -2804082067093959048, 'source_dataset': 'data'}