text:
package mods.alice.championglove.utility;

import java.lang.reflect.Field;

public class Reflecter
{
	public static Field getField(Class<?> clazz, String... names)
	{
		Field f = null;

		if(clazz == null)
		{
			//ChampionGlove.log.warning("Class is not specificed.");
			return null;
		}

		for(String name : names)
		{
			if((name == null) || (name.length() == 0))
			{
				break;
			}

			try
			{
				f = clazz.getDeclaredField(name);
				f.setAccessible(true);
			}
			catch(SecurityException e)
			{
				//ChampionGlove.log.severe(String.format("SecurityException is occurred when obtaining field %s from class %s.", name, clazz.getName()));
			}
			catch(NoSuchFieldException e)
			{
				f = null;
			}

			if(f != null)
			{
				break;
			}
		}

		return f;
	}
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.navercorp.pinpoint</groupId>
        <artifactId>pom</artifactId>
        <relativePath>../..</relativePath>
        <version>1.5.0-SNAPSHOT</version>
    </parent>

    <artifactId>pinpoint-servlet-plugin</artifactId>
    <name>pinpoint-servlet-plugin</name>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>com.navercorp.pinpoint</groupId>
            <artifactId>pinpoint-bootstrap-core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>catalina</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>coyote</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>

redpajama_set_name: RedPajamaGithub


text:
#include "safeclib_private.h"
#include "safe_str_constraint.h"
#include "safe_str_lib.h"

/**
 * NAME
 *    strfirstchar_s
 *
 * SYNOPSIS
 *    #include "safe_str_lib.h"
 *    errno_t
 *    strfirstchar_s(char *dest, rsize_t dmax, char c, char **first)
 *
 * DESCRIPTION
 *    This function returns a pointer to the first occurrence
 *    of character c in dest. The scanning stops at the first null
 *    or after dmax characters.
 *
 * EXTENSION TO
 *    ISO/IEC TR 24731, Programming languages, environments
 *    and system software interfaces, Extensions to the C Library,
 *    Part I: Bounds-checking interfaces
 *
 * INPUT PARAMETERS
 *    dest    pointer to string to compare against
 *
 *    dmax    restricted maximum length of string
 *
 *    c       character to locate
 *
 *    first   returned pointer to first occurrence of c
 *
 * OUTPUT PARAMETERS
 *    first   updated pointer to first occurrence of c
 *
 * RUNTIME CONSTRAINTS
 *    dest shall not be a null pointer.
 *    first shall not be a null pointer.
 *    dmax shall not be 0
 *    dmax shall not be greater than RSIZE_MAX_STR
 *
 * RETURN VALUE
 *    pointer to first occurence of c, NULL if not found
 *
 *    EOK         pointer to first occurrence is returned
 *    ESNULLP     NULL pointer
 *    ESZEROL     zero length
 *    ESLEMAX     length exceeds max limit
 *
 * ALSO SEE
 *    strlastchar_s(), strfirstdiff_s(), strfirstsame_s(),
 *    strlastdiff_s(), strlastsame_s(),
 *
 */
errno_t
strfirstchar_s (char *dest, rsize_t dmax, char c, char **first)
{

    if (first == NULL) {
        invoke_safe_str_constraint_handler("strfirstchar_s: index is null",
                   NULL, ESNULLP);
        return (ESNULLP);
    }
    *first = NULL;

    if (dest == NULL) {
        invoke_safe_str_constraint_handler("strfirstchar_s: dest is null",
                   NULL, ESNULLP);
        return (ESNULLP);
    }

    if (dmax == 0 ) {
        invoke_safe_str_constraint_handler("strfirstchar_s: dmax is 0",
                   NULL, ESZEROL);
        return (ESZEROL);
    }

    if (dmax > RSIZE_MAX_STR) {
        invoke_safe_str_constraint_handler("strfirstchar_s: dmax exceeds max",
                   NULL, ESLEMAX);
        return (ESLEMAX);
    }

    while (*dest && dmax) {

        if (*dest == c) {
            *first = dest;
            return (EOK);
        }
        dest++;
        dmax--;
    }

    return (ESNOTFND);
}


text:
from .samples import ExpDecayingSample
from .moving_average import ExpWeightedMovingAvg
from .snapshot import Snapshot


text:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML5 Canvas</title>
</head>
<body>
<canvas id="draw" width="800" height="800"></canvas>
<script>
const canvas = document.querySelector('#draw');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ctx.strokeStyle = '#BADA55';
ctx.lineJoin = 'round';
ctx.lineCap = 'round';
ctx.lineWidth = 50;
ctx.globalCompositeOperation = 'multiply';

let isDrawing = true;
let lastX = 0;
let lastY = 0;
let hue = 0;
let direction = true;

function draw(e){
  if(!isDrawing) return;
  let lineX = e.offsetX;
  let lineY = e.offsetY;
  ctx.strokeStyle = `hsl(${hue},100%,50%)`;
  ctx.beginPath();
  ctx.moveTo(lastX,lastY);
  ctx.lineTo(lineX,lineY);
  ctx.stroke();
  [lastX,lastY] = [e.offsetX,e.offsetY];
  hue++;
  hue %= 361;
  if(direction){
    ctx.lineWidth--;
  }else{
    ctx.lineWidth++;
  }
  // if(ctx.lineWidth<=1){
  //   direction = false;
  // }else if(ctx.lineWidth > 50){
  //   direction = true;
  // }

  if (ctx.lineWidth >= 50 || ctx.lineWidth <= 1) {
    direction = !direction;
  }
  console.log(ctx.lineWidth);
  // hue = (hue++)%360;  //ERROR!
  // if(hue > 360){
  //   hue = 0;
  // }
}

canvas.addEventListener('mousemove',draw,false);
canvas.addEventListener('mousedown',(e) => {
  [lastX,lastY] = [e.offsetX,e.offsetY];
  isDrawing = true;
},false);
canvas.addEventListener('mouseup',() => { isDrawing = false;},false);
canvas.addEventListener('mouseover',() => { isDrawing = false;},false);
</script>

<style>
  html, body {
    margin:0;
  }
</style>

</body>
</html>


text:
<TITLE>Review for Easter Parade (1948)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Easter Parade (1948)

reviewed by
Mattias Thuresson

EASTER PARADE
United States 1948
Director: Charles Walters

Cast: Fred Astaire [Don Hewes], Judy Garland [Hannah Brown],
Peter Lawford [Johnny Harrow], Ann Miller [Nadine Hale]

Rating: 3 out of 5

An MGM musical doesn't come much nicer and
sweeter than Easter Parade. Someone who found
anything in it upsetting should reconsider
what is valuable in life. I think it's
obvious that the production didn't start with
a screenplay, it began with someone thinking:
"Hey, let's do a musical filled with the songs
of Irving Berlin!". The plot between the
singing and dancing is the standard musical
plot: Boy meets girl, boy and girl fall in
love, boy and girl gets seperated, boy and girl
meets again. This time it's Fred Astaire and
Judy Garland as the couple in love.

Don Hewes and Nadine Hale is a dancing team on
various theatres. But Nadine wants to build a
career on her own and leaves him. He picks up
the next dancing girl he meet, Hannah Brown, as his
new dancing partner. Although he falls in love
with her, he keeps their relationship strictly
a business arrangement. Hannah falls in love
with Don but believes incorrectly that he loves
Nadine and that he only keeps her as a temporary
stand-in until Nadine comes back to him.

Gene Kelly was first cast as dancer Don Hewes.
After breaking his ankle he suggested that
he was replaced with Fred Astaire, at the time
in semi-retirement. Production couldn't be delayed,
since Garland was in a good mood and the
producer's was afraid that her mood should change
for the worse. No one seem to have remembered that
Astaire was old enough to be Garland's father.

Fred Astaire was a wonderful dancer and he shows
it in several sequences, most impressively in
"Steppin' Out With my Baby", where an Astaire
in slow motion proves his talent to the audience.
Although Garland got first billing, Astaire is
the one who makes the movie memorable.

Ann Miller plays Astaire's ex-partner Nadine.
Is it a coincidence or did she always play self-
centered unsympathetic roles? Anyway, she
replaced Cyd Charisse who had a broken tendon.
Rumour has it that she (Miller) was dating MGM boss
Louis B. Mayer at the time.

Mattias Thuresson
mattias.thuresson@mbox300.swipnet.se
980414

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
using std::advance;
using std::back_insert_iterator;
using std::back_inserter;
using std::begin;
using std::distance;
using std::end;
using std::insert_iterator;
using std::inserter;
using std::istream_iterator;
using std::iterator_traits;
using std::next;
using std::reverse_iterator;

#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif


text:
'use strict';

const should = require('should');
const request = require('supertest');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));
const { connectionFactory, schemaBuilder } = require('cv-core');
const server = require('../server');
const winston = require('winston');
const config = require('../config');

let location = {};

describe('location test suite', () => {
  before((done) => {
    // create schema
    connectionFactory.sqlite({
      database: config.DATABASE,
      logger: winston,
    })
    .then(conn => schemaBuilder.sqlite(conn)
      .then(() => conn))
    .then(conn => conn.close())
    .then(() => done(null))
    .catch(done);
  });
  beforeEach((done) => {
    location = {
      city: 'Guadalajara',
      country: 'Mex',
    };
    request(server)
      .post('/locations')
      .send(location)
      .expect('Content-Type', /json/)
      .expect(201)
      .then((response) => {
        const { body } = response;
        const { data } = body;
        should(data.id).be.a.Number();
        should(data.id > 0).be.exactly(true);
        location.id = data.id;
        return done(null);
      })
      .catch(done);
  });
  it('get all locations', (done) => {
    request(server)
      .get('/locations')
      .expect('Content-Type', /json/)
      .expect(200)
      .then(({ body }) => {
        const { data: locations } = body;
        should(locations).be.an.Array();
        should(locations).have.length(1);
        should(locations[0]).have.properties([
          'city',
          'id',
          'country',
        ]);
        should(locations[0].city).be.exactly('Guadalajara');
        should(locations[0].country).be.exactly('Mex');
        should(locations[0].id).be.exactly(location.id);
        return done(null);
      })
      .catch(done);
  });
  it('remove location by id not resource found', (done) => {
    request(server)
      .del('/locations/0')
      .expect(404)
      .expect('Content-Type', /json/)
      .then(({ body }) => {
        const { data } = body;
        should(data).be.exactly('Location resource not found');
        return done(null);
      })
      .catch(done);
  });
  it('update location', (done) => {
    request(server)
      .put(`/locations/${location.id}`)
      .send({
        city: 'Colima',
        country: 'Mexico',
      })
      .expect(204)
      .then(() => request(server)
        .get('/locations')
        .expect(200))
      .then(({ body }) => {
        const { data: locations } = body;
        should(locations).be.an.Array();
        should(locations).have.length(1);
        should(locations[0]).have.properties([
          'city',
          'id',
          'country',
        ]);
        should(locations[0].city).be.exactly('Colima');
        should(locations[0].country).be.exactly('Mexico');
        should(locations[0].id).be.exactly(location.id);
        return done(null);
      })
      .catch(done);
  });
  it('create location - throw 500 if invalid paylod', (done) => {
    request(server)
      .post('/locations')
      .send({
        city: 'Guadalajara',
        country: 'Mex2',
      })
      .expect('Content-Type', /json/)
      .expect(500)
      .then((response) => {
        const { body } = response;
        const { message: error } = body;
        should(error).be.a.Object();
        should(error.code).be.exactly('InvalidPayloadError');
        should(error.message).be.exactly('location.country does not conform to the "onlyCharactersAndSpace" format');
        return done(null);
      })
      .catch(done);
  });
  it('update location - throw 500 if invalid payload', (done) => {
    request(server)
      .put(`/locations/${location.id}`)
      .send({
        city: 2,
        country: 'Mex',
      })
      .expect('Content-Type', /json/)
      .expect(500)
      .then((response) => {
        const { body } = response;
        const { message: error } = body;
        should(error).be.a.Object();
        should(error.code).be.exactly('InvalidPayloadError');
        should(error.message).be.exactly('location.city is not of a type(s) string, location.city does not conform to the "onlyCharactersAndSpace" format');
        return done(null);
      })
      .catch(done);
  });
  afterEach((done) => {
    request(server)
      .del(`/locations/${location.id}`)
      .expect(204)
      .then(() => {
        location = null;
        return done(null);
      })
      .catch(done);
  });
  after((done) => {
    fs.unlinkAsync(config.DATABASE)
      .then(() => done(null))
      .catch(done);
  });
});


text:
Hal is a chat bot framework written in the Go programming language.

[![](http://img.shields.io/badge/everything-AWESOME-brightgreen.svg)](http://youtu.be/StTqXEQ2l-Y "Everything status: AWESOME")

## Getting started

["Good morning, Dr. Chandra. This is HAL. I'm ready for my first lesson." ![](http://img.youtube.com/vi/nXgboDb9ucE/0.jpg)](https://www.youtube.com/watch?v=nXgboDb9ucE#t=180 "Good morning, Dr. Chandra. This is HAL. I'm ready for my first lesson.")

Hal is Go all the way down, and uses standard packages wherever possible. For an idea of how you can use it, look at [a simple example](examples/simple/main.go), or [a more complex example](examples/complex/main.go). Please see below for additional resources.

## Resources

* [Project documentation](http://hal.readthedocs.org)
* [API documentation](http://godoc.org/github.com/danryan/hal)
* [Mailing list](https://groups.google.com/group/hal-bot)
* [Bugs and feature requests](https://github.com/danryan/hal/issues)
* IRC - ##hal on irc.freenode.net

## Is it any good?

[Probably not.](http://news.ycombinator.com/item?id=3067434)

## License

Copyright 2014 Applied Awesome LLC.

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.


text:
$context.section('Базовый');
$context.section_begin('fieldset-basic');
$context.section_end('fieldset-basic');

var w = $.ergo({
	etype: 'html:fieldset',
	as: 'border rounded',
	$title: {
		etype: 'html:legend',
		text: 'Заголовок'
	},
	$content: {
		etype: 'box',
		text: LOREMIPSUM
	}
});

w.render('#sample');


text:
// Type definitions for polymer's paper-toast
// Project: https://github.com/Polymer/core-drawer-panel
// Definitions by: Louis Grignon <https://github.com/lgrignon>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

///<reference path="polymer.d.ts"/>

declare module PolymerComponents {
	export module Core {
		export interface DrawerPanel extends PolymerElement, HTMLElement {
			/**
			 * Width of the drawer panel. default: '256px'
			 */
			drawerWidth: string;

			/**
			 * Max-width when the panel changes to narrow layout. default: '640px'
			 */
			responsiveWidth: string;

			/**
			 * The panel that is being selected. drawer for the drawer panel and main for the main panel. default: null
			 */
			selected: string;

			/**
			 * The panel to be selected when core-drawer-panel changes to narrow layout. default: 'main'
			 */
			defaultSelected: string;

			/**
			 * Returns true if the panel is in narrow layout. This is useful if you need to show/hide elements based on the layout. default: false
			 */
			narrow: boolean;

			/**
			 * If true, position the drawer to the right. default: false
			 */
			rightDrawer: boolean;

			/**
			 * If true, swipe to open/close the drawer is disabled. default: false
			 */
			disableSwipe: boolean;

			/**
			 * If true, ignore responsiveWidth setting and force the narrow layout. default: false
			 */
			forceNarrow: boolean;

			/**
			 * If true, swipe from the edge is disabled. default: false
			 */
			disableEdgeSwipe: boolean;

			/**
			 * Toggles the panel open and closed.
			 */
			togglePanel(): void;

			/**
			 * Opens the drawer.
			 */
			openDrawer(): void;

			/**
			 * Closes the drawer.
			 */
			closeDrawer(): void;
		}
	}
}


text:
(function() {
'use strict';

function baz() {
  'use asm';
  function f() {}
  return {f: f};
}

function foo(x) {
  baz(x);
  %DeoptimizeFunction(foo);
};
%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
})();


text:
/* Generated by wayland-scanner 1.11.0 */

#ifndef REMOTE_SHELL_UNSTABLE_V1_CLIENT_PROTOCOL_H
#define REMOTE_SHELL_UNSTABLE_V1_CLIENT_PROTOCOL_H

#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"

#ifdef  __cplusplus
extern "C" {
#endif

/**
 * @page page_remote_shell_unstable_v1 The remote_shell_unstable_v1 protocol
 * Create remote desktop-style surfaces
 *
 * @section page_desc_remote_shell_unstable_v1 Description
 *
 * remote_shell allows clients to turn a wl_surface into a "real window"
 * which can be stacked and activated by the user.
 *
 * Warning! The protocol described in this file is experimental and backward
 * incompatible changes may be made. Backward compatible changes may be added
 * together with the corresponding interface version bump. Backward
 * incompatible changes are done by bumping the version number in the protocol
 * and interface names and resetting the interface version. Once the protocol
 * is to be declared stable, the 'z' prefix and the version number in the
 * protocol and interface names are removed and the interface version number is
 * reset.
 *
 * @section page_ifaces_remote_shell_unstable_v1 Interfaces
 * - @subpage page_iface_zcr_remote_shell_v1 - remote_shell
 * - @subpage page_iface_zcr_remote_surface_v1 - A desktop window
 * - @subpage page_iface_zcr_notification_surface_v1 - A notification window
 * @section page_copyright_remote_shell_unstable_v1 Copyright
 * <pre>
 *
 * Copyright 2016 The Chromium Authors.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 * </pre>
 */
struct wl_surface;
struct zcr_notification_surface_v1;
struct zcr_remote_shell_v1;
struct zcr_remote_surface_v1;

/**
 * @page page_iface_zcr_remote_shell_v1 zcr_remote_shell_v1
 * @section page_iface_zcr_remote_shell_v1_desc Description
 *
 * The global interface that allows clients to turn a wl_surface into a
 * "real window" which is remotely managed but can be stacked, activated
 * and made fullscreen by the user.
 * @section page_iface_zcr_remote_shell_v1_api API
 * See @ref iface_zcr_remote_shell_v1.
 */
/**
 * @defgroup iface_zcr_remote_shell_v1 The zcr_remote_shell_v1 interface
 *
 * The global interface that allows clients to turn a wl_surface into a
 * "real window" which is remotely managed but can be stacked, activated
 * and made fullscreen by the user.
 */
extern const struct wl_interface zcr_remote_shell_v1_interface;
/**
 * @page page_iface_zcr_remote_surface_v1 zcr_remote_surface_v1
 * @section page_iface_zcr_remote_surface_v1_desc Description
 *
 * An interface that may be implemented by a wl_surface, for
 * implementations that provide a desktop-style user interface
 * and allows for remotely managed windows.
 *
 * It provides requests to treat surfaces like windows, allowing to set
 * properties like app id and geometry.
 *
 * The client must call wl_surface.commit on the corresponding wl_surface
 * for the remote_surface state to take effect.
 *
 * For a surface to be mapped by the compositor the client must have
 * committed both an remote_surface state and a buffer.
 * @section page_iface_zcr_remote_surface_v1_api API
 * See @ref iface_zcr_remote_surface_v1.
 */
/**
 * @defgroup iface_zcr_remote_surface_v1 The zcr_remote_surface_v1 interface
 *
 * An interface that may be implemented by a wl_surface, for
 * implementations that provide a desktop-style user interface
 * and allows for remotely managed windows.
 *
 * It provides requests to treat surfaces like windows, allowing to set
 * properties like app id and geometry.
 *
 * The client must call wl_surface.commit on the corresponding wl_surface
 * for the remote_surface state to take effect.
 *
 * For a surface to be mapped by the compositor the client must have
 * committed both an remote_surface state and a buffer.
 */
extern const struct wl_interface zcr_remote_surface_v1_interface;
/**
 * @page page_iface_zcr_notification_surface_v1 zcr_notification_surface_v1
 * @section page_iface_zcr_notification_surface_v1_desc Description
 *
 * An interface that may be implemented by a wl_surface to host
 * notification contents.
 * @section page_iface_zcr_notification_surface_v1_api API
 * See @ref iface_zcr_notification_surface_v1.
 */
/**
 * @defgroup iface_zcr_notification_surface_v1 The zcr_notification_surface_v1 interface
 *
 * An interface that may be implemented by a wl_surface to host
 * notification contents.
 */
extern const struct wl_interface zcr_notification_surface_v1_interface;

#ifndef ZCR_REMOTE_SHELL_V1_CONTAINER_ENUM
#define ZCR_REMOTE_SHELL_V1_CONTAINER_ENUM
/**
 * @ingroup iface_zcr_remote_shell_v1
 * containers for remote surfaces
 *
 * Determine how a remote surface should be stacked relative to other
 * shell surfaces.
 */
enum zcr_remote_shell_v1_container {
	/**
	 * default container
	 */
	ZCR_REMOTE_SHELL_V1_CONTAINER_DEFAULT = 1,
	/**
	 * system modal container
	 */
	ZCR_REMOTE_SHELL_V1_CONTAINER_OVERLAY = 2,
};
#endif /* ZCR_REMOTE_SHELL_V1_CONTAINER_ENUM */

#ifndef ZCR_REMOTE_SHELL_V1_STATE_TYPE_ENUM
#define ZCR_REMOTE_SHELL_V1_STATE_TYPE_ENUM
/**
 * @ingroup iface_zcr_remote_shell_v1
 * state types for remote surfaces
 *
 * Defines common show states for shell surfaces.
 */
enum zcr_remote_shell_v1_state_type {
	/**
	 * normal window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_NORMAL = 1,
	/**
	 * minimized window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_MINIMIZED = 2,
	/**
	 * maximized window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_MAXIMIZED = 3,
	/**
	 * fullscreen window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_FULLSCREEN = 4,
	/**
	 * pinned window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_PINNED = 5,
	/**
	 * trusted pinned window state
	 */
	ZCR_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED = 6,
};
#endif /* ZCR_REMOTE_SHELL_V1_STATE_TYPE_ENUM */

#ifndef ZCR_REMOTE_SHELL_V1_ERROR_ENUM
#define ZCR_REMOTE_SHELL_V1_ERROR_ENUM
enum zcr_remote_shell_v1_error {
	/**
	 * given wl_surface has another role
	 */
	ZCR_REMOTE_SHELL_V1_ERROR_ROLE = 0,
	/**
	 * invalid notification id
	 */
	ZCR_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID = 1,
};
#endif /* ZCR_REMOTE_SHELL_V1_ERROR_ENUM */

#ifndef ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_ENUM
#define ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_ENUM
/**
 * @ingroup iface_zcr_remote_shell_v1
 * the layout mode
 *
 * Determine how a client should layout surfaces.
 */
enum zcr_remote_shell_v1_layout_mode {
	/**
	 * multiple windows
	 */
	ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED = 1,
	/**
	 * restricted mode for tablet
	 */
	ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET = 2,
};
#endif /* ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_ENUM */

/**
 * @ingroup iface_zcr_remote_shell_v1
 * @struct zcr_remote_shell_v1_listener
 */
struct zcr_remote_shell_v1_listener {
	/**
	 * activated surface changed
	 *
	 * Notifies client that the activated surface changed.
	 */
	void (*activated)(void *data,
			  struct zcr_remote_shell_v1 *zcr_remote_shell_v1,
			  struct wl_surface *gained_active,
			  struct wl_surface *lost_active);
	/**
	 * suggests a re-configuration of remote shell
	 *
	 * Suggests a re-configuration of remote shell.
	 */
	void (*configuration_changed)(void *data,
				      struct zcr_remote_shell_v1 *zcr_remote_shell_v1,
				      int32_t width,
				      int32_t height,
				      int32_t transform,
				      wl_fixed_t scale_factor,
				      int32_t work_area_inset_left,
				      int32_t work_area_inset_top,
				      int32_t work_area_inset_right,
				      int32_t work_area_inset_bottom,
				      uint32_t layout_mode);
};

/**
 * @ingroup zcr_remote_shell_v1_iface
 */
static inline int
zcr_remote_shell_v1_add_listener(struct zcr_remote_shell_v1 *zcr_remote_shell_v1,
				 const struct zcr_remote_shell_v1_listener *listener, void *data)
{
	return wl_proxy_add_listener((struct wl_proxy *) zcr_remote_shell_v1,
				     (void (**)(void)) listener, data);
}

#define ZCR_REMOTE_SHELL_V1_DESTROY	0
#define ZCR_REMOTE_SHELL_V1_GET_REMOTE_SURFACE	1
#define ZCR_REMOTE_SHELL_V1_GET_NOTIFICATION_SURFACE	2

/**
 * @ingroup iface_zcr_remote_shell_v1
 */
#define ZCR_REMOTE_SHELL_V1_DESTROY_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_shell_v1
 */
#define ZCR_REMOTE_SHELL_V1_GET_REMOTE_SURFACE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_shell_v1
 */
#define ZCR_REMOTE_SHELL_V1_GET_NOTIFICATION_SURFACE_SINCE_VERSION	1

/** @ingroup iface_zcr_remote_shell_v1 */
static inline void
zcr_remote_shell_v1_set_user_data(struct zcr_remote_shell_v1 *zcr_remote_shell_v1, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) zcr_remote_shell_v1, user_data);
}

/** @ingroup iface_zcr_remote_shell_v1 */
static inline void *
zcr_remote_shell_v1_get_user_data(struct zcr_remote_shell_v1 *zcr_remote_shell_v1)
{
	return wl_proxy_get_user_data((struct wl_proxy *) zcr_remote_shell_v1);
}

static inline uint32_t
zcr_remote_shell_v1_get_version(struct zcr_remote_shell_v1 *zcr_remote_shell_v1)
{
	return wl_proxy_get_version((struct wl_proxy *) zcr_remote_shell_v1);
}

/**
 * @ingroup iface_zcr_remote_shell_v1
 *
 * Destroy this remote_shell object.
 *
 * Destroying a bound remote_shell object while there are surfaces
 * still alive created by this remote_shell object instance is illegal
 * and will result in a protocol error.
 */
static inline void
zcr_remote_shell_v1_destroy(struct zcr_remote_shell_v1 *zcr_remote_shell_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_shell_v1,
			 ZCR_REMOTE_SHELL_V1_DESTROY);

	wl_proxy_destroy((struct wl_proxy *) zcr_remote_shell_v1);
}

/**
 * @ingroup iface_zcr_remote_shell_v1
 *
 * This creates an remote_surface for the given surface and gives it the
 * remote_surface role. A wl_surface can only be given a remote_surface
 * role once. If get_remote_surface is called with a wl_surface that
 * already has an active remote_surface associated with it, or if it had
 * any other role, an error is raised.
 *
 * See the documentation of remote_surface for more details about what an
 * remote_surface is and how it is used.
 */
static inline struct zcr_remote_surface_v1 *
zcr_remote_shell_v1_get_remote_surface(struct zcr_remote_shell_v1 *zcr_remote_shell_v1, struct wl_surface *surface, uint32_t container)
{
	struct wl_proxy *id;

	id = wl_proxy_marshal_constructor((struct wl_proxy *) zcr_remote_shell_v1,
			 ZCR_REMOTE_SHELL_V1_GET_REMOTE_SURFACE, &zcr_remote_surface_v1_interface, NULL, surface, container);

	return (struct zcr_remote_surface_v1 *) id;
}

/**
 * @ingroup iface_zcr_remote_shell_v1
 *
 * Creates a notification_surface for the given surface, gives it the
 * notification_surface role and associated it with a notification id.
 */
static inline struct zcr_notification_surface_v1 *
zcr_remote_shell_v1_get_notification_surface(struct zcr_remote_shell_v1 *zcr_remote_shell_v1, struct wl_surface *surface, const char *notification_id)
{
	struct wl_proxy *id;

	id = wl_proxy_marshal_constructor((struct wl_proxy *) zcr_remote_shell_v1,
			 ZCR_REMOTE_SHELL_V1_GET_NOTIFICATION_SURFACE, &zcr_notification_surface_v1_interface, NULL, surface, notification_id);

	return (struct zcr_notification_surface_v1 *) id;
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 * @struct zcr_remote_surface_v1_listener
 */
struct zcr_remote_surface_v1_listener {
	/**
	 * surface wants to be closed
	 *
	 * The close event is sent by the compositor when the user wants
	 * the surface to be closed. This should be equivalent to the user
	 * clicking the close button in client-side decorations, if your
	 * application has any...
	 *
	 * This is only a request that the user intends to close your
	 * window. The client may choose to ignore this request, or show a
	 * dialog to ask the user to save their data...
	 */
	void (*close)(void *data,
		      struct zcr_remote_surface_v1 *zcr_remote_surface_v1);
	/**
	 * surface state type changed
	 *
	 * The state_type_changed event is sent by the compositor when
	 * the surface state changed.
	 *
	 * This is an event to notify that the window state changed in
	 * compositor. The state change may be triggered by a client's
	 * request, or some user action directly handled by the compositor.
	 * The client may choose to ignore this event.
	 */
	void (*state_type_changed)(void *data,
				   struct zcr_remote_surface_v1 *zcr_remote_surface_v1,
				   uint32_t state_type);
};

/**
 * @ingroup zcr_remote_surface_v1_iface
 */
static inline int
zcr_remote_surface_v1_add_listener(struct zcr_remote_surface_v1 *zcr_remote_surface_v1,
				   const struct zcr_remote_surface_v1_listener *listener, void *data)
{
	return wl_proxy_add_listener((struct wl_proxy *) zcr_remote_surface_v1,
				     (void (**)(void)) listener, data);
}

#define ZCR_REMOTE_SURFACE_V1_DESTROY	0
#define ZCR_REMOTE_SURFACE_V1_SET_APP_ID	1
#define ZCR_REMOTE_SURFACE_V1_SET_WINDOW_GEOMETRY	2
#define ZCR_REMOTE_SURFACE_V1_SET_SCALE	3
#define ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW	4
#define ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW_BACKGROUND_OPACITY	5
#define ZCR_REMOTE_SURFACE_V1_SET_TITLE	6
#define ZCR_REMOTE_SURFACE_V1_SET_TOP_INSET	7
#define ZCR_REMOTE_SURFACE_V1_ACTIVATE	8
#define ZCR_REMOTE_SURFACE_V1_MAXIMIZE	9
#define ZCR_REMOTE_SURFACE_V1_MINIMIZE	10
#define ZCR_REMOTE_SURFACE_V1_RESTORE	11
#define ZCR_REMOTE_SURFACE_V1_FULLSCREEN	12
#define ZCR_REMOTE_SURFACE_V1_UNFULLSCREEN	13
#define ZCR_REMOTE_SURFACE_V1_PIN	14
#define ZCR_REMOTE_SURFACE_V1_UNPIN	15
#define ZCR_REMOTE_SURFACE_V1_SET_SYSTEM_MODAL	16
#define ZCR_REMOTE_SURFACE_V1_UNSET_SYSTEM_MODAL	17
#define ZCR_REMOTE_SURFACE_V1_SET_MOVING	18
#define ZCR_REMOTE_SURFACE_V1_UNSET_MOVING	19

/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_DESTROY_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_APP_ID_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_WINDOW_GEOMETRY_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_SCALE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW_BACKGROUND_OPACITY_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_TITLE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_TOP_INSET_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_ACTIVATE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_MAXIMIZE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_MINIMIZE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_RESTORE_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_FULLSCREEN_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_UNFULLSCREEN_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_PIN_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_UNPIN_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_SYSTEM_MODAL_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_UNSET_SYSTEM_MODAL_SINCE_VERSION	1
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_SET_MOVING_SINCE_VERSION	2
/**
 * @ingroup iface_zcr_remote_surface_v1
 */
#define ZCR_REMOTE_SURFACE_V1_UNSET_MOVING_SINCE_VERSION	2

/** @ingroup iface_zcr_remote_surface_v1 */
static inline void
zcr_remote_surface_v1_set_user_data(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) zcr_remote_surface_v1, user_data);
}

/** @ingroup iface_zcr_remote_surface_v1 */
static inline void *
zcr_remote_surface_v1_get_user_data(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	return wl_proxy_get_user_data((struct wl_proxy *) zcr_remote_surface_v1);
}

static inline uint32_t
zcr_remote_surface_v1_get_version(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	return wl_proxy_get_version((struct wl_proxy *) zcr_remote_surface_v1);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Unmap and destroy the window. The window will be effectively
 * hidden from the user's point of view, and all state will be lost.
 */
static inline void
zcr_remote_surface_v1_destroy(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_DESTROY);

	wl_proxy_destroy((struct wl_proxy *) zcr_remote_surface_v1);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Set an application identifier for the surface.
 */
static inline void
zcr_remote_surface_v1_set_app_id(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, const char *app_id)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_APP_ID, app_id);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * The window geometry of a window is its "visible bounds" from the
 * user's perspective. Client-side decorations often have invisible
 * portions like drop-shadows which should be ignored for the
 * purposes of aligning, placing and constraining windows.
 *
 * The window geometry is double buffered, and will be applied at the
 * time wl_surface.commit of the corresponding wl_surface is called.
 *
 * Once the window geometry of the surface is set once, it is not
 * possible to unset it, and it will remain the same until
 * set_window_geometry is called again, even if a new subsurface or
 * buffer is attached.
 *
 * If never set, the value is the full bounds of the output. This
 * updates dynamically on every commit.
 *
 * The arguments are given in the output coordinate space.
 *
 * The width and height must be greater than zero.
 */
static inline void
zcr_remote_surface_v1_set_window_geometry(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, int32_t x, int32_t y, int32_t width, int32_t height)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_WINDOW_GEOMETRY, x, y, width, height);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Set a scale factor that will be applied to surface and all descendants.
 */
static inline void
zcr_remote_surface_v1_set_scale(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, wl_fixed_t scale)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_SCALE, scale);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface needs a rectangular shadow.
 *
 * This is only a request that the surface should have a rectangular
 * shadow. The compositor may choose to ignore this request.
 *
 * The arguments are given in the output coordinate space and specifies
 * the inner bounds of the shadow.
 *
 * The arguments are given in the output coordinate space.
 * Specifying zero width and height will disable the shadow.
 */
static inline void
zcr_remote_surface_v1_set_rectangular_shadow(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, int32_t x, int32_t y, int32_t width, int32_t height)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW, x, y, width, height);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Suggests the window's background opacity when the shadow is requested.
 */
static inline void
zcr_remote_surface_v1_set_rectangular_shadow_background_opacity(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, wl_fixed_t opacity)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_RECTANGULAR_SHADOW_BACKGROUND_OPACITY, opacity);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Set a short title for the surface.
 *
 * This string may be used to identify the surface in a task bar,
 * window list, or other user interface elements provided by the
 * compositor.
 *
 * The string must be encoded in UTF-8.
 */
static inline void
zcr_remote_surface_v1_set_title(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, const char *title)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_TITLE, title);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Set distance from the top of the surface to the contents.
 *
 * This distance typically represents the size of the window caption.
 */
static inline void
zcr_remote_surface_v1_set_top_inset(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, int32_t height)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_TOP_INSET, height);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Make the surface active and bring it to the front.
 */
static inline void
zcr_remote_surface_v1_activate(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, uint32_t serial)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_ACTIVATE, serial);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is maximized. The window geometry will be updated
 * to whatever the compositor finds appropriate for a maximized window.
 *
 * This is only a request that the window should be maximized. The
 * compositor may choose to ignore this request. The client should
 * listen to set_maximized events to determine if the window was
 * maximized or not.
 */
static inline void
zcr_remote_surface_v1_maximize(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_MAXIMIZE);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is minimized.
 *
 * This is only a request that the window should be minimized. The
 * compositor may choose to ignore this request. The client should
 * listen to set_minimized events to determine if the window was
 * minimized or not.
 */
static inline void
zcr_remote_surface_v1_minimize(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_MINIMIZE);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is restored. This restores the window geometry
 * to what it was before the window was minimized, maximized or made
 * fullscreen.
 *
 * This is only a request that the window should be restored. The
 * compositor may choose to ignore this request. The client should
 * listen to unset_maximized, unset_minimize and unset_fullscreen
 * events to determine if the window was restored or not.
 */
static inline void
zcr_remote_surface_v1_restore(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_RESTORE);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is made fullscreen.
 *
 * This is only a request that the window should be made fullscreen.
 * The compositor may choose to ignore this request. The client should
 * listen to set_fullscreen events to determine if the window was
 * made fullscreen or not.
 */
static inline void
zcr_remote_surface_v1_fullscreen(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_FULLSCREEN);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is made unfullscreen.
 *
 * This is only a request that the window should be made unfullscreen.
 * The compositor may choose to ignore this request. The client should
 * listen to unset_fullscreen events to determine if the window was
 * made unfullscreen or not.
 */
static inline void
zcr_remote_surface_v1_unfullscreen(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_UNFULLSCREEN);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is pinned.
 *
 * This is only a request that the window should be pinned.
 * The compositor may choose to ignore this request. The client should
 * listen to state_changed events to determine if the window was
 * pinned or not. If trusted flag is non-zero, the app can prevent users
 * from exiting the pinned mode.
 */
static inline void
zcr_remote_surface_v1_pin(struct zcr_remote_surface_v1 *zcr_remote_surface_v1, int32_t trusted)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_PIN, trusted);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Request that surface is unpinned.
 *
 * This is only a request that the window should be unpinned.
 * The compositor may choose to ignore this request. The client should
 * listen to unset_pinned events to determine if the window was
 * unpinned or not.
 */
static inline void
zcr_remote_surface_v1_unpin(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_UNPIN);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Suggests a surface should become system modal.
 */
static inline void
zcr_remote_surface_v1_set_system_modal(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_SYSTEM_MODAL);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Suggests a surface should become non system modal.
 */
static inline void
zcr_remote_surface_v1_unset_system_modal(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_UNSET_SYSTEM_MODAL);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Notifies the compositor when an interactive, user-driven move of the
 * surface starts. The compositor may assume that subsequent
 * set_window_geometry requests are position updates until it receives a
 * unset_moving request.
 */
static inline void
zcr_remote_surface_v1_set_moving(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_SET_MOVING);
}

/**
 * @ingroup iface_zcr_remote_surface_v1
 *
 * Notifies the compositor when an interactive, user-driven move of the
 * surface stops. The compositor may choose to stop the move regardless
 * of this request.
 */
static inline void
zcr_remote_surface_v1_unset_moving(struct zcr_remote_surface_v1 *zcr_remote_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_remote_surface_v1,
			 ZCR_REMOTE_SURFACE_V1_UNSET_MOVING);
}

#define ZCR_NOTIFICATION_SURFACE_V1_DESTROY	0

/**
 * @ingroup iface_zcr_notification_surface_v1
 */
#define ZCR_NOTIFICATION_SURFACE_V1_DESTROY_SINCE_VERSION	1

/** @ingroup iface_zcr_notification_surface_v1 */
static inline void
zcr_notification_surface_v1_set_user_data(struct zcr_notification_surface_v1 *zcr_notification_surface_v1, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) zcr_notification_surface_v1, user_data);
}

/** @ingroup iface_zcr_notification_surface_v1 */
static inline void *
zcr_notification_surface_v1_get_user_data(struct zcr_notification_surface_v1 *zcr_notification_surface_v1)
{
	return wl_proxy_get_user_data((struct wl_proxy *) zcr_notification_surface_v1);
}

static inline uint32_t
zcr_notification_surface_v1_get_version(struct zcr_notification_surface_v1 *zcr_notification_surface_v1)
{
	return wl_proxy_get_version((struct wl_proxy *) zcr_notification_surface_v1);
}

/**
 * @ingroup iface_zcr_notification_surface_v1
 *
 * Unmap and destroy the notification surface.
 */
static inline void
zcr_notification_surface_v1_destroy(struct zcr_notification_surface_v1 *zcr_notification_surface_v1)
{
	wl_proxy_marshal((struct wl_proxy *) zcr_notification_surface_v1,
			 ZCR_NOTIFICATION_SURFACE_V1_DESTROY);

	wl_proxy_destroy((struct wl_proxy *) zcr_notification_surface_v1);
}

#ifdef  __cplusplus
}
#endif

#endif


text:
package com.atherton.darren.presentation;

import android.app.Application;

import com.atherton.darren.presentation.injection.component.AppComponent;
import com.atherton.darren.presentation.injection.component.DaggerAppComponent;
import com.atherton.darren.presentation.injection.module.AppModule;

import timber.log.Timber;

public class AndroidApplication extends Application {

    private AppComponent appComponent;

    @Override public void onCreate() {
        super.onCreate();
        initInjection();
        initLogger();
    }

    private void initInjection() {
        appComponent = DaggerAppComponent.builder()
                .appModule(new AppModule(this))
                .build();
    }

    private void initLogger() {
        Timber.plant(new Timber.DebugTree());
    }

    public AppComponent getAppComponent() {
        return appComponent;
    }
}


text:
"Some utility methods"
from __future__ import division

import numpy as np
from numpy import cos
from numpy import pi
from numpy import sin

def parse_units(val, units, name, dtype=float):
    """
    Convert, as necessary, `val` to `units` as `dtype`
    """

    try:
        return val.to(units).value
    except AttributeError:
        pass
    except Exception as inst:
        raise IOError("Bad format for input {}. ({})".
                      format(name, inst))
    try:
        parsed_val = np.array(val).astype(dtype)
        if parsed_val.size == 1:
            return parsed_val.flatten()[0]
        return parsed_val
    except Exception as inst:
        raise IOError("Bad format for input {}. ({})".
                      format(name, inst))

def parse_DM(DM):
    """
    Convert, as necessary, DM into float
    """
    return parse_units(DM, 'pc/cm**3', 'DM')

def parse_lbd(gal_l, gal_b, distance):
    """
    Convert, as necessary, l,b,d into floats

    Parameters
    ----------
    in_l : float or Angle
      Galactic longitude; assumed deg if unitless
    in_b : float
      Galactic latitude; assumed deg if unitless
    in_d : float or Quantity
      Distance to source; assumed kpc if unitless

    Returns
    -------
    gal_l : float
      Galactic longitude in deg
    gal_b : float
      Galactic latitude in deg
    distance : float
      Distance in kpc

    """
    l = parse_units(gal_l, 'deg', 'Galactic longitude')
    b = parse_units(gal_b, 'deg', 'Galactic latitude')
    d = parse_units(distance, 'kpc', 'distance')
    return l, b, d

def galactic_to_galactocentric(l, b, distance, xyz_sun):
    """ Convert galactic coordiantes to galactocentric
    Parameters
    ----------
    l : float
      latitude
    b : float
      longitude
    distance : float
      kpc
    xyz_sun : ndarray
      positions of the Sun in kpc

    Returns
    -------
    xyz_c : ndarray
      x,y,z positions along the sightline

    """
    slc = sin(l/180*pi)
    clc = cos(l/180*pi)
    sbc = sin(b/180*pi)
    cbc = cos(b/180*pi)
    rgalc = distance*cbc
    xc = xyz_sun[0] + rgalc*slc
    yc = xyz_sun[1] - rgalc*clc
    zc = xyz_sun[-1] + distance*sbc
    return np.array([xc, yc, zc])

def lzproperty(attribute):
    """
    Lazy property: evaluate property only once
    """
    save_att = '_' + attribute.__name__

    @property
    def _get(self):
        try:
            return getattr(self, save_att)
        except AttributeError:
            setattr(self, save_att, attribute(self))
        return getattr(self, save_att)
    return _get

def rotation(theta, axis=-1):
    """
    Return a rotation matrix around axis
    0:x, 1:y, 2:z
    """
    ct = cos(theta)
    st = sin(theta)

    if axis in (0, -3):
        return np.array([[1, 0, 0],
                         [0, ct, st],
                         [0, -st, ct]])

    if axis in (1, -2):
        return np.array([[ct, 0, st],
                         [0, 1, 0],
                         [-st, 0, ct]])

    if axis in (2, -1):
        return np.array([[ct, st, 0],
                         [-st, ct, 0],
                         [0, 0, 1]])

def rad3d2(xyz):
    return xyz[0]**2 + xyz[1]**2 + xyz[-1]**2

def rad2d2(xyz):
    return xyz[0]**2 + xyz[1]**2

def matmul(a, b):
    try:
        return a.__matmul__(b)
    except AttributeError:
        return np.matmul(a, b)


text:
// //////////////////////////////////////////////////
// wordWindow object
// //////////////////////////////////////////////////
function wordWindow() {
	// private properties
	this._forms = [];

	// private methods
	this._getWordObject = _getWordObject;
	// this._getSpellerObject = _getSpellerObject;
	this._wordInputStr = _wordInputStr;
	this._adjustIndexes = _adjustIndexes;
	this._isWordChar = _isWordChar;
	this._lastPos = _lastPos;

	// public properties
	this.wordChar = /[a-zA-Z]/;
	this.windowType = "wordWindow";
	this.originalSpellings = new Array();
	this.suggestions = new Array();
	this.checkWordBgColor = "pink";
	this.normWordBgColor = "white";
	this.text = "";
	this.textInputs = new Array();
	this.indexes = new Array();
	// this.speller = this._getSpellerObject();

	// public methods
	this.resetForm = resetForm;
	this.totalMisspellings = totalMisspellings;
	this.totalWords = totalWords;
	this.totalPreviousWords = totalPreviousWords;
	// this.getTextObjectArray = getTextObjectArray;
	this.getTextVal = getTextVal;
	this.setFocus = setFocus;
	this.removeFocus = removeFocus;
	this.setText = setText;
	// this.getTotalWords = getTotalWords;
	this.writeBody = writeBody;
	this.printForHtml = printForHtml;
}

function resetForm() {
	if (this._forms) {
		for (var i = 0; i < this._forms.length; i++) {
			this._forms[i].reset();
		}
	}
	return true;
}

function totalMisspellings() {
	var total_words = 0;
	for (var i = 0; i < this.textInputs.length; i++) {
		total_words += this.totalWords(i);
	}
	return total_words;
}

function totalWords(textIndex) {
	return this.originalSpellings[textIndex].length;
}

function totalPreviousWords(textIndex, wordIndex) {
	var total_words = 0;
	for (var i = 0; i <= textIndex; i++) {
		for (var j = 0; j < this.totalWords(i); j++) {
			if (i == textIndex && j == wordIndex) {
				break;
			} else {
				total_words++;
			}
		}
	}
	return total_words;
}

// function getTextObjectArray() {
// return this._form.elements;
// }

function getTextVal(textIndex, wordIndex) {
	var word = this._getWordObject(textIndex, wordIndex);
	if (word) {
		return word.value;
	}
}

function setFocus(textIndex, wordIndex) {
	var word = this._getWordObject(textIndex, wordIndex);
	if (word) {
		if (word.type == "text") {
			word.focus();
			word.style.backgroundColor = this.checkWordBgColor;
		}
	}
}

function removeFocus(textIndex, wordIndex) {
	var word = this._getWordObject(textIndex, wordIndex);
	if (word) {
		if (word.type == "text") {
			word.blur();
			word.style.backgroundColor = this.normWordBgColor;
		}
	}
}

function setText(textIndex, wordIndex, newText) {
	var word = this._getWordObject(textIndex, wordIndex);
	var beginStr;
	var endStr;
	if (word) {
		var pos = this.indexes[textIndex][wordIndex];
		var oldText = word.value;
		// update the text given the index of the string
		beginStr = this.textInputs[textIndex].substring(0, pos);
		endStr = this.textInputs[textIndex].substring(pos + oldText.length,
				this.textInputs[textIndex].length);
		this.textInputs[textIndex] = beginStr + newText + endStr;

		// adjust the indexes on the stack given the differences in
		// length between the new word and old word.
		var lengthDiff = newText.length - oldText.length;
		this._adjustIndexes(textIndex, wordIndex, lengthDiff);

		word.size = newText.length;
		word.value = newText;
		this.removeFocus(textIndex, wordIndex);
	}
}

function writeBody() {
	var d = window.document;
	var is_html = false;

	d.open();

	// iterate through each text input.
	for (var txtid = 0; txtid < this.textInputs.length; txtid++) {
		var end_idx = 0;
		var begin_idx = 0;
		d.writeln('<form name="textInput' + txtid + '">');
		var wordtxt = this.textInputs[txtid];
		this.indexes[txtid] = [];

		if (wordtxt) {
			var orig = this.originalSpellings[txtid];
			if (!orig)
				break;

			// !!! plain text, or HTML mode?
			d.writeln('
');
			// iterate through each occurrence of a misspelled word.
			for (var i = 0; i < orig.length; i++) {
				// find the position of the current misspelled word,
				// starting at the last misspelled word.
				// and keep looking if it's a substring of another word
				do {
					begin_idx = wordtxt.indexOf(orig[i], end_idx);
					end_idx = begin_idx + orig[i].length;
					// word not found? messed up!
					if (begin_idx == -1)
						break;
					// look at the characters immediately before and after
					// the word. If they are word characters we'll keep looking.
					var before_char = wordtxt.charAt(begin_idx - 1);
					var after_char = wordtxt.charAt(end_idx);
				} while (this._isWordChar(before_char)
						|| this._isWordChar(after_char));

				// keep track of its position in the original text.
				this.indexes[txtid][i] = begin_idx;

				// write out the characters before the current misspelled word
				for (var j = this._lastPos(txtid, i); j < begin_idx; j++) {
					// !!! html mode? make it html compatible
					d.write(this.printForHtml(wordtxt.charAt(j)));
				}

				// write out the misspelled word.
				d.write(this._wordInputStr(orig[i]));

				// if it's the last word, write out the rest of the text
				if (i == orig.length - 1) {
					d.write(printForHtml(wordtxt.substr(end_idx)));
				}
			}

			d.writeln('
');

		}
		d.writeln('</form>');
	}
	// for ( var j = 0; j < d.forms.length; j++ ) {
	// alert( d.forms[j].name );
	// for( var k = 0; k < d.forms[j].elements.length; k++ ) {
	// alert( d.forms[j].elements[k].name + ": " + d.forms[j].elements[k].value
	// );
	// }
	// }

	// set the _forms property
	this._forms = d.forms;
	d.close();
}

// return the character index in the full text after the last word we evaluated
function _lastPos(txtid, idx) {
	if (idx > 0)
		return this.indexes[txtid][idx - 1]
				+ this.originalSpellings[txtid][idx - 1].length;
	else
		return 0;
}

function printForHtml(n) {
	return n; // by FredCK
	/*
	 * var htmlstr = n; if( htmlstr.length == 1 ) { // do simple case statement
	 * if it's just one character switch ( n ) { case "\n": htmlstr = '
';
	 * break; case "<": htmlstr = '<'; break; case ">": htmlstr = '>';
	 * break; } return htmlstr; } else { htmlstr = htmlstr.replace( /</g, '&lt' );
	 * htmlstr = htmlstr.replace( />/g, '&gt' ); htmlstr = htmlstr.replace(
	 * /\n/g, '
' ); return htmlstr; }
	 */

}

function _isWordChar(letter) {
	if (letter.search(this.wordChar) == -1) {
		return false;
	} else {
		return true;
	}
}

function _getWordObject(textIndex, wordIndex) {
	if (this._forms[textIndex]) {
		if (this._forms[textIndex].elements[wordIndex]) {
			return this._forms[textIndex].elements[wordIndex];
		}
	}
	return null;
}

function _wordInputStr(word) {
	var str = '<input readonly ';
	str += 'class="blend" type="text" value="' + word + '" size="'
			+ word.length + '">';
	return str;
}

function _adjustIndexes(textIndex, wordIndex, lengthDiff) {
	for (var i = wordIndex + 1; i < this.originalSpellings[textIndex].length; i++) {
		this.indexes[textIndex][i] = this.indexes[textIndex][i] + lengthDiff;
	}
}


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

    Copyright (C) 2014 Thiago Moreira (tmoreira2020@gmail.com)

    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.

-->

<beans
	default-destroy-method="destroy"
	default-init-method="afterPropertiesSet"
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
	<bean id="liferayHibernateSessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil" factory-method="newBean">
		<constructor-arg value="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration" />
		<constructor-arg>
			<map>
				<entry key="dataSource" value-ref="liferayDataSource" />
			</map>
		</constructor-arg>
	</bean>
	<bean id="liferaySessionFactory" class="com.liferay.portal.kernel.spring.util.SpringFactoryUtil" factory-method="newBean">
		<constructor-arg value="com.liferay.portal.dao.orm.hibernate.PortletSessionFactoryImpl" />
		<constructor-arg>
			<map>
				<entry key="dataSource" value-ref="liferayDataSource" />
				<entry key="sessionFactoryClassLoader" value-ref="portletClassLoader" />
				<entry key="sessionFactoryImplementor" value-ref="liferayHibernateSessionFactory" />
			</map>
		</constructor-arg>
	</bean>
	<bean id="liferayTransactionManager" class="com.liferay.portal.kernel.util.InfrastructureUtil" factory-method="getTransactionManager" />
</beans>


text:
EXTERN_CVAR(Bool, joy_ps2raw)
EXTERN_CVAR(Bool, joy_dinput)
EXTERN_CVAR(Bool, joy_xinput)

// PUBLIC DATA DEFINITIONS -------------------------------------------------

CUSTOM_CVAR(Bool, use_joystick, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
{
#ifdef _WIN32
	joy_ps2raw.Callback();
	joy_dinput.Callback();
	joy_xinput.Callback();
#endif
}

// PRIVATE DATA DEFINITIONS ------------------------------------------------

// Bits 0 is X+, 1 is X-, 2 is Y+, and 3 is Y-.
static BYTE JoyAngleButtons[8] = { 1, 1+4, 4, 2+4, 2, 2+8, 8, 1+8 };

// CODE --------------------------------------------------------------------

//==========================================================================
//
// IJoystickConfig - Virtual Destructor
//
//==========================================================================

IJoystickConfig::~IJoystickConfig()
{
}

//==========================================================================
//
// M_SetJoystickConfigSection
//
// Sets up the config for reading or writing this controller's axis config.
//
//==========================================================================

static bool M_SetJoystickConfigSection(IJoystickConfig *joy, bool create)
{
	FString id = "Joy:";
	id += joy->GetIdentifier();
	return GameConfig->SetSection(id, create);
}

//==========================================================================
//
// M_LoadJoystickConfig
//
//==========================================================================

bool M_LoadJoystickConfig(IJoystickConfig *joy)
{
	char key[32];
	const char *value;
	int axislen;
	int numaxes;

	joy->SetDefaultConfig();
	if (!M_SetJoystickConfigSection(joy, false))
	{
		return false;
	}
	value = GameConfig->GetValueForKey("Sensitivity");
	if (value != NULL)
	{
		joy->SetSensitivity((float)atof(value));
	}
	numaxes = joy->GetNumAxes();
	for (int i = 0; i < numaxes; ++i)
	{
		axislen = mysnprintf(key, countof(key), "Axis%u", i);

		mysnprintf(key + axislen, countof(key) - axislen, "deadzone");
		value = GameConfig->GetValueForKey(key);
		if (value != NULL)
		{
			joy->SetAxisDeadZone(i, (float)atof(value));
		}

		mysnprintf(key + axislen, countof(key) - axislen, "scale");
		value = GameConfig->GetValueForKey(key);
		if (value != NULL)
		{
			joy->SetAxisScale(i, (float)atof(value));
		}

		mysnprintf(key + axislen, countof(key) - axislen, "map");
		value = GameConfig->GetValueForKey(key);
		if (value != NULL)
		{
			EJoyAxis gameaxis = (EJoyAxis)atoi(value);
			if (gameaxis < JOYAXIS_None || gameaxis >= NUM_JOYAXIS)
			{
				gameaxis = JOYAXIS_None;
			}
			joy->SetAxisMap(i, gameaxis);
		}
	}
	return true;
}

//==========================================================================
//
// M_SaveJoystickConfig
//
// Only saves settings that are not at their defaults.
//
//==========================================================================

void M_SaveJoystickConfig(IJoystickConfig *joy)
{
	char key[32], value[32];
	int axislen, numaxes;

	if (M_SetJoystickConfigSection(joy, true))
	{
		GameConfig->ClearCurrentSection();
		if (!joy->IsSensitivityDefault())
		{
			mysnprintf(value, countof(value), "%g", joy->GetSensitivity());
			GameConfig->SetValueForKey("Sensitivity", value);
		}
		numaxes = joy->GetNumAxes();
		for (int i = 0; i < numaxes; ++i)
		{
			axislen = mysnprintf(key, countof(key), "Axis%u", i);

			if (!joy->IsAxisDeadZoneDefault(i))
			{
				mysnprintf(key + axislen, countof(key) - axislen, "deadzone");
				mysnprintf(value, countof(value), "%g", joy->GetAxisDeadZone(i));
				GameConfig->SetValueForKey(key, value);
			}
			if (!joy->IsAxisScaleDefault(i))
			{
				mysnprintf(key + axislen, countof(key) - axislen, "scale");
				mysnprintf(value, countof(value), "%g", joy->GetAxisScale(i));
				GameConfig->SetValueForKey(key, value);
			}
			if (!joy->IsAxisMapDefault(i))
			{
				mysnprintf(key + axislen, countof(key) - axislen, "map");
				mysnprintf(value, countof(value), "%d", joy->GetAxisMap(i));
				GameConfig->SetValueForKey(key, value);
			}
		}
		// If the joystick is entirely at its defaults, delete this section
		// so that we don't write out a lone section header.
		if (GameConfig->SectionIsEmpty())
		{
			GameConfig->DeleteCurrentSection();
		}
	}
}

//===========================================================================
//
// Joy_RemoveDeadZone
//
//===========================================================================

double Joy_RemoveDeadZone(double axisval, double deadzone, BYTE *buttons)
{
	BYTE butt;

	// Cancel out deadzone.
	if (fabs(axisval) < deadzone)
	{
		axisval = 0;
		butt = 0;
	}
	// Make the dead zone the new 0.
	else if (axisval < 0)
	{
		axisval = (axisval + deadzone) / (1.0 - deadzone);
		butt = 2;	// button minus
	}
	else
	{
		axisval = (axisval - deadzone) / (1.0 - deadzone);
		butt = 1;	// button plus
	}
	if (buttons != NULL)
	{
		*buttons = butt;
	}
	return axisval;
}

//===========================================================================
//
// Joy_XYAxesToButtons
//
// Given two axes, returns a button set for them. They should have already
// been sent through Joy_RemoveDeadZone. For axes that share the same
// physical stick, the angle the stick forms should determine whether or
// not the four component buttons are present. Going by deadzone alone gives
// you huge areas where you have to buttons pressed and thin strips where
// you only have one button pressed. For DirectInput gamepads, there is
// not much standard for how the right stick is presented, so we can only
// do this for the left stick for those, since X and Y axes are pretty
// standard. For XInput and Raw PS2 controllers, both sticks are processed
// through here.
//
//===========================================================================

int Joy_XYAxesToButtons(double x, double y)
{
	if (x == 0 && y == 0)
	{
		return 0;
	}
	double rad = atan2(y, x);
	if (rad < 0)
	{
		rad += 2*M_PI;
	}
	// The circle is divided into eight segments for corresponding
	// button combinations. Each segment is pi/4 radians wide. We offset
	// by half this so that the segments are centered around the ideal lines
	// their buttons represent instead of being right on the lines.
	rad += M_PI/8;		// Offset
	rad *= 4/M_PI;		// Convert range from [0,2pi) to [0,8)
	return JoyAngleButtons[int(rad) & 7];
}

//===========================================================================
//
// Joy_GenerateButtonEvents
//
// Provided two bitmasks for a set of buttons, generates events to reflect
// any changes from the old to new set, where base is the key for bit 0,
// base+1 is the key for bit 1, etc.
//
//===========================================================================

void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, int base)
{
	int changed = oldbuttons ^ newbuttons;
	if (changed != 0)
	{
		event_t ev = { 0, 0, 0, 0, 0, 0, 0 };
		int mask = 1;
		for (int j = 0; j < numbuttons; mask <<= 1, ++j)
		{
			if (changed & mask)
			{
				ev.data1 = base + j;
				ev.type = (newbuttons & mask) ? EV_KeyDown : EV_KeyUp;
				D_PostEvent(&ev);
			}
		}
	}
}

void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, const int *keys)
{
	int changed = oldbuttons ^ newbuttons;
	if (changed != 0)
	{
		event_t ev = { 0, 0, 0, 0, 0, 0, 0 };
		int mask = 1;
		for (int j = 0; j < numbuttons; mask <<= 1, ++j)
		{
			if (changed & mask)
			{
				ev.data1 = keys[j];
				ev.type = (newbuttons & mask) ? EV_KeyDown : EV_KeyUp;
				D_PostEvent(&ev);
			}
		}
	}
}


text:
(function () {
    'use strict';

    angular.module('myAppName', [
        'api',
        'app',
        'common',
        'models',
        'ngAnimate',
        'templates'
    ]);

}());
(function () {
    'use strict';

    var API_BASE_URL = '/api';

    function URL() {
        /**
         * @returns a properly formatted url.
         *     Example Usage: URL('my', 'url', '4') === '/{API_BASE_URL}/my/url/4/'
         */
        return function () {
            var url_array = [API_BASE_URL];
            Array.prototype.push.apply(url_array, arguments);
            return url_array.join('/') + '/';
        };
    }

    angular.module('api', [])
        .service('URL', URL);
}());
(function () {
    'use strict';

    function config($stateProvider, $urlRouterProvider) {

        ///////////////////////////
        // Redirects and Otherwise
        ///////////////////////////
        $urlRouterProvider
            .otherwise('/');

        ///////////////////////////
        // State Configurations
        ///////////////////////////

        $stateProvider

            ///////////////////////////
            // App
            ///////////////////////////
            .state('app', {
                url: '/',
                templateUrl: 'app/app.html',
                abstract: true
            })

            ///////////////////////////
            // Home
            ///////////////////////////
            .state('app.home', {
                url: '',
                templateUrl: 'app/home/home.html'
            });
    }
    config.$inject = ["$stateProvider", "$urlRouterProvider"];

    function init($rootScope) {
        $rootScope.debug = true;
    }
    init.$inject = ["$rootScope"];

    angular.module('app', [
        'app.share',
        'app.reasons',
        'ui.router',
        'ngAnimate'
    ])
        .config(config)
        .run(init);
}());
(function () {
    'use strict';

    // This module should depend on all of the common components
    // A common component is a component that will be used
    // in multiple places across your app.

    angular.module('common', [
        'common.autofocus',
        'common.tcons',
        'common.navbar'
    ]);
}());
(function () {
    'use strict';

    angular.module('models', [
        'models.submission'
    ]);
}());
(function () {
    'use strict';

    function stateConfig($stateProvider) {
        $stateProvider
            .state('app.reasons', {
                controller: ["submissions", function (submissions) {
                    this.submissions = submissions;
                }],
                controllerAs: 'reasonsState',
                resolve: {
                    submissions: ["Submission", function (Submission) {
                        return Submission.getList();
                    }]
                },
                template: '<reasons-list ng-model="reasonsState.submissions"></reasons-list>',
                url: 'reasons'
            });
    }
    stateConfig.$inject = ["$stateProvider"];

    angular.module('app.reasons', ['app.reasons.list', 'app.reasons.reason'])
        .config(stateConfig);
}());
(function () {
    'use strict';

    function stateConfig($stateProvider) {
        $stateProvider
            .state('app.share', {
                url: 'share',
                abstract: true,
                template: '<div ui-view></div>'
            })
            .state('app.share.submission', {
                url: '',
                template: '<reason-submission-form></reason-submission-form>'
            })
            .state('app.share.submitted', {
                url: '',
                template: '<reason-submitted></reason-submitted>'
            });
    }
    stateConfig.$inject = ["$stateProvider"];

    angular.module('app.share', [
        'app.share.submission',
        'app.share.submitted',
        'ui.router'
    ])
        .config(stateConfig);
}());
(function () {
    'use strict';

    /*jslint unparam:true*/
    function autoFocus($timeout) {
        return {
            restrict: 'AC',
            link: function (_scope, _element) {
                $timeout(function () {
                    _element[0].focus();
                }, 0);
            }
        };
    }
    autoFocus.$inject = ["$timeout"];

    angular.module('common.autofocus', [])
        .directive('autoFocus', autoFocus);
}());
(function () {
    'use strict';

    function NavbarController($scope, $window) {
        var self = this;
        angular.element($window).bind('scroll', function () {
            if (this.pageYOffset >= 70) {
                self.overlayNavbar = true;
            } else {
                self.overlayNavbar = false;
            }
            $scope.$apply();
        });

        self.isMobileMenuShown = false;
        self.toggleMobileMenu = function () {
            self.isMobileMenuShown = !self.isMobileMenuShown;
        }
    }
    NavbarController.$inject = ["$scope", "$window"];

    function navbar() {
        return {
            controller: NavbarController,
            controllerAs: 'ctrl',
            replace: true,
            restrict: 'E',
            scope: {},
            templateUrl: 'common/navbar/navbar.html'
        };
    }

    angular.module('common.navbar', [])
        .directive('navbar', navbar);

}());
(function (root, factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        // AMD module
        define(factory);
    } else if (typeof exports === 'object') {
        // CommonJS-like environment (i.e. Node)
        module.exports = factory();
    } else {
        // Browser global
        root.transformicons = factory();
        root.transformicons.add('.tcon');
    }
}(this || window, function () {

    // ####################
    // MODULE TRANSFORMICON
    // ####################
    'use strict';

    var
        tcon = {}, // static class
        _transformClass = 'tcon-transform',

        // const
        DEFAULT_EVENTS = {
            transform : ['click'],
            revert : ['click']
        };

    // ##############
    // private methods
    // ##############

    /**
    * Normalize a selector string, a single DOM element or an array of elements into an array of DOM elements.
    * @private
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements
    * @returns {array} Array of DOM elements
    */
    var getElementList = function (elements) {
        if (typeof elements === 'string') {
            return Array.prototype.slice.call(document.querySelectorAll(elements));
        } else if (typeof elements === 'undefined' || elements instanceof Array) {
            return elements;
        } else {
            return [elements];
        }
    };

    /**
    * Normalize a string with eventnames separated by spaces or an array of eventnames into an array of eventnames.
    * @private
    *
    * @param {(string|array)} elements - String with eventnames separated by spaces or array of eventnames
    * @returns {array} Array of eventnames
    */
    var getEventList = function (events) {
        if (typeof events === 'string') {
            return events.toLowerCase().split(' ');
        } else {
            return events;
        }
    };

    /**
    * Attach or remove transformicon events to one or more elements.
    * @private
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be toggled
    * @param {object} [events] - An Object containing one or more special event definitions
    * @param {boolean} [remove=false] - Defines wether the listeners should be added (default) or removed.
    */
    var setListeners = function (elements, events, remove) {
        var
            method = (remove ? 'remove' : 'add') + 'EventListener',
            elementList = getElementList(elements),
            currentElement = elementList.length,
            eventLists = {};

        // get events or use defaults
        for (var prop in DEFAULT_EVENTS) {
            eventLists[prop] = (events && events[prop]) ? getEventList(events[prop]) : DEFAULT_EVENTS[prop];
        }

        // add or remove all events for all occasions to all elements
        while(currentElement--) {
            for (var occasion in eventLists) {
                var currentEvent = eventLists[occasion].length;
                while(currentEvent--) {
                    elementList[currentElement][method](eventLists[occasion][currentEvent], handleEvent);
                }
            }
        }
    };

    /**
    * Event handler for transform events.
    * @private
    *
    * @param {object} event - event object
    */
    var handleEvent = function (event) {
        tcon.toggle(event.currentTarget);
    };

    // ##############
    // public methods
    // ##############

    /**
    * Add transformicon behavior to one or more elements.
    * @public
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be toggled
    * @param {object} [events] - An Object containing one or more special event definitions
    * @param {(string|array)} [events.transform] - One or more events that trigger the transform. Can be an Array or string with events seperated by space.
    * @param {(string|array)} [events.revert] - One or more events that trigger the reversion. Can be an Array or string with events seperated by space.
    * @returns {transformicon} transformicon instance for chaining
    */
    tcon.add = function (elements, events) {
        setListeners(elements, events);
        return tcon;
    };

    /**
    * Remove transformicon behavior from one or more elements.
    * @public
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be toggled
    * @param {object} [events] - An Object containing one or more special event definitions
    * @param {(string|array)} [events.transform] - One or more events that trigger the transform. Can be an Array or string with events seperated by space.
    * @param {(string|array)} [events.revert] - One or more events that trigger the reversion. Can be an Array or string with events seperated by space.
    * @returns {transformicon} transformicon instance for chaining
    */
    tcon.remove = function (elements, events) {
        setListeners(elements, events, true);
        return tcon;
    };

    /**
    * Put one or more elements in the transformed state.
    * @public
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be transformed
    * @returns {transformicon} transformicon instance for chaining
    */
    tcon.transform = function (elements) {
        getElementList(elements).forEach(function(element) {
            element.classList.add(_transformClass);
        });
        return tcon;
    };

    /**
    * Revert one or more elements to the original state.
    * @public
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be reverted
    * @returns {transformicon} transformicon instance for chaining
    */
    tcon.revert = function (elements) {
        getElementList(elements).forEach(function(element) {
            element.classList.remove(_transformClass);
        });
        return tcon;
    };

    /**
    * Toggles one or more elements between transformed and original state.
    * @public
    *
    * @param {(string|element|array)} elements - Selector, DOM element or Array of DOM elements to be toggled
    * @returns {transformicon} transformicon instance for chaining
    */
    tcon.toggle = function (elements) {
        getElementList(elements).forEach(function(element) {
            tcon[element.classList.contains(_transformClass) ? 'revert' : 'transform'](element);
        });
        return tcon;
    };

    return tcon;
}));
(function () {
    'use strict';
    angular.module('common.tcons', [])
        .run(["$timeout", "$window", function ($timeout, $window) {
            $timeout(function () {
                console.log($window);
                $window.transformicons.add('.tcon');
            });
        }]);
}());

(function () {
    'use strict';

    function Submission($q) {
        var self = {};

        self._cache = {
            list: []
        };

        self.getList = function () {
            return $q.resolve(self._cache.list);
        };

        self.save = function (model) {
            /**
             * This function currently just creates a fake submission
             * and assigns it a fake ID based on the number of submissions
             * in the list.
             */
            var submission = angular.copy(model);
            submission.id = self._cache.list.length + 1;
            self._cache.list.push(submission);
            return $q.resolve(submission);
        };

        return self;
    }
    Submission.$inject = ["$q"];

    function loadFixtures($rootScope, Submission) {
        if ($rootScope.debug) {
            Submission.save({
                id: 1,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 2,
                name: 'Zack Browne',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He caerve it. He made a way from Heaven, not to Heaven I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to HeavenI love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'http://media.idownloadblog.com/wp-content/uploads/2012/04/Phil-Schiller-headshot-e1362692403868.jpg'
            });
            Submission.save({
                id: 50,
                name: 'John Doe',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'http://pdnpulse.pdnonline.com/wp-content/uploads/2012/07/Andrew-Fingerman-Headshot.jpg'
            });
            Submission.save({
                id: 25,
                name: 'Alan Thicke',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD bm Heaven, not to Heaven',
                image: 'https://avatars1.githubusercontent.com/u/8485105?v=3&s=460'
            });
            Submission.save({
                id: 5,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
            Submission.save({
                id: 6,
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'My reason is short.',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
        }
    }
    loadFixtures.$inject = ["$rootScope", "Submission"];

    angular.module('models.submission', [])
        .factory('Submission', Submission)
        .run(loadFixtures);
}());
(function () {
    'use strict';

    function ReasonsController() {
        var ctrl = this;
        ctrl.reasons = [];

        ctrl.add = function () {
            ctrl.ngModel.unshift({
                name: 'Jordan Carroll',
                email: 'jcarroll2007@gmail.com',
                age: '23',
                reason: 'I love our LORD because He came to us to save us when we didn\'t deserve it. He made a way from Heaven, not to Heaven',
                image: 'https://scontent-atl3-1.xx.fbcdn.net/hphotos-xta1/v/t1.0-9/12342504_10208675592032047_2237316667569290936_n.jpg?oh=66cfdbe0967533875b661dbf8281e94b&oe=574BE051'
            });
        };
    }

    function reasonsList() {
        return {
            controller: ReasonsController,
            controllerAs: 'ctrl',
            bindToController: true,
            restrict: 'E',
            scope: {
                ngModel: '='
            },
            templateUrl: 'app/reasons/list/list.html'
        };
    }

    angular.module('app.reasons.list', ['akoenig.deckgrid'])
        .directive('reasonsList', reasonsList);

}());
(function () {
    'use strict';

    function ReasonController() {
        this.test = 'test';
    }

    function reason() {
        return {
            controller: ReasonController,
            controllerAs: 'ctrl',
            bindToController: {
                ngModel: '=?'
            },
            restrict: 'E',
            scope: {},
            templateUrl: 'app/reasons/reason/reason.html'
        };
    }

    angular.module('app.reasons.reason', [])
        .directive('reason', reason);
}());
(function () {
    'use strict';

    function ReasonSubmissionController(Submission, $state) {
        var ctrl = this;

        ctrl.submission = {};

        ctrl.isSubmitting = false;
        ctrl.submit = function () {
            ctrl.isSubmitting = true;
            Submission.save(ctrl.submission)
                .then(function () {
                    $state.go('app.share.submitted');
                });
        };
    }
    ReasonSubmissionController.$inject = ["Submission", "$state"];

    function reasonSubmissionForm() {
        return {
            controller: ReasonSubmissionController,
            controllerAs: 'submission',
            restrict: 'E',
            templateUrl: 'app/share/submission/submission.html'
        };
    }

    angular.module('app.share.submission', [
        'api'
    ])
        .directive('reasonSubmissionForm', reasonSubmissionForm);
}());
(function () {
    'use strict';

    function ReasonSubmittedController() {
        this.test = 'test';
    }

    function reasonSubmitted() {
        return {
            controller: ReasonSubmittedController,
            controllerAs: 'submitted',
            restrict: 'E',
            templateUrl: 'app/share/submitted/submitted.html'
        };
    }

    angular.module('app.share.submitted', [
        'api'
    ])
        .directive('reasonSubmitted', reasonSubmitted);
}());