text:
<!DOCTYPE html>

	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="author" content="SemiColonWeb" />

	<link href="http://fonts.googleapis.com/css?family=Lato:300,400,400italic,600,700|Raleway:300,400,500,600,700|Crete+Round:400italic" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
	<link rel="stylesheet" href="style.css" type="text/css" />
	<link rel="stylesheet" href="css/dark.css" type="text/css" />
	<link rel="stylesheet" href="css/font-icons.css" type="text/css" />
	<link rel="stylesheet" href="css/animate.css" type="text/css" />
	<link rel="stylesheet" href="css/magnific-popup.css" type="text/css" />

	<link rel="stylesheet" href="css/responsive.css" type="text/css" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />

	<link rel="stylesheet" type="text/css" href="include/rs-plugin/css/settings.css" media="screen" />
	<link rel="stylesheet" type="text/css" href="include/rs-plugin/css/layers.css">
	<link rel="stylesheet" type="text/css" href="include/rs-plugin/css/navigation.css">

	<title>Revolution Slider - HTML5 Videos | Canvas</title>

Home

Home - Corporate

Corporate - Layout 1

Corporate - Layout 2

Corporate - Layout 3

Corporate - Layout 4

Home - Portfolio

Portfolio - Layout 1

Portfolio - Layout 2

Portfolio - Masonry

Portfolio - AJAX

Home - Blog

Blog - Layout 1

Blog - Layout 2

Blog - Layout 3

Home - Shop

Shop - Layout 1

Shop - Layout 2

Home - Magazine

Magazine - Layout 1

Magazine - Layout 2

Magazine - Layout 3

Home - Landing Page

Landing Page - Layout 1

Landing Page - Layout 2

Landing Page - Layout 3

Landing Page - Layout 4

Landing Page - Layout 5

Home - Full Screen

Full Screen - Image

Full Screen - Slider

Full Screen - Video

Home - One Page

One Page - Default

One Page - Submenu

One Page - Dots Style

Home - Wedding

Home - Restaurant

Home - Events

Home - Parallax

Home - App Showcase

Home - Boxed Layout

Features

Sliders

Revolution Slider

Premium Templates

Full Screen

Full Width

Kenburns Effect

HTML5 Video

Canvas Slider

Full Width

Fade Transition

Autoplay Feature

Custom Video Event

Pagination Navigation

3 Columns

4 Columns

5 Columns

Flex Slider

Default Layout

with Thumbs

Owl Slider

Full Width

Boxed Width

Video Slider

Static Media

Static - Parallax

Static - Image

Static - Thumb Gallery

Static - HTML5 Video

Static - Embedded Video

Camera Slider

Elastic Slider

Nivo Slider

Widgets

Links

Flickr Photostream

Dribbble Shots

Instagram Feed

Posts List

Twitter Feed

Tabbed Widgets

Carousel

Subscribers

Social Icons

Testimonials

Quick Contact

Tags Cloud

Video Embeds

Raw Text/HTML

Headers

Light Version

Dark Version

Transparent

Semi Transparent

Light Version

Dark Version

Left Side Header

Fixed Position

OnClick Open

Push Content

Right Side Header

Fixed Position

OnClick Open

Push Content

Floating Version

Static Sticky

Responsive Sticky

Alternate Logos

Alternate Mobile Menu

Side Panel

Left Overlay

Left Push

Right Overlay

Right Push

Light Background

Mega Menu

Menu Styles

Menu - Style 1

Menu - Style 2

Menu - Style 3

Menu - Style 4

Menu - Style 5

Menu - Style 6

Menu - Style 7

Menu - Style 8

Menu - Style 9

Menu - Overlay

Menu - Split Layout

Page Titles

Left Align

Right Align

Center Align

Dark Style

Pattern Background

Parallax Background

Default Header

Transparent Header

HTML5 Video

No Background

Mini Version

Contact Pages

Contact 1

Contact 2

Contact 3

Contact 4

Contact 5

Contact 6

Contact 7

Footers

Sticky Footer

Footer - Layout 1

Footer - Layout 2

Footer - Layout 3

Footer - Layout 4

Footer - Layout 5

Footer - Layout 6

Footer - Layout 7

Events

Full Width Calendar

Events List

Right Sidebar

Left Sidebar

Both Sidebar

Full Width

Parallax List

Single Event

Right Sidebar

Left Sidebar

Both Sidebar

Full Width

Single Event - Full

Parallax Image

Google Map

Slider Gallery

HTML5 Video

Modal OnLoad

Simple Layout

Video iFrame

Subscription Form

Common Height

Cookies Enabled

Coming Soon

Simple Layout

Parallax Image

HTML5 Video

User Profile

Pages

Introduction

About Us

About Us - Layout 2

About Me

Team Members

Careers

Side Navigation

Page Submenu

Sitemap

Utility

Services - Layout 1

Services - Layout 2

Services - Layout 3

FAQs - Layout 1

FAQs - Layout 2

FAQs - Layout 3

FAQs - Layout 4

Maintenance Page

Layout Grids

Full Width

Full Width - Wide

Right Sidebar

Left Sidebar

Both Sidebar

Both Right Sidebar

Both Left Sidebar

Blank Page

Miscellaneous

Login/Register

Login/Register - Style 2

Login/Register - Style 3

Login - Style 1

Login - Style 2

404 - Simple Layout

404 - Parallax Image

404 - HTML5 Video

Portfolio

Grids

1 Column

2 Columns

3 Columns

4 Columns

5 Columns

6 Columns

Masonry

Mixed Columns

2 Columns

3 Columns

4 Columns

5 Columns

6 Columns

Loading Styles

jQuery Filter

jQuery Pagination

Infinity Scroll

AJAX In Page

AJAX In Modal

Filter Styles

Single Project

Extended Item

Parallax Image

Slider Gallery

HTML5 Video

Masonry Thumbs

Embed Video

Layouts

Default

Right Sidebar

Left Sidebar

Both Sidebar

100% Width

Parallax

Blog

Default

Right Sidebar

Left Sidebar

Both Sidebar

Full Width

Timeline

Right Sidebar

Left Sidebar

Full Width

Masonry

4 Columns

3 Columns

2 Columns

100% Width

Grid

4 Columns

3 Columns

2 Columns

Small Thumbs

Left Sidebar

Right Sidebar

Both Sidebar

Full Width

Alternate Layout

Item Splitting

Pagination

Infinite Scroll

Single

Default Layout

Left Sidebar

Full Width

Small Image

Split Layout

Comments Module

Facebook Comments

Disqus Comments

Shop

4 Columns

3 Columns

Full Width

Right Sidebar

Left Sidebar

2 Columns

Right Sidebar

Left Sidebar

Both Sidebar

1 Columns

Full Width

Right Sidebar

Left Sidebar

Both Sidebar

Categories - Parallax

Combination Filter

Single Product

Full Width

Right Sidebar

Left Sidebar

Both Sidebar

Cart

Checkout

Shortcodes

Animations

Buttons

Carousel

Charts

Clients

Columns

Counters

Data Tables

Date & Time Pickers

Dividers

Icon Boxes

Galleries

Heading Styles

Icon Lists

Labels

Lightbox

Editable Fields

File Uploads

Lists & Panels

Maps

Media Embeds

Modal Boxes

Navigations

Pagination

Pies & Skills

Range Slider

Star Ratings

Pricing Boxes

Process Steps

Promo Boxes

Blockquotes

Responsive

Sections

Social Icons

Select Picker

Select Boxes

Alert Boxes

Styled Icons

Tables

Tabs

Testimonials

Thumbnails

Toggles

Radios & Switches

Input Typeahead

							5

Shopping Cart

											Blue Round-Neck Tshirt
											$19.99
											x 2

											Light Blue Denim Dress
											$24.99
											x 3

									$114.95
									<button class="button button-3d button-small nomargin fright">View Cart</button>

							<form action="search.html" method="get">
								<input type="text" name="q" class="form-control" value="" placeholder="Type & Hit Enter..">
							</form>

								<div class="tp-fade fadeout fullscreenvideo rs-background-video-layer"
									data-forcerewind="on"
									data-volume="mute"
									data-videowidth="100%"
									data-videoheight="100%"
									data-videomp4="http://revcdn1.themepunch.com/wp-content/uploads//2015/07/iceberg.mp4"
									data-videopreload="preload"
									data-videoloop="none"
									data-forceCover="1"
									data-aspectratio="16:9"
									data-autoplay="true"
									data-autoplayonlyfirsttime="false"
									data-nextslideatend="true"
						 			style="z-index: 2;">

								<div class="tp-caption customin ltl tp-resizeme revo-slider-caps-text uppercase"
								data-x="600"
								data-y="235"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1000"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; color: #FFF; white-space: nowrap;">Hello There!

								<div class="tp-caption customin ltl tp-resizeme revo-slider-emphasis-text nopadding noborder"
								data-x="600"
								data-y="260"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1200"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; color: #FFF; font-size: 60px; white-space: nowrap;">Welcome to Canvas

								<div class="tp-caption customin ltl tp-resizeme revo-slider-desc-text tleft"
								data-x="600"
								data-y="360"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1600"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; color: #FFF; max-width: 550px; white-space: normal;">The most Beautiful & Performance Friendly Theme available on the Envato Marketplaces.

								<div class="tp-caption customin ltl tp-resizeme"
								data-x="600"
								data-y="470"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1550"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3;">Start Tour

								<div class="tp-fade fadeout fullscreenvideo rs-background-video-layer"
									data-forcerewind="on"
									data-volume="mute"
									data-videowidth="100%"
									data-videoheight="100%"
									data-videomp4="http://revcdn1.themepunch.com/wp-content/uploads//2015/07/space.mp4"
									data-videopreload="preload"
									data-videoloop="none"
									data-forceCover="1"
									data-aspectratio="16:9"
									data-autoplay="true"
									data-autoplayonlyfirsttime="false"
									data-nextslideatend="true">

								<div class="tp-caption customin ltl tp-resizeme revo-slider-emphasis-text uppercase"
								data-x="203"
								data-y="235"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1000"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; white-space: nowrap;">Mobile Ready Design

								<div class="tp-caption customin ltl tp-resizeme revo-slider-desc-text"
								data-x="245"
								data-y="400"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1200"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; max-width: 650px; white-space: normal;">Completely Responsive & Retina Ready Design built on the amazing Bootstrap Framework.

								<div class="tp-caption customin ltl tp-resizeme"
								data-x="495"
								data-y="503"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1350"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3;">Read More

								<div class="tp-caption customin ltl tp-resizeme revo-slider-caps-text uppercase"
								data-x="453"
								data-y="235"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1000"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; white-space: nowrap;">Why Choose Canvas?

								<div class="tp-caption customin ltl tp-resizeme revo-slider-emphasis-text nopadding noborder"
								data-x="264"
								data-y="260"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1200"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; white-space: nowrap;">Unlimited Possibilities

								<div class="tp-caption customin ltl tp-resizeme revo-slider-desc-text"
								data-x="245"
								data-y="370"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1400"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3; max-width: 650px; white-space: normal;">Create whatever you require for your Business to bloom with Tons of Customization Possibilities.

								<div class="tp-caption customin ltl tp-resizeme"
								data-x="508"
								data-y="478"
								data-customin="x:0;y:150;z:0;rotationZ:0;scaleX:1;scaleY:1;skewX:0;skewY:0;transformPerspective:200;transformOrigin:50% 0%;"
								data-speed="800"
								data-start="1550"
								data-easing="easeOutQuad"
								data-splitin="none"
								data-splitout="none"
								data-elementdelay="0.01"
								data-endelementdelay="0.1"
								data-endspeed="1000"
								data-endeasing="Power4.easeIn" style="z-index: 3;">Browse

Call us today at +91.22.57412541 or Email us at support@canvas.com

						We strive to provide Our Customers with Top Notch Support to make their Theme Experience Wonderful
						Browse Now

Responsive Layout

Powerful Layout with Responsive functionality that can be adapted to any screen size. Resize browser to view.

Retina Ready Graphics

Looks beautiful & ultra-sharp on Retina Screen Displays. Retina Icons, Fonts & all others graphics are optimized.

Powerful Performance

Canvas includes tons of optimized code that are completely customizable and deliver unmatched fast performance.

Premium Sliders Included

Canvas included 20+ custom designed Slider Pages with Premium Sliders like Layer, Revolution, Swiper & others.

Unlimited Color Options

Change the color scheme of the Theme in a flash just by changing the 6-digit HEX code in the colors.php file.

CUSTOMIZABLE FONTS

Use any Font you like from Google Web Fonts, Typekit or other Web Fonts. They will blend in perfectly.

We believe in Simple, Creative & Flexible Design Standards.

									<address>
										Headquarters:

										795 Folsom Ave, Suite 600

										San Francisco, CA 94107

									</address>
									Phone: (91) 8547 632521

									Fax: (91) 11 4752 1433

									Email: info@canvas.com

Blogroll

Documentation

Feedback

Plugins

Support Forums

Themes

WordPress Blog

WordPress Planet

Recent Posts

Lorem ipsum dolor sit amet, consectetur

10th July 2014

Elit Assumenda vel amet dolorum quasi

10th July 2014

Debitis nihil placeat, illum est nisi

10th July 2014

Total Downloads

Clients

Subscribe to Our Newsletter to get Important News, Amazing Offers & Inside Scoops:

							<form id="widget-subscribe-form" action="include/subscribe.php" role="form" method="post" class="nobottommargin">

									<input type="email" id="widget-subscribe-form-email" name="widget-subscribe-form-email" class="form-control required email" placeholder="Enter your Email">

										<button class="btn btn-success" type="submit">Subscribe</button>

							</form>

									Like us
on Facebook

									Subscribe
to RSS Feeds

						Copyrights © 2014 All Rights Reserved by Canvas Inc.

Terms of Use / Privacy Policy

						 info@canvas.com ·  +91-11-6541-6369 ·  CanvasOnSkype


text:
// Copyright (c) 2016 Antony Arciuolo. See License.txt regarding use.

// Encapsulation of parsing a string representing a file on a local hard drive.

#pragma once
#include <oString/fixed_string.h>
#include <oString/path_traits.h>
#include <oCore/stringize.h>
#include <functional>

namespace ouro {

template<typename charT, typename traitsT = default_posix_path_traits<charT>>
class basic_path_t
{
public:
	static const size_t Capacity = oMAX_PATH;
	typedef typename traitsT traits;
	typedef typename traits::char_type char_type;
	typedef size_t hash_type;
	typedef size_t size_type;
	typedef path_string string_type;
	typedef std::pair<const char_type*, const char_type*> string_piece_type;

	typedef const char_type(&const_array_ref)[Capacity];

	basic_path_t() { clear(); }
	basic_path_t(const char_type* start, const char_type* end) : p(start, end) { parse(); }
	basic_path_t(const char_type* that) { operator=(that); }
	basic_path_t(const basic_path_t& that) { operator=(that); }
	basic_path_t& operator=(const basic_path_t& that) { return operator=(that.c_str()); }
	basic_path_t& operator=(const char_type* that)
	{
		if (that)
		{
			p = that;
			parse();
		}
		else
			clear();
		return *this;
	}

	// modifiers

	void clear()
	{
		p.clear();
		length_ = 0;
		root_dir_offset_ = parent_end_offset_ = basename_offset_ = extension_offset_ = npos;
		has_root_name_ = ends_with_sep_ = false;
		hash_ = 0;
	}

	basic_path_t& assign(const char_type* start, const char_type* end) { p.assign(start, end); parse(); return *this; }

	basic_path_t& append(const char_type* path_element, bool ensure_separator = true)
	{
		if (ensure_separator && !traits::is_sep(*path_element) && !ends_with_sep_ && p.length())
			p.append(traits::generic_sep_str());
		p.append(path_element);
		parse();
		return *this;
	}

	basic_path_t& append(const char_type* start, const char_type* end, bool ensure_separator = true)
	{
		if (ensure_separator && !traits::is_sep(*start) && !ends_with_sep_ && p.length())
			p.append(traits::generic_sep_str());
		p.append(start, end);
		parse();
		return *this;
	}

	basic_path_t& append(const string_piece_type& string_piece, bool ensure_separator = true) { return append(string_piece.first, string_piece.second, ensure_separator); }

	void swap(basic_path_t& that)
	{
		if (this != &that)
		{
			std::swap(p, that.p);
			std::swap(root_dir_offset_, that.root_dir_offset_);
			std::swap(parent_end_offset_, that.parent_end_offset_);
			std::swap(basename_offset_, that.basename_offset_);
			std::swap(extension_offset_, that.extension_offset_);
			std::swap(has_root_name_, that.has_root_name_);
			std::swap(ends_with_sep_, that.ends_with_sep_);
		}
	}

	basic_path_t operator/(const basic_path_t& that) const
	{
		basic_path_t path(*this);
		return path /= that;
	}

	basic_path_t operator/(const char_type* that) const
	{
		basic_path_t path(*this);
		return path.append(that);
	}

	basic_path_t& operator/=(const char_type* that)
	{
		append(that);
		return *this;
	}

	basic_path_t& replace_extension(const char_type* new_ext = traits::empty_str())
	{
		if (has_extension()) p[extension_offset_] = 0;
		if (new_ext && !traits::is_dot(new_ext[0])) p.append(traits::dot_str());
		p.append(new_ext);
		parse();
		return *this;
	}

	basic_path_t& replace_extension(const string_type& new_ext)
	{
		return replace_extension(new_ext.c_str());
	}

	basic_path_t& replace_extension_with_suffix(const char_type* new_ext = traits::empty_str())
	{
		if (has_extension()) p[extension_offset_] = 0;
		p.append(new_ext);
		parse();
		return *this;
	}

	basic_path_t& replace_extension_with_suffix(const string_type& new_ext)
	{
		return replace_extension_with_suffix(new_ext.c_str());
	}

	basic_path_t& replace_filename(const char_type* new_filename = traits::empty_str())
	{
		if (basename_offset_ != npos)
			p[basename_offset_] = 0;
		else if (extension_offset_ != npos)
			p[extension_offset_] = 0;
		p.append(new_filename);
		parse();
		return *this;
	}

	basic_path_t& replace_filename(const string_type& new_filename)
	{
		return replace_filename(new_filename.c_str());
	}

	basic_path_t& replace_filename(const basic_path_t& new_filename)
	{
		return replace_filename(new_filename.c_str());
	}

	basic_path_t& remove_filename()
	{
		if (basename_offset_ != npos)
		{
			p[basename_offset_] = 0;
			parse();
		}
		else if (ends_with_sep_)
		{
			ends_with_sep_ = false;
			p[p.length()-1] = 0;
			parse();
		}
		return *this;
	}

	// Inserts text after basename and before extension
	basic_path_t& insert_basename_suffix(const char_type* new_suffix)
	{
		auto tmp = extension();
		if (has_extension())
			p[extension_offset_] = 0;
		p.append(new_suffix);
		p.append(tmp);
		parse();
		return *this;
	}

	basic_path_t& insert_basename_suffix(const string_type& new_suffix)
	{
		return insert_basename_suffix(new_suffix.c_str());
	}

	basic_path_t& remove_basename_suffix(const char_type* suffix)
	{
		if (has_basename() && suffix)
		{
			string_type s = suffix;
			char_type* ext = has_extension() ? &p[extension_offset_] : nullptr;
			if (ext) s += ext;
			char_type* suf = ext ? ext : &p[basename_offset_];
			while (*suf && suf < ext) suf++; // move to end of basename
			suf -= strlen(suffix);
			if (suf >= p.c_str())
			{
				if (!traits::compare(suf, s))
				{
					*suf = 0;
					p.append(ext);
					parse();
				}
			}
		}

		return *this;
	}

	basic_path_t& remove_basename_suffix(const string_type& suffix)
	{
		return remove_basename_suffix(suffix.c_str());
	}

	// decomposition
	const_array_ref c_str() const { return (const_array_ref)p; }
	operator const char_type*() const { return p; }
	operator string_type() const { return p; }

	#define NULL_STR_PIECE string_piece_type(p.c_str(), p.c_str())
	string_piece_type string_piece() const { return string_piece_type(p.c_str(), p.c_str() + length_); }
	string_piece_type root_path_piece() const { return has_root_name() ? (has_root_directory() ? string_piece_type(p.c_str(), p.c_str() + root_dir_offset_ + 1) : string_piece()) : (traits::has_vol(p) ? NULL_STR_PIECE : root_directory_piece()); }
	string_piece_type root_name_piece() const { return has_root_name_ ? (has_root_directory() ? string_piece_type(p.c_str(), p.c_str() + root_dir_offset_) : string_piece()) : NULL_STR_PIECE; }
	string_piece_type root_directory_piece() const { return has_root_directory() ? string_piece_type(p.c_str() + root_dir_offset_, p.c_str() + root_dir_offset_ + 1) : NULL_STR_PIECE; }
	string_piece_type relative_path_piece() const { const char* first = after_seps(p.c_str() + (has_root_directory() ? root_dir_offset_ + 1 : 0)); return string_piece_type(first, first + length_); }
	string_piece_type parent_path_piece() const { return has_parent_path() ? string_piece_type(p.c_str(), p.c_str() + parent_end_offset_) : NULL_STR_PIECE; }
	string_piece_type basename_piece() const { return has_basename() ? (string_piece_type(p.c_str() + basename_offset_, has_extension() ? (p.c_str() + extension_offset_) : (p.c_str() + length_))) : NULL_STR_PIECE; }
	string_piece_type filename_piece() const { return ends_with_sep_ ? string_piece_type(traits::dot_str(), traits::dot_str() + 1) : (basename_offset_ != npos ? string_piece_type(p.c_str() + basename_offset_, p.c_str() + length_) : string_piece()); }
	string_piece_type extension_piece() const { return has_extension() ? string_piece_type(p.c_str() + extension_offset_, p.c_str() + length_) : NULL_STR_PIECE; }
	#undef NULL_STR_PIECE

	basic_path_t string() const { string_piece_type sp = string_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t root_path() const { string_piece_type sp = root_path_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t root_name() const { string_piece_type sp = root_name_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t root_directory() const { string_piece_type sp = root_directory_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t relative_path() const { string_piece_type sp = relative_path_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t parent_path() const { string_piece_type sp = parent_path_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t basename() const { string_piece_type sp = basename_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t filename() const { string_piece_type sp = filename_piece(); return basic_path_t(sp.first, sp.second); }
	basic_path_t extension() const { string_piece_type sp = extension_piece(); return basic_path_t(sp.first, sp.second); }

	// All elements up to extension
	string_type stem() const { return has_extension() ? (has_basename() ? string_type(p.c_str(), p.c_str() + extension_offset_) : string_type()) : p; }

	// All elements up to and including the left-most colon
	string_type prefix() const { return traits::has_vol(p) ? string_type(p.c_str(), p.c_str() + 2) : string_type(); }

	// query
	/* constexpr */ size_type capacity() const { return Capacity; }
	bool empty() const { return p.empty(); }
	bool has_root_path() const { return has_root_directory() || has_root_name(); }
	bool has_root_name() const { return has_root_name_; }
	bool has_root_directory() const { return root_dir_offset_ != npos; }
	bool has_relative_path() const { return !p.empty() && has_root_directory() && !traits::is_sep(p[0]) && !p[1]; }
	bool has_parent_path() const { return parent_end_offset_ != 0 && parent_end_offset_ != npos; }
	bool has_filename() const { return has_basename() || has_extension(); }

	bool is_absolute() const { return (has_root_directory() && !traits::posix && has_root_name());  }
	bool is_windows_absolute() const { return is_absolute() || base_path_traits<char_type, false>::has_vol(p);  } // it is too annoying to live without this
	bool is_relative() const { return !is_absolute(); }
	bool is_windows_relative() const { return !is_windows_absolute(); }
	bool is_unc() const { return traits::is_unc(p); }
	bool is_windows_unc() const { return base_path_traits<char_type, false>::is_unc(p); }
	bool has_basename() const { return basename_offset_ != npos; }
	bool has_extension() const { return extension_offset_ != npos; }
	bool has_extension(const char_type* _Extension) const { return _Extension && traits::is_dot(*_Extension) && has_extension() ? !traits::compare(&p[extension_offset_], _Extension) : false; }

	hash_type hash() const { return hash_; }

	// Returns similar to strcmp/stricmp depending on path_traits. NOTE: A clean
	// and unclean path will not compare to be the same.
	int compare(const basic_path_t& that) const { return traits::compare(this->c_str(), that.c_str()); }
	int compare(const char_type* that) const { return traits::compare(this->c_str(), that); }

	bool is_relative_to(const char* root) const
	{
		if (root && *root)
		{
			size_t cmn_len = cmnroot(p, root);
			if (cmn_len)
			{
				size_t nseps = 0;
				size_t index = cmn_len + 1;
				while (root[index])
				{
					if (traits::is_sep(root[index]))
						return false;
					index++;
				}
			}
		}
		return true;
	}

	basic_path_t relative_path(const char* root) const
	{
		basic_path_t rel;
		if (root && *root)
		{
			size_t cmn_len = cmnroot(p, root);
			if (cmn_len)
			{
				size_t nseps = 0;
				size_t index = cmn_len + 1;
				while (root[index])
				{
					if (traits::is_sep(root[index]))
						nseps++;
					index++;
				}
				for (size_t i = 0; i < nseps; i++)
				{
					rel.p.append(traits::dotdot_str());
					rel.p.append(traits::generic_sep_str());
				}

				rel.ends_with_sep_ = !!nseps;
			}

			const char* src = (*this).c_str() + cmn_len;
			if (traits::is_sep(*src))
				src++;
			rel /= src;
		}
		return rel;
	}

private:
	typedef unsigned short index_type;
	static const index_type npos = ~0u & 0xffff;
	unsigned short idx(const char_type* _PtrIntoP) { return _PtrIntoP ? static_cast<unsigned short>(std::distance((const char_type*)p, _PtrIntoP)) : npos; }

	hash_type hash_;
	string_type p;
	index_type root_dir_offset_; // index of first non-root-name slash
	index_type parent_end_offset_; // index of first right-most slash backed up past any redundant slashes
	index_type basename_offset_; // index of just after right-most slash
	index_type extension_offset_; // index of right-most dot
	index_type length_; // or offset of nul terminator
	bool has_root_name_;
	bool ends_with_sep_;

	static const char_type* after_seps(const char_type* p) { while (*p && traits::is_sep(*p)) p++; return p; }
	static const char_type* to_sep(const char_type* p) { while (*p && !traits::is_sep(*p)) p++; return p; }
	static const char_type* find_root_directory(const char_type* path, const char_type* root_name)
	{
		const char_type* dir = root_name;
		if (dir)
		{
			dir = after_seps(dir); // move past unc seps
			dir = to_sep(dir); // move past unc name
			if (!*dir) dir = nullptr; // if after-unc sep, then no rootdir
		}

		else if (traits::is_sep(path[0])) // rootdir is has_root_name() || is_sep(p[0])
			dir = path;
		return dir;
	}

	void parse()
	{
		if (traits::always_clean) clean_path(p, p);
		const char_type *rootname = nullptr, *path = nullptr, *parentend = nullptr, *base = nullptr, *ext = nullptr;
		length_ = static_cast<index_type>(tsplit_path<char_type>(p, traits::posix, &rootname, &path, &parentend, &base, &ext));
		has_root_name_ = !!rootname;
		basename_offset_ = idx(base);
		extension_offset_ = idx(ext);
		root_dir_offset_ = idx(find_root_directory(p, rootname));
		parent_end_offset_ = idx(parentend);
		ends_with_sep_ = length_ > 1 && traits::is_sep(p[length_-1]);
		hash_ = fnv1a<hash_type>(p);
	}
};

typedef basic_path_t<char> posix_path_t;
typedef basic_path_t<wchar_t> posix_wpath_t;

typedef basic_path_t<char, default_windows_path_traits<char>> windows_path_t;
typedef basic_path_t<wchar_t, default_windows_path_traits<wchar_t>> windows_wpath_t;

typedef posix_path_t path_t;
typedef posix_wpath_t wpath_t;

template<typename charT, typename traitsT>
char* to_string(char* dst, size_t dst_size, const basic_path_t<charT, traitsT>& value)
{
	try { ((const basic_path_t<charT, traitsT>::string_type&)value).copy_to(dst, dst_size); }
	catch (std::exception&) { return nullptr; }
	return dst;
}

template<typename charT, typename traitsT>
bool from_string(basic_path_t<charT, traitsT>* out_value, const char* src)
{
	try { *out_value = src; }
	catch (std::exception&) { return false; }
	return true;
}

}

namespace std {

template<typename charT, typename traitsT>
struct hash<ouro::basic_path_t<charT, traitsT>> { std::size_t operator()(const ouro::basic_path_t<charT, traitsT>& path) const { return path.hash(); } };

}

redpajama_set_name: RedPajamaGithub


text:
namespace media {
namespace cast {
// Settings chosen to match default sender settings.
#define DEFAULT_SEND_PORT "2346"
#define DEFAULT_RECEIVE_PORT "2344"
#define DEFAULT_SEND_IP "127.0.0.1"
#define DEFAULT_RESTART "0"
#define DEFAULT_AUDIO_FEEDBACK_SSRC "1"
#define DEFAULT_AUDIO_INCOMING_SSRC "2"
#define DEFAULT_AUDIO_PAYLOAD_TYPE "127"
#define DEFAULT_VIDEO_FEEDBACK_SSRC "12"
#define DEFAULT_VIDEO_INCOMING_SSRC "11"
#define DEFAULT_VIDEO_PAYLOAD_TYPE "96"
#define DEFAULT_VIDEO_CODEC_WIDTH "640"
#define DEFAULT_VIDEO_CODEC_HEIGHT "480"
#define DEFAULT_VIDEO_CODEC_BITRATE "2000"

static const int kAudioSamplingFrequency = 48000;
#if defined(OS_LINUX)
const int kVideoWindowWidth = 1280;
const int kVideoWindowHeight = 720;
#endif  // OS_LINUX
static const int kFrameTimerMs = 33;

void GetPorts(int* tx_port, int* rx_port) {
  test::InputBuilder tx_input("Enter send port.",
      DEFAULT_SEND_PORT, 1, INT_MAX);
  *tx_port = tx_input.GetIntInput();

  test::InputBuilder rx_input("Enter receive port.",
      DEFAULT_RECEIVE_PORT, 1, INT_MAX);
  *rx_port = rx_input.GetIntInput();
}

std::string GetIpAddress(const std::string display_text) {
 test::InputBuilder input(display_text, DEFAULT_SEND_IP,
      INT_MIN, INT_MAX);
  std::string ip_address = input.GetStringInput();
  // Ensure correct form:
  while (std::count(ip_address.begin(), ip_address.end(), '.') != 3) {
    ip_address = input.GetStringInput();
  }
  return ip_address;
}

void GetSsrcs(AudioReceiverConfig* audio_config) {
  test::InputBuilder input_tx("Choose audio sender SSRC.",
      DEFAULT_AUDIO_FEEDBACK_SSRC, 1, INT_MAX);
  audio_config->feedback_ssrc = input_tx.GetIntInput();

  test::InputBuilder input_rx("Choose audio receiver SSRC.",
      DEFAULT_AUDIO_INCOMING_SSRC, 1, INT_MAX);
  audio_config->incoming_ssrc = input_tx.GetIntInput();
}

void GetSsrcs(VideoReceiverConfig* video_config) {
  test::InputBuilder input_tx("Choose video sender SSRC.",
      DEFAULT_VIDEO_FEEDBACK_SSRC, 1, INT_MAX);
  video_config->feedback_ssrc = input_tx.GetIntInput();

  test::InputBuilder input_rx("Choose video receiver SSRC.",
      DEFAULT_VIDEO_INCOMING_SSRC, 1, INT_MAX);
  video_config->incoming_ssrc = input_rx.GetIntInput();
}

void GetPayloadtype(AudioReceiverConfig* audio_config) {
  test::InputBuilder input("Choose audio receiver payload type.",
      DEFAULT_AUDIO_PAYLOAD_TYPE, 96, 127);
  audio_config->rtp_payload_type = input.GetIntInput();
}

AudioReceiverConfig GetAudioReceiverConfig() {
  AudioReceiverConfig audio_config;

  GetSsrcs(&audio_config);
  GetPayloadtype(&audio_config);

  audio_config.rtcp_c_name = "audio_receiver@a.b.c.d";

  VLOG(1) << "Using OPUS 48Khz stereo";
  audio_config.use_external_decoder = false;
  audio_config.frequency = 48000;
  audio_config.channels = 2;
  audio_config.codec = kOpus;
  return audio_config;
}

void GetPayloadtype(VideoReceiverConfig* video_config) {
  test::InputBuilder input("Choose video receiver payload type.",
      DEFAULT_VIDEO_PAYLOAD_TYPE, 96, 127);
  video_config->rtp_payload_type = input.GetIntInput();
}

VideoReceiverConfig GetVideoReceiverConfig() {
  VideoReceiverConfig video_config;

  GetSsrcs(&video_config);
  GetPayloadtype(&video_config);

  video_config.rtcp_c_name = "video_receiver@a.b.c.d";

  video_config.use_external_decoder = false;

  VLOG(1) << "Using VP8";
  video_config.codec = kVp8;
  return video_config;
}

class ReceiveProcess : public base::RefCountedThreadSafe<ReceiveProcess> {
 public:
  explicit ReceiveProcess(scoped_refptr<FrameReceiver> frame_receiver)
    : frame_receiver_(frame_receiver),
#if defined(OS_LINUX)
      render_(0, 0, kVideoWindowWidth, kVideoWindowHeight, "Cast_receiver"),
#endif // OS_LINUX
      last_playout_time_(),
      last_render_time_() {}

  void Start() {
    GetAudioFrame(base::TimeDelta::FromMilliseconds(kFrameTimerMs));
    GetVideoFrame();
  }

 protected:
  virtual ~ReceiveProcess() {}

 private:
  friend class base::RefCountedThreadSafe<ReceiveProcess>;

  void DisplayFrame(const scoped_refptr<media::VideoFrame>& video_frame,
      const base::TimeTicks& render_time) {
#ifdef OS_LINUX
    render_.RenderFrame(video_frame);
#endif // OS_LINUX
    // Print out the delta between frames.
    if (!last_render_time_.is_null()){
        base::TimeDelta time_diff = render_time - last_render_time_;
        VLOG(0) << " RenderDelay[mS] =  " << time_diff.InMilliseconds();
    }
    last_render_time_ = render_time;
    GetVideoFrame();
  }

  void ReceiveAudioFrame(scoped_ptr<PcmAudioFrame> audio_frame,
                         const base::TimeTicks& playout_time) {
    // For audio just print the playout delta between audio frames.
    // Default diff time is kFrameTimerMs.
    base::TimeDelta time_diff =
        base::TimeDelta::FromMilliseconds(kFrameTimerMs);
    if (!last_playout_time_.is_null()){
        time_diff = playout_time - last_playout_time_;
        VLOG(0) << " ***PlayoutDelay[mS] =  " << time_diff.InMilliseconds();
    }
    last_playout_time_ = playout_time;
    GetAudioFrame(time_diff);
  }

  void GetAudioFrame(base::TimeDelta playout_diff) {
    int num_10ms_blocks = playout_diff.InMilliseconds() / 10;
    frame_receiver_->GetRawAudioFrame(num_10ms_blocks, kAudioSamplingFrequency,
        base::Bind(&ReceiveProcess::ReceiveAudioFrame, this));
  }

  void GetVideoFrame() {
    frame_receiver_->GetRawVideoFrame(
        base::Bind(&ReceiveProcess::DisplayFrame, this));
  }

  scoped_refptr<FrameReceiver> frame_receiver_;
#ifdef OS_LINUX
  test::LinuxOutputWindow render_;
#endif // OS_LINUX
  base::TimeTicks last_playout_time_;
  base::TimeTicks last_render_time_;
};

}  // namespace cast
}  // namespace media

int main(int argc, char** argv) {
  base::AtExitManager at_exit;
  base::MessageLoopForIO main_message_loop;
  VLOG(1) << "Cast Receiver";
  base::Thread main_thread("Cast main send thread");
  base::Thread audio_thread("Cast audio decoder thread");
  base::Thread video_thread("Cast video decoder thread");
  main_thread.Start();
  audio_thread.Start();
  video_thread.Start();

  base::DefaultTickClock clock;
  // Enable receiver side threads, and disable logging.
  scoped_refptr<media::cast::CastEnvironment> cast_environment(new
      media::cast::CastEnvironment(&clock,
                                   main_thread.message_loop_proxy(),
                                   NULL,
                                   audio_thread.message_loop_proxy(),
                                   NULL,
                                   video_thread.message_loop_proxy(),
                                   media::cast::GetDefaultCastLoggingConfig()));

  media::cast::AudioReceiverConfig audio_config =
      media::cast::GetAudioReceiverConfig();
  media::cast::VideoReceiverConfig video_config =
      media::cast::GetVideoReceiverConfig();

  scoped_ptr<media::cast::test::Transport> transport(
      new media::cast::test::Transport(main_message_loop.message_loop_proxy()));
  scoped_ptr<media::cast::CastReceiver> cast_receiver(
      media::cast::CastReceiver::CreateCastReceiver(
      cast_environment,
      audio_config,
      video_config,
      transport->packet_sender()));

  media::cast::PacketReceiver* packet_receiver =
      cast_receiver->packet_receiver();

  int send_to_port, receive_port;
  media::cast::GetPorts(&send_to_port, &receive_port);
  std::string ip_address = media::cast::GetIpAddress("Enter destination IP.");
  std::string local_ip_address = media::cast::GetIpAddress("Enter local IP.");
  transport->SetLocalReceiver(packet_receiver, ip_address, local_ip_address,
                              receive_port);
  transport->SetSendDestination(ip_address, send_to_port);

  scoped_refptr<media::cast::ReceiveProcess> receive_process(
      new media::cast::ReceiveProcess(cast_receiver->frame_receiver()));
  receive_process->Start();
  main_message_loop.Run();
  transport->StopReceiving();
  return 0;
}


text: module.exports = require('./lib/imaging.js')


text:
import zope.schema
import zope.app.locking.interfaces

class ILockInfo(zope.app.locking.interfaces.ILockInfo):
    """Extended LockInfo interface."""

    locked_until = zope.schema.Datetime(
        title=u"Locked Until",
        required=False)


text:
from gzip import GzipFile

from unittest import TestCase

from marrow.util.compat import IO, unicode
from marrow.wsgi.egress.compression import CompressionFilter

_status = b"200 OK"
_body = b"a" * 1000

class TestCompressionFilter(TestCase):
    def setUp(self):
        self.filter = CompressionFilter()

    def mock_headers(self, length=None, disable=False, mime=b"text/plain"):
        headers = [(b'Content-Type', mime)] if mime else []

        if length is not None:
            headers.append((b'Content-Length', unicode(length).encode('ascii')))

        if disable:
            headers.append((b'Content-Encoding', b'mock'))

        return headers

    def mock_environ(self, enable=True, disable=False, async=False):
        environ = {
                'wsgi.multiprocess': False,
                'wsgi.multithread': False,
                'wsgi.run_once': True,
                'wsgi.version': (2, 0),
            }

        if enable:
            environ['HTTP_ACCEPT_ENCODING'] = b'gzip'

        if disable:
            environ['wsgi.compression'] = False

        if async:
            environ['wsgi.async'] = True

        return environ

    def find(self, header, headers):
        """Determine the value and index into headers for the given header, or None if not found."""

        for i, (name, value) in enumerate(headers):
            if name.lower() == header:
                return value, i

        return None, None

    def decompress(self, body):
        buf = IO()

        for chunk in body:
            buf.write(chunk)

        buf.seek(0)

        gzfile = GzipFile(mode='rb', fileobj=buf)
        data = gzfile.read()
        gzfile.close()

        del buf
        del gzfile

        return data

    def test_functional(self):
        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(len(_body)), [_body])
        assert int(self.find(b'content-length', headers)[0]) < len(_body), "Content didn't shrink."
        self.assertEquals(_body, self.decompress(body))

        _, headers, body = self.filter(self.mock_environ(async=True), _status, self.mock_headers(len(_body)), [_body])
        self.assertEquals(_body, self.decompress(body))

    def test_disabled(self):
        _, headers, body = self.filter(self.mock_environ(disable=True), _status, self.mock_headers(len(_body)), [_body])
        self.assertEquals(_body, b''.join(body))

        def gen():
            yield _body

        _, headers, body = self.filter(self.mock_environ(async=True), _status, self.mock_headers(len(_body)), gen)
        self.assertEquals(_body, b''.join(body()))

        _, headers, body = self.filter(self.mock_environ(enable=False), _status, self.mock_headers(len(_body)), [_body])
        self.assertEquals(_body, b''.join(body))

        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(len(_body), disable=True), [_body])
        self.assertEquals(_body, b''.join(body))

    def test_mimetypes(self):
        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(len(_body), mime=None), [_body])
        self.assertEquals(_body, b''.join(body))

        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(len(_body), mime=b"application/gzip"), [_body])
        self.assertEquals(_body, b''.join(body))

        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(len(_body), mime=b'video/mpeg4'), [_body])
        self.assertEquals(_body, b''.join(body))

    def test_inefficient(self):
        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(1), [b'a'])
        assert int(self.find(b'content-length', headers)[0]) > 1, "Content didn't grow in size."
        self.assertEquals(b'a', self.decompress(body))

    def test_edge(self):
        _, headers, body = self.filter(self.mock_environ(), _status, self.mock_headers(), [_body])
        self.assertEquals(_body, self.decompress(body))
        self.assertNotEqual((None, None), self.find(b'content-length', headers))


text:
namespace open_spiel {
namespace ludii {

Game::Game(JNIEnv *env, jobject game, std::string game_path)
    : env(env), game(game), game_path(game_path) {}

std::string Game::GetPath() const { return game_path; }

jobject Game::GetObj() const { return game; }

std::string Game::GetName() const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID name_id =
      env->GetMethodID(gameClass, "name", "()Ljava/lang/String;");
  jstring stringArray = (jstring)env->CallObjectMethod(game, name_id);

  // convert jstring game name to char array
  const char *strReturn = env->GetStringUTFChars(stringArray, 0);
  std::string string_name(strReturn);
  env->ReleaseStringUTFChars(stringArray, strReturn);

  return string_name;
}

void Game::Create(int viewSize) const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID create_id = env->GetMethodID(gameClass, "create", "(I)V");
  env->CallVoidMethod(game, create_id, viewSize);
}

int Game::StateFlags() const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID stateFlags_id = env->GetMethodID(gameClass, "stateFlags", "()I");
  return (int)env->CallIntMethod(game, stateFlags_id);
}

Mode Game::GetMode() const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID mode_id = env->GetMethodID(gameClass, "mode", "()Lgame/mode/Mode;");
  jobject mode = env->CallObjectMethod(game, mode_id);
  return Mode(env, mode);
}

void Game::Start(Context context) const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID start_id =
      env->GetMethodID(gameClass, "start", "(Lutil/Context;)V");
  env->CallVoidMethod(game, start_id, context.GetObj());
}

Moves Game::GetMoves(Context context) const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID moves_id = env->GetMethodID(
      gameClass, "moves", "(Lutil/Context;)Lgame/rules/play/moves/Moves;");
  jobject moves_obj = env->CallObjectMethod(game, moves_id, context.GetObj());
  jclass clsObj = env->GetObjectClass(context.GetObj());

  return Moves(env, moves_obj);
}

Move Game::Apply(Context context, Move move) const {
  jclass gameClass = env->FindClass("game/Game");
  jmethodID apply_id = env->GetMethodID(
      gameClass, "apply", "(Lutil/Context;Lutil/Move;)Lutil/Move;");
  jobject move_obj =
      env->CallObjectMethod(game, apply_id, context.GetObj(), move.GetObj());

  return Move(env, move_obj);
}

}  // namespace ludii
}  // namespace open_spiel


text:
<?php

final class DiffusionGitUploadPackWireProtocol
  extends DiffusionGitWireProtocol {

  private $readMode = 'length';
  private $readBuffer;
  private $readFrameLength;
  private $readFrames = array();

  private $readFrameMode = 'refs';
  private $refFrames = array();

  private $readMessages = array();

  public function willReadBytes($bytes) {
    if ($this->readBuffer === null) {
      $this->readBuffer = new PhutilRope();
    }
    $buffer = $this->readBuffer;

    $buffer->append($bytes);

    while (true) {
      $len = $buffer->getByteLength();
      switch ($this->readMode) {
        case 'length':
          // We're expecting 4 bytes containing the length of the protocol
          // frame as hexadecimal in ASCII text, like "01ab". Wait until we
          // see at least 4 bytes on the wire.
          if ($len < 4) {
            if ($len > 0) {
              $bytes = $this->peekBytes($len);
              if (!preg_match('/^[0-9a-f]+\z/', $bytes)) {
                throw new Exception(
                  pht(
                    'Bad frame length character in Git protocol ("%s"), '.
                    'expected a 4-digit hexadecimal value encoded as ASCII '.
                    'text.',
                    $bytes));
              }
            }

            // We can't make any more progress until we get enough bytes, so
            // we're done with state processing.
            break 2;
          }

          $frame_length = $this->readBytes(4);
          $frame_length = hexdec($frame_length);

          // Note that the frame length includes the 4 header bytes, so we
          // usually expect a length of 5 or larger. Frames with length 0
          // are boundaries.
          if ($frame_length === 0) {
            $this->readFrames[] = $this->newProtocolFrame('null', '');
          } else if ($frame_length >= 1 && $frame_length <= 3) {
            throw new Exception(
              pht(
                'Encountered Git protocol frame with unexpected frame '.
                'length (%s)!',
                $frame_length));
          } else {
            $this->readFrameLength = $frame_length - 4;
            $this->readMode = 'frame';
          }

          break;
        case 'frame':
          // We're expecting a protocol frame of a specified length. Note that
          // it is possible for a frame to have length 0.

          // We don't have enough bytes yet, so wait for more.
          if ($len < $this->readFrameLength) {
            break 2;
          }

          if ($this->readFrameLength > 0) {
            $bytes = $this->readBytes($this->readFrameLength);
          } else {
            $bytes = '';
          }

          // Emit a protocol frame.
          $this->readFrames[] = $this->newProtocolFrame('data', $bytes);
          $this->readMode = 'length';
          break;
      }
    }

    while (true) {
      switch ($this->readFrameMode) {
        case 'refs':
          if (!$this->readFrames) {
            break 2;
          }

          foreach ($this->readFrames as $key => $frame) {
            unset($this->readFrames[$key]);

            if ($frame['type'] === 'null') {
              $ref_frames = $this->refFrames;
              $this->refFrames = array();

              $ref_frames[] = $frame;

              $this->readMessages[] = $this->newProtocolRefMessage($ref_frames);
              $this->readFrameMode = 'passthru';
              break;
            } else {
              $this->refFrames[] = $frame;
            }
          }

          break;
        case 'passthru':
          if (!$this->readFrames) {
            break 2;
          }

          $this->readMessages[] = $this->newProtocolDataMessage(
            $this->readFrames);
          $this->readFrames = array();

          break;
      }
    }

    $wire = array();
    foreach ($this->readMessages as $key => $message) {
      $wire[] = $message;
      unset($this->readMessages[$key]);
    }
    $wire = implode('', $wire);

    return $wire;
  }

  public function willWriteBytes($bytes) {
    return $bytes;
  }

  private function readBytes($count) {
    $buffer = $this->readBuffer;

    $bytes = $buffer->getPrefixBytes($count);
    $buffer->removeBytesFromHead($count);

    return $bytes;
  }

  private function peekBytes($count) {
    $buffer = $this->readBuffer;
    return $buffer->getPrefixBytes($count);
  }

  private function newProtocolFrame($type, $bytes) {
    return array(
      'type' => $type,
      'length' => strlen($bytes),
      'bytes' => $bytes,
    );
  }

  private function newProtocolRefMessage(array $frames) {
    $head_key = head_key($frames);
    $last_key = last_key($frames);

    $capabilities = null;
    $last_frame = null;

    $refs = array();
    foreach ($frames as $key => $frame) {
      $is_last = ($key === $last_key);
      if ($is_last) {
        // This is a "0000" frame at the end of the list of refs, so we pass
        // it through unmodified after we figure out what the rest of the
        // frames should look like, below.
        $last_frame = $frame;
        continue;
      }

      $is_first = ($key === $head_key);

      // Otherwise, we expect a list of:
      //
      //   <hash> <ref-name>\0<capabilities>
      //   <hash> <ref-name>
      //   ...

      $bytes = $frame['bytes'];
      $matches = array();
      if ($is_first) {
        $ok = preg_match(
          '('.
            '^'.
            '(?P<hash>[0-9a-f]{40})'.
            ' '.
            '(?P<name>[^\0\n]+)'.
            '\0'.
            '(?P<capabilities>[^\n]+)'.
            '\n'.
            '\z'.
          ')',
          $bytes,
          $matches);
        if (!$ok) {
          throw new Exception(
            pht(
              'Unexpected "git upload-pack" initial protocol frame: expected '.
              '"<hash> <name>\0<capabilities>\n", got "%s".',
              $bytes));
        }
      } else {
        $ok = preg_match(
          '('.
            '^'.
            '(?P<hash>[0-9a-f]{40})'.
            ' '.
            '(?P<name>[^\0\n]+)'.
            '\n'.
            '\z'.
          ')',
          $bytes,
          $matches);
        if (!$ok) {
          throw new Exception(
            pht(
              'Unexpected "git upload-pack" protocol frame: expected '.
              '"<hash> <name>\n", got "%s".',
              $bytes));
        }
      }

      $hash = $matches['hash'];
      $name = $matches['name'];

      if ($is_first) {
        $capabilities = $matches['capabilities'];
      }

      $refs[] = array(
        'hash' => $hash,
        'name' => $name,
      );
    }

    $capabilities = DiffusionGitWireProtocolCapabilities::newFromWireFormat(
      $capabilities);

    $ref_list = id(new DiffusionGitWireProtocolRefList())
      ->setCapabilities($capabilities);

    foreach ($refs as $ref) {
      $ref_list->addRef(
        id(new DiffusionGitWireProtocolRef())
          ->setName($ref['name'])
          ->setHash($ref['hash']));
    }

    // TODO: Here, we have a structured list of refs. In a future change,
    // we are free to mutate the structure before flattening it back into
    // wire format.

    $refs = $ref_list->getRefs();

    // Before we write the ref list, sort it for consistency with native
    // Git output. We may have added, removed, or renamed refs and ended up
    // with an out-of-order list.

    $refs = msortv($refs, 'newSortVector');

    // The first ref we send back includes the capabilities data. Note that if
    // we send back no refs, we also don't send back capabilities! This is
    // a little surprising, but is consistent with the native behavior of the
    // protocol.

    $output = array();
    $is_first = true;
    foreach ($refs as $ref) {
      if ($is_first) {
        $result = sprintf(
          "%s %s\0%s\n",
          $ref->getHash(),
          $ref->getName(),
          $ref_list->getCapabilities()->toWireFormat());
      } else {
        $result = sprintf(
          "%s %s\n",
          $ref->getHash(),
          $ref->getName());
      }

      $output[] = $this->newProtocolFrame('data', $result);
      $is_first = false;
    }

    $output[] = $last_frame;

    return $this->newProtocolDataMessage($output);
  }

  private function newProtocolDataMessage(array $frames) {
    $message = array();

    foreach ($frames as $frame) {
      switch ($frame['type']) {
        case 'null':
          $message[] = '0000';
          break;
        case 'data':
          $message[] = sprintf(
            '%04x%s',
            $frame['length'] + 4,
            $frame['bytes']);
          break;
      }
    }

    $message = implode('', $message);

    return $message;
  }

}