text:
// .NAME vtkBranchExtentTranslator - Uses alternative source for whole extent.
// .SECTION Description
// vtkBranchExtentTranslator is like extent translator, but it uses an
// alternative source as a whole extent. The whole extent passed is assumed
// to be a subextent of the original source.  we simply take the intersection
// of the split extent and the whole extdent passed in.  We are attempting to
// make branching pipelines request consistent extents with the same piece
// requests.

// .SECTION Caveats
// This object is still under development.

#ifndef __vtkBranchExtentTranslator_h
#define __vtkBranchExtentTranslator_h

#include "vtkExtentTranslator.h"

class vtkImageData;

class VTK_PARALLEL_EXPORT vtkBranchExtentTranslator : public vtkExtentTranslator
{
public:
  static vtkBranchExtentTranslator *New();

  vtkTypeMacro(vtkBranchExtentTranslator,vtkExtentTranslator);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // This is the original upstream image source.
  virtual void SetOriginalSource(vtkImageData*);
  vtkGetObjectMacro(OriginalSource,vtkImageData);

  // Description:
  // Generates the extent from the pieces.
  int PieceToExtent();

  // Description:
  // This unstructured extent/piece is store here for the users convenience.
  // It is not used internally.  The intent was to let an "assignment" be made
  // when the translator/first source is created.  The translator/assignment
  // can be used for any new filter that uses the original source as output.
  // Branches will then have the same assignment.
  vtkSetMacro(AssignedPiece, int);
  vtkGetMacro(AssignedPiece, int);
  vtkSetMacro(AssignedNumberOfPieces, int);
  vtkGetMacro(AssignedNumberOfPieces, int);

protected:
  vtkBranchExtentTranslator();
  ~vtkBranchExtentTranslator();

  vtkImageData *OriginalSource;
  int AssignedPiece;
  int AssignedNumberOfPieces;
private:
  vtkBranchExtentTranslator(const vtkBranchExtentTranslator&);  // Not implemented.
  void operator=(const vtkBranchExtentTranslator&);  // Not implemented.
};

#endif


text:
create table webpage (
	id char(72) not null primary key,
	title char(72) not null,
	menu_title char(72) not null,
	window_title char(72) not null,
	access char(12) not null,
	layout char(48) not null,
	description text,
	keywords text,
	body text
);

create index webpage_access on webpage (access);

insert into webpage (id, title, menu_title, window_title, access, layout, description, keywords, body) values ('index', 'Welcome to Elefant', 'Home', '', 'public', 'index', '', '', '

Congratulations!
You have successfully installed Elefant, the refreshingly simple new PHP web framework and CMS.
Getting Started
To log in as an administrator and edit pages, write a blog post, or upload files, go to /admin.
Developers
Documentation, source code and issue tracking can be found at github.com/jbroadway/elefant

');

create table block (
	id char(72) not null primary key,
	title char(72) not null,
	body text,
	access char(12) not null,
	show_title char(3) not null
);

create index block_access on block (id, access);

insert into block (id, title, access, body, show_title) values ('members', 'Members', 'public', '{! user/sidebar !}', 'no');

create table user (
	id integer primary key,
	email char(72) unique not null,
	password char(128) not null,
	session_id char(32) unique,
	expires datetime not null,
	name char(72) not null,
	type char(32) not null,
	signed_up datetime not null,
	updated datetime not null,
	userdata text not null
);

create index user_email_password on user (email, password);
create index user_session_id on user (session_id);

create table user_openid (
	token char(128) primary key,
	user_id int not null
);

create table versions (
	id integer primary key,
	class char(72) not null,
	pkey char(72) not null,
	user int not null,
	ts datetime not null,
	serialized text not null
);

create index versions_class on versions (class, pkey, ts);
create index versions_user on versions (user, ts);

create table api (
	token char(35) not null primary key,
	api_key char(35) not null,
	user_id int not null
);

create index api_token on api (token, api_key);
create index api_user on api (user_id);

create table blog_post (
	id integer primary key,
	title char(72) not null,
	ts datetime not null,
	author char(32) not null,
	published char(3) not null,
	body text not null,
	tags text not null,
	extra text not null
);

create index blog_post_ts on blog_post (ts);
create index blog_post_pts on blog_post (ts, published);

create table blog_tag (
	id char(24) not null,
	primary key (id)
);

create table blog_post_tag (
	tag_id char(24) not null,
	post_id int not null,
	primary key (tag_id, post_id)
);

create table `lock` (
	id integer primary key,
	user int not null,
	resource varchar(72) not null,
	resource_id varchar(72) not null,
	expires datetime not null,
	created datetime not null,
	modified datetime not null
);

create index lock_resource on lock (resource, resource_id, expires);
create index lock_user on lock (user);

create table apps (
	name char(48) not null primary key,
	version char(16) not null
);

insert into apps (name, version) values ('blog', '1.1.3-stable');
insert into apps (name, version) values ('user', '1.1.3-stable');

redpajama_set_name: RedPajamaGithub


text:
'use strict';

import path from 'path';
import chalk from 'chalk';

var logPrefix = '[' + path.basename(__filename) + '] ';

const routeBuilder = function () {
    var objects = arguments;
    var prefix = typeof objects[0] === 'string' ? objects[0] : '/api';
    if (typeof objects[0] === 'string') {
        Array.prototype.shift.call(objects);
    }
    var routes = [];
    Array.prototype.forEach.call(objects, (obj) => {
        if (obj.routes && Array.isArray(obj.routes)) {
            obj.routes.forEach((route, i, objRoutes) => {
                var _route = objRoutes.slice(i, i + 1)[0];
                _route.path = prefix + _route.path;
                routes.push(_route);
                console.log(chalk.green(`${logPrefix} Build Route for (${_route.path})`));
            });
        }
    });
    return routes;
};

module.exports = {RouteBuilder: routeBuilder};


text:
#ifndef TAGDETECTION_H
#define TAGDETECTION_H

#include <Eigen/Dense>

#include "opencv2/opencv.hpp"

#include <utility>
#include <vector>

namespace AprilTags {

struct TagDetection {

  //! Constructor
  TagDetection();

  //! Constructor for manually creating tags in a world map
  TagDetection(int id);

  //! Is the detection good enough?
  bool good;

  //! Observed code
  long long obsCode;

  //! Matched code
  long long code;

  //! What was the ID of the detected tag?
  int id;

  //! The hamming distance between the detected code and the true code
  int hammingDistance;

  //! How many 90 degree rotations were required to align the code (internal use only)
  int rotation;

  /////////////// Fields below are filled in by TagDetector ///////////////
  //! Position (in fractional pixel coordinates) of the detection.
  /*  The points travel counter-clockwise around the target, always
   *  starting from the same corner of the tag.
   */
  std::pair<float,float> p[4];

  //! Center of tag in pixel coordinates.
  std::pair<float,float> cxy;

  //! Measured in pixels, how long was the observed perimeter.
  /*! Observed perimeter excludes the inferred perimeter which is used to connect incomplete quads. */
  float observedPerimeter;

  //! A 3x3 homography that computes pixel coordinates from tag-relative coordinates.
  /*  Both the input and output coordinates are 2D homogeneous vectors, with y = Hx.
   *  'y' are pixel coordinates, 'x' are tag-relative coordinates. Tag coordinates span
   *  from (-1,-1) to (1,1). The orientation of the homography reflects the orientation
   *  of the target.
   */
  Eigen::Matrix3d homography;

  //! Orientation in the xy plane
  float getXYOrientation() const;

  //! The homography is relative to image center, whose coordinates are below.
  std::pair<float,float> hxy;

  //! Interpolate point given (x,y) is in tag coordinate space from (-1,-1) to (1,1).
  std::pair<float,float> interpolate(float x, float y) const;

  //! Used to eliminate redundant tags
  bool overlapsTooMuch(const TagDetection &other) const;

  //! Relative pose of tag with respect to the camera
  /* Returns the relative location and orientation of the tag using a
     4x4 homogeneous transformation matrix (see Hartley&Zisserman,
     Multi-View Geometry, 2003). Requires knowledge of physical tag
     size (side length of black square in meters) as well as camera
     calibration (focal length and principal point); Result is in
     camera frame (z forward, x right, y down)
  */
  Eigen::Matrix4d getRelativeTransform(double tag_size, double fx, double fy,
                                       double px, double py) const;

  //! Recover rotation matrix and translation vector of April tag relative to camera.
  // Result is in object frame (x forward, y left, z up)
  void getRelativeTranslationRotation(double tag_size, double fx, double fy, double px, double py,
                                      Eigen::Vector3d& trans, Eigen::Matrix3d& rot) const;

  //! Draw the detection within the supplied image, including boarders and tag ID.
  void draw(cv::Mat& image) const;
};

} // namespace

#endif


text:
package org.apache.hadoop.hive.serde2.objectinspector.primitive;

import org.apache.hadoop.hive.ql.io.parquet.writable.BinaryWritable;
import org.apache.hadoop.io.Text;

import org.apache.parquet.io.api.Binary;

/**
 * The ParquetStringInspector inspects a BinaryWritable to give a Text or String.
 *
 */
public class ParquetStringInspector extends JavaStringObjectInspector implements SettableStringObjectInspector {

  public ParquetStringInspector() {
    super();
  }

  @Override
  public Text getPrimitiveWritableObject(final Object o) {
    if (o == null) {
      return null;
    }

    if (o instanceof BinaryWritable) {
      return new Text(((BinaryWritable) o).getBytes());
    }

    if (o instanceof Text) {
      return (Text) o;
    }

    if (o instanceof String) {
      return new Text((String) o);
    }

    throw new UnsupportedOperationException("Cannot inspect " + o.getClass().getCanonicalName());
  }

  @Override
  public String getPrimitiveJavaObject(final Object o) {
    if (o == null) {
      return null;
    }

    if (o instanceof BinaryWritable) {
      return ((BinaryWritable) o).getString();
    }

    if (o instanceof Text) {
      return ((Text) o).toString();
    }

    if (o instanceof String) {
      return (String) o;
    }

    throw new UnsupportedOperationException("Cannot inspect " + o.getClass().getCanonicalName());
  }

  @Override
  public Object set(final Object o, final Text text) {
    return new BinaryWritable(text == null ? null : Binary.fromByteArray(text.getBytes()));
  }

  @Override
  public Object set(final Object o, final String string) {
    return new BinaryWritable(string == null ? null : Binary.fromString(string));
  }

  @Override
  public Object create(final Text text) {
    if (text == null) {
      return null;
    }
    return text.toString();
  }

  @Override
  public Object create(final String string) {
    return string;
  }
}


text:
// ----------------------------------------------------------------------------------
//
// Copyright 2011 Microsoft Corporation
// 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.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Reflection;
using System.Xml.Serialization;
using Microsoft.WindowsAzure.Management.CloudService.Properties;
using Microsoft.WindowsAzure.Management.CloudService.ServiceConfigurationSchema;
using Microsoft.WindowsAzure.Management.CloudService.ServiceDefinitionSchema;
using Microsoft.WindowsAzure.Management.CloudService.Utilities;
using System.Linq;
using System.Collections;
using Microsoft.WindowsAzure.Management.CloudService.Model;

namespace Microsoft.WindowsAzure.Management.CloudService.Model
{
    /// <summary>
    /// Role Info for a worker role
    /// </summary>
    internal class WorkerRoleInfo : RoleInfo
    {
        public WorkerRoleInfo(string name, int instanceCount = 1) : base(name, instanceCount) { }

        internal override void AddRoleToDefinition(ServiceDefinition def, object template)
        {
            base.AddRoleToDefinition(def, template);
            WorkerRole workerRole = template as WorkerRole;
            var toAdd = new WorkerRole[] { workerRole };

            if (def.WorkerRole != null)
            {
                def.WorkerRole = def.WorkerRole.Concat(toAdd).ToArray();
            }
            else
            {
                def.WorkerRole = toAdd;
            }
        }
    }
}


text:
package it.rainbowbreeze.picama.ui;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import it.rainbowbreeze.picama.R;

public class MainActivity extends InjectableActivity {
    /**
     * The {@link android.support.v4.view.PagerAdapter} that will provide
     * fragments for each of the sections. We use a
     * {@link FragmentPagerAdapter} derivative, which will keep every
     * loaded fragment in memory. If this becomes too memory intensive, it
     * may be best to switch to a
     * {@link android.support.v4.app.FragmentStatePagerAdapter}.
     */
    private SectionsPagerAdapter mSectionsPagerAdapter;

    /**
     * The {@link ViewPager} that will host the section contents.
     */
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.act_main);

        // Toolbar help:
        //  http://android-developers.blogspot.it/2014/10/appcompat-v21-material-design-for-pre.html
        Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
        setSupportActionBar(toolbar);

        // Create the adapter that will return a fragment for each sections of the activity.
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), getBaseContext());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.main_viewpager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        // Give the TabLayout the ViewPager
        // https://github.com/codepath/android_guides/wiki/Google-Play-Style-Tabs-using-TabLayout
        TabLayout tabLayout = (TabLayout) findViewById(R.id.main_slidingTabs);
        tabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        boolean value = true;
        switch (id) {
            case R.id.main_mnuSettings:
                Intent intent = new Intent(this, SettingsActivity.class);
                startActivity(intent);
                break;
            case R.id.main_mnuAbout:
                Toast.makeText(this, "Make by me", Toast.LENGTH_SHORT).show();
                break;
            default:
                value = super.onOptionsItemSelected(item);
        }
        return value;
    }
}


text:
namespace TraktApiSharp.Objects.Post.Syncs.Collection
{
    using Requests.Interfaces;
    using System.Collections.Generic;

    public interface ITraktSyncCollectionPost : IRequestBody
    {
        IEnumerable<ITraktSyncCollectionPostMovie> Movies { get; set; }

        IEnumerable<ITraktSyncCollectionPostShow> Shows { get; set; }

        IEnumerable<ITraktSyncCollectionPostEpisode> Episodes { get; set; }
    }
}


text:
package net

const (
	TCPNetwork = Network("tcp")
	UDPNetwork = Network("udp")
)

type Network string

type NetworkList interface {
	HasNetwork(Network) bool
}


text:
package edu.common.dynamicextensions.domain;

import edu.common.dynamicextensions.domaininterface.RoleInterface;
import edu.common.dynamicextensions.util.global.Constants.AssociationType;
import edu.common.dynamicextensions.util.global.Constants.Cardinality;
import edu.wustl.common.actionForm.AbstractActionForm;
import edu.wustl.common.domain.AbstractDomainObject;
import edu.wustl.common.exception.AssignDataException;

/**
 * This Class represents the role of the Association.
 * @version 1.0
 * @created 28-Sep-2006 12:20:08 PM
 * @hibernate.class table="DYEXTN_ROLE"
 * @hibernate.cache  usage="read-write"
 */
public class Role extends DynamicExtensionBaseDomainObject implements RoleInterface
{

	/**
	 * Serial Version Unique Identifier
	 */
	private static final long serialVersionUID = 8674217047857771139L;

	/**
	 * The association type : containment or linking
	 */
	protected String associationType;

	/**
	 *  Maximum cardinality of this role.
	 */
	protected Integer maxCardinality;

	/**
	 * Minimum cardinality of this role.
	 */
	protected Integer minCardinality;

	/**
	 * Name of the role.
	 */
	protected String name;

	/**
	 * Empty constructor.
	 */
	public Role()
	{
	}

	/**
	 * This method returns the Unique identifier of this Object.
	 * @hibernate.id name="id" column="IDENTIFIER" type="long"
	 * length="30" unsaved-value="null" generator-class="native"
	 * @hibernate.generator-param name="sequence" value="DYEXTN_ROLE_SEQ"
	 * @return the Unique identifier of this Object.
	 */
	public Long getId()
	{
		return id;
	}

	/**
	 * This method returns the type of Association.
	 * @hibernate.property name="associationType" type="string" column="ASSOCIATION_TYPE"
	 * @return the type of Association.
	 */
	private String getAssociationType()
	{
		return associationType;
	}

	/**
	 * This method sets the type of Association.
	 * @param associationType the type of Association to be set.
	 */
	private void setAssociationType(String associationType)
	{
		this.associationType = associationType;
	}

	/**
	 * This method returns the maximum cardinality.
	 * @hibernate.property name="maxCardinality" type="integer" column="MAX_CARDINALITY"
	 * @return the maximum cardinality.
	 */
	public Integer getMaxCardinality()
	{
		return maxCardinality;
	}

	/**
	 * This method sets the maximum cardinality.
	 * @param maxCardinality the value to be set as maximum cardinality.
	 */
	public void setMaxCardinality(Integer maxCardinality)
	{
		this.maxCardinality = maxCardinality;
	}

	/**
	 * This method returns the minimum cardinality.
	 * @hibernate.property name="minCardinality" type="integer" column="MIN_CARDINALITY"
	 * @return Returns the minimum cardinality.
	 */
	public Integer getMinCardinality()
	{
		return minCardinality;
	}

	/**
	 * This method sets the minimum cardinality.
	 * @param minCardinality the value to be set as minimum cardinality.
	 */
	public void setMinCardinality(Integer minCardinality)
	{
		this.minCardinality = minCardinality;
	}

	/**
	 * This method returns the name of the role.
	 * @hibernate.property name="name" type="string" column="NAME"
	 * @return the name of the role.
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * This method sets the name of the role.
	 * @param name the name to be set.
	 */
	public void setName(String name)
	{
		this.name = name;
	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#getMaximumCardinality()
	 */
	public Cardinality getMaximumCardinality()
	{
		return Cardinality.get(getMaxCardinality());
	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#setMaximumCardinality(edu.common.dynamicextensions.util.global.Constants.Cardinality)
	 */
	public void setMaximumCardinality(Cardinality maxCardinality)
	{
		setMaxCardinality(maxCardinality.getValue());

	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#getMinimumCardinality()
	 */
	public Cardinality getMinimumCardinality()
	{
		return Cardinality.get(getMinCardinality());
	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#setMinimumCardinality(edu.common.dynamicextensions.util.global.Constants.Cardinality)
	 */
	public void setMinimumCardinality(Cardinality minCardinality)
	{
		setMinCardinality(minCardinality.getValue());
	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#getAssociationsType()
	 */
	public AssociationType getAssociationsType()
	{
		return AssociationType.get(getAssociationType());
	}

	/**
	 * @see edu.common.dynamicextensions.domaininterface.RoleInterface#setAssociationsType(edu.common.dynamicextensions.util.global.Constants.AssociationType)
	 */
	public void setAssociationsType(AssociationType associationType)
	{
		 setAssociationType(associationType.getValue());
	}

}


text:
#include <boost/test/unit_test.hpp>
#include <reactive/http/cookie_bag.hpp>
#include <reactive/http/cookie.hpp>

BOOST_AUTO_TEST_SUITE(reactive_http_cookie_bag)

BOOST_AUTO_TEST_CASE(test_has)
{
    reactive::http::cookie_bag cb;
    BOOST_CHECK_EQUAL(cb.has("foo"), false);
}

BOOST_AUTO_TEST_CASE(test_add)
{
    reactive::http::cookie_bag cb;
    BOOST_CHECK_EQUAL(cb.has("foo"), false);

    cb.add("foo", "bar");
    BOOST_CHECK_EQUAL(cb.has("foo"), true);

    reactive::http::cookie_t c;
    c.name = "foo1";
    c.value = "bar1";

    cb.add(c);
    BOOST_CHECK_EQUAL(cb.has("foo1"), true);
}

BOOST_AUTO_TEST_CASE(test_get)
{
    reactive::http::cookie_bag cb;
    BOOST_CHECK_EQUAL(cb.has("foo"), false);

    BOOST_CHECK_THROW(cb.get("foo"), std::runtime_error);

    cb.add("foo", "bar");
    BOOST_CHECK_EQUAL(cb.has("foo"), true);

    reactive::http::cookie_t c;
    c = cb.get("foo");

    BOOST_CHECK_EQUAL(reactive::http::cookie::to_string(c), "foo=bar");
}

BOOST_AUTO_TEST_CASE(test_del)
{
    reactive::http::cookie_bag cb;
    BOOST_CHECK_EQUAL(cb.has("foo"), false);

    cb.add("foo", "bar");
    BOOST_CHECK_EQUAL(cb.has("foo"), true);

    BOOST_CHECK_EQUAL(cb.del("foo"), true);
    BOOST_CHECK_EQUAL(cb.has("foo"), false);
}

BOOST_AUTO_TEST_SUITE_END()


text:
class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest {
 public:
  BookmarkBarViewInstantExtendedTest() {
  }

 protected:
  virtual TestingProfile* CreateProfile() OVERRIDE {
    TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
    // TemplateURLService is normally NULL during testing. Instant extended
    // needs this service so set a custom factory function.
    TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
        profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService);
    return profile;
  }

 private:
  static KeyedService* CreateTemplateURLService(
      content::BrowserContext* profile) {
    return new TemplateURLService(static_cast<Profile*>(profile));
  }

  DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest);
};

// Verify that in instant extended mode the visibility of the apps shortcut
// button properly follows the pref value.
TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) {
  ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
  profile()->CreateBookmarkModel(true);
  test::WaitForBookmarkModelToLoad(
      BookmarkModelFactory::GetForProfile(profile()));
  BookmarkBarView bookmark_bar_view(browser(), NULL);
  bookmark_bar_view.set_owned_by_client();
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kShowAppsShortcutInBookmarkBar, false);
  EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());

  // Try to make the Apps shortcut visible. Its visibility depends on whether
  // the app launcher is enabled.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kShowAppsShortcutInBookmarkBar, true);
  if (IsAppLauncherEnabled()) {
    EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
  } else {
    EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
  }

  // Make sure we can also properly transition from true to false.
  browser()->profile()->GetPrefs()->SetBoolean(
      prefs::kShowAppsShortcutInBookmarkBar, false);
  EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
}

#if !defined(OS_CHROMEOS)
typedef BrowserWithTestWindowTest BookmarkBarViewTest;

// Verifies that the apps shortcut is shown or hidden following the policy
// value. This policy (and the apps shortcut) isn't present on ChromeOS.
TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) {
  ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
  profile()->CreateBookmarkModel(true);
  test::WaitForBookmarkModelToLoad(
      BookmarkModelFactory::GetForProfile(profile()));
  BookmarkBarView bookmark_bar_view(browser(), NULL);
  bookmark_bar_view.set_owned_by_client();

  // By default, the pref is not managed and the apps shortcut is shown.
  TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService();
  EXPECT_FALSE(
      prefs->IsManagedPreference(prefs::kShowAppsShortcutInBookmarkBar));
  EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());

  // Hide the apps shortcut by policy, via the managed pref.
  prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar,
                        new base::FundamentalValue(false));
  EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());

  // And try showing it via policy too.
  prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar,
                        new base::FundamentalValue(true));
  EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
}
#endif


text:
<?php

namespace App\Http\Controllers;

use App\models\CoreActive;
use App\models\CoreAddress;
use App\Models\CoreCountry;
use App\models\CoreMarital;
use App\Models\CoreRace;
use App\Models\CoreStates;
use App\Models\CoreStatus;
use App\Models\CoreUserType;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Models\CoreUser;
use App\Models\CoreGender;
use DB;

class UserController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $users=CoreUser::all();
        return view('user/index',compact('users'));
    }

    public function create()
    {
        $dropdown=$this->prepareDropdown();

        return view('user.create')->with(compact('dropdown'));
    }

    public function store(Requests\StoreUser $request)
    {
        //dd($request);
        /*pre insert check*/

        /*execute progress*/
        DB::beginTransaction();

        $user=new CoreUser();

        $user->code= $request->code;
        $user->access_key=$request->access_key;
        $user->account=$request->account;
        $user->password=bcrypt($request->password);
        $user->c_name=$request->c_name;
        $user->e_name=$request->e_name;
        $user->gender_id=$request->gender_id;
        $user->race_id=$request->race_id;
        $user->religion=$request->religion;
        $user->handphone=$request->handphone;
        $user->country_id=$request->country_id;
        $user->birthday=$request->birthday;
        $user->birth_place=$request->birth_place;
        $user->ic_number=$request->ic_number;
        $user->money=0;
        $user->status_id=$request->status_id;
        $user->active_id=$request->active_id;
        $user->user_type_id=$request->user_type_id;
        $user->email=$request->email;
        $user->marital_id=$request->marital_id;

        if(!$user->save())
        {
            DB::rollback();
            session()->flash('error',trans('exec.create_error'));
            return redirect('user');
        }

        DB::commit();
        session()->flash('message',trans('exec.create_success'));
        return redirect('user');
    }

    public function edit($id)
    {
        //finding target user
        $user=CoreUser::findOrFail($id);

        $dropdown=$this->prepareDropdown();

        return view('user.edit')->with(compact('dropdown','user'));
    }

    public function update(Requests\UpdateUser $request,$id)
    {
        //finding the target record
        $user=CoreUser::findOrFail($id);

        DB::beginTransaction();

        $user->code= $request->code;
        $user->access_key=$request->access_key;
        $user->account=$request->account;

        if(isset($request->password) && $request->password !="")
        {
            $user->password=bcrypt($request->password);
        }

        $user->c_name=$request->c_name;
        $user->e_name=$request->e_name;
        $user->gender_id=$request->gender_id;
        $user->race_id=$request->race_id;
        $user->religion=$request->religion;
        $user->handphone=$request->handphone;
        $user->country_id=$request->country_id;
        $user->birthday=$request->birthday;
        $user->birth_place=$request->birth_place;
        $user->ic_number=$request->ic_number;
        $user->status_id=$request->status_id;
        $user->active_id=$request->active_id;
        $user->user_type_id=$request->user_type_id;
        $user->email=$request->email;
        $user->marital_id=$request->marital_id;

        if(!$user->save())
        {
            DB::rollback();
            session()->flash('error',trans('exec.update_error'));
            return redirect('user');
        }

        DB::commit();
        session()->flash('message',trans('exec.update_success'));
        return redirect('user');
    }

    public function delete($id)
    {
        $user=CoreUser::findOrFail($id);

        //pre-delete checking

        //running remove
        DB::beginTransaction();

        if(!$user->delete())
        {
            DB::rollback();
            session()->flash('error',trans('exec.delete_error'));
            return redirect('user');
        }

        DB::commit();
        session()->flash('message',trans('exec.delete_success'));
        return redirect('user');
    }

    public function view($id)
    {
        $user=CoreUser::with('country','race','marital','status','active')->findOrFail($id);

        $addresses=CoreAddress::where('user_id',$id)->with('type','state','country')->get();

        return view('user.view')->with(compact('user','addresses'));
    }

    private function prepareDropdown()
    {
        //select the dropdown array from db
        $value['genders']=CoreGender::all()->pluck('c_name','id');
        $value['nationality']=CoreCountry::all()->pluck('name','id');
        $value['races']=CoreRace::all()->pluck('c_name','id');
        $value['status']=CoreStatus::all()->pluck('c_name','id');
        $value['marital']=CoreMarital::all()->pluck('c_name','id');
        $value['user_type']=CoreUserType::all()->pluck('c_name','id');
        $value['active']=CoreActive::all()->pluck('c_name','id');

        return $value;
    }
}


text:
using namespace llvm;
using namespace llvm::object;
using namespace llvm::Win64EH;

namespace {

class COFFDumper : public ObjDumper {
public:
  COFFDumper(const llvm::object::COFFObjectFile *Obj, StreamWriter& Writer)
    : ObjDumper(Writer)
    , Obj(Obj) {
  }

  void printFileHeaders() override;
  void printSections() override;
  void printRelocations() override;
  void printSymbols() override;
  void printDynamicSymbols() override;
  void printUnwindInfo() override;
  void printCOFFImports() override;
  void printCOFFExports() override;
  void printCOFFDirectives() override;
  void printCOFFBaseReloc() override;
  void printCodeViewDebugInfo() override;
  void printStackMap() const override;
private:
  void printSymbol(const SymbolRef &Sym);
  void printRelocation(const SectionRef &Section, const RelocationRef &Reloc);
  void printDataDirectory(uint32_t Index, const std::string &FieldName);

  void printDOSHeader(const dos_header *DH);
  template <class PEHeader> void printPEHeader(const PEHeader *Hdr);
  void printBaseOfDataField(const pe32_header *Hdr);
  void printBaseOfDataField(const pe32plus_header *Hdr);

  void printCodeViewSection(const SectionRef &Section);

  void printCodeViewSymbolsSubsection(StringRef Subsection,
                                      const SectionRef &Section,
                                      uint32_t Offset);

  void cacheRelocations();

  std::error_code resolveSymbol(const coff_section *Section, uint64_t Offset,
                                SymbolRef &Sym);
  std::error_code resolveSymbolName(const coff_section *Section,
                                    uint64_t Offset, StringRef &Name);
  void printImportedSymbols(iterator_range<imported_symbol_iterator> Range);
  void printDelayImportedSymbols(
      const DelayImportDirectoryEntryRef &I,
      iterator_range<imported_symbol_iterator> Range);

  typedef DenseMap<const coff_section*, std::vector<RelocationRef> > RelocMapTy;

  const llvm::object::COFFObjectFile *Obj;
  bool RelocCached = false;
  RelocMapTy RelocMap;
  StringRef CVFileIndexToStringOffsetTable;
  StringRef CVStringTable;
};

} // namespace

namespace llvm {

std::error_code createCOFFDumper(const object::ObjectFile *Obj,
                                 StreamWriter &Writer,
                                 std::unique_ptr<ObjDumper> &Result) {
  const COFFObjectFile *COFFObj = dyn_cast<COFFObjectFile>(Obj);
  if (!COFFObj)
    return readobj_error::unsupported_obj_file_format;

  Result.reset(new COFFDumper(COFFObj, Writer));
  return readobj_error::success;
}

} // namespace llvm

// Given a a section and an offset into this section the function returns the
// symbol used for the relocation at the offset.
std::error_code COFFDumper::resolveSymbol(const coff_section *Section,
                                          uint64_t Offset, SymbolRef &Sym) {
  cacheRelocations();
  const auto &Relocations = RelocMap[Section];
  for (const auto &Relocation : Relocations) {
    uint64_t RelocationOffset = Relocation.getOffset();

    if (RelocationOffset == Offset) {
      Sym = *Relocation.getSymbol();
      return readobj_error::success;
    }
  }
  return readobj_error::unknown_symbol;
}

// Given a section and an offset into this section the function returns the name
// of the symbol used for the relocation at the offset.
std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
                                              uint64_t Offset,
                                              StringRef &Name) {
  SymbolRef Symbol;
  if (std::error_code EC = resolveSymbol(Section, Offset, Symbol))
    return EC;
  ErrorOr<StringRef> NameOrErr = Symbol.getName();
  if (std::error_code EC = NameOrErr.getError())
    return EC;
  Name = *NameOrErr;
  return std::error_code();
}

static const EnumEntry<COFF::MachineTypes> ImageFileMachineType[] = {
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_UNKNOWN  ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AM33     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AMD64    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_ARM      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_ARMNT    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_EBC      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_I386     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_IA64     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_M32R     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_MIPS16   ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_MIPSFPU  ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_MIPSFPU16),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_POWERPC  ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_POWERPCFP),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_R4000    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_SH3      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_SH3DSP   ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_SH4      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_SH5      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_THUMB    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_WCEMIPSV2)
};

static const EnumEntry<COFF::Characteristics> ImageFileCharacteristics[] = {
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_RELOCS_STRIPPED        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_EXECUTABLE_IMAGE       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_LINE_NUMS_STRIPPED     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_LOCAL_SYMS_STRIPPED    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_AGGRESSIVE_WS_TRIM     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_LARGE_ADDRESS_AWARE    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_BYTES_REVERSED_LO      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_32BIT_MACHINE          ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_DEBUG_STRIPPED         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_NET_RUN_FROM_SWAP      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_SYSTEM                 ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_DLL                    ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_UP_SYSTEM_ONLY         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_BYTES_REVERSED_HI      )
};

static const EnumEntry<COFF::WindowsSubsystem> PEWindowsSubsystem[] = {
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_UNKNOWN                ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_NATIVE                 ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_WINDOWS_GUI            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_WINDOWS_CUI            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_POSIX_CUI              ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_WINDOWS_CE_GUI         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_EFI_APPLICATION        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER     ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_EFI_ROM                ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SUBSYSTEM_XBOX                   ),
};

static const EnumEntry<COFF::DLLCharacteristics> PEDLLCharacteristics[] = {
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY      ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_NO_SEH               ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_NO_BIND              ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_APPCONTAINER         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER           ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_GUARD_CF             ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE),
};

static const EnumEntry<COFF::SectionCharacteristics>
ImageSectionCharacteristics[] = {
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NOLOAD           ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NO_PAD           ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_CNT_CODE              ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_CNT_INITIALIZED_DATA  ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_CNT_UNINITIALIZED_DATA),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_LNK_OTHER             ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_LNK_INFO              ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_LNK_REMOVE            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_LNK_COMDAT            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_GPREL                 ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_PURGEABLE         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_16BIT             ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_LOCKED            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_PRELOAD           ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_1BYTES          ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_2BYTES          ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_4BYTES          ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_8BYTES          ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_16BYTES         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_32BYTES         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_64BYTES         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_128BYTES        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_256BYTES        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_512BYTES        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_1024BYTES       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_2048BYTES       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_4096BYTES       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_8192BYTES       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_LNK_NRELOC_OVFL       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_DISCARDABLE       ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_NOT_CACHED        ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_NOT_PAGED         ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_SHARED            ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_EXECUTE           ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_READ              ),
  LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_SCN_MEM_WRITE             )
};

static const EnumEntry<COFF::SymbolBaseType> ImageSymType[] = {
  { "Null"  , COFF::IMAGE_SYM_TYPE_NULL   },
  { "Void"  , COFF::IMAGE_SYM_TYPE_VOID   },
  { "Char"  , COFF::IMAGE_SYM_TYPE_CHAR   },
  { "Short" , COFF::IMAGE_SYM_TYPE_SHORT  },
  { "Int"   , COFF::IMAGE_SYM_TYPE_INT    },
  { "Long"  , COFF::IMAGE_SYM_TYPE_LONG   },
  { "Float" , COFF::IMAGE_SYM_TYPE_FLOAT  },
  { "Double", COFF::IMAGE_SYM_TYPE_DOUBLE },
  { "Struct", COFF::IMAGE_SYM_TYPE_STRUCT },
  { "Union" , COFF::IMAGE_SYM_TYPE_UNION  },
  { "Enum"  , COFF::IMAGE_SYM_TYPE_ENUM   },
  { "MOE"   , COFF::IMAGE_SYM_TYPE_MOE    },
  { "Byte"  , COFF::IMAGE_SYM_TYPE_BYTE   },
  { "Word"  , COFF::IMAGE_SYM_TYPE_WORD   },
  { "UInt"  , COFF::IMAGE_SYM_TYPE_UINT   },
  { "DWord" , COFF::IMAGE_SYM_TYPE_DWORD  }
};

static const EnumEntry<COFF::SymbolComplexType> ImageSymDType[] = {
  { "Null"    , COFF::IMAGE_SYM_DTYPE_NULL     },
  { "Pointer" , COFF::IMAGE_SYM_DTYPE_POINTER  },
  { "Function", COFF::IMAGE_SYM_DTYPE_FUNCTION },
  { "Array"   , COFF::IMAGE_SYM_DTYPE_ARRAY    }
};

static const EnumEntry<COFF::SymbolStorageClass> ImageSymClass[] = {
  { "EndOfFunction"  , COFF::IMAGE_SYM_CLASS_END_OF_FUNCTION  },
  { "Null"           , COFF::IMAGE_SYM_CLASS_NULL             },
  { "Automatic"      , COFF::IMAGE_SYM_CLASS_AUTOMATIC        },
  { "External"       , COFF::IMAGE_SYM_CLASS_EXTERNAL         },
  { "Static"         , COFF::IMAGE_SYM_CLASS_STATIC           },
  { "Register"       , COFF::IMAGE_SYM_CLASS_REGISTER         },
  { "ExternalDef"    , COFF::IMAGE_SYM_CLASS_EXTERNAL_DEF     },
  { "Label"          , COFF::IMAGE_SYM_CLASS_LABEL            },
  { "UndefinedLabel" , COFF::IMAGE_SYM_CLASS_UNDEFINED_LABEL  },
  { "MemberOfStruct" , COFF::IMAGE_SYM_CLASS_MEMBER_OF_STRUCT },
  { "Argument"       , COFF::IMAGE_SYM_CLASS_ARGUMENT         },
  { "StructTag"      , COFF::IMAGE_SYM_CLASS_STRUCT_TAG       },
  { "MemberOfUnion"  , COFF::IMAGE_SYM_CLASS_MEMBER_OF_UNION  },
  { "UnionTag"       , COFF::IMAGE_SYM_CLASS_UNION_TAG        },
  { "TypeDefinition" , COFF::IMAGE_SYM_CLASS_TYPE_DEFINITION  },
  { "UndefinedStatic", COFF::IMAGE_SYM_CLASS_UNDEFINED_STATIC },
  { "EnumTag"        , COFF::IMAGE_SYM_CLASS_ENUM_TAG         },
  { "MemberOfEnum"   , COFF::IMAGE_SYM_CLASS_MEMBER_OF_ENUM   },
  { "RegisterParam"  , COFF::IMAGE_SYM_CLASS_REGISTER_PARAM   },
  { "BitField"       , COFF::IMAGE_SYM_CLASS_BIT_FIELD        },
  { "Block"          , COFF::IMAGE_SYM_CLASS_BLOCK            },
  { "Function"       , COFF::IMAGE_SYM_CLASS_FUNCTION         },
  { "EndOfStruct"    , COFF::IMAGE_SYM_CLASS_END_OF_STRUCT    },
  { "File"           , COFF::IMAGE_SYM_CLASS_FILE             },
  { "Section"        , COFF::IMAGE_SYM_CLASS_SECTION          },
  { "WeakExternal"   , COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL    },
  { "CLRToken"       , COFF::IMAGE_SYM_CLASS_CLR_TOKEN        }
};

static const EnumEntry<COFF::COMDATType> ImageCOMDATSelect[] = {
  { "NoDuplicates", COFF::IMAGE_COMDAT_SELECT_NODUPLICATES },
  { "Any"         , COFF::IMAGE_COMDAT_SELECT_ANY          },
  { "SameSize"    , COFF::IMAGE_COMDAT_SELECT_SAME_SIZE    },
  { "ExactMatch"  , COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH  },
  { "Associative" , COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE  },
  { "Largest"     , COFF::IMAGE_COMDAT_SELECT_LARGEST      },
  { "Newest"      , COFF::IMAGE_COMDAT_SELECT_NEWEST       }
};

static const EnumEntry<COFF::WeakExternalCharacteristics>
WeakExternalCharacteristics[] = {
  { "NoLibrary", COFF::IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY },
  { "Library"  , COFF::IMAGE_WEAK_EXTERN_SEARCH_LIBRARY   },
  { "Alias"    , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS     }
};

template <typename T>
static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
                                        COFFSymbolRef Symbol,
                                        uint8_t AuxSymbolIdx, const T *&Aux) {
  ArrayRef<uint8_t> AuxData = Obj->getSymbolAuxData(Symbol);
  AuxData = AuxData.slice(AuxSymbolIdx * Obj->getSymbolTableEntrySize());
  Aux = reinterpret_cast<const T*>(AuxData.data());
  return readobj_error::success;
}

void COFFDumper::cacheRelocations() {
  if (RelocCached)
    return;
  RelocCached = true;

  for (const SectionRef &S : Obj->sections()) {
    const coff_section *Section = Obj->getCOFFSection(S);

    for (const RelocationRef &Reloc : S.relocations())
      RelocMap[Section].push_back(Reloc);

    // Sort relocations by address.
    std::sort(RelocMap[Section].begin(), RelocMap[Section].end(),
              relocAddressLess);
  }
}

void COFFDumper::printDataDirectory(uint32_t Index, const std::string &FieldName) {
  const data_directory *Data;
  if (Obj->getDataDirectory(Index, Data))
    return;
  W.printHex(FieldName + "RVA", Data->RelativeVirtualAddress);
  W.printHex(FieldName + "Size", Data->Size);
}

void COFFDumper::printFileHeaders() {
  time_t TDS = Obj->getTimeDateStamp();
  char FormattedTime[20] = { };
  strftime(FormattedTime, 20, "%Y-%m-%d %H:%M:%S", gmtime(&TDS));

  {
    DictScope D(W, "ImageFileHeader");
    W.printEnum  ("Machine", Obj->getMachine(),
                    makeArrayRef(ImageFileMachineType));
    W.printNumber("SectionCount", Obj->getNumberOfSections());
    W.printHex   ("TimeDateStamp", FormattedTime, Obj->getTimeDateStamp());
    W.printHex   ("PointerToSymbolTable", Obj->getPointerToSymbolTable());
    W.printNumber("SymbolCount", Obj->getNumberOfSymbols());
    W.printNumber("OptionalHeaderSize", Obj->getSizeOfOptionalHeader());
    W.printFlags ("Characteristics", Obj->getCharacteristics(),
                    makeArrayRef(ImageFileCharacteristics));
  }

  // Print PE header. This header does not exist if this is an object file and
  // not an executable.
  const pe32_header *PEHeader = nullptr;
  error(Obj->getPE32Header(PEHeader));
  if (PEHeader)
    printPEHeader<pe32_header>(PEHeader);

  const pe32plus_header *PEPlusHeader = nullptr;
  error(Obj->getPE32PlusHeader(PEPlusHeader));
  if (PEPlusHeader)
    printPEHeader<pe32plus_header>(PEPlusHeader);

  if (const dos_header *DH = Obj->getDOSHeader())
    printDOSHeader(DH);
}

void COFFDumper::printDOSHeader(const dos_header *DH) {
  DictScope D(W, "DOSHeader");
  W.printString("Magic", StringRef(DH->Magic, sizeof(DH->Magic)));
  W.printNumber("UsedBytesInTheLastPage", DH->UsedBytesInTheLastPage);
  W.printNumber("FileSizeInPages", DH->FileSizeInPages);
  W.printNumber("NumberOfRelocationItems", DH->NumberOfRelocationItems);
  W.printNumber("HeaderSizeInParagraphs", DH->HeaderSizeInParagraphs);
  W.printNumber("MinimumExtraParagraphs", DH->MinimumExtraParagraphs);
  W.printNumber("MaximumExtraParagraphs", DH->MaximumExtraParagraphs);
  W.printNumber("InitialRelativeSS", DH->InitialRelativeSS);
  W.printNumber("InitialSP", DH->InitialSP);
  W.printNumber("Checksum", DH->Checksum);
  W.printNumber("InitialIP", DH->InitialIP);
  W.printNumber("InitialRelativeCS", DH->InitialRelativeCS);
  W.printNumber("AddressOfRelocationTable", DH->AddressOfRelocationTable);
  W.printNumber("OverlayNumber", DH->OverlayNumber);
  W.printNumber("OEMid", DH->OEMid);
  W.printNumber("OEMinfo", DH->OEMinfo);
  W.printNumber("AddressOfNewExeHeader", DH->AddressOfNewExeHeader);
}

template <class PEHeader>
void COFFDumper::printPEHeader(const PEHeader *Hdr) {
  DictScope D(W, "ImageOptionalHeader");
  W.printNumber("MajorLinkerVersion", Hdr->MajorLinkerVersion);
  W.printNumber("MinorLinkerVersion", Hdr->MinorLinkerVersion);
  W.printNumber("SizeOfCode", Hdr->SizeOfCode);
  W.printNumber("SizeOfInitializedData", Hdr->SizeOfInitializedData);
  W.printNumber("SizeOfUninitializedData", Hdr->SizeOfUninitializedData);
  W.printHex   ("AddressOfEntryPoint", Hdr->AddressOfEntryPoint);
  W.printHex   ("BaseOfCode", Hdr->BaseOfCode);
  printBaseOfDataField(Hdr);
  W.printHex   ("ImageBase", Hdr->ImageBase);
  W.printNumber("SectionAlignment", Hdr->SectionAlignment);
  W.printNumber("FileAlignment", Hdr->FileAlignment);
  W.printNumber("MajorOperatingSystemVersion",
                Hdr->MajorOperatingSystemVersion);
  W.printNumber("MinorOperatingSystemVersion",
                Hdr->MinorOperatingSystemVersion);
  W.printNumber("MajorImageVersion", Hdr->MajorImageVersion);
  W.printNumber("MinorImageVersion", Hdr->MinorImageVersion);
  W.printNumber("MajorSubsystemVersion", Hdr->MajorSubsystemVersion);
  W.printNumber("MinorSubsystemVersion", Hdr->MinorSubsystemVersion);
  W.printNumber("SizeOfImage", Hdr->SizeOfImage);
  W.printNumber("SizeOfHeaders", Hdr->SizeOfHeaders);
  W.printEnum  ("Subsystem", Hdr->Subsystem, makeArrayRef(PEWindowsSubsystem));
  W.printFlags ("Characteristics", Hdr->DLLCharacteristics,
                makeArrayRef(PEDLLCharacteristics));
  W.printNumber("SizeOfStackReserve", Hdr->SizeOfStackReserve);
  W.printNumber("SizeOfStackCommit", Hdr->SizeOfStackCommit);
  W.printNumber("SizeOfHeapReserve", Hdr->SizeOfHeapReserve);
  W.printNumber("SizeOfHeapCommit", Hdr->SizeOfHeapCommit);
  W.printNumber("NumberOfRvaAndSize", Hdr->NumberOfRvaAndSize);

  if (Hdr->NumberOfRvaAndSize > 0) {
    DictScope D(W, "DataDirectory");
    static const char * const directory[] = {
      "ExportTable", "ImportTable", "ResourceTable", "ExceptionTable",
      "CertificateTable", "BaseRelocationTable", "Debug", "Architecture",
      "GlobalPtr", "TLSTable", "LoadConfigTable", "BoundImport", "IAT",
      "DelayImportDescriptor", "CLRRuntimeHeader", "Reserved"
    };

    for (uint32_t i = 0; i < Hdr->NumberOfRvaAndSize; ++i) {
      printDataDirectory(i, directory[i]);
    }
  }
}

void COFFDumper::printBaseOfDataField(const pe32_header *Hdr) {
  W.printHex("BaseOfData", Hdr->BaseOfData);
}

void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}

void COFFDumper::printCodeViewDebugInfo() {
  for (const SectionRef &S : Obj->sections()) {
    StringRef SecName;
    error(S.getName(SecName));
    if (SecName == ".debug$S")
      printCodeViewSection(S);
  }
}

void COFFDumper::printCodeViewSection(const SectionRef &Section) {
  StringRef Data;
  error(Section.getContents(Data));

  SmallVector<StringRef, 10> FunctionNames;
  StringMap<StringRef> FunctionLineTables;

  ListScope D(W, "CodeViewDebugInfo");
  {
    // FIXME: Add more offset correctness checks.
    DataExtractor DE(Data, true, 4);
    uint32_t Offset = 0,
             Magic = DE.getU32(&Offset);
    W.printHex("Magic", Magic);
    if (Magic != COFF::DEBUG_SECTION_MAGIC) {
      error(object_error::parse_failed);
      return;
    }

    bool Finished = false;
    while (DE.isValidOffset(Offset) && !Finished) {
      // The section consists of a number of subsection in the following format:
      // |Type|PayloadSize|Payload...|
      uint32_t SubSectionType = DE.getU32(&Offset),
               PayloadSize = DE.getU32(&Offset);
      ListScope S(W, "Subsection");
      W.printHex("Type", SubSectionType);
      W.printHex("PayloadSize", PayloadSize);
      if (PayloadSize > Data.size() - Offset) {
        error(object_error::parse_failed);
        return;
      }

      StringRef Contents = Data.substr(Offset, PayloadSize);
      if (opts::CodeViewSubsectionBytes) {
        // Print the raw contents to simplify debugging if anything goes wrong
        // afterwards.
        W.printBinaryBlock("Contents", Contents);
      }

      switch (SubSectionType) {
      case COFF::DEBUG_SYMBOL_SUBSECTION:
        printCodeViewSymbolsSubsection(Contents, Section, Offset);
        break;
      case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
        // Holds a PC to file:line table.  Some data to parse this subsection is
        // stored in the other subsections, so just check sanity and store the
        // pointers for deferred processing.

        if (PayloadSize < 12) {
          // There should be at least three words to store two function
          // relocations and size of the code.
          error(object_error::parse_failed);
          return;
        }

        StringRef LinkageName;
        error(resolveSymbolName(Obj->getCOFFSection(Section), Offset,
                                LinkageName));
        W.printString("LinkageName", LinkageName);
        if (FunctionLineTables.count(LinkageName) != 0) {
          // Saw debug info for this function already?
          error(object_error::parse_failed);
          return;
        }

        FunctionLineTables[LinkageName] = Contents;
        FunctionNames.push_back(LinkageName);
        break;
      }
      case COFF::DEBUG_STRING_TABLE_SUBSECTION:
        if (PayloadSize == 0 || CVStringTable.data() != nullptr ||
            Contents.back() != '\0') {
          // Empty or duplicate or non-null-terminated subsection.
          error(object_error::parse_failed);
          return;
        }
        CVStringTable = Contents;
        break;
      case COFF::DEBUG_INDEX_SUBSECTION:
        // Holds the translation table from file indices
        // to offsets in the string table.

        if (PayloadSize == 0 ||
            CVFileIndexToStringOffsetTable.data() != nullptr) {
          // Empty or duplicate subsection.
          error(object_error::parse_failed);
          return;
        }
        CVFileIndexToStringOffsetTable = Contents;
        break;
      }
      Offset += PayloadSize;

      // Align the reading pointer by 4.
      Offset += (-Offset) % 4;
    }
  }

  // Dump the line tables now that we've read all the subsections and know all
  // the required information.
  for (unsigned I = 0, E = FunctionNames.size(); I != E; ++I) {
    StringRef Name = FunctionNames[I];
    ListScope S(W, "FunctionLineTable");
    W.printString("LinkageName", Name);

    DataExtractor DE(FunctionLineTables[Name], true, 4);
    uint32_t Offset = 6;  // Skip relocations.
    uint16_t Flags = DE.getU16(&Offset);
    W.printHex("Flags", Flags);
    bool HasColumnInformation =
        Flags & COFF::DEBUG_LINE_TABLES_HAVE_COLUMN_RECORDS;
    uint32_t FunctionSize = DE.getU32(&Offset);
    W.printHex("CodeSize", FunctionSize);
    while (DE.isValidOffset(Offset)) {
      // For each range of lines with the same filename, we have a segment
      // in the line table.  The filename string is accessed using double
      // indirection to the string table subsection using the index subsection.
      uint32_t OffsetInIndex = DE.getU32(&Offset),
               NumLines = DE.getU32(&Offset),
               FullSegmentSize = DE.getU32(&Offset);

      uint32_t ColumnOffset = Offset + 8 * NumLines;
      DataExtractor ColumnDE(DE.getData(), true, 4);

      if (FullSegmentSize !=
          12 + 8 * NumLines + (HasColumnInformation ? 4 * NumLines : 0)) {
        error(object_error::parse_failed);
        return;
      }

      uint32_t FilenameOffset;
      {
        DataExtractor SDE(CVFileIndexToStringOffsetTable, true, 4);
        uint32_t OffsetInSDE = OffsetInIndex;
        if (!SDE.isValidOffset(OffsetInSDE)) {
          error(object_error::parse_failed);
          return;
        }
        FilenameOffset = SDE.getU32(&OffsetInSDE);
      }

      if (FilenameOffset == 0 || FilenameOffset + 1 >= CVStringTable.size() ||
          CVStringTable.data()[FilenameOffset - 1] != '\0') {
        // Each string in an F3 subsection should be preceded by a null
        // character.
        error(object_error::parse_failed);
        return;
      }

      StringRef Filename(CVStringTable.data() + FilenameOffset);
      ListScope S(W, "FilenameSegment");
      W.printString("Filename", Filename);
      for (unsigned LineIdx = 0;
           LineIdx != NumLines && DE.isValidOffset(Offset); ++LineIdx) {
        // Then go the (PC, LineNumber) pairs.  The line number is stored in the
        // least significant 31 bits of the respective word in the table.
        uint32_t PC = DE.getU32(&Offset), LineData = DE.getU32(&Offset);
        if (PC >= FunctionSize) {
          error(object_error::parse_failed);
          return;
        }
        char Buffer[32];
        format("+0x%X", PC).snprint(Buffer, 32);
        ListScope PCScope(W, Buffer);
        uint32_t LineNumberStart = LineData & COFF::CVL_MaxLineNumber;
        uint32_t LineNumberEndDelta =
            (LineData >> COFF::CVL_LineNumberStartBits) &
            COFF::CVL_LineNumberEndDeltaMask;
        bool IsStatement = LineData & COFF::CVL_IsStatement;
        W.printNumber("LineNumberStart", LineNumberStart);
        W.printNumber("LineNumberEndDelta", LineNumberEndDelta);
        W.printBoolean("IsStatement", IsStatement);
        if (HasColumnInformation &&
            ColumnDE.isValidOffsetForDataOfSize(ColumnOffset, 4)) {
          uint16_t ColStart = ColumnDE.getU16(&ColumnOffset);
          W.printNumber("ColStart", ColStart);
          uint16_t ColEnd = ColumnDE.getU16(&ColumnOffset);
          W.printNumber("ColEnd", ColEnd);
        }
      }
      // Skip over the column data.
      if (HasColumnInformation) {
        for (unsigned LineIdx = 0;
             LineIdx != NumLines && DE.isValidOffset(Offset); ++LineIdx) {
          DE.getU32(&Offset);
        }
      }
    }
  }
}

void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
                                                const SectionRef &Section,
                                                uint32_t OffsetInSection) {
  if (Subsection.size() == 0) {
    error(object_error::parse_failed);
    return;
  }
  DataExtractor DE(Subsection, true, 4);
  uint32_t Offset = 0;

  // Function-level subsections have "procedure start" and "procedure end"
  // commands that should come in pairs and surround relevant info.
  bool InFunctionScope = false;
  while (DE.isValidOffset(Offset)) {
    // Read subsection segments one by one.
    uint16_t Size = DE.getU16(&Offset);
    // The section size includes the size of the type identifier.
    if (Size < 2 || !DE.isValidOffsetForDataOfSize(Offset, Size)) {
      error(object_error::parse_failed);
      return;
    }
    Size -= 2;
    uint16_t Type = DE.getU16(&Offset);
    switch (Type) {
    case COFF::DEBUG_SYMBOL_TYPE_PROC_START: {
      DictScope S(W, "ProcStart");
      if (InFunctionScope || Size < 36) {
        error(object_error::parse_failed);
        return;
      }
      InFunctionScope = true;

      // We're currently interested in a limited subset of fields in this
      // segment, just ignore the rest of the fields for now.
      uint8_t Unused[12];
      DE.getU8(&Offset, Unused, 12);
      uint32_t CodeSize = DE.getU32(&Offset);
      DE.getU8(&Offset, Unused, 12);
      StringRef SectionName;
      error(resolveSymbolName(Obj->getCOFFSection(Section),
                              OffsetInSection + Offset, SectionName));
      Offset += 4;
      DE.getU8(&Offset, Unused, 3);
      StringRef DisplayName = DE.getCStr(&Offset);
      if (!DE.isValidOffset(Offset)) {
        error(object_error::parse_failed);
        return;
      }
      W.printString("DisplayName", DisplayName);
      W.printString("Section", SectionName);
      W.printHex("CodeSize", CodeSize);

      break;
    }
    case COFF::DEBUG_SYMBOL_TYPE_PROC_END: {
      W.startLine() << "ProcEnd\n";
      if (!InFunctionScope || Size > 0) {
        error(object_error::parse_failed);
        return;
      }
      InFunctionScope = false;
      break;
    }
    default: {
      if (opts::CodeViewSubsectionBytes) {
        ListScope S(W, "Record");
        W.printHex("Size", Size);
        W.printHex("Type", Type);

        StringRef Contents = DE.getData().substr(Offset, Size);
        W.printBinaryBlock("Contents", Contents);
      }

      Offset += Size;
      break;
    }
    }
  }

  if (InFunctionScope)
    error(object_error::parse_failed);
}

void COFFDumper::printSections() {
  ListScope SectionsD(W, "Sections");
  int SectionNumber = 0;
  for (const SectionRef &Sec : Obj->sections()) {
    ++SectionNumber;
    const coff_section *Section = Obj->getCOFFSection(Sec);

    StringRef Name;
    error(Sec.getName(Name));

    DictScope D(W, "Section");
    W.printNumber("Number", SectionNumber);
    W.printBinary("Name", Name, Section->Name);
    W.printHex   ("VirtualSize", Section->VirtualSize);
    W.printHex   ("VirtualAddress", Section->VirtualAddress);
    W.printNumber("RawDataSize", Section->SizeOfRawData);
    W.printHex   ("PointerToRawData", Section->PointerToRawData);
    W.printHex   ("PointerToRelocations", Section->PointerToRelocations);
    W.printHex   ("PointerToLineNumbers", Section->PointerToLinenumbers);
    W.printNumber("RelocationCount", Section->NumberOfRelocations);
    W.printNumber("LineNumberCount", Section->NumberOfLinenumbers);
    W.printFlags ("Characteristics", Section->Characteristics,
                    makeArrayRef(ImageSectionCharacteristics),
                    COFF::SectionCharacteristics(0x00F00000));

    if (opts::SectionRelocations) {
      ListScope D(W, "Relocations");
      for (const RelocationRef &Reloc : Sec.relocations())
        printRelocation(Sec, Reloc);
    }

    if (opts::SectionSymbols) {
      ListScope D(W, "Symbols");
      for (const SymbolRef &Symbol : Obj->symbols()) {
        if (!Sec.containsSymbol(Symbol))
          continue;

        printSymbol(Symbol);
      }
    }

    if (opts::SectionData &&
        !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
      StringRef Data;
      error(Sec.getContents(Data));

      W.printBinaryBlock("SectionData", Data);
    }
  }
}

void COFFDumper::printRelocations() {
  ListScope D(W, "Relocations");

  int SectionNumber = 0;
  for (const SectionRef &Section : Obj->sections()) {
    ++SectionNumber;
    StringRef Name;
    error(Section.getName(Name));

    bool PrintedGroup = false;
    for (const RelocationRef &Reloc : Section.relocations()) {
      if (!PrintedGroup) {
        W.startLine() << "Section (" << SectionNumber << ") " << Name << " {\n";
        W.indent();
        PrintedGroup = true;
      }

      printRelocation(Section, Reloc);
    }

    if (PrintedGroup) {
      W.unindent();
      W.startLine() << "}\n";
    }
  }
}

void COFFDumper::printRelocation(const SectionRef &Section,
                                 const RelocationRef &Reloc) {
  uint64_t Offset = Reloc.getOffset();
  uint64_t RelocType = Reloc.getType();
  SmallString<32> RelocName;
  StringRef SymbolName;
  Reloc.getTypeName(RelocName);
  symbol_iterator Symbol = Reloc.getSymbol();
  if (Symbol != Obj->symbol_end()) {
    ErrorOr<StringRef> SymbolNameOrErr = Symbol->getName();
    error(SymbolNameOrErr.getError());
    SymbolName = *SymbolNameOrErr;
  }

  if (opts::ExpandRelocs) {
    DictScope Group(W, "Relocation");
    W.printHex("Offset", Offset);
    W.printNumber("Type", RelocName, RelocType);
    W.printString("Symbol", SymbolName.empty() ? "-" : SymbolName);
  } else {
    raw_ostream& OS = W.startLine();
    OS << W.hex(Offset)
       << " " << RelocName
       << " " << (SymbolName.empty() ? "-" : SymbolName)
       << "\n";
  }
}

void COFFDumper::printSymbols() {
  ListScope Group(W, "Symbols");

  for (const SymbolRef &Symbol : Obj->symbols())
    printSymbol(Symbol);
}

void COFFDumper::printDynamicSymbols() { ListScope Group(W, "DynamicSymbols"); }

static ErrorOr<StringRef>
getSectionName(const llvm::object::COFFObjectFile *Obj, int32_t SectionNumber,
               const coff_section *Section) {
  if (Section) {
    StringRef SectionName;
    if (std::error_code EC = Obj->getSectionName(Section, SectionName))
      return EC;
    return SectionName;
  }
  if (SectionNumber == llvm::COFF::IMAGE_SYM_DEBUG)
    return StringRef("IMAGE_SYM_DEBUG");
  if (SectionNumber == llvm::COFF::IMAGE_SYM_ABSOLUTE)
    return StringRef("IMAGE_SYM_ABSOLUTE");
  if (SectionNumber == llvm::COFF::IMAGE_SYM_UNDEFINED)
    return StringRef("IMAGE_SYM_UNDEFINED");
  return StringRef("");
}

void COFFDumper::printSymbol(const SymbolRef &Sym) {
  DictScope D(W, "Symbol");

  COFFSymbolRef Symbol = Obj->getCOFFSymbol(Sym);
  const coff_section *Section;
  if (std::error_code EC = Obj->getSection(Symbol.getSectionNumber(), Section)) {
    W.startLine() << "Invalid section number: " << EC.message() << "\n";
    W.flush();
    return;
  }

  StringRef SymbolName;
  if (Obj->getSymbolName(Symbol, SymbolName))
    SymbolName = "";

  StringRef SectionName = "";
  ErrorOr<StringRef> Res =
      getSectionName(Obj, Symbol.getSectionNumber(), Section);
  if (Res)
    SectionName = *Res;

  W.printString("Name", SymbolName);
  W.printNumber("Value", Symbol.getValue());
  W.printNumber("Section", SectionName, Symbol.getSectionNumber());
  W.printEnum  ("BaseType", Symbol.getBaseType(), makeArrayRef(ImageSymType));
  W.printEnum  ("ComplexType", Symbol.getComplexType(),
                                                   makeArrayRef(ImageSymDType));
  W.printEnum  ("StorageClass", Symbol.getStorageClass(),
                                                   makeArrayRef(ImageSymClass));
  W.printNumber("AuxSymbolCount", Symbol.getNumberOfAuxSymbols());

  for (uint8_t I = 0; I < Symbol.getNumberOfAuxSymbols(); ++I) {
    if (Symbol.isFunctionDefinition()) {
      const coff_aux_function_definition *Aux;
      error(getSymbolAuxData(Obj, Symbol, I, Aux));

      DictScope AS(W, "AuxFunctionDef");
      W.printNumber("TagIndex", Aux->TagIndex);
      W.printNumber("TotalSize", Aux->TotalSize);
      W.printHex("PointerToLineNumber", Aux->PointerToLinenumber);
      W.printHex("PointerToNextFunction", Aux->PointerToNextFunction);

    } else if (Symbol.isAnyUndefined()) {
      const coff_aux_weak_external *Aux;
      error(getSymbolAuxData(Obj, Symbol, I, Aux));

      ErrorOr<COFFSymbolRef> Linked = Obj->getSymbol(Aux->TagIndex);
      StringRef LinkedName;
      std::error_code EC = Linked.getError();
      if (EC || (EC = Obj->getSymbolName(*Linked, LinkedName))) {
        LinkedName = "";
        error(EC);
      }

      DictScope AS(W, "AuxWeakExternal");
      W.printNumber("Linked", LinkedName, Aux->TagIndex);
      W.printEnum  ("Search", Aux->Characteristics,
                    makeArrayRef(WeakExternalCharacteristics));

    } else if (Symbol.isFileRecord()) {
      const char *FileName;
      error(getSymbolAuxData(Obj, Symbol, I, FileName));

      DictScope AS(W, "AuxFileRecord");

      StringRef Name(FileName, Symbol.getNumberOfAuxSymbols() *
                                   Obj->getSymbolTableEntrySize());
      W.printString("FileName", Name.rtrim(StringRef("\0", 1)));
      break;
    } else if (Symbol.isSectionDefinition()) {
      const coff_aux_section_definition *Aux;
      error(getSymbolAuxData(Obj, Symbol, I, Aux));

      int32_t AuxNumber = Aux->getNumber(Symbol.isBigObj());

      DictScope AS(W, "AuxSectionDef");
      W.printNumber("Length", Aux->Length);
      W.printNumber("RelocationCount", Aux->NumberOfRelocations);
      W.printNumber("LineNumberCount", Aux->NumberOfLinenumbers);
      W.printHex("Checksum", Aux->CheckSum);
      W.printNumber("Number", AuxNumber);
      W.printEnum("Selection", Aux->Selection, makeArrayRef(ImageCOMDATSelect));

      if (Section && Section->Characteristics & COFF::IMAGE_SCN_LNK_COMDAT
          && Aux->Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
        const coff_section *Assoc;
        StringRef AssocName = "";
        std::error_code EC = Obj->getSection(AuxNumber, Assoc);
        ErrorOr<StringRef> Res = getSectionName(Obj, AuxNumber, Assoc);
        if (Res)
          AssocName = *Res;
        if (!EC)
          EC = Res.getError();
        if (EC) {
          AssocName = "";
          error(EC);
        }

        W.printNumber("AssocSection", AssocName, AuxNumber);
      }
    } else if (Symbol.isCLRToken()) {
      const coff_aux_clr_token *Aux;
      error(getSymbolAuxData(Obj, Symbol, I, Aux));

      ErrorOr<COFFSymbolRef> ReferredSym =
          Obj->getSymbol(Aux->SymbolTableIndex);
      StringRef ReferredName;
      std::error_code EC = ReferredSym.getError();
      if (EC || (EC = Obj->getSymbolName(*ReferredSym, ReferredName))) {
        ReferredName = "";
        error(EC);
      }

      DictScope AS(W, "AuxCLRToken");
      W.printNumber("AuxType", Aux->AuxType);
      W.printNumber("Reserved", Aux->Reserved);
      W.printNumber("SymbolTableIndex", ReferredName, Aux->SymbolTableIndex);

    } else {
      W.startLine() << "<unhandled auxiliary record>\n";
    }
  }
}

void COFFDumper::printUnwindInfo() {
  ListScope D(W, "UnwindInformation");
  switch (Obj->getMachine()) {
  case COFF::IMAGE_FILE_MACHINE_AMD64: {
    Win64EH::Dumper Dumper(W);
    Win64EH::Dumper::SymbolResolver
    Resolver = [](const object::coff_section *Section, uint64_t Offset,
                  SymbolRef &Symbol, void *user_data) -> std::error_code {
      COFFDumper *Dumper = reinterpret_cast<COFFDumper *>(user_data);
      return Dumper->resolveSymbol(Section, Offset, Symbol);
    };
    Win64EH::Dumper::Context Ctx(*Obj, Resolver, this);
    Dumper.printData(Ctx);
    break;
  }
  case COFF::IMAGE_FILE_MACHINE_ARMNT: {
    ARM::WinEH::Decoder Decoder(W);
    Decoder.dumpProcedureData(*Obj);
    break;
  }
  default:
    W.printEnum("unsupported Image Machine", Obj->getMachine(),
                makeArrayRef(ImageFileMachineType));
    break;
  }
}

void COFFDumper::printImportedSymbols(
    iterator_range<imported_symbol_iterator> Range) {
  for (const ImportedSymbolRef &I : Range) {
    StringRef Sym;
    error(I.getSymbolName(Sym));
    uint16_t Ordinal;
    error(I.getOrdinal(Ordinal));
    W.printNumber("Symbol", Sym, Ordinal);
  }
}

void COFFDumper::printDelayImportedSymbols(
    const DelayImportDirectoryEntryRef &I,
    iterator_range<imported_symbol_iterator> Range) {
  int Index = 0;
  for (const ImportedSymbolRef &S : Range) {
    DictScope Import(W, "Import");
    StringRef Sym;
    error(S.getSymbolName(Sym));
    uint16_t Ordinal;
    error(S.getOrdinal(Ordinal));
    W.printNumber("Symbol", Sym, Ordinal);
    uint64_t Addr;
    error(I.getImportAddress(Index++, Addr));
    W.printHex("Address", Addr);
  }
}

void COFFDumper::printCOFFImports() {
  // Regular imports
  for (const ImportDirectoryEntryRef &I : Obj->import_directories()) {
    DictScope Import(W, "Import");
    StringRef Name;
    error(I.getName(Name));
    W.printString("Name", Name);
    uint32_t Addr;
    error(I.getImportLookupTableRVA(Addr));
    W.printHex("ImportLookupTableRVA", Addr);
    error(I.getImportAddressTableRVA(Addr));
    W.printHex("ImportAddressTableRVA", Addr);
    printImportedSymbols(I.imported_symbols());
  }

  // Delay imports
  for (const DelayImportDirectoryEntryRef &I : Obj->delay_import_directories()) {
    DictScope Import(W, "DelayImport");
    StringRef Name;
    error(I.getName(Name));
    W.printString("Name", Name);
    const delay_import_directory_table_entry *Table;
    error(I.getDelayImportTable(Table));
    W.printHex("Attributes", Table->Attributes);
    W.printHex("ModuleHandle", Table->ModuleHandle);
    W.printHex("ImportAddressTable", Table->DelayImportAddressTable);
    W.printHex("ImportNameTable", Table->DelayImportNameTable);
    W.printHex("BoundDelayImportTable", Table->BoundDelayImportTable);
    W.printHex("UnloadDelayImportTable", Table->UnloadDelayImportTable);
    printDelayImportedSymbols(I, I.imported_symbols());
  }
}

void COFFDumper::printCOFFExports() {
  for (const ExportDirectoryEntryRef &E : Obj->export_directories()) {
    DictScope Export(W, "Export");

    StringRef Name;
    uint32_t Ordinal, RVA;

    error(E.getSymbolName(Name));
    error(E.getOrdinal(Ordinal));
    error(E.getExportRVA(RVA));

    W.printNumber("Ordinal", Ordinal);
    W.printString("Name", Name);
    W.printHex("RVA", RVA);
  }
}

void COFFDumper::printCOFFDirectives() {
  for (const SectionRef &Section : Obj->sections()) {
    StringRef Contents;
    StringRef Name;

    error(Section.getName(Name));
    if (Name != ".drectve")
      continue;

    error(Section.getContents(Contents));

    W.printString("Directive(s)", Contents);
  }
}

static StringRef getBaseRelocTypeName(uint8_t Type) {
  switch (Type) {
  case COFF::IMAGE_REL_BASED_ABSOLUTE: return "ABSOLUTE";
  case COFF::IMAGE_REL_BASED_HIGH: return "HIGH";
  case COFF::IMAGE_REL_BASED_LOW: return "LOW";
  case COFF::IMAGE_REL_BASED_HIGHLOW: return "HIGHLOW";
  case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
  case COFF::IMAGE_REL_BASED_ARM_MOV32T: return "ARM_MOV32(T)";
  case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
  default: return "unknown (" + llvm::utostr(Type) + ")";
  }
}

void COFFDumper::printCOFFBaseReloc() {
  ListScope D(W, "BaseReloc");
  for (const BaseRelocRef &I : Obj->base_relocs()) {
    uint8_t Type;
    uint32_t RVA;
    error(I.getRVA(RVA));
    error(I.getType(Type));
    DictScope Import(W, "Entry");
    W.printString("Type", getBaseRelocTypeName(Type));
    W.printHex("Address", RVA);
  }
}

void COFFDumper::printStackMap() const {
  object::SectionRef StackMapSection;
  for (auto Sec : Obj->sections()) {
    StringRef Name;
    Sec.getName(Name);
    if (Name == ".llvm_stackmaps") {
      StackMapSection = Sec;
      break;
    }
  }

  if (StackMapSection == object::SectionRef())
    return;

  StringRef StackMapContents;
  StackMapSection.getContents(StackMapContents);
  ArrayRef<uint8_t> StackMapContentsArray(
      reinterpret_cast<const uint8_t*>(StackMapContents.data()),
      StackMapContents.size());

  if (Obj->isLittleEndian())
    prettyPrintStackMap(
                      llvm::outs(),
                      StackMapV1Parser<support::little>(StackMapContentsArray));
  else
    prettyPrintStackMap(llvm::outs(),
                        StackMapV1Parser<support::big>(StackMapContentsArray));
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

 -->

<!--  These resources are around just to allow their values to be customized
     for different hardware and product builds.  -->

<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <string-array name="wfcOperatorErrorAlertMessages">
    <item msgid="1972026366984640493">"Para facer chamadas e enviar mensaxes a través da wifi, primeiro pídelle ao teu operador que configure este servizo. A continuación, activa de novo as chamadas por wifi en Configuración."</item>
  </string-array>
  <string-array name="wfcOperatorErrorNotificationMessages">
    <item msgid="1383416528714661108">"Rexístrate co teu operador"</item>
  </string-array>
    <string name="wfcSpnFormat" msgid="7770475174975527040">"Chamadas por wifi de %s"</string>
</resources>


text:
import { events } from '../constants'
import * as Messages from '../messages'

/**
 * Handler responsible for dispatching mapped
 * bolt listeners whenever there's a trigger beign
 * called by one of the users
 */
export const triggerHandler = ({ dispatch, options }) => action => {
  const { trigger } = action[options.propName]

  // Checks whether the object returned contains an
  // array of listeners to call
  if (!Array.isArray(trigger) || trigger.length <= 0) {
    throw Messages.errors.triggerObjectMalformed
  }

  trigger.map(listenerObj => {
    const { listener, args } = listenerObj
    // If there's no listener, throws an error
    if (!listener) {
      throw Messages.errors.triggerObjectMalformed
    }

    if (options.listeners.hasOwnProperty(listener)) {
      dispatch(options.listeners[listener](...args))
    }
  })
}

export default {
  event: events.trigger,
  handler: triggerHandler
}


text:
package in.twizmwaz.cardinal.event;

import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class PlayerVisibilityChangeEvent extends Event {

    private static final HandlerList handlers = new HandlerList();
    private Player player;

    public PlayerVisibilityChangeEvent(Player player) {
        this.player = player;
    }

    public static HandlerList getHandlerList() {
        return handlers;
    }

    @Override
    public HandlerList getHandlers() {
        return handlers;
    }

    public Player getPlayer() {
        return player;
    }
}


text:
require 'gitcafe_maid/user'
require 'gitcafe_maid/configuration'
require 'gitcafe_maid/web'
require 'gitcafe_maid/version'
require 'gitcafe_maid/webhook'

module GitcafeMaid
end


text:
module Travis
  module Api
    module Serialize
      module V0
        module Notification
          class Repository
            attr_reader :repository

            def initialize(repository, options = {})
              @repository = repository
            end

            def data
              {
                'repository' => repository_data
              }
            end

            def repository_data
              {
                'id' => repository.id,
                'slug' => repository.slug
              }
            end
          end
        end
      end
    end
  end
end


text:
class Jena < Formula
  desc "Framework for building semantic web and linked data apps"
  homepage "https://jena.apache.org/"
  url "https://www.apache.org/dyn/closer.lua?path=jena/binaries/apache-jena-4.1.0.tar.gz"
  mirror "https://archive.apache.org/dist/jena/binaries/apache-jena-4.1.0.tar.gz"
  sha256 "ff423a57823a7c948cda6b41ec131fc64472bc1337aa8683733ca053a4420488"
  license "Apache-2.0"

  bottle do
    sha256 cellar: :any_skip_relocation, all: "b1a07fdf2b0c57f9dcf6eaddc97e2dd1bbb3086e7d79ea101673089fa03d7b0c"
  end

  depends_on "openjdk"

  def install
    env = {
      JAVA_HOME: Formula["openjdk"].opt_prefix,
      JENA_HOME: libexec,
    }

    rm_rf "bat" # Remove Windows scripts

    libexec.install Dir["*"]
    Pathname.glob("#{libexec}/bin/*") do |file|
      next if file.directory?

      basename = file.basename
      next if basename.to_s == "service"

      (bin/basename).write_env_script file, env
    end
  end

  test do
    system "#{bin}/sparql", "--version"
  end
end


text:
layout: data_model
title: StatementType
this_version: 1.0.1
---

  Heads up! These docs are for STIX 1.0.1, which is not the latest version (1.2). View the latest!

StatementTypeSTIX Common Schema

				StatementType allows the expression of a statement with an associated value, description, source, confidence, and timestamp.

      <form id="nav-version">
        <select>

            <option value="1.2" >STIX 1.2</option>

            <option value="1.1.1" >STIX 1.1.1</option>

            <option value="1.1" >STIX 1.1</option>

            <option value="1.0.1" selected="selected">STIX 1.0.1</option>

            <option value="1.0" >STIX 1.0</option>

        </select>
      </form>

Fields

      Field Name
      Type
      Description

      @timestampoptional

          dateTime

Specifies the time this statement was asserted.

      Value0..1

          ControlledVocabularyStringType

						Specifies a value characterizing the statement within some vocabulary.

						This field is implemented through the xsi:type controlled vocabulary extension mechanism. The default vocabulary may be provided by the field using this construct. If that's the case, the schema annotations on that element will describe which vocabulary to use. If not, the default vocabulary is HighMediumLowVocab-1.0 in the http://stix.mitre.org/default_vocabularies-1 namespace. This type is defined in the stix_default_vocabularies.xsd file or at the URL http://stix.mitre.org/XMLSchema/default_vocabularies/1.0.1/stix_default_vocabularies.xsd .

						Users may also define their own vocabulary using the type extension mechanism, specify a vocabulary name and reference using the attributes, or simply use this as a string field.

      Description0..1

          StructuredTextType

Specifies a prose description of the statement.

      Source0..1

          ControlledVocabularyStringType

						The Source field captures the source of this statement. An optional vocabulary name and reference allows the expression of the source name in some given vocabulary context.

						This field is implemented through the xsi:type controlled vocabulary extension mechanism. No default vocabulary type has been defined for STIX 1.0. Users may either define their own vocabulary using the type extension mechanism, specify a vocabulary name and reference using the attributes, or simply use this as a free string field.

      Confidence0..1

          ConfidenceType

The Confidence field characterizes the level of confidence held in the statement.


text:
<!DOCTYPE html>

  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />

<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">

  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">

  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">

  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">

  <meta name="keywords" content="Hexo, NexT" />

<meta name="description" content="Android web">
<meta property="og:type" content="article">
<meta property="og:title" content="d">
<meta property="og:url" content="https://hkllzh.github.io/2018/05/21/d/index.html">
<meta property="og:site_name" content="HKLLZH-BLOG">
<meta property="og:description" content="Android web">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-05-21T08:57:54.286Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="d">
<meta name="twitter:description" content="Android web">

  <link rel="canonical" href="https://hkllzh.github.io/2018/05/21/d/"/>

  <title>d | HKLLZH-BLOG</title>

        HKLLZH-BLOG

日常开发随笔

    <button>

    </button>

            首页

            归档

    <link itemprop="mainEntityOfPage" href="https://hkllzh.github.io/2018/05/21/d/">

      <meta itemprop="name" content="lizheng">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">

      <meta itemprop="name" content="HKLLZH-BLOG">

d

                发表于

              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-05-21T16:57:38+08:00">
                2018-05-21
              </time>

                 Hello World

                npm_param

lizheng

Android web

                  3
                  日志

© 2018

  lizheng

由 Hexo 强力驱动

  |

主题 — NexT.Muse v5.1.4


text:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item >
        <shape android:shape="rectangle">
            <solid android:color="#00b4b4b4"/>
        </shape>
    </item>
</selector>


text:
'use strict';

// Load modules

const Code = require('@hapi/code');
const _Lab = require('../../test_runner');

// Declare internals

const internals = {};

// Test shortcuts

const lab = exports.lab = _Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;

describe('Test CLI', () => {

    it('adds two numbers together', () => {

        expect(1 + 1).to.equal(2);
    });

    it('subtracts two numbers', () => {

        expect(2 - 2).to.equal(0);
    });
});


text:
// GENERATED FILE. To update, edit tftypes.pl instead.

package org.tensorflow.types;

import org.tensorflow.DataType;

/** Represents a 64-bit double precision floating point number. */
public class TFDouble implements TFType {
  private TFDouble() {}
  static {
    Types.typeCodes.put(TFDouble.class, DataType.DOUBLE);
  }
  static {
    Types.scalars.put(TFDouble.class, 0.0);
  }
}


text:
import { curryN, nAry } from 'ramda'

const weakMemoizeWith = curryN(2, (mFn, fn) => {
  const cache = new WeakMap()
  return nAry(fn.length, (...args) => {
    const key = mFn(...args)
    if (!cache.has(key)) {
      const result = fn(...args)
      cache.set(key, result)
      return result
    }
    return cache.get(key)
  })
})

export default weakMemoizeWith


text:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

//global $modInvisList;
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('MOD', $mod_strings);
$sugar_smarty->assign('APP', $app_strings);

//nsingh bug: 21669. Messes up localization
/*foreach($modInvisList as $modinvisname){
    if(empty($app_list_strings['moduleList'][$modinvisname])){
	   $app_list_strings['moduleList'][$modinvisname] = $modinvisname;
    }
}*/
$sugar_smarty->assign('APP_LIST', $app_list_strings);
/*foreach($modInvisList as $modinvisname){
	unset($app_list_strings['moduleList'][$modinvisname]);
}*/
$role = new ACLRole();
$role->retrieve($_REQUEST['record']);
$categories = ACLRole::getRoleActions($_REQUEST['record']);
$names = ACLAction::setupCategoriesMatrix($categories);

$categories2 = array();
$categories2=$categories;
$hidden_categories = array(
"KBDocuments", "Campaigns","Forecasts","ForecastSchedule",
"Emails","EmailTemplates","EmailMarketing","Reports");
foreach($hidden_categories as $v){
	if (isset($categories2[$v])) {
	   unset($categories2[$v]);
	}
}
if(!empty($names))$tdwidth = 100 / sizeof($names);
$sugar_smarty->assign('ROLE', $role->toArray());
//xye customization begin
$sugar_smarty->assign("CHECKED", $role->enablesoftphone?"checked":"");
//xye customization end
$sugar_smarty->assign('CATEGORIES', $categories);
$sugar_smarty->assign('CATEGORIES2', $categories2);
$sugar_smarty->assign('TDWIDTH', $tdwidth);
$sugar_smarty->assign('ACTION_NAMES', $names);

$return= array('module'=>'ACLRoles', 'action'=>'DetailView', 'record'=>$role->id);
$sugar_smarty->assign('RETURN', $return);
$params = array();
$params[] = "{$mod_strings['LBL_MODULE_NAME']}";
$params[] = $role->get_summary_text();
echo getClassicModuleTitle("ACLRoles", $params, true);
//$sugar_smarty->assign('TITLE', $title);
$hide_hide_supanels = true;

//xye customization begin
echo $sugar_smarty->fetch('custom/modules/ACLRoles/DetailView.tpl');
//xye customization end
//for subpanels the variable must be named focus;
$focus =& $role;
$_REQUEST['module'] = 'ACLRoles';
require_once('include/SubPanel/SubPanelTiles.php');

$subpanel = new SubPanelTiles($role, 'ACLRoles');

echo $subpanel->display();

?>


text:
function File(client, data) {
  this.client = client;
  this.data = data;
}

File.prototype.toString = function() {
  return '<File id="' + this.data.id + '" name="' + this.data.name + '">';
};

File.prototype.update = function(file, options, callback) {
  this.client.file.update(this.data.id, file, options, callback);
};

module.exports = File;


text:
<?php

namespace RK\HelperModule\Entity\Base;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Zikula\Core\Doctrine\EntityAccess;
use RK\HelperModule\Traits\StandardFieldsTrait;
use RK\HelperModule\Validator\Constraints as HelperAssert;

/**
 * Entity class that defines the entity structure and behaviours.
 *
 * This is the base entity class for image entities.
 * The following annotation marks it as a mapped superclass so subclasses
 * inherit orm properties.
 *
 * @ORM\MappedSuperclass
 */
abstract class AbstractImageEntity extends EntityAccess
{
    /**
     * Hook standard fields behaviour embedding createdBy, updatedBy, createdDate, updatedDate fields.
     */
    use StandardFieldsTrait;

    /**
     * @var string The tablename this object maps to
     */
    protected $_objectType = 'image';

    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer", unique=true)
     * @Assert\Type(type="integer")
     * @Assert\NotNull()
     * @Assert\LessThan(value=1000000000)
     * @var integer $id
     */
    protected $id = 0;

    /**
     * the current workflow state
     * @ORM\Column(length=20)
     * @Assert\NotBlank()
     * @HelperAssert\ListEntry(entityName="image", propertyName="workflowState", multiple=false)
     * @var string $workflowState
     */
    protected $workflowState = 'initial';

    /**
     * @ORM\Column(length=255)
     * @Assert\NotBlank()
     * @Assert\Length(min="0", max="255")
     * @var string $imageTitle
     */
    protected $imageTitle = '';

    /**
     * My image meta data array.
     *
     * @ORM\Column(type="array")
     * @Assert\Type(type="array")
     * @var array $myImageMeta
     */
    protected $myImageMeta = [];

    /**
     * @ORM\Column(length=255)
     * @Assert\NotBlank()
     * @Assert\Length(min="0", max="255")
     * @Assert\File(
     *    mimeTypes = {"image/*"}
     * )
     * @Assert\Image(
     * )
     * @var string $myImage
     */
    protected $myImage = null;

    /**
     * Full my image path as url.
     *
     * @Assert\Type(type="string")
     * @var string $myImageUrl
     */
    protected $myImageUrl = '';

    /**
     * please note if the image do have a specific reason
     * @ORM\Column(type="text", length=20000)
     * @Assert\NotNull()
     * @Assert\Length(min="0", max="20000")
     * @var text $myDescription
     */
    protected $myDescription = '';

    /**
     * @ORM\Column(length=255)
     * @Assert\NotNull()
     * @Assert\Length(min="0", max="255")
     * @var string $copyright
     */
    protected $copyright = '';

    /**
     * ImageEntity constructor.
     *
     * Will not be called by Doctrine and can therefore be used
     * for own implementation purposes. It is also possible to add
     * arbitrary arguments as with every other class method.
     */
    public function __construct()
    {
    }

    /**
     * Returns the _object type.
     *
     * @return string
     */
    public function get_objectType()
    {
        return $this->_objectType;
    }

    /**
     * Sets the _object type.
     *
     * @param string $_objectType
     *
     * @return void
     */
    public function set_objectType($_objectType)
    {
        if ($this->_objectType != $_objectType) {
            $this->_objectType = $_objectType;
        }
    }

    /**
     * Returns the id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Sets the id.
     *
     * @param integer $id
     *
     * @return void
     */
    public function setId($id)
    {
        if (intval($this->id) !== intval($id)) {
            $this->id = intval($id);
        }
    }

    /**
     * Returns the workflow state.
     *
     * @return string
     */
    public function getWorkflowState()
    {
        return $this->workflowState;
    }

    /**
     * Sets the workflow state.
     *
     * @param string $workflowState
     *
     * @return void
     */
    public function setWorkflowState($workflowState)
    {
        if ($this->workflowState !== $workflowState) {
            $this->workflowState = isset($workflowState) ? $workflowState : '';
        }
    }

    /**
     * Returns the image title.
     *
     * @return string
     */
    public function getImageTitle()
    {
        return $this->imageTitle;
    }

    /**
     * Sets the image title.
     *
     * @param string $imageTitle
     *
     * @return void
     */
    public function setImageTitle($imageTitle)
    {
        if ($this->imageTitle !== $imageTitle) {
            $this->imageTitle = isset($imageTitle) ? $imageTitle : '';
        }
    }

    /**
     * Returns the my image.
     *
     * @return string
     */
    public function getMyImage()
    {
        return $this->myImage;
    }

    /**
     * Sets the my image.
     *
     * @param string $myImage
     *
     * @return void
     */
    public function setMyImage($myImage)
    {
        if ($this->myImage !== $myImage) {
            $this->myImage = isset($myImage) ? $myImage : '';
        }
    }

    /**
     * Returns the my image url.
     *
     * @return string
     */
    public function getMyImageUrl()
    {
        return $this->myImageUrl;
    }

    /**
     * Sets the my image url.
     *
     * @param string $myImageUrl
     *
     * @return void
     */
    public function setMyImageUrl($myImageUrl)
    {
        if ($this->myImageUrl !== $myImageUrl) {
            $this->myImageUrl = isset($myImageUrl) ? $myImageUrl : '';
        }
    }

    /**
     * Returns the my image meta.
     *
     * @return array
     */
    public function getMyImageMeta()
    {
        return $this->myImageMeta;
    }

    /**
     * Sets the my image meta.
     *
     * @param array $myImageMeta
     *
     * @return void
     */
    public function setMyImageMeta($myImageMeta = [])
    {
        if ($this->myImageMeta !== $myImageMeta) {
            $this->myImageMeta = isset($myImageMeta) ? $myImageMeta : '';
        }
    }

    /**
     * Returns the my description.
     *
     * @return text
     */
    public function getMyDescription()
    {
        return $this->myDescription;
    }

    /**
     * Sets the my description.
     *
     * @param text $myDescription
     *
     * @return void
     */
    public function setMyDescription($myDescription)
    {
        if ($this->myDescription !== $myDescription) {
            $this->myDescription = isset($myDescription) ? $myDescription : '';
        }
    }

    /**
     * Returns the copyright.
     *
     * @return string
     */
    public function getCopyright()
    {
        return $this->copyright;
    }

    /**
     * Sets the copyright.
     *
     * @param string $copyright
     *
     * @return void
     */
    public function setCopyright($copyright)
    {
        if ($this->copyright !== $copyright) {
            $this->copyright = isset($copyright) ? $copyright : '';
        }
    }

    /**
     * Creates url arguments array for easy creation of display urls.
     *
     * @return array The resulting arguments list
     */
    public function createUrlArgs()
    {
        return [
            'id' => $this->getId()
        ];
    }

    /**
     * Returns the primary key.
     *
     * @return integer The identifier
     */
    public function getKey()
    {
        return $this->getId();
    }

    /**
     * Determines whether this entity supports hook subscribers or not.
     *
     * @return boolean
     */
    public function supportsHookSubscribers()
    {
        return true;
    }

    /**
     * Return lower case name of multiple items needed for hook areas.
     *
     * @return string
     */
    public function getHookAreaPrefix()
    {
        return 'rkhelpermodule.ui_hooks.images';
    }

    /**
     * Returns an array of all related objects that need to be persisted after clone.
     *
     * @param array $objects The objects are added to this array. Default: []
     *
     * @return array of entity objects
     */
    public function getRelatedObjectsToPersist(&$objects = [])
    {
        return [];
    }

    /**
     * ToString interceptor implementation.
     * This method is useful for debugging purposes.
     *
     * @return string The output string for this entity
     */
    public function __toString()
    {
        return 'Image ' . $this->getKey() . ': ' . $this->getImageTitle();
    }

    /**
     * Clone interceptor implementation.
     * This method is for example called by the reuse functionality.
     * Performs a quite simple shallow copy.
     *
     * See also:
     * (1) http://docs.doctrine-project.org/en/latest/cookbook/implementing-wakeup-or-clone.html
     * (2) http://www.php.net/manual/en/language.oop5.cloning.php
     * (3) http://stackoverflow.com/questions/185934/how-do-i-create-a-copy-of-an-object-in-php
     */
    public function __clone()
    {
        // if the entity has no identity do nothing, do NOT throw an exception
        if (!$this->id) {
            return;
        }

        // otherwise proceed

        // unset identifier
        $this->setId(0);

        // reset workflow
        $this->setWorkflowState('initial');

        // reset upload fields
        $this->setMyImage(null);
        $this->setMyImageMeta([]);
        $this->setMyImageUrl('');

        $this->setCreatedBy(null);
        $this->setCreatedDate(null);
        $this->setUpdatedBy(null);
        $this->setUpdatedDate(null);

    }
}