text:
from books.util.ZohoHttpClient import ZohoHttpClient
from books.parser.BillsParser import BillsParser
from books.api.Api import Api
from os.path import basename
from json import dumps

base_url = Api().base_url + 'bills/'
zoho_http_client = ZohoHttpClient()
parser = BillsParser()

class BillsApi:
    """Bills Api is used to

    1.List all bills with pagination
    2.Get the details of a bill.
    3.Create a bill received from a vendor.
    4.Update an existing bill.
    5.delete an existing bill.
    6.Mark a bill status as void.
    7.Mark a void bill as open.
    8.Update the billing address.
    9.Get the list of payments made for the bill.
    10.Apply the vendor credits from excess vendor payments to a bill.
    11.Delete a payment made to a bill.
    12.Returns a file attached to the bill.
    13.Attach a file to a bill.
    14.Delete the file attached to a bill.
    15.Get the cmplete history and comments of a bill.
    16.Add a comment for a bill.
    17.Delete a bill comment.

    """
    def __init__(self, authtoken, organization_id):
        """Initialize Bills api using user's authtoken and organization id.

        Args:
            authotoken(str): User's Authtoken.
            organization id(str): User's Organization id.

        """
        self.details = {
            'authtoken': authtoken,
            'organization_id': organization_id
            }

    def get_bills(self, parameter=None):
        """List all bills with pagination.

        Args:
            parameter(dict, optional): Filter with which the list has to be
                displayed.

        Returns:
            instance: Bill list object.

        """
        resp = zoho_http_client.get(base_url, self.details, parameter)
        return parser.get_list(resp)

    def get(self, bill_id):
        """Get the details of a bill.

        Args:
            bill_id(str): Bill id.

        Returns:
            instance: Bill object.

        """
        url = base_url + bill_id
        resp = zoho_http_client.get(url, self.details)
        return parser.get_bill(resp)

    def create(self, bill, attachment=None):
        """Create a bill received from the vendor.

        Args:
            bill(instance): Bill object.
            attachment(file, optional): File to be attached with the bill.
                Allowed extensions are gif, png, jpeg, jpg, bmp and pdf.

        Returns:
            instance: Bill object.

        """
        json_object = dumps(bill.to_json())
        data = {
            'JSONString': json_object
            }
        if attachment is None:
            attachments = None
        else:
            attachments = [{
                'attachment': {
                    'filename': basename(attachment),
                    'content': open(attachment).read()
                    }
                }]
        resp = zoho_http_client.post(base_url, self.details, data, None, \
                                     attachments)
        return parser.get_bill(resp)

    def update(self, bill_id, bill, attachment=None):
        """Update an existing bill.

        Args:
            bill_id(str): Bill id.
            bill(instance): Bill object.
            attachment(file, optional): File to be attached with the bill.
                Allowed extensions are gif, png, jpeg, jpg, bmp and pdf.

        Returns:
            instance: Bill object.

        """
        url = base_url + bill_id
        json_object = dumps(bill.to_json())
        data = {
            'JSONString': json_object
            }
        if attachment is None:
            attachments = None
        else:
            attachments = [{
                'attachment': {
                    'filename': basename(attachment),
                    'content': open(attachment).read()
                    }
                }]
        resp = zoho_http_client.put(url, self.details, data, None, \
                                     attachments)
        return parser.get_bill(resp)

    def delete(self, bill_id):
        """Delete an existing bill.

        Args:
            bill_id(str): Bill id.

        Returns:
            str: Success message('The bill has been deleted.').

        """
        url = base_url + bill_id
        resp = zoho_http_client.delete(url, self.details)
        return parser.get_message(resp)

    def void_a_bill(self, bill_id):
        """Mark a bill status as void.

        Args:
            bill_id(str): Bill id.

        Returns:
            str: Success message('The bill has been marked as void.').

        """
        url = base_url + bill_id + '/status/void'
        resp = zoho_http_client.post(url, self.details, '')
        return parser.get_message(resp)

    def mark_a_bill_as_open(self, bill_id):
        """Mark a void bill as open.

        Args:
            bill_id(str): Bill id.

        Returns:
            str: Success message('The status of the bill has been changed from
                 void to open.').

        """
        url = base_url + bill_id + '/status/open'
        resp = zoho_http_client.post(url, self.details, '')
        return parser.get_message(resp)

    def update_billing_address(self, bill_id, billing_address):
        """Update the billing address for the bill.

        Args:
            bill_id(str): Bill id.
            billing_address(instance): Billing address object.

        Returns:
            str: Success message('Billing address update.').

        """
        url = base_url + bill_id + '/address/billing'
        json_object = dumps(billing_address.to_json())
        data = {
            'JSONString': json_object
            }
        resp = zoho_http_client.put(url, self.details, data)
        return parser.get_message(resp)

    def list_bill_payments(self, bill_id):
        """Get the list of payments made for the bill.

        Args:
            bill_id(str): Bill id.

        Returns:
            instance: Payments list object.

        """
        url = base_url + bill_id + '/payments'
        resp = zoho_http_client.get(url, self.details)
        return parser.get_payments_list(resp)

    def apply_credits(self, bill_id, bill_payments):
        """Apply the vendor credits from excess vendor payments to a bill.

        Args:
            bill_id(str): Bill id.
            bill_payments(list of instance): list of payments object.

        Returns:
            str: Success message('Credits have been applied to the bill.').

        """
        url = base_url + bill_id + '/credits'
        data = {}
        bill_payments_list = []
        for value in bill_payments:
            bill_payment = {}
            bill_payment['payment_id'] = value.get_payment_id()
            bill_payment['amount_applied'] = value.get_amount_applied()
            bill_payments_list.append(bill_payment)

        data['bill_payments'] = bill_payments_list
        json_string = {
            'JSONString': dumps(data)
            }
        resp = zoho_http_client.post(url, self.details, json_string)
        return parser.get_message(resp)

    def delete_a_payment(self, bill_id, bill_payment_id):
        """Delete a payment made to a bill.

        Args:
            bill_id(str): Bill id.
            bill_payment_id(str): Bill payment id.

        Returns:
            str: Success message('The payment has been deleted.').

        Raises:
            Books Exception: If status is not '200' or '201'.

        """
        url = base_url + bill_id + '/payments/' + bill_payment_id
        resp = zoho_http_client.delete(url, self.details)
        return parser.get_message(resp)

    def get_a_bill_attachment(self, bill_id, preview=None):
        """Get the file attached to the bill.

        Args:
            bill_id(str): Bill id.
            preview(bool, optional): True to get the thumbnail of the
                attachment else False.

        Returns:
            file: File attached to the bill.

        """
        if preview is not None:
            query = {
                'preview': preview
                }
        else:
            query = None
        url = base_url + bill_id + '/attachment'
        resp = zoho_http_client.getfile(url, self.details, query)
        return resp

    def add_attachments_to_a_bill(self, bill_id, attachment):
        """Attach a file to a bill.

        Args:
            bill_id(str): Bill id.
            attachment(file): File to attach. Allowed extensions are gif, png,
                jpeg, jpg, bmp, pdf, xls, xlsx, doc, docx.

        Returns:
            str: Success message('The document has been deleted.').

        """
        url = base_url + bill_id + '/attachment'
        attachments = [{
                'attachment': {
                    'filename': basename(attachment),
                    'content': open(attachment).read()
                    }
                }]
        data = {
            'JSONString': ''
            }
        resp = zoho_http_client.post(url, self.details, data, None, attachments)
        return parser.get_message(resp)

    def delete_an_attachment(self, bill_id):
        """Delete the file attached to a bill.

        Args:
            bill_id(str): Bill id.

        Returns:
            str: Success message('The attachment has been deleted.').

        """
        url = base_url + bill_id + '/attachment'
        resp = zoho_http_client.delete(url, self.details)
        return parser.get_message(resp)

    def list_bill_comments_and_history(self, bill_id):
        """Get the complete history and comments of a bill.

        Args:
            bill_id(str): Bill id.

        Returns:
            instance: Comments list object.

        """
        url = base_url + bill_id + '/comments'
        resp = zoho_http_client.get(url, self.details)
        return parser.get_comments(resp)

    def add_comment(self, bill_id, description):
        """Add a comment for a bill.

        Args:
            bill_id(str): Bill id.
            description(str): Description.

        Returns:
            str: Success message('Comments added.').

        """
        url = base_url + bill_id + '/comments'
        data = {
            'description': description
            }
        json_string = {
            'JSONString': dumps(data)
            }
        resp = zoho_http_client.post(url, self.details, json_string)
        return parser.get_comment(resp)

    def delete_a_comment(self, bill_id, comment_id):
        """Delete a bill comment.

        Args:
            bill_id(str): Bill id.
            comment_id(str): Comment id.

        Returns:
            str: Success message('The comment has been deleted.').

        Raises:
            Books Exception: If status is '200' or '201'.

        """
        url = base_url + bill_id + '/comments/' + comment_id
        resp = zoho_http_client.delete(url, self.details)
        return parser.get_message(resp)


text:
using System;
using UnityEditor;
using UnityEngine;

namespace UnitySampleAssets.ImageEffects.Inspector
{
    [CustomEditor(typeof(ColorCorrectionCurves))]
    public class ColorCorrectionCurvesEditor : Editor
    {
        private SerializedObject serObj;
        private SerializedProperty mode;
        private SerializedProperty redChannel;
        private SerializedProperty greenChannel;
        private SerializedProperty blueChannel;
        private SerializedProperty useDepthCorrection;
        private SerializedProperty depthRedChannel;
        private SerializedProperty depthGreenChannel;
        private SerializedProperty depthBlueChannel;
        private SerializedProperty zCurveChannel;
        private SerializedProperty saturation;
        private SerializedProperty selectiveCc;
        private SerializedProperty selectiveFromColor;
        private SerializedProperty selectiveToColor;

        private bool applyCurveChanges = false;

        private void OnEnable()
        {
            serObj = new SerializedObject(target);

            mode = serObj.FindProperty("mode");

            saturation = serObj.FindProperty("saturation");

            redChannel = serObj.FindProperty("redChannel");
            greenChannel = serObj.FindProperty("greenChannel");
            blueChannel = serObj.FindProperty("blueChannel");

            useDepthCorrection = serObj.FindProperty("useDepthCorrection");

            zCurveChannel = serObj.FindProperty("zCurve");

            depthRedChannel = serObj.FindProperty("depthRedChannel");
            depthGreenChannel = serObj.FindProperty("depthGreenChannel");
            depthBlueChannel = serObj.FindProperty("depthBlueChannel");

            if (redChannel.animationCurveValue.length == 0)
                redChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                    new Keyframe(1, 1.0f, 1.0f, 1.0f));
            if (greenChannel.animationCurveValue.length == 0)
                greenChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                      new Keyframe(1, 1.0f, 1.0f, 1.0f));
            if (blueChannel.animationCurveValue.length == 0)
                blueChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                     new Keyframe(1, 1.0f, 1.0f, 1.0f));

            if (depthRedChannel.animationCurveValue.length == 0)
                depthRedChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                         new Keyframe(1, 1.0f, 1.0f, 1.0f));
            if (depthGreenChannel.animationCurveValue.length == 0)
                depthGreenChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                           new Keyframe(1, 1.0f, 1.0f, 1.0f));
            if (depthBlueChannel.animationCurveValue.length == 0)
                depthBlueChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                          new Keyframe(1, 1.0f, 1.0f, 1.0f));

            if (zCurveChannel.animationCurveValue.length == 0)
                zCurveChannel.animationCurveValue = new AnimationCurve(new Keyframe(0, 0.0f, 1.0f, 1.0f),
                                                                       new Keyframe(1, 1.0f, 1.0f, 1.0f));

            serObj.ApplyModifiedProperties();

            selectiveCc = serObj.FindProperty("selectiveCc");
            selectiveFromColor = serObj.FindProperty("selectiveFromColor");
            selectiveToColor = serObj.FindProperty("selectiveToColor");
        }

        private void CurveGui(String name, SerializedProperty animationCurve, Color color)
        {
            // @NOTE: EditorGUILayout.CurveField is buggy and flickers, using PropertyField for now
            //animationCurve.animationCurveValue = EditorGUILayout.CurveField (GUIContent (name), animationCurve.animationCurveValue, color, Rect (0.0,0.0,1.0,1.0));
            EditorGUILayout.PropertyField(animationCurve, new GUIContent(name));
            if (GUI.changed)
                applyCurveChanges = true;
        }

        private void BeginCurves()
        {
            applyCurveChanges = false;
        }

        private void ApplyCurves()
        {
            if (applyCurveChanges)
            {
                serObj.ApplyModifiedProperties();
                (serObj.targetObject as ColorCorrectionCurves).gameObject.SendMessage("UpdateTextures");
            }
        }

        public override void OnInspectorGUI()
        {
            serObj.Update();

            GUILayout.Label("Use curves to tweak RGB channel colors", EditorStyles.miniBoldLabel);

            saturation.floatValue = EditorGUILayout.Slider("Saturation", saturation.floatValue, 0.0f, 5.0f);

            EditorGUILayout.PropertyField(mode, new GUIContent("Mode"));
            EditorGUILayout.Separator();

            BeginCurves();

            CurveGui(" Red", redChannel, Color.red);
            CurveGui(" Green", greenChannel, Color.green);
            CurveGui(" Blue", blueChannel, Color.blue);

            EditorGUILayout.Separator();

            if (mode.intValue > 0)
                useDepthCorrection.boolValue = true;
            else
                useDepthCorrection.boolValue = false;

            if (useDepthCorrection.boolValue)
            {
                CurveGui(" Red (depth)", depthRedChannel, Color.red);
                CurveGui(" Green (depth)", depthGreenChannel, Color.green);
                CurveGui(" Blue (depth)", depthBlueChannel, Color.blue);
                EditorGUILayout.Separator();
                CurveGui(" Blend Curve", zCurveChannel, Color.grey);
            }

            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(selectiveCc, new GUIContent("Selective"));
            if (selectiveCc.boolValue)
            {
                EditorGUILayout.PropertyField(selectiveFromColor, new GUIContent(" Key"));
                EditorGUILayout.PropertyField(selectiveToColor, new GUIContent(" Target"));
            }

            ApplyCurves();

            if (!applyCurveChanges)
                serObj.ApplyModifiedProperties();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
void ShadowBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr )
{
    DepthBuffer::Create( Name, Width, Height, DXGI_FORMAT_D16_UNORM, VidMemPtr );

    m_Viewport.TopLeftX = 0.0f;
    m_Viewport.TopLeftY = 0.0f;
    m_Viewport.Width = (float)Width;
    m_Viewport.Height = (float)Height;
    m_Viewport.MinDepth = 0.0f;
    m_Viewport.MaxDepth = 1.0f;

    // Prevent drawing to the boundary pixels so that we don't have to worry about shadows stretching
    m_Scissor.left = 1;
    m_Scissor.top = 1;
    m_Scissor.right = (LONG)Width - 2;
    m_Scissor.bottom = (LONG)Height - 2;
}

void ShadowBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, EsramAllocator& Allocator )
{
    DepthBuffer::Create( Name, Width, Height, DXGI_FORMAT_D16_UNORM, Allocator );

    m_Viewport.TopLeftX = 0.0f;
    m_Viewport.TopLeftY = 0.0f;
    m_Viewport.Width = (float)Width;
    m_Viewport.Height = (float)Height;
    m_Viewport.MinDepth = 0.0f;
    m_Viewport.MaxDepth = 1.0f;

    // Prevent drawing to the boundary pixels so that we don't have to worry about shadows stretching
    m_Scissor.left = 1;
    m_Scissor.top = 1;
    m_Scissor.right = (LONG)Width - 2;
    m_Scissor.bottom = (LONG)Height - 2;
}

void ShadowBuffer::BeginRendering( GraphicsContext& Context )
{
    Context.TransitionResource(*this, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
    Context.ClearDepth(*this);
    Context.SetDepthStencilTarget(GetDSV());
    Context.SetViewportAndScissor(m_Viewport, m_Scissor);
}

void ShadowBuffer::EndRendering( GraphicsContext& Context )
{
    Context.TransitionResource(*this, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
}


text:
from Exporter import Exporter

#==============================================================================
# CodeExporter
#==============================================================================
class CodeExporter(Exporter):

    def __init__(self, info):
        Exporter.__init__(self, info)

    def Name(self):
        return self.info.code

    def Export(self, codeunit, exported_names):
        codeunit.Write(self.info.section, self.info.code)

    def WriteInclude(self, codeunit):
        pass


text:
Reports unresolved or wrongly used I18n property keys.

Property keys that are not present in the associated I18n Bundle will lead to runtime errors.
    The same can be applied to properties that take arguments, which are not provided by the code.


text:
<!doctype html>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css?family=Josefin+Sans|Lily+Script+One" rel="stylesheet">
    <link rel="stylesheet" href="/css/style.css">
    <title>Holiday Helper</title>


text:
package cli

import (
	"bytes"
	"database/sql/driver"
	"fmt"
	"io"
	"net/url"
	"strings"
	"text/tabwriter"
	"unicode"
	"unicode/utf8"

	"golang.org/x/net/context"

	"github.com/olekukonko/tablewriter"

	"github.com/cockroachdb/cockroach/pkg/security"
	"github.com/cockroachdb/cockroach/pkg/util"
	"github.com/cockroachdb/cockroach/pkg/util/log"
	"github.com/cockroachdb/pq"
)

type sqlConnI interface {
	driver.Conn
	driver.Execer
	driver.Queryer
	Next() (driver.Rows, error)
}

type sqlConn struct {
	url          string
	conn         sqlConnI
	reconnecting bool
}

func (c *sqlConn) ensureConn() error {
	if c.conn == nil {
		if c.reconnecting && isInteractive {
			fmt.Fprintf(osStderr, "connection lost; opening new connection and resetting session parameters...\n")
		}
		conn, err := pq.Open(c.url)
		if err != nil {
			return err
		}
		c.reconnecting = false
		c.conn = conn.(sqlConnI)
	}
	return nil
}

func (c *sqlConn) Exec(query string, args []driver.Value) error {
	if err := c.ensureConn(); err != nil {
		return err
	}
	_, err := c.conn.Exec(query, args)
	return err
}

func (c *sqlConn) Query(query string, args []driver.Value) (*sqlRows, error) {
	if err := c.ensureConn(); err != nil {
		return nil, err
	}
	rows, err := c.conn.Query(query, args)
	if err == driver.ErrBadConn {
		c.reconnecting = true
		c.Close()
	}
	if err != nil {
		return nil, err
	}
	return &sqlRows{rows: rows.(sqlRowsI), conn: c}, nil
}

func (c *sqlConn) Next() (*sqlRows, error) {
	if c.conn == nil {
		return nil, driver.ErrBadConn
	}
	rows, err := c.conn.Next()
	if err == driver.ErrBadConn {
		c.reconnecting = true
		c.Close()
	}
	if err != nil {
		return nil, err
	}
	return &sqlRows{rows: rows.(sqlRowsI), conn: c}, nil
}

func (c *sqlConn) QueryRow(query string, args []driver.Value) ([]driver.Value, error) {
	rows, err := makeQuery(query, args...)(c)
	if err != nil {
		return nil, err
	}
	defer func() { _ = rows.Close() }()
	vals := make([]driver.Value, len(rows.Columns()))
	err = rows.Next(vals)
	return vals, err
}

func (c *sqlConn) Close() {
	if c.conn != nil {
		err := c.conn.Close()
		if err != nil && err != driver.ErrBadConn {
			log.Info(context.TODO(), err)
		}
		c.conn = nil
	}
}

type sqlRowsI interface {
	driver.Rows
	Result() driver.Result
	Tag() string
}

type sqlRows struct {
	rows sqlRowsI
	conn *sqlConn
}

func (r *sqlRows) Columns() []string {
	return r.rows.Columns()
}

func (r *sqlRows) Result() driver.Result {
	return r.rows.Result()
}

func (r *sqlRows) Tag() string {
	return r.rows.Tag()
}

func (r *sqlRows) Close() error {
	err := r.rows.Close()
	if err == driver.ErrBadConn {
		r.conn.Close()
	}
	return err
}

// Next populates values with the next row of results. []byte values are copied
// so that subsequent calls to Next and Close do not mutate values. This
// makes it slower than theoretically possible but the safety concerns
// (since this is unobvious and unexpected behavior) outweigh.
func (r *sqlRows) Next(values []driver.Value) error {
	err := r.rows.Next(values)
	if err == driver.ErrBadConn {
		r.conn.reconnecting = true
		r.conn.Close()
	}
	for i, v := range values {
		if b, ok := v.([]byte); ok {
			values[i] = append([]byte{}, b...)
		}
	}
	return err
}

func makeSQLConn(url string) *sqlConn {
	return &sqlConn{
		url: url,
	}
}

// getPasswordAndMakeSQLClient prompts for a password if running in secure mode
// and no certificates have been supplied. security.RootUser won't be prompted
// for a password as the only authentication method available for this user is
// certificate authentication.
func getPasswordAndMakeSQLClient() (*sqlConn, error) {
	if len(connURL) != 0 {
		return makeSQLConn(connURL), nil
	}
	var user *url.Userinfo
	if !baseCfg.Insecure && connUser != security.RootUser && baseCfg.SSLCert == "" && baseCfg.SSLCertKey == "" {
		pwd, err := security.PromptForPassword()
		if err != nil {
			return nil, err
		}
		user = url.UserPassword(connUser, pwd)
	} else {
		user = url.User(connUser)
	}
	return makeSQLClient(user)
}

func makeSQLClient(user *url.Userinfo) (*sqlConn, error) {
	sqlURL := connURL
	if len(connURL) == 0 {
		u, err := sqlCtx.PGURL(user)
		if err != nil {
			return nil, err
		}
		u.Path = connDBName
		sqlURL = u.String()
	}
	return makeSQLConn(sqlURL), nil
}

type queryFunc func(conn *sqlConn) (*sqlRows, error)

func nextResult(conn *sqlConn) (*sqlRows, error) {
	return conn.Next()
}

func makeQuery(query string, parameters ...driver.Value) queryFunc {
	return func(conn *sqlConn) (*sqlRows, error) {
		// driver.Value is an alias for interface{}, but must adhere to a restricted
		// set of types when being passed to driver.Queryer.Query (see
		// driver.IsValue). We use driver.DefaultParameterConverter to perform the
		// necessary conversion. This is usually taken care of by the sql package,
		// but we have to do so manually because we're talking directly to the
		// driver.
		for i := range parameters {
			var err error
			parameters[i], err = driver.DefaultParameterConverter.ConvertValue(parameters[i])
			if err != nil {
				return nil, err
			}
		}
		return conn.Query(query, parameters)
	}
}

// runQuery takes a 'query' with optional 'parameters'.
// It runs the sql query and returns a list of columns names and a list of rows.
func runQuery(conn *sqlConn, fn queryFunc, pretty bool) ([]string, [][]string, string, error) {
	rows, err := fn(conn)
	if err != nil {
		return nil, nil, "", err
	}

	defer func() { _ = rows.Close() }()
	return sqlRowsToStrings(rows, pretty)
}

// runQueryAndFormatResults takes a 'query' with optional 'parameters'.
// It runs the sql query and writes output to 'w'.
func runQueryAndFormatResults(conn *sqlConn, w io.Writer, fn queryFunc, pretty bool) error {
	for {
		cols, allRows, result, err := runQuery(conn, fn, pretty)
		if err != nil {
			if err == pq.ErrNoMoreResults {
				return nil
			}
			return err
		}
		printQueryOutput(w, cols, allRows, result, pretty)
		fn = nextResult
	}
}

// sqlRowsToStrings turns 'rows' into a list of rows, each of which
// is a  list of column values.
// 'rows' should be closed by the caller.
// It returns the header row followed by all data rows.
// If both the header row and list of rows are empty, it means no row
// information was returned (eg: statement was not a query).
// If pretty is true, then more characters are not escaped.
func sqlRowsToStrings(rows *sqlRows, pretty bool) ([]string, [][]string, string, error) {
	srcCols := rows.Columns()
	cols := make([]string, len(srcCols))
	for i, c := range srcCols {
		cols[i] = formatVal(c, pretty, false)
	}

	var allRows [][]string
	var vals []driver.Value
	if len(cols) > 0 {
		vals = make([]driver.Value, len(cols))
	}

	for {
		err := rows.Next(vals)
		if err == io.EOF {
			break
		}
		if err != nil {
			return nil, nil, "", err
		}
		rowStrings := make([]string, len(cols))
		for i, v := range vals {
			rowStrings[i] = formatVal(v, pretty, pretty)
		}
		allRows = append(allRows, rowStrings)
	}

	result := rows.Result()
	tag := rows.Tag()
	switch tag {
	case "":
		tag = "OK"
	case "DELETE", "INSERT", "UPDATE":
		if n, err := result.RowsAffected(); err == nil {
			tag = fmt.Sprintf("%s %d", tag, n)
		}
	}

	return cols, allRows, tag, nil
}

// expandTabsAndNewLines ensures that multi-line row strings that may
// contain tabs are properly formatted: tabs are expanded to spaces,
// and newline characters are marked visually. Marking newline
// characters is especially important in single-column results where
// the underlying TableWriter would not otherwise show the difference
// between one multi-line row and two one-line rows.
func expandTabsAndNewLines(s string) string {
	var buf bytes.Buffer
	// 4-wide columns, 1 character minimum width.
	w := tabwriter.NewWriter(&buf, 4, 0, 1, ' ', 0)
	fmt.Fprint(w, strings.Replace(s, "\n", "␤\n", -1))
	_ = w.Flush()
	return buf.String()
}

// printQueryOutput takes a list of column names and a list of row contents
// writes a pretty table to 'w', or "OK" if empty.
func printQueryOutput(w io.Writer, cols []string, allRows [][]string, tag string, pretty bool) {
	if len(cols) == 0 {
		// This operation did not return rows, just show the tag.
		fmt.Fprintln(w, tag)
		return
	}

	if pretty {
		// Initialize tablewriter and set column names as the header row.
		table := tablewriter.NewWriter(w)
		table.SetAutoFormatHeaders(false)
		table.SetAutoWrapText(false)
		table.SetHeader(cols)
		for _, row := range allRows {
			for i, r := range row {
				row[i] = expandTabsAndNewLines(r)
			}
			table.Append(row)
		}
		table.Render()
		nRows := len(allRows)
		fmt.Fprintf(w, "(%d row%s)\n", nRows, util.Pluralize(int64(nRows)))
	} else {
		if len(cols) == 0 {
			// No result selected, inform the user.
			fmt.Fprintln(w, tag)
		} else {
			// Some results selected, inform the user about how much data to expect.
			fmt.Fprintf(w, "%d row%s\n", len(allRows),
				util.Pluralize(int64(len(allRows))))

			// Then print the results themselves.
			fmt.Fprintln(w, strings.Join(cols, "\t"))
			for _, row := range allRows {
				fmt.Fprintln(w, strings.Join(row, "\t"))
			}
		}
	}
}

func isNotPrintableASCII(r rune) bool { return r < 0x20 || r > 0x7e || r == '"' || r == '\\' }
func isNotGraphicUnicode(r rune) bool { return !unicode.IsGraphic(r) }
func isNotGraphicUnicodeOrTabOrNewline(r rune) bool {
	return r != '\t' && r != '\n' && !unicode.IsGraphic(r)
}

func formatVal(val driver.Value, showPrintableUnicode bool, showNewLinesAndTabs bool) string {
	switch t := val.(type) {
	case nil:
		return "NULL"
	case string:
		if showPrintableUnicode {
			pred := isNotGraphicUnicode
			if showNewLinesAndTabs {
				pred = isNotGraphicUnicodeOrTabOrNewline
			}
			if utf8.ValidString(t) && strings.IndexFunc(t, pred) == -1 {
				return t
			}
		} else {
			if strings.IndexFunc(t, isNotPrintableASCII) == -1 {
				return t
			}
		}
		return fmt.Sprintf("%+q", t)

	case []byte:
		if showPrintableUnicode {
			pred := isNotGraphicUnicode
			if showNewLinesAndTabs {
				pred = isNotGraphicUnicodeOrTabOrNewline
			}
			if utf8.Valid(t) && bytes.IndexFunc(t, pred) == -1 {
				return string(t)
			}
		} else {
			if bytes.IndexFunc(t, isNotPrintableASCII) == -1 {
				return string(t)
			}
		}
		return fmt.Sprintf("%+q", t)
	}
	return fmt.Sprint(val)
}


text:
package fw.db.annotations;

import java.lang.annotation.*;

/**
 * 此标注为ORM标注,申明标注它的类型所对应的数据库表名
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Table {

    /**
     * 对应的数据库表名
     *
     */
    String value();
}


text:
[npm history][1]

[1]: https://www.npmjs.com/package/@google-cloud/text-to-speech?activeTab=versions

## [4.0.4](https://github.com/googleapis/nodejs-text-to-speech/compare/v4.0.3...v4.0.4) (2022-11-09)

### Bug Fixes

* **deps:** Use google-gax v3.5.2 ([#641](https://github.com/googleapis/nodejs-text-to-speech/issues/641)) ([6f691f6](https://github.com/googleapis/nodejs-text-to-speech/commit/6f691f65c5d21f93117268ec87c89309fc6e667f))
* update proto definitions ([3321981](https://github.com/googleapis/nodejs-text-to-speech/commit/3321981c96b4726ef764a76bc3ce35b90943b16b))
* Update proto definitions ([#645](https://github.com/googleapis/nodejs-text-to-speech/issues/645)) ([3321981](https://github.com/googleapis/nodejs-text-to-speech/commit/3321981c96b4726ef764a76bc3ce35b90943b16b))

## [4.0.3](https://github.com/googleapis/nodejs-text-to-speech/compare/v4.0.2...v4.0.3) (2022-09-14)

### Bug Fixes

* Allow passing gax instance to client constructor ([#625](https://github.com/googleapis/nodejs-text-to-speech/issues/625)) ([df7fc10](https://github.com/googleapis/nodejs-text-to-speech/commit/df7fc1076fa70c3a41a40f18d677ea3108091e76))
* Do not import the whole google-gax from proto JS ([#1553](https://github.com/googleapis/nodejs-text-to-speech/issues/1553)) ([#624](https://github.com/googleapis/nodejs-text-to-speech/issues/624)) ([655571f](https://github.com/googleapis/nodejs-text-to-speech/commit/655571f6322adc6fd75fc05b694eddc52b7eccbe))
* Preserve default values in x-goog-request-params header ([#627](https://github.com/googleapis/nodejs-text-to-speech/issues/627)) ([26a4f84](https://github.com/googleapis/nodejs-text-to-speech/commit/26a4f8456c713272c8f3d0aab45ecbb4392e0fa1))
* use google-gax v3.3.0 ([655571f](https://github.com/googleapis/nodejs-text-to-speech/commit/655571f6322adc6fd75fc05b694eddc52b7eccbe))

## [4.0.2](https://github.com/googleapis/nodejs-text-to-speech/compare/v4.0.1...v4.0.2) (2022-08-23)

### Bug Fixes

* better support for fallback mode ([#618](https://github.com/googleapis/nodejs-text-to-speech/issues/618)) ([cece3bd](https://github.com/googleapis/nodejs-text-to-speech/commit/cece3bdb3782c3c8e8bd264fac706edc887c281b))
* change import long to require ([#620](https://github.com/googleapis/nodejs-text-to-speech/issues/620)) ([e525bd8](https://github.com/googleapis/nodejs-text-to-speech/commit/e525bd8d1b4ecf281b8b3d6145f5183384dacc3f))
* remove pip install statements ([#1546](https://github.com/googleapis/nodejs-text-to-speech/issues/1546)) ([#623](https://github.com/googleapis/nodejs-text-to-speech/issues/623)) ([6626498](https://github.com/googleapis/nodejs-text-to-speech/commit/6626498331534247b53a876b06aefa11c689b5a2))

## [4.0.1](https://github.com/googleapis/nodejs-text-to-speech/compare/v4.0.0...v4.0.1) (2022-06-30)

### Bug Fixes

* **docs:** describe fallback rest option ([#610](https://github.com/googleapis/nodejs-text-to-speech/issues/610)) ([26bc91a](https://github.com/googleapis/nodejs-text-to-speech/commit/26bc91afb45e51486061d00517c4acb0de7aaa2e))

## [4.0.0](https://github.com/googleapis/nodejs-text-to-speech/compare/v3.4.0...v4.0.0) (2022-06-10)

### ⚠ BREAKING CHANGES

* update library to use Node 12 (#604)

### Features

* Consolidate task details into service API and add orchestration result details ([74f7cfb](https://github.com/googleapis/nodejs-text-to-speech/commit/74f7cfb6947c0b9b35dcddb9ede343877b4938a6))
* promote CustomVoiceParams to v1 ([#591](https://github.com/googleapis/nodejs-text-to-speech/issues/591)) ([fe647dc](https://github.com/googleapis/nodejs-text-to-speech/commit/fe647dc8735792333e0203844279da6ada898e1a))

### Build System

* update library to use Node 12 ([#604](https://github.com/googleapis/nodejs-text-to-speech/issues/604)) ([4395d56](https://github.com/googleapis/nodejs-text-to-speech/commit/4395d5696205c257498d33693e53135da998ed38))

## [3.4.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.3.1...v3.4.0) (2021-12-09)

### Features

* adds support for MULAW and ALAW audio encoding ([#565](https://www.github.com/googleapis/nodejs-text-to-speech/issues/565)) ([cf7cb74](https://www.github.com/googleapis/nodejs-text-to-speech/commit/cf7cb74655a5bd1cfc13b670a4b620ac8dd78138))
* update v1beta1 proto ([#562](https://www.github.com/googleapis/nodejs-text-to-speech/issues/562)) ([0d78e6c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/0d78e6c87e51c040c5f35064b53f96d1353f93b9))

### [3.3.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.3.0...v3.3.1) (2021-09-10)

### Bug Fixes

* **build:** set default branch to main ([#548](https://www.github.com/googleapis/nodejs-text-to-speech/issues/548)) ([6891351](https://www.github.com/googleapis/nodejs-text-to-speech/commit/6891351d06b48e6337567c4fb9e6f885204920e3))

## [3.3.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.7...v3.3.0) (2021-08-23)

### Features

* turns on self-signed JWT feature flag ([#543](https://www.github.com/googleapis/nodejs-text-to-speech/issues/543)) ([bd5ecd3](https://www.github.com/googleapis/nodejs-text-to-speech/commit/bd5ecd31f2cf39486b85c62e1f5d35850cde22b9))

### [3.2.7](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.6...v3.2.7) (2021-08-17)

### Bug Fixes

* **deps:** google-gax v2.24.1 ([#541](https://www.github.com/googleapis/nodejs-text-to-speech/issues/541)) ([0c93b5b](https://www.github.com/googleapis/nodejs-text-to-speech/commit/0c93b5bd89bd983c1a9d658d22179b8732b533ed))

### [3.2.6](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.5...v3.2.6) (2021-07-21)

### Bug Fixes

* Updating WORKSPACE files to use the newest version of the Typescript generator. ([#534](https://www.github.com/googleapis/nodejs-text-to-speech/issues/534)) ([dee8dc2](https://www.github.com/googleapis/nodejs-text-to-speech/commit/dee8dc23024f67d5ad3888e2ea4b6829cbd4cae6))

### [3.2.5](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.4...v3.2.5) (2021-07-12)

### Bug Fixes

* **deps:** google-gax v2.17.1 ([#532](https://www.github.com/googleapis/nodejs-text-to-speech/issues/532)) ([200ddae](https://www.github.com/googleapis/nodejs-text-to-speech/commit/200ddae856e42b45a10a34d903adc699eb188c7c))

### [3.2.4](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.3...v3.2.4) (2021-06-30)

### Bug Fixes

* **deps:** google-gax v2.17.0 with mTLS ([#529](https://www.github.com/googleapis/nodejs-text-to-speech/issues/529)) ([5c6c68c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/5c6c68cb54aa684a4d2f33cedc6565ef2f17e153))

### [3.2.3](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.2...v3.2.3) (2021-06-23)

### Bug Fixes

* make request optional in all cases ([#525](https://www.github.com/googleapis/nodejs-text-to-speech/issues/525)) ([256f21b](https://www.github.com/googleapis/nodejs-text-to-speech/commit/256f21bada718586549f07327be2509c79da3912))

### [3.2.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.1...v3.2.2) (2021-06-04)

### Bug Fixes

* GoogleAdsError missing using generator version after 1.3.0 ([#515](https://www.github.com/googleapis/nodejs-text-to-speech/issues/515)) ([f48e238](https://www.github.com/googleapis/nodejs-text-to-speech/commit/f48e238ae8141c4bd92cfa2fbca8f6af7cc07355))

### [3.2.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.2.0...v3.2.1) (2021-05-12)

### Bug Fixes

* **deps:** require google-gax v2.12.0 ([#505](https://www.github.com/googleapis/nodejs-text-to-speech/issues/505)) ([077490c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/077490cb19e0cd3835c449392556131b3e1e9373))
* use require() to load JSON protos ([#508](https://www.github.com/googleapis/nodejs-text-to-speech/issues/508)) ([5046bb9](https://www.github.com/googleapis/nodejs-text-to-speech/commit/5046bb9e223e8effe5a9a414783e1e482c8f8b4c))

## [3.2.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.1.3...v3.2.0) (2021-04-16)

### Features

* add ALAW support on client library. And improve the ListVoiceRequest message's documentation ([#490](https://www.github.com/googleapis/nodejs-text-to-speech/issues/490)) ([0c5217c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/0c5217ce2882297aae399f83a444eaa6a7483811))

### [3.1.3](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.1.2...v3.1.3) (2020-11-25)

### Bug Fixes

* **browser:** check for fetch on window ([a0925b3](https://www.github.com/googleapis/nodejs-text-to-speech/commit/a0925b35d4e39587388cfe05685891d523f1bc49))

### [3.1.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.1.1...v3.1.2) (2020-11-06)

### Bug Fixes

* do not modify options object, use defaultScopes ([#463](https://www.github.com/googleapis/nodejs-text-to-speech/issues/463)) ([c3558d8](https://www.github.com/googleapis/nodejs-text-to-speech/commit/c3558d84568ed53f794f8e8136ddaf96e84630d6))

### [3.1.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.1.0...v3.1.1) (2020-09-12)

### Bug Fixes

* **deps:** update dependency yargs to v16 ([#446](https://www.github.com/googleapis/nodejs-text-to-speech/issues/446)) ([d069082](https://www.github.com/googleapis/nodejs-text-to-speech/commit/d069082f8e5630a80e3b064525dd51f011f8c0dd))

## [3.1.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.0.1...v3.1.0) (2020-07-30)

### Features

* support MULAW and MP3_64_KBPS audio encoding and support timepointing via SSML <mark> tag ([8826c87](https://www.github.com/googleapis/nodejs-text-to-speech/commit/8826c8714498d4d87546b2d61ea9ebbcff443971))

### [3.0.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v3.0.0...v3.0.1) (2020-06-29)

### Bug Fixes

* handle fallback option properly ([#413](https://www.github.com/googleapis/nodejs-text-to-speech/issues/413)) ([9ca230e](https://www.github.com/googleapis/nodejs-text-to-speech/commit/9ca230ea459b5c385ab259af943ba7efdc8437ec))
* update node issue template ([#415](https://www.github.com/googleapis/nodejs-text-to-speech/issues/415)) ([5f506f0](https://www.github.com/googleapis/nodejs-text-to-speech/commit/5f506f013f46c734fef6fbeb38ed1827f0648514))

## [3.0.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.3.0...v3.0.0) (2020-06-04)

### ⚠ BREAKING CHANGES

* The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM.

### Features

* drop node8 support ([#373](https://www.github.com/googleapis/nodejs-text-to-speech/issues/373)) ([21e3598](https://www.github.com/googleapis/nodejs-text-to-speech/commit/21e359885c39d4dfc6ed0a231fd66d35628fa0cb))

### Bug Fixes

* regen protos and tests, formatting ([#401](https://www.github.com/googleapis/nodejs-text-to-speech/issues/401)) ([6c7d38a](https://www.github.com/googleapis/nodejs-text-to-speech/commit/6c7d38a0a217d6d7a7d77dcde3756b10e47fb220))
* remove eslint, update gax, fix generated protos, run the generator ([#385](https://www.github.com/googleapis/nodejs-text-to-speech/issues/385)) ([f035747](https://www.github.com/googleapis/nodejs-text-to-speech/commit/f0357470f152c97a8203edeff2a8385068e3e316))
* remove unused files in package ([#389](https://www.github.com/googleapis/nodejs-text-to-speech/issues/389)) ([7b1e5e4](https://www.github.com/googleapis/nodejs-text-to-speech/commit/7b1e5e4abe442e54219b53a7e17ab20c0c277995))
* synth.py clean up for multiple version ([#403](https://www.github.com/googleapis/nodejs-text-to-speech/issues/403)) ([1b36546](https://www.github.com/googleapis/nodejs-text-to-speech/commit/1b36546437ec40e882d771c238a2926a5c18eee9))

## [2.3.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.2.0...v2.3.0) (2020-03-06)

### Features

* deferred client initialization ([#359](https://www.github.com/googleapis/nodejs-text-to-speech/issues/359)) ([547fb77](https://www.github.com/googleapis/nodejs-text-to-speech/commit/547fb77d625a6c25ef288e8bdad19d448113271e))
* export protos in src/index.ts ([b6ca82f](https://www.github.com/googleapis/nodejs-text-to-speech/commit/b6ca82f901d4791d3d4994a5782c7f19d449becf))

## [2.2.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.3...v2.2.0) (2020-02-12)

### Features

* bump release level to ga ([#342](https://www.github.com/googleapis/nodejs-text-to-speech/issues/342)) ([eca7bfa](https://www.github.com/googleapis/nodejs-text-to-speech/commit/eca7bfabbab2fc169e77922bbda3d7b79e34e1c4))

### [2.1.3](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.2...v2.1.3) (2020-02-01)

### Bug Fixes

* enum, bytes, and Long types now accept strings ([3839359](https://www.github.com/googleapis/nodejs-text-to-speech/commit/3839359a2cc8397f93fdb656a9b4c3a04b0ef488))

### [2.1.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.1...v2.1.2) (2020-01-03)

### Bug Fixes

* "client already closed" error fires earlier ([41b39bc](https://www.github.com/googleapis/nodejs-text-to-speech/commit/41b39bce3a598e6034a4b63c122b1ce89ddec5b5))

### [2.1.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.1.0...v2.1.1) (2019-12-30)

### Bug Fixes

* increase timeout from 20s to 60s ([#312](https://www.github.com/googleapis/nodejs-text-to-speech/issues/312)) ([ea9f75c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/ea9f75c383351724ae0f5186073c5289d2f8996a))
* move region tag to encompass catch ([#320](https://www.github.com/googleapis/nodejs-text-to-speech/issues/320)) ([988c5f5](https://www.github.com/googleapis/nodejs-text-to-speech/commit/988c5f55859bca543a79800d6eb4668dafeec70f))

## [2.1.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.0.2...v2.1.0) (2019-12-11)

### Features

* make service stub public ([921f404](https://www.github.com/googleapis/nodejs-text-to-speech/commit/921f404c156379c6073f5a0db224df703b2d3e3e))

### Bug Fixes

* **deps:** pin TypeScript below 3.7.0 ([4da93ee](https://www.github.com/googleapis/nodejs-text-to-speech/commit/4da93ee0b509c1260b9c49e7794b6546ecd2ed6e))

### [2.0.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.0.1...v2.0.2) (2019-11-20)

### Bug Fixes

* **docs:** bump release level to beta ([#297](https://www.github.com/googleapis/nodejs-text-to-speech/issues/297)) ([247ae7a](https://www.github.com/googleapis/nodejs-text-to-speech/commit/247ae7a1c402d04ec5285faad6e92d736a03c825))

### [2.0.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v2.0.0...v2.0.1) (2019-11-18)

### Bug Fixes

* **deps:** update dependency yargs to v15 ([#295](https://www.github.com/googleapis/nodejs-text-to-speech/issues/295)) ([2c7eea2](https://www.github.com/googleapis/nodejs-text-to-speech/commit/2c7eea213ad6211a38b0ee2d591d52d79a3b4c0a))

## [2.0.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.4.1...v2.0.0) (2019-11-14)

### ⚠ BREAKING CHANGES

* move library to typescript code generation (#285)

Starting with this release, the auto-generated library code was changed from JavaScript to TypeScript, so all the TypeScript types are now exported from the `.d.ts` files.

Please note that if you used `@types/google-cloud__text-to-speech` package to get TypeScript types for this library, you need to stop using it and remove it from your `devDependencies`.

If you see any issues caused by this migration to TypeScript, please feel free to submit an issue!

### Features

* move library to typescript code generation ([#285](https://www.github.com/googleapis/nodejs-text-to-speech/issues/285)) ([d3d6208](https://www.github.com/googleapis/nodejs-text-to-speech/commit/d3d620853adc54fe7b671fa01643f6b0ef94794b))

### Bug Fixes

* import long into proto ts declaration file ([#288](https://www.github.com/googleapis/nodejs-text-to-speech/issues/288)) ([5bfb2ab](https://www.github.com/googleapis/nodejs-text-to-speech/commit/5bfb2ab7f76625361d52ad945733087877e03800))
* **docs:** snippets are now replaced in jsdoc comments ([#287](https://www.github.com/googleapis/nodejs-text-to-speech/issues/287)) ([6e77aaf](https://www.github.com/googleapis/nodejs-text-to-speech/commit/6e77aaf10d814ab5366117c7251c29f25aa603b3))

### [1.4.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.4.0...v1.4.1) (2019-10-22)

### Bug Fixes

* **deps:** bump google-gax to 1.7.5 ([#280](https://www.github.com/googleapis/nodejs-text-to-speech/issues/280)) ([9e426ca](https://www.github.com/googleapis/nodejs-text-to-speech/commit/9e426cab4d62165d0cb79d8e489a5ccd1a1cfb46))

## [1.4.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.3.0...v1.4.0) (2019-10-09)

### Bug Fixes

* use compatible version of google-gax ([475c794](https://www.github.com/googleapis/nodejs-text-to-speech/commit/475c794))

### Features

* .d.ts for protos ([#270](https://www.github.com/googleapis/nodejs-text-to-speech/issues/270)) ([dd7f91e](https://www.github.com/googleapis/nodejs-text-to-speech/commit/dd7f91e))

## [1.3.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.2.0...v1.3.0) (2019-09-16)

### Bug Fixes

* **docs:** READMEs updated with new samples ([d3e09e0](https://www.github.com/googleapis/nodejs-text-to-speech/commit/d3e09e0))
* add proto field behavior options ([#265](https://www.github.com/googleapis/nodejs-text-to-speech/issues/265)) ([1f184a3](https://www.github.com/googleapis/nodejs-text-to-speech/commit/1f184a3))

### Features

* code samples for ssml addresses tutorial ([#257](https://www.github.com/googleapis/nodejs-text-to-speech/issues/257)) ([e423f2a](https://www.github.com/googleapis/nodejs-text-to-speech/commit/e423f2a))

## [1.2.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.1.4...v1.2.0) (2019-09-05)

### Features

* load protos from JSON, grpc-fallback support ([c9a203d](https://www.github.com/googleapis/nodejs-text-to-speech/commit/c9a203d))

### [1.1.4](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.1.3...v1.1.4) (2019-08-28)

### Bug Fixes

* **deps:** update dependency yargs to v14 ([8392e8b](https://www.github.com/googleapis/nodejs-text-to-speech/commit/8392e8b))
* use correct version for x-goog-api-client header ([6e03123](https://www.github.com/googleapis/nodejs-text-to-speech/commit/6e03123))

### [1.1.3](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.1.2...v1.1.3) (2019-08-02)

### Bug Fixes

* allow calls with no request, add JSON proto ([cb8a51b](https://www.github.com/googleapis/nodejs-text-to-speech/commit/cb8a51b))

### [1.1.2](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.1.1...v1.1.2) (2019-06-26)

### Bug Fixes

* **docs:** link to reference docs section on googleapis.dev ([#242](https://www.github.com/googleapis/nodejs-text-to-speech/issues/242)) ([f05140a](https://www.github.com/googleapis/nodejs-text-to-speech/commit/f05140a))

### [1.1.1](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.1.0...v1.1.1) (2019-06-13)

### Bug Fixes

* **docs:** move to new client docs URL ([#239](https://www.github.com/googleapis/nodejs-text-to-speech/issues/239)) ([59a89d9](https://www.github.com/googleapis/nodejs-text-to-speech/commit/59a89d9))

## [1.1.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v1.0.0...v1.1.0) (2019-06-05)

### Features

* support apiEndpoint override in client constructor ([#234](https://www.github.com/googleapis/nodejs-text-to-speech/issues/234)) ([519c36c](https://www.github.com/googleapis/nodejs-text-to-speech/commit/519c36c))

## [1.0.0](https://www.github.com/googleapis/nodejs-text-to-speech/compare/v0.5.1...v1.0.0) (2019-05-14)

### Bug Fixes

* **deps:** update dependency google-gax to v1 ([#223](https://www.github.com/googleapis/nodejs-text-to-speech/issues/223)) ([aa8bbed](https://www.github.com/googleapis/nodejs-text-to-speech/commit/aa8bbed))
* DEADLINE_EXCEEDED is idempotent ([#224](https://www.github.com/googleapis/nodejs-text-to-speech/issues/224)) ([affbbd1](https://www.github.com/googleapis/nodejs-text-to-speech/commit/affbbd1))
* DEADLINE_EXCEEDED no longer treated as idempotent and retried ([9e5baee](https://www.github.com/googleapis/nodejs-text-to-speech/commit/9e5baee))
* **deps:** update dependency google-gax to ^0.26.0 ([#212](https://www.github.com/googleapis/nodejs-text-to-speech/issues/212)) ([30ea99f](https://www.github.com/googleapis/nodejs-text-to-speech/commit/30ea99f))

### Build System

* upgrade engines field to >=8.10.0 ([#214](https://www.github.com/googleapis/nodejs-text-to-speech/issues/214)) ([d0c1639](https://www.github.com/googleapis/nodejs-text-to-speech/commit/d0c1639))

### BREAKING CHANGES

* upgrade engines field to >=8.10.0 (#214)

## v0.5.1

02-14-2019 17:36 PST

### Bug Fixes
- fix: throw on invalid credentials ([#189](https://github.com/googleapis/nodejs-text-to-speech/pull/189))

### Documentation
- docs: update sample to show method inside of async function ([#188](https://github.com/googleapis/nodejs-text-to-speech/pull/188))
- docs: update links in contrib guide ([#191](https://github.com/googleapis/nodejs-text-to-speech/pull/191))
- docs: update contributing path in README ([#184](https://github.com/googleapis/nodejs-text-to-speech/pull/184))

### Internal / Testing Changes
- build: use linkinator for docs test ([#190](https://github.com/googleapis/nodejs-text-to-speech/pull/190))
- fix(deps): update dependency yargs to v13 ([#187](https://github.com/googleapis/nodejs-text-to-speech/pull/187))
- build: create docs test npm scripts ([#186](https://github.com/googleapis/nodejs-text-to-speech/pull/186))
- build: test using @grpc/grpc-js in CI ([#185](https://github.com/googleapis/nodejs-text-to-speech/pull/185))
- chore: move CONTRIBUTING.md to root ([#183](https://github.com/googleapis/nodejs-text-to-speech/pull/183))

## v0.5.0

02-05-2019 13:22 PST

 ### New Features
- feat: add the effects_profile_id property. ([#173](https://github.com/googleapis/nodejs-text-to-speech/pull/173))

 ### Dependencies
- fix(deps): update dependency google-gax to ^0.25.0 ([#178](https://github.com/googleapis/nodejs-text-to-speech/pull/178))
- chore(deps): update dependency eslint-config-prettier to v4 ([#176](https://github.com/googleapis/nodejs-text-to-speech/pull/176))
- fix(deps): update dependency google-gax to ^0.24.0 ([#175](https://github.com/googleapis/nodejs-text-to-speech/pull/175))
- fix(deps): update dependency google-gax to ^0.23.0 ([#170](https://github.com/googleapis/nodejs-text-to-speech/pull/170))

 ### Documentation
- build: ignore googleapis.com in doc link check ([#174](https://github.com/googleapis/nodejs-text-to-speech/pull/174))
- docs: fix dead link to audio profiles ([#177](https://github.com/googleapis/nodejs-text-to-speech/pull/177))
- fix(docs): fix require stmt ([#166](https://github.com/googleapis/nodejs-text-to-speech/pull/166))
- build: check broken links in generated docs ([#165](https://github.com/googleapis/nodejs-text-to-speech/pull/165))

 ### Internal / Testing Changes
- test: add a smoke test ([#172](https://github.com/googleapis/nodejs-text-to-speech/pull/172))
- refactor: modernize the sample tests ([#164](https://github.com/googleapis/nodejs-text-to-speech/pull/164))
- chore(build): inject yoshi automation key ([#161](https://github.com/googleapis/nodejs-text-to-speech/pull/161))
- chore: update nyc and eslint configs ([#160](https://github.com/googleapis/nodejs-text-to-speech/pull/160))
- chore: fix publish.sh permission +x ([#158](https://github.com/googleapis/nodejs-text-to-speech/pull/158))
- fix(build): fix Kokoro release script ([#157](https://github.com/googleapis/nodejs-text-to-speech/pull/157))
- build: add Kokoro configs for autorelease ([#156](https://github.com/googleapis/nodejs-text-to-speech/pull/156))
- chore: always nyc report before calling codecov ([#152](https://github.com/googleapis/nodejs-text-to-speech/pull/152))

## v0.4.0

12-05-2018 16:31 PST

### Implementation Changes
- chore: require node 8 for samples ([#61](https://github.com/googleapis/nodejs-text-to-speech/pull/61))

### Dependencies
- chore: remove unused deps and cleanup ([#125](https://github.com/googleapis/nodejs-text-to-speech/pull/125))
- chore: removed async from dependency list ([#140](https://github.com/googleapis/nodejs-text-to-speech/pull/140))
- fix(deps): update dependency google-gax to ^0.22.0 ([#132](https://github.com/googleapis/nodejs-text-to-speech/pull/132))
- chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 ([#129](https://github.com/googleapis/nodejs-text-to-speech/pull/129))
- chore(deps): update dependency through2 to v3 ([#123](https://github.com/googleapis/nodejs-text-to-speech/pull/123))
- chore(deps): update dependency eslint-plugin-node to v8 ([#114](https://github.com/googleapis/nodejs-text-to-speech/pull/114))
- chore(deps): update dependency canvas to v2 ([#102](https://github.com/googleapis/nodejs-text-to-speech/pull/102))
- chore(deps): update dependency eslint-plugin-prettier to v3 ([#98](https://github.com/googleapis/nodejs-text-to-speech/pull/98))
- fix(deps): update dependency google-gax to ^0.20.0 ([#85](https://github.com/googleapis/nodejs-text-to-speech/pull/85))
- chore(deps): update dependency nyc to v13 ([#78](https://github.com/googleapis/nodejs-text-to-speech/pull/78))
- fix(deps): update dependency google-gax to ^0.19.0 ([#76](https://github.com/googleapis/nodejs-text-to-speech/pull/76))
- Update region tags to standard ([#75](https://github.com/googleapis/nodejs-text-to-speech/pull/75))
- chore(deps): update dependency eslint-config-prettier to v3 ([#73](https://github.com/googleapis/nodejs-text-to-speech/pull/73))
- chore(deps): lock file maintenance ([#68](https://github.com/googleapis/nodejs-text-to-speech/pull/68))
- chore(deps): lock file maintenance ([#67](https://github.com/googleapis/nodejs-text-to-speech/pull/67))
- fix(deps): update dependency google-gax to ^0.18.0 ([#63](https://github.com/googleapis/nodejs-text-to-speech/pull/63))
- chore(deps): lock file maintenance ([#62](https://github.com/googleapis/nodejs-text-to-speech/pull/62))
- chore(deps): lock file maintenance ([#59](https://github.com/googleapis/nodejs-text-to-speech/pull/59))
- chore(deps): update dependency eslint-plugin-node to v7 ([#57](https://github.com/googleapis/nodejs-text-to-speech/pull/57))
- chore(deps): lock file maintenance ([#56](https://github.com/googleapis/nodejs-text-to-speech/pull/56))

### Documentation
- fix(docs): bad namespaces causing 404s ([#149](https://github.com/googleapis/nodejs-text-to-speech/pull/149))
- docs: update readme badges ([#143](https://github.com/googleapis/nodejs-text-to-speech/pull/143))
- docs(samples): updated samples code to use async await ([#118](https://github.com/googleapis/nodejs-text-to-speech/pull/118))

### Internal / Testing Changes
- chore: nyc ignore build/test by default ([#148](https://github.com/googleapis/nodejs-text-to-speech/pull/148))
- chore: clean up usage of prettier and eslint ([#147](https://github.com/googleapis/nodejs-text-to-speech/pull/147))
- chore: update license file ([#145](https://github.com/googleapis/nodejs-text-to-speech/pull/145))
- fix(build): fix system key decryption ([#141](https://github.com/googleapis/nodejs-text-to-speech/pull/141))
- refactor(samples): convert sample tests from ava to mocha ([#133](https://github.com/googleapis/nodejs-text-to-speech/pull/133))
- chore: add a synth.metadata
- chore: drop contributors from multiple places ([#126](https://github.com/googleapis/nodejs-text-to-speech/pull/126))
- chore: use latest npm on Windows ([#124](https://github.com/googleapis/nodejs-text-to-speech/pull/124))
- chore: update eslintignore
- chore: update CircleCI config ([#121](https://github.com/googleapis/nodejs-text-to-speech/pull/121))
- chore: update issue templates ([#113](https://github.com/googleapis/nodejs-text-to-speech/pull/113))
- chore: remove old issue template ([#111](https://github.com/googleapis/nodejs-text-to-speech/pull/111))
- build: run tests on node11 ([#110](https://github.com/googleapis/nodejs-text-to-speech/pull/110))
- chores(build): do not collect sponge.xml from windows builds ([#109](https://github.com/googleapis/nodejs-text-to-speech/pull/109))
- chores(build): run codecov on continuous builds ([#108](https://github.com/googleapis/nodejs-text-to-speech/pull/108))
- chore: update new issue template ([#107](https://github.com/googleapis/nodejs-text-to-speech/pull/107))
- build: fix codecov uploading on Kokoro ([#101](https://github.com/googleapis/nodejs-text-to-speech/pull/101))
- Update kokoro config ([#99](https://github.com/googleapis/nodejs-text-to-speech/pull/99))
- build: prevent system/sample-test from leaking credentials
- Update the kokoro config ([#94](https://github.com/googleapis/nodejs-text-to-speech/pull/94))
- test: remove appveyor config ([#93](https://github.com/googleapis/nodejs-text-to-speech/pull/93))
- Update the CI config ([#92](https://github.com/googleapis/nodejs-text-to-speech/pull/92))
- Fix the linter ([#90](https://github.com/googleapis/nodejs-text-to-speech/pull/90))
- Enable prefer-const in the eslint config ([#88](https://github.com/googleapis/nodejs-text-to-speech/pull/88))
- Enable no-var in eslint ([#87](https://github.com/googleapis/nodejs-text-to-speech/pull/87))
- Switch to let/const ([#86](https://github.com/googleapis/nodejs-text-to-speech/pull/86))
- Update CI config ([#84](https://github.com/googleapis/nodejs-text-to-speech/pull/84))
- Update CI config ([#83](https://github.com/googleapis/nodejs-text-to-speech/pull/83))
- Retry npm install in CI ([#81](https://github.com/googleapis/nodejs-text-to-speech/pull/81))
- Add templates to synth.py and run it ([#79](https://github.com/googleapis/nodejs-text-to-speech/pull/79))
- chore: do not use npm ci ([#72](https://github.com/googleapis/nodejs-text-to-speech/pull/72))
- chore: ignore package-lock.json ([#69](https://github.com/googleapis/nodejs-text-to-speech/pull/69))
- chore: update renovate config ([#65](https://github.com/googleapis/nodejs-text-to-speech/pull/65))
- chore: remove bonus whitespace
- Code Samples demonstrating Audio Profiles ([#31](https://github.com/googleapis/nodejs-text-to-speech/pull/31))
- remove that whitespace ([#64](https://github.com/googleapis/nodejs-text-to-speech/pull/64))
- chore: move mocha options to mocha.opts ([#60](https://github.com/googleapis/nodejs-text-to-speech/pull/60))
- test: use strictEqual in tests ([#58](https://github.com/googleapis/nodejs-text-to-speech/pull/58))

## v0.3.0

### Implementation Changes
- Fixed the wrong region tag (#46)

#### Breaking Change:
- fix: drop support for node.js 4.x and 9.x (#49)

### New Features
- v1 GA is released (#29) 🎉

### Dependencies
- Update synth.py and update google-gax to 0.17.0 (#45)
- chore(deps): update dependency eslint to v5 (#42)
- fix(deps): update dependency yargs to v12 (#44)
- chore(deps): update dependency ava to ^0.25.0 (#37)
- fix(deps): update dependency yargs to v11 (#43)
- chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.3.0 (#36)

### Documentation
- fix: update linking for samples (#33)

### Internal / Testing Changes
- Configure Renovate (#30)
- refactor: drop repo-tool as an exec wrapper (#35)


text:
import logging

from . import JNISimProcedure
from ...engines.soot.expressions import SimSootExpr_NewArray
from ...engines.soot.values import SimSootValue_ArrayRef

l = logging.getLogger('angr.procedures.java_jni.array_operations')

# pylint: disable=arguments-differ,unused-argument

# pylint: disable=arguments-differ,unused-argument

#
# GetArrayLength
#

class GetArrayLength(JNISimProcedure):

    return_ty = 'int'

    def run(self, ptr_env, array_):
        array = self.state.jni_references.lookup(array_)
        return array.size

#
# New<Type>Array
#

class NewArray(JNISimProcedure):

    element_type = None
    return_ty = 'reference'

    def run(self, ptr_env, length_):
        length = self._normalize_array_idx(length_)
        array = SimSootExpr_NewArray.new_array(self.state, self.element_type, length)
        return self.state.jni_references.create_new_reference(obj=array)

class NewBooleanArray(NewArray):
    element_type = "boolean"
class NewByteArray(NewArray):
    element_type = "byte"
class NewCharArray(NewArray):
    element_type = "char"
class NewShortArray(NewArray):
    element_type = "short"
class NewIntArray(NewArray):
    element_type = "int"
class NewLongArray(NewArray):
    element_type = "long"

#
# NewObjectArray
#

class NewObjectArray(JNISimProcedure):

    return_ty = 'reference'

    def run(self, ptr_env, length_, element_type_, initial_element_):

        length = self._normalize_array_idx(length_)
        element_type = self.state.jni_references.lookup(element_type_)

        # create new array
        array = SimSootExpr_NewArray.new_array(self.state, element_type.name, length)

        # if available, set the initial_element as the arrays default value
        if self.state.solver.eval(initial_element_ != 0):
            initial_element = self.state.jni_references.lookup(initial_element_)
            generator = lambda state: initial_element
            array.add_default_value_generator(generator)
        else:
            initial_element = None

        # return reference to array
        return self.state.jni_references.create_new_reference(array)

#
# GetObjectArrayElement / SetObjectArrayElement
#

class GetObjectArrayElement(JNISimProcedure):

    return_ty = 'reference'

    def run(self, ptr_env, array_, idx_):

        idx = self._normalize_array_idx(idx_)
        array = self.state.jni_references.lookup(array_)

        # check array bounds
        SimSootValue_ArrayRef.check_array_bounds(idx, array, self.state)

        # concretize idx (TODO: handle symbolic idxes)
        if self.state.solver.symbolic(idx):
            idx = self.state.eval(idx)
            l.warning("Symbolic indices are not supported for object arrays %s. "
                      "Index gets concretized to %s", array, idx)

        # load element and return reference to it
        element = self.state.javavm_memory.load_array_element(array, idx)
        return self.state.jni_references.create_new_reference(element)

class SetObjectArrayElement(JNISimProcedure):

    return_ty = 'reference'

    def run(self, ptr_env, array_, idx_, value_):

        idx = self._normalize_array_idx(idx_)
        array = self.state.jni_references.lookup(array_)
        value = self.state.jni_references.lookup(value_)

        # check array bounds
        SimSootValue_ArrayRef.check_array_bounds(idx, array, self.state)

         # concretize idx (TODO: handle symbolic idxes)
        if self.state.solver.symbolic(idx):
            idx = self.state.eval(idx)
            l.warning("Symbolic indices are not supported for object arrays %s. "
                      "Index gets concretized to %s", array, idx)

        self.state.javavm_memory.store_array_element(array, idx, value)

#
# Get<Type>ArrayElements / Release<Type>ArrayElements
#

class GetArrayElements(JNISimProcedure):

    return_ty = 'reference'

    def run(self, ptr_env, array_, ptr_isCopy):

        array = self.state.jni_references.lookup(array_)

        # load array elements from java memory
        # => if size is symbolic, we load the maximum number of elements
        max_array_length = self.state.solver.max(array.size)
        values = self.state.javavm_memory.load_array_elements(array, start_idx=0, no_of_elements=max_array_length)

        # store elements in native memory
        memory_addr = self._store_in_native_memory(values, array.element_type)

        # if isCopy is not null, store JNI_TRUE at that address
        if self.state.solver.eval(ptr_isCopy != 0):
            self._store_in_native_memory(data=self.JNI_TRUE, data_type='boolean', addr=ptr_isCopy)

        # return native address to the elements
        return memory_addr

class ReleaseArrayElements(JNISimProcedure):

    return_ty = 'void'

    JNI_COMMIT = 1
    JNI_ABORT = 2

    def run(self, ptr_env, array_, ptr_elems, mode_):

        if self.state.solver.symbolic(mode_):
            l.warning("Symbolic mode %s in JNI function ReleaseArrayElements"
                      "is not supported and gets concretized.", mode_)
        mode = self.state.solver.min(mode_) # avoid JNI_ABORT by taking the minimum

        if mode == self.JNI_ABORT:
            return

        array = self.state.jni_references.lookup(array_)

        # load array elements from native memory
        # => if size is symbolic, we load the maximum number of elements
        max_array_size = self.state.solver.max(array.size)
        elements = self._load_from_native_memory(addr=ptr_elems,
                                                 data_type=array.element_type,
                                                 no_of_elements=max_array_size)

        # store elements in java memory
        self.state.javavm_memory.store_array_elements(array, start_idx=0, data=elements)

#
# Get<Type>ArrayRegion / Set<Type>ArrayRegion
#

class GetArrayRegion(JNISimProcedure):

    return_ty = 'void'

    def run(self, ptr_env, array_, start_idx_, length_, ptr_buf):

        array = self.state.jni_references.lookup(array_)
        start_idx = self._normalize_array_idx(start_idx_)
        length = self._normalize_array_idx(length_)

        # check if the range (induced by start_idx and length) is valid
        if not self._check_region_bounds(array, start_idx, length, self.state):
            return

        # concretize length (TODO handle symbolic length)
        no_of_elements = self._concretize_region_length(length, self.state)

        # load elements from java memory
        elements = self.state.javavm_memory.load_array_elements(array, start_idx, no_of_elements)

        # and store them in the native memory
        self._store_in_native_memory(data=elements, data_type=array.element_type, addr=ptr_buf)

    @staticmethod
    def _concretize_region_length(length, state):
        # if necessary, concretize length
        # TODO handle symbolic length
        if state.solver.symbolic(length):
            midpoint_length = (state.solver.min(length) + state.solver.max(length)) // 2
            state.solver.add(length == midpoint_length)
            l.warning("Symbolic lengths are currently not supported. "
                      "Length is concretized to a midpoint value.")
        return state.solver.eval_one(length)

    @staticmethod
    def _check_region_bounds(array, start_idx, length, state):
        # A valid range fulfills the following constraints:
        # - 0 <= start_idx < array_size
        # - start_idx <= last_idx < array_size
        #   with last_idx := start_idx+length-1
        # - 0 <= length <= array_size
        range_constraints = state.solver.And(
            start_idx.SGE(0), start_idx.SLT(array.size),
            array.size.SGT(start_idx+length-1),
            length.SGE(0), length.SLE(array.size)
        )

        # Evaluate range constraints
        # => Note: if start_idx and/or length are symbolic, the result can be
        #    True and False at the same time
        range_stays_within_bounds = state.solver.eval_upto(range_constraints, 2)

        if not True in range_stays_within_bounds:
            # There is no valid combination of start_idx and length, s.t. the
            # range stays within the array bounds.
            # Correct simulation must continue with a raised Exception
            # TODO raise java.lang.ArrayIndexOutOfBoundsException
            #      For now, we just skip this SimProcedure.
            l.error("Skipping SimProcedure: "
                    "Every combination of start_idx %s and length %s is invalid (array length %s).",
                    start_idx, length, array.size)
            return False

        if False in range_stays_within_bounds and \
           True  in range_stays_within_bounds:
           # There are some combination of start_idx and length, s.t. the range
           # exceeds array bounds.
           # For now, just constraint values to stay within bounds.
           # TODO split current SimState into two successors:
           #      --> one w/ all valid indexes
           #      --> one w/ all invalid indexes and a raised exception
           l.warning("Possible out-of-bounds access! "
                     "Constraint start_idx %s and length %s to valid values (array length %s).",
                     start_idx, length, array.size)
           state.solver.add(range_constraints)

        return True

class SetArrayRegion(JNISimProcedure):

    return_ty = 'void'

    def run(self, ptr_env, array_, start_idx_, length_, ptr_buf):

        array = self.state.jni_references.lookup(array_)
        start_idx = self._normalize_array_idx(start_idx_)
        length = self._normalize_array_idx(length_)

        # check if the range (induced by start_idx and length) is valid
        if not GetArrayRegion._check_region_bounds(array, start_idx, length, self.state):
            return

        # concretize length (TODO handle symbolic length)
        no_of_elements = GetArrayRegion._concretize_region_length(length, self.state)

        # load elements from native memory
        elements = self._load_from_native_memory(addr=ptr_buf,
                                                 data_type=array.element_type,
                                                 no_of_elements=no_of_elements)

        # and store them in the java memory
        self.state.javavm_memory.store_array_elements(array, start_idx, elements)


text:
class UsersController < ApplicationController
    before_action :current_user_redirect, only: [:show, :index, :destroy, :edit, :update]
    before_action :redirect_if_restricted, only: [:show, :destroy, :edit, :update]

    def new
      @user = User.new
    end

    def create
        @user = User.new(user_params)
        if @user.save
          session[:user_id] = @user.id
          redirect_to users_path
        else
          @errors = @user.errors.full_messages
          render 'new'
        end
    end

    def index
      @users = User.all
    end

    def show
      get_user
    end

    def edit
      get_user
      redirect_not_admin_or_self
    end

    def update
      get_user

      redirect_not_admin_or_self
      if is_an_admin
        @user.update(user_role_param)
      end
      if @user.update(user_params)
        redirect_to users_path
      else
        @errors = @user.errors.full_messages
        render 'edit'
      end
    end

    def destroy
      if is_an_admin
        get_user
        unless @user.destroy
          flash[:notice] = "Something went wrong. Plase try again"
        end
      else
        flash[:notice] = "You do not have authorization to perform this action"
      end
        redirect_to users_path
    end

    private

    def get_user
      @user = User.find(params[:id])
    end

    def user_params
        params.require(:user).permit(:email, :password, :first_name, :last_name, :phone_number)
    end

    def user_role_param
      params.require(:user).permit(:role)
    end
end


text:
package com.gabia.api;

import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Random;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class ApiClass {

	private String smsId = "";
	private String apiKey = "";
	private String method = "basic";
	private final static String apiUrl = "http://sms.gabia.com/api";
	private final static String methodName = "gabiasms";

	private String refXmlFormat = "<request>" + "<sms-id>%s</sms-id>"
			+ "<access-token>%s</access-token>"
			+ "<response-format>xml</response-format>"
			+ "<method>SMS.getStatusByRef</method>" + "<params>"
			+ "<ref_key>%s</ref_key>" + "</params>" + "</request>";

	private String refXmlFormat_all = "<request>" + "<sms-id>%s</sms-id>"
			+ "<access-token>%s</access-token>"
			+ "<response-format>xml</response-format>"
			+ "<method>SMS.getStatusByRef_all</method>" + "<params>"
			+ "<ref_key>%s</ref_key>" + "</params>" + "</request>";

	private String reqXmlFormat = "<request>" + "<sms-id>%s</sms-id>"
			+ "<access-token>%s</access-token>"
			+ "<response-format>xml</response-format>"
			+ "<method>SMS.send</method>" + "<params>"
			+ "<send_type>%s</send_type>" + "<ref_key>%s</ref_key>"
			+ "<subject>%s</subject>" + "<message>%s</message>"
			+ "<callback>%s</callback>" + "<phone>%s</phone>"
			+ "<reserve>%s</reserve>" + "</params>"
			+ "</request>";

	private String reqXmlFormat2 = "<request>" + "<sms-id>%s</sms-id>"
			+ "<access-token>%s</access-token>"
			+ "<response-format>xml</response-format>"
			+ "<method>SMS.multi_send</method>" + "<params>"
			+ "<send_type>%s</send_type>" + "<ref_key>%s</ref_key>"
			+ "<subject>%s</subject>" + "<message>%s</message>"
			+ "<callback>%s</callback>" + "<phone>%s</phone>"
			+ "<reserve>%s</reserve>" + "</params>"
			+ "</request>";

	private String reserveCancel = "<request>" + "<sms-id>%s</sms-id>"
			+ "<access-token>%s</access-token>"
			+ "<response-format>xml</response-format>"
			+ "<method>SMS.reservationCancel</method>" + "<params>"
			+ "<ref_key>%s</ref_key>" + "<send_type>%s</send_type>"
			+ "<phonenum>%s</phonenum>" + "</params>" + "</request>";

	public ApiClass(String smsId, String apiKey) {
		this.smsId = smsId;
		this.apiKey = apiKey;
	}

	public String MakeToString(String phone_arr[]){
		String phone_st = Arrays.toString(phone_arr);
		phone_st = phone_st.replace("[","");
		phone_st = phone_st.replace("]","");
		phone_st = phone_st.replace(" ", "");
		return phone_st;
	}

	public String send(String[] args) {
		try {
			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
			config.setServerURL(new URL(apiUrl));
			XmlRpcClient client = new XmlRpcClient();
			client.setConfig(config);

			String nonce = getNonce();
			String md5_access_token = nonce + getMD5(nonce + this.apiKey);
			String s;

			if (args[0] == "status_by_ref") {
				s = String.format(refXmlFormat, this.smsId, md5_access_token,
						args[1]);
			}else if(args[0] == "status_by_ref_all"){
				this.method = args[0];
				s = String.format(refXmlFormat_all, this.smsId, md5_access_token,
						args[1]);
			}else if(args[0] == "multi_sms"){
				args[0] = "sms";
				args[2] = this.escape_xml_str(args[2]);
				args[3] = this.escape_xml_str(args[3]);
				s = String.format(reqXmlFormat2, this.smsId, md5_access_token,
						args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
			}else if(args[0] == "multi_lms"){
				args[0] = "lms";
				args[2] = this.escape_xml_str(args[2]);
				args[3] = this.escape_xml_str(args[3]);
				s = String.format(reqXmlFormat2, this.smsId, md5_access_token,
						args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
			}else if(args[0] == "reserveCancel"){
				s = String.format(reserveCancel, this.smsId, md5_access_token,
						args[1], args[2],args[3]);
			}else{
				args[2] = this.escape_xml_str(args[2]);
				args[3] = this.escape_xml_str(args[3]);
				s = String.format(reqXmlFormat, this.smsId, md5_access_token,
						args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
			}

//			System.out.println(s);
			Object[] params = new Object[] { new String(s) };
			String response = (String) client.execute(methodName, params);

//			System.out.println("Response:" + getResultXml(response));
			return response;
		} catch (XmlRpcException exception) {
			System.err.println("JavaClient: XML-RPC Fault #"
					+ Integer.toString(exception.code) + ": "
					+ exception.toString());
		} catch (Exception exception) {
			System.err.println("JavaClient: " + exception.toString());
		}
		return "";
	}

	public String escape_xml_str(String str){
		str = str.replace("&", "&amp");
		str = str.replace("<", "&lt");
		str = str.replace(">", "&gt");
		str = str.replace("'", "&apos");
		str = str.replace("\"", "&quot");

		return str;
	}
	public String getNonce() {
		StringBuffer nonce = new StringBuffer();
		Random random = new Random();

		String chars[] = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9"
				.split(",");

		for (int i = 0; i < 8; i++) {
			nonce.append(chars[random.nextInt(chars.length)]);
		}
		// System.out.println("nonce:" + nonce.toString());
		return nonce.toString();
	}

	public String getMD5(String str) throws NoSuchAlgorithmException {
		MessageDigest di = MessageDigest.getInstance("MD5");
		di.update(new String(str).getBytes());
		byte[] md5Code = di.digest();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < md5Code.length; i++) {
			String md5Char = String.format("%02x", 0xff & (char) md5Code[i]);
			sb.append(md5Char);
		}

		return sb.toString();
	}

	public ApiResult getResult( String xmlStr ) {
		String code = "";
		String mesg = "";

		try {
			// first of all we request out
			// DOM-implementation:
			DocumentBuilderFactory factory = DocumentBuilderFactory
					.newInstance();
			// then we have to create document-loader:
			DocumentBuilder loader = factory.newDocumentBuilder();

			// loading a DOM-tree...
			Document document = loader.parse(new InputSource(new StringReader(
					xmlStr)));
			// at last, we get a root element:
			Element tree = document.getDocumentElement();
			// ... do something with document element ...
			NodeList items = tree.getElementsByTagName("code");
			code = items.item(0).getFirstChild().getNodeValue();

			items = tree.getElementsByTagName("mesg");
			mesg = items.item(0).getFirstChild().getNodeValue();

		} catch (IOException ex) {
			// any IO errors occur:
			handleError(ex);
		} catch (SAXException ex) {
			// parse errors occur:
			handleError(ex);
		} catch (ParserConfigurationException ex) {
			// document-loader cannot be created which,
			// satisfies the configuration requested
			handleError(ex);
		} catch (FactoryConfigurationError ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		} catch (NullPointerException ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		}

		ApiResult res = new ApiResult(code,mesg);
		return res;
	}

	public String getResultXml(String xmlStr) {
		try {
			// first of all we request out
			// DOM-implementation:
			DocumentBuilderFactory factory = DocumentBuilderFactory
					.newInstance();
			// then we have to create document-loader:
			DocumentBuilder loader = factory.newDocumentBuilder();

			// loading a DOM-tree...
			Document document = loader.parse(new InputSource(new StringReader(
					xmlStr)));
			// at last, we get a root element:
			Element tree = document.getDocumentElement();
			// ... do something with document element ...
			NodeList items = tree.getElementsByTagName("result");
			String nodeValue = items.item(0).getFirstChild().getNodeValue();

			byte[] bytDecoded = Base64Utils.decode(nodeValue);
			String result = new String(bytDecoded);

//			System.out.println("DecodedString=" + result);

			return result.toString();

		} catch (IOException ex) {
			// any IO errors occur:
			handleError(ex);
		} catch (SAXException ex) {
			// parse errors occur:
			handleError(ex);
		} catch (ParserConfigurationException ex) {
			// document-loader cannot be created which,
			// satisfies the configuration requested
			handleError(ex);
		} catch (FactoryConfigurationError ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		} catch (NullPointerException ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		}

		return "";
	}

	public String[][] getResultXml_All(String xmlStr) {
		String[][] result_ref_all = null;
		try {
			// first of all we request out
			// DOM-implementation:
			DocumentBuilderFactory factory = DocumentBuilderFactory
					.newInstance();
			// then we have to create document-loader:
			DocumentBuilder loader = factory.newDocumentBuilder();

			// loading a DOM-tree...
			Document document = loader.parse(new InputSource(new StringReader(
					xmlStr)));
			// at last, we get a root element:
			Element tree = document.getDocumentElement();
			// ... do something with document element ...
			NodeList items = tree.getElementsByTagName("result");
			String nodeValue = items.item(0).getFirstChild().getNodeValue();

			byte[] bytDecoded = Base64Utils.decode(nodeValue);
			String result = new String(bytDecoded);
			System.out.println(result);
			document = loader.parse(new InputSource(new StringReader(result)));
			tree = document.getDocumentElement();
			items = tree.getElementsByTagName("entry");

			if(items.item(0).getFirstChild().getNodeValue() == "NODATA"){
				return result_ref_all;
			}
			result_ref_all = new String[items.getLength()][2];
			for(int a=0; a<items.getLength(); a++){
				Node nd = items.item(a);
				if(nd.getNodeType() == Node.ELEMENT_NODE){
					Element el = (Element)nd;

					NodeList phoneNdlist = el.getElementsByTagName("PHONENUM");
					NodeList mesgNdlist = el.getElementsByTagName("MESG");
					Element phoneEl = (Element)phoneNdlist.item(0);
					Element mesgEl = (Element)mesgNdlist.item(0);
					NodeList chNdListPhone = phoneEl.getChildNodes();
					NodeList chNdListMesg = mesgEl.getChildNodes();

					result_ref_all[a][0] = (String)chNdListPhone.item(0).getNodeValue();
					result_ref_all[a][1] = (String)chNdListMesg.item(0).getNodeValue();
					//System.out.println("**code**" + chNdListPhone.item(0).getNodeValue());
					//System.out.println("**mesg**"+ chNdListMesg.item(0).getNodeValue());
				}
			}

			//System.out.println(Arrays.toString(result_ref_all));
//			System.out.println("DecodedString=" + result);

			return result_ref_all;

		} catch (IOException ex) {
			// any IO errors occur:
			handleError(ex);
		} catch (SAXException ex) {
			// parse errors occur:
			handleError(ex);
		} catch (ParserConfigurationException ex) {
			// document-loader cannot be created which,
			// satisfies the configuration requested
			handleError(ex);
		} catch (FactoryConfigurationError ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		} catch (NullPointerException ex) {
			// DOM-implementation is not available
			// or cannot be instantiated:
			handleError(ex);
		}

		return result_ref_all;
	}

	private static final void handleError(Throwable ex) {
		// ... handle error here...
		System.out.println("Error Handler: " + ex.toString());
	}
}