package com.rnviewpagerdemo;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

{'repo_name': 'zbtang/React-Native-ViewPager', 'stars': '908', 'repo_language': 'JavaScript', 'file_name': 'index.ios.js', 'mime_type': 'text/x-java', 'hash': 5747732817970442341, 'source_dataset': 'data'}


/*
Copyright 2019 The Predictive Horizontal Pod Autoscaler Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package linear_test

import (
	"errors"
	"testing"
	"time"

	"github.com/google/go-cmp/cmp"
	"github.com/jthomperoo/predictive-horizontal-pod-autoscaler/config"
	"github.com/jthomperoo/predictive-horizontal-pod-autoscaler/prediction/linear"
	"github.com/jthomperoo/predictive-horizontal-pod-autoscaler/stored"
)

func TestPredict_GetPrediction(t *testing.T) {
	equateErrorMessage := cmp.Comparer(func(x, y error) bool {
		if x == nil || y == nil {
			return x == nil && y == nil
		}
		return x.Error() == y.Error()
	})

	var tests = []struct {
		description string
		expected    int32
		expectedErr error
		model       *config.Model
		evaluations []*stored.Evaluation
	}{
		{
			"Fail no Linear configuration",
			0,
			errors.New("No Linear configuration provided for model"),
			&config.Model{},
			[]*stored.Evaluation{},
		},
		{
			"Successful prediction",
			5,
			nil,
			&config.Model{
				Type: linear.Type,
				Linear: &config.Linear{
					StoredValues: 5,
					LookAhead:    0,
				},
			},
			[]*stored.Evaluation{
				&stored.Evaluation{
					Created: time.Now().UTC().Add(time.Duration(-40) * time.Second),
					Evaluation: stored.DBEvaluation{
						TargetReplicas: 1,
					},
				},
				&stored.Evaluation{
					Created: time.Now().UTC().Add(time.Duration(-30) * time.Second),
					Evaluation: stored.DBEvaluation{
						TargetReplicas: 2,
					},
				},
				&stored.Evaluation{
					Created: time.Now().UTC().Add(time.Duration(-20) * time.Second),
					Evaluation: stored.DBEvaluation{
						TargetReplicas: 3,
					},
				},
				&stored.Evaluation{
					Created: time.Now().UTC().Add(time.Duration(-10) * time.Second),
					Evaluation: stored.DBEvaluation{
						TargetReplicas: 4,
					},
				},
			},
		},
	}
	for _, test := range tests {
		t.Run(test.description, func(t *testing.T) {
			predicter := &linear.Predict{}
			result, err := predicter.GetPrediction(test.model, test.evaluations)
			if !cmp.Equal(&err, &test.expectedErr, equateErrorMessage) {
				t.Errorf("error mismatch (-want +got):\n%s", cmp.Diff(test.expectedErr, err, equateErrorMessage))
				return
			}
			if !cmp.Equal(test.expected, result) {
				t.Errorf("result mismatch (-want +got):\n%s", cmp.Diff(test.expected, result))
			}
		})
	}
}

func TestModelPredict_GetIDsToRemove(t *testing.T) {
	equateErrorMessage := cmp.Comparer(func(x, y error) bool {
		if x == nil || y == nil {
			return x == nil && y == nil
		}
		return x.Error() == y.Error()
	})

	var tests = []struct {
		description string
		expected    []int
		expectedErr error
		model       *config.Model
		evaluations []*stored.Evaluation
	}{
		{
			"Fail no Linear configuration",
			nil,
			errors.New("No Linear configuration provided for model"),
			&config.Model{},
			[]*stored.Evaluation{},
		},
		{
			"3 IDs too many, mark 3 for removal",
			[]int{5, 3, 8},
			nil,
			&config.Model{
				Linear: &config.Linear{
					StoredValues: 3,
				},
			},
			[]*stored.Evaluation{
				&stored.Evaluation{
					ID:      1,
					Created: time.Time{}.Add(time.Duration(4) * time.Second),
				},
				&stored.Evaluation{
					ID:      2,
					Created: time.Time{}.Add(time.Duration(5) * time.Second),
				},
				// START OLDEST
				&stored.Evaluation{
					ID:      5,
					Created: time.Time{}.Add(time.Duration(1) * time.Second),
				},
				&stored.Evaluation{
					ID:      3,
					Created: time.Time{}.Add(time.Duration(2) * time.Second),
				},
				&stored.Evaluation{
					ID:      8,
					Created: time.Time{}.Add(time.Duration(3) * time.Second),
				},
				// END OLDEST
				&stored.Evaluation{
					ID:      4,
					Created: time.Time{}.Add(time.Duration(6) * time.Second),
				},
			},
		},
	}
	for _, test := range tests {
		t.Run(test.description, func(t *testing.T) {
			predicter := &linear.Predict{}
			result, err := predicter.GetIDsToRemove(test.model, test.evaluations)
			if !cmp.Equal(&err, &test.expectedErr, equateErrorMessage) {
				t.Errorf("error mismatch (-want +got):\n%s", cmp.Diff(test.expectedErr, err, equateErrorMessage))
				return
			}
			if !cmp.Equal(test.expected, result) {
				t.Errorf("remove IDs mismatch (-want +got):\n%s", cmp.Diff(test.expected, result))
			}
		})
	}
}

func TestPredict_GetType(t *testing.T) {
	var tests = []struct {
		description string
		expected    string
	}{
		{
			"Successful get type",
			"Linear",
		},
	}
	for _, test := range tests {
		t.Run(test.description, func(t *testing.T) {
			predicter := &linear.Predict{}
			result := predicter.GetType()
			if !cmp.Equal(test.expected, result) {
				t.Errorf("type mismatch (-want +got):\n%s", cmp.Diff(test.expected, result))
			}
		})
	}
}

{'repo_name': 'jthomperoo/predictive-horizontal-pod-autoscaler', 'stars': '104', 'repo_language': 'Go', 'file_name': 'main.go', 'mime_type': 'text/x-c', 'hash': 2845616117481589887, 'source_dataset': 'data'}


/*
 *  hdac_i915.c - routines for sync between HD-A core and i915 display driver
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the Free
 *  Software Foundation; either version 2 of the License, or (at your option)
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 *  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 *  for more details.
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/component.h>
#include <drm/i915_component.h>
#include <sound/core.h>
#include <sound/hdaudio.h>
#include <sound/hda_i915.h>
#include <sound/hda_register.h>

static struct i915_audio_component *hdac_acomp;

/**
 * snd_hdac_set_codec_wakeup - Enable / disable HDMI/DP codec wakeup
 * @bus: HDA core bus
 * @enable: enable or disable the wakeup
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function should be called during the chip reset, also called at
 * resume for updating STATESTS register read.
 *
 * Returns zero for success or a negative error code.
 */
int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable)
{
	struct i915_audio_component *acomp = bus->audio_component;

	if (!acomp || !acomp->ops)
		return -ENODEV;

	if (!acomp->ops->codec_wake_override) {
		dev_warn(bus->dev,
			"Invalid codec wake callback\n");
		return 0;
	}

	dev_dbg(bus->dev, "%s codec wakeup\n",
		enable ? "enable" : "disable");

	acomp->ops->codec_wake_override(acomp->dev, enable);

	return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_set_codec_wakeup);

/**
 * snd_hdac_display_power - Power up / down the power refcount
 * @bus: HDA core bus
 * @enable: power up or down
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function manages a refcount and calls the i915 get_power() and
 * put_power() ops accordingly, toggling the codec wakeup, too.
 *
 * Returns zero for success or a negative error code.
 */
int snd_hdac_display_power(struct hdac_bus *bus, bool enable)
{
	struct i915_audio_component *acomp = bus->audio_component;

	if (!acomp || !acomp->ops)
		return -ENODEV;

	dev_dbg(bus->dev, "display power %s\n",
		enable ? "enable" : "disable");

	if (enable) {
		if (!bus->i915_power_refcount++) {
			acomp->ops->get_power(acomp->dev);
			snd_hdac_set_codec_wakeup(bus, true);
			snd_hdac_set_codec_wakeup(bus, false);
		}
	} else {
		WARN_ON(!bus->i915_power_refcount);
		if (!--bus->i915_power_refcount)
			acomp->ops->put_power(acomp->dev);
	}

	return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_display_power);

#define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \
				((pci)->device == 0x0c0c) || \
				((pci)->device == 0x0d0c) || \
				((pci)->device == 0x160c))

/**
 * snd_hdac_i915_set_bclk - Reprogram BCLK for HSW/BDW
 * @bus: HDA core bus
 *
 * Intel HSW/BDW display HDA controller is in GPU. Both its power and link BCLK
 * depends on GPU. Two Extended Mode registers EM4 (M value) and EM5 (N Value)
 * are used to convert CDClk (Core Display Clock) to 24MHz BCLK:
 * BCLK = CDCLK * M / N
 * The values will be lost when the display power well is disabled and need to
 * be restored to avoid abnormal playback speed.
 *
 * Call this function at initializing and changing power well, as well as
 * at ELD notifier for the hotplug.
 */
void snd_hdac_i915_set_bclk(struct hdac_bus *bus)
{
	struct i915_audio_component *acomp = bus->audio_component;
	struct pci_dev *pci = to_pci_dev(bus->dev);
	int cdclk_freq;
	unsigned int bclk_m, bclk_n;

	if (!acomp || !acomp->ops || !acomp->ops->get_cdclk_freq)
		return; /* only for i915 binding */
	if (!CONTROLLER_IN_GPU(pci))
		return; /* only HSW/BDW */

	cdclk_freq = acomp->ops->get_cdclk_freq(acomp->dev);
	switch (cdclk_freq) {
	case 337500:
		bclk_m = 16;
		bclk_n = 225;
		break;

	case 450000:
	default: /* default CDCLK 450MHz */
		bclk_m = 4;
		bclk_n = 75;
		break;

	case 540000:
		bclk_m = 4;
		bclk_n = 90;
		break;

	case 675000:
		bclk_m = 8;
		bclk_n = 225;
		break;
	}

	snd_hdac_chip_writew(bus, HSW_EM4, bclk_m);
	snd_hdac_chip_writew(bus, HSW_EM5, bclk_n);
}
EXPORT_SYMBOL_GPL(snd_hdac_i915_set_bclk);

/* There is a fixed mapping between audio pin node and display port.
 * on SNB, IVY, HSW, BSW, SKL, BXT, KBL:
 * Pin Widget 5 - PORT B (port = 1 in i915 driver)
 * Pin Widget 6 - PORT C (port = 2 in i915 driver)
 * Pin Widget 7 - PORT D (port = 3 in i915 driver)
 *
 * on VLV, ILK:
 * Pin Widget 4 - PORT B (port = 1 in i915 driver)
 * Pin Widget 5 - PORT C (port = 2 in i915 driver)
 * Pin Widget 6 - PORT D (port = 3 in i915 driver)
 */
static int pin2port(struct hdac_device *codec, hda_nid_t pin_nid)
{
	int base_nid;

	switch (codec->vendor_id) {
	case 0x80860054: /* ILK */
	case 0x80862804: /* ILK */
	case 0x80862882: /* VLV */
		base_nid = 3;
		break;
	default:
		base_nid = 4;
		break;
	}

	if (WARN_ON(pin_nid <= base_nid || pin_nid > base_nid + 3))
		return -1;
	return pin_nid - base_nid;
}

/**
 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate
 * @codec: HDA codec
 * @nid: the pin widget NID
 * @dev_id: device identifier
 * @rate: the sample rate to set
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function sets N/CTS value based on the given sample rate.
 * Returns zero for success, or a negative error code.
 */
int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid,
			     int dev_id, int rate)
{
	struct hdac_bus *bus = codec->bus;
	struct i915_audio_component *acomp = bus->audio_component;
	int port, pipe;

	if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)
		return -ENODEV;
	port = pin2port(codec, nid);
	if (port < 0)
		return -EINVAL;
	pipe = dev_id;
	return acomp->ops->sync_audio_rate(acomp->dev, port, pipe, rate);
}
EXPORT_SYMBOL_GPL(snd_hdac_sync_audio_rate);

/**
 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component
 * @codec: HDA codec
 * @nid: the pin widget NID
 * @dev_id: device identifier
 * @audio_enabled: the pointer to store the current audio state
 * @buffer: the buffer pointer to store ELD bytes
 * @max_bytes: the max bytes to be stored on @buffer
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function queries the current state of the audio on the given
 * digital port and fetches the ELD bytes onto the given buffer.
 * It returns the number of bytes for the total ELD data, zero for
 * invalid ELD, or a negative error code.
 *
 * The return size is the total bytes required for the whole ELD bytes,
 * thus it may be over @max_bytes.  If it's over @max_bytes, it implies
 * that only a part of ELD bytes have been fetched.
 */
int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid, int dev_id,
			   bool *audio_enabled, char *buffer, int max_bytes)
{
	struct hdac_bus *bus = codec->bus;
	struct i915_audio_component *acomp = bus->audio_component;
	int port, pipe;

	if (!acomp || !acomp->ops || !acomp->ops->get_eld)
		return -ENODEV;

	port = pin2port(codec, nid);
	if (port < 0)
		return -EINVAL;

	pipe = dev_id;
	return acomp->ops->get_eld(acomp->dev, port, pipe, audio_enabled,
				   buffer, max_bytes);
}
EXPORT_SYMBOL_GPL(snd_hdac_acomp_get_eld);

static int hdac_component_master_bind(struct device *dev)
{
	struct i915_audio_component *acomp = hdac_acomp;
	int ret;

	ret = component_bind_all(dev, acomp);
	if (ret < 0)
		return ret;

	if (WARN_ON(!(acomp->dev && acomp->ops && acomp->ops->get_power &&
		      acomp->ops->put_power && acomp->ops->get_cdclk_freq))) {
		ret = -EINVAL;
		goto out_unbind;
	}

	/*
	 * Atm, we don't support dynamic unbinding initiated by the child
	 * component, so pin its containing module until we unbind.
	 */
	if (!try_module_get(acomp->ops->owner)) {
		ret = -ENODEV;
		goto out_unbind;
	}

	return 0;

out_unbind:
	component_unbind_all(dev, acomp);

	return ret;
}

static void hdac_component_master_unbind(struct device *dev)
{
	struct i915_audio_component *acomp = hdac_acomp;

	module_put(acomp->ops->owner);
	component_unbind_all(dev, acomp);
	WARN_ON(acomp->ops || acomp->dev);
}

static const struct component_master_ops hdac_component_master_ops = {
	.bind = hdac_component_master_bind,
	.unbind = hdac_component_master_unbind,
};

static int hdac_component_master_match(struct device *dev, void *data)
{
	/* i915 is the only supported component */
	return !strcmp(dev->driver->name, "i915");
}

/**
 * snd_hdac_i915_register_notifier - Register i915 audio component ops
 * @aops: i915 audio component ops
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function sets the given ops to be called by the i915 graphics driver.
 *
 * Returns zero for success or a negative error code.
 */
int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops *aops)
{
	if (!hdac_acomp)
		return -ENODEV;

	hdac_acomp->audio_ops = aops;
	return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier);

/* check whether intel graphics is present */
static bool i915_gfx_present(void)
{
	static const struct pci_device_id ids[] = {
		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
		  .class = PCI_BASE_CLASS_DISPLAY << 16,
		  .class_mask = 0xff << 16 },
		{}
	};
	return pci_dev_present(ids);
}

/**
 * snd_hdac_i915_init - Initialize i915 audio component
 * @bus: HDA core bus
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function initializes and sets up the audio component to communicate
 * with i915 graphics driver.
 *
 * Returns zero for success or a negative error code.
 */
int snd_hdac_i915_init(struct hdac_bus *bus)
{
	struct component_match *match = NULL;
	struct device *dev = bus->dev;
	struct i915_audio_component *acomp;
	int ret;

	if (WARN_ON(hdac_acomp))
		return -EBUSY;

	if (!i915_gfx_present())
		return -ENODEV;

	acomp = kzalloc(sizeof(*acomp), GFP_KERNEL);
	if (!acomp)
		return -ENOMEM;
	bus->audio_component = acomp;
	hdac_acomp = acomp;

	component_match_add(dev, &match, hdac_component_master_match, bus);
	ret = component_master_add_with_match(dev, &hdac_component_master_ops,
					      match);
	if (ret < 0)
		goto out_err;

	/*
	 * Atm, we don't support deferring the component binding, so make sure
	 * i915 is loaded and that the binding successfully completes.
	 */
	request_module("i915");

	if (!acomp->ops) {
		ret = -ENODEV;
		goto out_master_del;
	}
	dev_dbg(dev, "bound to i915 component master\n");

	return 0;
out_master_del:
	component_master_del(dev, &hdac_component_master_ops);
out_err:
	kfree(acomp);
	bus->audio_component = NULL;
	hdac_acomp = NULL;
	dev_info(dev, "failed to add i915 component master (%d)\n", ret);

	return ret;
}
EXPORT_SYMBOL_GPL(snd_hdac_i915_init);

/**
 * snd_hdac_i915_exit - Finalize i915 audio component
 * @bus: HDA core bus
 *
 * This function is supposed to be used only by a HD-audio controller
 * driver that needs the interaction with i915 graphics.
 *
 * This function releases the i915 audio component that has been used.
 *
 * Returns zero for success or a negative error code.
 */
int snd_hdac_i915_exit(struct hdac_bus *bus)
{
	struct device *dev = bus->dev;
	struct i915_audio_component *acomp = bus->audio_component;

	if (!acomp)
		return 0;

	WARN_ON(bus->i915_power_refcount);
	if (bus->i915_power_refcount > 0 && acomp->ops)
		acomp->ops->put_power(acomp->dev);

	component_master_del(dev, &hdac_component_master_ops);

	kfree(acomp);
	bus->audio_component = NULL;
	hdac_acomp = NULL;

	return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_i915_exit);

{'repo_name': 'beagleboard/linux', 'stars': '492', 'repo_language': 'C', 'file_name': 'Kconfig', 'mime_type': 'text/plain', 'hash': 3752314773883317534, 'source_dataset': 'data'}


require 'package'

class Libaudiofile < Package
  description 'The Audio File Library is a C-based library for reading and writing audio files in many common formats.'
  homepage 'https://audiofile.68k.org/'
  version 'b62c90'
  compatibility 'all'
  source_url 'https://github.com/mpruett/audiofile/archive/b62c902dd258125cac86cd2df21fc898035a43d3.tar.gz'
  source_sha256 '808aff989a24ee3b60d3f08897d90ca45a031c95c42fe22d4fd913042c1ce307'

  binary_url ({
    aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/libaudiofile-b62c90-chromeos-armv7l.tar.xz',
     armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/libaudiofile-b62c90-chromeos-armv7l.tar.xz',
       i686: 'https://dl.bintray.com/chromebrew/chromebrew/libaudiofile-b62c90-chromeos-i686.tar.xz',
     x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/libaudiofile-b62c90-chromeos-x86_64.tar.xz',
  })
  binary_sha256 ({
    aarch64: '4d4f7ea006f09f5777c2998775f6dd49e4ddf91ac40c3cdad09e94b5f1016ddc',
     armv7l: '4d4f7ea006f09f5777c2998775f6dd49e4ddf91ac40c3cdad09e94b5f1016ddc',
       i686: '0302ccfddd315e8fcbc58c2139463b03da3352dacc83a4e424130d15fdca1da1',
     x86_64: 'f74fa54401206607f94c5c76e8ba8bcedc13b202ed64262785b2ab11d7eb87db',
  })

  depends_on 'flac'

  def self.build
    system './autogen.sh'
    # Fix ./configure: line 7237: /usr/bin/file: No such file or directory
    system 'filefix'
    system './configure',
           "--prefix=#{CREW_PREFIX}",
           "--libdir=#{CREW_LIB_PREFIX}",
           '--disable-docs'
    system 'make'
  end

  def self.check
    system 'make', 'check'
  end

  def self.install
    system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
  end
end

{'repo_name': 'skycocker/chromebrew', 'stars': '1588', 'repo_language': 'Ruby', 'file_name': 'test_all', 'mime_type': 'text/x-ruby', 'hash': -9079468667751564586, 'source_dataset': 'data'}


/* Source Cited:

 Nature of Code by Daniel Shiffman
 Chapter 2: Forces
 http://natureofcode.com

 */

Mover [] movers = new Mover[600];

void setup() {
  size(500, 500);
  smooth();
  frameRate(30);
  for (int i = 0; i < movers.length; i++) {
    movers[i] = new Mover(random(0.1, 70), random(width+5), random(height+5));
  }
}

void draw() {
  // saveFrame("output/frames#################.tif");

  background(0);
  PVector wind = new PVector(0, 0);
  PVector gravity = new PVector(0, 5);
  for (int i = 0; i < movers.length; i++) {
    movers[i].applyForce(wind);
    movers[i].applyForce(gravity);
    movers[i].update();
    movers[i].display();
    movers[i].checkEdges();
  }
}

class Mover {

  PVector location;
  PVector velocity;
  PVector acceleration;

  float mass;

  Mover(float m, float x, float y) {
    mass = m;
    location = new PVector(x, y);
    velocity = new PVector(0, 0);
    acceleration = new PVector(0, 0);
  }

  // Newton’s second law.
  void applyForce(PVector force) {
    PVector f = PVector.div(force, mass);
    acceleration.add(f);
    if (mousePressed == true) {
      acceleration.sub(f);
    }
  }

  void update() {
    velocity.add(acceleration);
    location.add(velocity);

    acceleration.mult(0);
  }

  void display() {
    noStroke();
    fill(255);
    ellipse(location.x, location.y, mass, mass);
  }

  void checkEdges() {
    if (location.x > width) {
      location.x = width;
      velocity.x *= -1;
    } else if (location.x < 0) {
      velocity.x *= -1;
      location.x = 0;
    }

    if (location.y > height) {
      velocity.y *= -1;
      location.y = height;
    }
  }
}

{'repo_name': 'hiddenenigma/365Processing', 'stars': '101', 'repo_language': 'Processing', 'file_name': 'ParticleSystem.pde', 'mime_type': 'text/x-c++', 'hash': 642016660327906880, 'source_dataset': 'data'}


<!doctype html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>TrainTicket Admin</title>
    <meta name="description" content="This is the admin page of TrainTicket system">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}">导航切换 </button>

 FullScreen

                    Default admin

                Management

                            Order

                            Route

                            Travel

                            User

                            Basic

                                    Contact

                                    Station

                                    Train

                                    Price

                                    Config

                        Route List

                                    <button type="button" class="am-btn am-btn-default am-btn-success" ng-click="addNewRoute()"> Add</button>

                            <form class="am-form">

                                            Operation
                                            Id
                                            Stations
                                            Distances
                                            StartStationId
                                            terminalStationId

                                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="updateRoute(record)"> Update</button>

                                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger" ng-click="deleteRoute(record.id)"> Delete</button>

                                            {{record.id}}
                                            {{record.stations}}
                                            {{record.distances}}
                                            {{record.startStationId}}
                                            {{record.terminalStationId}}

Update Route

                                                        <form class="am-form am-form-horizontal">

                                                                Route Id:

                                                                    <input type="text" readonly="readonly" id="update_route_id" class="am-modal-prompt-input" ng-model="update_route_id">

                                                                Stations:

                                                                    <input type="text" id="update_route_stations" class="am-modal-prompt-input" ng-model="update_route_stations">

                                                                Distances:

                                                                    <input type="text" id="update_route_distances" class="am-modal-prompt-input" ng-model="update_route_distances">

                                                                Start Station:

                                                                    <input type="text" id="update_route_start_station" class="am-modal-prompt-input" ng-model="update_route_start_station">

                                                                Terminal Station:

                                                                    <input type="text" id="update_route_terminal_station" class="am-modal-prompt-input" ng-model="update_route_terminal_station">

                                                        </form>

                                                Cancel
                                                Update

Delete Route

                                                Are you sure to delete this route record?

                                                Cancel
                                                Delete

Add Route

                                                        <form class="am-form am-form-horizontal">

                                                                Stations:

                                                                    <input type="text" id="add_route_stations" class="am-modal-prompt-input" ng-model="add_route_stations">

                                                                Distances:

                                                                    <input type="text" id="add_route_distances" class="am-modal-prompt-input" ng-model="add_route_distances">

                                                                Start Station:

                                                                    <input type="text" id="add_route_start_station" class="am-modal-prompt-input" ng-model="add_route_start_station">

                                                                Terminal Station:

                                                                    <input type="text" id="add_route_terminal_station" class="am-modal-prompt-input" ng-model="add_route_terminal_station">

                                                        </form>

                                                Cancel
                                                Add

                            </form>

{'repo_name': 'FudanSELab/train-ticket', 'stars': '170', 'repo_language': 'Java', 'file_name': 'FoodControllerTest.java', 'mime_type': 'text/x-java', 'hash': -7036070853509788354, 'source_dataset': 'data'}


@echo off
echo adding to git
call git commit -am "commit before tentative release."
call rimraf .\web-ext-artifacts
echo rebuilding web extension...
call npm run clean-build
echo building web extension...
cd .\dist
call web-ext build --overwrite-dest
move .\web-ext-artifacts ..\
cd ..
echo compressing source..
call git archive -o source.zip HEAD
move .\source.zip .\web-ext-artifacts
echo done

{'repo_name': 'soapdog/patchfox', 'stars': '136', 'repo_language': 'HTML', 'file_name': '2020.3.6.md', 'mime_type': 'text/plain', 'hash': 2939557020203023070, 'source_dataset': 'data'}


/*
 Copyright (c) 2017, Stephane Sudre
 All rights reserved.

 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 - Neither the name of the WhiteBox nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#import "PKGDistributionRequirementSourceListDataSource.h"

#import "PKGDistributionRequirementSourceListFlatTree.h"
#import "PKGDistributionRequirementSourceListNode.h"
#import "PKGDistributionRequirementSourceListGroupItem.h"
#import "PKGDistributionRequirementSourceListRequirementItem.h"

#import "NSOutlineView+Selection.h"

#import "PKGDistributionRequirementPanel.h"

#import "PKGRequirementPluginsManager.h"
#import "PKGPluginsManager+AppKit.h"

#import "PKGRequirement+UI.h"

#import "NSArray+UniqueName.h"
#import "NSString+BaseName.h"

#import "NSIndexSet+Analysis.h"

NSString * const PKGDistributionRequirementInternalPboardType=@"fr.whitebox.packages.internal.distribution.requirements";

NSString * const PKGDistributionRequirementTransferInstallationPboardType=@"fr.whitebox.packages.transfer.distribution.installation.requirements";

NSString * const PKGDistributionRequirementTransferTargetPboardType=@"fr.whitebox.packages.transfer.distribution.target.requirements";

@interface PKGDistributionRequirementSourceListDataSource ()
{
	PKGDistributionRequirementSourceListFlatTree * _flatTree;

	NSIndexSet * _internalDragData;
}

- (void)tableView:(NSTableView *)inTableView addRequirement:(PKGRequirement *)inRequirement completionHandler:(void(^)(BOOL))handler;
- (void)tableView:(NSTableView *)inTableView addRequirements:(NSArray *)inRequirements completionHandler:(void(^)(BOOL))handler;

@end

@implementation PKGDistributionRequirementSourceListDataSource

+ (NSArray *)supportedDraggedTypes
{
	return @[NSFilenamesPboardType,PKGDistributionRequirementInternalPboardType,PKGDistributionRequirementTransferInstallationPboardType,PKGDistributionRequirementTransferTargetPboardType];
}

- (void)setRequirements:(NSMutableArray *)inRequirements
{
	if (_requirements!=inRequirements)
	{
		_requirements=inRequirements;

		_flatTree=[[PKGDistributionRequirementSourceListFlatTree alloc] initWithRequirements:_requirements];
	}
}

#pragma mark -

- (NSUInteger)numberOfItems
{
	return _flatTree.count;
}

#pragma mark - NSTableViewDataSource

- (NSInteger)numberOfRowsInTableView:(NSTableView *)inTableView
{
	if (_flatTree==nil)
		return 0;

	return _flatTree.count;
}

#pragma mark - NSPasteboardOwner

- (void)pasteboard:(NSPasteboard *)inPasteboard provideDataForType:(NSString *)inType
{
	if (inPasteboard==nil || inType==nil)
		return;

	if (_internalDragData==nil)
		return;

	if ([inType isEqualToString:PKGDistributionRequirementTransferInstallationPboardType]==NO &&
		[inType isEqualToString:PKGDistributionRequirementTransferTargetPboardType]==NO)
		return;

	NSArray * tNodes=[_flatTree nodesAtIndexes:_internalDragData];

	__block PKGRequirementType tRequirementType=PKGRequirementTypeUndefined;

	NSArray * tPasteboardArray=[tNodes WB_arrayByMappingObjectsUsingBlock:^NSDictionary *(PKGDistributionRequirementSourceListNode * bNode, NSUInteger bIndex) {

		PKGRequirement * tRequirementCopy=[((PKGDistributionRequirementSourceListRequirementItem *)bNode.representedObject).requirement copy];

		if (tRequirementType==PKGRequirementTypeUndefined)
		{
			tRequirementType=tRequirementCopy.requirementType;
		}

		Class tPluginUIClass=[[PKGRequirementPluginsManager defaultManager] pluginUIClassForIdentifier:tRequirementCopy.identifier];

		NSDictionary * tPasteboardSettingsRepresentation=[tPluginUIClass performSelector:@selector(pasteboardDictionaryFromDictionary:converter:) withObject:tRequirementCopy.settingsRepresentation withObject:self.filePathConverter];

		tRequirementCopy.settingsRepresentation=tPasteboardSettingsRepresentation;

		return [tRequirementCopy representation];
	}];

	[inPasteboard setPropertyList:tPasteboardArray forType:(tRequirementType==PKGRequirementTypeInstallation) ? PKGDistributionRequirementTransferInstallationPboardType : PKGDistributionRequirementTransferTargetPboardType];
}

#pragma mark - Drag and Drop support

- (void)tableView:(NSTableView *)inTableView draggingSession:(NSDraggingSession *)inDraggingSession endedAtPoint:(NSPoint)inScreenPoint operation:(NSDragOperation)inOperation
{
	_internalDragData=nil;
}

- (BOOL)tableView:(NSTableView *)inTableView writeRowsWithIndexes:(NSIndexSet *)inRowIndexes toPasteboard:(NSPasteboard *)inPasteboard
{
	NSMutableSet * tMutableSet=[NSMutableSet set];

	NSArray * tItems=[_flatTree nodesAtIndexes:inRowIndexes];

	for(PKGDistributionRequirementSourceListNode * tNode in tItems)
	{
		PKGDistributionRequirementSourceListNode * tParent=tNode.parent;

		if (tParent==nil)
			return NO;

		[tMutableSet addObject:tParent];
	}

	if (tMutableSet.count!=1)	// Only one type of requirements in a drag
		return NO;

	_internalDragData=inRowIndexes;

	NSMutableArray * tPasteboardTypes=[NSMutableArray arrayWithObject:PKGDistributionRequirementInternalPboardType];

	PKGRequirementType tRequirementType=[_flatTree requirementTypeForNode:[_flatTree nodeAtIndex:inRowIndexes.firstIndex]];

	if (tRequirementType==PKGRequirementTypeUndefined)
		return NO;

	[tPasteboardTypes addObject:(tRequirementType==PKGRequirementTypeInstallation) ? PKGDistributionRequirementTransferInstallationPboardType : PKGDistributionRequirementTransferTargetPboardType];

	[inPasteboard declareTypes:tPasteboardTypes owner:self];		// Make the external drag a promised case since it will be less usual IMHO

	[inPasteboard setData:[NSData data] forType:PKGDistributionRequirementInternalPboardType];

	return YES;
}

- (NSDragOperation)tableView:(NSTableView *)inTableView validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)inRow proposedDropOperation:(NSTableViewDropOperation)inDropOperation
{
	if (inDropOperation==NSTableViewDropOn)
		return NSDragOperationNone;

	NSPasteboard * tPasteBoard=[info draggingPasteboard];

	// Internal Drag

	if ([tPasteBoard availableTypeFromArray:@[PKGDistributionRequirementInternalPboardType]]!=nil && [info draggingSource]==inTableView)
	{
		PKGDistributionRequirementSourceListNode * tDroppedNode=[_flatTree nodeAtIndex:_internalDragData.firstIndex];
		NSUInteger tParentRow=[_flatTree indexOfNode:tDroppedNode.parent];
		NSUInteger tFirstDroppableRow=tParentRow+1;
		NSUInteger tLastDroppableRow=tDroppedNode.parent.numberOfChildren+tParentRow;

		if (inRow<tFirstDroppableRow || inRow>(tLastDroppableRow+1))
			return NSDragOperationNone;

		if ([_internalDragData WB_containsOnlyOneRange]==YES)
		{
			NSUInteger tFirstIndex=_internalDragData.firstIndex;
			NSUInteger tLastIndex=_internalDragData.lastIndex;

			if (inRow>=tFirstIndex && inRow<=(tLastIndex+1))
				return NSDragOperationNone;
		}
		else
		{
			if ([_internalDragData containsIndex:(inRow-1)]==YES)
				return NSDragOperationNone;
		}

		return NSDragOperationMove;
	}

	NSString * tAvailableType=[tPasteBoard availableTypeFromArray:@[PKGDistributionRequirementTransferInstallationPboardType,PKGDistributionRequirementTransferTargetPboardType]];

	if (tAvailableType!=nil)
	{
		if (inDropOperation!=NSTableViewDropAbove)
			return NSDragOperationNone;

		PKGRequirementType tDraggedRequirementType=([tAvailableType isEqualToString:PKGDistributionRequirementTransferInstallationPboardType]==YES) ? PKGRequirementTypeInstallation : PKGRequirementTypeTarget;

		NSRange tRange=[_flatTree rangeOfNodesWithRequirementType:tDraggedRequirementType];

		if (tRange.location==NSNotFound)
		{
			[inTableView setDropRow:-1 dropOperation:NSTableViewDropOn];
			return NSDragOperationCopy;
		}

		tRange.length+=1;

		if (NSLocationInRange(inRow,tRange)==NO)
			return NSDragOperationNone;

		return NSDragOperationCopy;
	}

	return NSDragOperationNone;
}

- (BOOL)tableView:(NSTableView *)inTableView acceptDrop:(id <NSDraggingInfo>)info row:(NSInteger)inRow dropOperation:(NSTableViewDropOperation)inDropOperation
{
	if (inTableView==nil)
		return NO;

	// Internal drag and drop

	NSPasteboard * tPasteBoard=[info draggingPasteboard];

	if ([tPasteBoard availableTypeFromArray:@[PKGDistributionRequirementInternalPboardType]]!=nil && [info draggingSource]==inTableView)
	{
		NSArray * tNodes=[_flatTree nodesAtIndexes:_internalDragData];
		PKGDistributionRequirementSourceListNode * tParent=((PKGDistributionRequirementSourceListNode *)tNodes.lastObject).parent;

		[_flatTree removeNodesInArray:tNodes];

		NSUInteger tIndex=[_internalDragData firstIndex];

		while (tIndex!=NSNotFound)
		{
			if (tIndex<inRow)
				inRow--;

			tIndex=[_internalDragData indexGreaterThanIndex:tIndex];
		}

		[_flatTree insertNodes:tNodes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(inRow, tNodes.count)]];

		for(PKGDistributionRequirementSourceListNode * tNode in tNodes)
			tNode.parent=tParent;

		[inTableView deselectAll:nil];

		[self.delegate sourceListDataDidChange:self];

		[inTableView reloadData];

		[inTableView selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(inRow,_internalDragData.count)]
				 byExtendingSelection:NO];

		return YES;
	}

	NSString * tAvailableType=[tPasteBoard availableTypeFromArray:@[PKGDistributionRequirementTransferInstallationPboardType,PKGDistributionRequirementTransferTargetPboardType]];

	if (tAvailableType!=nil)
	{
		NSArray * tObjects=(NSArray *) [tPasteBoard propertyListForType:tAvailableType];

		NSArray * tNewRequirements=[tObjects WB_arrayByMappingObjectsUsingBlock:^PKGRequirement *(NSDictionary * bRequirementRepresentation, NSUInteger bIndex) {

			NSError * tError=nil;

			PKGRequirement * tNewRequirement=[[PKGRequirement alloc] initWithRepresentation:bRequirementRepresentation error:&tError];

			if (tNewRequirement==nil)
			{
				if (tError!=nil)
				{
					// A COMPLETER
				}

				return nil;
			}

			Class tPluginUIClass=[[PKGRequirementPluginsManager defaultManager] pluginUIClassForIdentifier:tNewRequirement.identifier];

			NSDictionary * tSettingsRepresenation=[tPluginUIClass performSelector:@selector(dictionaryFromPasteboardDictionary:converter:) withObject:tNewRequirement.settingsRepresentation withObject:self.filePathConverter];

			tNewRequirement.settingsRepresentation=tSettingsRepresenation;

			return tNewRequirement;

		}];

		if (tNewRequirements==nil)
			return NO;

		if (inRow==-1)
		{
			[self tableView:inTableView addRequirements:tNewRequirements completionHandler:nil];

			return YES;
		}

		NSIndexSet * tIndexSet=[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(inRow, tNewRequirements.count)];

		[_flatTree insertRequirements:tNewRequirements atIndexes:tIndexSet];

		[inTableView deselectAll:nil];

		[self.delegate sourceListDataDidChange:self];

		[inTableView reloadData];

		[inTableView selectRowIndexes:tIndexSet
				 byExtendingSelection:NO];

		return YES;
	}

	return NO;
}

#pragma mark -

- (void)tableView:(NSTableView *)inTableView addNewRequirementWithCompletionHandler:(void(^)(BOOL))handler
{
	PKGRequirement * tNewRequirement=[PKGRequirement new];

	tNewRequirement.identifier=@"fr.whitebox.Packages.requirement.os";

	PKGDistributionRequirementPanel * tRequirementPanel=[PKGDistributionRequirementPanel distributionRequirementPanel];
	tRequirementPanel.prompt=NSLocalizedString(@"Add", @"");
	tRequirementPanel.requirement=tNewRequirement;

	[tRequirementPanel beginSheetModalForWindow:inTableView.window completionHandler:^(NSInteger bResult) {

		if (bResult==PKGPanelCancelButton)
			return;

		NSString * tBaseName=[[PKGRequirementPluginsManager defaultManager] localizedPluginNameForIdentifier:tNewRequirement.identifier];

		tNewRequirement.name=[self.requirements uniqueNameWithBaseName:tBaseName usingNameExtractor:^NSString *(PKGRequirement * bRequirement,NSUInteger bIndex) {

			return bRequirement.name;
		}];

		if (tNewRequirement.name==nil)
		{
			NSLog(@"Could not determine a unique name for the requirement");

			tNewRequirement.name=@"";
		}

		[self tableView:inTableView addRequirement:tNewRequirement completionHandler:handler];
	}];
}

- (void)editRequirement:(NSTableView *)inTableView
{
	NSUInteger tIndex=inTableView.WB_selectedOrClickedRowIndexes.firstIndex;
	if (tIndex==NSNotFound)	// Double-click with no requirements in list for example
		return;

	PKGDistributionRequirementSourceListNode * tTreeNode=[_flatTree nodeAtIndex:tIndex];
	PKGDistributionRequirementSourceListRequirementItem * tRequirementItem=(PKGDistributionRequirementSourceListRequirementItem *)tTreeNode.representedObject;
	PKGRequirement * tOriginalRequirement=tRequirementItem.requirement;
	PKGRequirement * tEditedRequirement=[tOriginalRequirement copy];

	PKGDistributionRequirementPanel * tRequirementPanel=[PKGDistributionRequirementPanel distributionRequirementPanel];

	tRequirementPanel.requirement=tEditedRequirement;

	[tRequirementPanel beginSheetModalForWindow:inTableView.window completionHandler:^(NSInteger bResult) {

		if (bResult==PKGPanelCancelButton)
				return;

		if ([tEditedRequirement isEqualToRequirement:tOriginalRequirement]==YES)
			return;

		NSUInteger tIndex=[self.requirements indexOfObjectIdenticalTo:tOriginalRequirement];

		if (tIndex==NSNotFound)
			return;

		PKGRequirementType tOriginalRequirementType=tOriginalRequirement.requirementType;
		PKGRequirementType tEditedRequirementType=tEditedRequirement.requirementType;

		if (tOriginalRequirementType==tEditedRequirementType)
		{
			[self.requirements replaceObjectAtIndex:tIndex withObject:tEditedRequirement];

			[tTreeNode setRepresentedObject:[[PKGDistributionRequirementSourceListRequirementItem alloc] initWithRequirement:tEditedRequirement]];

			[self.delegate sourceListDataDidChange:self];

			return;
		}

		dispatch_async(dispatch_get_main_queue(), ^{

			[self.requirements removeObject:tOriginalRequirement];

			[_flatTree removeNode:tTreeNode];

			[self tableView:inTableView addRequirement:tEditedRequirement completionHandler:nil];
		});
	}];
}

#pragma mark -

- (id)itemAtIndex:(NSUInteger)inIndex
{
	return [_flatTree nodeAtIndex:inIndex];
}

- (NSArray *)itemsAtIndexes:(NSIndexSet *)inIndexSet
{
	return [_flatTree nodesAtIndexes:inIndexSet];
}

- (NSInteger)rowForItem:(id)inItem
{
	if (inItem==nil)
		return -1;

	NSUInteger tIndex=[_flatTree indexOfNode:inItem];

	return (tIndex==NSNotFound) ? -1 : tIndex;
}

- (void)tableView:(NSTableView *)inTableView setItem:(PKGDistributionRequirementSourceListNode *)inRequirementTreeNode state:(BOOL)inState
{
	if (inTableView==nil || inRequirementTreeNode==nil)
		return;

	PKGDistributionRequirementSourceListRequirementItem * tRequirementItem=inRequirementTreeNode.representedObject;
	PKGRequirement * tRequirement=tRequirementItem.requirement;

	if (tRequirement.isEnabled==inState)
		return;

	tRequirement.enabled=inState;

	[self.delegate sourceListDataDidChange:self];
}

- (void)tableView:(NSTableView *)inTableView addRequirement:(PKGRequirement *)inRequirement completionHandler:(void(^)(BOOL))handler
{
	if (inRequirement==nil)
		return;

	[self tableView:inTableView addRequirements:@[inRequirement] completionHandler:handler];
}

- (void)tableView:(NSTableView *)inTableView addRequirements:(NSArray *)inRequirements completionHandler:(void(^)(BOOL))handler
{
	if (inTableView==nil || inRequirements.count==0)
	{
		if (handler!=nil)
			handler(NO);

		return;
	}

	NSMutableSet * tMutableSet=[NSMutableSet set];

	for(PKGRequirement * tRequirement in inRequirements)
	{
		if ([self.requirements containsObject:tRequirement]==YES)
		{
			// A COMPLETER

			continue;
		}

		[self.requirements addObject:tRequirement];

		[_flatTree addRequirement:tRequirement];

		[tMutableSet addObject:tRequirement];
	}

	if (tMutableSet.count==0)
	{
		if (handler!=nil)
			handler(NO);

		return;
	}

	[inTableView reloadData];

	// Post Notification

	[self.delegate sourceListDataDidChange:self];

	NSMutableIndexSet * tMutableIndexSet=[NSMutableIndexSet indexSet];

	for(PKGRequirement * tRequirement in tMutableSet)
	{
		PKGDistributionRequirementSourceListNode * tTreeNode=[_flatTree treeNodeForRequirement:tRequirement];

		NSInteger tSelectedRow=(tTreeNode==nil) ? 0 : [_flatTree indexOfNode:tTreeNode];

		if (tSelectedRow==-1)
			tSelectedRow=0;

		[tMutableIndexSet addIndex:tSelectedRow];
	}

	[inTableView scrollRowToVisible:(tMutableIndexSet.firstIndex==NSNotFound) ? 0 : tMutableIndexSet.firstIndex];

	[inTableView selectRowIndexes:tMutableIndexSet byExtendingSelection:NO];

	if (handler!=nil)
		handler(YES);
}

- (BOOL)tableView:(NSTableView *)inTableView shouldRenameRequirement:(PKGDistributionRequirementSourceListNode *)inRequirementTreeNode as:(NSString *)inNewName
{
	if (inTableView==nil || inRequirementTreeNode==nil || inNewName==nil)
		return NO;

	PKGRequirement * tRequirement=((PKGDistributionRequirementSourceListRequirementItem *) inRequirementTreeNode.representedObject).requirement;
	NSString * tName=tRequirement.name;

	if ([tName compare:inNewName]==NSOrderedSame)
		return NO;

	if ([tName caseInsensitiveCompare:inNewName]!=NSOrderedSame)
	{
		NSUInteger tLength=inNewName.length;
		NSIndexSet * tReloadRowIndexes=[NSIndexSet indexSetWithIndex:[_flatTree indexOfNode:inRequirementTreeNode]];
		NSIndexSet * tReloadColumnIndexes=[NSIndexSet indexSetWithIndex:[inTableView columnWithIdentifier:@"requirement"]];

		if (tLength==0)
		{
			[inTableView reloadDataForRowIndexes:tReloadRowIndexes columnIndexes:tReloadColumnIndexes];
			return NO;
		}
	}

	return YES;
}

- (BOOL)tableView:(NSTableView *)inTableView renameRequirement:(PKGDistributionRequirementSourceListNode *)inRequirementTreeNode as:(NSString *)inNewName
{
	if (inTableView==nil || inRequirementTreeNode==nil || inNewName==nil)
		return NO;

	PKGRequirement * tRequirement=((PKGDistributionRequirementSourceListRequirementItem *) inRequirementTreeNode.representedObject).requirement;

	tRequirement.name=inNewName;

	[inTableView reloadData];

	[self.delegate sourceListDataDidChange:self];

	NSInteger tSelectedRow=[_flatTree indexOfNode:inRequirementTreeNode];

	if (tSelectedRow!=-1)
	{
		[inTableView scrollRowToVisible:tSelectedRow];
		[inTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:tSelectedRow] byExtendingSelection:NO];
	}

	return YES;
}

- (void)tableView:(NSTableView *)inTableView duplicateItems:(NSArray *)inItems
{
	if (inTableView==nil || inItems.count==0)
		return;

	__block NSMutableArray * tTemporaryComponents=[self.requirements mutableCopy];

	NSArray * tDuplicatedPackageComponents=[inItems WB_arrayByMappingObjectsLenientlyUsingBlock:^PKGRequirement *(PKGDistributionRequirementSourceListNode * bSourceListNode, NSUInteger bIndex) {

		PKGDistributionRequirementSourceListRequirementItem * tRequirementItem=bSourceListNode.representedObject;

		PKGRequirement * tNewRequirement=[tRequirementItem.requirement copy];

		// Unique Name

		NSString * tBaseName=[tNewRequirement.name PKG_baseName];

		NSString * tNewName=[tTemporaryComponents uniqueNameWithBaseName:[tBaseName stringByAppendingString:NSLocalizedString(@" copy", @"")]
													  usingNameExtractor:^NSString *(PKGRequirement * bRequirement, NSUInteger bIndex) {
														  return bRequirement.name;
													  }];

		if (tNewName!=nil)
			tNewRequirement.name=tNewName;

		[tTemporaryComponents addObject:tNewRequirement];

		return tNewRequirement;
	}];

	[self tableView:inTableView addRequirements:tDuplicatedPackageComponents completionHandler:nil];
}

- (void)tableView:(NSTableView *)inTableView removeItems:(NSArray *)inItems
{
	if (inTableView==nil || inItems.count==0)
		return;

	// Remove the requirements

	for(PKGDistributionRequirementSourceListNode * tSourceListNode in inItems)
	{
		PKGDistributionRequirementSourceListRequirementItem * tRequirementItem=tSourceListNode.representedObject;

		// A COMPLETER

		[_requirements removeObject:tRequirementItem.requirement];

		[_flatTree removeNode:tSourceListNode];
	}

	[inTableView deselectAll:nil];

	[inTableView reloadData];

	[self.delegate sourceListDataDidChange:self];
}

@end

{'repo_name': 'packagesdev/packages', 'stars': '146', 'repo_language': 'Objective-C', 'file_name': 'Script.xcscheme', 'mime_type': 'text/xml', 'hash': -8090487406028143554, 'source_dataset': 'data'}


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

#ifndef __CMAC_HOST_H_
#define __CMAC_HOST_H_

#ifdef __cplusplus
extern "C" {
#endif

typedef int (* cmac_mbox_read_cb)(const uint8_t *, uint16_t len);

void cmac_host_init(void);
void cmac_mbox_write(const uint8_t *buf, size_t len);
void cmac_mbox_set_read_cb(cmac_mbox_read_cb cb);

#ifdef __cplusplus
}
#endif

#endif /* __CMAC_HOST_H_ */

{'repo_name': 'JF002/Pinetime', 'stars': '126', 'repo_language': 'C', 'file_name': 'connection_sequence.puml', 'mime_type': 'text/plain', 'hash': -7083548636009537283, 'source_dataset': 'data'}


---
title: DefaultTextStyle
---

The text style to apply to descendant Text widgets without explicit style.

## Example

```dart liveslice=DefaultTextStyle
DefaultTextStyle(
  style: TextStyle(
    fontSize: 60,
    color: Colors.blue,
    fontWeight: FontWeight.bold,
  ),
  child: Text('Flutter'),
)
```

## Related Links

- https://api.flutter.dev/flutter/widgets/DefaultTextStyle-class.html

{'repo_name': 'learn-flutter-dev/flutter-widget-livebook', 'stars': '482', 'repo_language': 'Dart', 'file_name': 'mdx-fm-loader.js', 'mime_type': 'text/plain', 'hash': 5325925251732508191, 'source_dataset': 'data'}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace N2.Raven.Tests
{
	public class MyItem : ContentItem
	{
		public string Text
		{
			get { return GetDetail("Text", ""); }
			set { SetDetail("Text", value, ""); }
		}
	}
}

{'repo_name': 'n2cms/n2cms', 'stars': '359', 'repo_language': 'C#', 'file_name': 'n2propfta.snippet', 'mime_type': 'text/xml', 'hash': 4606809839653846578, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
      <application>
        <!--This Id value indicates the application supports Windows Vista functionality -->
          <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
        <!--This Id value indicates the application supports Windows 7 functionality-->
          <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
        <!--This Id value indicates the application supports Windows 8 functionality-->
          <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
        <!--This Id value indicates the application supports Windows 8.1 functionality-->
          <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
        <!--This Id value indicates the application supports Windows 10 functionality -->
          <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
      </application>
  </compatibility>
</assembly>

{'repo_name': 'microsoft/cpprestsdk', 'stars': '5432', 'repo_language': 'C++', 'file_name': 'build-ubuntu-vcpkg.yml', 'mime_type': 'text/plain', 'hash': 2474150182958619147, 'source_dataset': 'data'}


/*
 * Allwinner A1X SoCs pinctrl driver.
 *
 * Copyright (C) 2012 Maxime Ripard
 *
 * Maxime Ripard <maxime.ripard@free-electrons.com>
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

#include <linux/io.h>
#include <linux/clk.h>
#include <linux/gpio/driver.h>
#include <linux/irqdomain.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/export.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

#include "../core.h"
#include "../../gpio/gpiolib.h"
#include "pinctrl-sunxi.h"

static struct irq_chip sunxi_pinctrl_edge_irq_chip;
static struct irq_chip sunxi_pinctrl_level_irq_chip;

static struct sunxi_pinctrl_group *
sunxi_pinctrl_find_group_by_name(struct sunxi_pinctrl *pctl, const char *group)
{
	int i;

	for (i = 0; i < pctl->ngroups; i++) {
		struct sunxi_pinctrl_group *grp = pctl->groups + i;

		if (!strcmp(grp->name, group))
			return grp;
	}

	return NULL;
}

static struct sunxi_pinctrl_function *
sunxi_pinctrl_find_function_by_name(struct sunxi_pinctrl *pctl,
				    const char *name)
{
	struct sunxi_pinctrl_function *func = pctl->functions;
	int i;

	for (i = 0; i < pctl->nfunctions; i++) {
		if (!func[i].name)
			break;

		if (!strcmp(func[i].name, name))
			return func + i;
	}

	return NULL;
}

static struct sunxi_desc_function *
sunxi_pinctrl_desc_find_function_by_name(struct sunxi_pinctrl *pctl,
					 const char *pin_name,
					 const char *func_name)
{
	int i;

	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;

		if (!strcmp(pin->pin.name, pin_name)) {
			struct sunxi_desc_function *func = pin->functions;

			while (func->name) {
				if (!strcmp(func->name, func_name))
					return func;

				func++;
			}
		}
	}

	return NULL;
}

static struct sunxi_desc_function *
sunxi_pinctrl_desc_find_function_by_pin(struct sunxi_pinctrl *pctl,
					const u16 pin_num,
					const char *func_name)
{
	int i;

	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;

		if (pin->pin.number == pin_num) {
			struct sunxi_desc_function *func = pin->functions;

			while (func->name) {
				if (!strcmp(func->name, func_name))
					return func;

				func++;
			}
		}
	}

	return NULL;
}

static int sunxi_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	return pctl->ngroups;
}

static const char *sunxi_pctrl_get_group_name(struct pinctrl_dev *pctldev,
					      unsigned group)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	return pctl->groups[group].name;
}

static int sunxi_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
				      unsigned group,
				      const unsigned **pins,
				      unsigned *num_pins)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	*pins = (unsigned *)&pctl->groups[group].pin;
	*num_pins = 1;

	return 0;
}

static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
				      struct device_node *node,
				      struct pinctrl_map **map,
				      unsigned *num_maps)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
	unsigned long *pinconfig;
	struct property *prop;
	const char *function;
	const char *group;
	int ret, nmaps, i = 0;
	u32 val;

	*map = NULL;
	*num_maps = 0;

	ret = of_property_read_string(node, "allwinner,function", &function);
	if (ret) {
		dev_err(pctl->dev,
			"missing allwinner,function property in node %s\n",
			node->name);
		return -EINVAL;
	}

	nmaps = of_property_count_strings(node, "allwinner,pins") * 2;
	if (nmaps < 0) {
		dev_err(pctl->dev,
			"missing allwinner,pins property in node %s\n",
			node->name);
		return -EINVAL;
	}

	*map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
	if (!*map)
		return -ENOMEM;

	of_property_for_each_string(node, "allwinner,pins", prop, group) {
		struct sunxi_pinctrl_group *grp =
			sunxi_pinctrl_find_group_by_name(pctl, group);
		int j = 0, configlen = 0;

		if (!grp) {
			dev_err(pctl->dev, "unknown pin %s", group);
			continue;
		}

		if (!sunxi_pinctrl_desc_find_function_by_name(pctl,
							      grp->name,
							      function)) {
			dev_err(pctl->dev, "unsupported function %s on pin %s",
				function, group);
			continue;
		}

		(*map)[i].type = PIN_MAP_TYPE_MUX_GROUP;
		(*map)[i].data.mux.group = group;
		(*map)[i].data.mux.function = function;

		i++;

		(*map)[i].type = PIN_MAP_TYPE_CONFIGS_GROUP;
		(*map)[i].data.configs.group_or_pin = group;

		if (of_find_property(node, "allwinner,drive", NULL))
			configlen++;
		if (of_find_property(node, "allwinner,pull", NULL))
			configlen++;

		pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
		if (!pinconfig) {
			kfree(*map);
			return -ENOMEM;
		}

		if (!of_property_read_u32(node, "allwinner,drive", &val)) {
			u16 strength = (val + 1) * 10;
			pinconfig[j++] =
				pinconf_to_config_packed(PIN_CONFIG_DRIVE_STRENGTH,
							 strength);
		}

		if (!of_property_read_u32(node, "allwinner,pull", &val)) {
			enum pin_config_param pull = PIN_CONFIG_END;
			if (val == 1)
				pull = PIN_CONFIG_BIAS_PULL_UP;
			else if (val == 2)
				pull = PIN_CONFIG_BIAS_PULL_DOWN;
			pinconfig[j++] = pinconf_to_config_packed(pull, 0);
		}

		(*map)[i].data.configs.configs = pinconfig;
		(*map)[i].data.configs.num_configs = configlen;

		i++;
	}

	*num_maps = nmaps;

	return 0;
}

static void sunxi_pctrl_dt_free_map(struct pinctrl_dev *pctldev,
				    struct pinctrl_map *map,
				    unsigned num_maps)
{
	int i;

	for (i = 0; i < num_maps; i++) {
		if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
			kfree(map[i].data.configs.configs);
	}

	kfree(map);
}

static const struct pinctrl_ops sunxi_pctrl_ops = {
	.dt_node_to_map		= sunxi_pctrl_dt_node_to_map,
	.dt_free_map		= sunxi_pctrl_dt_free_map,
	.get_groups_count	= sunxi_pctrl_get_groups_count,
	.get_group_name		= sunxi_pctrl_get_group_name,
	.get_group_pins		= sunxi_pctrl_get_group_pins,
};

static int sunxi_pconf_group_get(struct pinctrl_dev *pctldev,
				 unsigned group,
				 unsigned long *config)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	*config = pctl->groups[group].config;

	return 0;
}

static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
				 unsigned group,
				 unsigned long *configs,
				 unsigned num_configs)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
	struct sunxi_pinctrl_group *g = &pctl->groups[group];
	unsigned long flags;
	unsigned pin = g->pin - pctl->desc->pin_base;
	u32 val, mask;
	u16 strength;
	u8 dlevel;
	int i;

	spin_lock_irqsave(&pctl->lock, flags);

	for (i = 0; i < num_configs; i++) {
		switch (pinconf_to_config_param(configs[i])) {
		case PIN_CONFIG_DRIVE_STRENGTH:
			strength = pinconf_to_config_argument(configs[i]);
			if (strength > 40) {
				spin_unlock_irqrestore(&pctl->lock, flags);
				return -EINVAL;
			}
			/*
			 * We convert from mA to what the register expects:
			 *   0: 10mA
			 *   1: 20mA
			 *   2: 30mA
			 *   3: 40mA
			 */
			dlevel = strength / 10 - 1;
			val = readl(pctl->membase + sunxi_dlevel_reg(pin));
			mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(pin);
			writel((val & ~mask)
				| dlevel << sunxi_dlevel_offset(pin),
				pctl->membase + sunxi_dlevel_reg(pin));
			break;
		case PIN_CONFIG_BIAS_PULL_UP:
			val = readl(pctl->membase + sunxi_pull_reg(pin));
			mask = PULL_PINS_MASK << sunxi_pull_offset(pin);
			writel((val & ~mask) | 1 << sunxi_pull_offset(pin),
				pctl->membase + sunxi_pull_reg(pin));
			break;
		case PIN_CONFIG_BIAS_PULL_DOWN:
			val = readl(pctl->membase + sunxi_pull_reg(pin));
			mask = PULL_PINS_MASK << sunxi_pull_offset(pin);
			writel((val & ~mask) | 2 << sunxi_pull_offset(pin),
				pctl->membase + sunxi_pull_reg(pin));
			break;
		default:
			break;
		}
		/* cache the config value */
		g->config = configs[i];
	} /* for each config */

	spin_unlock_irqrestore(&pctl->lock, flags);

	return 0;
}

static const struct pinconf_ops sunxi_pconf_ops = {
	.pin_config_group_get	= sunxi_pconf_group_get,
	.pin_config_group_set	= sunxi_pconf_group_set,
};

static int sunxi_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	return pctl->nfunctions;
}

static const char *sunxi_pmx_get_func_name(struct pinctrl_dev *pctldev,
					   unsigned function)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	return pctl->functions[function].name;
}

static int sunxi_pmx_get_func_groups(struct pinctrl_dev *pctldev,
				     unsigned function,
				     const char * const **groups,
				     unsigned * const num_groups)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);

	*groups = pctl->functions[function].groups;
	*num_groups = pctl->functions[function].ngroups;

	return 0;
}

static void sunxi_pmx_set(struct pinctrl_dev *pctldev,
				 unsigned pin,
				 u8 config)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
	unsigned long flags;
	u32 val, mask;

	spin_lock_irqsave(&pctl->lock, flags);

	pin -= pctl->desc->pin_base;
	val = readl(pctl->membase + sunxi_mux_reg(pin));
	mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
	writel((val & ~mask) | config << sunxi_mux_offset(pin),
		pctl->membase + sunxi_mux_reg(pin));

	spin_unlock_irqrestore(&pctl->lock, flags);
}

static int sunxi_pmx_set_mux(struct pinctrl_dev *pctldev,
			     unsigned function,
			     unsigned group)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
	struct sunxi_pinctrl_group *g = pctl->groups + group;
	struct sunxi_pinctrl_function *func = pctl->functions + function;
	struct sunxi_desc_function *desc =
		sunxi_pinctrl_desc_find_function_by_name(pctl,
							 g->name,
							 func->name);

	if (!desc)
		return -EINVAL;

	sunxi_pmx_set(pctldev, g->pin, desc->muxval);

	return 0;
}

static int
sunxi_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
			struct pinctrl_gpio_range *range,
			unsigned offset,
			bool input)
{
	struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
	struct sunxi_desc_function *desc;
	const char *func;

	if (input)
		func = "gpio_in";
	else
		func = "gpio_out";

	desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, offset, func);
	if (!desc)
		return -EINVAL;

	sunxi_pmx_set(pctldev, offset, desc->muxval);

	return 0;
}

static const struct pinmux_ops sunxi_pmx_ops = {
	.get_functions_count	= sunxi_pmx_get_funcs_cnt,
	.get_function_name	= sunxi_pmx_get_func_name,
	.get_function_groups	= sunxi_pmx_get_func_groups,
	.set_mux		= sunxi_pmx_set_mux,
	.gpio_set_direction	= sunxi_pmx_gpio_set_direction,
};

static int sunxi_pinctrl_gpio_direction_input(struct gpio_chip *chip,
					unsigned offset)
{
	return pinctrl_gpio_direction_input(chip->base + offset);
}

static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
{
	struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
	u32 reg = sunxi_data_reg(offset);
	u8 index = sunxi_data_offset(offset);
	bool set_mux = pctl->desc->irq_read_needs_mux &&
		gpiochip_line_is_irq(chip, offset);
	u32 pin = offset + chip->base;
	u32 val;

	if (set_mux)
		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_INPUT);

	val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;

	if (set_mux)
		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_IRQ);

	return !!val;
}

static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
				unsigned offset, int value)
{
	struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
	u32 reg = sunxi_data_reg(offset);
	u8 index = sunxi_data_offset(offset);
	unsigned long flags;
	u32 regval;

	spin_lock_irqsave(&pctl->lock, flags);

	regval = readl(pctl->membase + reg);

	if (value)
		regval |= BIT(index);
	else
		regval &= ~(BIT(index));

	writel(regval, pctl->membase + reg);

	spin_unlock_irqrestore(&pctl->lock, flags);
}

static int sunxi_pinctrl_gpio_direction_output(struct gpio_chip *chip,
					unsigned offset, int value)
{
	sunxi_pinctrl_gpio_set(chip, offset, value);
	return pinctrl_gpio_direction_output(chip->base + offset);
}

static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
				const struct of_phandle_args *gpiospec,
				u32 *flags)
{
	int pin, base;

	base = PINS_PER_BANK * gpiospec->args[0];
	pin = base + gpiospec->args[1];

	if (pin > gc->ngpio)
		return -EINVAL;

	if (flags)
		*flags = gpiospec->args[2];

	return pin;
}

static int sunxi_pinctrl_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
{
	struct sunxi_pinctrl *pctl = gpiochip_get_data(chip);
	struct sunxi_desc_function *desc;
	unsigned pinnum = pctl->desc->pin_base + offset;
	unsigned irqnum;

	if (offset >= chip->ngpio)
		return -ENXIO;

	desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, pinnum, "irq");
	if (!desc)
		return -EINVAL;

	irqnum = desc->irqbank * IRQ_PER_BANK + desc->irqnum;

	dev_dbg(chip->parent, "%s: request IRQ for GPIO %d, return %d\n",
		chip->label, offset + chip->base, irqnum);

	return irq_find_mapping(pctl->domain, irqnum);
}

static int sunxi_pinctrl_irq_request_resources(struct irq_data *d)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
	struct sunxi_desc_function *func;
	int ret;

	func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
					pctl->irq_array[d->hwirq], "irq");
	if (!func)
		return -EINVAL;

	ret = gpiochip_lock_as_irq(pctl->chip,
			pctl->irq_array[d->hwirq] - pctl->desc->pin_base);
	if (ret) {
		dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n",
			irqd_to_hwirq(d));
		return ret;
	}

	/* Change muxing to INT mode */
	sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);

	return 0;
}

static void sunxi_pinctrl_irq_release_resources(struct irq_data *d)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);

	gpiochip_unlock_as_irq(pctl->chip,
			      pctl->irq_array[d->hwirq] - pctl->desc->pin_base);
}

static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
	u32 reg = sunxi_irq_cfg_reg(d->hwirq, pctl->desc->irq_bank_base);
	u8 index = sunxi_irq_cfg_offset(d->hwirq);
	unsigned long flags;
	u32 regval;
	u8 mode;

	switch (type) {
	case IRQ_TYPE_EDGE_RISING:
		mode = IRQ_EDGE_RISING;
		break;
	case IRQ_TYPE_EDGE_FALLING:
		mode = IRQ_EDGE_FALLING;
		break;
	case IRQ_TYPE_EDGE_BOTH:
		mode = IRQ_EDGE_BOTH;
		break;
	case IRQ_TYPE_LEVEL_HIGH:
		mode = IRQ_LEVEL_HIGH;
		break;
	case IRQ_TYPE_LEVEL_LOW:
		mode = IRQ_LEVEL_LOW;
		break;
	default:
		return -EINVAL;
	}

	spin_lock_irqsave(&pctl->lock, flags);

	if (type & IRQ_TYPE_LEVEL_MASK)
		irq_set_chip_handler_name_locked(d, &sunxi_pinctrl_level_irq_chip,
						 handle_fasteoi_irq, NULL);
	else
		irq_set_chip_handler_name_locked(d, &sunxi_pinctrl_edge_irq_chip,
						 handle_edge_irq, NULL);

	regval = readl(pctl->membase + reg);
	regval &= ~(IRQ_CFG_IRQ_MASK << index);
	writel(regval | (mode << index), pctl->membase + reg);

	spin_unlock_irqrestore(&pctl->lock, flags);

	return 0;
}

static void sunxi_pinctrl_irq_ack(struct irq_data *d)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
	u32 status_reg = sunxi_irq_status_reg(d->hwirq,
					      pctl->desc->irq_bank_base);
	u8 status_idx = sunxi_irq_status_offset(d->hwirq);

	/* Clear the IRQ */
	writel(1 << status_idx, pctl->membase + status_reg);
}

static void sunxi_pinctrl_irq_mask(struct irq_data *d)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
	u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base);
	u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
	unsigned long flags;
	u32 val;

	spin_lock_irqsave(&pctl->lock, flags);

	/* Mask the IRQ */
	val = readl(pctl->membase + reg);
	writel(val & ~(1 << idx), pctl->membase + reg);

	spin_unlock_irqrestore(&pctl->lock, flags);
}

static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
{
	struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
	u32 reg = sunxi_irq_ctrl_reg(d->hwirq, pctl->desc->irq_bank_base);
	u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
	unsigned long flags;
	u32 val;

	spin_lock_irqsave(&pctl->lock, flags);

	/* Unmask the IRQ */
	val = readl(pctl->membase + reg);
	writel(val | (1 << idx), pctl->membase + reg);

	spin_unlock_irqrestore(&pctl->lock, flags);
}

static void sunxi_pinctrl_irq_ack_unmask(struct irq_data *d)
{
	sunxi_pinctrl_irq_ack(d);
	sunxi_pinctrl_irq_unmask(d);
}

static struct irq_chip sunxi_pinctrl_edge_irq_chip = {
	.name		= "sunxi_pio_edge",
	.irq_ack	= sunxi_pinctrl_irq_ack,
	.irq_mask	= sunxi_pinctrl_irq_mask,
	.irq_unmask	= sunxi_pinctrl_irq_unmask,
	.irq_request_resources = sunxi_pinctrl_irq_request_resources,
	.irq_release_resources = sunxi_pinctrl_irq_release_resources,
	.irq_set_type	= sunxi_pinctrl_irq_set_type,
	.flags		= IRQCHIP_SKIP_SET_WAKE,
};

static struct irq_chip sunxi_pinctrl_level_irq_chip = {
	.name		= "sunxi_pio_level",
	.irq_eoi	= sunxi_pinctrl_irq_ack,
	.irq_mask	= sunxi_pinctrl_irq_mask,
	.irq_unmask	= sunxi_pinctrl_irq_unmask,
	/* Define irq_enable / disable to avoid spurious irqs for drivers
	 * using these to suppress irqs while they clear the irq source */
	.irq_enable	= sunxi_pinctrl_irq_ack_unmask,
	.irq_disable	= sunxi_pinctrl_irq_mask,
	.irq_request_resources = sunxi_pinctrl_irq_request_resources,
	.irq_release_resources = sunxi_pinctrl_irq_release_resources,
	.irq_set_type	= sunxi_pinctrl_irq_set_type,
	.flags		= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_EOI_THREADED |
			  IRQCHIP_EOI_IF_HANDLED,
};

static int sunxi_pinctrl_irq_of_xlate(struct irq_domain *d,
				      struct device_node *node,
				      const u32 *intspec,
				      unsigned int intsize,
				      unsigned long *out_hwirq,
				      unsigned int *out_type)
{
	struct sunxi_pinctrl *pctl = d->host_data;
	struct sunxi_desc_function *desc;
	int pin, base;

	if (intsize < 3)
		return -EINVAL;

	base = PINS_PER_BANK * intspec[0];
	pin = pctl->desc->pin_base + base + intspec[1];

	desc = sunxi_pinctrl_desc_find_function_by_pin(pctl, pin, "irq");
	if (!desc)
		return -EINVAL;

	*out_hwirq = desc->irqbank * PINS_PER_BANK + desc->irqnum;
	*out_type = intspec[2];

	return 0;
}

static struct irq_domain_ops sunxi_pinctrl_irq_domain_ops = {
	.xlate		= sunxi_pinctrl_irq_of_xlate,
};

static void sunxi_pinctrl_irq_handler(struct irq_desc *desc)
{
	unsigned int irq = irq_desc_get_irq(desc);
	struct irq_chip *chip = irq_desc_get_chip(desc);
	struct sunxi_pinctrl *pctl = irq_desc_get_handler_data(desc);
	unsigned long bank, reg, val;

	for (bank = 0; bank < pctl->desc->irq_banks; bank++)
		if (irq == pctl->irq[bank])
			break;

	if (bank == pctl->desc->irq_banks)
		return;

	reg = sunxi_irq_status_reg_from_bank(bank, pctl->desc->irq_bank_base);
	val = readl(pctl->membase + reg);

	if (val) {
		int irqoffset;

		chained_irq_enter(chip, desc);
		for_each_set_bit(irqoffset, &val, IRQ_PER_BANK) {
			int pin_irq = irq_find_mapping(pctl->domain,
						       bank * IRQ_PER_BANK + irqoffset);
			generic_handle_irq(pin_irq);
		}
		chained_irq_exit(chip, desc);
	}
}

static int sunxi_pinctrl_add_function(struct sunxi_pinctrl *pctl,
					const char *name)
{
	struct sunxi_pinctrl_function *func = pctl->functions;

	while (func->name) {
		/* function already there */
		if (strcmp(func->name, name) == 0) {
			func->ngroups++;
			return -EEXIST;
		}
		func++;
	}

	func->name = name;
	func->ngroups = 1;

	pctl->nfunctions++;

	return 0;
}

static int sunxi_pinctrl_build_state(struct platform_device *pdev)
{
	struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);
	int i;

	pctl->ngroups = pctl->desc->npins;

	/* Allocate groups */
	pctl->groups = devm_kzalloc(&pdev->dev,
				    pctl->ngroups * sizeof(*pctl->groups),
				    GFP_KERNEL);
	if (!pctl->groups)
		return -ENOMEM;

	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
		struct sunxi_pinctrl_group *group = pctl->groups + i;

		group->name = pin->pin.name;
		group->pin = pin->pin.number;
	}

	/*
	 * We suppose that we won't have any more functions than pins,
	 * we'll reallocate that later anyway
	 */
	pctl->functions = devm_kzalloc(&pdev->dev,
				pctl->desc->npins * sizeof(*pctl->functions),
				GFP_KERNEL);
	if (!pctl->functions)
		return -ENOMEM;

	/* Count functions and their associated groups */
	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
		struct sunxi_desc_function *func = pin->functions;

		while (func->name) {
			/* Create interrupt mapping while we're at it */
			if (!strcmp(func->name, "irq")) {
				int irqnum = func->irqnum + func->irqbank * IRQ_PER_BANK;
				pctl->irq_array[irqnum] = pin->pin.number;
			}

			sunxi_pinctrl_add_function(pctl, func->name);
			func++;
		}
	}

	pctl->functions = krealloc(pctl->functions,
				pctl->nfunctions * sizeof(*pctl->functions),
				GFP_KERNEL);

	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;
		struct sunxi_desc_function *func = pin->functions;

		while (func->name) {
			struct sunxi_pinctrl_function *func_item;
			const char **func_grp;

			func_item = sunxi_pinctrl_find_function_by_name(pctl,
									func->name);
			if (!func_item)
				return -EINVAL;

			if (!func_item->groups) {
				func_item->groups =
					devm_kzalloc(&pdev->dev,
						     func_item->ngroups * sizeof(*func_item->groups),
						     GFP_KERNEL);
				if (!func_item->groups)
					return -ENOMEM;
			}

			func_grp = func_item->groups;
			while (*func_grp)
				func_grp++;

			*func_grp = pin->pin.name;
			func++;
		}
	}

	return 0;
}

int sunxi_pinctrl_init(struct platform_device *pdev,
		       const struct sunxi_pinctrl_desc *desc)
{
	struct device_node *node = pdev->dev.of_node;
	struct pinctrl_desc *pctrl_desc;
	struct pinctrl_pin_desc *pins;
	struct sunxi_pinctrl *pctl;
	struct resource *res;
	int i, ret, last_pin;
	struct clk *clk;

	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
	if (!pctl)
		return -ENOMEM;
	platform_set_drvdata(pdev, pctl);

	spin_lock_init(&pctl->lock);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	pctl->membase = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(pctl->membase))
		return PTR_ERR(pctl->membase);

	pctl->dev = &pdev->dev;
	pctl->desc = desc;

	pctl->irq_array = devm_kcalloc(&pdev->dev,
				       IRQ_PER_BANK * pctl->desc->irq_banks,
				       sizeof(*pctl->irq_array),
				       GFP_KERNEL);
	if (!pctl->irq_array)
		return -ENOMEM;

	ret = sunxi_pinctrl_build_state(pdev);
	if (ret) {
		dev_err(&pdev->dev, "dt probe failed: %d\n", ret);
		return ret;
	}

	pins = devm_kzalloc(&pdev->dev,
			    pctl->desc->npins * sizeof(*pins),
			    GFP_KERNEL);
	if (!pins)
		return -ENOMEM;

	for (i = 0; i < pctl->desc->npins; i++)
		pins[i] = pctl->desc->pins[i].pin;

	pctrl_desc = devm_kzalloc(&pdev->dev,
				  sizeof(*pctrl_desc),
				  GFP_KERNEL);
	if (!pctrl_desc)
		return -ENOMEM;

	pctrl_desc->name = dev_name(&pdev->dev);
	pctrl_desc->owner = THIS_MODULE;
	pctrl_desc->pins = pins;
	pctrl_desc->npins = pctl->desc->npins;
	pctrl_desc->confops = &sunxi_pconf_ops;
	pctrl_desc->pctlops = &sunxi_pctrl_ops;
	pctrl_desc->pmxops =  &sunxi_pmx_ops;

	pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, pctrl_desc, pctl);
	if (IS_ERR(pctl->pctl_dev)) {
		dev_err(&pdev->dev, "couldn't register pinctrl driver\n");
		return PTR_ERR(pctl->pctl_dev);
	}

	pctl->chip = devm_kzalloc(&pdev->dev, sizeof(*pctl->chip), GFP_KERNEL);
	if (!pctl->chip)
		return -ENOMEM;

	last_pin = pctl->desc->pins[pctl->desc->npins - 1].pin.number;
	pctl->chip->owner = THIS_MODULE;
	pctl->chip->request = gpiochip_generic_request,
	pctl->chip->free = gpiochip_generic_free,
	pctl->chip->direction_input = sunxi_pinctrl_gpio_direction_input,
	pctl->chip->direction_output = sunxi_pinctrl_gpio_direction_output,
	pctl->chip->get = sunxi_pinctrl_gpio_get,
	pctl->chip->set = sunxi_pinctrl_gpio_set,
	pctl->chip->of_xlate = sunxi_pinctrl_gpio_of_xlate,
	pctl->chip->to_irq = sunxi_pinctrl_gpio_to_irq,
	pctl->chip->of_gpio_n_cells = 3,
	pctl->chip->can_sleep = false,
	pctl->chip->ngpio = round_up(last_pin, PINS_PER_BANK) -
			    pctl->desc->pin_base;
	pctl->chip->label = dev_name(&pdev->dev);
	pctl->chip->parent = &pdev->dev;
	pctl->chip->base = pctl->desc->pin_base;

	ret = gpiochip_add_data(pctl->chip, pctl);
	if (ret)
		return ret;

	for (i = 0; i < pctl->desc->npins; i++) {
		const struct sunxi_desc_pin *pin = pctl->desc->pins + i;

		ret = gpiochip_add_pin_range(pctl->chip, dev_name(&pdev->dev),
					     pin->pin.number - pctl->desc->pin_base,
					     pin->pin.number, 1);
		if (ret)
			goto gpiochip_error;
	}

	clk = devm_clk_get(&pdev->dev, NULL);
	if (IS_ERR(clk)) {
		ret = PTR_ERR(clk);
		goto gpiochip_error;
	}

	ret = clk_prepare_enable(clk);
	if (ret)
		goto gpiochip_error;

	pctl->irq = devm_kcalloc(&pdev->dev,
				 pctl->desc->irq_banks,
				 sizeof(*pctl->irq),
				 GFP_KERNEL);
	if (!pctl->irq) {
		ret = -ENOMEM;
		goto clk_error;
	}

	for (i = 0; i < pctl->desc->irq_banks; i++) {
		pctl->irq[i] = platform_get_irq(pdev, i);
		if (pctl->irq[i] < 0) {
			ret = pctl->irq[i];
			goto clk_error;
		}
	}

	pctl->domain = irq_domain_add_linear(node,
					     pctl->desc->irq_banks * IRQ_PER_BANK,
					     &sunxi_pinctrl_irq_domain_ops,
					     pctl);
	if (!pctl->domain) {
		dev_err(&pdev->dev, "Couldn't register IRQ domain\n");
		ret = -ENOMEM;
		goto clk_error;
	}

	for (i = 0; i < (pctl->desc->irq_banks * IRQ_PER_BANK); i++) {
		int irqno = irq_create_mapping(pctl->domain, i);

		irq_set_chip_and_handler(irqno, &sunxi_pinctrl_edge_irq_chip,
					 handle_edge_irq);
		irq_set_chip_data(irqno, pctl);
	}

	for (i = 0; i < pctl->desc->irq_banks; i++) {
		/* Mask and clear all IRQs before registering a handler */
		writel(0, pctl->membase + sunxi_irq_ctrl_reg_from_bank(i,
						pctl->desc->irq_bank_base));
		writel(0xffffffff,
		       pctl->membase + sunxi_irq_status_reg_from_bank(i,
						pctl->desc->irq_bank_base));

		irq_set_chained_handler_and_data(pctl->irq[i],
						 sunxi_pinctrl_irq_handler,
						 pctl);
	}

	dev_info(&pdev->dev, "initialized sunXi PIO driver\n");

	return 0;

clk_error:
	clk_disable_unprepare(clk);
gpiochip_error:
	gpiochip_remove(pctl->chip);
	return ret;
}

{'repo_name': 'libos-nuse/net-next-nuse', 'stars': '238', 'repo_language': 'C', 'file_name': 'nf_tables_netdev.c', 'mime_type': 'text/x-c', 'hash': 1239323347948515500, 'source_dataset': 'data'}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{08DD560A-88E6-4FA3-BEC9-F56966751851}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>CSharpTest23</RootNamespace>
    <AssemblyName>CSharpTest23</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />

  </ItemGroup>
  <ItemGroup>

  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\CSharpTest1\CSharpTest1.csproj">
      <Project>{36436cb1-e611-4567-8bd1-11027019291b}</Project>
      <Name>CSharpTest1</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest2\CSharpTest2.csproj">
      <Project>{686dcb8a-ac16-4f3e-9a40-66e107e38f94}</Project>
      <Name>CSharpTest2</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest3\CSharpTest3.csproj">
      <Project>{0b48846b-657a-483f-9edd-22c10c598487}</Project>
      <Name>CSharpTest3</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest4\CSharpTest4.csproj">
      <Project>{011ce3a9-5dfd-4620-b3e4-c31bf3079a62}</Project>
      <Name>CSharpTest4</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest5\CSharpTest5.csproj">
      <Project>{bf246047-0ece-4679-b32a-a624ec7f0bb9}</Project>
      <Name>CSharpTest5</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest6\CSharpTest6.csproj">
      <Project>{01d1a2f4-4085-44a9-9765-9cac80458322}</Project>
      <Name>CSharpTest6</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest7\CSharpTest7.csproj">
      <Project>{41c4669c-c71d-4065-b5c9-0117483ca66e}</Project>
      <Name>CSharpTest7</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest8\CSharpTest8.csproj">
      <Project>{fff0f4f8-10cd-42e7-8324-bbb4bad9a75f}</Project>
      <Name>CSharpTest8</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest9\CSharpTest9.csproj">
      <Project>{c43b4d7a-546f-4219-a706-483987bc4546}</Project>
      <Name>CSharpTest9</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest10\CSharpTest10.csproj">
      <Project>{01752b43-8c79-4144-928b-67ba72860b40}</Project>
      <Name>CSharpTest10</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest11\CSharpTest11.csproj">
      <Project>{bfae6d68-6115-43b9-b6c9-c34df7dc84e7}</Project>
      <Name>CSharpTest11</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest12\CSharpTest12.csproj">
      <Project>{f26d16e2-9725-4b4f-9437-67834506d773}</Project>
      <Name>CSharpTest12</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest13\CSharpTest13.csproj">
      <Project>{c3a74222-4d1d-42d7-934d-2943dac965cf}</Project>
      <Name>CSharpTest13</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest14\CSharpTest14.csproj">
      <Project>{c9681fca-cc32-44a8-8481-5c887cdb82bf}</Project>
      <Name>CSharpTest14</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest15\CSharpTest15.csproj">
      <Project>{63e55bf4-09ea-440c-ab76-8c7af58da267}</Project>
      <Name>CSharpTest15</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest16\CSharpTest16.csproj">
      <Project>{7566d698-9ef2-45b7-ac6f-a58513280d16}</Project>
      <Name>CSharpTest16</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest17\CSharpTest17.csproj">
      <Project>{f16604e6-2585-4c9b-b378-27904698df79}</Project>
      <Name>CSharpTest17</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest18\CSharpTest18.csproj">
      <Project>{f566d2fc-4f92-4626-98cc-80cb67a55829}</Project>
      <Name>CSharpTest18</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest19\CSharpTest19.csproj">
      <Project>{864b8922-6b0e-426a-bb3a-64b03567f181}</Project>
      <Name>CSharpTest19</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest20\CSharpTest20.csproj">
      <Project>{3363f9c4-18cb-46e6-8e97-8318dc0944af}</Project>
      <Name>CSharpTest20</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest21\CSharpTest21.csproj">
      <Project>{98e82292-46ed-4157-afbe-e806b8a89190}</Project>
      <Name>CSharpTest21</Name>
    </ProjectReference>
    <ProjectReference Include="..\CSharpTest22\CSharpTest22.csproj">
      <Project>{289d0068-582e-47b9-aad6-380690ab1fd8}</Project>
      <Name>CSharpTest22</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

{'repo_name': 'dotnet/fsharp', 'stars': '2323', 'repo_language': 'F#', 'file_name': 'NuGet.targets', 'mime_type': 'text/plain', 'hash': -6527605367381626588, 'source_dataset': 'data'}


# frozen_string_literal: true

source 'https://rubygems.org'
ruby '>= 2.5.0', '< 3.0.0'

gem 'pkg-config', '~> 1.4'

gem 'puma', '~> 5.0'
gem 'rails', '~> 5.2.4.4'
gem 'sprockets', '~> 3.7.2'
gem 'thor', '~> 1.0'
gem 'rack', '~> 2.2.3'

gem 'thwait', '~> 0.2.0'
gem 'e2mmap', '~> 0.1.0'

gem 'hamlit-rails', '~> 0.2'
gem 'pg', '~> 1.2'
gem 'makara', '~> 0.4'
gem 'pghero', '~> 2.7'
gem 'dotenv-rails', '~> 2.7'

gem 'aws-sdk-s3', '~> 1.81', require: false
gem 'fog-core', '<= 2.1.0'
gem 'fog-openstack', '~> 0.3', require: false
gem 'paperclip', '~> 6.0'
gem 'paperclip-av-transcoder', '~> 0.6'
gem 'streamio-ffmpeg', '~> 3.0'
gem 'blurhash', '~> 0.1'

gem 'active_model_serializers', '~> 0.10'
gem 'addressable', '~> 2.7'
gem 'bootsnap', '~> 1.4', require: false
gem 'browser'
gem 'charlock_holmes', '~> 0.7.7'
gem 'iso-639'
gem 'chewy', '~> 5.1'
gem 'cld3', '~> 3.3.0'
gem 'devise', '~> 4.7'
gem 'devise-two-factor', '~> 3.1'

group :pam_authentication, optional: true do
  gem 'devise_pam_authenticatable2', '~> 9.2'
end

gem 'net-ldap', '~> 0.16'
gem 'omniauth-cas', '~> 1.1'
gem 'omniauth-saml', '~> 1.10'
gem 'omniauth', '~> 1.9'

gem 'color_diff', '~> 0.1'
gem 'discard', '~> 1.2'
gem 'doorkeeper', '~> 5.4'
gem 'ed25519', '~> 1.2'
gem 'fast_blank', '~> 1.0'
gem 'fastimage'
gem 'goldfinger', '~> 2.1'
gem 'hiredis', '~> 0.6'
gem 'redis-namespace', '~> 1.8'
gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b799ead604f900ed50685e9b2d469cd2befba5b'
gem 'htmlentities', '~> 4.3'
gem 'http', '~> 4.4'
gem 'http_accept_language', '~> 2.1'
gem 'httplog', '~> 1.4.3'
gem 'idn-ruby', require: 'idn'
gem 'kaminari', '~> 1.2'
gem 'link_header', '~> 0.0'
gem 'mime-types', '~> 3.3.1', require: 'mime/types/columnar'
gem 'nilsimsa', git: 'https://github.com/witgo/nilsimsa', ref: 'fd184883048b922b176939f851338d0a4971a532'
gem 'nokogiri', '~> 1.10'
gem 'nsa', '~> 0.2'
gem 'oj', '~> 3.10'
gem 'ox', '~> 2.13'
gem 'parslet'
gem 'parallel', '~> 1.19'
gem 'posix-spawn'
gem 'pundit', '~> 2.1'
gem 'premailer-rails'
gem 'rack-attack', '~> 6.3'
gem 'rack-cors', '~> 1.1', require: 'rack/cors'
gem 'rails-i18n', '~> 5.1'
gem 'rails-settings-cached', '~> 0.6'
gem 'redis', '~> 4.2', require: ['redis', 'redis/connection/hiredis']
gem 'mario-redis-lock', '~> 1.2', require: 'redis_lock'
gem 'rqrcode', '~> 1.1'
gem 'ruby-progressbar', '~> 1.10'
gem 'sanitize', '~> 5.2'
gem 'sidekiq', '~> 6.1'
gem 'sidekiq-scheduler', '~> 3.0'
gem 'sidekiq-unique-jobs', '~> 6.0'
gem 'sidekiq-bulk', '~>0.2.0'
gem 'simple-navigation', '~> 4.1'
gem 'simple_form', '~> 5.0'
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
gem 'stoplight', '~> 2.2.1'
gem 'strong_migrations', '~> 0.7'
gem 'tty-prompt', '~> 0.22', require: false
gem 'twitter-text', '~> 1.14'
gem 'tzinfo-data', '~> 1.2020'
gem 'webpacker', '~> 5.2'
gem 'webpush'
gem 'webauthn', '~> 3.0.0.alpha1'

gem 'json-ld'
gem 'json-ld-preloaded', '~> 3.1'
gem 'rdf-normalize', '~> 0.4'

group :development, :test do
  gem 'fabrication', '~> 2.21'
  gem 'fuubar', '~> 2.5'
  gem 'i18n-tasks', '~> 0.9', require: false
  gem 'pry-byebug', '~> 3.9'
  gem 'pry-rails', '~> 0.3'
  gem 'rspec-rails', '~> 4.0'
end

group :production, :test do
  gem 'private_address_check', '~> 0.5'
end

group :test do
  gem 'capybara', '~> 3.33'
  gem 'climate_control', '~> 0.2'
  gem 'faker', '~> 2.14'
  gem 'microformats', '~> 4.2'
  gem 'rails-controller-testing', '~> 1.0'
  gem 'rspec-sidekiq', '~> 3.1'
  gem 'simplecov', '~> 0.19', require: false
  gem 'webmock', '~> 3.9'
  gem 'parallel_tests', '~> 3.3'
  gem 'rspec_junit_formatter', '~> 0.4'
end

group :development do
  gem 'active_record_query_trace', '~> 1.7'
  gem 'annotate', '~> 3.1'
  gem 'better_errors', '~> 2.8'
  gem 'binding_of_caller', '~> 0.7'
  gem 'bullet', '~> 6.1'
  gem 'letter_opener', '~> 1.7'
  gem 'letter_opener_web', '~> 1.4'
  gem 'memory_profiler'
  gem 'rubocop', '~> 0.91', require: false
  gem 'rubocop-rails', '~> 2.8', require: false
  gem 'brakeman', '~> 4.9', require: false
  gem 'bundler-audit', '~> 0.7', require: false

  gem 'capistrano', '~> 3.14'
  gem 'capistrano-rails', '~> 1.6'
  gem 'capistrano-rbenv', '~> 2.2'
  gem 'capistrano-yarn', '~> 2.0'

  gem 'stackprof'
end

group :production do
  gem 'lograge', '~> 0.11'
  gem 'redis-rails', '~> 5.0'
end

gem 'concurrent-ruby', require: false
gem 'connection_pool', require: false

{'repo_name': 'tootsuite/mastodon', 'stars': '21475', 'repo_language': 'Ruby', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': -1723758106291474985, 'source_dataset': 'data'}


(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * In addition to the permissions granted to you by the LGPL, you may combine
 * or link a "work that uses the Library" with a publicly distributed version
 * of this file to produce a combined library or application, then distribute
 * that combined work under the terms of your choosing, with no requirement
 * to comply with the obligations normally placed on you by section 4 of the
 * LGPL version 3 (or the corresponding section of a later version of the LGPL
 * should you choose to use a later version).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type command =
  {
    cmd : string ;
    cwd : string ;
    args : string array
  }

val command_fatal_error : command -> int -> unit

val run_command_execv :   command -> int

val remove_dir_recursive : string -> unit

{'repo_name': 'BuckleScript/bucklescript', 'stars': '4752', 'repo_language': 'OCaml', 'file_name': 'generator.mli', 'mime_type': 'text/plain', 'hash': -1721964579911726405, 'source_dataset': 'data'}


{'repo_name': 'microsoft/CDM', 'stars': '662', 'repo_language': 'Java', 'file_name': 'InventTransOriginRAssetScrap_RU.1.0.cdm.json', 'mime_type': 'text/plain', 'hash': -5823328065762088687, 'source_dataset': 'data'}


package m2paxos

import (
	"github.com/ailidani/paxi"
	"github.com/ailidani/paxi/log"
)

// Replica is WPaxos replica node
type Replica struct {
	paxi.Node
	paxi map[paxi.Key]*kpaxos
}

// NewReplica create new Replica instance
func NewReplica(id paxi.ID) *Replica {
	r := new(Replica)
	r.Node = paxi.NewNode(id)
	r.paxi = make(map[paxi.Key]*kpaxos)

	r.Register(paxi.Request{}, r.handleRequest)
	r.Register(Prepare{}, r.handlePrepare)
	r.Register(Promise{}, r.handlePromise)
	r.Register(Accept{}, r.handleAccept)
	r.Register(Accepted{}, r.handleAccepted)
	r.Register(Commit{}, r.handleCommit)
	r.Register(LeaderChange{}, r.handleLeaderChange)
	return r
}

func (r *Replica) init(key paxi.Key) {
	if _, exists := r.paxi[key]; !exists {
		r.paxi[key] = newKPaxos(key, r.Node)
	}
}

func (r *Replica) handleRequest(m paxi.Request) {
	log.Debugf("Replica %s received %v\n", r.ID(), m)
	key := m.Command.Key
	r.init(key)

	p := r.paxi[key]
	if p.IsLeader() || p.Ballot() == 0 {
		p.HandleRequest(m)
		to := p.Hit(m.NodeID)
		if to != "" && to.Zone() != r.ID().Zone() {
			p.Send(to, LeaderChange{
				Key:    key,
				To:     to,
				From:   r.ID(),
				Ballot: p.Ballot(),
			})
		}
	} else {
		go r.Forward(p.Leader(), m)
	}
}

func (r *Replica) handlePrepare(m Prepare) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.Ballot.ID(), m, r.ID())
	r.init(m.Key)
	r.paxi[m.Key].HandleP1a(m.P1a)
}

func (r *Replica) handlePromise(m Promise) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.ID, m, r.ID())
	r.paxi[m.Key].HandleP1b(m.P1b)
}

func (r *Replica) handleAccept(m Accept) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.Ballot.ID(), m, r.ID())
	r.init(m.Key)
	r.paxi[m.Key].HandleP2a(m.P2a)
}

func (r *Replica) handleAccepted(m Accepted) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.ID, m, r.ID())
	r.paxi[m.Key].HandleP2b(m.P2b)
}

func (r *Replica) handleCommit(m Commit) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.Ballot.ID(), m, r.ID())
	r.init(m.Key)
	r.paxi[m.Key].HandleP3(m.P3)
}

func (r *Replica) handleLeaderChange(m LeaderChange) {
	log.Debugf("Replica %s ===[%v]===>>> Replica %s\n", m.From, m, r.ID())
	p := r.paxi[m.Key]
	if m.Ballot == p.Ballot() && m.To == r.ID() {
		// log.Debugf("Replica %s : change leader of key %d\n", r.ID(), m.Key)
		p.P1a()
	}
}

{'repo_name': 'ailidani/paxi', 'stars': '397', 'repo_language': 'Go', 'file_name': 'msg.go', 'mime_type': 'text/plain', 'hash': 2670907211304834939, 'source_dataset': 'data'}