code
stringlengths
5
1.01M
repo_name
stringlengths
5
84
path
stringlengths
4
311
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
5
1.01M
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
--- layout: post title: "springMVC学习(二)" date: 2017-06-10 00:06:05 categories: spring tags: springMVC excerpt: springMVC author: nivelle --- * content {:toc} ### 处理数据模型 方法入参绑定请求消息只是处理方法的第一步,还有更为重要的任务等待完成,根据入参执行相应的逻辑,产生模型数据,导向特定视图中. SpringMVC提供了多种途径输出模型数据,如下: - ModelAndView :当处理方法返回值类型为ModelAndView时,方法体即可通过该对象添加模型数据 - @ModelAttribute:在方法入参标注该注解后,入参的对象就会放到数据模型中 - Map及Model:如果方法入参为org.springframework.ui.Model,org.springframework.ui.ModelMap或java.util.Map,则当处理方法返回时,Map中的数据会自动添加到模型中. - @SessionAttributes:将模型中的某个属性暂存到HttpSession中,便多个请求可以共享这个属性. 1. ModelAndView 可以简单将模型数据看作一个Map<String,Object>对象: - ModelAndView addObject(String attributeName,Object attributeValue) - ModelAndView addAllObjects(Map<String,?>modelMap) - void setView(view view):指定一个具体视图对象 - void setViewName(String viewName):指定一个逻辑视图名. 2. @ModelAttribute 如果希望将方法入参对象添加到模型中,则仅需响应入参前使用@ModelAttribute注解即可. ``` @RequestMapping(path="/handle") public String handle(@ModelAttribute("user") User user){ user.setUserId("100"); return "/user/createSuccess"; } ``` Spring MVC将请求消息绑定到对象中,然后以user为键,Usuer对象放到模型中,在准备对视图进行渲染前,SpringMVC还会进一步将模型中的数据转储到视图上下文中并暴露给视图对象.对于jsp,会将模型数据转储到servletRequest的书写列中,通过ServletRequest setAttribute(name,Object)保存.在视图中可通过${user.userName}访问模型中的数据.除了在入参上使用@ModelAttribute注解外,还可以在方法定义中使用. SpirngMVC在调用目标处理方法前,会逐个调用在方法级别上标注了@ModelAttribute注解的方法,并将这些方法的返回值添加到模型中. ![image](http://7xpuj1.com1.z0.glb.clouddn.com/ModelAttribute.png) 3. Map以及Model SpringMVC 在内部使用一个org.springframework.ui.Model接口存储模型数据,它们功能类似java.util.Map,但它比Map易用.ModelMap实现了Map接口.而org.springframework.ui.ExtendedModelMap扩展与ModelMap的同时实现了Model接口. **SpirngMVC 在调用方法前会创建一个隐含的模型对象,作为模型数据的存储容器,我们称之为"隐含模型".如果处理方法的入参为Map或Model类型,则Sping MVC会将隐含模型的引用传递给这些入参.方法体内,开发者可以通过这个入参对象访问到模型中的所有数据,也可以向明显中添加信息属性数据.** ![image](http://7xpuj1.com1.z0.glb.clouddn.com/ModelMap.png) SpringMVC一旦发现处理方法有Map或Model类型的入参,就会将请求在内的隐含模型对象传递给这些参数,因此在方法体中可以通过这个入参对模型中的数据进行读写操作. 4. @SessionAttributes 如果希望在多个请求之间公用某个模型属性数据,则可以在控制器类标注一个@SessionAttributes,SpringMVC会将模型中对应的属性暂存到HttpSession中. ![image](http://7xpuj1.com1.z0.glb.clouddn.com/TIM%E6%88%AA%E5%9B%BE20170830001820.png) 在(1)处标注的@AttributeAttributes("user")会自动将处理器中任何方法属性名为user的模型属性透明底存储到HttpSession中.(2)处,handle71()方法的User user入参会添加到隐含模型中,于是这个模型属性在handle71()方法执行时,会由Spring MVC将其透明底保存到HttpSession中. 在(3)处可以从HttpSession中获取属性值. 注意:一般情况下,控制器放回字符串类型的值会被当做逻辑视图名处理,但如果字符串带"forward:"或"redirect:"前缀,则Spring MVC将对它进行特殊处理:将"forward:"或"redirect:"当成指示符,其后字符串作为URL处理. ![image](http://7xpuj1.com1.z0.glb.clouddn.com/ModelAttributeAndSessionAttribute.png)
nivelle/nivelle.github.io
_posts/2017-08-28-springMVC学习(二).md
Markdown
mit
4,227
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 3500, 2213, 25465, 1817, 100, 1006, 1752, 1007, 1000, 3058, 1024, 2418, 1011, 5757, 1011, 2184, 4002, 1024, 5757, 1024, 5709, 7236, 1024, 3500, 22073, 1024, 3500, 2213, 25465, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<link href="../static/css/mgt_analysis/business_merchant_list.css" rel="stylesheet"> <div class="amp-main-panel" id="business-merchant-list"> <div class="amp-content-header clearfix"> <div class="pull-left"> <ul class="amp-breadcrumb"> <li><a href="#/contract_main">收入分析</a></li> <li><a href="#/business_main">营收</a></li> <li><a>{{commercialType}}</a></li> </ul> </div> </div> <div class="amp-content-panel"> <div class="ys-table-block"> <div class="amp-collapse-table"> <div class="amp-thead"> <div class="amp-table-row"> <ul class="amp-table-row-content"> <li class="amp-table-cell">品牌</li> <li class="amp-table-cell">商铺号</li> <li class="amp-table-cell text-right">当月实际</li> <li class="amp-table-cell text-right">全年累计</li> </ul> </div> </div><!-- amp-thead --> <div class="amp-tbody"> <div class="amp-table-row" ng-repeat="item in filteredRecords|limitTo:10"> <ul class="amp-table-row-content"> <li class="amp-table-cell">{{item.brandName}}</li> <li class="amp-table-cell">{{item.storeNo}}</li> <li class="amp-table-cell text-right">{{item.curMonthAmount|numberFormatDefault}}</li> <li class="amp-table-cell text-right">{{item.curYearAmount|numberFormatDefault}}</li> </ul> </div><!-- amp-table-row --> </div><!-- amp-tbody --> </div><!-- amp-table-collapse --> <div class="amp-pagination-toolbar-wrapper clearfix"> <div class="amp-pagination-toolbar pull-right"> <span>共{{filteredRecords.length}}条记录,当前1/{{parseInt(filteredRecords.length/10)+1}}页</span> <div class="pagination-nav-group"> <a>&lt;</a> <a>&gt;</a> <input type="text" value="1"/> </div> <a class="pagination-ok-btn">确定</a> </div> </div><!-- amp-pagination-toolbar-wrapper --> </div><!-- ys-table-block --> </div><!-- amp-content-panel --> </div><!-- amp-main-panel -->
ghrhome/amp
app/mgt_analysis/business_merchant_list.html
HTML
mit
2,645
[ 30522, 1026, 4957, 17850, 12879, 1027, 1000, 1012, 1012, 1013, 10763, 1013, 20116, 2015, 1013, 11460, 2102, 1035, 4106, 1013, 2449, 1035, 6432, 1035, 2862, 1012, 20116, 2015, 1000, 2128, 2140, 1027, 1000, 6782, 21030, 2102, 1000, 1028, 1026...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
window.ImageViewer = function(url, alt, title){ var img = $('<img />').attr('src', url).attr('alt', title).css({ display: 'inline-block', 'max-width': '90vw', 'max-height': '90vh' }); var a = $('<a></a>').attr('target', '_blank') .attr('title', title) .attr('href', url) .css({ display: 'inline-block', height: '100%' }) .append(img); var close_it = function(){ overlay.remove(); container.remove(); }; var closeBtn = $('<a class="icon-remove-sign"></a>').css({ color: 'red', 'font-size': 'x-large', 'margin-left': '-0.1em' }).bind('click', close_it); var closeWrapper = $('<div></div>').css({ height: '100%', width: '2em', 'text-align': 'left', 'display': 'inline-block', 'vertical-algin': 'top', 'margin-top': '-0.6em', 'float': 'right' }).append(closeBtn); var container = $('<div></div>').append( $('<div></div>').css({ margin: '5vh 1vw', display: 'inline-block', 'vertical-align': 'top' }).append(a).append(closeWrapper)) .css({ 'z-index': 30000000, 'position': 'fixed', 'padding': 0, 'margin': 0, 'width': '100vw', 'height': '100vh', 'top': 0, 'left': 0, 'text-align': 'center', 'cursor': 'default', 'vertical-align': 'middle' }) .bind('click',close_it) .appendTo('body'); var overlay = $('<div class="blockUI blockMsg blockPage">').css({ 'z-index': 9999, 'position': 'fixed', padding: 0, margin: 0, width: '100vw', height: '100vh', top: '0vh', left: '0vw', 'text-align': 'center', 'cursor': 'default', 'vertical-align': 'middle', 'background-color': 'gray', 'opacity': '0.4' }).bind('click', close_it).appendTo('body'); this.close = close_it; return this; }
clazz/clazz.github.io
js/image-viewer.js
JavaScript
mit
2,216
[ 30522, 3332, 1012, 3746, 8584, 2121, 1027, 3853, 1006, 24471, 2140, 1010, 12456, 1010, 2516, 1007, 1063, 13075, 10047, 2290, 1027, 1002, 1006, 1005, 1026, 10047, 2290, 1013, 1028, 1005, 1007, 1012, 2012, 16344, 1006, 1005, 5034, 2278, 1005,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="panel panel-danger"> <div class="panel-heading"> <h1 class="panel-title"> {% include "theme/brandx/BRANDING-name.html" %} Alert Help! </h1> </div> <div class="panel-body"> <div class="sidebar-module"> <h2> Group Name </h2> <p>Full name of this group with no spaces.</p> </div><!--/sidebar-module--> <div class="sidebar-module"> <h2> Group Display Name </h2> <p>This is the pre-fix to each message sent. Make this as short as possible.</p> </div><!--/sidebar-module--> <div class="sidebar-module"> <h2> Group Owner </h2> <p>Who will own this group? Messages will be from this user.</p> </div><!--/sidebar-module--> <div class="sidebar-module"> <h2> Group Type </h2> <p>PUBLIC: Anyone can subscribe.<br />PRIVATE: Only admin can subscribe users.<br />REQUIRED: All users are subscribed.</p> </div><!--/sidebar-module--> <div class="sidebar-module"> <h2> Group Description </h2> <p>Add a description of what the group will be for.</p> </div><!--/sidebar-module--> </div><!--/panel-body--> </div><!--/panel-->
WesternOKState/CampusClaxon
templates/theme/brandx/AlertAdmin/helpText-Topic.html
HTML
gpl-3.0
1,874
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 5997, 5997, 1011, 5473, 1000, 1028, 1026, 4487, 2615, 2465, 1027, 1000, 5997, 1011, 5825, 1000, 1028, 1026, 1044, 2487, 2465, 1027, 1000, 5997, 1011, 2516, 1000, 1028, 1063, 1003, 2421, 1000, 432...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/// <reference path="../custom_typings/ambient.d.ts" /> import * as gulp from "gulp"; import * as runSequence from "run-sequence"; /* Build task for deployment */ gulp.task("build:prod", done => build(["typescript:prod", "sass", "html"], done)); /* Build task for dev environment */ gulp.task("build:dev", done => build(["typescript:dev:bundle", "typescript:dev", "sass", "html"], done)); function build(tasks: string[], done: any) { runSequence("clean", tasks, done) }
lukeautry/typescript-bundler
build/tasks/build.ts
TypeScript
mit
477
[ 30522, 1013, 1013, 1013, 1026, 4431, 4130, 1027, 1000, 1012, 1012, 1013, 7661, 1035, 22868, 2015, 1013, 17093, 1012, 1040, 1012, 24529, 1000, 1013, 1028, 12324, 1008, 2004, 26546, 2013, 1000, 26546, 1000, 1025, 12324, 1008, 2004, 3216, 2063...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# ![](https://avatars1.githubusercontent.com/u/8237355?v=2&s=50) Grav [![SensioLabsInsight](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad/mini.png)](https://insight.sensiolabs.com/projects/cfd20465-d0f8-4a0a-8444-467f5b5f16ad) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/getgrav/grav?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/getgrav/grav.svg?branch=develop)](https://travis-ci.org/getgrav/grav) Grav is a **Fast**, **Simple**, and **Flexible**, file-based Web-platform. There is **Zero** installation required. Just extract the ZIP archive, and you are already up and running. It follows similar principles to other flat-file CMS platforms, but has a different design philosophy than most. Grav comes with a powerful **Package Management System** to allow for simple installation and upgrading of plugins and themes, as well as simple updating of Grav itself. The underlying architecture of Grav is designed to use well-established and _best-in-class_ technologies to ensure that Grav is simple to use and easy to extend. Some of these key technologies include: * [Twig Templating](http://twig.sensiolabs.org/): for powerful control of the user interface * [Markdown](http://en.wikipedia.org/wiki/Markdown): for easy content creation * [YAML](http://yaml.org): for simple configuration * [Parsedown](http://parsedown.org/): for fast Markdown and Markdown Extra support * [Doctrine Cache](http://docs.doctrine-project.org/en/2.0.x/reference/caching.html): layer for performance * [Pimple Dependency Injection Container](http://pimple.sensiolabs.org/): for extensibility and maintainability * [Symfony Event Dispatcher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html): for plugin event handling * [Symfony Console](http://symfony.com/doc/current/components/console/introduction.html): for CLI interface * [Gregwar Image Library](https://github.com/Gregwar/Image): for dynamic image manipulation # Requirements - PHP 5.5.9 or higher. Check the [required modules list](http://learn.getgrav.org/basics/requirements#php-requirements) - Check the [Apache](http://learn.getgrav.org/basics/requirements#apache-requirements) or [IIS](http://learn.getgrav.org/basics/requirements#iis-requirements) requirements # QuickStart These are the options to get Grav: ### Downloading a Grav Package You can download a **ready-built** package from the [Downloads page on http://getgrav.org](http://getgrav.org/downloads) ### With composer You can create a new project with the latest **stable** Grav release with the following command: ``` $ composer create-project getgrav/grav ~/webroot/grav ``` ### From GitHub 1. Clone the Grav repository from [https://github.com/getgrav/grav]() to a folder in the webroot of your server, e.g. `~/webroot/grav`. Launch a **terminal** or **console** and navigate to the webroot folder: ``` $ cd ~/webroot $ git clone https://github.com/getgrav/grav.git ``` 2. Install the **plugin** and **theme dependencies** by using the [Grav CLI application](http://learn.getgrav.org/advanced/grav-cli) `bin/grav`: ``` $ cd ~/webroot/grav $ bin/grav install ``` Check out the [install procedures](http://learn.getgrav.org/basics/installation) for more information. # Adding Functionality You can download [plugins](http://getgrav.org/downloads/plugins) or [themes](http://getgrav.org/downloads/themes) manually from the appropriate tab on the [Downloads page on http://getgrav.org](http://getgrav.org/downloads), but the preferred solution is to use the [Grav Package Manager](http://learn.getgrav.org/advanced/grav-gpm) or `GPM`: ``` $ bin/gpm index ``` This will display all the available plugins and then you can install one or more with: ``` $ bin/gpm install <plugin/theme> ``` # Updating To update Grav you should use the [Grav Package Manager](http://learn.getgrav.org/advanced/grav-gpm) or `GPM`: ``` $ bin/gpm selfupgrade ``` To update plugins and themes: ``` $ bin/gpm update ``` # Contributing We appreciate any contribution to Grav, whether it is related to bugs, grammar, or simply a suggestion or improvement. However, we ask that any contributions follow our simple guidelines in order to be properly received. All our projects follow the [GitFlow branching model][gitflow-model], from development to release. If you are not familiar with it, there are several guides and tutorials to make you understand what it is about. You will probably want to get started by installing [this very good collection of git extensions][gitflow-extensions]. What you mainly want to know is that: - All the main activity happens in the `develop` branch. Any pull request should be addressed only to that branch. We will not consider pull requests made to the `master`. - It's very well appreciated, and highly suggested, to start a new feature whenever you want to make changes or add functionalities. It will make it much easier for us to just checkout your feature branch and test it, before merging it into `develop` # Getting Started * [What is Grav?](http://learn.getgrav.org/basics/what-is-grav) * [Install](http://learn.getgrav.org/basics/installation) Grav in few seconds * Understand the [Configuration](http://learn.getgrav.org/basics/grav-configuration) * Take a peek at our available free [Skeletons](http://getgrav.org/downloads/skeletons) * If you have questions, jump on our [Gitter Room](https://gitter.im/getgrav/grav)! * Have fun! # Exploring More * Have a look at our [Basic Tutorial](http://learn.getgrav.org/basics/basic-tutorial) * Dive into more [advanced](http://learn.getgrav.org/advanced) functions # License See [LICENSE](LICENSE.txt) [gitflow-model]: http://nvie.com/posts/a-successful-git-branching-model/ [gitflow-extensions]: https://github.com/nvie/gitflow # Running Tests First install the dev dependencies by running `composer update` from the Grav root. Then `composer test` will run the Unit Tests, which should be always executed successfully on any site. You can also run a single unit test file, e.g. `composer test tests/unit/Grav/Common/AssetsTest.php`
mbochynski/business-card
grav/README.md
Markdown
mit
6,227
[ 30522, 1001, 999, 1031, 1033, 1006, 16770, 1024, 1013, 1013, 22128, 2015, 2487, 1012, 21025, 2705, 12083, 20330, 8663, 6528, 2102, 1012, 4012, 1013, 1057, 1013, 6445, 24434, 19481, 2629, 1029, 1058, 1027, 1016, 1004, 1055, 1027, 2753, 1007,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ /* * Do not modify this file. This file is generated from the cloudformation-2010-05-15.normal.json service model. */ using System; using System.Collections.Generic; using System.Xml.Serialization; using System.Text; using System.IO; using Amazon.Runtime; using Amazon.Runtime.Internal; namespace Amazon.CloudFormation.Model { /// <summary> /// Container for the parameters to the CreateStack operation. /// Creates a stack as specified in the template. After the call completes successfully, /// the stack creation starts. You can check the status of the stack via the <a>DescribeStacks</a> /// API. /// </summary> public partial class CreateStackRequest : AmazonCloudFormationRequest { private List<string> _capabilities = new List<string>(); private bool? _disableRollback; private List<string> _notificationARNs = new List<string>(); private OnFailure _onFailure; private List<Parameter> _parameters = new List<Parameter>(); private List<string> _resourceTypes = new List<string>(); private string _stackName; private string _stackPolicyBody; private string _stackPolicyURL; private List<Tag> _tags = new List<Tag>(); private string _templateBody; private string _templateURL; private int? _timeoutInMinutes; /// <summary> /// Gets and sets the property Capabilities. /// <para> /// A list of capabilities that you must specify before AWS CloudFormation can create /// or update certain stacks. Some stack templates might include resources that can affect /// permissions in your AWS account. For those stacks, you must explicitly acknowledge /// their capabilities by specifying this parameter. /// </para> /// /// <para> /// Currently, the only valid value is <code>CAPABILITY_IAM</code>, which is required /// for the following resources: <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html"> /// AWS::IAM::AccessKey</a>, <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-group.html"> /// AWS::IAM::Group</a>, <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html"> /// AWS::IAM::InstanceProfile</a>, <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-policy.html"> /// AWS::IAM::Policy</a>, <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html"> /// AWS::IAM::Role</a>, <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html"> /// AWS::IAM::User</a>, and <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-addusertogroup.html"> /// AWS::IAM::UserToGroupAddition</a>. If your stack template contains these resources, /// we recommend that you review any permissions associated with them. If you don't specify /// this parameter, this action returns an <code>InsufficientCapabilities</code> error. /// </para> /// </summary> public List<string> Capabilities { get { return this._capabilities; } set { this._capabilities = value; } } // Check to see if Capabilities property is set internal bool IsSetCapabilities() { return this._capabilities != null && this._capabilities.Count > 0; } /// <summary> /// Gets and sets the property DisableRollback. /// <para> /// Set to <code>true</code> to disable rollback of the stack if stack creation failed. /// You can specify either <code>DisableRollback</code> or <code>OnFailure</code>, but /// not both. /// </para> /// /// <para> /// Default: <code>false</code> /// </para> /// </summary> public bool DisableRollback { get { return this._disableRollback.GetValueOrDefault(); } set { this._disableRollback = value; } } // Check to see if DisableRollback property is set internal bool IsSetDisableRollback() { return this._disableRollback.HasValue; } /// <summary> /// Gets and sets the property NotificationARNs. /// <para> /// The Simple Notification Service (SNS) topic ARNs to publish stack related events. /// You can find your SNS topic ARNs using the <a href="http://console.aws.amazon.com/sns">SNS /// console</a> or your Command Line Interface (CLI). /// </para> /// </summary> public List<string> NotificationARNs { get { return this._notificationARNs; } set { this._notificationARNs = value; } } // Check to see if NotificationARNs property is set internal bool IsSetNotificationARNs() { return this._notificationARNs != null && this._notificationARNs.Count > 0; } /// <summary> /// Gets and sets the property OnFailure. /// <para> /// Determines what action will be taken if stack creation fails. This must be one of: /// DO_NOTHING, ROLLBACK, or DELETE. You can specify either <code>OnFailure</code> or /// <code>DisableRollback</code>, but not both. /// </para> /// /// <para> /// Default: <code>ROLLBACK</code> /// </para> /// </summary> public OnFailure OnFailure { get { return this._onFailure; } set { this._onFailure = value; } } // Check to see if OnFailure property is set internal bool IsSetOnFailure() { return this._onFailure != null; } /// <summary> /// Gets and sets the property Parameters. /// <para> /// A list of <code>Parameter</code> structures that specify input parameters for the /// stack. /// </para> /// </summary> public List<Parameter> Parameters { get { return this._parameters; } set { this._parameters = value; } } // Check to see if Parameters property is set internal bool IsSetParameters() { return this._parameters != null && this._parameters.Count > 0; } /// <summary> /// Gets and sets the property ResourceTypes. /// <para> /// The template resource types that you have permissions to work with for this create /// stack action, such as <code>AWS::EC2::Instance</code>, <code>AWS::EC2::*</code>, or /// <code>Custom::MyCustomInstance</code>. Use the following syntax to describe template /// resource types: <code>AWS::*</code> (for all AWS resource), <code>Custom::*</code> /// (for all custom resources), <code>Custom::<i>logical_ID</i></code> (for a specific /// custom resource), <code>AWS::<i>service_name</i>::*</code> (for all resources of a /// particular AWS service), and <code>AWS::<i>service_name</i>::<i>resource_logical_ID</i></code> /// (for a specific AWS resource). /// </para> /// /// <para> /// If the list of resource types doesn't include a resource that you're creating, the /// stack creation fails. By default, AWS CloudFormation grants permissions to all resource /// types. AWS Identity and Access Management (IAM) uses this parameter for AWS CloudFormation-specific /// condition keys in IAM policies. For more information, see <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html">Controlling /// Access with AWS Identity and Access Management</a>. /// </para> /// </summary> public List<string> ResourceTypes { get { return this._resourceTypes; } set { this._resourceTypes = value; } } // Check to see if ResourceTypes property is set internal bool IsSetResourceTypes() { return this._resourceTypes != null && this._resourceTypes.Count > 0; } /// <summary> /// Gets and sets the property StackName. /// <para> /// The name that is associated with the stack. The name must be unique in the region /// in which you are creating the stack. /// </para> /// <note>A stack name can contain only alphanumeric characters (case sensitive) and /// hyphens. It must start with an alphabetic character and cannot be longer than 255 /// characters.</note> /// </summary> public string StackName { get { return this._stackName; } set { this._stackName = value; } } // Check to see if StackName property is set internal bool IsSetStackName() { return this._stackName != null; } /// <summary> /// Gets and sets the property StackPolicyBody. /// <para> /// Structure containing the stack policy body. For more information, go to <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html"> /// Prevent Updates to Stack Resources</a> in the AWS CloudFormation User Guide. You can /// specify either the <code>StackPolicyBody</code> or the <code>StackPolicyURL</code> /// parameter, but not both. /// </para> /// </summary> public string StackPolicyBody { get { return this._stackPolicyBody; } set { this._stackPolicyBody = value; } } // Check to see if StackPolicyBody property is set internal bool IsSetStackPolicyBody() { return this._stackPolicyBody != null; } /// <summary> /// Gets and sets the property StackPolicyURL. /// <para> /// Location of a file containing the stack policy. The URL must point to a policy (max /// size: 16KB) located in an S3 bucket in the same region as the stack. You can specify /// either the <code>StackPolicyBody</code> or the <code>StackPolicyURL</code> parameter, /// but not both. /// </para> /// </summary> public string StackPolicyURL { get { return this._stackPolicyURL; } set { this._stackPolicyURL = value; } } // Check to see if StackPolicyURL property is set internal bool IsSetStackPolicyURL() { return this._stackPolicyURL != null; } /// <summary> /// Gets and sets the property Tags. /// <para> /// A set of user-defined <code>Tags</code> to associate with this stack, represented /// by key/value pairs. Tags defined for the stack are propagated to EC2 resources that /// are created as part of the stack. A maximum number of 10 tags can be specified. /// </para> /// </summary> public List<Tag> Tags { get { return this._tags; } set { this._tags = value; } } // Check to see if Tags property is set internal bool IsSetTags() { return this._tags != null && this._tags.Count > 0; } /// <summary> /// Gets and sets the property TemplateBody. /// <para> /// Structure containing the template body with a minimum length of 1 byte and a maximum /// length of 51,200 bytes. For more information, go to <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template /// Anatomy</a> in the AWS CloudFormation User Guide. /// </para> /// /// <para> /// Conditional: You must specify either the <code>TemplateBody</code> or the <code>TemplateURL</code> /// parameter, but not both. /// </para> /// </summary> public string TemplateBody { get { return this._templateBody; } set { this._templateBody = value; } } // Check to see if TemplateBody property is set internal bool IsSetTemplateBody() { return this._templateBody != null; } /// <summary> /// Gets and sets the property TemplateURL. /// <para> /// Location of file containing the template body. The URL must point to a template (max /// size: 460,800 bytes) that is located in an Amazon S3 bucket. For more information, /// go to the <a href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html">Template /// Anatomy</a> in the AWS CloudFormation User Guide. /// </para> /// /// <para> /// Conditional: You must specify either the <code>TemplateBody</code> or the <code>TemplateURL</code> /// parameter, but not both. /// </para> /// </summary> public string TemplateURL { get { return this._templateURL; } set { this._templateURL = value; } } // Check to see if TemplateURL property is set internal bool IsSetTemplateURL() { return this._templateURL != null; } /// <summary> /// Gets and sets the property TimeoutInMinutes. /// <para> /// The amount of time that can pass before the stack status becomes CREATE_FAILED; if /// <code>DisableRollback</code> is not set or is set to <code>false</code>, the stack /// will be rolled back. /// </para> /// </summary> public int TimeoutInMinutes { get { return this._timeoutInMinutes.GetValueOrDefault(); } set { this._timeoutInMinutes = value; } } // Check to see if TimeoutInMinutes property is set internal bool IsSetTimeoutInMinutes() { return this._timeoutInMinutes.HasValue; } } }
rafd123/aws-sdk-net
sdk/src/Services/CloudFormation/Generated/Model/CreateStackRequest.cs
C#
apache-2.0
14,931
[ 30522, 1013, 1008, 1008, 9385, 2230, 1011, 2297, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * RemoveContactFromListTest * * PHP version 5 * * @category Class * @package SendinBlue\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ /** * SendinBlue API * * SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/sendinblue **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed | | 406 | Error. Not Acceptable | * * OpenAPI spec version: 3.0.0 * Contact: contact@sendinblue.com * Generated by: https://github.com/swagger-api/swagger-codegen.git * Swagger Codegen version: 2.4.12 */ /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Please update the test case below to test the model. */ namespace SendinBlue\Client; /** * RemoveContactFromListTest Class Doc Comment * * @category Class * @description RemoveContactFromList * @package SendinBlue\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ class RemoveContactFromListTest extends \PHPUnit_Framework_TestCase { /** * Setup before running any test case */ public static function setUpBeforeClass() { } /** * Setup before running each test case */ public function setUp() { } /** * Clean up after running each test case */ public function tearDown() { } /** * Clean up after running all test cases */ public static function tearDownAfterClass() { } /** * Test "RemoveContactFromList" */ public function testRemoveContactFromList() { } /** * Test attribute "emails" */ public function testPropertyEmails() { } /** * Test attribute "all" */ public function testPropertyAll() { } }
LoicLEMEUT/sendinblue
lib/api-v3-sdk/test/Model/RemoveContactFromListTest.php
PHP
gpl-3.0
2,553
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 6366, 8663, 2696, 6593, 19699, 5358, 9863, 22199, 1008, 1008, 25718, 2544, 1019, 1008, 1008, 1030, 4696, 2465, 1008, 1030, 7427, 4604, 2378, 16558, 5657, 1032, 7396, 1008, 1030, 3166, 25430,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
mvn javadoc:javadoc sphinx-build -w sphinx-errors docs prose-docs
elonlang/workspaceHoccleve
build-docs.sh
Shell
mpl-2.0
66
[ 30522, 19842, 2078, 9262, 3527, 2278, 1024, 9262, 3527, 2278, 27311, 1011, 3857, 1011, 1059, 27311, 1011, 10697, 9986, 2015, 12388, 1011, 9986, 2015, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* A Bison parser, made by GNU Bison 1.875a. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* Written by Richard Stallman by simplifying the original so called ``semantic'' parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 0 /* Using locations. */ #define YYLSP_NEEDED 0 /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { TYPEVAR = 258, ABSTYPE = 259, DATA = 260, TYPESYM = 261, DEC = 262, INFIX = 263, INFIXR = 264, USES = 265, PRIVATE = 266, DISPLAY = 267, SAVE = 268, WRITE = 269, TO = 270, EXIT = 271, EDIT = 272, DEFEQ = 273, OR = 274, VALOF = 275, IS = 276, GIVES = 277, THEN = 278, FORALL = 279, MODSYM = 280, PUBCONST = 281, PUBFUN = 282, PUBTYPE = 283, END = 284, MU = 285, IN = 286, WHEREREC = 287, WHERE = 288, ELSE = 289, BIN_BASE = 290, LBINARY1 = 291, RBINARY1 = 292, LBINARY2 = 293, RBINARY2 = 294, LBINARY3 = 295, RBINARY3 = 296, LBINARY4 = 297, RBINARY4 = 298, LBINARY5 = 299, RBINARY5 = 300, LBINARY6 = 301, RBINARY6 = 302, LBINARY7 = 303, RBINARY7 = 304, LBINARY8 = 305, RBINARY8 = 306, LBINARY9 = 307, RBINARY9 = 308, NONOP = 309, LAMBDA = 310, IF = 311, LETREC = 312, LET = 313, CHAR = 314, LITERAL = 315, NUMBER = 316, IDENT = 317, APPLY = 318, ALWAYS_REDUCE = 319 }; #endif #define TYPEVAR 258 #define ABSTYPE 259 #define DATA 260 #define TYPESYM 261 #define DEC 262 #define INFIX 263 #define INFIXR 264 #define USES 265 #define PRIVATE 266 #define DISPLAY 267 #define SAVE 268 #define WRITE 269 #define TO 270 #define EXIT 271 #define EDIT 272 #define DEFEQ 273 #define OR 274 #define VALOF 275 #define IS 276 #define GIVES 277 #define THEN 278 #define FORALL 279 #define MODSYM 280 #define PUBCONST 281 #define PUBFUN 282 #define PUBTYPE 283 #define END 284 #define MU 285 #define IN 286 #define WHEREREC 287 #define WHERE 288 #define ELSE 289 #define BIN_BASE 290 #define LBINARY1 291 #define RBINARY1 292 #define LBINARY2 293 #define RBINARY2 294 #define LBINARY3 295 #define RBINARY3 296 #define LBINARY4 297 #define RBINARY4 298 #define LBINARY5 299 #define RBINARY5 300 #define LBINARY6 301 #define RBINARY6 302 #define LBINARY7 303 #define RBINARY7 304 #define LBINARY8 305 #define RBINARY8 306 #define LBINARY9 307 #define RBINARY9 308 #define NONOP 309 #define LAMBDA 310 #define IF 311 #define LETREC 312 #define LET 313 #define CHAR 314 #define LITERAL 315 #define NUMBER 316 #define IDENT 317 #define APPLY 318 #define ALWAYS_REDUCE 319 /* Copy the first part of user declarations. */ #include "defs.h" #include "memory.h" #include "typevar.h" #include "op.h" #include "newstring.h" #include "module.h" #include "expr.h" #include "deftype.h" #include "cons.h" #include "eval.h" #include "error.h" #include "text.h" /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) typedef union YYSTYPE { Num numval; int intval; Text *textval; String strval; Natural charval; Type *type; TypeList *typelist; DefType *deftype; QType *qtype; Expr *expr; Branch *branch; Cons *cons; } YYSTYPE; /* Line 191 of yacc.c. */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Traditional yacc provides a global variable yyerrflag, which is non-zero when the parser is attempting to recover from an error. We use this for simple error recovery for interactive sessions in yylex(). */ extern int yyerrflag; global Bool recovering(void) { return yyerrflag != 0; } #ifdef YYBISON /* Bison defines a corresponding variable yyerrstatus local to yyparse(). To kludge around this, the Makefile comments out the local definition, and we supply a global one. */ int yyerrflag; #define yyerrstatus yyerrflag #endif /* Line 214 of yacc.c. */ #if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # if YYSTACK_USE_ALLOCA # define YYSTACK_ALLOC alloca # else # ifndef YYSTACK_USE_ALLOCA # if defined (alloca) || defined (_ALLOCA_H) # define YYSTACK_ALLOC alloca # else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # else # if defined (__STDC__) || defined (__cplusplus) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif # define YYSTACK_ALLOC malloc # define YYSTACK_FREE free # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ || (YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { short yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) #endif #if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char; #else typedef short yysigned_char; #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 1751 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 73 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 41 /* YYNRULES -- Number of rules. */ #define YYNRULES 202 /* YYNRULES -- Number of states. */ #define YYNSTATES 401 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 319 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const unsigned char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 56, 71, 2, 2, 31, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 70, 69, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 57, 2, 72, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 32, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const unsigned short yyprhs[] = { 0, 0, 3, 6, 7, 10, 13, 16, 19, 22, 25, 30, 35, 37, 40, 42, 47, 51, 55, 57, 60, 65, 67, 70, 73, 75, 78, 80, 83, 86, 89, 92, 94, 95, 99, 101, 103, 107, 109, 113, 117, 121, 125, 127, 129, 133, 135, 139, 141, 143, 146, 151, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 229, 232, 234, 236, 240, 242, 244, 248, 251, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320, 324, 328, 331, 336, 340, 344, 348, 352, 356, 360, 364, 368, 372, 376, 380, 384, 388, 392, 396, 400, 404, 408, 413, 417, 418, 421, 423, 427, 429, 431, 435, 437, 439, 443, 447, 450, 451, 453, 457, 461, 463, 465, 467, 469, 474, 479, 483, 487, 490, 493, 497, 501, 505, 509, 513, 517, 521, 525, 529, 533, 537, 541, 545, 549, 553, 557, 561, 565, 569, 576, 583, 590, 596, 602, 607, 609, 613, 615, 619, 623, 629, 631, 632, 634, 636, 638, 640, 644, 647, 649, 651, 653, 655, 657, 659, 661, 663, 665, 667, 669, 671, 673, 675, 677, 679, 681 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yysigned_char yyrhs[] = { 74, 0, -1, 74, 75, -1, -1, 76, 69, -1, 1, 69, -1, 3, 78, -1, 8, 80, -1, 9, 81, -1, 4, 85, -1, 6, 87, 18, 94, -1, 5, 87, 18, 92, -1, 11, -1, 7, 100, -1, 101, -1, 20, 105, 21, 106, -1, 105, 21, 106, -1, 105, 18, 106, -1, 106, -1, 14, 105, -1, 14, 105, 15, 64, -1, 12, -1, 10, 83, -1, 13, 112, -1, 17, -1, 17, 112, -1, 16, -1, 25, 112, -1, 26, 77, -1, 27, 77, -1, 28, 77, -1, 29, -1, -1, 77, 31, 112, -1, 112, -1, 79, -1, 78, 31, 79, -1, 112, -1, 66, 70, 82, -1, 66, 31, 80, -1, 66, 70, 82, -1, 66, 31, 81, -1, 65, -1, 84, -1, 83, 31, 84, -1, 112, -1, 85, 31, 86, -1, 86, -1, 87, -1, 112, 88, -1, 112, 56, 91, 71, -1, 112, 56, 90, 71, -1, 91, 38, 91, -1, 91, 39, 91, -1, 91, 40, 91, -1, 91, 41, 91, -1, 91, 42, 91, -1, 91, 43, 91, -1, 91, 44, 91, -1, 91, 45, 91, -1, 91, 46, 91, -1, 91, 47, 91, -1, 91, 48, 91, -1, 91, 49, 91, -1, 91, 50, 91, -1, 91, 51, 91, -1, 91, 52, 91, -1, 91, 53, 91, -1, 91, 54, 91, -1, 91, 55, 91, -1, -1, 91, 88, -1, 91, -1, 90, -1, 91, 31, 89, -1, 112, -1, 93, -1, 93, 19, 92, -1, 112, 95, -1, 112, 56, 98, 71, -1, 94, 38, 94, -1, 94, 39, 94, -1, 94, 40, 94, -1, 94, 41, 94, -1, 94, 42, 94, -1, 94, 43, 94, -1, 94, 44, 94, -1, 94, 45, 94, -1, 94, 46, 94, -1, 94, 47, 94, -1, 94, 48, 94, -1, 94, 49, 94, -1, 94, 50, 94, -1, 94, 51, 94, -1, 94, 52, 94, -1, 94, 53, 94, -1, 94, 54, 94, -1, 94, 55, 94, -1, 112, 95, -1, 112, 56, 98, 71, -1, 94, 38, 94, -1, 94, 39, 94, -1, 94, 40, 94, -1, 94, 41, 94, -1, 94, 42, 94, -1, 94, 43, 94, -1, 94, 44, 94, -1, 94, 45, 94, -1, 94, 46, 94, -1, 94, 47, 94, -1, 94, 48, 94, -1, 94, 49, 94, -1, 94, 50, 94, -1, 94, 51, 94, -1, 94, 52, 94, -1, 94, 53, 94, -1, 94, 54, 94, -1, 94, 55, 94, -1, 30, 99, 22, 94, -1, 56, 94, 71, -1, -1, 96, 95, -1, 112, -1, 56, 94, 71, -1, 94, -1, 98, -1, 94, 31, 97, -1, 112, -1, 101, -1, 111, 31, 100, -1, 111, 70, 102, -1, 103, 94, -1, -1, 112, -1, 104, 31, 104, -1, 56, 104, 71, -1, 112, -1, 65, -1, 64, -1, 63, -1, 56, 105, 113, 71, -1, 56, 113, 105, 71, -1, 56, 106, 71, -1, 57, 107, 72, -1, 57, 72, -1, 105, 105, -1, 105, 38, 105, -1, 105, 39, 105, -1, 105, 40, 105, -1, 105, 41, 105, -1, 105, 42, 105, -1, 105, 43, 105, -1, 105, 44, 105, -1, 105, 45, 105, -1, 105, 46, 105, -1, 105, 47, 105, -1, 105, 48, 105, -1, 105, 49, 105, -1, 105, 50, 105, -1, 105, 51, 105, -1, 105, 52, 105, -1, 105, 53, 105, -1, 105, 54, 105, -1, 105, 55, 105, -1, 59, 108, 110, -1, 60, 105, 23, 106, 36, 105, -1, 62, 106, 18, 106, 33, 105, -1, 61, 104, 18, 106, 33, 105, -1, 105, 35, 106, 18, 105, -1, 105, 34, 104, 18, 105, -1, 30, 104, 22, 105, -1, 105, -1, 105, 31, 106, -1, 105, -1, 105, 31, 107, -1, 109, 22, 105, -1, 109, 22, 105, 32, 108, -1, 106, -1, -1, 29, -1, 112, -1, 113, -1, 66, -1, 56, 113, 71, -1, 58, 113, -1, 38, -1, 39, -1, 40, -1, 41, -1, 42, -1, 43, -1, 44, -1, 45, -1, 46, -1, 47, -1, 48, -1, 49, -1, 50, -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { 0, 177, 177, 178, 181, 182, 185, 186, 187, 189, 190, 192, 194, 195, 196, 197, 199, 201, 203, 204, 205, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 221, 222, 225, 226, 229, 232, 234, 238, 240, 244, 247, 248, 251, 254, 255, 258, 261, 262, 265, 267, 271, 275, 279, 283, 287, 291, 295, 299, 303, 307, 311, 315, 319, 323, 327, 331, 335, 341, 342, 345, 346, 349, 352, 355, 356, 364, 366, 368, 373, 378, 383, 388, 393, 398, 403, 408, 413, 418, 423, 428, 433, 438, 443, 448, 453, 461, 463, 465, 470, 475, 480, 485, 490, 495, 500, 505, 510, 515, 520, 525, 530, 535, 540, 545, 550, 555, 557, 560, 561, 565, 567, 570, 571, 574, 578, 581, 582, 585, 588, 591, 594, 595, 596, 599, 600, 601, 602, 603, 605, 607, 609, 611, 612, 614, 618, 622, 626, 630, 634, 638, 642, 646, 650, 654, 658, 662, 666, 670, 674, 678, 682, 686, 688, 690, 692, 694, 696, 698, 702, 703, 707, 710, 714, 716, 729, 740, 741, 744, 745, 748, 749, 750, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770 }; #endif #if YYDEBUG || YYERROR_VERBOSE /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "TYPEVAR", "ABSTYPE", "DATA", "TYPESYM", "DEC", "INFIX", "INFIXR", "USES", "PRIVATE", "DISPLAY", "SAVE", "WRITE", "TO", "EXIT", "EDIT", "DEFEQ", "OR", "VALOF", "IS", "GIVES", "THEN", "FORALL", "MODSYM", "PUBCONST", "PUBFUN", "PUBTYPE", "END", "MU", "','", "'|'", "IN", "WHEREREC", "WHERE", "ELSE", "BIN_BASE", "LBINARY1", "RBINARY1", "LBINARY2", "RBINARY2", "LBINARY3", "RBINARY3", "LBINARY4", "RBINARY4", "LBINARY5", "RBINARY5", "LBINARY6", "RBINARY6", "LBINARY7", "RBINARY7", "LBINARY8", "RBINARY8", "LBINARY9", "RBINARY9", "'('", "'['", "NONOP", "LAMBDA", "IF", "LETREC", "LET", "CHAR", "LITERAL", "NUMBER", "IDENT", "APPLY", "ALWAYS_REDUCE", "';'", "':'", "')'", "']'", "$accept", "lines", "line", "cmd", "idlist", "newtvlist", "newtv", "infixlist", "infixrlist", "precedence", "uselist", "use", "abstypelist", "abstype", "newtype", "tvargs", "tvlist", "tvpair", "tv", "constypelist", "constype", "type", "typeargs", "typearg", "typelist", "typepair", "mu_tv", "decl", "simple_decl", "q_type", "start_dec", "tuple", "expr", "exprbody", "exprlist", "rulelist", "formals", "optend", "name", "ident", "binop", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const unsigned short yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 44, 124, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 40, 91, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 59, 58, 41, 93 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { 0, 73, 74, 74, 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 77, 77, 78, 78, 79, 80, 80, 81, 81, 82, 83, 83, 84, 85, 85, 86, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 88, 88, 89, 89, 90, 91, 92, 92, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 95, 95, 96, 96, 97, 97, 98, 99, 100, 100, 101, 102, 103, 104, 104, 104, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 106, 106, 107, 107, 108, 108, 109, 110, 110, 111, 111, 112, 112, 112, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 4, 4, 1, 2, 1, 4, 3, 3, 1, 2, 4, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 0, 3, 1, 1, 3, 1, 3, 3, 3, 3, 1, 1, 3, 1, 3, 1, 1, 2, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 2, 1, 1, 3, 1, 1, 3, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 0, 2, 1, 3, 1, 1, 3, 1, 1, 3, 3, 2, 0, 1, 3, 3, 1, 1, 1, 1, 4, 4, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 5, 5, 4, 1, 3, 1, 3, 3, 5, 1, 0, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const unsigned char yydefact[] = { 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 21, 0, 0, 26, 24, 0, 0, 0, 0, 0, 31, 0, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 0, 0, 0, 0, 0, 0, 0, 139, 138, 137, 182, 2, 0, 14, 171, 18, 0, 136, 181, 5, 0, 6, 35, 37, 9, 47, 48, 0, 75, 0, 0, 13, 128, 0, 180, 0, 7, 0, 8, 22, 43, 45, 23, 19, 136, 25, 0, 27, 28, 34, 29, 30, 0, 0, 133, 171, 0, 0, 144, 173, 0, 184, 171, 177, 178, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 70, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 0, 142, 183, 0, 0, 143, 179, 164, 0, 0, 0, 0, 17, 16, 172, 0, 0, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 130, 0, 36, 46, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, 0, 71, 0, 0, 11, 76, 0, 120, 10, 120, 129, 39, 42, 38, 41, 40, 44, 20, 15, 33, 135, 170, 134, 140, 141, 174, 175, 0, 0, 0, 0, 0, 131, 51, 0, 50, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 120, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 0, 0, 0, 0, 169, 168, 74, 73, 72, 0, 119, 77, 80, 81, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 0, 0, 0, 121, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 0, 176, 165, 167, 166, 118, 0, 123, 99, 0, 99, 124, 126, 125 }; /* YYDEFGOTO[NTERM-NUM]. */ static const short yydefgoto[] = { -1, 1, 54, 55, 91, 64, 65, 79, 81, 266, 82, 83, 67, 68, 69, 160, 341, 252, 70, 257, 258, 259, 312, 313, 399, 366, 289, 74, 75, 230, 231, 96, 136, 106, 103, 107, 108, 202, 76, 87, 138 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -302 static const short yypact[] = { -302, 646, -302, -40, -28, -28, -28, -28, 1369, -29, -24, -28, -302, -302, -28, 1243, -302, -28, 1243, -28, -28, -28, -28, -302, -25, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, 1179, 922, 1547, 1243, 1243, -25, 1243, -302, -302, -302, -302, -302, -21, -302, 795, -302, -18, -15, -302, -302, 1547, 29, -302, -302, 65, -302, -302, 1565, -7, 51, 96, -302, -302, -9, -302, -6, -302, 35, -302, 98, -302, -302, -302, 698, -302, -302, 841, -302, 99, -302, 99, 99, 1398, 143, -302, 1068, 60, 998, -302, 1105, 62, -302, 1142, -302, 103, 113, 885, 8, 119, -302, 1243, 1243, 1243, -25, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, -302, -302, 90, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, -28, 1369, -302, -28, -302, 67, 67, 1369, -29, 102, -24, 102, -28, 104, 1243, -28, -17, 1243, -25, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 105, -302, -302, 961, 1243, -302, -302, -302, 1243, 1243, 1243, 1243, -302, -302, -302, 9, 155, 1426, 1426, 1452, 1452, 1476, 1476, 1498, 1498, 1518, 1518, 1572, 1572, 724, 724, 1230, 1230, 661, 661, -302, 67, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, 107, 27, -302, -28, 1216, -302, 158, 1601, 50, 1619, 61, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, -302, 1311, 149, -302, -302, -302, 1278, 171, 175, 181, 1243, 1243, 1619, -302, -28, -302, 194, -302, 918, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 1216, -4, 70, -302, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 1216, -302, 1243, 1243, 1243, 1243, 1340, 1340, -302, -302, 187, 67, -302, -302, 1637, 1655, 140, 191, 350, 574, 151, 746, 421, 755, 372, 429, 49, 196, 203, 209, -2, 38, 1034, 148, 1216, -302, 1672, 1672, 310, 310, 1685, 1685, 1696, 1696, 287, 287, 230, 230, 172, 172, -19, -19, 166, 166, 160, -302, 1340, 1311, 1311, 1619, 67, -302, 26, 995, -302, 556, -302, -302 }; /* YYPGOTO[NTERM-NUM]. */ static const short yypgoto[] = { -302, -302, -302, -302, 88, -302, 114, 63, 84, 97, -302, 100, -302, 127, 106, 108, -302, -16, -70, -3, -302, 246, -250, -302, -302, -301, -302, 109, 267, -302, -302, -5, 332, 7, 74, -60, -302, -302, 275, -1, 1 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -181 static const short yytable[] = { 60, 161, 61, 66, 71, 71, 71, 77, 58, 61, 84, -70, 334, 85, 176, -78, 88, -96, 90, 92, 92, 92, 165, 97, -70, 166, 205, 283, 63, 62, 45, 95, 387, 45, 330, 331, 332, 78, 53, 176, 176, 53, 80, 110, 100, -79, 104, 97, 112, 159, 99, 45, 137, 332, 273, -180, 111, -97, 287, 53, 139, 137, -70, 368, 167, -78, 168, -96, -92, 163, 162, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 253, 174, 161, 400, 332, 97, -79, 140, 255, 288, 195, 328, 329, 330, 331, 332, 169, 311, -97, 45, 93, 94, 210, 72, 73, 164, 97, 53, 333, -92, 45, 207, 208, 209, 256, 211, 45, 367, 53, 45, 170, 173, 196, 201, 53, 200, 203, 53, 206, 66, 71, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, -82, 162, 197, 260, 262, 77, 175, 61, 265, 270, 84, -86, 275, 272, 284, 176, 97, 276, 292, 286, 271, 176, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 336, 337, -82, -83, 280, 281, 282, 338, -93, 344, 343, 287, 395, -86, 332, -94, 328, 329, 330, 331, 332, -95, 264, 262, 397, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 328, 329, 330, 331, 332, 267, 232, 290, 262, 330, 331, 332, 314, -83, 314, 330, 331, 332, -93, 268, 233, 56, 254, 269, 342, -94, 278, 263, 388, 59, 0, -95, 326, 327, 328, 329, 330, 331, 332, 162, 0, 0, 346, 0, 260, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 0, 314, 0, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, 57, 324, 325, 326, 327, 328, 329, 330, 331, 332, 262, 0, 0, 0, 86, 0, 0, 89, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 262, 0, 0, -84, 0, 0, 0, 0, 0, 98, 102, 0, 105, 109, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, -90, 262, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 261, 0, 0, 0, 0, 0, 0, 0, 0, -84, 0, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 198, 0, 0, 0, 0, 0, 0, 0, -88, -90, 0, 0, 0, 105, 105, 105, -91, 105, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 324, 325, 326, 327, 328, 329, 330, 331, 332, 285, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 0, -88, 0, 0, 0, 0, 0, 0, 0, -91, 0, 0, 0, 291, 0, 105, 0, 0, 274, 0, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 0, 0, 0, 0, 102, 0, 0, 0, 279, 105, 105, 105, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 0, 0, 0, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 365, 0, 0, 0, 0, 0, 0, 0, 393, 0, 0, 392, 0, 0, -85, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 396, 0, 339, 340, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 0, 0, 0, 0, 0, 398, 0, 0, 0, -85, 0, 0, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 16, 17, 0, 0, 18, 105, 389, 390, 391, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 171, 0, -32, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 0, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -87, 0, 0, 0, 0, 0, 0, 0, 0, -89, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 113, 0, -87, 114, 0, 0, 0, 0, 0, 0, 0, -89, 24, 115, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 172, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 204, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 0, 0, 0, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 345, 0, 24, 0, 0, 101, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 0, 0, 0, 277, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 393, 394, 0, 0, 197, 0, 0, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 0, 0, 0, 0, 0, 0, 0, 0, 24, 115, 0, 0, 116, 117, 0, 394, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 199, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 115, 0, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 24, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 255, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 256, 24, 45, 0, 0, 0, 0, 0, 0, 0, 53, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 0, 0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 335, 0, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 116, 117, 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 63, 0, 45, 0, 0, 0, 0, 0, 0, 0, 53, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 95, 0, 45, 0, 0, 0, 0, 0, 0, 0, 53, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 127, 128, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 129, 130, 131, 132, 133, 134, 135, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, -100, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, -101, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332 }; static const short yycheck[] = { 1, 71, 1, 4, 5, 6, 7, 8, 1, 8, 11, 18, 262, 14, 31, 19, 17, 19, 19, 20, 21, 22, 31, 24, 31, 31, 18, 18, 56, 69, 58, 56, 333, 58, 53, 54, 55, 66, 66, 31, 31, 66, 66, 48, 43, 19, 45, 48, 69, 56, 43, 58, 70, 55, 71, 70, 49, 19, 31, 66, 31, 70, 69, 313, 70, 69, 31, 69, 19, 18, 71, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 95, 161, 393, 55, 95, 69, 31, 30, 71, 98, 51, 52, 53, 54, 55, 70, 56, 69, 58, 21, 22, 116, 6, 7, 18, 116, 66, 56, 69, 58, 113, 114, 115, 56, 117, 58, 56, 66, 58, 31, 31, 71, 29, 66, 72, 22, 66, 18, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 19, 161, 71, 163, 164, 165, 22, 165, 65, 64, 170, 19, 176, 173, 18, 31, 176, 71, 19, 71, 172, 31, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 36, 33, 69, 19, 204, 205, 206, 33, 19, 22, 287, 31, 71, 69, 55, 19, 51, 52, 53, 54, 55, 19, 166, 231, 71, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 51, 52, 53, 54, 55, 168, 139, 255, 256, 53, 54, 55, 260, 69, 262, 53, 54, 55, 69, 169, 140, 1, 161, 170, 287, 69, 199, 165, 335, 1, -1, 69, 49, 50, 51, 52, 53, 54, 55, 287, -1, -1, 292, -1, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, -1, 313, -1, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 1, 47, 48, 49, 50, 51, 52, 53, 54, 55, 344, -1, -1, -1, 15, -1, -1, 18, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 367, -1, -1, 19, -1, -1, -1, -1, -1, 43, 44, -1, 46, 47, -1, 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 393, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, 164, -1, -1, -1, -1, -1, -1, -1, -1, 69, -1, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, -1, -1, 19, 69, -1, -1, -1, 113, 114, 115, 19, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 47, 48, 49, 50, 51, 52, 53, 54, 55, 231, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, -1, 69, -1, -1, -1, -1, -1, -1, -1, 69, -1, -1, -1, 256, -1, 172, -1, -1, 175, -1, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, -1, -1, -1, -1, 199, -1, -1, -1, 203, 204, 205, 206, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, -1, -1, -1, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, 344, -1, -1, 19, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, 367, -1, 283, 284, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, -1, -1, -1, -1, -1, 393, -1, -1, -1, 69, -1, -1, 0, 1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -1, 16, 17, -1, -1, 20, 335, 336, 337, 338, 25, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 15, -1, 69, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, -1, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 19, -1, -1, -1, -1, -1, -1, -1, -1, 19, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, 18, -1, 69, 21, -1, -1, -1, -1, -1, -1, -1, 69, 30, 31, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 21, -1, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 23, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, -1, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 71, -1, 30, -1, -1, 72, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, -1, -1, -1, 71, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 31, 71, -1, -1, 71, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, -1, -1, 34, 35, -1, 71, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, 31, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, 31, -1, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, -1, -1, -1, -1, -1, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 30, -1, -1, -1, -1, -1, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 30, 58, -1, -1, -1, -1, -1, -1, -1, 66, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, -1, -1, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 32, -1, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 34, 35, -1, -1, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, -1, 58, -1, -1, -1, -1, -1, -1, -1, 66, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, -1, 58, -1, -1, -1, -1, -1, -1, -1, 66, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { 0, 74, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 25, 26, 27, 28, 29, 30, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 75, 76, 101, 105, 106, 111, 112, 113, 69, 56, 78, 79, 112, 85, 86, 87, 91, 112, 87, 87, 100, 101, 111, 112, 66, 80, 66, 81, 83, 84, 112, 112, 105, 112, 112, 105, 112, 77, 112, 77, 77, 56, 104, 112, 105, 106, 113, 72, 105, 107, 113, 105, 106, 108, 109, 105, 104, 106, 69, 18, 21, 31, 34, 35, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 105, 70, 113, 31, 31, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 88, 91, 112, 18, 18, 31, 31, 70, 31, 70, 31, 15, 21, 31, 104, 22, 31, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 113, 71, 71, 105, 31, 72, 29, 110, 22, 23, 18, 18, 106, 106, 106, 104, 106, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 102, 103, 79, 86, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 90, 91, 88, 30, 56, 92, 93, 94, 112, 94, 112, 100, 80, 65, 82, 81, 82, 84, 64, 106, 112, 71, 105, 104, 71, 71, 107, 105, 106, 106, 106, 18, 18, 94, 71, 31, 71, 99, 112, 94, 19, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 95, 96, 112, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 95, 32, 36, 33, 33, 105, 105, 89, 90, 91, 22, 71, 92, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 98, 56, 95, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 98, 108, 105, 105, 105, 94, 31, 71, 71, 94, 71, 94, 97, 98 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ #endif #if ! defined (YYSIZE_T) && defined (size_t) # define YYSIZE_T size_t #endif #if ! defined (YYSIZE_T) # if defined (__STDC__) || defined (__cplusplus) # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif #endif #if ! defined (YYSIZE_T) # define YYSIZE_T unsigned int #endif #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Compute the default location (before the actions are run). */ #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.first_line = Rhs[1].first_line; \ Current.first_column = Rhs[1].first_column; \ Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (YYLEX_PARAM) #else # define YYLEX yylex () #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (0) # define YYDSYMPRINT(Args) \ do { \ if (yydebug) \ yysymprint Args; \ } while (0) # define YYDSYMPRINTF(Title, Token, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yysymprint (stderr, \ Token, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (cinluded). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_stack_print (short *bottom, short *top) #else static void yy_stack_print (bottom, top) short *bottom; short *top; #endif { YYFPRINTF (stderr, "Stack now"); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yy_reduce_print (int yyrule) #else static void yy_reduce_print (yyrule) int yyrule; #endif { int yyi; unsigned int yylineno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", yyrule - 1, yylineno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ } while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YYDSYMPRINT(Args) # define YYDSYMPRINTF(Title, Token, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #if YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined (__GLIBC__) && defined (_STRING_H) # define yystrlen strlen # else /* Return the length of YYSTR. */ static YYSIZE_T # if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) # else yystrlen (yystr) const char *yystr; # endif { register const char *yys = yystr; while (*yys++ != '\0') continue; return yys - yystr - 1; } # endif # endif # ifndef yystpcpy # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ static char * # if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) # else yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; # endif { register char *yyd = yydest; register const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif #endif /* !YYERROR_VERBOSE */ #if YYDEBUG /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) #else static void yysymprint (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; if (yytype < YYNTOKENS) { YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); # ifdef YYPRINT YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif } else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); switch (yytype) { default: break; } YYFPRINTF (yyoutput, ")"); } #endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void yydestruct (int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yytype, yyvaluep) int yytype; YYSTYPE *yyvaluep; #endif { /* Pacify ``unused variable'' warnings. */ (void) yyvaluep; switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM); # else int yyparse (); # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM # if defined (__STDC__) || defined (__cplusplus) int yyparse (void *YYPARSE_PARAM) # else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; # endif #else /* ! YYPARSE_PARAM */ #if defined (__STDC__) || defined (__cplusplus) int yyparse (void) #else int yyparse () #endif #endif { register int yystate; register int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ /* int yyerrstatus; */ /* Lookahead token as an internal (translated) token number. */ int yytoken = 0; /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ short yyssa[YYINITDEPTH]; short *yyss = yyssa; register short *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; #define YYPOPSTACK (yyvsp--, yyssp--) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* When reducing, the number of symbols on the RHS of the reduced rule. */ int yylen; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow ("parser stack overflow", &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyoverflowlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyoverflowlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { short *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyoverflowlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: { erroneous = FALSE; } break; case 3: { erroneous = FALSE; } break; case 4: { clean_slate(); mod_fetch(); } break; case 5: { clean_slate(); yyerrok; } break; case 7: { preserve(); } break; case 8: { preserve(); } break; case 10: { type_syn(yyvsp[-2].deftype, yyvsp[0].type); } break; case 11: { decl_type(yyvsp[-2].deftype, yyvsp[0].cons); } break; case 12: { mod_private(); } break; case 14: {;} break; case 15: { def_value(yyvsp[-2].expr, yyvsp[0].expr); } break; case 16: { def_value(yyvsp[-2].expr, yyvsp[0].expr); } break; case 17: { def_value(yyvsp[-2].expr, yyvsp[0].expr); } break; case 18: { eval_expr(yyvsp[0].expr); } break; case 19: { wr_expr(yyvsp[0].expr, (const char *)0); } break; case 20: { wr_expr(yyvsp[-2].expr, (const char *)(yyvsp[0].textval->t_start)); } break; case 21: { display(); } break; case 22: { preserve(); } break; case 23: { mod_save(yyvsp[0].strval); } break; case 24: { edit((String)0); } break; case 25: { edit(yyvsp[0].strval); } break; case 26: { YYACCEPT; } break; case 34: {;} break; case 37: { tv_declare(yyvsp[0].strval); } break; case 38: { op_declare(yyvsp[-2].strval, yyvsp[0].intval, ASSOC_LEFT); yyval.intval = yyvsp[0].intval; } break; case 39: { op_declare(yyvsp[-2].strval, yyvsp[0].intval, ASSOC_LEFT); yyval.intval = yyvsp[0].intval; } break; case 40: { op_declare(yyvsp[-2].strval, yyvsp[0].intval, ASSOC_RIGHT); yyval.intval = yyvsp[0].intval; } break; case 41: { op_declare(yyvsp[-2].strval, yyvsp[0].intval, ASSOC_RIGHT); yyval.intval = yyvsp[0].intval; } break; case 42: { yyval.intval = (int)yyvsp[0].numval; } break; case 45: { mod_use(yyvsp[0].strval); } break; case 48: { abstype(yyvsp[0].deftype); } break; case 49: { yyval.deftype = new_deftype(yyvsp[-1].strval, FALSE, yyvsp[0].typelist); } break; case 50: { yyval.deftype = new_deftype(yyvsp[-3].strval, FALSE, cons_type(yyvsp[-1].type, NULL)); } break; case 51: { yyval.deftype = new_deftype(yyvsp[-3].strval, TRUE, yyvsp[-1].typelist); } break; case 52: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 53: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 54: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 55: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 56: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 57: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 58: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 59: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 60: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 61: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 62: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 63: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 64: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 65: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 66: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 67: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 68: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 69: { yyval.deftype = new_deftype(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 70: { yyval.typelist = NULL; } break; case 71: { yyval.typelist = cons_type(yyvsp[-1].type, yyvsp[0].typelist); } break; case 72: { yyval.typelist = cons_type(yyvsp[0].type, (TypeList *)NULL); } break; case 73: { yyval.typelist = yyvsp[0].typelist; } break; case 74: { yyval.typelist = cons_type(yyvsp[-2].type, yyvsp[0].typelist); } break; case 75: { yyval.type = new_tv(yyvsp[0].strval); } break; case 76: { yyval.cons = alt_cons(yyvsp[0].cons, (Cons *)NULL); } break; case 77: { yyval.cons = alt_cons(yyvsp[-2].cons, yyvsp[0].cons); } break; case 78: { yyval.cons = constructor(yyvsp[-1].strval, FALSE, yyvsp[0].typelist); } break; case 79: { yyval.cons = constructor(yyvsp[-3].strval, TRUE, yyvsp[-1].typelist); } break; case 80: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 81: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 82: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 83: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 84: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 85: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 86: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 87: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 88: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 89: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 90: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 91: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 92: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 93: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 94: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 95: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 96: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 97: { yyval.cons = constructor(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 98: { yyval.type = new_type(yyvsp[-1].strval, FALSE, yyvsp[0].typelist); } break; case 99: { yyval.type = new_type(yyvsp[-3].strval, TRUE, yyvsp[-1].typelist); } break; case 100: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 101: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 102: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 103: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 104: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 105: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 106: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 107: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 108: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 109: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 110: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 111: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 112: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 113: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 114: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 115: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 116: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 117: { yyval.type = new_type(yyvsp[-1].strval, TRUE, cons_type(yyvsp[-2].type, cons_type(yyvsp[0].type, (TypeList *)NULL))); } break; case 118: { yyval.type = mu_type(yyvsp[0].type); } break; case 119: { yyval.type = yyvsp[-1].type; } break; case 120: { yyval.typelist = (TypeList *)NULL; } break; case 121: { yyval.typelist = cons_type(yyvsp[-1].type, yyvsp[0].typelist); } break; case 122: { yyval.type = new_type(yyvsp[0].strval, FALSE, (TypeList *)NULL); } break; case 123: { yyval.type = yyvsp[-1].type; } break; case 124: { yyval.typelist = cons_type(yyvsp[0].type, (TypeList *)NULL); } break; case 125: { yyval.typelist = yyvsp[0].typelist; } break; case 126: { yyval.typelist = cons_type(yyvsp[-2].type, yyvsp[0].typelist); } break; case 127: { enter_mu_tv(yyvsp[0].strval); } break; case 128: { yyval.qtype = yyvsp[0].qtype; } break; case 129: { decl_value(yyvsp[-2].strval, yyvsp[0].qtype); yyval.qtype = yyvsp[0].qtype; } break; case 130: { decl_value(yyvsp[-2].strval, yyvsp[0].qtype); yyval.qtype = yyvsp[0].qtype; } break; case 131: { yyval.qtype = qualified_type(yyvsp[0].type); } break; case 132: { start_dec_type(); } break; case 133: { yyval.expr = id_expr(yyvsp[0].strval); } break; case 134: { yyval.expr = pair_expr(yyvsp[-2].expr, yyvsp[0].expr); } break; case 135: { yyval.expr = yyvsp[-1].expr; } break; case 136: { yyval.expr = id_expr(yyvsp[0].strval); } break; case 137: { yyval.expr = num_expr(yyvsp[0].numval); } break; case 138: { yyval.expr = text_expr(yyvsp[0].textval->t_start, yyvsp[0].textval->t_length); } break; case 139: { yyval.expr = char_expr(yyvsp[0].charval); } break; case 140: { yyval.expr = presection(yyvsp[-1].strval, yyvsp[-2].expr); } break; case 141: { yyval.expr = postsection(yyvsp[-2].strval, yyvsp[-1].expr); } break; case 142: { yyval.expr = yyvsp[-1].expr; } break; case 143: { yyval.expr = yyvsp[-1].expr; } break; case 144: { yyval.expr = e_nil; } break; case 145: { yyval.expr = apply_expr(yyvsp[-1].expr, yyvsp[0].expr); } break; case 146: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 147: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 148: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 149: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 150: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 151: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 152: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 153: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 154: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 155: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 156: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 157: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 158: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 159: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 160: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 161: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 162: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 163: { yyval.expr = apply_expr(id_expr(yyvsp[-1].strval), pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 164: { yyval.expr = func_expr(yyvsp[-1].branch); } break; case 165: { yyval.expr = ite_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr); } break; case 166: { yyval.expr = let_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr, FALSE); } break; case 167: { yyval.expr = let_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr, TRUE); } break; case 168: { yyval.expr = where_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr, FALSE); } break; case 169: { yyval.expr = where_expr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr, TRUE); } break; case 170: { yyval.expr = mu_expr(yyvsp[-2].expr, yyvsp[0].expr); } break; case 171: { yyval.expr = yyvsp[0].expr; } break; case 172: { yyval.expr = pair_expr(yyvsp[-2].expr, yyvsp[0].expr); } break; case 173: { yyval.expr = apply_expr(e_cons, pair_expr(yyvsp[0].expr, e_nil)); } break; case 174: { yyval.expr = apply_expr(e_cons, pair_expr(yyvsp[-2].expr, yyvsp[0].expr)); } break; case 175: { yyval.branch = new_branch(yyvsp[-2].expr, yyvsp[0].expr, (Branch *)0); } break; case 176: { yyval.branch = new_branch(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].branch); } break; case 177: { yyval.expr = apply_expr((Expr *)0, yyvsp[0].expr); } break; case 180: { yyval.strval = yyvsp[0].strval; } break; case 181: { yyval.strval = yyvsp[0].strval; } break; case 182: { yyval.strval = yyvsp[0].strval; } break; case 183: { yyval.strval = yyvsp[-1].strval; } break; case 184: { yyval.strval = yyvsp[0].strval; } break; case 185: { yyval.strval = yyvsp[0].strval; } break; case 186: { yyval.strval = yyvsp[0].strval; } break; case 187: { yyval.strval = yyvsp[0].strval; } break; case 188: { yyval.strval = yyvsp[0].strval; } break; case 189: { yyval.strval = yyvsp[0].strval; } break; case 190: { yyval.strval = yyvsp[0].strval; } break; case 191: { yyval.strval = yyvsp[0].strval; } break; case 192: { yyval.strval = yyvsp[0].strval; } break; case 193: { yyval.strval = yyvsp[0].strval; } break; case 194: { yyval.strval = yyvsp[0].strval; } break; case 195: { yyval.strval = yyvsp[0].strval; } break; case 196: { yyval.strval = yyvsp[0].strval; } break; case 197: { yyval.strval = yyvsp[0].strval; } break; case 198: { yyval.strval = yyvsp[0].strval; } break; case 199: { yyval.strval = yyvsp[0].strval; } break; case 200: { yyval.strval = yyvsp[0].strval; } break; case 201: { yyval.strval = yyvsp[0].strval; } break; case 202: { yyval.strval = yyvsp[0].strval; } break; } /* Line 999 of yacc.c. */ yyvsp -= yylen; yyssp -= yylen; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if YYERROR_VERBOSE yyn = yypact[yystate]; if (YYPACT_NINF < yyn && yyn < YYLAST) { YYSIZE_T yysize = 0; int yytype = YYTRANSLATE (yychar); char *yymsg; int yyx, yycount; yycount = 0; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) yysize += yystrlen (yytname[yyx]) + 15, yycount++; yysize += yystrlen ("syntax error, unexpected ") + 1; yysize += yystrlen (yytname[yytype]); yymsg = (char *) YYSTACK_ALLOC (yysize); if (yymsg != 0) { char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); yyp = yystpcpy (yyp, yytname[yytype]); if (yycount < 5) { yycount = 0; for (yyx = yyn < 0 ? -yyn : 0; yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { const char *yyq = ! yycount ? ", expecting " : " or "; yyp = yystpcpy (yyp, yyq); yyp = yystpcpy (yyp, yytname[yyx]); yycount++; } } yyerror (yymsg); YYSTACK_FREE (yymsg); } else yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ yyerror ("syntax error"); } if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ /* Return failure if at end of input. */ if (yychar == YYEOF) { /* Pop the error token. */ YYPOPSTACK; /* Pop the rest of the stack. */ while (yyss < yyssp) { YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[*yyssp], yyvsp); YYPOPSTACK; } YYABORT; } YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); yydestruct (yytoken, &yylval); yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; /*----------------------------------------------------. | yyerrlab1 -- error raised explicitly by an action. | `----------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); yyvsp--; yystate = *--yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; YYDPRINTF ((stderr, "Shifting error token, ")); *++yyvsp = yylval; yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*----------------------------------------------. | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: yyerror ("parser stack overflow"); yyresult = 2; /* Fall through. */ #endif yyreturn: #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif return yyresult; }
dmbaturin/hope
src/yyparse.c
C
gpl-2.0
99,821
[ 30522, 1013, 1008, 1037, 22285, 11968, 8043, 1010, 2081, 2011, 27004, 22285, 1015, 1012, 27658, 2050, 1012, 1008, 1013, 1013, 1008, 13526, 11968, 8043, 2005, 8038, 30524, 1010, 4297, 1012, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 241...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* __ * _| |_ * ____ _ _ __ __ _ __ __ ____ |_ _| * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ __ |__| * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | _| |_ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ |_ _| * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| |__| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * @author PocketMine++ Team * @link http://pm-plus-plus.tk/ */ namespace pocketmine\entity; use pocketmine\inventory\InventoryHolder; use pocketmine\inventory\PlayerInventory; use pocketmine\item\Item as ItemItem; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\StringTag; use pocketmine\network\NetworkTag; use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\RemovePlayerPacket; use pocketmine\Player; use pocketmine\utils\UUID; class Human extends Creature implements ProjectileSource, InventoryHolder { const DATA_PLAYER_FLAG_SLEEP = 1; const DATA_PLAYER_FLAG_DEAD = 2; const DATA_PLAYER_FLAGS = 16; const DATA_PLAYER_BED_POSITION = 17; /** @var PlayerInventory */ protected $inventory; /** @var UUID */ protected $uuid; protected $rawUUID; public $width = 0.6; public $length = 0.6; public $height = 1.8; public $eyeHeight = 1.62; protected $skin; protected $skinname; protected $isOldClient; protected $isSlim = \false; protected $isTransparent = \false; public function getSkinData() { return $this->skin; } public function getSkinName() { return $this->skinname; } public function isOldClient() { return $this->isOldClient; } public function isSkinTransparent() { return $this->isTransparent; } public function isSkinSlim() { return $this->isSlim; } /** * @return UUID|null */ public function getUniqueId() { return $this->uuid; } /** * @return string */ public function getRawUniqueId() { return $this->rawUUID; } /** * @param string $str * @param bool $isSlim */ public function setSkin($str, $skinname = "", $isOldClient = \false, $isSlim = \false, $isTransparent = \null) { $this->skin = $str; $this->skinname = $skinname; $this->isOldClient = (bool)$isOldClient; $this->isTransparent = (bool)$isTransparent; $this->isSlim = (bool)$isSlim; } public function getInventory() { return $this->inventory; } protected function initEntity() { $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, \false); $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [0, 0, 0]); $this->inventory = new PlayerInventory($this); if ($this instanceof Player) { $this->addWindow($this->inventory, 0); } if (!($this instanceof Player)) { if (isset($this->namedtag->NameTag)) { $this->setNameTag($this->namedtag["NameTag"]); } if (isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag) { $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Slim"] > 0, $this->namedtag->Skin["Transparent"] > 0); } $this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag()); } if (isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof ListTag) { foreach ($this->namedtag->Inventory as $item) { if ($item["Slot"] >= 0 and $item["Slot"] < 9) { //Hotbar $this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1); } elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) { //Armor $this->inventory->setItem($this->inventory->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item)); } else { $this->inventory->setItem($item["Slot"] - 9, NBT::getItemHelper($item)); } } } parent::initEntity(); } public function getName() { return $this->getNameTag(); } public function getDrops() { $drops = []; if ($this->inventory !== \null) { foreach ($this->inventory->getContents() as $item) { $drops[] = $item; } } return $drops; } public function saveNBT() { parent::saveNBT(); $this->namedtag->Inventory = new ListTag("Inventory", []); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); if ($this->inventory !== \null) { for ($slot = 0; $slot < 9; ++$slot) { $hotbarSlot = $this->inventory->getHotbarSlotIndex($slot); if ($hotbarSlot !== -1) { $item = $this->inventory->getItem($hotbarSlot); if ($item->getId() !== 0 and $item->getCount() > 0) { $tag = NBT::putItemHelper($item, $slot); $tag->TrueSlot = new ByteTag("TrueSlot", $hotbarSlot); $this->namedtag->Inventory[$slot] = $tag; continue; } } $this->namedtag->Inventory[$slot] = new CompoundTag("", [ new ByteTag("Count", 0), new ShortTag("Damage", 0), new ByteTag("Slot", $slot), new ByteTag("TrueSlot", -1), new ShortTag("id", 0), ]); } //Normal inventory $slotCount = Player::SURVIVAL_SLOTS + 9; //$slotCount = (($this instanceof Player and ($this->gamemode & 0x01) === 1) ? Player::CREATIVE_SLOTS : Player::SURVIVAL_SLOTS) + 9; for ($slot = 9; $slot < $slotCount; ++$slot) { $item = $this->inventory->getItem($slot - 9); $this->namedtag->Inventory[$slot] = NBT::putItemHelper($item, $slot); } //Armor for ($slot = 100; $slot < 104; ++$slot) { $item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100); if ($item instanceof ItemItem and $item->getId() !== ItemItem::AIR) { $this->namedtag->Inventory[$slot] = NBT::putItemHelper($item, $slot); } } } if (strlen($this->getSkinData()) > 0) { $this->namedtag->Skin = new CompoundTag("Skin", [ "Data" => new StringTag("Data", $this->getSkinData()), "Name" => new StringTag("Name", $this->getSkinName()), "Client" => new ByteTag("Clinet", $this->isOldClient() ? 1 : 0), "Slim" => new ByteTag("Slim", $this->isSkinSlim() ? 1 : 0), "Transparent" => new ByteTag("Transparent", $this->isSkinTransparent() ? 1 : 0) ]); } } public function spawnTo(Player $player) { if ($player !== $this and !isset($this->hasSpawned[$player->getLoaderId()])) { $this->hasSpawned[$player->getLoaderId()] = $player; if (strlen($this->skin) < 64 * 32 * 4) { throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set"); } if ($this instanceof Player) { $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->isSlim, $this->skin, [$player], $this->isTransparent, $this->skinname); } $pk = new AddPlayerPacket(); $pk->uuid = $this->getUniqueId(); $pk->username = $this->getName(); $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->item = $this->getInventory()->getItemInHand(); $pk->metadata = $this->dataProperties; $player->dataPacket($pk); $this->inventory->sendArmorContents($player); } } public function despawnFrom(Player $player) { if (isset($this->hasSpawned[$player->getLoaderId()])) { if ($this instanceof Player) { $this->server->removePlayerListData($this->getUniqueId(), [$player]); } $pk = new RemovePlayerPacket(); $pk->eid = $this->getId(); $pk->clientId = $this->getUniqueId(); $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } } public function close() { if (!$this->closed) { if (!($this instanceof Player) or $this->loggedIn) { foreach ($this->inventory->getViewers() as $viewer) { $viewer->removeWindow($this->inventory); } } parent::close(); } } }
PocketMinePlusPlus/PocketMinePlusPlus
src/pocketmine/entity/Human.php
PHP
gpl-2.0
9,941
[ 30522, 1026, 1029, 25718, 1013, 1008, 1035, 1035, 1008, 1035, 1064, 1064, 1035, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1035, 1035, 1064, 1008, 1064, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- coding: utf-8 -*- # # Copyright (C) Pootle contributors. # # This file is a part of the Pootle project. It is distributed under the GPL3 # or later license. See the LICENSE file for a copy of the license and the # AUTHORS file for copyright and authorship information. import io import os import six import pytest from pytest_pootle.factories import ( LanguageDBFactory, ProjectDBFactory, StoreDBFactory, TranslationProjectFactory) from pytest_pootle.utils import update_store from translate.storage.factory import getclass from django.db.models import Max from django.core.exceptions import ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from pootle.core.delegate import ( config, format_classes, format_diffs, formats) from pootle.core.models import Revision from pootle.core.delegate import deserializers, serializers from pootle.core.url_helpers import to_tp_relative_path from pootle.core.plugin import provider from pootle.core.serializers import Serializer, Deserializer from pootle_app.models import Directory from pootle_config.exceptions import ConfigurationError from pootle_format.exceptions import UnrecognizedFiletype from pootle_format.formats.po import PoStoreSyncer from pootle_format.models import Format from pootle_language.models import Language from pootle_project.models import Project from pootle_statistics.models import ( SubmissionFields, SubmissionTypes) from pootle_store.constants import ( NEW, OBSOLETE, PARSED, POOTLE_WINS, TRANSLATED) from pootle_store.diff import DiffableStore, StoreDiff from pootle_store.models import Store from pootle_store.util import parse_pootle_revision from pootle_translationproject.models import TranslationProject def _update_from_upload_file(store, update_file, content_type="text/x-gettext-translation", user=None, submission_type=None): with open(update_file, "r") as f: upload = SimpleUploadedFile(os.path.basename(update_file), f.read(), content_type) test_store = getclass(upload)(upload.read()) store_revision = parse_pootle_revision(test_store) store.update(test_store, store_revision=store_revision, user=user, submission_type=submission_type) def _store_as_string(store): ttk = store.syncer.convert(store.syncer.file_class) if hasattr(ttk, "updateheader"): # FIXME We need those headers on import # However some formats just don't support setting metadata ttk.updateheader( add=True, X_Pootle_Path=store.pootle_path) ttk.updateheader( add=True, X_Pootle_Revision=store.get_max_unit_revision()) return str(ttk) @pytest.mark.django_db def test_delete_mark_obsolete(project0_nongnu, project0, store0): """Tests that the in-DB Store and Directory are marked as obsolete after the on-disk file ceased to exist. Refs. #269. """ tp = TranslationProjectFactory( project=project0, language=LanguageDBFactory()) store = StoreDBFactory( translation_project=tp, parent=tp.directory) store.update(store.deserialize(store0.serialize())) store.sync() pootle_path = store.pootle_path # Remove on-disk file os.remove(store.file.path) # Update stores by rescanning TP tp.scan_files() # Now files that ceased to exist should be marked as obsolete updated_store = Store.objects.get(pootle_path=pootle_path) assert updated_store.obsolete # The units they contained are obsolete too assert not updated_store.units.exists() assert updated_store.unit_set.filter(state=OBSOLETE).exists() obs_unit = updated_store.unit_set.filter(state=OBSOLETE).first() obs_unit.submission_set.count() == 0 @pytest.mark.django_db def test_sync(project0_nongnu, project0, store0): """Tests that the new on-disk file is created after sync for existing in-DB Store if the corresponding on-disk file ceased to exist. """ tp = TranslationProjectFactory( project=project0, language=LanguageDBFactory()) store = StoreDBFactory( translation_project=tp, parent=tp.directory) store.update(store.deserialize(store0.serialize())) assert not store.file.exists() store.sync() assert store.file.exists() os.remove(store.file.path) assert not store.file.exists() store.sync() assert store.file.exists() @pytest.mark.django_db def test_update_from_ts(store0, test_fs, member): store0.parsed = True orig_units = store0.units.count() existing_created_at = store0.units.aggregate( Max("creation_time"))["creation_time__max"] existing_mtime = store0.units.aggregate( Max("mtime"))["mtime__max"] old_revision = store0.data.max_unit_revision with test_fs.open(['data', 'ts', 'tutorial', 'en', 'tutorial.ts']) as f: store = getclass(f)(f.read()) store0.update( store, submission_type=SubmissionTypes.UPLOAD, user=member) assert not store0.units[orig_units].hasplural() unit = store0.units[orig_units + 1] assert unit.submission_set.count() == 0 assert unit.hasplural() assert unit.creation_time >= existing_created_at assert unit.creation_time >= existing_mtime unit_source = unit.unit_source assert unit_source.created_with == SubmissionTypes.UPLOAD assert unit_source.created_by == member assert unit.change.changed_with == SubmissionTypes.UPLOAD assert unit.change.submitted_by == member assert unit.change.submitted_on >= unit.creation_time assert unit.change.reviewed_by is None assert unit.change.reviewed_on is None assert unit.revision > old_revision @pytest.mark.django_db def test_update_ts_plurals(store_po, test_fs, ts): project = store_po.translation_project.project filetype_tool = project.filetype_tool project.filetypes.add(ts) filetype_tool.set_store_filetype(store_po, ts) with test_fs.open(['data', 'ts', 'add_plurals.ts']) as f: file_store = getclass(f)(f.read()) store_po.update(file_store) unit = store_po.units[0] assert unit.hasplural() assert unit.submission_set.count() == 0 with test_fs.open(['data', 'ts', 'update_plurals.ts']) as f: file_store = getclass(f)(f.read()) store_po.update(file_store) unit = store_po.units[0] assert unit.hasplural() assert unit.submission_set.count() == 1 update_sub = unit.submission_set.first() assert update_sub.revision == unit.revision assert update_sub.creation_time == unit.change.submitted_on assert update_sub.submitter == unit.change.submitted_by assert update_sub.new_value == unit.target assert update_sub.type == unit.change.changed_with assert update_sub.field == SubmissionFields.TARGET # this fails 8( # from pootle.core.utils.multistring import unparse_multistring # assert ( # unparse_multistring(update_sub.new_value) # == unparse_multistring(unit.target)) @pytest.mark.django_db def test_update_with_non_ascii(store0, test_fs): store0.state = PARSED orig_units = store0.units.count() path = 'data', 'po', 'tutorial', 'en', 'tutorial_non_ascii.po' with test_fs.open(path) as f: store = getclass(f)(f.read()) store0.update(store) last_unit = store0.units[orig_units] updated_target = "Hèḽḽě, ŵôrḽḓ" assert last_unit.target == updated_target assert last_unit.submission_set.count() == 0 # last_unit.target = "foo" # last_unit.save() # this should now have a submission with the old target # but it fails # assert last_unit.submission_set.count() == 1 # update_sub = last_unit.submission_set.first() # assert update_sub.old_value == updated_target # assert update_sub.new_value == "foo" @pytest.mark.django_db def test_update_unit_order(project0_nongnu, ordered_po, ordered_update_ttk): """Tests unit order after a specific update. """ # Set last sync revision ordered_po.sync() assert ordered_po.file.exists() expected_unit_list = ['1->2', '2->4', '3->3', '4->5'] updated_unit_list = [unit.unitid for unit in ordered_po.units] assert expected_unit_list == updated_unit_list original_revision = ordered_po.get_max_unit_revision() ordered_po.update( ordered_update_ttk, store_revision=original_revision) expected_unit_list = [ 'X->1', '1->2', '3->3', '2->4', '4->5', 'X->6', 'X->7', 'X->8'] updated_unit_list = [unit.unitid for unit in ordered_po.units] assert expected_unit_list == updated_unit_list unit = ordered_po.units.first() assert unit.revision > original_revision assert unit.submission_set.count() == 0 @pytest.mark.django_db def test_update_save_changed_units(project0_nongnu, store0, member, system): """Tests that any update saves changed units only. """ # not sure if this is testing anything store = store0 # Set last sync revision store.sync() store.update(store.file.store) unit_list = list(store.units) store.file = 'tutorial/ru/update_save_changed_units_updated.po' store.update(store.file.store, user=member) updated_unit_list = list(store.units) # nothing changed for index in range(0, len(unit_list)): unit = unit_list[index] updated_unit = updated_unit_list[index] assert unit.revision == updated_unit.revision assert unit.mtime == updated_unit.mtime assert unit.target == updated_unit.target @pytest.mark.django_db def test_update_set_last_sync_revision(project0_nongnu, tp0, store0, test_fs): """Tests setting last_sync_revision after store creation. """ unit = store0.units.first() unit.target = "UPDATED TARGET" unit.save() store0.sync() # Store is already parsed and store.last_sync_revision should be equal to # max unit revision assert store0.last_sync_revision == store0.get_max_unit_revision() # store.last_sync_revision is not changed after empty update saved_last_sync_revision = store0.last_sync_revision store0.updater.update_from_disk() assert store0.last_sync_revision == saved_last_sync_revision orig = str(store0) update_file = test_fs.open( "data/po/tutorial/ru/update_set_last_sync_revision_updated.po", "r") with update_file as sourcef: with open(store0.file.path, "wb") as targetf: targetf.write(sourcef.read()) store0 = Store.objects.get(pk=store0.pk) # any non-empty update sets last_sync_revision to next global revision next_revision = Revision.get() + 1 store0.updater.update_from_disk() assert store0.last_sync_revision == next_revision # store.last_sync_revision is not changed after empty update (even if it # has unsynced units) item_index = 0 next_unit_revision = Revision.get() + 1 dbunit = store0.units.first() dbunit.target = "ANOTHER DB TARGET UPDATE" dbunit.save() assert dbunit.revision == next_unit_revision store0.updater.update_from_disk() assert store0.last_sync_revision == next_revision # Non-empty update sets store.last_sync_revision to next global revision # (even the store has unsynced units). There is only one unsynced unit in # this case so its revision should be set next to store.last_sync_revision next_revision = Revision.get() + 1 with open(store0.file.path, "wb") as targetf: targetf.write(orig) store0 = Store.objects.get(pk=store0.pk) store0.updater.update_from_disk() assert store0.last_sync_revision == next_revision # Get unsynced unit in DB. Its revision should be greater # than store.last_sync_revision to allow to keep this change during # update from a file dbunit = store0.units[item_index] assert dbunit.revision == store0.last_sync_revision + 1 @pytest.mark.django_db def test_update_upload_defaults(store0, system): store0.state = PARSED unit = store0.units.first() original_revision = unit.revision last_sub_pk = unit.submission_set.order_by( "id").values_list("id", flat=True).last() or 0 update_store( store0, [(unit.source, "%s UPDATED" % unit.source, False)], store_revision=Revision.get() + 1) unit = store0.units[0] assert unit.change.submitted_by == system assert unit.change.submitted_on >= unit.creation_time assert unit.change.submitted_by == system assert ( unit.submission_set.last().type == SubmissionTypes.SYSTEM) assert unit.revision > original_revision new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id") # there should be 2 new subs - state_change and target_change new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id") assert new_subs.count() == 2 target_sub = new_subs[0] assert target_sub.old_value == "" assert target_sub.new_value == unit.target assert target_sub.field == SubmissionFields.TARGET assert target_sub.type == SubmissionTypes.SYSTEM assert target_sub.submitter == system assert target_sub.revision == unit.revision assert target_sub.creation_time == unit.change.submitted_on state_sub = new_subs[1] assert state_sub.old_value == "0" assert state_sub.new_value == "200" assert state_sub.field == SubmissionFields.STATE assert state_sub.type == SubmissionTypes.SYSTEM assert state_sub.submitter == system assert state_sub.revision == unit.revision assert state_sub.creation_time == unit.change.submitted_on @pytest.mark.django_db def test_update_upload_member_user(store0, system, member): store0.state = PARSED original_unit = store0.units.first() original_revision = original_unit.revision last_sub_pk = original_unit.submission_set.order_by( "id").values_list("id", flat=True).last() or 0 update_store( store0, [(original_unit.source, "%s UPDATED" % original_unit.source, False)], user=member, store_revision=Revision.get() + 1, submission_type=SubmissionTypes.UPLOAD) unit = store0.units[0] assert unit.change.submitted_by == member assert unit.change.changed_with == SubmissionTypes.UPLOAD assert unit.change.submitted_on >= unit.creation_time assert unit.change.reviewed_on is None assert unit.revision > original_revision unit_source = unit.unit_source unit_source.created_by == system unit_source.created_with == SubmissionTypes.SYSTEM # there should be 2 new subs - state_change and target_change new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id") assert new_subs.count() == 2 target_sub = new_subs[0] assert target_sub.old_value == "" assert target_sub.new_value == unit.target assert target_sub.field == SubmissionFields.TARGET assert target_sub.type == SubmissionTypes.UPLOAD assert target_sub.submitter == member assert target_sub.revision == unit.revision assert target_sub.creation_time == unit.change.submitted_on state_sub = new_subs[1] assert state_sub.old_value == "0" assert state_sub.new_value == "200" assert state_sub.field == SubmissionFields.STATE assert state_sub.type == SubmissionTypes.UPLOAD assert state_sub.submitter == member assert state_sub.revision == unit.revision assert state_sub.creation_time == unit.change.submitted_on @pytest.mark.django_db def test_update_upload_submission_type(store0): store0.state = PARSED unit = store0.units.first() last_sub_pk = unit.submission_set.order_by( "id").values_list("id", flat=True).last() or 0 update_store( store0, [(unit.source, "%s UPDATED" % unit.source, False)], submission_type=SubmissionTypes.UPLOAD, store_revision=Revision.get() + 1) unit_source = store0.units[0].unit_source unit_change = store0.units[0].change assert unit_source.created_with == SubmissionTypes.SYSTEM assert unit_change.changed_with == SubmissionTypes.UPLOAD # there should be 2 new subs - state_change and target_change # and both should show as by UPLOAD new_subs = unit.submission_set.filter(id__gt=last_sub_pk) assert ( list(new_subs.values_list("type", flat=True)) == [SubmissionTypes.UPLOAD] * 2) @pytest.mark.django_db def test_update_upload_new_revision(store0, member): original_revision = store0.data.max_unit_revision old_unit = store0.units.first() update_store( store0, [("Hello, world", "Hello, world UPDATED", False)], submission_type=SubmissionTypes.UPLOAD, store_revision=Revision.get() + 1, user=member) old_unit.refresh_from_db() assert old_unit.state == OBSOLETE assert len(store0.units) == 1 unit = store0.units[0] unit_source = unit.unit_source assert unit.revision > original_revision assert unit_source.created_by == member assert unit.change.submitted_by == member assert unit.creation_time == unit.change.submitted_on assert unit.change.reviewed_by is None assert unit.change.reviewed_on is None assert unit.target == "Hello, world UPDATED" assert unit.submission_set.count() == 0 @pytest.mark.django_db def test_update_upload_again_new_revision(store0, member, member2): store = store0 assert store.state == NEW original_unit = store0.units[0] update_store( store, [("Hello, world", "Hello, world UPDATED", False)], submission_type=SubmissionTypes.UPLOAD, store_revision=Revision.get() + 1, user=member) original_unit.refresh_from_db() assert original_unit.state == OBSOLETE store = Store.objects.get(pk=store0.pk) assert store.state == PARSED created_unit = store.units[0] assert created_unit.target == "Hello, world UPDATED" assert created_unit.state == TRANSLATED assert created_unit.submission_set.count() == 0 old_unit_revision = store.data.max_unit_revision update_store( store0, [("Hello, world", "Hello, world UPDATED AGAIN", False)], submission_type=SubmissionTypes.WEB, user=member2, store_revision=Revision.get() + 1) assert created_unit.submission_set.count() == 1 update_sub = created_unit.submission_set.first() store = Store.objects.get(pk=store0.pk) assert store.state == PARSED unit = store.units[0] unit_source = unit.unit_source assert unit.revision > old_unit_revision assert unit.target == "Hello, world UPDATED AGAIN" assert unit_source.created_by == member assert unit_source.created_with == SubmissionTypes.UPLOAD assert unit.change.submitted_by == member2 assert unit.change.submitted_on >= unit.creation_time assert unit.change.reviewed_by is None assert unit.change.reviewed_on is None assert unit.change.changed_with == SubmissionTypes.WEB assert update_sub.creation_time == unit.change.submitted_on assert update_sub.type == unit.change.changed_with assert update_sub.field == SubmissionFields.TARGET assert update_sub.submitter == unit.change.submitted_by assert update_sub.old_value == created_unit.target assert update_sub.new_value == unit.target assert update_sub.revision == unit.revision @pytest.mark.django_db def test_update_upload_old_revision_unit_conflict(store0, admin, member): original_revision = Revision.get() original_unit = store0.units[0] update_store( store0, [("Hello, world", "Hello, world UPDATED", False)], submission_type=SubmissionTypes.UPLOAD, store_revision=original_revision + 1, user=admin) unit = store0.units[0] unit_source = unit.unit_source assert unit_source.created_by == admin updated_revision = unit.revision assert ( unit_source.created_with == SubmissionTypes.UPLOAD) assert unit.change.submitted_by == admin assert ( unit.change.changed_with == SubmissionTypes.UPLOAD) last_submit_time = unit.change.submitted_on assert last_submit_time >= unit.creation_time # load update with expired revision and conflicting unit update_store( store0, [("Hello, world", "Hello, world CONFLICT", False)], submission_type=SubmissionTypes.WEB, store_revision=original_revision, user=member) unit = store0.units[0] assert unit.submission_set.count() == 0 unit_source = unit.unit_source # unit target is not updated and revision remains the same assert store0.units[0].target == "Hello, world UPDATED" assert unit.revision == updated_revision unit_source = original_unit.unit_source unit_source.created_by == admin assert unit_source.created_with == SubmissionTypes.SYSTEM unit.change.changed_with == SubmissionTypes.UPLOAD unit.change.submitted_by == admin unit.change.submitted_on == last_submit_time unit.change.reviewed_by is None unit.change.reviewed_on is None # but suggestion is added suggestion = store0.units[0].get_suggestions()[0] assert suggestion.target == "Hello, world CONFLICT" assert suggestion.user == member @pytest.mark.django_db def test_update_upload_new_revision_new_unit(store0, member): file_name = "pytest_pootle/data/po/tutorial/en/tutorial_update_new_unit.po" store0.state = PARSED old_unit_revision = store0.data.max_unit_revision _update_from_upload_file( store0, file_name, user=member, submission_type=SubmissionTypes.WEB) unit = store0.units.last() unit_source = unit.unit_source # the new unit has been added assert unit.submission_set.count() == 0 assert unit.revision > old_unit_revision assert unit.target == 'Goodbye, world' assert unit_source.created_by == member assert unit_source.created_with == SubmissionTypes.WEB assert unit.change.submitted_by == member assert unit.change.changed_with == SubmissionTypes.WEB @pytest.mark.django_db def test_update_upload_old_revision_new_unit(store0, member2): store0.units.delete() store0.state = PARSED old_unit_revision = store0.data.max_unit_revision # load initial update _update_from_upload_file( store0, "pytest_pootle/data/po/tutorial/en/tutorial_update.po") # load old revision with new unit file_name = "pytest_pootle/data/po/tutorial/en/tutorial_update_old_unit.po" _update_from_upload_file( store0, file_name, user=member2, submission_type=SubmissionTypes.WEB) # the unit has been added because its not already obsoleted assert store0.units.count() == 2 unit = store0.units.last() unit_source = unit.unit_source # the new unit has been added assert unit.submission_set.count() == 0 assert unit.revision > old_unit_revision assert unit.target == 'Goodbye, world' assert unit_source.created_by == member2 assert unit_source.created_with == SubmissionTypes.WEB assert unit.change.submitted_by == member2 assert unit.change.changed_with == SubmissionTypes.WEB def _test_store_update_indexes(store, *test_args): # make sure indexes are not fooed indexes only have to be unique indexes = [x.index for x in store.units] assert len(indexes) == len(set(indexes)) def _test_store_update_units_before(*test_args): # test what has happened to the units that were present before the update (store, units_update, store_revision, resolve_conflict, units_before, member_, member2) = test_args updates = {unit[0]: unit[1] for unit in units_update} for unit, change in units_before: updated_unit = store.unit_set.get(unitid=unit.unitid) if unit.source not in updates: # unit is not in update, target should be left unchanged assert updated_unit.target == unit.target assert updated_unit.change.submitted_by == change.submitted_by # depending on unit/store_revision should be obsoleted if unit.isobsolete() or store_revision >= unit.revision: assert updated_unit.isobsolete() else: assert not updated_unit.isobsolete() else: # unit is in update if store_revision >= unit.revision: assert not updated_unit.isobsolete() elif unit.isobsolete(): # the unit has been obsoleted since store_revision assert updated_unit.isobsolete() else: assert not updated_unit.isobsolete() if not updated_unit.isobsolete(): if store_revision >= unit.revision: # file store wins outright assert updated_unit.target == updates[unit.source] if unit.target != updates[unit.source]: # unit has changed, or was resurrected assert updated_unit.change.submitted_by == member2 # damn mysql microsecond precision if change.submitted_on.time().microsecond != 0: assert ( updated_unit.change.submitted_on != change.submitted_on) elif unit.isobsolete(): # unit has changed, or was resurrected assert updated_unit.change.reviewed_by == member2 # damn mysql microsecond precision if change.reviewed_on.time().microsecond != 0: assert ( updated_unit.change.reviewed_on != change.reviewed_on) else: assert ( updated_unit.change.submitted_by == change.submitted_by) assert ( updated_unit.change.submitted_on == change.submitted_on) assert updated_unit.get_suggestions().count() == 0 else: # conflict found suggestion = updated_unit.get_suggestions()[0] if resolve_conflict == POOTLE_WINS: assert updated_unit.target == unit.target assert ( updated_unit.change.submitted_by == change.submitted_by) assert suggestion.target == updates[unit.source] assert suggestion.user == member2 else: assert updated_unit.target == updates[unit.source] assert updated_unit.change.submitted_by == member2 assert suggestion.target == unit.target assert suggestion.user == change.submitted_by def _test_store_update_ordering(*test_args): (store, units_update, store_revision, resolve_conflict_, units_before, member_, member2_) = test_args updates = {unit[0]: unit[1] for unit in units_update} old_units = {unit.source: unit for unit, change in units_before} # test ordering new_unit_list = [] for unit, change_ in units_before: add_unit = (not unit.isobsolete() and unit.source not in updates and unit.revision > store_revision) if add_unit: new_unit_list.append(unit.source) for source, target_, is_fuzzy_ in units_update: if source in old_units: old_unit = old_units[source] should_add = (not old_unit.isobsolete() or old_unit.revision <= store_revision) if should_add: new_unit_list.append(source) else: new_unit_list.append(source) assert new_unit_list == [x.source for x in store.units] def _test_store_update_units_now(*test_args): (store, units_update, store_revision, resolve_conflict_, units_before, member_, member2_) = test_args # test that all the current units should be there updates = {unit[0]: unit[1] for unit in units_update} old_units = {unit.source: unit for unit, change in units_before} for unit in store.units: assert ( unit.source in updates or (old_units[unit.source].revision > store_revision and not old_units[unit.source].isobsolete())) @pytest.mark.django_db def test_store_update(param_update_store_test): _test_store_update_indexes(*param_update_store_test) _test_store_update_units_before(*param_update_store_test) _test_store_update_units_now(*param_update_store_test) _test_store_update_ordering(*param_update_store_test) @pytest.mark.django_db def test_store_file_diff(store_diff_tests): diff, store, update_units, store_revision = store_diff_tests assert diff.target_store == store assert diff.source_revision == store_revision assert ( update_units == [(x.source, x.target, x.isfuzzy()) for x in diff.source_store.units[1:]] == [(v['source'], v['target'], v['state'] == 50) for v in diff.source_units.values()]) assert diff.active_target_units == [x.source for x in store.units] assert diff.target_revision == store.get_max_unit_revision() assert ( diff.target_units == {unit["source_f"]: unit for unit in store.unit_set.values("source_f", "index", "target_f", "state", "unitid", "id", "revision", "developer_comment", "translator_comment", "locations", "context")}) diff_diff = diff.diff() if diff_diff is not None: assert ( sorted(diff_diff.keys()) == ["add", "index", "obsolete", "update"]) # obsoleted units have no index - so just check they are all they match obsoleted = (store.unit_set.filter(state=OBSOLETE) .filter(revision__gt=store_revision) .values_list("source_f", flat=True)) assert len(diff.obsoleted_target_units) == obsoleted.count() assert all(x in diff.obsoleted_target_units for x in obsoleted) assert ( diff.updated_target_units == list(store.units.filter(revision__gt=store_revision) .values_list("source_f", flat=True))) @pytest.mark.django_db def test_store_repr(): store = Store.objects.first() assert str(store) == str(store.syncer.convert(store.syncer.file_class)) assert repr(store) == u"<Store: %s>" % store.pootle_path @pytest.mark.django_db def test_store_po_deserializer(test_fs, store_po): with test_fs.open("data/po/complex.po") as test_file: test_string = test_file.read() ttk_po = getclass(test_file)(test_string) store_po.update(store_po.deserialize(test_string)) assert len(ttk_po.units) - 1 == store_po.units.count() @pytest.mark.django_db def test_store_po_serializer(test_fs, store_po): with test_fs.open("data/po/complex.po") as test_file: test_string = test_file.read() ttk_po = getclass(test_file)(test_string) store_po.update(store_po.deserialize(test_string)) store_io = io.BytesIO(store_po.serialize()) store_ttk = getclass(store_io)(store_io.read()) assert len(store_ttk.units) == len(ttk_po.units) @pytest.mark.django_db def test_store_po_serializer_custom(test_fs, store_po): class SerializerCheck(object): original_data = None context = None checker = SerializerCheck() class EGSerializer(Serializer): @property def output(self): checker.original_data = self.original_data checker.context = self.context @provider(serializers, sender=Project) def provide_serializers(**kwargs): return dict(eg_serializer=EGSerializer) with test_fs.open("data/po/complex.po") as test_file: test_string = test_file.read() # ttk_po = getclass(test_file)(test_string) store_po.update(store_po.deserialize(test_string)) # add config to the project project = store_po.translation_project.project config.get(project.__class__, instance=project).set_config( "pootle.core.serializers", ["eg_serializer"]) store_po.serialize() assert checker.context == store_po assert ( not isinstance(checker.original_data, six.text_type) and isinstance(checker.original_data, str)) assert checker.original_data == _store_as_string(store_po) @pytest.mark.django_db def test_store_po_deserializer_custom(test_fs, store_po): class DeserializerCheck(object): original_data = None context = None checker = DeserializerCheck() class EGDeserializer(Deserializer): @property def output(self): checker.context = self.context checker.original_data = self.original_data return self.original_data @provider(deserializers, sender=Project) def provide_deserializers(**kwargs): return dict(eg_deserializer=EGDeserializer) with test_fs.open("data/po/complex.po") as test_file: test_string = test_file.read() # add config to the project project = store_po.translation_project.project config.get().set_config( "pootle.core.deserializers", ["eg_deserializer"], project) store_po.deserialize(test_string) assert checker.original_data == test_string assert checker.context == store_po @pytest.mark.django_db def test_store_base_serializer(store_po): original_data = "SOME DATA" serializer = Serializer(store_po, original_data) assert serializer.context == store_po assert serializer.data == original_data @pytest.mark.django_db def test_store_base_deserializer(store_po): original_data = "SOME DATA" deserializer = Deserializer(store_po, original_data) assert deserializer.context == store_po assert deserializer.data == original_data @pytest.mark.django_db def test_store_set_bad_deserializers(store_po): project = store_po.translation_project.project with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.deserializers", ["DESERIALIZER_DOES_NOT_EXIST"]) class EGDeserializer(object): pass @provider(deserializers) def provide_deserializers(**kwargs): return dict(eg_deserializer=EGDeserializer) # must be list with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.deserializers", "eg_deserializer") with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.deserializers", dict(serializer="eg_deserializer")) config.get(project.__class__, instance=project).set_config( "pootle.core.deserializers", ["eg_deserializer"]) @pytest.mark.django_db def test_store_set_bad_serializers(store_po): project = store_po.translation_project.project with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.serializers", ["SERIALIZER_DOES_NOT_EXIST"]) class EGSerializer(Serializer): pass @provider(serializers) def provide_serializers(**kwargs): return dict(eg_serializer=EGSerializer) # must be list with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.serializers", "eg_serializer") with pytest.raises(ConfigurationError): config.get(project.__class__, instance=project).set_config( "pootle.core.serializers", dict(serializer="eg_serializer")) config.get(project.__class__, instance=project).set_config( "pootle.core.serializers", ["eg_serializer"]) @pytest.mark.django_db def test_store_create_by_bad_path(project0): # bad project name with pytest.raises(Project.DoesNotExist): Store.objects.create_by_path( "/language0/does/not/exist.po") # bad language code with pytest.raises(Language.DoesNotExist): Store.objects.create_by_path( "/does/project0/not/exist.po") # project and project code dont match with pytest.raises(ValueError): Store.objects.create_by_path( "/language0/project1/store.po", project=project0) # bad store.ext with pytest.raises(ValueError): Store.objects.create_by_path( "/language0/project0/store_by_path.foo") # subdir doesnt exist path = '/language0/project0/path/to/subdir.po' with pytest.raises(Directory.DoesNotExist): Store.objects.create_by_path( path, create_directory=False) path = '/%s/project0/notp.po' % LanguageDBFactory().code with pytest.raises(TranslationProject.DoesNotExist): Store.objects.create_by_path( path, create_tp=False) @pytest.mark.django_db def test_store_create_by_path(po_directory): # create in tp path = '/language0/project0/path.po' store = Store.objects.create_by_path(path) assert store.pootle_path == path # "create" in tp again - get existing store store = Store.objects.create_by_path(path) assert store.pootle_path == path # create in existing subdir path = '/language0/project0/subdir0/exists.po' store = Store.objects.create_by_path(path) assert store.pootle_path == path # create in new subdir path = '/language0/project0/path/to/subdir.po' store = Store.objects.create_by_path(path) assert store.pootle_path == path @pytest.mark.django_db def test_store_create_by_path_with_project(project0): # create in tp with project path = '/language0/project0/path2.po' store = Store.objects.create_by_path( path, project=project0) assert store.pootle_path == path # create in existing subdir with project path = '/language0/project0/subdir0/exists2.po' store = Store.objects.create_by_path( path, project=project0) assert store.pootle_path == path # create in new subdir with project path = '/language0/project0/path/to/subdir2.po' store = Store.objects.create_by_path( path, project=project0) assert store.pootle_path == path @pytest.mark.django_db def test_store_create_by_new_tp_path(po_directory): language = LanguageDBFactory() path = '/%s/project0/tp.po' % language.code store = Store.objects.create_by_path(path) assert store.pootle_path == path assert store.translation_project.language == language language = LanguageDBFactory() path = '/%s/project0/with/subdir/tp.po' % language.code store = Store.objects.create_by_path(path) assert store.pootle_path == path assert store.translation_project.language == language @pytest.mark.django_db def test_store_create(tp0): tp = tp0 project = tp.project registry = formats.get() po = Format.objects.get(name="po") po2 = registry.register("special_po_2", "po") po3 = registry.register("special_po_3", "po") xliff = Format.objects.get(name="xliff") project.filetypes.add(xliff) project.filetypes.add(po2) project.filetypes.add(po3) store = Store.objects.create( name="store.po", parent=tp.directory, translation_project=tp) assert store.filetype == po assert not store.is_template store = Store.objects.create( name="store.pot", parent=tp.directory, translation_project=tp) # not in source_language folder assert not store.is_template assert store.filetype == po store = Store.objects.create( name="store.xliff", parent=tp.directory, translation_project=tp) assert store.filetype == xliff # push po to the back of the queue project.filetypes.remove(po) project.filetypes.add(po) store = Store.objects.create( name="another_store.po", parent=tp.directory, translation_project=tp) assert store.filetype == po2 store = Store.objects.create( name="another_store.pot", parent=tp.directory, translation_project=tp) assert store.filetype == po store = Store.objects.create( name="another_store.xliff", parent=tp.directory, translation_project=tp) with pytest.raises(UnrecognizedFiletype): store = Store.objects.create( name="another_store.foo", parent=tp.directory, translation_project=tp) @pytest.mark.django_db def test_store_create_name_with_slashes_or_backslashes(tp0): """Test Stores are not created with (back)slashes on their name.""" with pytest.raises(ValidationError): Store.objects.create(name="slashed/name.po", parent=tp0.directory, translation_project=tp0) with pytest.raises(ValidationError): Store.objects.create(name="backslashed\\name.po", parent=tp0.directory, translation_project=tp0) @pytest.mark.django_db def test_store_get_file_class(): store = Store.objects.filter( translation_project__project__code="project0", translation_project__language__code="language0").first() # this matches because po is recognised by ttk assert store.syncer.file_class == getclass(store) # file_class is cached so lets delete it del store.syncer.__dict__["file_class"] class CustomFormatClass(object): pass @provider(format_classes) def format_class_provider(**kwargs): return dict(po=CustomFormatClass) # we get the CutomFormatClass as it was registered assert store.syncer.file_class is CustomFormatClass # the Store.filetype is used in this case not the name store.name = "new_store_name.foo" del store.syncer.__dict__["file_class"] assert store.syncer.file_class is CustomFormatClass # lets register a foo filetype format_registry = formats.get() foo_filetype = format_registry.register("foo", "foo") store.filetype = foo_filetype store.save() # oh no! not recognised by ttk del store.syncer.__dict__["file_class"] with pytest.raises(ValueError): store.syncer.file_class @provider(format_classes) def another_format_class_provider(**kwargs): return dict(foo=CustomFormatClass) # works now assert store.syncer.file_class is CustomFormatClass format_classes.disconnect(format_class_provider) format_classes.disconnect(another_format_class_provider) @pytest.mark.django_db def test_store_get_template_file_class(po_directory, templates): project = ProjectDBFactory(source_language=templates) tp = TranslationProjectFactory(language=templates, project=project) format_registry = formats.get() foo_filetype = format_registry.register("foo", "foo", template_extension="bar") tp.project.filetypes.add(foo_filetype) store = Store.objects.create( name="mystore.bar", translation_project=tp, parent=tp.directory) # oh no! not recognised by ttk with pytest.raises(ValueError): store.syncer.file_class class CustomFormatClass(object): pass @provider(format_classes) def format_class_provider(**kwargs): return dict(foo=CustomFormatClass) assert store.syncer.file_class == CustomFormatClass format_classes.disconnect(format_class_provider) @pytest.mark.django_db def test_store_create_templates(po_directory, templates): project = ProjectDBFactory(source_language=templates) tp = TranslationProjectFactory(language=templates, project=project) po = Format.objects.get(name="po") store = Store.objects.create( name="mystore.pot", translation_project=tp, parent=tp.directory) assert store.filetype == po assert store.is_template @pytest.mark.django_db def test_store_get_or_create_templates(po_directory, templates): project = ProjectDBFactory(source_language=templates) tp = TranslationProjectFactory(language=templates, project=project) po = Format.objects.get(name="po") store = Store.objects.get_or_create( name="mystore.pot", translation_project=tp, parent=tp.directory)[0] assert store.filetype == po assert store.is_template @pytest.mark.django_db def test_store_diff(diffable_stores): target_store, source_store = diffable_stores differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) # no changes assert not differ.diff() assert differ.target_store == target_store assert differ.source_store == source_store @pytest.mark.django_db def test_store_diff_delete_target_unit(diffable_stores): target_store, source_store = diffable_stores # delete a unit in the target store remove_unit = target_store.units.first() remove_unit.delete() # the unit will always be re-added (as its not obsolete) # with source_revision to the max differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision()) result = differ.diff() assert result["add"][0][0].source_f == remove_unit.source_f assert len(result["add"]) == 1 assert len(result["index"]) == 0 assert len(result["obsolete"]) == 0 assert result['update'] == (set(), {}) # and source_revision to 0 differ = StoreDiff( target_store, source_store, 0) result = differ.diff() assert result["add"][0][0].source_f == remove_unit.source_f assert len(result["add"]) == 1 assert len(result["index"]) == 0 assert len(result["obsolete"]) == 0 assert result['update'] == (set(), {}) @pytest.mark.django_db def test_store_diff_delete_source_unit(diffable_stores): target_store, source_store = diffable_stores # delete a unit in the source store remove_unit = source_store.units.first() remove_unit.delete() # set the source_revision to max and the unit will be obsoleted differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision()) result = differ.diff() to_remove = target_store.units.get(unitid=remove_unit.unitid) assert result["obsolete"] == [to_remove.pk] assert len(result["obsolete"]) == 1 assert len(result["add"]) == 0 assert len(result["index"]) == 0 # set the source_revision to less that than the target_stores' max_revision # and the unit will be ignored, as its assumed to have been previously # deleted differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() - 1) assert not differ.diff() @pytest.mark.django_db def test_store_diff_delete_obsoleted_target_unit(diffable_stores): target_store, source_store = diffable_stores # delete a unit in the source store remove_unit = source_store.units.first() remove_unit.delete() # and obsolete the same unit in the target obsolete_unit = target_store.units.get(unitid=remove_unit.unitid) obsolete_unit.makeobsolete() obsolete_unit.save() # as the unit is already obsolete - nothing differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) assert not differ.diff() @pytest.mark.django_db def test_store_diff_obsoleted_target_unit(diffable_stores): target_store, source_store = diffable_stores # obsolete a unit in target obsolete_unit = target_store.units.first() obsolete_unit.makeobsolete() obsolete_unit.save() # as the revision is higher it gets unobsoleted differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) result = differ.diff() assert result["update"][0] == set([obsolete_unit.pk]) assert len(result["update"][1]) == 1 assert result["update"][1][obsolete_unit.unitid]["dbid"] == obsolete_unit.pk # if the revision is less - no change differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() - 1) assert not differ.diff() @pytest.mark.django_db def test_store_diff_update_target_unit(diffable_stores): target_store, source_store = diffable_stores # update a unit in target update_unit = target_store.units.first() update_unit.target_f = "Some other string" update_unit.save() # the unit is always marked for update differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) result = differ.diff() assert result["update"][0] == set([update_unit.pk]) assert result["update"][1] == {} assert len(result["add"]) == 0 assert len(result["index"]) == 0 differ = StoreDiff( target_store, source_store, 0) result = differ.diff() assert result["update"][0] == set([update_unit.pk]) assert result["update"][1] == {} assert len(result["add"]) == 0 assert len(result["index"]) == 0 @pytest.mark.django_db def test_store_diff_update_source_unit(diffable_stores): target_store, source_store = diffable_stores # update a unit in source update_unit = source_store.units.first() update_unit.target_f = "Some other string" update_unit.save() target_unit = target_store.units.get( unitid=update_unit.unitid) # the unit is always marked for update differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) result = differ.diff() assert result["update"][0] == set([target_unit.pk]) assert result["update"][1] == {} assert len(result["add"]) == 0 assert len(result["index"]) == 0 differ = StoreDiff( target_store, source_store, 0) result = differ.diff() assert result["update"][0] == set([target_unit.pk]) assert result["update"][1] == {} assert len(result["add"]) == 0 assert len(result["index"]) == 0 @pytest.mark.django_db def test_store_diff_custom(diffable_stores): target_store, source_store = diffable_stores class CustomDiffableStore(DiffableStore): pass @provider(format_diffs) def format_diff_provider(**kwargs): return { target_store.filetype.name: CustomDiffableStore} differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) assert isinstance( differ.diffable, CustomDiffableStore) @pytest.mark.django_db def test_store_diff_delete_obsoleted_source_unit(diffable_stores): target_store, source_store = diffable_stores # delete a unit in the target store remove_unit = target_store.units.first() remove_unit.delete() # and obsolete the same unit in the target obsolete_unit = source_store.units.get(unitid=remove_unit.unitid) obsolete_unit.makeobsolete() obsolete_unit.save() # as the unit is already obsolete - nothing differ = StoreDiff( target_store, source_store, target_store.get_max_unit_revision() + 1) assert not differ.diff() @pytest.mark.django_db def test_store_syncer(tp0): store = tp0.stores.live().first() assert isinstance(store.syncer, PoStoreSyncer) assert store.syncer.file_class == getclass(store) assert store.syncer.translation_project == store.translation_project assert ( store.syncer.language == store.translation_project.language) assert ( store.syncer.project == store.translation_project.project) assert ( store.syncer.source_language == store.translation_project.project.source_language) @pytest.mark.django_db def test_store_syncer_obsolete_unit(tp0): store = tp0.stores.live().first() unit = store.units.filter(state=TRANSLATED).first() unit_syncer = store.syncer.unit_sync_class(unit) newunit = unit_syncer.create_unit(store.syncer.file_class.UnitClass) # unit is untranslated, its always just deleted obsolete, deleted = store.syncer.obsolete_unit(newunit, True) assert not obsolete assert deleted obsolete, deleted = store.syncer.obsolete_unit(newunit, False) assert not obsolete assert deleted # set unit to translated newunit.target = unit.target # if conservative, nothings changed obsolete, deleted = store.syncer.obsolete_unit(newunit, True) assert not obsolete assert not deleted # not conservative and the unit is deleted obsolete, deleted = store.syncer.obsolete_unit(newunit, False) assert obsolete assert not deleted @pytest.mark.django_db def test_store_syncer_sync_store(tp0, dummy_store_syncer): store = tp0.stores.live().first() DummyStoreSyncer, __, expected = dummy_store_syncer disk_store = store.syncer.convert() dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], update_structure=expected["update_structure"], conservative=expected["conservative"]) assert result[0] is True assert result[1]["updated"] == expected["changes"] # conservative makes no diff here expected["conservative"] = False dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], update_structure=expected["update_structure"], conservative=expected["conservative"]) assert result[0] is True assert result[1]["updated"] == expected["changes"] @pytest.mark.django_db def test_store_syncer_sync_store_no_changes(tp0, dummy_store_syncer): store = tp0.stores.live().first() DummyStoreSyncer, __, expected = dummy_store_syncer disk_store = store.syncer.convert() dummy_syncer = DummyStoreSyncer(store, expected=expected) # no changes expected["changes"] = [] expected["conservative"] = True dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], expected["update_structure"], expected["conservative"]) assert result[0] is False assert not result[1].get("updated") # conservative makes no diff here expected["conservative"] = False dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], expected["update_structure"], expected["conservative"]) assert result[0] is False assert not result[1].get("updated") @pytest.mark.django_db def test_store_syncer_sync_store_structure(tp0, dummy_store_syncer): store = tp0.stores.live().first() DummyStoreSyncer, DummyDiskStore, expected = dummy_store_syncer disk_store = DummyDiskStore(expected) expected["update_structure"] = True expected["changes"] = [] dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], expected["update_structure"], expected["conservative"]) assert result[0] is True assert result[1]["updated"] == [] assert result[1]["obsolete"] == 8 assert result[1]["deleted"] == 9 assert result[1]["added"] == 10 expected["obsolete_units"] = [] expected["new_units"] = [] expected["changes"] = [] dummy_syncer = DummyStoreSyncer(store, expected=expected) result = dummy_syncer.sync( disk_store, expected["last_revision"], expected["update_structure"], expected["conservative"]) assert result[0] is False @pytest.mark.django_db def test_store_syncer_sync_update_structure(dummy_store_structure_syncer, tp0): store = tp0.stores.live().first() DummyStoreSyncer, DummyDiskStore, DummyUnit = dummy_store_structure_syncer expected = dict( unit_class="FOO", conservative=True, obsolete_delete=(True, True), obsolete_units=["a", "b", "c"]) expected["new_units"] = [ DummyUnit(unit, expected=expected) for unit in ["5", "6", "7"]] syncer = DummyStoreSyncer(store, expected=expected) disk_store = DummyDiskStore(expected) result = syncer.update_structure( disk_store, expected["obsolete_units"], expected["new_units"], expected["conservative"]) obsolete_units = ( len(expected["obsolete_units"]) if expected["obsolete_delete"][0] else 0) deleted_units = ( len(expected["obsolete_units"]) if expected["obsolete_delete"][1] else 0) new_units = len(expected["new_units"]) assert result == (obsolete_units, deleted_units, new_units) def _test_get_new(results, syncer, old_ids, new_ids): assert list(results) == list( syncer.store.findid_bulk( [syncer.dbid_index.get(uid) for uid in new_ids - old_ids])) def _test_get_obsolete(results, disk_store, syncer, old_ids, new_ids): assert list(results) == list( disk_store.findid(uid) for uid in old_ids - new_ids if (disk_store.findid(uid) and not disk_store.findid(uid).isobsolete())) @pytest.mark.django_db def test_store_syncer_obsolete_units(dummy_store_syncer_units, tp0): store = tp0.stores.live().first() disk_store = store.syncer.convert() expected = dict( old_ids=set(), new_ids=set(), disk_ids={}) syncer = dummy_store_syncer_units(store, expected=expected) results = syncer.get_units_to_obsolete( disk_store, expected["old_ids"], expected["new_ids"]) _test_get_obsolete( results, disk_store, syncer, expected["old_ids"], expected["new_ids"]) expected = dict( old_ids=set(["2", "3", "4"]), new_ids=set(["3", "4", "5"]), disk_ids={"3": "foo", "4": "bar", "5": "baz"}) results = syncer.get_units_to_obsolete( disk_store, expected["old_ids"], expected["new_ids"]) _test_get_obsolete( results, disk_store, syncer, expected["old_ids"], expected["new_ids"]) @pytest.mark.django_db def test_store_syncer_new_units(dummy_store_syncer_units, tp0): store = tp0.stores.live().first() expected = dict( old_ids=set(), new_ids=set(), disk_ids={}, db_ids={}) syncer = dummy_store_syncer_units(store, expected=expected) results = syncer.get_new_units( expected["old_ids"], expected["new_ids"]) _test_get_new( results, syncer, expected["old_ids"], expected["new_ids"]) expected = dict( old_ids=set(["2", "3", "4"]), new_ids=set(["3", "4", "5"]), db_ids={"3": "foo", "4": "bar", "5": "baz"}) syncer = dummy_store_syncer_units(store, expected=expected) results = syncer.get_new_units( expected["old_ids"], expected["new_ids"]) _test_get_new( results, syncer, expected["old_ids"], expected["new_ids"]) @pytest.mark.django_db def test_store_path(store0): assert store0.path == to_tp_relative_path(store0.pootle_path) @pytest.mark.django_db def test_store_sync_empty(project0_nongnu, tp0, caplog): store = StoreDBFactory( name="empty.po", translation_project=tp0, parent=tp0.directory) store.sync() assert os.path.exists(store.file.path) modified = os.stat(store.file.path).st_mtime store.sync() assert modified == os.stat(store.file.path).st_mtime # warning message - nothing changes store.sync(conservative=True, only_newer=False) assert "nothing changed" in caplog.records[-1].message assert modified == os.stat(store.file.path).st_mtime @pytest.mark.django_db def test_store_sync_template(project0_nongnu, templates_project0, caplog): template = templates_project0.stores.first() template.sync() modified = os.stat(template.file.path).st_mtime unit = template.units.first() unit.target = "NEW TARGET" unit.save() template.sync(conservative=True) assert modified == os.stat(template.file.path).st_mtime template.sync(conservative=False) assert not modified == os.stat(template.file.path).st_mtime @pytest.mark.django_db def test_store_update_with_state_change(store0, admin): units = dict([(x.id, (x.source, x.target, not x.isfuzzy())) for x in store0.units]) update_store( store0, units=units.values(), store_revision=store0.data.max_unit_revision, user=admin) for unit_id, unit in units.items(): assert unit[2] == store0.units.get(id=unit_id).isfuzzy() @pytest.mark.django_db def test_update_xliff(store_po, test_fs, xliff): project = store_po.translation_project.project filetype_tool = project.filetype_tool project.filetypes.add(xliff) filetype_tool.set_store_filetype(store_po, xliff) with test_fs.open(['data', 'xliff', 'welcome.xliff']) as f: file_store = getclass(f)(f.read()) store_po.update(file_store) unit = store_po.units[0] assert unit.istranslated() with test_fs.open(['data', 'xliff', 'updated_welcome.xliff']) as f: file_store = getclass(f)(f.read()) store_po.update(file_store) updated_unit = store_po.units.get(id=unit.id) assert unit.source != updated_unit.source @pytest.mark.django_db def test_update_resurrect(store_po, test_fs): with test_fs.open(['data', 'po', 'obsolete.po']) as f: file_store = getclass(f)(f.read()) store_po.update(file_store) obsolete_units = store_po.unit_set.filter(state=OBSOLETE) obsolete_ids = list(obsolete_units.values_list('id', flat=True)) assert len(obsolete_ids) > 0 with test_fs.open(['data', 'po', 'resurrected.po']) as f: file_store = getclass(f)(f.read()) store_revision = store_po.data.max_unit_revision # set store_revision as we do in update_stores cli command store_po.update(file_store, store_revision=store_revision - 1) obsolete_units = store_po.unit_set.filter(state=OBSOLETE) assert obsolete_units.count() == len(obsolete_ids) for unit in obsolete_units.filter(id__in=obsolete_ids): assert unit.isobsolete() # set store_revision as we do in update_stores cli command store_po.update(file_store, store_revision=store_revision) units = store_po.units.filter(id__in=obsolete_ids) assert units.count() == len(obsolete_ids) for unit in units: assert not unit.isobsolete() @pytest.mark.django_db def test_store_comment_update(store0, member): ttk = store0.deserialize(store0.serialize()) fileunit = ttk.units[-1] fileunit.removenotes() fileunit.addnote("A new comment") unit = store0.findid(fileunit.getid()) last_sub_pk = unit.submission_set.order_by( "id").values_list("id", flat=True).last() or 0 store0.update( ttk, store_revision=store0.data.max_unit_revision + 1, user=member ) assert ttk.units[-1].getnotes("translator") == "A new comment" unit = store0.units.get(id=unit.id) assert unit.translator_comment == "A new comment" assert unit.change.commented_by == member new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id") assert new_subs.count() == 1 comment_sub = new_subs[0] assert comment_sub.old_value == "" assert comment_sub.new_value == "A new comment" assert comment_sub.field == SubmissionFields.COMMENT assert comment_sub.type == SubmissionTypes.SYSTEM assert comment_sub.submitter == member assert comment_sub.revision == unit.revision assert comment_sub.creation_time == unit.change.commented_on
ta2-1/pootle
tests/models/store.py
Python
gpl-3.0
64,439
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 1001, 1001, 9385, 1006, 1039, 1007, 13433, 4140, 2571, 16884, 1012, 1001, 1001, 2023, 5371, 2003, 1037, 2112, 1997, 1996, 13433, 4140, 2571, 2622, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"51320455","logradouro":"Rua Santana","bairro":"COHAB","cidade":"Recife","uf":"PE","estado":"Pernambuco"});
lfreneda/cepdb
api/v1/51320455.jsonp.js
JavaScript
cc0-1.0
121
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 4868, 16703, 2692, 19961, 2629, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 21766, 2050, 21158, 1000, 1010, 1000, 21790, 18933, 1000, 1024, 1000, 2522...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const frisby = require('frisby') const config = require('config') const URL = 'http://localhost:3000' let blueprint for (const product of config.get('products')) { if (product.fileForRetrieveBlueprintChallenge) { blueprint = product.fileForRetrieveBlueprintChallenge break } } describe('Server', () => { it('GET responds with index.html when visiting application URL', done => { frisby.get(URL) .expect('status', 200) .expect('header', 'content-type', /text\/html/) .expect('bodyContains', 'dist/juice-shop.min.js') .done(done) }) it('GET responds with index.html when visiting application URL with any path', done => { frisby.get(URL + '/whatever') .expect('status', 200) .expect('header', 'content-type', /text\/html/) .expect('bodyContains', 'dist/juice-shop.min.js') .done(done) }) it('GET a restricted file directly from file system path on server via Directory Traversal attack loads index.html instead', done => { frisby.get(URL + '/public/images/../../ftp/eastere.gg') .expect('status', 200) .expect('bodyContains', '<meta name="description" content="An intentionally insecure JavaScript Web Application">') .done(done) }) it('GET a restricted file directly from file system path on server via URL-encoded Directory Traversal attack loads index.html instead', done => { frisby.get(URL + '/public/images/%2e%2e%2f%2e%2e%2fftp/eastere.gg') .expect('status', 200) .expect('bodyContains', '<meta name="description" content="An intentionally insecure JavaScript Web Application">') .done(done) }) }) describe('/public/images/tracking', () => { it('GET tracking image for "Score Board" page access challenge', done => { frisby.get(URL + '/public/images/tracking/scoreboard.png') .expect('status', 200) .expect('header', 'content-type', 'image/png') .done(done) }) it('GET tracking image for "Administration" page access challenge', done => { frisby.get(URL + '/public/images/tracking/administration.png') .expect('status', 200) .expect('header', 'content-type', 'image/png') .done(done) }) it('GET tracking background image for "Geocities Theme" challenge', done => { frisby.get(URL + '/public/images/tracking/microfab.gif') .expect('status', 200) .expect('header', 'content-type', 'image/gif') .done(done) }) }) describe('/encryptionkeys', () => { it('GET serves a directory listing', done => { frisby.get(URL + '/encryptionkeys') .expect('status', 200) .expect('header', 'content-type', /text\/html/) .expect('bodyContains', '<title>listing directory /encryptionkeys</title>') .done(done) }) it('GET a non-existing file in will return a 404 error', done => { frisby.get(URL + '/encryptionkeys/doesnotexist.md') .expect('status', 404) .done(done) }) it('GET the Premium Content AES key', done => { frisby.get(URL + '/encryptionkeys/premium.key') .expect('status', 200) .done(done) }) it('GET a key file whose name contains a "/" fails with a 403 error', done => { frisby.fetch(URL + '/encryptionkeys/%2fetc%2fos-release%2500.md', {}, { urlEncode: false }) .expect('status', 403) .expect('bodyContains', 'Error: File names cannot contain forward slashes!') .done(done) }) }) describe('Hidden URL', () => { it('GET the second easter egg by visiting the Base64>ROT13-decrypted URL', done => { frisby.get(URL + '/the/devs/are/so/funny/they/hid/an/easter/egg/within/the/easter/egg') .expect('status', 200) .expect('header', 'content-type', /text\/html/) .expect('bodyContains', '<title>Welcome to Planet Orangeuze</title>') .done(done) }) it('GET the premium content by visiting the ROT5>Base64>z85>ROT5-decrypted URL', done => { frisby.get(URL + '/this/page/is/hidden/behind/an/incredibly/high/paywall/that/could/only/be/unlocked/by/sending/1btc/to/us') .expect('status', 200) .expect('header', 'content-type', 'image/gif') .done(done) }) it('GET Geocities theme CSS is accessible directly from file system path', done => { frisby.get(URL + '/css/geo-bootstrap/swatch/bootstrap.css') .expect('status', 200) .expect('bodyContains', 'Designed and built with all the love in the world @twitter by @mdo and @fat.') .done(done) }) it('GET Klingon translation file for "Extra Language" challenge', done => { frisby.get(URL + '/i18n/tlh_AA.json') .expect('status', 200) .expect('header', 'content-type', /application\/json/) .done(done) }) it('GET blueprint file for "Retrieve Blueprint" challenge', done => { frisby.get(URL + '/public/images/products/' + blueprint) .expect('status', 200) .done(done) }) })
m4l1c3/juice-shop
test/api/fileServingSpec.js
JavaScript
mit
4,853
[ 30522, 9530, 3367, 10424, 2483, 3762, 1027, 5478, 1006, 1005, 10424, 2483, 3762, 1005, 1007, 9530, 3367, 9530, 8873, 2290, 1027, 5478, 1006, 1005, 9530, 8873, 2290, 1005, 1007, 9530, 3367, 24471, 2140, 1027, 1005, 8299, 1024, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 1999-2001 Vojtech Pavlik * * USB HIDBP Keyboard support */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Should you need to contact me, the author, you can do so either by * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/kernel.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> #include <linux/usb/input.h> #include <linux/hid.h> /* * Version Information */ #define DRIVER_VERSION "" #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" #define DRIVER_DESC "USB HID Boot Protocol keyboard driver" #define DRIVER_LICENSE "GPL" MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE(DRIVER_LICENSE); static const unsigned char usb_kbd_keycode[256] = { 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106, 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71, 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190, 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113, 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0, 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113, 150,158,159,128,136,177,178,176,142,152,173,140 }; /** * struct usb_kbd - state of each attached keyboard * @dev: input device associated with this keyboard * @usbdev: usb device associated with this keyboard * @old: data received in the past from the @irq URB representing which * keys were pressed. By comparing with the current list of keys * that are pressed, we are able to see key releases. * @irq: URB for receiving a list of keys that are pressed when a * new key is pressed or a key that was pressed is released. * @led: URB for sending LEDs (e.g. numlock, ...) * @newleds: data that will be sent with the @led URB representing which LEDs should be on * @name: Name of the keyboard. @dev's name field points to this buffer * @phys: Physical path of the keyboard. @dev's phys field points to this * buffer * @new: Buffer for the @irq URB * @cr: Control request for @led URB * @leds: Buffer for the @led URB * @new_dma: DMA address for @irq URB * @leds_dma: DMA address for @led URB * @leds_lock: spinlock that protects @leds, @newleds, and @led_urb_submitted * @led_urb_submitted: indicates whether @led is in progress, i.e. it has been * submitted and its completion handler has not returned yet * without resubmitting @led */ struct usb_kbd { struct input_dev *dev; struct usb_device *usbdev; unsigned char old[8]; struct urb *irq, *led; unsigned char newleds; char name[128]; char phys[64]; unsigned char *new; struct usb_ctrlrequest *cr; unsigned char *leds; dma_addr_t new_dma; dma_addr_t leds_dma; spinlock_t leds_lock; bool led_urb_submitted; }; static void usb_kbd_irq(struct urb *urb) { struct usb_kbd *kbd = urb->context; int i; switch (urb->status) { case 0: /* success */ break; case -ECONNRESET: /* unlink */ case -ENOENT: case -ESHUTDOWN: return; /* -EPIPE: should clear the halt */ default: /* error */ goto resubmit; } for (i = 0; i < 8; i++) input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); for (i = 2; i < 8; i++) { if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { if (usb_kbd_keycode[kbd->old[i]]) input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); else hid_info(urb->dev, "Unknown key (scancode %#x) released.\n", kbd->old[i]); } if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { if (usb_kbd_keycode[kbd->new[i]]) input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); else hid_info(urb->dev, "Unknown key (scancode %#x) released.\n", kbd->new[i]); } } input_sync(kbd->dev); memcpy(kbd->old, kbd->new, 8); resubmit: i = usb_submit_urb (urb, GFP_ATOMIC); if (i) hid_err(urb->dev, "can't resubmit intr, %s-%s/input0, status %d", kbd->usbdev->bus->bus_name, kbd->usbdev->devpath, i); } static int usb_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) { unsigned long flags; struct usb_kbd *kbd = input_get_drvdata(dev); if (type != EV_LED) return -1; spin_lock_irqsave(&kbd->leds_lock, flags); kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | (!!test_bit(LED_NUML, dev->led)); if (kbd->led_urb_submitted){ spin_unlock_irqrestore(&kbd->leds_lock, flags); return 0; } if (*(kbd->leds) == kbd->newleds){ spin_unlock_irqrestore(&kbd->leds_lock, flags); return 0; } *(kbd->leds) = kbd->newleds; kbd->led->dev = kbd->usbdev; if (usb_submit_urb(kbd->led, GFP_ATOMIC)) pr_err("usb_submit_urb(leds) failed\n"); else kbd->led_urb_submitted = true; spin_unlock_irqrestore(&kbd->leds_lock, flags); return 0; } static void usb_kbd_led(struct urb *urb) { unsigned long flags; struct usb_kbd *kbd = urb->context; if (urb->status) hid_warn(urb->dev, "led urb status %d received\n", urb->status); spin_lock_irqsave(&kbd->leds_lock, flags); if (*(kbd->leds) == kbd->newleds){ kbd->led_urb_submitted = false; spin_unlock_irqrestore(&kbd->leds_lock, flags); return; } *(kbd->leds) = kbd->newleds; kbd->led->dev = kbd->usbdev; if (usb_submit_urb(kbd->led, GFP_ATOMIC)){ hid_err(urb->dev, "usb_submit_urb(leds) failed\n"); kbd->led_urb_submitted = false; } spin_unlock_irqrestore(&kbd->leds_lock, flags); } static int usb_kbd_open(struct input_dev *dev) { struct usb_kbd *kbd = input_get_drvdata(dev); kbd->irq->dev = kbd->usbdev; if (usb_submit_urb(kbd->irq, GFP_KERNEL)) return -EIO; return 0; } static void usb_kbd_close(struct input_dev *dev) { struct usb_kbd *kbd = input_get_drvdata(dev); usb_kill_urb(kbd->irq); } static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd) { if (!(kbd->irq = usb_alloc_urb(0, GFP_KERNEL))) return -1; if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) return -1; if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma))) return -1; if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) return -1; if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_ATOMIC, &kbd->leds_dma))) return -1; return 0; } static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) { usb_free_urb(kbd->irq); usb_free_urb(kbd->led); usb_free_coherent(dev, 8, kbd->new, kbd->new_dma); kfree(kbd->cr); usb_free_coherent(dev, 1, kbd->leds, kbd->leds_dma); } static int usb_kbd_probe(struct usb_interface *iface, const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev(iface); struct usb_host_interface *interface; struct usb_endpoint_descriptor *endpoint; struct usb_kbd *kbd; struct input_dev *input_dev; int i, pipe, maxp; int error = -ENOMEM; interface = iface->cur_altsetting; if (interface->desc.bNumEndpoints != 1) return -ENODEV; endpoint = &interface->endpoint[0].desc; if (!usb_endpoint_is_int_in(endpoint)) return -ENODEV; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!kbd || !input_dev) goto fail1; if (usb_kbd_alloc_mem(dev, kbd)) goto fail2; kbd->usbdev = dev; kbd->dev = input_dev; spin_lock_init(&kbd->leds_lock); if (dev->manufacturer) strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name)); if (dev->product) { if (dev->manufacturer) strlcat(kbd->name, " ", sizeof(kbd->name)); strlcat(kbd->name, dev->product, sizeof(kbd->name)); } if (!strlen(kbd->name)) snprintf(kbd->name, sizeof(kbd->name), "USB HIDBP Keyboard %04x:%04x", le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct)); usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); strlcat(kbd->phys, "/input0", sizeof(kbd->phys)); input_dev->name = kbd->name; input_dev->phys = kbd->phys; usb_to_input_id(dev, &input_dev->id); input_dev->dev.parent = &iface->dev; input_set_drvdata(input_dev, kbd); input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | BIT_MASK(EV_REP); input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | BIT_MASK(LED_SCROLLL) | BIT_MASK(LED_COMPOSE) | BIT_MASK(LED_KANA); for (i = 0; i < 255; i++) set_bit(usb_kbd_keycode[i], input_dev->keybit); clear_bit(0, input_dev->keybit); input_dev->event = usb_kbd_event; input_dev->open = usb_kbd_open; input_dev->close = usb_kbd_close; usb_fill_int_urb(kbd->irq, dev, pipe, kbd->new, (maxp > 8 ? 8 : maxp), usb_kbd_irq, kbd, endpoint->bInterval); kbd->irq->transfer_dma = kbd->new_dma; kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; kbd->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE; kbd->cr->bRequest = 0x09; kbd->cr->wValue = cpu_to_le16(0x200); kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); kbd->cr->wLength = cpu_to_le16(1); usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), (void *) kbd->cr, kbd->leds, 1, usb_kbd_led, kbd); kbd->led->transfer_dma = kbd->leds_dma; kbd->led->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(kbd->dev); if (error) goto fail2; usb_set_intfdata(iface, kbd); device_set_wakeup_enable(&dev->dev, 1); return 0; fail2: usb_kbd_free_mem(dev, kbd); fail1: input_free_device(input_dev); kfree(kbd); return error; } static void usb_kbd_disconnect(struct usb_interface *intf) { struct usb_kbd *kbd = usb_get_intfdata (intf); usb_set_intfdata(intf, NULL); if (kbd) { usb_kill_urb(kbd->irq); input_unregister_device(kbd->dev); usb_kill_urb(kbd->led); usb_kbd_free_mem(interface_to_usbdev(intf), kbd); kfree(kbd); } } static struct usb_device_id usb_kbd_id_table [] = { { USB_INTERFACE_INFO(USB_INTERFACE_CLASS_HID, USB_INTERFACE_SUBCLASS_BOOT, USB_INTERFACE_PROTOCOL_KEYBOARD) }, { } /* Terminating entry */ }; MODULE_DEVICE_TABLE (usb, usb_kbd_id_table); static struct usb_driver usb_kbd_driver = { .name = "usbkbd", .probe = usb_kbd_probe, .disconnect = usb_kbd_disconnect, .id_table = usb_kbd_id_table, }; module_usb_driver(usb_kbd_driver);
talnoah/android_kernel_htc_dlx
virt/drivers/hid/usbhid/usbkbd.c
C
gpl-2.0
11,776
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2639, 1011, 2541, 29536, 3501, 15007, 6643, 2615, 18393, 1008, 1008, 18833, 11041, 2497, 2361, 9019, 2490, 1008, 1013, 1013, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <string.h> #include <utility> #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "content/public/common/common_param_traits.h" #include "content/public/common/url_utils.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_utils.h" #include "net/base/host_port_pair.h" #include "printing/backend/print_backend.h" #include "printing/page_range.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/ipc/gfx_param_traits.h" #include "url/gurl.h" // Tests that serialize/deserialize correctly understand each other TEST(IPCMessageTest, Serialize) { const char* serialize_cases[] = { "http://www.google.com/", "http://user:pass@host.com:888/foo;bar?baz#nop", }; for (size_t i = 0; i < arraysize(serialize_cases); i++) { GURL input(serialize_cases[i]); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::ParamTraits<GURL>::Write(&msg, input); GURL output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); // We want to test each component individually to make sure its range was // correctly serialized and deserialized, not just the spec. EXPECT_EQ(input.possibly_invalid_spec(), output.possibly_invalid_spec()); EXPECT_EQ(input.is_valid(), output.is_valid()); EXPECT_EQ(input.scheme(), output.scheme()); EXPECT_EQ(input.username(), output.username()); EXPECT_EQ(input.password(), output.password()); EXPECT_EQ(input.host(), output.host()); EXPECT_EQ(input.port(), output.port()); EXPECT_EQ(input.path(), output.path()); EXPECT_EQ(input.query(), output.query()); EXPECT_EQ(input.ref(), output.ref()); } // Test an excessively long GURL. { const std::string url = std::string("http://example.org/").append( content::GetMaxURLChars() + 1, 'a'); GURL input(url.c_str()); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::ParamTraits<GURL>::Write(&msg, input); GURL output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); EXPECT_TRUE(output.is_empty()); } // Test an invalid GURL. { IPC::Message msg; msg.WriteString("#inva://idurl/"); GURL output; base::PickleIterator iter(msg); EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); } // Also test the corrupt case. IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); msg.WriteInt(99); GURL output; base::PickleIterator iter(msg); EXPECT_FALSE(IPC::ParamTraits<GURL>::Read(&msg, &iter, &output)); } // Tests std::pair serialization TEST(IPCMessageTest, Pair) { typedef std::pair<std::string, std::string> TestPair; TestPair input("foo", "bar"); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::ParamTraits<TestPair>::Write(&msg, input); TestPair output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<TestPair>::Read(&msg, &iter, &output)); EXPECT_EQ(output.first, "foo"); EXPECT_EQ(output.second, "bar"); } // Tests bitmap serialization. TEST(IPCMessageTest, Bitmap) { SkBitmap bitmap; bitmap.allocN32Pixels(10, 5); memset(bitmap.getPixels(), 'A', bitmap.getSize()); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::ParamTraits<SkBitmap>::Write(&msg, bitmap); SkBitmap output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<SkBitmap>::Read(&msg, &iter, &output)); EXPECT_EQ(bitmap.colorType(), output.colorType()); EXPECT_EQ(bitmap.width(), output.width()); EXPECT_EQ(bitmap.height(), output.height()); EXPECT_EQ(bitmap.rowBytes(), output.rowBytes()); EXPECT_EQ(bitmap.getSize(), output.getSize()); EXPECT_EQ(memcmp(bitmap.getPixels(), output.getPixels(), bitmap.getSize()), 0); // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); // Copy the first message block over to |bad_msg|. const char* fixed_data; int fixed_data_size; iter = base::PickleIterator(msg); EXPECT_TRUE(iter.ReadData(&fixed_data, &fixed_data_size)); bad_msg.WriteData(fixed_data, fixed_data_size); // Add some bogus pixel data. const size_t bogus_pixels_size = bitmap.getSize() * 2; scoped_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]); memset(bogus_pixels.get(), 'B', bogus_pixels_size); bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size); // Make sure we don't read out the bitmap! SkBitmap bad_output; iter = base::PickleIterator(bad_msg); EXPECT_FALSE(IPC::ParamTraits<SkBitmap>::Read(&bad_msg, &iter, &bad_output)); } TEST(IPCMessageTest, ListValue) { base::ListValue input; input.Set(0, new base::FundamentalValue(42.42)); input.Set(1, new base::StringValue("forty")); input.Set(2, base::Value::CreateNullValue()); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::WriteParam(&msg, input); base::ListValue output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); iter = base::PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } TEST(IPCMessageTest, DictionaryValue) { base::DictionaryValue input; input.Set("null", base::Value::CreateNullValue()); input.Set("bool", new base::FundamentalValue(true)); input.Set("int", new base::FundamentalValue(42)); scoped_ptr<base::DictionaryValue> subdict(new base::DictionaryValue()); subdict->Set("str", new base::StringValue("forty two")); subdict->Set("bool", new base::FundamentalValue(false)); scoped_ptr<base::ListValue> sublist(new base::ListValue()); sublist->Set(0, new base::FundamentalValue(42.42)); sublist->Set(1, new base::StringValue("forty")); sublist->Set(2, new base::StringValue("two")); subdict->Set("list", sublist.release()); input.Set("dict", subdict.release()); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::WriteParam(&msg, input); base::DictionaryValue output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); EXPECT_TRUE(input.Equals(&output)); // Also test the corrupt case. IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); bad_msg.WriteInt(99); iter = base::PickleIterator(bad_msg); EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); } // Tests net::HostPortPair serialization TEST(IPCMessageTest, HostPortPair) { net::HostPortPair input("host.com", 12345); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::ParamTraits<net::HostPortPair>::Write(&msg, input); net::HostPortPair output; base::PickleIterator iter(msg); EXPECT_TRUE(IPC::ParamTraits<net::HostPortPair>::Read(&msg, &iter, &output)); EXPECT_EQ(input.host(), output.host()); EXPECT_EQ(input.port(), output.port()); }
Chilledheart/chromium
content/common/common_param_traits_unittest.cc
C++
bsd-3-clause
7,187
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2262, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="form-horizontal"> <h3>Create a new Data</h3> <div class="form-group"> <div class="col-md-offset-2 col-sm-2"> <a id="Create" name="Create" class="btn btn-primary" href="#/DataConfig/new"><span class="glyphicon glyphicon-plus-sign"></span> Create</a> </div> </div> </div> <hr /> <div> <h3>Search for Data</h3> <form id="DataConfigSearch" class="form-horizontal"> <div class="form-group"> <label for="project" class="col-sm-2 control-label">Project</label> <div class="col-sm-10"> <input id="project" name="project" class="form-control" type="text" ng-model="search.baseConfig.id.project" placeholder="Enter the Project Name"></input> </div> </div> <div class="form-group"> <label for="buildVersion" class="col-sm-2 control-label">Build Version</label> <div class="col-sm-10"> <input id="buildVersion" name="buildVersion" class="form-control" type="text" ng-model="search.baseConfig.id.buildVersion" placeholder="Enter the Build Version"></input> </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-sm-10"> <a id="Search" name="Search" class="btn btn-primary" ng-click="performSearch()"><span class="glyphicon glyphicon-search"></span> Search</a> </div> </div> </form> </div> <div id="search-results"> <div class="table-responsive"> <table class="table table-responsive table-bordered table-striped clearfix"> <thead> <tr> <th>Name</th> <th>Browser</th> <th>Status</th> <th>Description</th> </tr> </thead> <tbody id="search-results-body"> <tr ng-repeat="result in searchResults | searchFilter:searchResults | startFrom:currentPage*pageSize | limitTo:pageSize"> <td><a href="#/DataConfig/edit/{{result.id}}">{{result.scriptName}}</a></td> <td><a href="#/DataConfig/edit/{{result.id}}">{{result.browser}}</a></td> <td><a href="#/DataConfig/edit/{{result.id}}">{{result.status}}</a></td> <td><a href="#/DataConfig/edit/{{result.id}}">{{result.description}}</a></td> </tr> </tbody> </table> </div> <ul class="pagination pagination-centered"> <li ng-class="{disabled:currentPage == 0}"><a id="prev" href ng-click="previous()">«</a></li> <li ng-repeat="n in pageRange" ng-class="{active:currentPage == n}" ng-click="setPage(n)"><a href ng-bind="n + 1">1</a></li> <li ng-class="{disabled: currentPage == (numberOfPages() - 1)}"> <a id="next" href ng-click="next()">»</a> </li> </ul> </div>
AnilVunnava/Automation
qa-webapp/src/main/webapp/admin/views/DataConfig/search.html
HTML
gpl-2.0
2,522
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 2433, 1011, 9876, 1000, 1028, 1026, 1044, 2509, 1028, 3443, 1037, 2047, 2951, 1026, 1013, 1044, 2509, 1028, 1026, 4487, 2615, 2465, 1027, 1000, 2433, 1011, 2177, 1000, 1028, 1026, 4487, 2615, 246...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace Microsoft.DocAsCode.DataContracts.Common { using System; using Newtonsoft.Json; using YamlDotNet.Serialization; using Microsoft.DocAsCode.Utility; [Serializable] public class SourceDetail { [YamlMember(Alias = "remote")] [JsonProperty("remote")] public GitDetail Remote { get; set; } [YamlMember(Alias = "base")] [JsonProperty("base")] public string BasePath { get; set; } [YamlMember(Alias = "id")] [JsonProperty("id")] public string Name { get; set; } /// <summary> /// The url path for current source, should be resolved at some late stage /// </summary> [YamlMember(Alias = Constants.PropertyName.Href)] [JsonProperty(Constants.PropertyName.Href)] public string Href { get; set; } /// <summary> /// The local path for current source, should be resolved to be relative path at some late stage /// </summary> [YamlMember(Alias = "path")] [JsonProperty("path")] public string Path { get; set; } [YamlMember(Alias = "startLine")] [JsonProperty("startLine")] public int StartLine { get; set; } [YamlMember(Alias = "endLine")] [JsonProperty("endLine")] public int EndLine { get; set; } [YamlMember(Alias = "content")] [JsonProperty("content")] public string Content { get; set; } /// <summary> /// The external path for current source if it is not locally available /// </summary> [YamlMember(Alias = "isExternal")] [JsonProperty("isExternal")] public bool IsExternalPath { get; set; } } }
sergey-vershinin/docfx
src/Microsoft.DocAsCode.DataContracts.Common/SourceDetail.cs
C#
mit
1,881
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 7513, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 7000, 2104, 1996, 10210, 6105, 1012, 2156, 6105, 5371, 1999, 1996, 2622, 7117, 2005, 2440, 6105, 2592, 1012, 3415, 15327, 7513, 1012, 9986, 28187, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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. */ #include <aws/comprehend/model/PartOfSpeechTag.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace Comprehend { namespace Model { PartOfSpeechTag::PartOfSpeechTag() : m_tag(PartOfSpeechTagType::NOT_SET), m_tagHasBeenSet(false), m_score(0.0), m_scoreHasBeenSet(false) { } PartOfSpeechTag::PartOfSpeechTag(JsonView jsonValue) : m_tag(PartOfSpeechTagType::NOT_SET), m_tagHasBeenSet(false), m_score(0.0), m_scoreHasBeenSet(false) { *this = jsonValue; } PartOfSpeechTag& PartOfSpeechTag::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Tag")) { m_tag = PartOfSpeechTagTypeMapper::GetPartOfSpeechTagTypeForName(jsonValue.GetString("Tag")); m_tagHasBeenSet = true; } if(jsonValue.ValueExists("Score")) { m_score = jsonValue.GetDouble("Score"); m_scoreHasBeenSet = true; } return *this; } JsonValue PartOfSpeechTag::Jsonize() const { JsonValue payload; if(m_tagHasBeenSet) { payload.WithString("Tag", PartOfSpeechTagTypeMapper::GetNameForPartOfSpeechTagType(m_tag)); } if(m_scoreHasBeenSet) { payload.WithDouble("Score", m_score); } return payload; } } // namespace Model } // namespace Comprehend } // namespace Aws
cedral/aws-sdk-cpp
aws-cpp-sdk-comprehend/source/model/PartOfSpeechTag.cpp
C++
apache-2.0
1,906
[ 30522, 1013, 1008, 1008, 9385, 2230, 1011, 2418, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="collapsibleregioninner" id="aera_core_group_add_group_members_inner"><br/><div style="border:solid 1px #DEDEDE;background:#E2E0E0; color:#222222;padding:4px;">Adds group members.</div><br/><br/><span style="color:#EA33A6">Arguments</span><br/><span style="font-size:80%"><b>members</b> (Required)<br/>        <br/><br/><div><div style="border:solid 1px #DEDEDE;background:#FFF1BC;color:#222222;padding:4px;"><pre><b>General structure</b><br/> list of ( <br/>object {<br/><b>groupid</b> int <span style="color:#2A33A6"> <i>//group record id</i></span><br/><b>userid</b> int <span style="color:#2A33A6"> <i>//user id</i></span><br/>} <br/>) </pre></div></div><div><div style="border:solid 1px #DEDEDE;background:#DFEEE7;color:#222222;padding:4px;"><pre><b>XML-RPC (PHP structure)</b><br/> [members] =&gt; Array ( [0] =&gt; Array ( [groupid] =&gt; int [userid] =&gt; int ) ) </pre></div></div><div><div style="border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;"><pre><b>REST (POST parameters)</b><br/> members[0][groupid]= int members[0][userid]= int </pre></div></div></span><br/><br/><span style="color:#EA33A6">Response</span><br/><span style="font-size:80%"></span><br/><br/><span style="color:#EA33A6">Error message</span><br/><br/><span style="font-size:80%"><div><div style="border:solid 1px #DEDEDE;background:#FEEBE5;color:#222222;padding:4px;"><pre><b>REST</b><br/> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;EXCEPTION class="invalid_parameter_exception"&gt; &lt;MESSAGE&gt;Invalid parameter value detected&lt;/MESSAGE&gt; &lt;DEBUGINFO&gt;&lt;/DEBUGINFO&gt; &lt;/EXCEPTION&gt; </pre></div></div></span><br/><br/><span style="color:#EA33A6">Restricted to logged-in users<br/></span>Yes<br/><br/><span style="color:#EA33A6">Callable from AJAX<br/></span>No<br/><br/></div>
manly-man/moodle-destroyer-tools
docs/moodle_api_3.1/functions/core_group_add_group_members.html
HTML
mit
1,997
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 8902, 2721, 4523, 7028, 23784, 23111, 2121, 1000, 8909, 1027, 1000, 29347, 2527, 1035, 4563, 1035, 2177, 1035, 5587, 1035, 2177, 1035, 2372, 1035, 5110, 1000, 1028, 1026, 7987, 1013, 1028, 1026, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//===========================================================================// // File: memblock.hh // // Contents: Interface specification of the memory block class // //---------------------------------------------------------------------------// // Copyright (C) Microsoft Corporation. All rights reserved. // //===========================================================================// #pragma once #include"stuff.hpp" namespace Stuff { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryBlockHeader ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class MemoryBlockHeader { public: MemoryBlockHeader *nextBlock; size_t blockSize; void TestInstance() {} }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryBlockBase ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class MemoryBlockBase #if defined(_ARMOR) : public Stuff::Signature #endif { public: void TestInstance() {Verify(blockMemory != NULL);} static void UsageReport(); static void CollapseBlocks(); protected: const char *blockName; MemoryBlockHeader *blockMemory; // the first record block allocated size_t blockSize, // size in bytes of the current record block recordSize, // size in bytes of the individual record deltaSize; // size in bytes of the growth blocks BYTE *firstHeaderRecord, // the beginning of useful free space *freeRecord, // the next address to allocate from the block *deletedRecord; // the next record to reuse MemoryBlockBase( size_t rec_size, size_t start, size_t delta, const char* name, HGOSHEAP parent = ParentClientHeap ); ~MemoryBlockBase(); void* Grow(); HGOSHEAP blockHeap; private: static MemoryBlockBase *firstBlock; MemoryBlockBase *nextBlock, *previousBlock; void Collapse(); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryBlock ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class MemoryBlock: public MemoryBlockBase { public: static bool TestClass(); MemoryBlock( size_t rec_size, size_t start, size_t delta, const char* name, HGOSHEAP parent = ParentClientHeap ): MemoryBlockBase(rec_size, start, delta, name, parent) {} void* New(); void Delete(void *Where); void* operator[](size_t Index); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryBlockOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <class T> class MemoryBlockOf: public MemoryBlock { public: MemoryBlockOf( size_t start, size_t delta, const char* name, HGOSHEAP parent = ParentClientHeap ): MemoryBlock(sizeof(T), start, delta, name, parent) {} T* New() {return Cast_Pointer(T*, MemoryBlock::New());} void Delete(void *where) {MemoryBlock::Delete(where);} T* operator[](size_t index) {return Cast_Pointer(T*, MemoryBlock::operator[](index));} }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryStack ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class MemoryStack: public MemoryBlockBase { public: static bool TestClass(); protected: BYTE *topOfStack; MemoryStack( size_t rec_size, size_t start, size_t delta, const char* name, HGOSHEAP parent = ParentClientHeap ): MemoryBlockBase(rec_size, start, delta, name, parent) {topOfStack = NULL;} void* Push(const void *What); void* Push(); void* Peek() {return topOfStack;} void Pop(); }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MemoryStackOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <class T> class MemoryStackOf: public MemoryStack { public: MemoryStackOf( size_t start, size_t delta, const char *name, HGOSHEAP parent = ParentClientHeap ): MemoryStack(sizeof(T), start, delta, name, parent) {} T* Push(const T *what) {return Cast_Pointer(T*, MemoryStack::Push(what));} T* Peek() {return static_cast<T*>(MemoryStack::Peek());} void Pop() {MemoryStack::Pop();} }; }
alariq/mc2
mclib/stuff/memoryblock.hpp
C++
gpl-3.0
4,175
[ 30522, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package net.jueb.util4j.buffer.tool.demo; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.List; import net.jueb.util4j.buffer.tool.ClassFileUitl; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import io.netty.util.CharsetUtil; import net.jueb.util4j.buffer.tool.BufferBuilder; public class BufferBuilderDemo { protected Logger log=LoggerFactory.getLogger(getClass()); public static final String writeMethodName="writeTo"; public static final String readMethodName="readFrom"; /** * (@Override)?([\s]+|[\r\n\t])(public)([\s]+|[\r\n|\r|\t])(void)([\s]+|[\r\n|\r|\t])(writeToSql)([\s]*|[\r\n|\r|\t])(\()([\s]*|[\r\n|\r|\t])(ByteBuffer)([\s]+|[\r\n|\r|\t])(buffer)([\s]*|[\r\n|\r|\t])(\))([\s]*|[\r\n|\r|\t])(\{)([\s\S]*)(\}) */ public static final String MATCH_WRITE="(@Override)?([\\s]+|[\\r\\n\\t])(public)([\\s]+|[\\r\\n|\\r|\\t])(void)([\\s]+|[\\r\\n|\\r|\\t])("+writeMethodName+")([\\s]*|[\\r\\n|\\r|\\t])(\\()([\\s]*|[\\r\\n|\\r|\\t])(ByteBuffer)([\\s]+|[\\r\\n|\\r|\\t])(buffer)([\\s]*|[\\r\\n|\\r|\\t])(\\))([\\s]*|[\\r\n|\\r|\\t])(\\{)([\\s\\S]*)(\\})"; public static final String MATCH_READ="(@Override)?([\\s]+|[\\r\\n\\t])(public)([\\s]+|[\\r\\n|\\r|\\t])(void)([\\s]+|[\\r\\n|\\r|\\t])("+readMethodName+")([\\s]*|[\\r\\n|\\r|\\t])(\\()([\\s]*|[\\r\\n|\\r|\\t])(ByteBuffer)([\\s]+|[\\r\\n|\\r|\\t])(buffer)([\\s]*|[\\r\\n|\\r|\\t])(\\))([\\s]*|[\\r\n|\\r|\\t])(\\{)([\\s\\S]*)(\\})"; public static String BEGIN_FLAG = "//auto sql write begin"; public static String END_FLAG = "//auto sql write end"; public void build(String soruceRootDir,String pkg)throws Exception { BufferBuilder bb=new BufferBuilder("net.jueb.util4j.buffer.ArrayBytesBuff", "writeTo", "readFrom"); //属性过滤器 bb.addFieldSkipFilter((field)->{ String name = field.getName(); return name.contains("$SWITCH_TABLE$"); }); //其它类型 bb.addTypeHandler((ctx)->{ Class<?> type=ctx.varType(); if(Date.class.isAssignableFrom(type)) { String ClassName=type.getSimpleName(); ctx.write().append("\t").append(ctx.varBuffer()+".writeLong("+ctx.varName()+".getTime());").append("\n"); ctx.read().append("\t").append(ctx.varName() +"=new "+ClassName+"();").append("\n"); ctx.read().append("\t").append(ctx.varName() + ".setTime("+ctx.varBuffer()+".readLong());").append("\n"); return true; } return false; }); List<Class<?>> fileList =ClassFileUitl.getClassInfo(soruceRootDir, pkg); for(Class<?> clazz:fileList) { if(!Dto.class.isAssignableFrom(clazz)) { continue; } StringBuilder writeSb=new StringBuilder(); StringBuilder readSb=new StringBuilder(); bb.build(clazz,writeSb,readSb); writeSb.append("\n"); writeSb.append(readSb.toString()); File javaSourceFile=ClassFileUitl.findJavaSourceFile(soruceRootDir, clazz); String javaSource=fillCode(javaSourceFile, writeSb); FileUtils.writeByteArrayToFile(javaSourceFile,javaSource.getBytes(CharsetUtil.UTF_8)); } } /** * 填充代码 * @param javaFile * @param bufferCode * @return * @throws IOException */ public String fillCode(File javaFile,StringBuilder bufferCode) throws IOException { String javaSource=FileUtils.readFileToString(javaFile, CharsetUtil.UTF_8); int start=javaSource.indexOf(BEGIN_FLAG); int end=javaSource.indexOf(END_FLAG); if(start>0&& end>0) { String head=javaSource.substring(0, start+BEGIN_FLAG.length()); String til=javaSource.substring(end, javaSource.length()); javaSource=head+"\n"+bufferCode.toString()+"\n"+til; } return javaSource; } public static void main(String[] args) throws Exception { String path=System.getProperty("user.dir")+File.separator+"src"+File.separator+"main"+File.separator+"java"+File.separator; String pkg="net.jueb.util4j.buffer.tool.demo"; BufferBuilderDemo buildUtils = new BufferBuilderDemo(); buildUtils.build(path,pkg); } }
juebanlin/util4j
util4j/src/main/java/net/jueb/util4j/buffer/tool/demo/BufferBuilderDemo.java
Java
apache-2.0
3,983
[ 30522, 7427, 5658, 1012, 18414, 15878, 1012, 21183, 4014, 2549, 3501, 1012, 17698, 1012, 6994, 1012, 9703, 1025, 12324, 9262, 1012, 22834, 1012, 5371, 1025, 12324, 9262, 1012, 22834, 1012, 22834, 10288, 24422, 1025, 12324, 9262, 1012, 21183, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var game = new Phaser.Game(375, 667, Phaser.AUTO, 'gameDiv'); // var game = new Phaser.Game(720, 1280, Phaser.AUTO, 'gameDiv'); game.global = { taps: 0, enemyHP: 0, enemyHPTotal: 0, level: 1, enemyNumber: 1, coins: 0, player: { name: 'mr. hero', level: 1, skillLevel: [0, 0, 0, 0, 0, 0] } }; game.state.add('boot', bootState); game.state.add('load', loadState); game.state.add('menu', menuState); game.state.add('play', playState); game.state.start('boot');
kelvinblade/tap-titans-clone
js/game.js
JavaScript
mit
488
[ 30522, 13075, 2208, 1027, 2047, 4403, 2099, 1012, 2208, 1006, 18034, 1010, 5764, 2581, 1010, 4403, 2099, 1012, 8285, 1010, 1005, 2208, 4305, 2615, 1005, 1007, 1025, 1013, 1013, 13075, 2208, 1027, 2047, 4403, 2099, 1012, 2208, 1006, 22857, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org> * See README for License detail, AUTHORS for developers list. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* wee-list.c: sorted lists management */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <string.h> #include "weechat.h" #include "wee-list.h" #include "wee-log.h" #include "wee-string.h" #include "../plugins/weechat-plugin.h" /* * weelist_new: create a new list */ struct t_weelist * weelist_new () { struct t_weelist *new_weelist; new_weelist = malloc (sizeof (*new_weelist)); if (new_weelist) { new_weelist->items = NULL; new_weelist->size = 0; } return new_weelist; } /* * weelist_find_pos: find position for data (keeping list sorted) */ struct t_weelist_item * weelist_find_pos (struct t_weelist *weelist, const char *data) { struct t_weelist_item *ptr_item; if (!weelist || !data) return NULL; for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { if (string_strcasecmp (data, ptr_item->data) < 0) return ptr_item; } /* position not found, best position is at the end */ return NULL; } /* * weelist_insert: insert an element to the list (at good position) */ void weelist_insert (struct t_weelist *weelist, struct t_weelist_item *item, const char *where) { struct t_weelist_item *pos_item; if (!weelist || !item) return; if (weelist->items) { /* remove element if already in list */ pos_item = weelist_search (weelist, item->data); if (pos_item) weelist_remove (weelist, pos_item); } if (weelist->items) { /* search position for new element, according to pos asked */ pos_item = NULL; if (string_strcasecmp (where, WEECHAT_LIST_POS_BEGINNING) == 0) pos_item = weelist->items; else if (string_strcasecmp (where, WEECHAT_LIST_POS_END) == 0) pos_item = NULL; else pos_item = weelist_find_pos (weelist, item->data); if (pos_item) { /* insert data into the list (before position found) */ item->prev_item = pos_item->prev_item; item->next_item = pos_item; if (pos_item->prev_item) (pos_item->prev_item)->next_item = item; else weelist->items = item; pos_item->prev_item = item; } else { /* add data to the end */ item->prev_item = weelist->last_item; item->next_item = NULL; (weelist->last_item)->next_item = item; weelist->last_item = item; } } else { item->prev_item = NULL; item->next_item = NULL; weelist->items = item; weelist->last_item = item; } } /* * weelist_add: create new data and add it to list */ struct t_weelist_item * weelist_add (struct t_weelist *weelist, const char *data, const char *where, void *user_data) { struct t_weelist_item *new_item; if (!weelist || !data || !data[0] || !where || !where[0]) return NULL; new_item = malloc (sizeof (*new_item)); if (new_item) { new_item->data = strdup (data); new_item->user_data = user_data; weelist_insert (weelist, new_item, where); weelist->size++; } return new_item; } /* * weelist_search: search data in a list (case sensitive) */ struct t_weelist_item * weelist_search (struct t_weelist *weelist, const char *data) { struct t_weelist_item *ptr_item; if (!weelist || !data) return NULL; for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { if (strcmp (data, ptr_item->data) == 0) return ptr_item; } /* data not found in list */ return NULL; } /* * weelist_casesearch: search data in a list (case unsensitive) */ struct t_weelist_item * weelist_casesearch (struct t_weelist *weelist, const char *data) { struct t_weelist_item *ptr_item; if (!weelist || !data) return NULL; for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { if (string_strcasecmp (data, ptr_item->data) == 0) return ptr_item; } /* data not found in list */ return NULL; } /* * weelist_get: get an item in a list by position (0 is first element) */ struct t_weelist_item * weelist_get (struct t_weelist *weelist, int position) { int i; struct t_weelist_item *ptr_item; if (!weelist) return NULL; i = 0; ptr_item = weelist->items; while (ptr_item) { if (i == position) return ptr_item; ptr_item = ptr_item->next_item; i++; } /* item not found */ return NULL; } /* * weelist_set: set a new value for an item */ void weelist_set (struct t_weelist_item *item, const char *value) { if (!item || !value) return; if (item->data) free (item->data); item->data = strdup (value); } /* * weelist_next: get next item */ struct t_weelist_item * weelist_next (struct t_weelist_item *item) { if (item) return item->next_item; return NULL; } /* * weelist_prev: get previous item */ struct t_weelist_item * weelist_prev (struct t_weelist_item *item) { if (item) return item->prev_item; return NULL; } /* * weelist_string: get string pointer to item data */ const char * weelist_string (struct t_weelist_item *item) { if (item) return item->data; return NULL; } /* * weelist_size: return size of weelist */ int weelist_size (struct t_weelist *weelist) { if (weelist) return weelist->size; return 0; } /* * weelist_remove: remove an item from a list */ void weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item) { struct t_weelist_item *new_items; if (!weelist || !item) return; /* remove item from list */ if (weelist->last_item == item) weelist->last_item = item->prev_item; if (item->prev_item) { (item->prev_item)->next_item = item->next_item; new_items = weelist->items; } else new_items = item->next_item; if (item->next_item) (item->next_item)->prev_item = item->prev_item; /* free data */ if (item->data) free (item->data); free (item); weelist->items = new_items; weelist->size--; } /* * weelist_remove_all: remove all items from a list */ void weelist_remove_all (struct t_weelist *weelist) { if (!weelist) return; while (weelist->items) { weelist_remove (weelist, weelist->items); } } /* * weelist_free: free a list */ void weelist_free (struct t_weelist *weelist) { if (!weelist) return; weelist_remove_all (weelist); free (weelist); } /* * weelist_print_log: print weelist in log (usually for crash dump) */ void weelist_print_log (struct t_weelist *weelist, const char *name) { struct t_weelist_item *ptr_item; log_printf ("[%s (addr:0x%lx)]", name, weelist); for (ptr_item = weelist->items; ptr_item; ptr_item = ptr_item->next_item) { log_printf (" data . . . . . . . . . : '%s'", ptr_item->data); log_printf (" prev_item. . . . . . . : 0x%lx", ptr_item->prev_item); log_printf (" next_item. . . . . . . : 0x%lx", ptr_item->next_item); } }
matsuu/weechat
src/core/wee-list.c
C
gpl-3.0
8,297
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2494, 1011, 2268, 2011, 5956, 16044, 1026, 5956, 16044, 1030, 5956, 8525, 2595, 1012, 8917, 1028, 1008, 2156, 3191, 4168, 2005, 6105, 6987, 1010, 6048, 2005, 9797, 2862, 1012, 1008, 1008, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* @LICENSE(MUSLC_MIT) */ #include "stdio_impl.h" /* This function makes no attempt to protect the user from his/her own * stupidity. If called any time but when then ISO C standard specifically * allows it, all hell can and will break loose, especially with threads! * * This implementation ignores all arguments except the buffering type, * and uses the existing buffer allocated alongside the FILE object. * In the case of stderr where the preexisting buffer is length 1, it * is not possible to set line buffering or full buffering. */ int setvbuf(FILE *f, char *buf, int type, size_t size) { f->lbf = EOF; if (type == _IONBF) f->buf_size = 0; else if (type == _IOLBF) f->lbf = '\n'; f->flags |= F_SVB; return 0; }
gapry/refos
libs/libmuslc/src/stdio/setvbuf.c
C
bsd-2-clause
741
[ 30522, 1013, 1008, 1030, 6105, 1006, 14163, 14540, 2278, 1035, 10210, 1007, 1008, 1013, 1001, 2421, 1000, 2358, 20617, 1035, 17727, 2140, 1012, 1044, 1000, 1013, 1008, 2023, 3853, 3084, 2053, 3535, 2000, 4047, 1996, 5310, 2013, 2010, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
require 'nmea_plus/message/ais/vdm_payload/vdm_msg' module NMEAPlus module Message module AIS module VDMPayload # AIS Type 24: Static Data Report class VDMMsg24 < NMEAPlus::Message::AIS::VDMPayload::VDMMsg payload_reader :part_number, 38, 2, :_u # Override default bitstring setting to dynamically calculate what fields belong in this message # which can be either part A or part B dpeending on the {#part_number} field def payload_bitstring=(val) super case part_number when 0 self.class.payload_reader :name, 40, 120, :_t when 1 self.class.payload_reader :ship_cargo_type, 40, 8, :_e self.class.payload_reader :vendor_id, 48, 18, :_t self.class.payload_reader :model_code, 66, 4, :_u self.class.payload_reader :serial_number, 70, 20, :_u self.class.payload_reader :callsign, 90, 42, :_t # If the MMSI is that of an auxiliary craft, these 30 bits are read as the MMSI of the mother ship. # otherwise they are the vessel dimensions if auxiliary_craft? self.class.payload_reader :mothership_mmsi, 132, 30, :_u else self.class.payload_reader :ship_dimension_to_bow, 132, 9, :_u self.class.payload_reader :ship_dimension_to_stern, 141, 9, :_u self.class.payload_reader :ship_dimension_to_port, 150, 6, :_u self.class.payload_reader :ship_dimension_to_starboard, 156, 6, :_u end end end # @!parse attr_reader :ship_cargo_type_description # @return [String] Cargo type description def ship_cargo_type_description get_ship_cargo_type_description(ship_cargo_type) end end end end end end
ifreecarve/nmea_plus
lib/nmea_plus/message/ais/vdm_payload/vdm_msg24.rb
Ruby
apache-2.0
1,933
[ 30522, 5478, 1005, 23770, 2050, 1035, 4606, 1013, 4471, 1013, 9932, 2015, 1013, 1058, 22117, 1035, 18093, 1013, 1058, 22117, 1035, 5796, 2290, 1005, 11336, 23770, 9331, 7393, 11336, 4471, 11336, 9932, 2015, 11336, 1058, 22117, 4502, 8516, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category Zend * @package Zend_Mail * @subpackage Storage * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: Abstract.php 24594 2012-01-05 21:27:01Z matthew $ */ /** * @category Zend * @package Zend_Mail * @subpackage Storage * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Mail_Storage_Abstract implements Countable, ArrayAccess, SeekableIterator { /** * class capabilities with default values * @var array */ protected $_has = array('uniqueid' => true, 'delete' => false, 'create' => false, 'top' => false, 'fetchPart' => true, 'flags' => false); /** * current iteration position * @var int */ protected $_iterationPos = 0; /** * maximum iteration position (= message count) * @var null|int */ protected $_iterationMax = null; /** * used message class, change it in an extened class to extend the returned message class * @var string */ protected $_messageClass = 'Zend_Mail_Message'; /** * Getter for has-properties. The standard has properties * are: hasFolder, hasUniqueid, hasDelete, hasCreate, hasTop * * The valid values for the has-properties are: * - true if a feature is supported * - false if a feature is not supported * - null is it's not yet known or it can't be know if a feature is supported * * @param string $var property name * @return bool supported or not * @throws Zend_Mail_Storage_Exception */ public function __get($var) { if (strpos($var, 'has') === 0) { $var = strtolower(substr($var, 3)); return isset($this->_has[$var]) ? $this->_has[$var] : null; } /** * @see Zend_Mail_Storage_Exception */ require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception($var . ' not found'); } /** * Get a full list of features supported by the specific mail lib and the server * * @return array list of features as array(featurename => true|false[|null]) */ public function getCapabilities() { return $this->_has; } /** * Count messages messages in current box/folder * * @return int number of messages * @throws Zend_Mail_Storage_Exception */ abstract public function countMessages(); /** * Get a list of messages with number and size * * @param int $id number of message * @return int|array size of given message of list with all messages as array(num => size) */ abstract public function getSize($id = 0); /** * Get a message with headers and body * * @param int $id number of message * @return Zend_Mail_Message */ abstract public function getMessage($id); /** * Get raw header of message or part * * @param int $id number of message * @param null|array|string $part path to part or null for messsage header * @param int $topLines include this many lines with header (after an empty line) * @return string raw header */ abstract public function getRawHeader($id, $part = null, $topLines = 0); /** * Get raw content of message or part * * @param int $id number of message * @param null|array|string $part path to part or null for messsage content * @return string raw content */ abstract public function getRawContent($id, $part = null); /** * Create instance with parameters * * @param array $params mail reader specific parameters * @throws Zend_Mail_Storage_Exception */ abstract public function __construct($params); /** * Destructor calls close() and therefore closes the resource. */ public function __destruct() { $this->close(); } /** * Close resource for mail lib. If you need to control, when the resource * is closed. Otherwise the destructor would call this. * * @return null */ abstract public function close(); /** * Keep the resource alive. * * @return null */ abstract public function noop(); /** * delete a message from current box/folder * * @return null */ abstract public function removeMessage($id); /** * get unique id for one or all messages * * if storage does not support unique ids it's the same as the message number * * @param int|null $id message number * @return array|string message number for given message or all messages as array * @throws Zend_Mail_Storage_Exception */ abstract public function getUniqueId($id = null); /** * get a message number from a unique id * * I.e. if you have a webmailer that supports deleting messages you should use unique ids * as parameter and use this method to translate it to message number right before calling removeMessage() * * @param string $id unique id * @return int message number * @throws Zend_Mail_Storage_Exception */ abstract public function getNumberByUniqueId($id); // interface implementations follows /** * Countable::count() * * @return int */ public function count() { return $this->countMessages(); } /** * ArrayAccess::offsetExists() * * @param int $id * @return boolean */ public function offsetExists($id) { try { if ($this->getMessage($id)) { return true; } } catch(Zend_Mail_Storage_Exception $e) {} return false; } /** * ArrayAccess::offsetGet() * * @param int $id * @return Zend_Mail_Message message object */ public function offsetGet($id) { return $this->getMessage($id); } /** * ArrayAccess::offsetSet() * * @param id $id * @param mixed $value * @throws Zend_Mail_Storage_Exception * @return void */ public function offsetSet($id, $value) { /** * @see Zend_Mail_Storage_Exception */ require_once 'Zend/Mail/Storage/Exception.php'; throw new Zend_Mail_Storage_Exception('cannot write mail messages via array access'); } /** * ArrayAccess::offsetUnset() * * @param int $id * @return boolean success */ public function offsetUnset($id) { return $this->removeMessage($id); } /** * Iterator::rewind() * * Rewind always gets the new count from the storage. Thus if you use * the interfaces and your scripts take long you should use reset() * from time to time. * * @return void */ public function rewind() { $this->_iterationMax = $this->countMessages(); $this->_iterationPos = 1; } /** * Iterator::current() * * @return Zend_Mail_Message current message */ public function current() { return $this->getMessage($this->_iterationPos); } /** * Iterator::key() * * @return int id of current position */ public function key() { return $this->_iterationPos; } /** * Iterator::next() * * @return void */ public function next() { ++$this->_iterationPos; } /** * Iterator::valid() * * @return boolean */ public function valid() { if ($this->_iterationMax === null) { $this->_iterationMax = $this->countMessages(); } return $this->_iterationPos && $this->_iterationPos <= $this->_iterationMax; } /** * SeekableIterator::seek() * * @param int $pos * @return void * @throws OutOfBoundsException */ public function seek($pos) { if ($this->_iterationMax === null) { $this->_iterationMax = $this->countMessages(); } if ($pos > $this->_iterationMax) { throw new OutOfBoundsException('this position does not exist'); } $this->_iterationPos = $pos; } }
MehdyOueriemi/Relais
wp-content/plugins/zend-framework/Zend/Mail/Storage/Abstract.php
PHP
gpl-2.0
9,316
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 16729, 2094, 7705, 1008, 1008, 6105, 1008, 1008, 2023, 3120, 5371, 2003, 3395, 2000, 1996, 2047, 18667, 2094, 6105, 2008, 2003, 24378, 1008, 2007, 2023, 7427, 1999, 1996, 5371, 6105, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package App::KADR::Path::Entity; # ABSTRACT: Path::Class::Entity for KADR, faster use common::sense; use Encode; use Params::Util qw(_INSTANCE); use Scalar::Util qw(refaddr); use overload '<=>' => 'abs_cmp', fallback => 1; sub abs_cmp { return 1 unless defined $_[1]; # Same object. # Use refaddr since this method is used as the == overload fallback. return 0 if refaddr $_[0] == refaddr $_[1]; my $a = shift; my $b = _INSTANCE($_[0], __PACKAGE__) || $a->new($_[0]); # Different entity subclass. return ref $a cmp ref $b if ref $a ne ref $b; return $a->absolute cmp $b->absolute; } sub exists { -e $_[0] } sub is_dir_exists { -d $_[0] } sub is_file_exists { -f $_[0] } sub size { $_[0]->stat->size } sub stat { $_[0]{stat} //= File::stat::stat($_[0]->stringify) } sub stat_now { $_[0]{stat} = File::stat::stat($_[0]->stringify) } sub _decode_path { decode_utf8 $_[1]; } 0x6B63; =head1 SYNOPSIS $path->exists == -e $path; $path->is_dir_exists == -d $path; $path->is_file_exists == -f $path; $path->size == -s $path; my $stat = $path->stat; # Cached my $stat = $path->stat_now; # Updates cache =head1 DESCRIPTION A "placeholder" of sorts to allow portable operations on Unicode paths to be added later. =head1 METHODS =head2 C<abs_cmp> my $cmp = $dir->abs_cmp('/home'); my $cmp = $dir->abs_cmp(dir()); my $cmp = $dir <=> '/home'; Compare two path entities of the same subclass as if both are relative to the current working directory.
Kulag/KADR
lib/App/KADR/Path/Entity.pm
Perl
mit
1,506
[ 30522, 7427, 10439, 1024, 1024, 10556, 13626, 1024, 1024, 4130, 1024, 1024, 9178, 1025, 1001, 10061, 1024, 4130, 1024, 1024, 2465, 1024, 1024, 9178, 2005, 10556, 13626, 1010, 5514, 2224, 2691, 1024, 1024, 3168, 1025, 2224, 4372, 16044, 1025...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: How the Go team could track what to include in release notes date: 2021-03-13 author: Paschalis Ts tags: [golang, foss] mathjax: false description: "" --- Release notes can sometimes be exciting to read. Condensing the work since the last release into a couple of paragraphs, announcing new exciting features or deprecating older ones, communicating bugfixes or architectural decisions, making important announcements.. Come to think of it, the couple of times that I've had to *write* them, wasn't so bad at all! Unfortunately, the current trend is release notes becoming a mix of *Bug fixes*, *Made ur app faster*, *Added new feature, won't tell you what it is*, which can sound like generalities at best and condescending or patronizing at worst; usually like something written just to fill an arbitrary word limit in the last five minutes before a release. Here's what's currently listed in the "What's New" section for a handful of popular applications in the Google Play Store. ``` - Thanks for choosing Chrome! This release includes stability and performance improvements. - Every week we polish up the Pinterest app to make it faster and better than ever. Tell us if you like this newest version at http://help.pinterest.com/contact - Get the best experience for enjoying recent hits and timeless classics with our latest Netflix update for your phone and tablet. - We update the Uber app as often as possible to help make it faster and more reliable for you. This version includes several bug fixes and performance improvements. - We’re always making changes and improvements to Spotify. To make sure you don’t miss a thing, just keep your Updates turned on. - For new features, look for in-product education & notifications sharing the feature and how to use it! (FYI this was YouTube, as it doesn't even mention the product's name) ``` The Opera browser, on the other hand has something more reminiscent of actual release notes. ``` What's New Thanks for choosing Opera! This version includes improvements to Flow, the share dialog and the built-in video player. More changes: - Chromium 87 - Updated onboarding - Adblocker improvements - Various fixes and stability improvements ``` Just to make things clear *I'm not bashing these fellow developers at all*. [Here's](https://github.com/beatlabs/patron/releases) the release history of a project I'm helping maintain; our release notes can be just as vague sometimes. Writing helpful, informative (and even fun!) release notes is time consuming and has little benefit non-technical folks. It's also hard to keep track of what's changed since the last release, and deciding what's important and what's not. How would *you* do it? ## The Go team solution So, how is Go team approaching this problem? A typical Go release in the past three years may contain from 1.6k to 2.3k commits. ``` from -> to commits 1.15 -> 1.16 1695 1.14 -> 1.15 1651 1.13 -> 1.14 1754 1.12 -> 1.13 1646 1.11 -> 1.12 1682 1.10 -> 1.11 2268 1.9 -> 1.10 1996 1.8 -> 1.9 2157 ``` How do you keep track of what was important, what someone reading the release notes may need to know? I set to find out, after [Emmanuel](https://twitter.com/odeke_et) (a great person, and one of the best ambassadors the Go community could wish for), added a mysterious comment on one of my [latest CLs](https://go-review.googlesource.com/c/go/+/284136) that read `RELNOTE=yes`. The [`build`](https://github.com/golang/build) repo holds Go's continuous build and release infrastructure; it also contains the [`relnote` tool](https://github.com/golang/build/blob/master/cmd/relnote/relnote.go) that gathers and summarizes Gerrit changes (CLs) which are marked with RELNOTE annotations. The earliest reference of this idea I could find is [this CL](https://go-review.googlesource.com/c/build/+/30697) from Brad Fitzpatrick, back in October 2016. So, any time a commit is merged (or close to merging) where someone thinks it may be useful to include in the release notes, they can leave a `RELNOTE=yes` or `RELNOTES=yes` comment. All these CLs are then gathered to be reviewed by the release author. Here's the actual Gerrit API query: ``` query := fmt.Sprintf(`status:merged branch:master since:%s (comment:"RELNOTE" OR comment:"RELNOTES")` ``` Of course, this is not a tool that will automatically generate something you can publish, but it's a pretty good alternative to sieving a couple thousands of commits manually. I love the simplicity; I feel that it embodies the Go way of doing things. I feel that if my team at work tried to find a solution, we'd come up with something much more complex, fragile and unmaintainable than this. The tool doesn't even support time ranges as input; since Go releases are roughly once every six months, here's how it decides which commits to include ```go // Releases are every 6 months. Walk forward by 6 month increments to next release. cutoff := time.Date(2016, time.August, 1, 00, 00, 00, 0, time.UTC) now := time.Now() for cutoff.Before(now) { cutoff = cutoff.AddDate(0, 6, 0) } // Previous release was 6 months earlier. cutoff = cutoff.AddDate(0, -6, 0) ``` ## In action! Here's me running the tool, and a small part of the output. ```bash $ git clone https://github.com/golang/build $ cd build/cmd/relnote $ go build . $ ./relnote ... ... https://golang.org/cl/268020: os: avoid allocation in File.WriteString reflect https://golang.org/cl/266197: reflect: add Method.IsExported and StructField.IsExported methods https://golang.org/cl/281233: reflect: add VisibleFields function syscall https://golang.org/cl/295371: syscall: do not overflow key memory in GetQueuedCompletionStatus unicode https://golang.org/cl/280493: unicode: correctly handle negative runes ``` ## Parting words That's all for today! I hope that my change will find its way on the Go 1.17 release notes; if not I'm happy that I learned something new! I'm not sure if the `relnote` tool is still being actively used, but I think it would be fun to learn more about what goes into packaging a Go release. Until next time, bye!
tpaschalis/tpaschalis.github.io
_posts/2021-03-13-relnote-yes.markdown
Markdown
mit
6,148
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 2129, 1996, 2175, 2136, 2071, 2650, 2054, 2000, 2421, 1999, 2713, 3964, 3058, 1024, 25682, 1011, 6021, 1011, 2410, 3166, 1024, 14674, 18598, 2483, 24529, 22073, 1024, 1031, 2175, 25023,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Modules\Core\Console\Installers\Scripts\UserProviders; use Modules\Core\Console\Installers\SetupScript; class UsherInstaller extends ProviderInstaller implements SetupScript { /** * @var string */ protected $driver = 'Usher'; /** * Check if the user driver is correctly registered. * @return bool */ public function checkIsInstalled() { return class_exists('Maatwebsite\Usher\UsherServiceProvider') && class_exists('Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider'); } /** * Not called * @return mixed */ public function composer() { $this->application->register('Maatwebsite\Usher\UsherServiceProvider'); } /** * @return mixed */ public function publish() { if ($this->command->option('verbose')) { $this->command->call('vendor:publish', ['--provider' => 'Maatwebsite\Usher\UsherServiceProvider']); return $this->command->call('vendor:publish', ['--provider' => 'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider']); } $this->command->callSilent('vendor:publish', ['--provider' => 'Maatwebsite\Usher\UsherServiceProvider']); return $this->command->callSilent('vendor:publish', ['--provider' => 'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider']); } /** * @return mixed */ public function migrate() { if ($this->command->option('verbose')) { return $this->command->call('doctrine:schema:update'); } return $this->command->callSilent('doctrine:schema:update'); } /** * @return mixed */ public function configure() { $path = base_path("config/usher.php"); $config = $this->finder->get($path); $config = str_replace('Maatwebsite\Usher\Domain\Users\UsherUser', "Modules\\User\\Entities\\{$this->driver}\\User", $config); $config = str_replace('Maatwebsite\Usher\Domain\Roles\UsherRole', "Modules\\User\\Entities\\{$this->driver}\\Role", $config); $this->finder->put($path, $config); // Doctrine config $path = base_path("config/doctrine.php"); $config = $this->finder->get($path); $config = str_replace('// Paths to entities here...', 'base_path(\'Modules/User/Entities/Usher\')', $config); $this->finder->put($path, $config); $this->bindUserRepositoryOnTheFly('Usher'); $this->application->register('Maatwebsite\Usher\UsherServiceProvider'); $this->application->register('Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider'); } /** * @return mixed */ public function seed() { if ($this->command->option('verbose')) { return $this->command->call('db:seed', ['--class' => 'Modules\User\Database\Seeders\UsherTableSeeder']); } return $this->command->callSilent('db:seed', ['--class' => 'Modules\User\Database\Seeders\UsherTableSeeder']); } /** * @param $password * @return mixed */ public function getHashedPassword($password) { return $password; } }
ruscon/Core
Console/Installers/Scripts/UserProviders/UsherInstaller.php
PHP
mit
3,182
[ 30522, 1026, 1029, 25718, 3415, 15327, 14184, 1032, 4563, 1032, 10122, 1032, 16500, 2545, 1032, 14546, 1032, 5310, 21572, 17258, 2545, 1025, 2224, 14184, 1032, 4563, 1032, 10122, 1032, 16500, 2545, 1032, 16437, 22483, 1025, 2465, 20774, 7076,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package seg.jUCMNav.actions.concerns; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.commands.UnexecutableCommand; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PlatformUI; import seg.jUCMNav.JUCMNavPlugin; import seg.jUCMNav.Messages; import seg.jUCMNav.actions.SelectionHelper; import seg.jUCMNav.actions.URNSelectionAction; import seg.jUCMNav.aourn.composer.AspectMarkerMappings; import seg.jUCMNav.aourn.composer.UCMAspectComposer; import seg.jUCMNav.aourn.composer.exceptions.CompositionNotRequired; import seg.jUCMNav.aourn.composer.exceptions.MalformedAspectMap; import seg.jUCMNav.aourn.matcher.Mapping; import seg.jUCMNav.aourn.matcher.Match; import seg.jUCMNav.aourn.matcher.MatchList; import seg.jUCMNav.aourn.matcher.MatchableElementFactory; import seg.jUCMNav.aourn.matcher.PointcutMatcher; import seg.jUCMNav.aourn.matcher.exceptions.MatchingFailedException; import seg.jUCMNav.model.commands.concerns.AddAspectStubsCommand; import seg.jUCMNav.views.preferences.DisplayPreferences; import ucm.map.InBinding; import ucm.map.NodeConnection; import ucm.map.OutBinding; import ucm.map.PathNode; import ucm.map.PluginBinding; import ucm.map.PointcutKind; import ucm.map.Stub; import ucm.map.UCMmap; import urn.URNspec; import urncore.URNmodelElement; /** * Action related to applying a concern to the model * * @author gunterm * */ public class ApplyConcernAction extends URNSelectionAction { public static final String APPLYCONCERN = "seg.jUCMNav.actions.concerns.ApplyConcernAction"; //$NON-NLS-1$ // this is either an aspect map, a pointcut graph, or a concern private URNmodelElement element; private URNspec urn; /** * @param part * the workbench part we are working with */ public ApplyConcernAction(IWorkbenchPart part) { super(part); setId(APPLYCONCERN); // TODO create a new icon for Apply Concern setImageDescriptor(JUCMNavPlugin.getImageDescriptor("icons/Concern16.gif")); //$NON-NLS-1$ } /** * Returns true if a map, a grl graph, or a concern is selected; false otherwise * * @see seg.jUCMNav.actions.URNSelectionAction#calculateEnabled() */ protected boolean calculateEnabled() { if(!DisplayPreferences.getInstance().isAdvancedControlEnabled() || !DisplayPreferences.getInstance().isShowAspect()) return false; SelectionHelper sel = new SelectionHelper(getSelectedObjects()); element = sel.getURNmodelElement(); switch (sel.getSelectionType()) { case SelectionHelper.MAP: // TODO GRL and concerns not yet supported // case SelectionHelper.GRLGRAPH: // case SelectionHelper.CONCERN: urn = sel.getUrnspec(); return true; default: return false; } } /** * @return a {@link AddAspectStubsCommand} */ protected Command getCommand() { boolean showInfoMessages = false; // TODO only works for UCM right now HashSet<UCMmap> pointcutMaps = getPointcutExpression(element); UCMmap pointcutMap = null; // TODO externalize strings if (!pointcutMaps.isEmpty()) { MatchableElementFactory.clearCache(); List<PathNode> joinpoints = MatchableElementFactory.createMatchableElements(urn, element, pointcutMaps); List<MatchList> matchResultList = new ArrayList<MatchList>(); MatchList matchResult = new MatchList(); String capture = ""; //$NON-NLS-1$ int size = 0; for (Iterator iterator = pointcutMaps.iterator(); iterator.hasNext();) { pointcutMap = (UCMmap) iterator.next(); if (showInfoMessages) MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Result", "Found pointcut expression: " + pointcutMap.getName() + " [" + pointcutMap.getId() + Messages.getString("ApplyConcernAction.CloseBracketJoinPoints") + joinpoints.size() + Messages.getString("ApplyConcernAction.SpacePathNodes")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ try { matchResult = PointcutMatcher.match(pointcutMap, joinpoints); matchResultList.add(matchResult); if (matchResult.getMatchList().size() < 20) capture = capture + capture(matchResult); size = size + matchResult.getMatchList().size(); } catch (MatchingFailedException e) { // add an empty list of matches, so that there is the same number of entries in the results array as there are pointcut maps matchResultList.add(new MatchList()); } } if (showInfoMessages) MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Result", "Found " + size + Messages.getString("ApplyConcernAction.SpaceMatches") + capture); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ else MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Result", "Found " + size + "matches!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // go through all the pointcut maps and compose their match results int i = 0; UCMAspectComposer.resetCounter(); List<List<AspectMarkerMappings>> composeResultList = new ArrayList<List<AspectMarkerMappings>>(); boolean compositionSuccessful = false; for (Iterator iterator = pointcutMaps.iterator(); iterator.hasNext();) { pointcutMap = (UCMmap) iterator.next(); MatchList mResult = matchResultList.get(i++); // if there are some matches, continue with the composition if (mResult.getMatchList().size() > 0) { List<AspectMarkerMappings> composeResult = new ArrayList<AspectMarkerMappings>(); capture = ""; //$NON-NLS-1$ try { composeResult = UCMAspectComposer.compose((UCMmap) element, pointcutMap, mResult); composeResultList.add(composeResult); if (composeResult.size() < 20) capture = capture + capture(composeResult); compositionSuccessful = true; } catch (MalformedAspectMap e) { MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "Malformed aspect map!"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (CompositionNotRequired e) { MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "Nothing to compose!"); //$NON-NLS-1$ //$NON-NLS-2$ } } } if (compositionSuccessful) { size = 0; for (int j = 0; j < composeResultList.size(); j++) { size = size + composeResultList.get(j).size(); } if (showInfoMessages) MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Result", "Aspect markers to apply: " + size + " " + capture); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (size < 250) { // perform the commands to update the model - one for each aspect marker that is being added CompoundCommand cmd = new AddAspectStubsCommand(urn, composeResultList); // dispose of the the temporary matching and composition data disposeMatchingCompositionInfo(); return cmd; } else { MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Info", "Too much work to add so many aspect markers!"); //$NON-NLS-1$ //$NON-NLS-2$ } } } else { MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "This map does not contain one or more pointcut stubs with the same pointcut maps and with in/out-bindings for all in/out-paths!"); //$NON-NLS-1$ //$NON-NLS-2$ } return UnexecutableCommand.INSTANCE; } private HashSet<UCMmap> getPointcutExpression(URNmodelElement element) { // TODO only works for UCM right now if (element instanceof UCMmap) { // find all pointcut stubs List<Stub> pointcutStubs = new ArrayList<Stub>(); for (Iterator iter = ((UCMmap) element).getNodes().iterator(); iter.hasNext();) { PathNode pathnode = (PathNode) iter.next(); if (pathnode instanceof Stub && !((Stub) pathnode).getAopointcut().equals(PointcutKind.NONE_LITERAL)) { pointcutStubs.add((Stub) pathnode); } } // check that all pointcuts stubs have the same number of plug-in maps and at least one plug-in map (i.e., pointcut map) HashSet<UCMmap> pointcutMaps = new HashSet<UCMmap>(); int numberOfPlugins = -1; for (int i = 0; i < pointcutStubs.size(); i++) { Stub stub = pointcutStubs.get(i); int size = stub.getBindings().size(); if (numberOfPlugins == -1) numberOfPlugins = size; else if (size != numberOfPlugins) { numberOfPlugins = -1; break; } for (Iterator iterator = stub.getBindings().iterator(); iterator.hasNext();) { UCMmap pcMap = ((PluginBinding) iterator.next()).getPlugin(); pointcutMaps.add(pcMap); } } // return empty set if the number of plug-in maps is not the same or is 0 (i.e., it was set to -1 in the previous for loop) // also check that all plug-in maps are the same for each pointcut stub (i.e., the number of all plug-in maps is the same as numberOfPlugins) if (numberOfPlugins == -1 || numberOfPlugins != pointcutMaps.size()) return new HashSet<UCMmap>(); // furthermore, all in/out-paths of the pointcut stubs need to have an in/outBinding for all its pointcut maps for (int i = 0; i < pointcutStubs.size(); i++) { Stub pcStub = pointcutStubs.get(i); for (int j = 0; j < pcStub.getBindings().size(); j++) { List<NodeConnection> ncList = new ArrayList<NodeConnection>(); ncList.addAll(pcStub.getPred()); ncList.addAll(pcStub.getSucc()); PluginBinding pl = (PluginBinding) pcStub.getBindings().get(j); // look through all the in/outBindings and remove the corresponding in/out-path from the list of in/out-paths for (int k = 0; k < pl.getIn().size(); k++) { InBinding in = (InBinding) pl.getIn().get(k); ncList.remove(in.getStubEntry()); } for (int k = 0; k < pl.getOut().size(); k++) { OutBinding out = (OutBinding) pl.getOut().get(k); ncList.remove(out.getStubExit()); } // the remaining list of in/out-paths has to be empty if all in/out-paths have bindings if (!ncList.isEmpty()) { // return empty set if some in/out-paths do not have bindings return new HashSet<UCMmap>(); } } } return pointcutMaps; } return new HashSet<UCMmap>(); } private void disposeMatchingCompositionInfo() { UCMAspectComposer.dispose(); PointcutMatcher.dispose(); } private String capture(MatchList result) { String capture = ""; //$NON-NLS-1$ if (result != null) { for (Iterator iter = result.getMatchList().iterator(); iter.hasNext();) { Match mappings = (Match) iter.next(); for (Iterator iterator = mappings.getMatch().iterator(); iterator.hasNext();) { Mapping mapping = (Mapping) iterator.next(); if (mapping.getPointcutElement().getElement() == null) capture += "null" + " --> " + mapping.getJoinpoint().getName() + "[" + mapping.getJoinpoint().getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ else capture += mapping.getPointcutElement().getName() + "[" + mapping.getPointcutElement().getId() + "] --> " + mapping.getJoinpoint().getName() + "[" + mapping.getJoinpoint().getId() + "] "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } capture += "----- "; //$NON-NLS-1$ } } else capture += Messages.getString("ApplyConcernAction.NoMatch"); //$NON-NLS-1$ return capture; } private static String capture(List<AspectMarkerMappings> result) { String capture = ""; //$NON-NLS-1$ for (int i = 0; i < result.size(); i++) { PathNode joinpoint = (PathNode) result.get(i).getFirstMapping().get(0); NodeConnection insertionPoint = (NodeConnection) result.get(i).getInsertionPoint(); capture += joinpoint.getName() + "[" + joinpoint.getId() + Messages.getString("ApplyConcernAction.CloseBracketInsertionPoint") + ((PathNode) insertionPoint.getSource()).getName() + "[" + ((PathNode) insertionPoint.getSource()).getId() + "]<-->" + ((PathNode) insertionPoint.getTarget()).getName() + "[" + ((PathNode) insertionPoint.getTarget()).getId() + "] ----- "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ } return capture; } }
McGill-DP-Group/seg.jUCMNav
src/seg/jUCMNav/actions/concerns/ApplyConcernAction.java
Java
epl-1.0
13,158
[ 30522, 7427, 7367, 2290, 1012, 18414, 27487, 2532, 2615, 1012, 4506, 1012, 5936, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 9140, 9863, 1025, 12324, 9262, 1012, 21183, 4014, 30524, 16216, 2546, 1012, 10954, 1012, 3094, 1025, 12324, 8917, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
namespace BarionClientLibrary.Operations.Common { public class ShippingAddress { public string Country { get; set; } public string City { get; set; } public string Region { get; set; } public string Zip { get; set; } public string Street { get; set; } public string Street2 { get; set; } public string Street3 { get; set; } public string FullName { get; set; } } }
szelpe/barion-dotnet
BarionClientLibrary/Operations/Common/ShippingAddress.cs
C#
gpl-3.0
444
[ 30522, 3415, 15327, 22466, 2239, 20464, 11638, 29521, 19848, 2100, 1012, 3136, 1012, 2691, 1063, 2270, 2465, 7829, 4215, 16200, 4757, 1063, 2270, 5164, 2406, 1063, 2131, 1025, 2275, 1025, 1065, 2270, 5164, 2103, 1063, 2131, 1025, 2275, 1025...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package datafield * @subpackage number * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2015111600; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2015111000; // Requires this Moodle version $plugin->component = 'datafield_number'; // Full name of the plugin (used for diagnostics)
ernestovi/ups
moodle/mod/data/field/number/version.php
PHP
gpl-3.0
1,176
[ 30522, 1026, 1029, 25718, 1013, 1013, 2023, 5371, 2003, 2112, 1997, 6888, 2571, 1011, 8299, 1024, 1013, 1013, 6888, 2571, 1012, 8917, 1013, 1013, 1013, 1013, 1013, 6888, 2571, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 26...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
(function (window) { 'use strict'; /*global define, module, exports, require */ var c3 = { version: "0.4.11" }; var c3_chart_fn, c3_chart_internal_fn, c3_chart_internal_axis_fn; function API(owner) { this.owner = owner; } function inherit(base, derived) { if (Object.create) { derived.prototype = Object.create(base.prototype); } else { var f = function f() {}; f.prototype = base.prototype; derived.prototype = new f(); } derived.prototype.constructor = derived; return derived; } function Chart(config) { var $$ = this.internal = new ChartInternal(this); $$.loadConfig(config); $$.beforeInit(config); $$.init(); $$.afterInit(config); // bind "this" to nested API (function bindThis(fn, target, argThis) { Object.keys(fn).forEach(function (key) { target[key] = fn[key].bind(argThis); if (Object.keys(fn[key]).length > 0) { bindThis(fn[key], target[key], argThis); } }); })(c3_chart_fn, this, this); } function ChartInternal(api) { var $$ = this; $$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; $$.api = api; $$.config = $$.getDefaultConfig(); $$.data = {}; $$.cache = {}; $$.axes = {}; } c3.generate = function (config) { return new Chart(config); }; c3.chart = { fn: Chart.prototype, internal: { fn: ChartInternal.prototype, axis: { fn: Axis.prototype } } }; c3_chart_fn = c3.chart.fn; c3_chart_internal_fn = c3.chart.internal.fn; c3_chart_internal_axis_fn = c3.chart.internal.axis.fn; c3_chart_internal_fn.beforeInit = function () { // can do something }; c3_chart_internal_fn.afterInit = function () { // can do something }; c3_chart_internal_fn.init = function () { var $$ = this, config = $$.config; $$.initParams(); if (config.data_url) { $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_headers, config.data_keys, $$.initWithData); } else if (config.data_json) { $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); } else if (config.data_rows) { $$.initWithData($$.convertRowsToData(config.data_rows)); } else if (config.data_columns) { $$.initWithData($$.convertColumnsToData(config.data_columns)); } else { throw Error('url or json or rows or columns is required.'); } }; c3_chart_internal_fn.initParams = function () { var $$ = this, d3 = $$.d3, config = $$.config; // MEMO: clipId needs to be unique because it conflicts when multiple charts exist $$.clipId = "c3-" + (+new Date()) + '-clip', $$.clipIdForXAxis = $$.clipId + '-xaxis', $$.clipIdForYAxis = $$.clipId + '-yaxis', $$.clipIdForGrid = $$.clipId + '-grid', $$.clipIdForSubchart = $$.clipId + '-subchart', $$.clipPath = $$.getClipPath($$.clipId), $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis), $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid), $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart), $$.dragStart = null; $$.dragging = false; $$.flowing = false; $$.cancelClick = false; $$.mouseover = false; $$.transiting = false; $$.color = $$.generateColor(); $$.levelColor = $$.generateLevelColor(); $$.dataTimeFormat = config.data_xLocaltime ? d3.time.format : d3.time.format.utc; $$.axisTimeFormat = config.axis_x_localtime ? d3.time.format : d3.time.format.utc; $$.defaultAxisTimeFormat = $$.axisTimeFormat.multi([ [".%L", function (d) { return d.getMilliseconds(); }], [":%S", function (d) { return d.getSeconds(); }], ["%I:%M", function (d) { return d.getMinutes(); }], ["%I %p", function (d) { return d.getHours(); }], ["%-m/%-d", function (d) { return d.getDay() && d.getDate() !== 1; }], ["%-m/%-d", function (d) { return d.getDate() !== 1; }], ["%-m/%-d", function (d) { return d.getMonth(); }], ["%Y/%-m/%-d", function () { return true; }] ]); $$.hiddenTargetIds = []; $$.hiddenLegendIds = []; $$.focusedTargetIds = []; $$.defocusedTargetIds = []; $$.xOrient = config.axis_rotated ? "left" : "bottom"; $$.yOrient = config.axis_rotated ? (config.axis_y_inner ? "top" : "bottom") : (config.axis_y_inner ? "right" : "left"); $$.y2Orient = config.axis_rotated ? (config.axis_y2_inner ? "bottom" : "top") : (config.axis_y2_inner ? "left" : "right"); $$.subXOrient = config.axis_rotated ? "left" : "bottom"; $$.isLegendRight = config.legend_position === 'right'; $$.isLegendInset = config.legend_position === 'inset'; $$.isLegendTop = config.legend_inset_anchor === 'top-left' || config.legend_inset_anchor === 'top-right'; $$.isLegendLeft = config.legend_inset_anchor === 'top-left' || config.legend_inset_anchor === 'bottom-left'; $$.legendStep = 0; $$.legendItemWidth = 0; $$.legendItemHeight = 0; $$.currentMaxTickWidths = { x: 0, y: 0, y2: 0 }; $$.rotated_padding_left = 30; $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; $$.rotated_padding_top = 5; $$.withoutFadeIn = {}; $$.intervalForObserveInserted = undefined; $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js }; c3_chart_internal_fn.initChartElements = function () { if (this.initBar) { this.initBar(); } if (this.initLine) { this.initLine(); } if (this.initArc) { this.initArc(); } if (this.initGauge) { this.initGauge(); } if (this.initText) { this.initText(); } }; c3_chart_internal_fn.initWithData = function (data) { var $$ = this, d3 = $$.d3, config = $$.config; var defs, main, binding = true; $$.axis = new Axis($$); if ($$.initPie) { $$.initPie(); } if ($$.initBrush) { $$.initBrush(); } if ($$.initZoom) { $$.initZoom(); } if (!config.bindto) { $$.selectChart = d3.selectAll([]); } else if (typeof config.bindto.node === 'function') { $$.selectChart = config.bindto; } else { $$.selectChart = d3.select(config.bindto); } if ($$.selectChart.empty()) { $$.selectChart = d3.select(document.createElement('div')).style('opacity', 0); $$.observeInserted($$.selectChart); binding = false; } $$.selectChart.html("").classed("c3", true); // Init data as targets $$.data.xs = {}; $$.data.targets = $$.convertDataToTargets(data); if (config.data_filter) { $$.data.targets = $$.data.targets.filter(config.data_filter); } // Set targets to hide if needed if (config.data_hide) { $$.addHiddenTargetIds(config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide); } if (config.legend_hide) { $$.addHiddenLegendIds(config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide); } // when gauge, hide legend // TODO: fix if ($$.hasType('gauge')) { config.legend_show = false; } // Init sizes and scales $$.updateSizes(); $$.updateScales(); // Set domains for each scale $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); $$.y.domain($$.getYDomain($$.data.targets, 'y')); $$.y2.domain($$.getYDomain($$.data.targets, 'y2')); $$.subX.domain($$.x.domain()); $$.subY.domain($$.y.domain()); $$.subY2.domain($$.y2.domain()); // Save original x domain for zoom update $$.orgXDomain = $$.x.domain(); // Set initialized scales to brush and zoom if ($$.brush) { $$.brush.scale($$.subX); } if (config.zoom_enabled) { $$.zoom.scale($$.x); } /*-- Basic Elements --*/ // Define svgs $$.svg = $$.selectChart.append("svg") .style("overflow", "hidden") .on('mouseenter', function () { return config.onmouseover.call($$); }) .on('mouseleave', function () { return config.onmouseout.call($$); }); if ($$.config.svg_classname) { $$.svg.attr('class', $$.config.svg_classname); } // Define defs defs = $$.svg.append("defs"); $$.clipChart = $$.appendClip(defs, $$.clipId); $$.clipXAxis = $$.appendClip(defs, $$.clipIdForXAxis); $$.clipYAxis = $$.appendClip(defs, $$.clipIdForYAxis); $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); $$.updateSvgSize(); // Define regions main = $$.main = $$.svg.append("g").attr("transform", $$.getTranslate('main')); if ($$.initSubchart) { $$.initSubchart(); } if ($$.initTooltip) { $$.initTooltip(); } if ($$.initLegend) { $$.initLegend(); } if ($$.initTitle) { $$.initTitle(); } /*-- Main Region --*/ // text when empty main.append("text") .attr("class", CLASS.text + ' ' + CLASS.empty) .attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers. .attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE. // Regions $$.initRegion(); // Grids $$.initGrid(); // Define g for chart area main.append('g') .attr("clip-path", $$.clipPath) .attr('class', CLASS.chart); // Grid lines if (config.grid_lines_front) { $$.initGridLines(); } // Cover whole with rects for events $$.initEventRect(); // Define g for chart $$.initChartElements(); // if zoom privileged, insert rect to forefront // TODO: is this needed? main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS.regions) .attr('class', CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height) .style('opacity', 0) .on("dblclick.zoom", null); // Set default extent if defined if (config.axis_x_extent) { $$.brush.extent($$.getDefaultExtent()); } // Add Axis $$.axis.init(); // Set targets $$.updateTargets($$.data.targets); // Draw with targets if (binding) { $$.updateDimension(); $$.config.oninit.call($$); $$.redraw({ withTransition: false, withTransform: true, withUpdateXDomain: true, withUpdateOrgXDomain: true, withTransitionForAxis: false }); } // Bind resize event $$.bindResize(); // export element of the chart $$.api.element = $$.selectChart.node(); }; c3_chart_internal_fn.smoothLines = function (el, type) { var $$ = this; if (type === 'grid') { el.each(function () { var g = $$.d3.select(this), x1 = g.attr('x1'), x2 = g.attr('x2'), y1 = g.attr('y1'), y2 = g.attr('y2'); g.attr({ 'x1': Math.ceil(x1), 'x2': Math.ceil(x2), 'y1': Math.ceil(y1), 'y2': Math.ceil(y2) }); }); } }; c3_chart_internal_fn.updateSizes = function () { var $$ = this, config = $$.config; var legendHeight = $$.legend ? $$.getLegendHeight() : 0, legendWidth = $$.legend ? $$.getLegendWidth() : 0, legendHeightForBottom = $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, hasArc = $$.hasArcType(), xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), subchartHeight = config.subchart_show && !hasArc ? (config.subchart_size_height + xAxisHeight) : 0; $$.currentWidth = $$.getCurrentWidth(); $$.currentHeight = $$.getCurrentHeight(); // for main $$.margin = config.axis_rotated ? { top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), right: hasArc ? 0 : $$.getCurrentPaddingRight(), bottom: $$.getHorizontalAxisHeight('y') + legendHeightForBottom + $$.getCurrentPaddingBottom(), left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft()) } : { top: 4 + $$.getCurrentPaddingTop(), // for top tick text right: hasArc ? 0 : $$.getCurrentPaddingRight(), bottom: xAxisHeight + subchartHeight + legendHeightForBottom + $$.getCurrentPaddingBottom(), left: hasArc ? 0 : $$.getCurrentPaddingLeft() }; // for subchart $$.margin2 = config.axis_rotated ? { top: $$.margin.top, right: NaN, bottom: 20 + legendHeightForBottom, left: $$.rotated_padding_left } : { top: $$.currentHeight - subchartHeight - legendHeightForBottom, right: NaN, bottom: xAxisHeight + legendHeightForBottom, left: $$.margin.left }; // for legend $$.margin3 = { top: 0, right: NaN, bottom: 0, left: 0 }; if ($$.updateSizeForLegend) { $$.updateSizeForLegend(legendHeight, legendWidth); } $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; if ($$.width < 0) { $$.width = 0; } if ($$.height < 0) { $$.height = 0; } $$.width2 = config.axis_rotated ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right : $$.width; $$.height2 = config.axis_rotated ? $$.height : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; if ($$.width2 < 0) { $$.width2 = 0; } if ($$.height2 < 0) { $$.height2 = 0; } // for arc $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); if ($$.hasType('gauge') && !config.gauge_fullCircle) { $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); } if ($$.updateRadius) { $$.updateRadius(); } if ($$.isLegendRight && hasArc) { $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; } }; c3_chart_internal_fn.updateTargets = function (targets) { var $$ = this; /*-- Main --*/ //-- Text --// $$.updateTargetsForText(targets); //-- Bar --// $$.updateTargetsForBar(targets); //-- Line --// $$.updateTargetsForLine(targets); //-- Arc --// if ($$.hasArcType() && $$.updateTargetsForArc) { $$.updateTargetsForArc(targets); } /*-- Sub --*/ if ($$.updateTargetsForSubchart) { $$.updateTargetsForSubchart(targets); } // Fade-in each chart $$.showTargets(); }; c3_chart_internal_fn.showTargets = function () { var $$ = this; $$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) .transition().duration($$.config.transition_duration) .style("opacity", 1); }; c3_chart_internal_fn.redraw = function (options, transitions) { var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension, withUpdateXAxis; var hideAxis = $$.hasArcType(); var drawArea, drawBar, drawLine, xForText, yForText; var duration, durationForExit, durationForAxis; var waitForDraw, flow; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; var xv = $$.xv.bind($$), cx, cy; options = options || {}; withY = getOption(options, "withY", true); withSubchart = getOption(options, "withSubchart", true); withTransition = getOption(options, "withTransition", true); withTransform = getOption(options, "withTransform", false); withUpdateXDomain = getOption(options, "withUpdateXDomain", false); withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false); withTrimXDomain = getOption(options, "withTrimXDomain", true); withUpdateXAxis = getOption(options, "withUpdateXAxis", withUpdateXDomain); withLegend = getOption(options, "withLegend", false); withEventRect = getOption(options, "withEventRect", true); withDimension = getOption(options, "withDimension", true); withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); duration = withTransition ? config.transition_duration : 0; durationForExit = withTransitionForExit ? duration : 0; durationForAxis = withTransitionForAxis ? duration : 0; transitions = transitions || $$.axis.generateTransitions(durationForAxis); // update legend and transform each g if (withLegend && config.legend_show) { $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); } else if (withDimension) { // need to update dimension (e.g. axis.y.tick.values) because y tick values should change // no need to update axis in it because they will be updated in redraw() $$.updateDimension(true); } // MEMO: needed for grids calculation if ($$.isCategorized() && targetsToShow.length === 0) { $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); } if (targetsToShow.length) { $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); if (!config.axis_x_tick_values) { tickValues = $$.axis.updateXAxisTickValues(targetsToShow); } } else { $$.xAxis.tickValues([]); $$.subXAxis.tickValues([]); } if (config.zoom_rescale && !options.flow) { xDomainForZoom = $$.x.orgDomain(); } $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); if (!config.axis_y_tick_values && config.axis_y_tick_count) { $$.yAxis.tickValues($$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count)); } if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { $$.y2Axis.tickValues($$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count)); } // axes $$.axis.redraw(transitions, hideAxis); // Update axis label $$.axis.updateLabels(withTransition); // show/hide if manual culling needed if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { if (config.axis_x_tick_culling && tickValues) { for (i = 1; i < tickValues.length; i++) { if (tickValues.length / i < config.axis_x_tick_culling_max) { intervalForCulling = i; break; } } $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { var index = tickValues.indexOf(e); if (index >= 0) { d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); } }); } else { $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').style('display', 'block'); } } // setup drawer - MEMO: these must be called after axis updated drawArea = $$.generateDrawArea ? $$.generateDrawArea(areaIndices, false) : undefined; drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; drawLine = $$.generateDrawLine ? $$.generateDrawLine(lineIndices, false) : undefined; xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); // Update sub domain if (withY) { $$.subY.domain($$.getYDomain(targetsToShow, 'y')); $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); } // xgrid focus $$.updateXgridFocus(); // Data empty label positioning and text. main.select("text." + CLASS.text + '.' + CLASS.empty) .attr("x", $$.width / 2) .attr("y", $$.height / 2) .text(config.data_empty_label_text) .transition() .style('opacity', targetsToShow.length ? 0 : 1); // grid $$.updateGrid(duration); // rect for regions $$.updateRegion(duration); // bars $$.updateBar(durationForExit); // lines, areas and cricles $$.updateLine(durationForExit); $$.updateArea(durationForExit); $$.updateCircle(); // text if ($$.hasDataLabel()) { $$.updateText(durationForExit); } // title if ($$.redrawTitle) { $$.redrawTitle(); } // arc if ($$.redrawArc) { $$.redrawArc(duration, durationForExit, withTransform); } // subchart if ($$.redrawSubchart) { $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); } // circles for select main.selectAll('.' + CLASS.selectedCircles) .filter($$.isBarType.bind($$)) .selectAll('circle') .remove(); // event rects will redrawn when flow called if (config.interaction_enabled && !options.flow && withEventRect) { $$.redrawEventRect(); if ($$.updateZoom) { $$.updateZoom(); } } // update circleY based on updated parameters $$.updateCircleY(); // generate circle x/y functions depending on updated params cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); if (options.flow) { flow = $$.generateFlow({ targets: targetsToShow, flow: options.flow, duration: options.flow.duration, drawBar: drawBar, drawLine: drawLine, drawArea: drawArea, cx: cx, cy: cy, xv: xv, xForText: xForText, yForText: yForText }); } if ((duration || flow) && $$.isTabVisible()) { // Only use transition if tab visible. See #938. // transition should be derived from one transition d3.transition().duration(duration).each(function () { var transitionsToWait = []; // redraw and gather transitions [ $$.redrawBar(drawBar, true), $$.redrawLine(drawLine, true), $$.redrawArea(drawArea, true), $$.redrawCircle(cx, cy, true), $$.redrawText(xForText, yForText, options.flow, true), $$.redrawRegion(true), $$.redrawGrid(true), ].forEach(function (transitions) { transitions.forEach(function (transition) { transitionsToWait.push(transition); }); }); // Wait for end of transitions to call flow and onrendered callback waitForDraw = $$.generateWait(); transitionsToWait.forEach(function (t) { waitForDraw.add(t); }); }) .call(waitForDraw, function () { if (flow) { flow(); } if (config.onrendered) { config.onrendered.call($$); } }); } else { $$.redrawBar(drawBar); $$.redrawLine(drawLine); $$.redrawArea(drawArea); $$.redrawCircle(cx, cy); $$.redrawText(xForText, yForText, options.flow); $$.redrawRegion(); $$.redrawGrid(); if (config.onrendered) { config.onrendered.call($$); } } // update fadein condition $$.mapToIds($$.data.targets).forEach(function (id) { $$.withoutFadeIn[id] = true; }); }; c3_chart_internal_fn.updateAndRedraw = function (options) { var $$ = this, config = $$.config, transitions; options = options || {}; // same with redraw options.withTransition = getOption(options, "withTransition", true); options.withTransform = getOption(options, "withTransform", false); options.withLegend = getOption(options, "withLegend", false); // NOT same with redraw options.withUpdateXDomain = true; options.withUpdateOrgXDomain = true; options.withTransitionForExit = false; options.withTransitionForTransform = getOption(options, "withTransitionForTransform", options.withTransition); // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) $$.updateSizes(); // MEMO: called in updateLegend in redraw if withLegend if (!(options.withLegend && config.legend_show)) { transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0); // Update scales $$.updateScales(); $$.updateSvgSize(); // Update g positions $$.transformAll(options.withTransitionForTransform, transitions); } // Draw with new sizes & scales $$.redraw(options, transitions); }; c3_chart_internal_fn.redrawWithoutRescale = function () { this.redraw({ withY: false, withSubchart: false, withEventRect: false, withTransitionForAxis: false }); }; c3_chart_internal_fn.isTimeSeries = function () { return this.config.axis_x_type === 'timeseries'; }; c3_chart_internal_fn.isCategorized = function () { return this.config.axis_x_type.indexOf('categor') >= 0; }; c3_chart_internal_fn.isCustomX = function () { var $$ = this, config = $$.config; return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); }; c3_chart_internal_fn.isTimeSeriesY = function () { return this.config.axis_y_type === 'timeseries'; }; c3_chart_internal_fn.getTranslate = function (target) { var $$ = this, config = $$.config, x, y; if (target === 'main') { x = asHalfPixel($$.margin.left); y = asHalfPixel($$.margin.top); } else if (target === 'context') { x = asHalfPixel($$.margin2.left); y = asHalfPixel($$.margin2.top); } else if (target === 'legend') { x = $$.margin3.left; y = $$.margin3.top; } else if (target === 'x') { x = 0; y = config.axis_rotated ? 0 : $$.height; } else if (target === 'y') { x = 0; y = config.axis_rotated ? $$.height : 0; } else if (target === 'y2') { x = config.axis_rotated ? 0 : $$.width; y = config.axis_rotated ? 1 : 0; } else if (target === 'subx') { x = 0; y = config.axis_rotated ? 0 : $$.height2; } else if (target === 'arc') { x = $$.arcWidth / 2; y = $$.arcHeight / 2; } return "translate(" + x + "," + y + ")"; }; c3_chart_internal_fn.initialOpacity = function (d) { return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0; }; c3_chart_internal_fn.initialOpacityForCircle = function (d) { return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0; }; c3_chart_internal_fn.opacityForCircle = function (d) { var opacity = this.config.point_show ? 1 : 0; return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0; }; c3_chart_internal_fn.opacityForText = function () { return this.hasDataLabel() ? 1 : 0; }; c3_chart_internal_fn.xx = function (d) { return d ? this.x(d.x) : null; }; c3_chart_internal_fn.xv = function (d) { var $$ = this, value = d.value; if ($$.isTimeSeries()) { value = $$.parseDate(d.value); } else if ($$.isCategorized() && typeof d.value === 'string') { value = $$.config.axis_x_categories.indexOf(d.value); } return Math.ceil($$.x(value)); }; c3_chart_internal_fn.yv = function (d) { var $$ = this, yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; return Math.ceil(yScale(d.value)); }; c3_chart_internal_fn.subxx = function (d) { return d ? this.subX(d.x) : null; }; c3_chart_internal_fn.transformMain = function (withTransition, transitions) { var $$ = this, xAxis, yAxis, y2Axis; if (transitions && transitions.axisX) { xAxis = transitions.axisX; } else { xAxis = $$.main.select('.' + CLASS.axisX); if (withTransition) { xAxis = xAxis.transition(); } } if (transitions && transitions.axisY) { yAxis = transitions.axisY; } else { yAxis = $$.main.select('.' + CLASS.axisY); if (withTransition) { yAxis = yAxis.transition(); } } if (transitions && transitions.axisY2) { y2Axis = transitions.axisY2; } else { y2Axis = $$.main.select('.' + CLASS.axisY2); if (withTransition) { y2Axis = y2Axis.transition(); } } (withTransition ? $$.main.transition() : $$.main).attr("transform", $$.getTranslate('main')); xAxis.attr("transform", $$.getTranslate('x')); yAxis.attr("transform", $$.getTranslate('y')); y2Axis.attr("transform", $$.getTranslate('y2')); $$.main.select('.' + CLASS.chartArcs).attr("transform", $$.getTranslate('arc')); }; c3_chart_internal_fn.transformAll = function (withTransition, transitions) { var $$ = this; $$.transformMain(withTransition, transitions); if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } if ($$.legend) { $$.transformLegend(withTransition); } }; c3_chart_internal_fn.updateSvgSize = function () { var $$ = this, brush = $$.svg.select(".c3-brush .background"); $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); $$.svg.selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]).select('rect') .attr('width', $$.width) .attr('height', $$.height); $$.svg.select('#' + $$.clipIdForXAxis).select('rect') .attr('x', $$.getXAxisClipX.bind($$)) .attr('y', $$.getXAxisClipY.bind($$)) .attr('width', $$.getXAxisClipWidth.bind($$)) .attr('height', $$.getXAxisClipHeight.bind($$)); $$.svg.select('#' + $$.clipIdForYAxis).select('rect') .attr('x', $$.getYAxisClipX.bind($$)) .attr('y', $$.getYAxisClipY.bind($$)) .attr('width', $$.getYAxisClipWidth.bind($$)) .attr('height', $$.getYAxisClipHeight.bind($$)); $$.svg.select('#' + $$.clipIdForSubchart).select('rect') .attr('width', $$.width) .attr('height', brush.size() ? brush.attr('height') : 0); $$.svg.select('.' + CLASS.zoomRect) .attr('width', $$.width) .attr('height', $$.height); // MEMO: parent div's height will be bigger than svg when <!DOCTYPE html> $$.selectChart.style('max-height', $$.currentHeight + "px"); }; c3_chart_internal_fn.updateDimension = function (withoutAxis) { var $$ = this; if (!withoutAxis) { if ($$.config.axis_rotated) { $$.axes.x.call($$.xAxis); $$.axes.subx.call($$.subXAxis); } else { $$.axes.y.call($$.yAxis); $$.axes.y2.call($$.y2Axis); } } $$.updateSizes(); $$.updateScales(); $$.updateSvgSize(); $$.transformAll(false); }; c3_chart_internal_fn.observeInserted = function (selection) { var $$ = this, observer; if (typeof MutationObserver === 'undefined') { window.console.error("MutationObserver not defined."); return; } observer= new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'childList' && mutation.previousSibling) { observer.disconnect(); // need to wait for completion of load because size calculation requires the actual sizes determined after that completion $$.intervalForObserveInserted = window.setInterval(function () { // parentNode will NOT be null when completed if (selection.node().parentNode) { window.clearInterval($$.intervalForObserveInserted); $$.updateDimension(); if ($$.brush) { $$.brush.update(); } $$.config.oninit.call($$); $$.redraw({ withTransform: true, withUpdateXDomain: true, withUpdateOrgXDomain: true, withTransition: false, withTransitionForTransform: false, withLegend: true }); selection.transition().style('opacity', 1); } }, 10); } }); }); observer.observe(selection.node(), {attributes: true, childList: true, characterData: true}); }; c3_chart_internal_fn.bindResize = function () { var $$ = this, config = $$.config; $$.resizeFunction = $$.generateResize(); $$.resizeFunction.add(function () { config.onresize.call($$); }); if (config.resize_auto) { $$.resizeFunction.add(function () { if ($$.resizeTimeout !== undefined) { window.clearTimeout($$.resizeTimeout); } $$.resizeTimeout = window.setTimeout(function () { delete $$.resizeTimeout; $$.api.flush(); }, 100); }); } $$.resizeFunction.add(function () { config.onresized.call($$); }); if (window.attachEvent) { window.attachEvent('onresize', $$.resizeFunction); } else if (window.addEventListener) { window.addEventListener('resize', $$.resizeFunction, false); } else { // fallback to this, if this is a very old browser var wrapper = window.onresize; if (!wrapper) { // create a wrapper that will call all charts wrapper = $$.generateResize(); } else if (!wrapper.add || !wrapper.remove) { // there is already a handler registered, make sure we call it too wrapper = $$.generateResize(); wrapper.add(window.onresize); } // add this graph to the wrapper, we will be removed if the user calls destroy wrapper.add($$.resizeFunction); window.onresize = wrapper; } }; c3_chart_internal_fn.generateResize = function () { var resizeFunctions = []; function callResizeFunctions() { resizeFunctions.forEach(function (f) { f(); }); } callResizeFunctions.add = function (f) { resizeFunctions.push(f); }; callResizeFunctions.remove = function (f) { for (var i = 0; i < resizeFunctions.length; i++) { if (resizeFunctions[i] === f) { resizeFunctions.splice(i, 1); break; } } }; return callResizeFunctions; }; c3_chart_internal_fn.endall = function (transition, callback) { var n = 0; transition .each(function () { ++n; }) .each("end", function () { if (!--n) { callback.apply(this, arguments); } }); }; c3_chart_internal_fn.generateWait = function () { var transitionsToWait = [], f = function (transition, callback) { var timer = setInterval(function () { var done = 0; transitionsToWait.forEach(function (t) { if (t.empty()) { done += 1; return; } try { t.transition(); } catch (e) { done += 1; } }); if (done === transitionsToWait.length) { clearInterval(timer); if (callback) { callback(); } } }, 10); }; f.add = function (transition) { transitionsToWait.push(transition); }; return f; }; c3_chart_internal_fn.parseDate = function (date) { var $$ = this, parsedDate; if (date instanceof Date) { parsedDate = date; } else if (typeof date === 'string') { parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date); } else if (typeof date === 'number' && !isNaN(date)) { parsedDate = new Date(+date); } if (!parsedDate || isNaN(+parsedDate)) { window.console.error("Failed to parse x '" + date + "' to Date object"); } return parsedDate; }; c3_chart_internal_fn.isTabVisible = function () { var hidden; if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support hidden = "hidden"; } else if (typeof document.mozHidden !== "undefined") { hidden = "mozHidden"; } else if (typeof document.msHidden !== "undefined") { hidden = "msHidden"; } else if (typeof document.webkitHidden !== "undefined") { hidden = "webkitHidden"; } return document[hidden] ? false : true; }; c3_chart_internal_fn.getDefaultConfig = function () { var config = { bindto: '#chart', svg_classname: undefined, size_width: undefined, size_height: undefined, padding_left: undefined, padding_right: undefined, padding_top: undefined, padding_bottom: undefined, resize_auto: true, zoom_enabled: false, zoom_extent: undefined, zoom_privileged: false, zoom_rescale: false, zoom_onzoom: function () {}, zoom_onzoomstart: function () {}, zoom_onzoomend: function () {}, zoom_x_min: undefined, zoom_x_max: undefined, interaction_brighten: true, interaction_enabled: true, onmouseover: function () {}, onmouseout: function () {}, onresize: function () {}, onresized: function () {}, oninit: function () {}, onrendered: function () {}, transition_duration: 350, data_x: undefined, data_xs: {}, data_xFormat: '%Y-%m-%d', data_xLocaltime: true, data_xSort: true, data_idConverter: function (id) { return id; }, data_names: {}, data_classes: {}, data_groups: [], data_axes: {}, data_type: undefined, data_types: {}, data_labels: {}, data_order: 'desc', data_regions: {}, data_color: undefined, data_colors: {}, data_hide: false, data_filter: undefined, data_selection_enabled: false, data_selection_grouped: false, data_selection_isselectable: function () { return true; }, data_selection_multiple: true, data_selection_draggable: false, data_onclick: function () {}, data_onmouseover: function () {}, data_onmouseout: function () {}, data_onselected: function () {}, data_onunselected: function () {}, data_url: undefined, data_headers: undefined, data_json: undefined, data_rows: undefined, data_columns: undefined, data_mimeType: undefined, data_keys: undefined, // configuration for no plot-able data supplied. data_empty_label_text: "", // subchart subchart_show: false, subchart_size_height: 60, subchart_axis_x_show: true, subchart_onbrush: function () {}, // color color_pattern: [], color_threshold: {}, // legend legend_show: true, legend_hide: false, legend_position: 'bottom', legend_inset_anchor: 'top-left', legend_inset_x: 10, legend_inset_y: 0, legend_inset_step: undefined, legend_item_onclick: undefined, legend_item_onmouseover: undefined, legend_item_onmouseout: undefined, legend_equally: false, legend_padding: 0, legend_item_tile_width: 10, legend_item_tile_height: 10, // axis axis_rotated: false, axis_x_show: true, axis_x_type: 'indexed', axis_x_localtime: true, axis_x_categories: [], axis_x_tick_centered: false, axis_x_tick_format: undefined, axis_x_tick_culling: {}, axis_x_tick_culling_max: 10, axis_x_tick_count: undefined, axis_x_tick_fit: true, axis_x_tick_values: null, axis_x_tick_rotate: 0, axis_x_tick_outer: true, axis_x_tick_multiline: true, axis_x_tick_width: null, axis_x_max: undefined, axis_x_min: undefined, axis_x_padding: {}, axis_x_height: undefined, axis_x_extent: undefined, axis_x_label: {}, axis_y_show: true, axis_y_type: undefined, axis_y_max: undefined, axis_y_min: undefined, axis_y_inverted: false, axis_y_center: undefined, axis_y_inner: undefined, axis_y_label: {}, axis_y_tick_format: undefined, axis_y_tick_outer: true, axis_y_tick_values: null, axis_y_tick_rotate: 0, axis_y_tick_count: undefined, axis_y_tick_time_value: undefined, axis_y_tick_time_interval: undefined, axis_y_padding: {}, axis_y_default: undefined, axis_y2_show: false, axis_y2_max: undefined, axis_y2_min: undefined, axis_y2_inverted: false, axis_y2_center: undefined, axis_y2_inner: undefined, axis_y2_label: {}, axis_y2_tick_format: undefined, axis_y2_tick_outer: true, axis_y2_tick_values: null, axis_y2_tick_count: undefined, axis_y2_padding: {}, axis_y2_default: undefined, // grid grid_x_show: false, grid_x_type: 'tick', grid_x_lines: [], grid_y_show: false, // not used // grid_y_type: 'tick', grid_y_lines: [], grid_y_ticks: 10, grid_focus_show: true, grid_lines_front: true, // point - point of each data point_show: true, point_r: 2.5, point_sensitivity: 10, point_focus_expand_enabled: true, point_focus_expand_r: undefined, point_select_r: undefined, // line line_connectNull: false, line_step_type: 'step', // bar bar_width: undefined, bar_width_ratio: 0.6, bar_width_max: undefined, bar_zerobased: true, // area area_zerobased: true, area_above: false, // pie pie_label_show: true, pie_label_format: undefined, pie_label_threshold: 0.05, pie_label_ratio: undefined, pie_expand: {}, pie_expand_duration: 50, // gauge gauge_fullCircle: false, gauge_label_show: true, gauge_label_format: undefined, gauge_min: 0, gauge_max: 100, gauge_startingAngle: -1 * Math.PI/2, gauge_units: undefined, gauge_width: undefined, gauge_expand: {}, gauge_expand_duration: 50, // donut donut_label_show: true, donut_label_format: undefined, donut_label_threshold: 0.05, donut_label_ratio: undefined, donut_width: undefined, donut_title: "", donut_expand: {}, donut_expand_duration: 50, // spline spline_interpolation_type: 'cardinal', // region - region to change style regions: [], // tooltip - show when mouseover on each data tooltip_show: true, tooltip_grouped: true, tooltip_format_title: undefined, tooltip_format_name: undefined, tooltip_format_value: undefined, tooltip_position: undefined, tooltip_contents: function (d, defaultTitleFormat, defaultValueFormat, color) { return this.getTooltipContent ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) : ''; }, tooltip_init_show: false, tooltip_init_x: 0, tooltip_init_position: {top: '0px', left: '50px'}, tooltip_onshow: function () {}, tooltip_onhide: function () {}, // title title_text: undefined, title_padding: { top: 0, right: 0, bottom: 0, left: 0 }, title_position: 'top-center', }; Object.keys(this.additionalConfig).forEach(function (key) { config[key] = this.additionalConfig[key]; }, this); return config; }; c3_chart_internal_fn.additionalConfig = {}; c3_chart_internal_fn.loadConfig = function (config) { var this_config = this.config, target, keys, read; function find() { var key = keys.shift(); // console.log("key =>", key, ", target =>", target); if (key && target && typeof target === 'object' && key in target) { target = target[key]; return find(); } else if (!key) { return target; } else { return undefined; } } Object.keys(this_config).forEach(function (key) { target = config; keys = key.split('_'); read = find(); // console.log("CONFIG : ", key, read); if (isDefined(read)) { this_config[key] = read; } }); }; c3_chart_internal_fn.getScale = function (min, max, forTimeseries) { return (forTimeseries ? this.d3.time.scale() : this.d3.scale.linear()).range([min, max]); }; c3_chart_internal_fn.getX = function (min, max, domain, offset) { var $$ = this, scale = $$.getScale(min, max, $$.isTimeSeries()), _scale = domain ? scale.domain(domain) : scale, key; // Define customized scale if categorized axis if ($$.isCategorized()) { offset = offset || function () { return 0; }; scale = function (d, raw) { var v = _scale(d) + offset(d); return raw ? v : Math.ceil(v); }; } else { scale = function (d, raw) { var v = _scale(d); return raw ? v : Math.ceil(v); }; } // define functions for (key in _scale) { scale[key] = _scale[key]; } scale.orgDomain = function () { return _scale.domain(); }; // define custom domain() for categorized axis if ($$.isCategorized()) { scale.domain = function (domain) { if (!arguments.length) { domain = this.orgDomain(); return [domain[0], domain[1] + 1]; } _scale.domain(domain); return scale; }; } return scale; }; c3_chart_internal_fn.getY = function (min, max, domain) { var scale = this.getScale(min, max, this.isTimeSeriesY()); if (domain) { scale.domain(domain); } return scale; }; c3_chart_internal_fn.getYScale = function (id) { return this.axis.getId(id) === 'y2' ? this.y2 : this.y; }; c3_chart_internal_fn.getSubYScale = function (id) { return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY; }; c3_chart_internal_fn.updateScales = function () { var $$ = this, config = $$.config, forInit = !$$.x; // update edges $$.xMin = config.axis_rotated ? 1 : 0; $$.xMax = config.axis_rotated ? $$.height : $$.width; $$.yMin = config.axis_rotated ? 0 : $$.height; $$.yMax = config.axis_rotated ? $$.width : 1; $$.subXMin = $$.xMin; $$.subXMax = $$.xMax; $$.subYMin = config.axis_rotated ? 0 : $$.height2; $$.subYMax = config.axis_rotated ? $$.width2 : 1; // update scales $$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { return $$.xAxis.tickOffset(); }); $$.y = $$.getY($$.yMin, $$.yMax, forInit ? config.axis_y_default : $$.y.domain()); $$.y2 = $$.getY($$.yMin, $$.yMax, forInit ? config.axis_y2_default : $$.y2.domain()); $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function (d) { return d % 1 ? 0 : $$.subXAxis.tickOffset(); }); $$.subY = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y_default : $$.subY.domain()); $$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y2_default : $$.subY2.domain()); // update axes $$.xAxisTickFormat = $$.axis.getXAxisTickFormat(); $$.xAxisTickValues = $$.axis.getXAxisTickValues(); $$.yAxisTickValues = $$.axis.getYAxisTickValues(); $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); $$.xAxis = $$.axis.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); $$.subXAxis = $$.axis.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); $$.yAxis = $$.axis.getYAxis($$.y, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, config.axis_y_tick_outer); $$.y2Axis = $$.axis.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, config.axis_y2_tick_outer); // Set initialized scales to brush and zoom if (!forInit) { if ($$.brush) { $$.brush.scale($$.subX); } if (config.zoom_enabled) { $$.zoom.scale($$.x); } } // update for arc if ($$.updateArc) { $$.updateArc(); } }; c3_chart_internal_fn.getYDomainMin = function (targets) { var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasNegativeValue; if (config.data_groups.length > 0) { hasNegativeValue = $$.hasNegativeValueInTargets(targets); for (j = 0; j < config.data_groups.length; j++) { // Determine baseId idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider negative values if (hasNegativeValue && ys[baseId]) { ys[baseId].forEach(function (v, i) { ys[baseId][i] = v < 0 ? v : 0; }); } // Compute min for (k = 1; k < idsInGroup.length; k++) { id = idsInGroup[k]; if (! ys[id]) { continue; } ys[id].forEach(function (v, i) { if ($$.axis.getId(id) === $$.axis.getId(baseId) && ys[baseId] && !(hasNegativeValue && +v > 0)) { ys[baseId][i] += +v; } }); } } } return $$.d3.min(Object.keys(ys).map(function (key) { return $$.d3.min(ys[key]); })); }; c3_chart_internal_fn.getYDomainMax = function (targets) { var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasPositiveValue; if (config.data_groups.length > 0) { hasPositiveValue = $$.hasPositiveValueInTargets(targets); for (j = 0; j < config.data_groups.length; j++) { // Determine baseId idsInGroup = config.data_groups[j].filter(function (id) { return ids.indexOf(id) >= 0; }); if (idsInGroup.length === 0) { continue; } baseId = idsInGroup[0]; // Consider positive values if (hasPositiveValue && ys[baseId]) { ys[baseId].forEach(function (v, i) { ys[baseId][i] = v > 0 ? v : 0; }); } // Compute max for (k = 1; k < idsInGroup.length; k++) { id = idsInGroup[k]; if (! ys[id]) { continue; } ys[id].forEach(function (v, i) { if ($$.axis.getId(id) === $$.axis.getId(baseId) && ys[baseId] && !(hasPositiveValue && +v < 0)) { ys[baseId][i] += +v; } }); } } } return $$.d3.max(Object.keys(ys).map(function (key) { return $$.d3.max(ys[key]); })); }; c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) { var $$ = this, config = $$.config, targetsByAxisId = targets.filter(function (t) { return $$.axis.getId(t.id) === axisId; }), yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId, yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, yDomainMin = $$.getYDomainMin(yTargets), yDomainMax = $$.getYDomainMax(yTargets), domain, domainLength, padding, padding_top, padding_bottom, center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || ($$.hasType('area', yTargets) && config.area_zerobased), isInverted = axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; // MEMO: avoid inverting domain unexpectedly yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? (yDomainMin < yMax ? yDomainMin : yMax - 10) : yDomainMin; yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? (yMin < yDomainMax ? yDomainMax : yMin + 10) : yDomainMax; if (yTargets.length === 0) { // use current domain if target of axisId is none return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); } if (isNaN(yDomainMin)) { // set minimum to zero when not number yDomainMin = 0; } if (isNaN(yDomainMax)) { // set maximum to have same value as yDomainMin yDomainMax = yDomainMin; } if (yDomainMin === yDomainMax) { yDomainMin < 0 ? yDomainMax = 0 : yDomainMin = 0; } isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; // Cancel zerobased if axis_*_min / axis_*_max specified if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { isZeroBased = false; } // Bar/Area chart should be 0-based if all positive|negative if (isZeroBased) { if (isAllPositive) { yDomainMin = 0; } if (isAllNegative) { yDomainMax = 0; } } domainLength = Math.abs(yDomainMax - yDomainMin); padding = padding_top = padding_bottom = domainLength * 0.1; if (typeof center !== 'undefined') { yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); yDomainMax = center + yDomainAbs; yDomainMin = center - yDomainAbs; } // add padding for data label if (showHorizontalDataLabel) { lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'width'); diff = diffDomain($$.y.range()); ratio = [lengths[0] / diff, lengths[1] / diff]; padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); } else if (showVerticalDataLabel) { lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'height'); padding_top += $$.axis.convertPixelsToAxisPadding(lengths[1], domainLength); padding_bottom += $$.axis.convertPixelsToAxisPadding(lengths[0], domainLength); } if (axisId === 'y' && notEmpty(config.axis_y_padding)) { padding_top = $$.axis.getPadding(config.axis_y_padding, 'top', padding_top, domainLength); padding_bottom = $$.axis.getPadding(config.axis_y_padding, 'bottom', padding_bottom, domainLength); } if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) { padding_top = $$.axis.getPadding(config.axis_y2_padding, 'top', padding_top, domainLength); padding_bottom = $$.axis.getPadding(config.axis_y2_padding, 'bottom', padding_bottom, domainLength); } // Bar/Area chart should be 0-based if all positive|negative if (isZeroBased) { if (isAllPositive) { padding_bottom = yDomainMin; } if (isAllNegative) { padding_top = -yDomainMax; } } domain = [yDomainMin - padding_bottom, yDomainMax + padding_top]; return isInverted ? domain.reverse() : domain; }; c3_chart_internal_fn.getXDomainMin = function (targets) { var $$ = this, config = $$.config; return isDefined(config.axis_x_min) ? ($$.isTimeSeries() ? this.parseDate(config.axis_x_min) : config.axis_x_min) : $$.d3.min(targets, function (t) { return $$.d3.min(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainMax = function (targets) { var $$ = this, config = $$.config; return isDefined(config.axis_x_max) ? ($$.isTimeSeries() ? this.parseDate(config.axis_x_max) : config.axis_x_max) : $$.d3.max(targets, function (t) { return $$.d3.max(t.values, function (v) { return v.x; }); }); }; c3_chart_internal_fn.getXDomainPadding = function (domain) { var $$ = this, config = $$.config, diff = domain[1] - domain[0], maxDataCount, padding, paddingLeft, paddingRight; if ($$.isCategorized()) { padding = 0; } else if ($$.hasType('bar')) { maxDataCount = $$.getMaxDataCount(); padding = maxDataCount > 1 ? (diff / (maxDataCount - 1)) / 2 : 0.5; } else { padding = diff * 0.01; } if (typeof config.axis_x_padding === 'object' && notEmpty(config.axis_x_padding)) { paddingLeft = isValue(config.axis_x_padding.left) ? config.axis_x_padding.left : padding; paddingRight = isValue(config.axis_x_padding.right) ? config.axis_x_padding.right : padding; } else if (typeof config.axis_x_padding === 'number') { paddingLeft = paddingRight = config.axis_x_padding; } else { paddingLeft = paddingRight = padding; } return {left: paddingLeft, right: paddingRight}; }; c3_chart_internal_fn.getXDomain = function (targets) { var $$ = this, xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)], firstX = xDomain[0], lastX = xDomain[1], padding = $$.getXDomainPadding(xDomain), min = 0, max = 0; // show center of x domain if min and max are the same if ((firstX - lastX) === 0 && !$$.isCategorized()) { if ($$.isTimeSeries()) { firstX = new Date(firstX.getTime() * 0.5); lastX = new Date(lastX.getTime() * 1.5); } else { firstX = firstX === 0 ? 1 : (firstX * 0.5); lastX = lastX === 0 ? -1 : (lastX * 1.5); } } if (firstX || firstX === 0) { min = $$.isTimeSeries() ? new Date(firstX.getTime() - padding.left) : firstX - padding.left; } if (lastX || lastX === 0) { max = $$.isTimeSeries() ? new Date(lastX.getTime() + padding.right) : lastX + padding.right; } return [min, max]; }; c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) { var $$ = this, config = $$.config; if (withUpdateOrgXDomain) { $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); $$.orgXDomain = $$.x.domain(); if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } $$.subX.domain($$.x.domain()); if ($$.brush) { $$.brush.scale($$.subX); } } if (withUpdateXDomain) { $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } } // Trim domain when too big by zoom mousemove event if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); } return $$.x.domain(); }; c3_chart_internal_fn.trimXDomain = function (domain) { var zoomDomain = this.getZoomDomain(), min = zoomDomain[0], max = zoomDomain[1]; if (domain[0] <= min) { domain[1] = +domain[1] + (min - domain[0]); domain[0] = min; } if (max <= domain[1]) { domain[0] = +domain[0] - (domain[1] - max); domain[1] = max; } return domain; }; c3_chart_internal_fn.isX = function (key) { var $$ = this, config = $$.config; return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key)); }; c3_chart_internal_fn.isNotX = function (key) { return !this.isX(key); }; c3_chart_internal_fn.getXKey = function (id) { var $$ = this, config = $$.config; return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null; }; c3_chart_internal_fn.getXValuesOfXKey = function (key, targets) { var $$ = this, xValues, ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : []; ids.forEach(function (id) { if ($$.getXKey(id) === key) { xValues = $$.data.xs[id]; } }); return xValues; }; c3_chart_internal_fn.getIndexByX = function (x) { var $$ = this, data = $$.filterByX($$.data.targets, x); return data.length ? data[0].index : null; }; c3_chart_internal_fn.getXValue = function (id, i) { var $$ = this; return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i; }; c3_chart_internal_fn.getOtherTargetXs = function () { var $$ = this, idsForX = Object.keys($$.data.xs); return idsForX.length ? $$.data.xs[idsForX[0]] : null; }; c3_chart_internal_fn.getOtherTargetX = function (index) { var xs = this.getOtherTargetXs(); return xs && index < xs.length ? xs[index] : null; }; c3_chart_internal_fn.addXs = function (xs) { var $$ = this; Object.keys(xs).forEach(function (id) { $$.config.data_xs[id] = xs[id]; }); }; c3_chart_internal_fn.hasMultipleX = function (xs) { return this.d3.set(Object.keys(xs).map(function (id) { return xs[id]; })).size() > 1; }; c3_chart_internal_fn.isMultipleX = function () { return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType('scatter'); }; c3_chart_internal_fn.addName = function (data) { var $$ = this, name; if (data) { name = $$.config.data_names[data.id]; data.name = name !== undefined ? name : data.id; } return data; }; c3_chart_internal_fn.getValueOnIndex = function (values, index) { var valueOnIndex = values.filter(function (v) { return v.index === index; }); return valueOnIndex.length ? valueOnIndex[0] : null; }; c3_chart_internal_fn.updateTargetX = function (targets, x) { var $$ = this; targets.forEach(function (t) { t.values.forEach(function (v, i) { v.x = $$.generateTargetX(x[i], t.id, i); }); $$.data.xs[t.id] = x; }); }; c3_chart_internal_fn.updateTargetXs = function (targets, xs) { var $$ = this; targets.forEach(function (t) { if (xs[t.id]) { $$.updateTargetX([t], xs[t.id]); } }); }; c3_chart_internal_fn.generateTargetX = function (rawX, id, index) { var $$ = this, x; if ($$.isTimeSeries()) { x = rawX ? $$.parseDate(rawX) : $$.parseDate($$.getXValue(id, index)); } else if ($$.isCustomX() && !$$.isCategorized()) { x = isValue(rawX) ? +rawX : $$.getXValue(id, index); } else { x = index; } return x; }; c3_chart_internal_fn.cloneTarget = function (target) { return { id : target.id, id_org : target.id_org, values : target.values.map(function (d) { return {x: d.x, value: d.value, id: d.id}; }) }; }; c3_chart_internal_fn.updateXs = function () { var $$ = this; if ($$.data.targets.length) { $$.xs = []; $$.data.targets[0].values.forEach(function (v) { $$.xs[v.index] = v.x; }); } }; c3_chart_internal_fn.getPrevX = function (i) { var x = this.xs[i - 1]; return typeof x !== 'undefined' ? x : null; }; c3_chart_internal_fn.getNextX = function (i) { var x = this.xs[i + 1]; return typeof x !== 'undefined' ? x : null; }; c3_chart_internal_fn.getMaxDataCount = function () { var $$ = this; return $$.d3.max($$.data.targets, function (t) { return t.values.length; }); }; c3_chart_internal_fn.getMaxDataCountTarget = function (targets) { var length = targets.length, max = 0, maxTarget; if (length > 1) { targets.forEach(function (t) { if (t.values.length > max) { maxTarget = t; max = t.values.length; } }); } else { maxTarget = length ? targets[0] : null; } return maxTarget; }; c3_chart_internal_fn.getEdgeX = function (targets) { var $$ = this; return !targets.length ? [0, 0] : [ $$.d3.min(targets, function (t) { return t.values[0].x; }), $$.d3.max(targets, function (t) { return t.values[t.values.length - 1].x; }) ]; }; c3_chart_internal_fn.mapToIds = function (targets) { return targets.map(function (d) { return d.id; }); }; c3_chart_internal_fn.mapToTargetIds = function (ids) { var $$ = this; return ids ? [].concat(ids) : $$.mapToIds($$.data.targets); }; c3_chart_internal_fn.hasTarget = function (targets, id) { var ids = this.mapToIds(targets), i; for (i = 0; i < ids.length; i++) { if (ids[i] === id) { return true; } } return false; }; c3_chart_internal_fn.isTargetToShow = function (targetId) { return this.hiddenTargetIds.indexOf(targetId) < 0; }; c3_chart_internal_fn.isLegendToShow = function (targetId) { return this.hiddenLegendIds.indexOf(targetId) < 0; }; c3_chart_internal_fn.filterTargetsToShow = function (targets) { var $$ = this; return targets.filter(function (t) { return $$.isTargetToShow(t.id); }); }; c3_chart_internal_fn.mapTargetsToUniqueXs = function (targets) { var $$ = this; var xs = $$.d3.set($$.d3.merge(targets.map(function (t) { return t.values.map(function (v) { return +v.x; }); }))).values(); xs = $$.isTimeSeries() ? xs.map(function (x) { return new Date(+x); }) : xs.map(function (x) { return +x; }); return xs.sort(function (a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; }); }; c3_chart_internal_fn.addHiddenTargetIds = function (targetIds) { this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds); }; c3_chart_internal_fn.removeHiddenTargetIds = function (targetIds) { this.hiddenTargetIds = this.hiddenTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); }; c3_chart_internal_fn.addHiddenLegendIds = function (targetIds) { this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds); }; c3_chart_internal_fn.removeHiddenLegendIds = function (targetIds) { this.hiddenLegendIds = this.hiddenLegendIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); }; c3_chart_internal_fn.getValuesAsIdKeyed = function (targets) { var ys = {}; targets.forEach(function (t) { ys[t.id] = []; t.values.forEach(function (v) { ys[t.id].push(v.value); }); }); return ys; }; c3_chart_internal_fn.checkValueInTargets = function (targets, checker) { var ids = Object.keys(targets), i, j, values; for (i = 0; i < ids.length; i++) { values = targets[ids[i]].values; for (j = 0; j < values.length; j++) { if (checker(values[j].value)) { return true; } } } return false; }; c3_chart_internal_fn.hasNegativeValueInTargets = function (targets) { return this.checkValueInTargets(targets, function (v) { return v < 0; }); }; c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) { return this.checkValueInTargets(targets, function (v) { return v > 0; }); }; c3_chart_internal_fn.isOrderDesc = function () { var config = this.config; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'desc'; }; c3_chart_internal_fn.isOrderAsc = function () { var config = this.config; return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'asc'; }; c3_chart_internal_fn.orderTargets = function (targets) { var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); if (orderAsc || orderDesc) { targets.sort(function (t1, t2) { var reducer = function (p, c) { return p + Math.abs(c.value); }; var t1Sum = t1.values.reduce(reducer, 0), t2Sum = t2.values.reduce(reducer, 0); return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum; }); } else if (isFunction(config.data_order)) { targets.sort(config.data_order); } // TODO: accept name array for order return targets; }; c3_chart_internal_fn.filterByX = function (targets, x) { return this.d3.merge(targets.map(function (t) { return t.values; })).filter(function (v) { return v.x - x === 0; }); }; c3_chart_internal_fn.filterRemoveNull = function (data) { return data.filter(function (d) { return isValue(d.value); }); }; c3_chart_internal_fn.filterByXDomain = function (targets, xDomain) { return targets.map(function (t) { return { id: t.id, id_org: t.id_org, values: t.values.filter(function (v) { return xDomain[0] <= v.x && v.x <= xDomain[1]; }) }; }); }; c3_chart_internal_fn.hasDataLabel = function () { var config = this.config; if (typeof config.data_labels === 'boolean' && config.data_labels) { return true; } else if (typeof config.data_labels === 'object' && notEmpty(config.data_labels)) { return true; } return false; }; c3_chart_internal_fn.getDataLabelLength = function (min, max, key) { var $$ = this, lengths = [0, 0], paddingCoef = 1.3; $$.selectChart.select('svg').selectAll('.dummy') .data([min, max]) .enter().append('text') .text(function (d) { return $$.dataLabelFormat(d.id)(d); }) .each(function (d, i) { lengths[i] = this.getBoundingClientRect()[key] * paddingCoef; }) .remove(); return lengths; }; c3_chart_internal_fn.isNoneArc = function (d) { return this.hasTarget(this.data.targets, d.id); }, c3_chart_internal_fn.isArc = function (d) { return 'data' in d && this.hasTarget(this.data.targets, d.data.id); }; c3_chart_internal_fn.findSameXOfValues = function (values, index) { var i, targetX = values[index].x, sames = []; for (i = index - 1; i >= 0; i--) { if (targetX !== values[i].x) { break; } sames.push(values[i]); } for (i = index; i < values.length; i++) { if (targetX !== values[i].x) { break; } sames.push(values[i]); } return sames; }; c3_chart_internal_fn.findClosestFromTargets = function (targets, pos) { var $$ = this, candidates; // map to array of closest points of each target candidates = targets.map(function (target) { return $$.findClosest(target.values, pos); }); // decide closest point and return return $$.findClosest(candidates, pos); }; c3_chart_internal_fn.findClosest = function (values, pos) { var $$ = this, minDist = $$.config.point_sensitivity, closest; // find mouseovering bar values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) { var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); if (!closest && $$.isWithinBar(shape)) { closest = v; } }); // find closest point from non-bar values.filter(function (v) { return v && !$$.isBarType(v.id); }).forEach(function (v) { var d = $$.dist(v, pos); if (d < minDist) { minDist = d; closest = v; } }); return closest; }; c3_chart_internal_fn.dist = function (data, pos) { var $$ = this, config = $$.config, xIndex = config.axis_rotated ? 1 : 0, yIndex = config.axis_rotated ? 0 : 1, y = $$.circleY(data, data.index), x = $$.x(data.x); return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2)); }; c3_chart_internal_fn.convertValuesToStep = function (values) { var converted = [].concat(values), i; if (!this.isCategorized()) { return values; } for (i = values.length + 1; 0 < i; i--) { converted[i] = converted[i - 1]; } converted[0] = { x: converted[0].x - 1, value: converted[0].value, id: converted[0].id }; converted[values.length + 1] = { x: converted[values.length].x + 1, value: converted[values.length].value, id: converted[values.length].id }; return converted; }; c3_chart_internal_fn.updateDataAttributes = function (name, attrs) { var $$ = this, config = $$.config, current = config['data_' + name]; if (typeof attrs === 'undefined') { return current; } Object.keys(attrs).forEach(function (id) { current[id] = attrs[id]; }); $$.redraw({withLegend: true}); return current; }; c3_chart_internal_fn.convertUrlToData = function (url, mimeType, headers, keys, done) { var $$ = this, type = mimeType ? mimeType : 'csv'; var req = $$.d3.xhr(url); if (headers) { Object.keys(headers).forEach(function (header) { req.header(header, headers[header]); }); } req.get(function (error, data) { var d; if (!data) { throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); } if (type === 'json') { d = $$.convertJsonToData(JSON.parse(data.response), keys); } else if (type === 'tsv') { d = $$.convertTsvToData(data.response); } else { d = $$.convertCsvToData(data.response); } done.call($$, d); }); }; c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { var rows = parser.parseRows(xsv), d; if (rows.length === 1) { d = [{}]; rows[0].forEach(function (id) { d[0][id] = null; }); } else { d = parser.parse(xsv); } return d; }; c3_chart_internal_fn.convertCsvToData = function (csv) { return this.convertXsvToData(csv, this.d3.csv); }; c3_chart_internal_fn.convertTsvToData = function (tsv) { return this.convertXsvToData(tsv, this.d3.tsv); }; c3_chart_internal_fn.convertJsonToData = function (json, keys) { var $$ = this, new_rows = [], targetKeys, data; if (keys) { // when keys specified, json would be an array that includes objects if (keys.x) { targetKeys = keys.value.concat(keys.x); $$.config.data_x = keys.x; } else { targetKeys = keys.value; } new_rows.push(targetKeys); json.forEach(function (o) { var new_row = []; targetKeys.forEach(function (key) { // convert undefined to null because undefined data will be removed in convertDataToTargets() var v = $$.findValueInJson(o, key); if (isUndefined(v)) { v = null; } new_row.push(v); }); new_rows.push(new_row); }); data = $$.convertRowsToData(new_rows); } else { Object.keys(json).forEach(function (key) { new_rows.push([key].concat(json[key])); }); data = $$.convertColumnsToData(new_rows); } return data; }; c3_chart_internal_fn.findValueInJson = function (object, path) { path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties (replace [] with .) path = path.replace(/^\./, ''); // strip a leading dot var pathArray = path.split('.'); for (var i = 0; i < pathArray.length; ++i) { var k = pathArray[i]; if (k in object) { object = object[k]; } else { return; } } return object; }; c3_chart_internal_fn.convertRowsToData = function (rows) { var keys = rows[0], new_row = {}, new_rows = [], i, j; for (i = 1; i < rows.length; i++) { new_row = {}; for (j = 0; j < rows[i].length; j++) { if (isUndefined(rows[i][j])) { throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); } new_row[keys[j]] = rows[i][j]; } new_rows.push(new_row); } return new_rows; }; c3_chart_internal_fn.convertColumnsToData = function (columns) { var new_rows = [], i, j, key; for (i = 0; i < columns.length; i++) { key = columns[i][0]; for (j = 1; j < columns[i].length; j++) { if (isUndefined(new_rows[j - 1])) { new_rows[j - 1] = {}; } if (isUndefined(columns[i][j])) { throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); } new_rows[j - 1][key] = columns[i][j]; } } return new_rows; }; c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { var $$ = this, config = $$.config, ids = $$.d3.keys(data[0]).filter($$.isNotX, $$), xs = $$.d3.keys(data[0]).filter($$.isX, $$), targets; // save x for update data by load when custom x and c3.x API ids.forEach(function (id) { var xKey = $$.getXKey(id); if ($$.isCustomX() || $$.isTimeSeries()) { // if included in input data if (xs.indexOf(xKey) >= 0) { $$.data.xs[id] = (appendXs && $$.data.xs[id] ? $$.data.xs[id] : []).concat( data.map(function (d) { return d[xKey]; }) .filter(isValue) .map(function (rawX, i) { return $$.generateTargetX(rawX, id, i); }) ); } // if not included in input data, find from preloaded data of other id's x else if (config.data_x) { $$.data.xs[id] = $$.getOtherTargetXs(); } // if not included in input data, find from preloaded data else if (notEmpty(config.data_xs)) { $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); } // MEMO: if no x included, use same x of current will be used } else { $$.data.xs[id] = data.map(function (d, i) { return i; }); } }); // check x is defined ids.forEach(function (id) { if (!$$.data.xs[id]) { throw new Error('x is not defined for id = "' + id + '".'); } }); // convert to target targets = ids.map(function (id, index) { var convertedId = config.data_idConverter(id); return { id: convertedId, id_org: id, values: data.map(function (d, i) { var xKey = $$.getXKey(id), rawX = d[xKey], value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, x; // use x as categories if custom x and categorized if ($$.isCustomX() && $$.isCategorized() && index === 0 && !isUndefined(rawX)) { if (index === 0 && i === 0) { config.axis_x_categories = []; } x = config.axis_x_categories.indexOf(rawX); if (x === -1) { x = config.axis_x_categories.length; config.axis_x_categories.push(rawX); } } else { x = $$.generateTargetX(rawX, id, i); } // mark as x = undefined if value is undefined and filter to remove after mapped if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { x = undefined; } return {x: x, value: value, id: convertedId}; }).filter(function (v) { return isDefined(v.x); }) }; }); // finish targets targets.forEach(function (t) { var i; // sort values by its x if (config.data_xSort) { t.values = t.values.sort(function (v1, v2) { var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, x2 = v2.x || v2.x === 0 ? v2.x : Infinity; return x1 - x2; }); } // indexing each value i = 0; t.values.forEach(function (v) { v.index = i++; }); // this needs to be sorted because its index and value.index is identical $$.data.xs[t.id].sort(function (v1, v2) { return v1 - v2; }); }); // cache information about values $$.hasNegativeValue = $$.hasNegativeValueInTargets(targets); $$.hasPositiveValue = $$.hasPositiveValueInTargets(targets); // set target types if (config.data_type) { $$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type); } // cache as original id keyed targets.forEach(function (d) { $$.addCache(d.id_org, d); }); return targets; }; c3_chart_internal_fn.load = function (targets, args) { var $$ = this; if (targets) { // filter loading targets if needed if (args.filter) { targets = targets.filter(args.filter); } // set type if args.types || args.type specified if (args.type || args.types) { targets.forEach(function (t) { var type = args.types && args.types[t.id] ? args.types[t.id] : args.type; $$.setTargetType(t.id, type); }); } // Update/Add data $$.data.targets.forEach(function (d) { for (var i = 0; i < targets.length; i++) { if (d.id === targets[i].id) { d.values = targets[i].values; targets.splice(i, 1); break; } } }); $$.data.targets = $$.data.targets.concat(targets); // add remained } // Set targets $$.updateTargets($$.data.targets); // Redraw with new targets $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); if (args.done) { args.done(); } }; c3_chart_internal_fn.loadFromArgs = function (args) { var $$ = this; if (args.data) { $$.load($$.convertDataToTargets(args.data), args); } else if (args.url) { $$.convertUrlToData(args.url, args.mimeType, args.headers, args.keys, function (data) { $$.load($$.convertDataToTargets(data), args); }); } else if (args.json) { $$.load($$.convertDataToTargets($$.convertJsonToData(args.json, args.keys)), args); } else if (args.rows) { $$.load($$.convertDataToTargets($$.convertRowsToData(args.rows)), args); } else if (args.columns) { $$.load($$.convertDataToTargets($$.convertColumnsToData(args.columns)), args); } else { $$.load(null, args); } }; c3_chart_internal_fn.unload = function (targetIds, done) { var $$ = this; if (!done) { done = function () {}; } // filter existing target targetIds = targetIds.filter(function (id) { return $$.hasTarget($$.data.targets, id); }); // If no target, call done and return if (!targetIds || targetIds.length === 0) { done(); return; } $$.svg.selectAll(targetIds.map(function (id) { return $$.selectorTarget(id); })) .transition() .style('opacity', 0) .remove() .call($$.endall, done); targetIds.forEach(function (id) { // Reset fadein for future load $$.withoutFadeIn[id] = false; // Remove target's elements if ($$.legend) { $$.legend.selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)).remove(); } // Remove target $$.data.targets = $$.data.targets.filter(function (t) { return t.id !== id; }); }); }; c3_chart_internal_fn.categoryName = function (i) { var config = this.config; return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; }; c3_chart_internal_fn.initEventRect = function () { var $$ = this; $$.main.select('.' + CLASS.chart).append("g") .attr("class", CLASS.eventRects) .style('fill-opacity', 0); }; c3_chart_internal_fn.redrawEventRect = function () { var $$ = this, config = $$.config, eventRectUpdate, maxDataCountTarget, isMultipleX = $$.isMultipleX(); // rects for mouseover var eventRects = $$.main.select('.' + CLASS.eventRects) .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) .classed(CLASS.eventRectsMultiple, isMultipleX) .classed(CLASS.eventRectsSingle, !isMultipleX); // clear old rects eventRects.selectAll('.' + CLASS.eventRect).remove(); // open as public variable $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); if (isMultipleX) { eventRectUpdate = $$.eventRect.data([0]); // enter : only one rect will be added $$.generateEventRectsForMultipleXs(eventRectUpdate.enter()); // update $$.updateEventRect(eventRectUpdate); // exit : not needed because always only one rect exists } else { // Set data and update $$.eventRect maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); eventRectUpdate = $$.eventRect.data(function (d) { return d; }); // enter $$.generateEventRectsForSingleX(eventRectUpdate.enter()); // update $$.updateEventRect(eventRectUpdate); // exit eventRectUpdate.exit().remove(); } }; c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { var $$ = this, config = $$.config, x, y, w, h, rectW, rectX; // set update selection if null eventRectUpdate = eventRectUpdate || $$.eventRect.data(function (d) { return d; }); if ($$.isMultipleX()) { // TODO: rotated not supported yet x = 0; y = 0; w = $$.width; h = $$.height; } else { if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) { // update index for x that is used by prevX and nextX $$.updateXs(); rectW = function (d) { var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index); // if there this is a single data point make the eventRect full width (or height) if (prevX === null && nextX === null) { return config.axis_rotated ? $$.height : $$.width; } if (prevX === null) { prevX = $$.x.domain()[0]; } if (nextX === null) { nextX = $$.x.domain()[1]; } return Math.max(0, ($$.x(nextX) - $$.x(prevX)) / 2); }; rectX = function (d) { var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), thisX = $$.data.xs[d.id][d.index]; // if there this is a single data point position the eventRect at 0 if (prevX === null && nextX === null) { return 0; } if (prevX === null) { prevX = $$.x.domain()[0]; } return ($$.x(thisX) + $$.x(prevX)) / 2; }; } else { rectW = $$.getEventRectWidth(); rectX = function (d) { return $$.x(d.x) - (rectW / 2); }; } x = config.axis_rotated ? 0 : rectX; y = config.axis_rotated ? rectX : 0; w = config.axis_rotated ? $$.width : rectW; h = config.axis_rotated ? rectW : $$.height; } eventRectUpdate .attr('class', $$.classEvent.bind($$)) .attr("x", x) .attr("y", y) .attr("width", w) .attr("height", h); }; c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { var $$ = this, d3 = $$.d3, config = $$.config; eventRectEnter.append("rect") .attr("class", $$.classEvent.bind($$)) .style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null) .on('mouseover', function (d) { var index = d.index; if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing if ($$.hasArcType()) { return; } // Expand shapes for selection if (config.point_focus_expand_enabled) { $$.expandCircles(index, null, true); } $$.expandBars(index, null, true); // Call event handler $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseover.call($$.api, d); }); }) .on('mouseout', function (d) { var index = d.index; if (!$$.config) { return; } // chart is destroyed if ($$.hasArcType()) { return; } $$.hideXGridFocus(); $$.hideTooltip(); // Undo expanded shapes $$.unexpandCircles(); $$.unexpandBars(); // Call event handler $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { config.data_onmouseout.call($$.api, d); }); }) .on('mousemove', function (d) { var selectedData, index = d.index, eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing if ($$.hasArcType()) { return; } if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { index -= 1; } // Show tooltip selectedData = $$.filterTargetsToShow($$.data.targets).map(function (t) { return $$.addName($$.getValueOnIndex(t.values, index)); }); if (config.tooltip_grouped) { $$.showTooltip(selectedData, this); $$.showXGridFocus(selectedData); } if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { return; } $$.main.selectAll('.' + CLASS.shape + '-' + index) .each(function () { d3.select(this).classed(CLASS.EXPANDED, true); if (config.data_selection_enabled) { eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); } if (!config.tooltip_grouped) { $$.hideXGridFocus(); $$.hideTooltip(); if (!config.data_selection_grouped) { $$.unexpandCircles(index); $$.unexpandBars(index); } } }) .filter(function (d) { return $$.isWithinShape(this, d); }) .each(function (d) { if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { eventRect.style('cursor', 'pointer'); } if (!config.tooltip_grouped) { $$.showTooltip([d], this); $$.showXGridFocus([d]); if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id, true); } $$.expandBars(index, d.id, true); } }); }) .on('click', function (d) { var index = d.index; if ($$.hasArcType() || !$$.toggleShape) { return; } if ($$.cancelClick) { $$.cancelClick = false; return; } if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { index -= 1; } $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { if (config.data_selection_grouped || $$.isWithinShape(this, d)) { $$.toggleShape(this, d, index); $$.config.data_onclick.call($$.api, d, this); } }); }) .call( config.data_selection_draggable && $$.drag ? ( d3.behavior.drag().origin(Object) .on('drag', function () { $$.drag(d3.mouse(this)); }) .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) .on('dragend', function () { $$.dragend(); }) ) : function () {} ); }; c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) { var $$ = this, d3 = $$.d3, config = $$.config; function mouseout() { $$.svg.select('.' + CLASS.eventRect).style('cursor', null); $$.hideXGridFocus(); $$.hideTooltip(); $$.unexpandCircles(); $$.unexpandBars(); } eventRectEnter.append('rect') .attr('x', 0) .attr('y', 0) .attr('width', $$.width) .attr('height', $$.height) .attr('class', CLASS.eventRect) .on('mouseout', function () { if (!$$.config) { return; } // chart is destroyed if ($$.hasArcType()) { return; } mouseout(); }) .on('mousemove', function () { var targetsToShow = $$.filterTargetsToShow($$.data.targets); var mouse, closest, sameXData, selectedData; if ($$.dragging) { return; } // do nothing when dragging if ($$.hasArcType(targetsToShow)) { return; } mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); if ($$.mouseover && (!closest || closest.id !== $$.mouseover.id)) { config.data_onmouseout.call($$.api, $$.mouseover); $$.mouseover = undefined; } if (! closest) { mouseout(); return; } if ($$.isScatterType(closest) || !config.tooltip_grouped) { sameXData = [closest]; } else { sameXData = $$.filterByX(targetsToShow, closest.x); } // show tooltip when cursor is close to some point selectedData = sameXData.map(function (d) { return $$.addName(d); }); $$.showTooltip(selectedData, this); // expand points if (config.point_focus_expand_enabled) { $$.expandCircles(closest.index, closest.id, true); } $$.expandBars(closest.index, closest.id, true); // Show xgrid focus line $$.showXGridFocus(selectedData); // Show cursor as pointer if point is close to mouse position if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) { $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); if (!$$.mouseover) { config.data_onmouseover.call($$.api, closest); $$.mouseover = closest; } } }) .on('click', function () { var targetsToShow = $$.filterTargetsToShow($$.data.targets); var mouse, closest; if ($$.hasArcType(targetsToShow)) { return; } mouse = d3.mouse(this); closest = $$.findClosestFromTargets(targetsToShow, mouse); if (! closest) { return; } // select if selection enabled if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < config.point_sensitivity) { $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll('.' + CLASS.shape + '-' + closest.index).each(function () { if (config.data_selection_grouped || $$.isWithinShape(this, closest)) { $$.toggleShape(this, closest, closest.index); $$.config.data_onclick.call($$.api, closest, this); } }); } }) .call( config.data_selection_draggable && $$.drag ? ( d3.behavior.drag().origin(Object) .on('drag', function () { $$.drag(d3.mouse(this)); }) .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) .on('dragend', function () { $$.dragend(); }) ) : function () {} ); }; c3_chart_internal_fn.dispatchEvent = function (type, index, mouse) { var $$ = this, selector = '.' + CLASS.eventRect + (!$$.isMultipleX() ? '-' + index : ''), eventRect = $$.main.select(selector).node(), box = eventRect.getBoundingClientRect(), x = box.left + (mouse ? mouse[0] : 0), y = box.top + (mouse ? mouse[1] : 0), event = document.createEvent("MouseEvents"); event.initMouseEvent(type, true, true, window, 0, x, y, x, y, false, false, false, false, 0, null); eventRect.dispatchEvent(event); }; c3_chart_internal_fn.getCurrentWidth = function () { var $$ = this, config = $$.config; return config.size_width ? config.size_width : $$.getParentWidth(); }; c3_chart_internal_fn.getCurrentHeight = function () { var $$ = this, config = $$.config, h = config.size_height ? config.size_height : $$.getParentHeight(); return h > 0 ? h : 320 / ($$.hasType('gauge') && !config.gauge_fullCircle ? 2 : 1); }; c3_chart_internal_fn.getCurrentPaddingTop = function () { var $$ = this, config = $$.config, padding = isValue(config.padding_top) ? config.padding_top : 0; if ($$.title && $$.title.node()) { padding += $$.getTitlePadding(); } return padding; }; c3_chart_internal_fn.getCurrentPaddingBottom = function () { var config = this.config; return isValue(config.padding_bottom) ? config.padding_bottom : 0; }; c3_chart_internal_fn.getCurrentPaddingLeft = function (withoutRecompute) { var $$ = this, config = $$.config; if (isValue(config.padding_left)) { return config.padding_left; } else if (config.axis_rotated) { return !config.axis_x_show ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40); } else if (!config.axis_y_show || config.axis_y_inner) { // && !config.axis_rotated return $$.axis.getYAxisLabelPosition().isOuter ? 30 : 1; } else { return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute)); } }; c3_chart_internal_fn.getCurrentPaddingRight = function () { var $$ = this, config = $$.config, defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; if (isValue(config.padding_right)) { return config.padding_right + 1; // 1 is needed not to hide tick line } else if (config.axis_rotated) { return defaultPadding + legendWidthOnRight; } else if (!config.axis_y2_show || config.axis_y2_inner) { // && !config.axis_rotated return 2 + legendWidthOnRight + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); } else { return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; } }; c3_chart_internal_fn.getParentRectValue = function (key) { var parent = this.selectChart.node(), v; while (parent && parent.tagName !== 'BODY') { try { v = parent.getBoundingClientRect()[key]; } catch(e) { if (key === 'width') { // In IE in certain cases getBoundingClientRect // will cause an "unspecified error" v = parent.offsetWidth; } } if (v) { break; } parent = parent.parentNode; } return v; }; c3_chart_internal_fn.getParentWidth = function () { return this.getParentRectValue('width'); }; c3_chart_internal_fn.getParentHeight = function () { var h = this.selectChart.style('height'); return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; }; c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) { var $$ = this, config = $$.config, hasLeftAxisRect = config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {right: 0}, chartRect = $$.selectChart.node().getBoundingClientRect(), hasArc = $$.hasArcType(), svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); return svgLeft > 0 ? svgLeft : 0; }; c3_chart_internal_fn.getAxisWidthByAxisId = function (id, withoutRecompute) { var $$ = this, position = $$.axis.getLabelPositionById(id); return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40); }; c3_chart_internal_fn.getHorizontalAxisHeight = function (axisId) { var $$ = this, config = $$.config, h = 30; if (axisId === 'x' && !config.axis_x_show) { return 8; } if (axisId === 'x' && config.axis_x_height) { return config.axis_x_height; } if (axisId === 'y' && !config.axis_y_show) { return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; } if (axisId === 'y2' && !config.axis_y2_show) { return $$.rotated_padding_top; } // Calculate x axis height when tick rotated if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_x_tick_rotate) / 180); } // Calculate y axis height when tick rotated if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { h = 30 + $$.axis.getMaxTickWidth(axisId) * Math.cos(Math.PI * (90 - config.axis_y_tick_rotate) / 180); } return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); }; c3_chart_internal_fn.getEventRectWidth = function () { return Math.max(0, this.xAxis.tickInterval()); }; c3_chart_internal_fn.getShapeIndices = function (typeFilter) { var $$ = this, config = $$.config, indices = {}, i = 0, j, k; $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) { for (j = 0; j < config.data_groups.length; j++) { if (config.data_groups[j].indexOf(d.id) < 0) { continue; } for (k = 0; k < config.data_groups[j].length; k++) { if (config.data_groups[j][k] in indices) { indices[d.id] = indices[config.data_groups[j][k]]; break; } } } if (isUndefined(indices[d.id])) { indices[d.id] = i++; } }); indices.__max__ = i - 1; return indices; }; c3_chart_internal_fn.getShapeX = function (offset, targetsNum, indices, isSub) { var $$ = this, scale = isSub ? $$.subX : $$.x; return function (d) { var index = d.id in indices ? indices[d.id] : 0; return d.x || d.x === 0 ? scale(d.x) - offset * (targetsNum / 2 - index) : 0; }; }; c3_chart_internal_fn.getShapeY = function (isSub) { var $$ = this; return function (d) { var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); return scale(d.value); }; }; c3_chart_internal_fn.getShapeOffset = function (typeFilter, indices, isSub) { var $$ = this, targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))), targetIds = targets.map(function (t) { return t.id; }); return function (d, i) { var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id), y0 = scale(0), offset = y0; targets.forEach(function (t) { var values = $$.isStepType(d) ? $$.convertValuesToStep(t.values) : t.values; if (t.id === d.id || indices[t.id] !== indices[d.id]) { return; } if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { // check if the x values line up if (typeof values[i] === 'undefined' || +values[i].x !== +d.x) { // "+" for timeseries // if not, try to find the value that does line up i = -1; values.forEach(function (v, j) { if (v.x === d.x) { i = j; } }); } if (i in values && values[i].value * d.value >= 0) { offset += scale(values[i].value) - y0; } } }); return offset; }; }; c3_chart_internal_fn.isWithinShape = function (that, d) { var $$ = this, shape = $$.d3.select(that), isWithin; if (!$$.isTargetToShow(d.id)) { isWithin = false; } else if (that.nodeName === 'circle') { isWithin = $$.isStepType(d) ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); } else if (that.nodeName === 'path') { isWithin = shape.classed(CLASS.bar) ? $$.isWithinBar(that) : true; } return isWithin; }; c3_chart_internal_fn.getInterpolate = function (d) { var $$ = this, interpolation = $$.isInterpolationType($$.config.spline_interpolation_type) ? $$.config.spline_interpolation_type : 'cardinal'; return $$.isSplineType(d) ? interpolation : $$.isStepType(d) ? $$.config.line_step_type : "linear"; }; c3_chart_internal_fn.initLine = function () { var $$ = this; $$.main.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartLines); }; c3_chart_internal_fn.updateTargetsForLine = function (targets) { var $$ = this, config = $$.config, mainLineUpdate, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$), classFocus = $$.classFocus.bind($$); mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', function (d) { return classChartLine(d) + classFocus(d); }); mainLineEnter = mainLineUpdate.enter().append('g') .attr('class', classChartLine) .style('opacity', 0) .style("pointer-events", "none"); // Lines for each data mainLineEnter.append('g') .attr("class", classLines); // Areas mainLineEnter.append('g') .attr('class', classAreas); // Circles for each data point on lines mainLineEnter.append('g') .attr("class", function (d) { return $$.generateClass(CLASS.selectedCircles, d.id); }); mainLineEnter.append('g') .attr("class", classCircles) .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); // Update date for selected circles targets.forEach(function (t) { $$.main.selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)).selectAll('.' + CLASS.selectedCircle).each(function (d) { d.value = t.values[d.index].value; }); }); // MEMO: can not keep same color... //mainLineUpdate.exit().remove(); }; c3_chart_internal_fn.updateLine = function (durationForExit) { var $$ = this; $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data($$.lineData.bind($$)); $$.mainLine.enter().append('path') .attr('class', $$.classLine.bind($$)) .style("stroke", $$.color); $$.mainLine .style("opacity", $$.initialOpacity.bind($$)) .style('shape-rendering', function (d) { return $$.isStepType(d) ? 'crispEdges' : ''; }) .attr('transform', null); $$.mainLine.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawLine = function (drawLine, withTransition) { return [ (withTransition ? this.mainLine.transition(Math.random().toString()) : this.mainLine) .attr("d", drawLine) .style("stroke", this.color) .style("opacity", 1) ]; }; c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { var $$ = this, config = $$.config, line = $$.d3.svg.line(), getPoints = $$.generateGetLinePoints(lineIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, yValue = function (d, i) { return config.data_groups.length > 0 ? getPoints(d, i)[0][1] : yScaleGetter.call($$, d.id)(d.value); }; line = config.axis_rotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue); if (!config.line_connectNull) { line = line.defined(function (d) { return d.value != null; }); } return function (d) { var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, x = isSub ? $$.x : $$.subX, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; if ($$.isLineType(d)) { if (config.data_regions[d.id]) { path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); } else { if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } path = line.interpolate($$.getInterpolate(d))(values); } } else { if (values[0]) { x0 = x(values[0].x); y0 = y(values[0].value); } path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; }; c3_chart_internal_fn.generateGetLinePoints = function (lineIndices, isSub) { // partial duplication of generateGetBarPoints var $$ = this, config = $$.config, lineTargetsNum = lineIndices.__max__ + 1, x = $$.getShapeX(0, lineTargetsNum, lineIndices, !!isSub), y = $$.getShapeY(!!isSub), lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; return function (d, i) { var y0 = yScale.call($$, d.id)(0), offset = lineOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the line position return [ [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)], // needed for compatibility [posX, posY - (y0 - offset)], // needed for compatibility [posX, posY - (y0 - offset)] // needed for compatibility ]; }; }; c3_chart_internal_fn.lineWithRegions = function (d, x, y, _regions) { var $$ = this, config = $$.config, prev = -1, i, j, s = "M", sWithRegion, xp, yp, dx, dy, dd, diff, diffx2, xOffset = $$.isCategorized() ? 0.5 : 0, xValue, yValue, regions = []; function isWithinRegions(x, regions) { var i; for (i = 0; i < regions.length; i++) { if (regions[i].start < x && x <= regions[i].end) { return true; } } return false; } // Check start/end of regions if (isDefined(_regions)) { for (i = 0; i < _regions.length; i++) { regions[i] = {}; if (isUndefined(_regions[i].start)) { regions[i].start = d[0].x; } else { regions[i].start = $$.isTimeSeries() ? $$.parseDate(_regions[i].start) : _regions[i].start; } if (isUndefined(_regions[i].end)) { regions[i].end = d[d.length - 1].x; } else { regions[i].end = $$.isTimeSeries() ? $$.parseDate(_regions[i].end) : _regions[i].end; } } } // Set scales xValue = config.axis_rotated ? function (d) { return y(d.value); } : function (d) { return x(d.x); }; yValue = config.axis_rotated ? function (d) { return x(d.x); } : function (d) { return y(d.value); }; // Define svg generator function for region function generateM(points) { return 'M' + points[0][0] + ' ' + points[0][1] + ' ' + points[1][0] + ' ' + points[1][1]; } if ($$.isTimeSeries()) { sWithRegion = function (d0, d1, j, diff) { var x0 = d0.x.getTime(), x_diff = d1.x - d0.x, xv0 = new Date(x0 + x_diff * j), xv1 = new Date(x0 + x_diff * (j + diff)), points; if (config.axis_rotated) { points = [[y(yp(j)), x(xv0)], [y(yp(j + diff)), x(xv1)]]; } else { points = [[x(xv0), y(yp(j))], [x(xv1), y(yp(j + diff))]]; } return generateM(points); }; } else { sWithRegion = function (d0, d1, j, diff) { var points; if (config.axis_rotated) { points = [[y(yp(j), true), x(xp(j))], [y(yp(j + diff), true), x(xp(j + diff))]]; } else { points = [[x(xp(j), true), y(yp(j))], [x(xp(j + diff), true), y(yp(j + diff))]]; } return generateM(points); }; } // Generate for (i = 0; i < d.length; i++) { // Draw as normal if (isUndefined(regions) || ! isWithinRegions(d[i].x, regions)) { s += " " + xValue(d[i]) + " " + yValue(d[i]); } // Draw with region // TODO: Fix for horizotal charts else { xp = $$.getScale(d[i - 1].x + xOffset, d[i].x + xOffset, $$.isTimeSeries()); yp = $$.getScale(d[i - 1].value, d[i].value); dx = x(d[i].x) - x(d[i - 1].x); dy = y(d[i].value) - y(d[i - 1].value); dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); diff = 2 / dd; diffx2 = diff * 2; for (j = diff; j <= 1; j += diffx2) { s += sWithRegion(d[i - 1], d[i], j, diff); } } prev = d[i].x; } return s; }; c3_chart_internal_fn.updateArea = function (durationForExit) { var $$ = this, d3 = $$.d3; $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data($$.lineData.bind($$)); $$.mainArea.enter().append('path') .attr("class", $$.classArea.bind($$)) .style("fill", $$.color) .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); $$.mainArea .style("opacity", $$.orgAreaOpacity); $$.mainArea.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawArea = function (drawArea, withTransition) { return [ (withTransition ? this.mainArea.transition(Math.random().toString()) : this.mainArea) .attr("d", drawArea) .style("fill", this.color) .style("opacity", this.orgAreaOpacity) ]; }; c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { var $$ = this, config = $$.config, area = $$.d3.svg.area(), getPoints = $$.generateGetAreaPoints(areaIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { return (isSub ? $$.subxx : $$.xx).call($$, d); }, value0 = function (d, i) { return config.data_groups.length > 0 ? getPoints(d, i)[0][1] : yScaleGetter.call($$, d.id)($$.getAreaBaseValue(d.id)); }, value1 = function (d, i) { return config.data_groups.length > 0 ? getPoints(d, i)[1][1] : yScaleGetter.call($$, d.id)(d.value); }; area = config.axis_rotated ? area.x0(value0).x1(value1).y(xValue) : area.x(xValue).y0(config.area_above ? 0 : value0).y1(value1); if (!config.line_connectNull) { area = area.defined(function (d) { return d.value !== null; }); } return function (d) { var values = config.line_connectNull ? $$.filterRemoveNull(d.values) : d.values, x0 = 0, y0 = 0, path; if ($$.isAreaType(d)) { if ($$.isStepType(d)) { values = $$.convertValuesToStep(values); } path = area.interpolate($$.getInterpolate(d))(values); } else { if (values[0]) { x0 = $$.x(values[0].x); y0 = $$.getYScale(d.id)(values[0].value); } path = config.axis_rotated ? "M " + y0 + " " + x0 : "M " + x0 + " " + y0; } return path ? path : "M 0 0"; }; }; c3_chart_internal_fn.getAreaBaseValue = function () { return 0; }; c3_chart_internal_fn.generateGetAreaPoints = function (areaIndices, isSub) { // partial duplication of generateGetBarPoints var $$ = this, config = $$.config, areaTargetsNum = areaIndices.__max__ + 1, x = $$.getShapeX(0, areaTargetsNum, areaIndices, !!isSub), y = $$.getShapeY(!!isSub), areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; return function (d, i) { var y0 = yScale.call($$, d.id)(0), offset = areaOffset(d, i) || y0, // offset is for stacked area chart posX = x(d), posY = y(d); // fix posY not to overflow opposite quadrant if (config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 1 point that marks the area position return [ [posX, offset], [posX, posY - (y0 - offset)], [posX, posY - (y0 - offset)], // needed for compatibility [posX, offset] // needed for compatibility ]; }; }; c3_chart_internal_fn.updateCircle = function () { var $$ = this; $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) .data($$.lineOrScatterData.bind($$)); $$.mainCircle.enter().append("circle") .attr("class", $$.classCircle.bind($$)) .attr("r", $$.pointR.bind($$)) .style("fill", $$.color); $$.mainCircle .style("opacity", $$.initialOpacityForCircle.bind($$)); $$.mainCircle.exit().remove(); }; c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition) { var selectedCircles = this.main.selectAll('.' + CLASS.selectedCircle); return [ (withTransition ? this.mainCircle.transition(Math.random().toString()) : this.mainCircle) .style('opacity', this.opacityForCircle.bind(this)) .style("fill", this.color) .attr("cx", cx) .attr("cy", cy), (withTransition ? selectedCircles.transition(Math.random().toString()) : selectedCircles) .attr("cx", cx) .attr("cy", cy) ]; }; c3_chart_internal_fn.circleX = function (d) { return d.x || d.x === 0 ? this.x(d.x) : null; }; c3_chart_internal_fn.updateCircleY = function () { var $$ = this, lineIndices, getPoints; if ($$.config.data_groups.length > 0) { lineIndices = $$.getShapeIndices($$.isLineType), getPoints = $$.generateGetLinePoints(lineIndices); $$.circleY = function (d, i) { return getPoints(d, i)[0][1]; }; } else { $$.circleY = function (d) { return $$.getYScale(d.id)(d.value); }; } }; c3_chart_internal_fn.getCircles = function (i, id) { var $$ = this; return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandCircles = function (i, id, reset) { var $$ = this, r = $$.pointExpandedR.bind($$); if (reset) { $$.unexpandCircles(); } $$.getCircles(i, id) .classed(CLASS.EXPANDED, true) .attr('r', r); }; c3_chart_internal_fn.unexpandCircles = function (i) { var $$ = this, r = $$.pointR.bind($$); $$.getCircles(i) .filter(function () { return $$.d3.select(this).classed(CLASS.EXPANDED); }) .classed(CLASS.EXPANDED, false) .attr('r', r); }; c3_chart_internal_fn.pointR = function (d) { var $$ = this, config = $$.config; return $$.isStepType(d) ? 0 : (isFunction(config.point_r) ? config.point_r(d) : config.point_r); }; c3_chart_internal_fn.pointExpandedR = function (d) { var $$ = this, config = $$.config; return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d); }; c3_chart_internal_fn.pointSelectR = function (d) { var $$ = this, config = $$.config; return isFunction(config.point_select_r) ? config.point_select_r(d) : ((config.point_select_r) ? config.point_select_r : $$.pointR(d) * 4); }; c3_chart_internal_fn.isWithinCircle = function (that, r) { var d3 = this.d3, mouse = d3.mouse(that), d3_this = d3.select(that), cx = +d3_this.attr("cx"), cy = +d3_this.attr("cy"); return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < r; }; c3_chart_internal_fn.isWithinStep = function (that, y) { return Math.abs(y - this.d3.mouse(that)[1]) < 30; }; c3_chart_internal_fn.initBar = function () { var $$ = this; $$.main.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartBars); }; c3_chart_internal_fn.updateTargetsForBar = function (targets) { var $$ = this, config = $$.config, mainBarUpdate, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classFocus = $$.classFocus.bind($$); mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', function (d) { return classChartBar(d) + classFocus(d); }); mainBarEnter = mainBarUpdate.enter().append('g') .attr('class', classChartBar) .style('opacity', 0) .style("pointer-events", "none"); // Bars for each data mainBarEnter.append('g') .attr("class", classBars) .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; }); }; c3_chart_internal_fn.updateBar = function (durationForExit) { var $$ = this, barData = $$.barData.bind($$), classBar = $$.classBar.bind($$), initialOpacity = $$.initialOpacity.bind($$), color = function (d) { return $$.color(d.id); }; $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data(barData); $$.mainBar.enter().append('path') .attr("class", classBar) .style("stroke", color) .style("fill", color); $$.mainBar .style("opacity", initialOpacity); $$.mainBar.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawBar = function (drawBar, withTransition) { return [ (withTransition ? this.mainBar.transition(Math.random().toString()) : this.mainBar) .attr('d', drawBar) .style("fill", this.color) .style("opacity", 1) ]; }; c3_chart_internal_fn.getBarW = function (axis, barTargetsNum) { var $$ = this, config = $$.config, w = typeof config.bar_width === 'number' ? config.bar_width : barTargetsNum ? (axis.tickInterval() * config.bar_width_ratio) / barTargetsNum : 0; return config.bar_width_max && w > config.bar_width_max ? config.bar_width_max : w; }; c3_chart_internal_fn.getBars = function (i, id) { var $$ = this; return (id ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); }; c3_chart_internal_fn.expandBars = function (i, id, reset) { var $$ = this; if (reset) { $$.unexpandBars(); } $$.getBars(i, id).classed(CLASS.EXPANDED, true); }; c3_chart_internal_fn.unexpandBars = function (i) { var $$ = this; $$.getBars(i).classed(CLASS.EXPANDED, false); }; c3_chart_internal_fn.generateDrawBar = function (barIndices, isSub) { var $$ = this, config = $$.config, getPoints = $$.generateGetBarPoints(barIndices, isSub); return function (d, i) { // 4 points that make a bar var points = getPoints(d, i); // switch points if axis is rotated, not applicable for sub chart var indexX = config.axis_rotated ? 1 : 0; var indexY = config.axis_rotated ? 0 : 1; var path = 'M ' + points[0][indexX] + ',' + points[0][indexY] + ' ' + 'L' + points[1][indexX] + ',' + points[1][indexY] + ' ' + 'L' + points[2][indexX] + ',' + points[2][indexY] + ' ' + 'L' + points[3][indexX] + ',' + points[3][indexY] + ' ' + 'z'; return path; }; }; c3_chart_internal_fn.generateGetBarPoints = function (barIndices, isSub) { var $$ = this, axis = isSub ? $$.subXAxis : $$.xAxis, barTargetsNum = barIndices.__max__ + 1, barW = $$.getBarW(axis, barTargetsNum), barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), barY = $$.getShapeY(!!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; return function (d, i) { var y0 = yScale.call($$, d.id)(0), offset = barOffset(d, i) || y0, // offset is for stacked bar chart posX = barX(d), posY = barY(d); // fix posY not to overflow opposite quadrant if ($$.config.axis_rotated) { if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { posY = y0; } } // 4 points that make a bar return [ [posX, offset], [posX, posY - (y0 - offset)], [posX + barW, posY - (y0 - offset)], [posX + barW, offset] ]; }; }; c3_chart_internal_fn.isWithinBar = function (that) { var mouse = this.d3.mouse(that), box = that.getBoundingClientRect(), seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1), x = Math.min(seg0.x, seg1.x), y = Math.min(seg0.y, seg1.y), w = box.width, h = box.height, offset = 2, sx = x - offset, ex = x + w + offset, sy = y + h + offset, ey = y - offset; return sx < mouse[0] && mouse[0] < ex && ey < mouse[1] && mouse[1] < sy; }; c3_chart_internal_fn.initText = function () { var $$ = this; $$.main.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartTexts); $$.mainText = $$.d3.selectAll([]); }; c3_chart_internal_fn.updateTargetsForText = function (targets) { var $$ = this, mainTextUpdate, mainTextEnter, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$), classFocus = $$.classFocus.bind($$); mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) .data(targets) .attr('class', function (d) { return classChartText(d) + classFocus(d); }); mainTextEnter = mainTextUpdate.enter().append('g') .attr('class', classChartText) .style('opacity', 0) .style("pointer-events", "none"); mainTextEnter.append('g') .attr('class', classTexts); }; c3_chart_internal_fn.updateText = function (durationForExit) { var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) .data(barOrLineData); $$.mainText.enter().append('text') .attr("class", classText) .attr('text-anchor', function (d) { return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; }) .style("stroke", 'none') .style("fill", function (d) { return $$.color(d); }) .style("fill-opacity", 0); $$.mainText .text(function (d, i, j) { return $$.dataLabelFormat(d.id)(d.value, d.id, i, j); }); $$.mainText.exit() .transition().duration(durationForExit) .style('fill-opacity', 0) .remove(); }; c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTransition) { return [ (withTransition ? this.mainText.transition() : this.mainText) .attr('x', xForText) .attr('y', yForText) .style("fill", this.color) .style("fill-opacity", forFlow ? 0 : this.opacityForText.bind(this)) ]; }; c3_chart_internal_fn.getTextRect = function (text, cls, element) { var dummy = this.d3.select('body').append('div').classed('c3', true), svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0), font = this.d3.select(element).style('font'), rect; svg.selectAll('.dummy') .data([text]) .enter().append('text') .classed(cls ? cls : "", true) .style('font', font) .text(text) .each(function () { rect = this.getBoundingClientRect(); }); dummy.remove(); return rect; }; c3_chart_internal_fn.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { var $$ = this, getAreaPoints = $$.generateGetAreaPoints(areaIndices, false), getBarPoints = $$.generateGetBarPoints(barIndices, false), getLinePoints = $$.generateGetLinePoints(lineIndices, false), getter = forX ? $$.getXForText : $$.getYForText; return function (d, i) { var getPoints = $$.isAreaType(d) ? getAreaPoints : $$.isBarType(d) ? getBarPoints : getLinePoints; return getter.call($$, getPoints(d, i), d, this); }; }; c3_chart_internal_fn.getXForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), xPos, padding; if ($$.config.axis_rotated) { padding = $$.isBarType(d) ? 4 : 6; xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); } else { xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0]; } // show labels regardless of the domain if value is null if (d.value === null) { if (xPos > $$.width) { xPos = $$.width - box.width; } else if (xPos < 0) { xPos = 4; } } return xPos; }; c3_chart_internal_fn.getYForText = function (points, d, textElement) { var $$ = this, box = textElement.getBoundingClientRect(), yPos; if ($$.config.axis_rotated) { yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; } else { yPos = points[2][1]; if (d.value < 0 || (d.value === 0 && !$$.hasPositiveValue)) { yPos += box.height; if ($$.isBarType(d) && $$.isSafari()) { yPos -= 3; } else if (!$$.isBarType(d) && $$.isChrome()) { yPos += 3; } } else { yPos += $$.isBarType(d) ? -3 : -6; } } // show labels regardless of the domain if value is null if (d.value === null && !$$.config.axis_rotated) { if (yPos < box.height) { yPos = box.height; } else if (yPos > this.height) { yPos = this.height - 4; } } return yPos; }; c3_chart_internal_fn.setTargetType = function (targetIds, type) { var $$ = this, config = $$.config; $$.mapToTargetIds(targetIds).forEach(function (id) { $$.withoutFadeIn[id] = (type === config.data_types[id]); config.data_types[id] = type; }); if (!targetIds) { config.data_type = type; } }; c3_chart_internal_fn.hasType = function (type, targets) { var $$ = this, types = $$.config.data_types, has = false; targets = targets || $$.data.targets; if (targets && targets.length) { targets.forEach(function (target) { var t = types[target.id]; if ((t && t.indexOf(type) >= 0) || (!t && type === 'line')) { has = true; } }); } else if (Object.keys(types).length) { Object.keys(types).forEach(function (id) { if (types[id] === type) { has = true; } }); } else { has = $$.config.data_type === type; } return has; }; c3_chart_internal_fn.hasArcType = function (targets) { return this.hasType('pie', targets) || this.hasType('donut', targets) || this.hasType('gauge', targets); }; c3_chart_internal_fn.isLineType = function (d) { var config = this.config, id = isString(d) ? d : d.id; return !config.data_types[id] || ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0; }; c3_chart_internal_fn.isStepType = function (d) { var id = isString(d) ? d : d.id; return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isSplineType = function (d) { var id = isString(d) ? d : d.id; return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isAreaType = function (d) { var id = isString(d) ? d : d.id; return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0; }; c3_chart_internal_fn.isBarType = function (d) { var id = isString(d) ? d : d.id; return this.config.data_types[id] === 'bar'; }; c3_chart_internal_fn.isScatterType = function (d) { var id = isString(d) ? d : d.id; return this.config.data_types[id] === 'scatter'; }; c3_chart_internal_fn.isPieType = function (d) { var id = isString(d) ? d : d.id; return this.config.data_types[id] === 'pie'; }; c3_chart_internal_fn.isGaugeType = function (d) { var id = isString(d) ? d : d.id; return this.config.data_types[id] === 'gauge'; }; c3_chart_internal_fn.isDonutType = function (d) { var id = isString(d) ? d : d.id; return this.config.data_types[id] === 'donut'; }; c3_chart_internal_fn.isArcType = function (d) { return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); }; c3_chart_internal_fn.lineData = function (d) { return this.isLineType(d) ? [d] : []; }; c3_chart_internal_fn.arcData = function (d) { return this.isArcType(d.data) ? [d] : []; }; /* not used function scatterData(d) { return isScatterType(d) ? d.values : []; } */ c3_chart_internal_fn.barData = function (d) { return this.isBarType(d) ? d.values : []; }; c3_chart_internal_fn.lineOrScatterData = function (d) { return this.isLineType(d) || this.isScatterType(d) ? d.values : []; }; c3_chart_internal_fn.barOrLineData = function (d) { return this.isBarType(d) || this.isLineType(d) ? d.values : []; }; c3_chart_internal_fn.isInterpolationType = function (type) { return ['linear', 'linear-closed', 'basis', 'basis-open', 'basis-closed', 'bundle', 'cardinal', 'cardinal-open', 'cardinal-closed', 'monotone'].indexOf(type) >= 0; }; c3_chart_internal_fn.initGrid = function () { var $$ = this, config = $$.config, d3 = $$.d3; $$.grid = $$.main.append('g') .attr("clip-path", $$.clipPathForGrid) .attr('class', CLASS.grid); if (config.grid_x_show) { $$.grid.append("g").attr("class", CLASS.xgrids); } if (config.grid_y_show) { $$.grid.append('g').attr('class', CLASS.ygrids); } if (config.grid_focus_show) { $$.grid.append('g') .attr("class", CLASS.xgridFocus) .append('line') .attr('class', CLASS.xgridFocus); } $$.xgrid = d3.selectAll([]); if (!config.grid_lines_front) { $$.initGridLines(); } }; c3_chart_internal_fn.initGridLines = function () { var $$ = this, d3 = $$.d3; $$.gridLines = $$.main.append('g') .attr("clip-path", $$.clipPathForGrid) .attr('class', CLASS.grid + ' ' + CLASS.gridLines); $$.gridLines.append('g').attr("class", CLASS.xgridLines); $$.gridLines.append('g').attr('class', CLASS.ygridLines); $$.xgridLines = d3.selectAll([]); }; c3_chart_internal_fn.updateXGrid = function (withoutUpdate) { var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; $$.xgridAttr = config.axis_rotated ? { 'x1': 0, 'x2': $$.width, 'y1': function (d) { return $$.x(d) - tickOffset; }, 'y2': function (d) { return $$.x(d) - tickOffset; } } : { 'x1': function (d) { return $$.x(d) + tickOffset; }, 'x2': function (d) { return $$.x(d) + tickOffset; }, 'y1': 0, 'y2': $$.height }; $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) .data(xgridData); $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); if (!withoutUpdate) { $$.xgrid.attr($$.xgridAttr) .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); } $$.xgrid.exit().remove(); }; c3_chart_internal_fn.updateYGrid = function () { var $$ = this, config = $$.config, gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) .data(gridValues); $$.ygrid.enter().append('line') .attr('class', CLASS.ygrid); $$.ygrid.attr("x1", config.axis_rotated ? $$.y : 0) .attr("x2", config.axis_rotated ? $$.y : $$.width) .attr("y1", config.axis_rotated ? 0 : $$.y) .attr("y2", config.axis_rotated ? $$.height : $$.y); $$.ygrid.exit().remove(); $$.smoothLines($$.ygrid, 'grid'); }; c3_chart_internal_fn.gridTextAnchor = function (d) { return d.position ? d.position : "end"; }; c3_chart_internal_fn.gridTextDx = function (d) { return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4; }; c3_chart_internal_fn.xGridTextX = function (d) { return d.position === 'start' ? -this.height : d.position === 'middle' ? -this.height / 2 : 0; }; c3_chart_internal_fn.yGridTextX = function (d) { return d.position === 'start' ? 0 : d.position === 'middle' ? this.width / 2 : this.width; }; c3_chart_internal_fn.updateGrid = function (duration) { var $$ = this, main = $$.main, config = $$.config, xgridLine, ygridLine, yv; // hide if arc type $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); if (config.grid_x_show) { $$.updateXGrid(); } $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) .data(config.grid_x_lines); // enter xgridLine = $$.xgridLines.enter().append('g') .attr("class", function (d) { return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); }); xgridLine.append('line') .style("opacity", 0); xgridLine.append('text') .attr("text-anchor", $$.gridTextAnchor) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .attr('dx', $$.gridTextDx) .attr('dy', -5) .style("opacity", 0); // udpate // done in d3.transition() of the end of this function // exit $$.xgridLines.exit().transition().duration(duration) .style("opacity", 0) .remove(); // Y-Grid if (config.grid_y_show) { $$.updateYGrid(); } $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) .data(config.grid_y_lines); // enter ygridLine = $$.ygridLines.enter().append('g') .attr("class", function (d) { return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); }); ygridLine.append('line') .style("opacity", 0); ygridLine.append('text') .attr("text-anchor", $$.gridTextAnchor) .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .attr('dx', $$.gridTextDx) .attr('dy', -5) .style("opacity", 0); // update yv = $$.yv.bind($$); $$.ygridLines.select('line') .transition().duration(duration) .attr("x1", config.axis_rotated ? yv : 0) .attr("x2", config.axis_rotated ? yv : $$.width) .attr("y1", config.axis_rotated ? 0 : yv) .attr("y2", config.axis_rotated ? $$.height : yv) .style("opacity", 1); $$.ygridLines.select('text') .transition().duration(duration) .attr("x", config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$)) .attr("y", yv) .text(function (d) { return d.text; }) .style("opacity", 1); // exit $$.ygridLines.exit().transition().duration(duration) .style("opacity", 0) .remove(); }; c3_chart_internal_fn.redrawGrid = function (withTransition) { var $$ = this, config = $$.config, xv = $$.xv.bind($$), lines = $$.xgridLines.select('line'), texts = $$.xgridLines.select('text'); return [ (withTransition ? lines.transition() : lines) .attr("x1", config.axis_rotated ? 0 : xv) .attr("x2", config.axis_rotated ? $$.width : xv) .attr("y1", config.axis_rotated ? xv : 0) .attr("y2", config.axis_rotated ? xv : $$.height) .style("opacity", 1), (withTransition ? texts.transition() : texts) .attr("x", config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)) .attr("y", xv) .text(function (d) { return d.text; }) .style("opacity", 1) ]; }; c3_chart_internal_fn.showXGridFocus = function (selectedData) { var $$ = this, config = $$.config, dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), xx = $$.xx.bind($$); if (! config.tooltip_show) { return; } // Hide when scatter plot exists if ($$.hasType('scatter') || $$.hasArcType()) { return; } focusEl .style("visibility", "visible") .data([dataToShow[0]]) .attr(config.axis_rotated ? 'y1' : 'x1', xx) .attr(config.axis_rotated ? 'y2' : 'x2', xx); $$.smoothLines(focusEl, 'grid'); }; c3_chart_internal_fn.hideXGridFocus = function () { this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); }; c3_chart_internal_fn.updateXgridFocus = function () { var $$ = this, config = $$.config; $$.main.select('line.' + CLASS.xgridFocus) .attr("x1", config.axis_rotated ? 0 : -10) .attr("x2", config.axis_rotated ? $$.width : -10) .attr("y1", config.axis_rotated ? -10 : 0) .attr("y2", config.axis_rotated ? -10 : $$.height); }; c3_chart_internal_fn.generateGridData = function (type, scale) { var $$ = this, gridData = [], xDomain, firstYear, lastYear, i, tickNum = $$.main.select("." + CLASS.axisX).selectAll('.tick').size(); if (type === 'year') { xDomain = $$.getXDomain(); firstYear = xDomain[0].getFullYear(); lastYear = xDomain[1].getFullYear(); for (i = firstYear; i <= lastYear; i++) { gridData.push(new Date(i + '-01-01 00:00:00')); } } else { gridData = scale.ticks(10); if (gridData.length > tickNum) { // use only int gridData = gridData.filter(function (d) { return ("" + d).indexOf('.') < 0; }); } } return gridData; }; c3_chart_internal_fn.getGridFilterToRemove = function (params) { return params ? function (line) { var found = false; [].concat(params).forEach(function (param) { if ((('value' in param && line.value === param.value) || ('class' in param && line['class'] === param['class']))) { found = true; } }); return found; } : function () { return true; }; }; c3_chart_internal_fn.removeGridLines = function (params, forX) { var $$ = this, config = $$.config, toRemove = $$.getGridFilterToRemove(params), toShow = function (line) { return !toRemove(line); }, classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; $$.main.select('.' + classLines).selectAll('.' + classLine).filter(toRemove) .transition().duration(config.transition_duration) .style('opacity', 0).remove(); if (forX) { config.grid_x_lines = config.grid_x_lines.filter(toShow); } else { config.grid_y_lines = config.grid_y_lines.filter(toShow); } }; c3_chart_internal_fn.initTooltip = function () { var $$ = this, config = $$.config, i; $$.tooltip = $$.selectChart .style("position", "relative") .append("div") .attr('class', CLASS.tooltipContainer) .style("position", "absolute") .style("pointer-events", "none") .style("display", "none"); // Show tooltip if needed if (config.tooltip_init_show) { if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); for (i = 0; i < $$.data.targets[0].values.length; i++) { if (($$.data.targets[0].values[i].x - config.tooltip_init_x) === 0) { break; } } config.tooltip_init_x = i; } $$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) { return $$.addName(d.values[config.tooltip_init_x]); }), $$.axis.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color)); $$.tooltip.style("top", config.tooltip_init_position.top) .style("left", config.tooltip_init_position.left) .style("display", "block"); } }; c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) { var $$ = this, config = $$.config, titleFormat = config.tooltip_format_title || defaultTitleFormat, nameFormat = config.tooltip_format_name || function (name) { return name; }, valueFormat = config.tooltip_format_value || defaultValueFormat, text, i, title, value, name, bgcolor, orderAsc = $$.isOrderAsc(); if (config.data_groups.length === 0) { d.sort(function(a, b){ var v1 = a ? a.value : null, v2 = b ? b.value : null; return orderAsc ? v1 - v2 : v2 - v1; }); } else { var ids = $$.orderTargets($$.data.targets).map(function (i) { return i.id; }); d.sort(function(a, b) { var v1 = a ? a.value : null, v2 = b ? b.value : null; if (v1 > 0 && v2 > 0) { v1 = a ? ids.indexOf(a.id) : null; v2 = b ? ids.indexOf(b.id) : null; } return orderAsc ? v1 - v2 : v2 - v1; }); } for (i = 0; i < d.length; i++) { if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; } if (! text) { title = sanitise(titleFormat ? titleFormat(d[i].x) : d[i].x); text = "<table class='" + $$.CLASS.tooltip + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : ""); } value = sanitise(valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index, d)); if (value !== undefined) { // Skip elements when their name is set to null if (d[i].name === null) { continue; } name = sanitise(nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index)); bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); text += "<tr class='" + $$.CLASS.tooltipName + "-" + $$.getTargetSelectorSuffix(d[i].id) + "'>"; text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>"; text += "<td class='value'>" + value + "</td>"; text += "</tr>"; } } return text + "</table>"; }; c3_chart_internal_fn.tooltipPosition = function (dataToShow, tWidth, tHeight, element) { var $$ = this, config = $$.config, d3 = $$.d3; var svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; var forArc = $$.hasArcType(), mouse = d3.mouse(element); // Determin tooltip position if (forArc) { tooltipLeft = (($$.width - ($$.isLegendRight ? $$.getLegendWidth() : 0)) / 2) + mouse[0]; tooltipTop = ($$.height / 2) + mouse[1] + 20; } else { svgLeft = $$.getSvgLeft(true); if (config.axis_rotated) { tooltipLeft = svgLeft + mouse[0] + 100; tooltipRight = tooltipLeft + tWidth; chartRight = $$.currentWidth - $$.getCurrentPaddingRight(); tooltipTop = $$.x(dataToShow[0].x) + 20; } else { tooltipLeft = svgLeft + $$.getCurrentPaddingLeft(true) + $$.x(dataToShow[0].x) + 20; tooltipRight = tooltipLeft + tWidth; chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); tooltipTop = mouse[1] + 15; } if (tooltipRight > chartRight) { // 20 is needed for Firefox to keep tooltip width tooltipLeft -= tooltipRight - chartRight + 20; } if (tooltipTop + tHeight > $$.currentHeight) { tooltipTop -= tHeight + 30; } } if (tooltipTop < 0) { tooltipTop = 0; } return {top: tooltipTop, left: tooltipLeft}; }; c3_chart_internal_fn.showTooltip = function (selectedData, element) { var $$ = this, config = $$.config; var tWidth, tHeight, position; var forArc = $$.hasArcType(), dataToShow = selectedData.filter(function (d) { return d && isValue(d.value); }), positionFunction = config.tooltip_position || c3_chart_internal_fn.tooltipPosition; if (dataToShow.length === 0 || !config.tooltip_show) { return; } $$.tooltip.html(config.tooltip_contents.call($$, selectedData, $$.axis.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)).style("display", "block"); // Get tooltip dimensions tWidth = $$.tooltip.property('offsetWidth'); tHeight = $$.tooltip.property('offsetHeight'); position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); // Set tooltip $$.tooltip .style("top", position.top + "px") .style("left", position.left + 'px'); }; c3_chart_internal_fn.hideTooltip = function () { this.tooltip.style("display", "none"); }; c3_chart_internal_fn.initLegend = function () { var $$ = this; $$.legendItemTextBox = {}; $$.legendHasRendered = false; $$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend')); if (!$$.config.legend_show) { $$.legend.style('visibility', 'hidden'); $$.hiddenLegendIds = $$.mapToIds($$.data.targets); return; } // MEMO: call here to update legend box and tranlate for all // MEMO: translate will be upated by this, so transform not needed in updateLegend() $$.updateLegendWithDefaults(); }; c3_chart_internal_fn.updateLegendWithDefaults = function () { var $$ = this; $$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false}); }; c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) { var $$ = this, config = $$.config, insetLegendPosition = { top: $$.isLegendTop ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 : $$.currentHeight - legendHeight - $$.getCurrentPaddingBottom() - config.legend_inset_y, left: $$.isLegendLeft ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 : $$.currentWidth - legendWidth - $$.getCurrentPaddingRight() - config.legend_inset_x + 0.5 }; $$.margin3 = { top: $$.isLegendRight ? 0 : $$.isLegendInset ? insetLegendPosition.top : $$.currentHeight - legendHeight, right: NaN, bottom: 0, left: $$.isLegendRight ? $$.currentWidth - legendWidth : $$.isLegendInset ? insetLegendPosition.left : 0 }; }; c3_chart_internal_fn.transformLegend = function (withTransition) { var $$ = this; (withTransition ? $$.legend.transition() : $$.legend).attr("transform", $$.getTranslate('legend')); }; c3_chart_internal_fn.updateLegendStep = function (step) { this.legendStep = step; }; c3_chart_internal_fn.updateLegendItemWidth = function (w) { this.legendItemWidth = w; }; c3_chart_internal_fn.updateLegendItemHeight = function (h) { this.legendItemHeight = h; }; c3_chart_internal_fn.getLegendWidth = function () { var $$ = this; return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; }; c3_chart_internal_fn.getLegendHeight = function () { var $$ = this, h = 0; if ($$.config.legend_show) { if ($$.isLegendRight) { h = $$.currentHeight; } else { h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); } } return h; }; c3_chart_internal_fn.opacityForLegend = function (legendItem) { return legendItem.classed(CLASS.legendItemHidden) ? null : 1; }; c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; }; c3_chart_internal_fn.toggleFocusLegend = function (targetIds, focus) { var $$ = this; targetIds = $$.mapToTargetIds(targetIds); $$.legend.selectAll('.' + CLASS.legendItem) .filter(function (id) { return targetIds.indexOf(id) >= 0; }) .classed(CLASS.legendItemFocused, focus) .transition().duration(100) .style('opacity', function () { var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; return opacity.call($$, $$.d3.select(this)); }); }; c3_chart_internal_fn.revertLegend = function () { var $$ = this, d3 = $$.d3; $$.legend.selectAll('.' + CLASS.legendItem) .classed(CLASS.legendItemFocused, false) .transition().duration(100) .style('opacity', function () { return $$.opacityForLegend(d3.select(this)); }); }; c3_chart_internal_fn.showLegend = function (targetIds) { var $$ = this, config = $$.config; if (!config.legend_show) { config.legend_show = true; $$.legend.style('visibility', 'visible'); if (!$$.legendHasRendered) { $$.updateLegendWithDefaults(); } } $$.removeHiddenLegendIds(targetIds); $$.legend.selectAll($$.selectorLegends(targetIds)) .style('visibility', 'visible') .transition() .style('opacity', function () { return $$.opacityForLegend($$.d3.select(this)); }); }; c3_chart_internal_fn.hideLegend = function (targetIds) { var $$ = this, config = $$.config; if (config.legend_show && isEmpty(targetIds)) { config.legend_show = false; $$.legend.style('visibility', 'hidden'); } $$.addHiddenLegendIds(targetIds); $$.legend.selectAll($$.selectorLegends(targetIds)) .style('opacity', 0) .style('visibility', 'hidden'); }; c3_chart_internal_fn.clearLegendItemTextBoxCache = function () { this.legendItemTextBox = {}; }; c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { var $$ = this, config = $$.config; var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect, x1ForLegendTile, x2ForLegendTile, yForLegendTile; var paddingTop = 4, paddingRight = 10, maxWidth = 0, maxHeight = 0, posMin = 10, tileWidth = config.legend_item_tile_width + 5; var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; var withTransition, withTransitionForTransform; var texts, rects, tiles, background; // Skip elements when their name is set to null targetIds = targetIds.filter(function(id) { return !isDefined(config.data_names[id]) || config.data_names[id] !== null; }); options = options || {}; withTransition = getOption(options, "withTransition", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true); function getTextBox(textElement, id) { if (!$$.legendItemTextBox[id]) { $$.legendItemTextBox[id] = $$.getTextRect(textElement.textContent, CLASS.legendItem, textElement); } return $$.legendItemTextBox[id]; } function updatePositions(textElement, id, index) { var reset = index === 0, isLast = index === targetIds.length - 1, box = getTextBox(textElement, id), itemWidth = box.width + tileWidth + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight) + config.legend_padding, itemHeight = box.height + paddingTop, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, areaLength = $$.isLegendRight || $$.isLegendInset ? $$.getLegendHeight() : $$.getLegendWidth(), margin, maxLength; // MEMO: care about condifion of step, totalLength function updateValues(id, withoutStep) { if (!withoutStep) { margin = (areaLength - totalLength - itemLength) / 2; if (margin < posMin) { margin = (areaLength - itemLength) / 2; totalLength = 0; step++; } } steps[id] = step; margins[step] = $$.isLegendInset ? 10 : margin; offsets[id] = totalLength; totalLength += itemLength; } if (reset) { totalLength = 0; step = 0; maxWidth = 0; maxHeight = 0; } if (config.legend_show && !$$.isLegendToShow(id)) { widths[id] = heights[id] = steps[id] = offsets[id] = 0; return; } widths[id] = itemWidth; heights[id] = itemHeight; if (!maxWidth || itemWidth >= maxWidth) { maxWidth = itemWidth; } if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; } maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; if (config.legend_equally) { Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); margin = (areaLength - maxLength * targetIds.length) / 2; if (margin < posMin) { totalLength = 0; step = 0; targetIds.forEach(function (id) { updateValues(id); }); } else { updateValues(id, true); } } else { updateValues(id); } } if ($$.isLegendInset) { step = config.legend_inset_step ? config.legend_inset_step : targetIds.length; $$.updateLegendStep(step); } if ($$.isLegendRight) { xForLegend = function (id) { return maxWidth * steps[id]; }; yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; } else if ($$.isLegendInset) { xForLegend = function (id) { return maxWidth * steps[id] + 10; }; yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; } else { xForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; yForLegend = function (id) { return maxHeight * steps[id]; }; } xForLegendText = function (id, i) { return xForLegend(id, i) + 4 + config.legend_item_tile_width; }; yForLegendText = function (id, i) { return yForLegend(id, i) + 9; }; xForLegendRect = function (id, i) { return xForLegend(id, i); }; yForLegendRect = function (id, i) { return yForLegend(id, i) - 5; }; x1ForLegendTile = function (id, i) { return xForLegend(id, i) - 2; }; x2ForLegendTile = function (id, i) { return xForLegend(id, i) - 2 + config.legend_item_tile_width; }; yForLegendTile = function (id, i) { return yForLegend(id, i) + 4; }; // Define g for legend area l = $$.legend.selectAll('.' + CLASS.legendItem) .data(targetIds) .enter().append('g') .attr('class', function (id) { return $$.generateClass(CLASS.legendItem, id); }) .style('visibility', function (id) { return $$.isLegendToShow(id) ? 'visible' : 'hidden'; }) .style('cursor', 'pointer') .on('click', function (id) { if (config.legend_item_onclick) { config.legend_item_onclick.call($$, id); } else { if ($$.d3.event.altKey) { $$.api.hide(); $$.api.show(id); } else { $$.api.toggle(id); $$.isTargetToShow(id) ? $$.api.focus(id) : $$.api.revert(); } } }) .on('mouseover', function (id) { if (config.legend_item_onmouseover) { config.legend_item_onmouseover.call($$, id); } else { $$.d3.select(this).classed(CLASS.legendItemFocused, true); if (!$$.transiting && $$.isTargetToShow(id)) { $$.api.focus(id); } } }) .on('mouseout', function (id) { if (config.legend_item_onmouseout) { config.legend_item_onmouseout.call($$, id); } else { $$.d3.select(this).classed(CLASS.legendItemFocused, false); $$.api.revert(); } }); l.append('text') .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) .each(function (id, i) { updatePositions(this, id, i); }) .style("pointer-events", "none") .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); l.append('rect') .attr("class", CLASS.legendItemEvent) .style('fill-opacity', 0) .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); l.append('line') .attr('class', CLASS.legendItemTile) .style('stroke', $$.color) .style("pointer-events", "none") .attr('x1', $$.isLegendRight || $$.isLegendInset ? x1ForLegendTile : -200) .attr('y1', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) .attr('x2', $$.isLegendRight || $$.isLegendInset ? x2ForLegendTile : -200) .attr('y2', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) .attr('stroke-width', config.legend_item_tile_height); // Set background for inset legend background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { background = $$.legend.insert('g', '.' + CLASS.legendItem) .attr("class", CLASS.legendBackground) .append('rect'); } texts = $$.legend.selectAll('text') .data(targetIds) .text(function (id) { return isDefined(config.data_names[id]) ? config.data_names[id] : id; }) // MEMO: needed for update .each(function (id, i) { updatePositions(this, id, i); }); (withTransition ? texts.transition() : texts) .attr('x', xForLegendText) .attr('y', yForLegendText); rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent) .data(targetIds); (withTransition ? rects.transition() : rects) .attr('width', function (id) { return widths[id]; }) .attr('height', function (id) { return heights[id]; }) .attr('x', xForLegendRect) .attr('y', yForLegendRect); tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile) .data(targetIds); (withTransition ? tiles.transition() : tiles) .style('stroke', $$.color) .attr('x1', x1ForLegendTile) .attr('y1', yForLegendTile) .attr('x2', x2ForLegendTile) .attr('y2', yForLegendTile); if (background) { (withTransition ? background.transition() : background) .attr('height', $$.getLegendHeight() - 12) .attr('width', maxWidth * (step + 1) + 10); } // toggle legend state $$.legend.selectAll('.' + CLASS.legendItem) .classed(CLASS.legendItemHidden, function (id) { return !$$.isTargetToShow(id); }); // Update all to reflect change of legend $$.updateLegendItemWidth(maxWidth); $$.updateLegendItemHeight(maxHeight); $$.updateLegendStep(step); // Update size and scale $$.updateSizes(); $$.updateScales(); $$.updateSvgSize(); // Update g positions $$.transformAll(withTransitionForTransform, transitions); $$.legendHasRendered = true; }; c3_chart_internal_fn.initTitle = function () { var $$ = this; $$.title = $$.svg.append("text") .text($$.config.title_text) .attr("class", $$.CLASS.title); }; c3_chart_internal_fn.redrawTitle = function () { var $$ = this; $$.title .attr("x", $$.xForTitle.bind($$)) .attr("y", $$.yForTitle.bind($$)); }; c3_chart_internal_fn.xForTitle = function () { var $$ = this, config = $$.config, position = config.title_position || 'left', x; if (position.indexOf('right') >= 0) { x = $$.currentWidth - $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width - config.title_padding.right; } else if (position.indexOf('center') >= 0) { x = ($$.currentWidth - $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width) / 2; } else { // left x = config.title_padding.left; } return x; }; c3_chart_internal_fn.yForTitle = function () { var $$ = this; return $$.config.title_padding.top + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).height; }; c3_chart_internal_fn.getTitlePadding = function() { var $$ = this; return $$.yForTitle() + $$.config.title_padding.bottom; }; function Axis(owner) { API.call(this, owner); } inherit(API, Axis); Axis.prototype.init = function init() { var $$ = this.owner, config = $$.config, main = $$.main; $$.axes.x = main.append("g") .attr("class", CLASS.axis + ' ' + CLASS.axisX) .attr("clip-path", $$.clipPathForXAxis) .attr("transform", $$.getTranslate('x')) .style("visibility", config.axis_x_show ? 'visible' : 'hidden'); $$.axes.x.append("text") .attr("class", CLASS.axisXLabel) .attr("transform", config.axis_rotated ? "rotate(-90)" : "") .style("text-anchor", this.textAnchorForXAxisLabel.bind(this)); $$.axes.y = main.append("g") .attr("class", CLASS.axis + ' ' + CLASS.axisY) .attr("clip-path", config.axis_y_inner ? "" : $$.clipPathForYAxis) .attr("transform", $$.getTranslate('y')) .style("visibility", config.axis_y_show ? 'visible' : 'hidden'); $$.axes.y.append("text") .attr("class", CLASS.axisYLabel) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", this.textAnchorForYAxisLabel.bind(this)); $$.axes.y2 = main.append("g") .attr("class", CLASS.axis + ' ' + CLASS.axisY2) // clip-path? .attr("transform", $$.getTranslate('y2')) .style("visibility", config.axis_y2_show ? 'visible' : 'hidden'); $$.axes.y2.append("text") .attr("class", CLASS.axisY2Label) .attr("transform", config.axis_rotated ? "" : "rotate(-90)") .style("text-anchor", this.textAnchorForY2AxisLabel.bind(this)); }; Axis.prototype.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { var $$ = this.owner, config = $$.config, axisParams = { isCategory: $$.isCategorized(), withOuterTick: withOuterTick, tickMultiline: config.axis_x_tick_multiline, tickWidth: config.axis_x_tick_width, tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, withoutTransition: withoutTransition, }, axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); if ($$.isTimeSeries() && tickValues && typeof tickValues !== "function") { tickValues = tickValues.map(function (v) { return $$.parseDate(v); }); } // Set tick axis.tickFormat(tickFormat).tickValues(tickValues); if ($$.isCategorized()) { axis.tickCentered(config.axis_x_tick_centered); if (isEmpty(config.axis_x_tick_culling)) { config.axis_x_tick_culling = false; } } return axis; }; Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) { var $$ = this.owner, config = $$.config, tickValues; if (config.axis_x_tick_fit || config.axis_x_tick_count) { tickValues = this.generateTickValues($$.mapTargetsToUniqueXs(targets), config.axis_x_tick_count, $$.isTimeSeries()); } if (axis) { axis.tickValues(tickValues); } else { $$.xAxis.tickValues(tickValues); $$.subXAxis.tickValues(tickValues); } return tickValues; }; Axis.prototype.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { var $$ = this.owner, config = $$.config, axisParams = { withOuterTick: withOuterTick, withoutTransition: withoutTransition, tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate }, axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); if ($$.isTimeSeriesY()) { axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); } else { axis.tickValues(tickValues); } return axis; }; Axis.prototype.getId = function getId(id) { var config = this.owner.config; return id in config.data_axes ? config.data_axes[id] : 'y'; }; Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() { var $$ = this.owner, config = $$.config, format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : v; }; if (config.axis_x_tick_format) { if (isFunction(config.axis_x_tick_format)) { format = config.axis_x_tick_format; } else if ($$.isTimeSeries()) { format = function (date) { return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : ""; }; } } return isFunction(format) ? function (v) { return format.call($$, v); } : format; }; Axis.prototype.getTickValues = function getTickValues(tickValues, axis) { return tickValues ? tickValues : axis ? axis.tickValues() : undefined; }; Axis.prototype.getXAxisTickValues = function getXAxisTickValues() { return this.getTickValues(this.owner.config.axis_x_tick_values, this.owner.xAxis); }; Axis.prototype.getYAxisTickValues = function getYAxisTickValues() { return this.getTickValues(this.owner.config.axis_y_tick_values, this.owner.yAxis); }; Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() { return this.getTickValues(this.owner.config.axis_y2_tick_values, this.owner.y2Axis); }; Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId(axisId) { var $$ = this.owner, config = $$.config, option; if (axisId === 'y') { option = config.axis_y_label; } else if (axisId === 'y2') { option = config.axis_y2_label; } else if (axisId === 'x') { option = config.axis_x_label; } return option; }; Axis.prototype.getLabelText = function getLabelText(axisId) { var option = this.getLabelOptionByAxisId(axisId); return isString(option) ? option : option ? option.text : null; }; Axis.prototype.setLabelText = function setLabelText(axisId, text) { var $$ = this.owner, config = $$.config, option = this.getLabelOptionByAxisId(axisId); if (isString(option)) { if (axisId === 'y') { config.axis_y_label = text; } else if (axisId === 'y2') { config.axis_y2_label = text; } else if (axisId === 'x') { config.axis_x_label = text; } } else if (option) { option.text = text; } }; Axis.prototype.getLabelPosition = function getLabelPosition(axisId, defaultPosition) { var option = this.getLabelOptionByAxisId(axisId), position = (option && typeof option === 'object' && option.position) ? option.position : defaultPosition; return { isInner: position.indexOf('inner') >= 0, isOuter: position.indexOf('outer') >= 0, isLeft: position.indexOf('left') >= 0, isCenter: position.indexOf('center') >= 0, isRight: position.indexOf('right') >= 0, isTop: position.indexOf('top') >= 0, isMiddle: position.indexOf('middle') >= 0, isBottom: position.indexOf('bottom') >= 0 }; }; Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() { return this.getLabelPosition('x', this.owner.config.axis_rotated ? 'inner-top' : 'inner-right'); }; Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() { return this.getLabelPosition('y', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); }; Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() { return this.getLabelPosition('y2', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); }; Axis.prototype.getLabelPositionById = function getLabelPositionById(id) { return id === 'y2' ? this.getY2AxisLabelPosition() : id === 'y' ? this.getYAxisLabelPosition() : this.getXAxisLabelPosition(); }; Axis.prototype.textForXAxisLabel = function textForXAxisLabel() { return this.getLabelText('x'); }; Axis.prototype.textForYAxisLabel = function textForYAxisLabel() { return this.getLabelText('y'); }; Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() { return this.getLabelText('y2'); }; Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) { var $$ = this.owner; if (forHorizontal) { return position.isLeft ? 0 : position.isCenter ? $$.width / 2 : $$.width; } else { return position.isBottom ? -$$.height : position.isMiddle ? -$$.height / 2 : 0; } }; Axis.prototype.dxForAxisLabel = function dxForAxisLabel(forHorizontal, position) { if (forHorizontal) { return position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0"; } else { return position.isTop ? "-0.5em" : position.isBottom ? "0.5em" : "0"; } }; Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel(forHorizontal, position) { if (forHorizontal) { return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end'; } else { return position.isBottom ? 'start' : position.isMiddle ? 'middle' : 'end'; } }; Axis.prototype.xForXAxisLabel = function xForXAxisLabel() { return this.xForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); }; Axis.prototype.xForYAxisLabel = function xForYAxisLabel() { return this.xForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); }; Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() { return this.xForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); }; Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() { return this.dxForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); }; Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() { return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); }; Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() { return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); }; Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() { var $$ = this.owner, config = $$.config, position = this.getXAxisLabelPosition(); if (config.axis_rotated) { return position.isInner ? "1.2em" : -25 - this.getMaxTickWidth('x'); } else { return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; } }; Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { var $$ = this.owner, position = this.getYAxisLabelPosition(); if ($$.config.axis_rotated) { return position.isInner ? "-0.5em" : "3em"; } else { return position.isInner ? "1.2em" : -10 - ($$.config.axis_y_inner ? 0 : (this.getMaxTickWidth('y') + 10)); } }; Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() { var $$ = this.owner, position = this.getY2AxisLabelPosition(); if ($$.config.axis_rotated) { return position.isInner ? "1.2em" : "-2.2em"; } else { return position.isInner ? "-0.5em" : 15 + ($$.config.axis_y2_inner ? 0 : (this.getMaxTickWidth('y2') + 15)); } }; Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() { var $$ = this.owner; return this.textAnchorForAxisLabel(!$$.config.axis_rotated, this.getXAxisLabelPosition()); }; Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() { var $$ = this.owner; return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getYAxisLabelPosition()); }; Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() { var $$ = this.owner; return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getY2AxisLabelPosition()); }; Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) { var $$ = this.owner, config = $$.config, maxWidth = 0, targetsToShow, scale, axis, dummy, svg; if (withoutRecompute && $$.currentMaxTickWidths[id]) { return $$.currentMaxTickWidths[id]; } if ($$.svg) { targetsToShow = $$.filterTargetsToShow($$.data.targets); if (id === 'y') { scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); axis = this.getYAxis(scale, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, false, true, true); } else if (id === 'y2') { scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); axis = this.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, false, true, true); } else { scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); axis = this.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, false, true, true); this.updateXAxisTickValues(targetsToShow, axis); } dummy = $$.d3.select('body').append('div').classed('c3', true); svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0), svg.append('g').call(axis).each(function () { $$.d3.select(this).selectAll('text').each(function () { var box = this.getBoundingClientRect(); if (maxWidth < box.width) { maxWidth = box.width; } }); dummy.remove(); }); } $$.currentMaxTickWidths[id] = maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; return $$.currentMaxTickWidths[id]; }; Axis.prototype.updateLabels = function updateLabels(withTransition) { var $$ = this.owner; var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); (withTransition ? axisXLabel.transition() : axisXLabel) .attr("x", this.xForXAxisLabel.bind(this)) .attr("dx", this.dxForXAxisLabel.bind(this)) .attr("dy", this.dyForXAxisLabel.bind(this)) .text(this.textForXAxisLabel.bind(this)); (withTransition ? axisYLabel.transition() : axisYLabel) .attr("x", this.xForYAxisLabel.bind(this)) .attr("dx", this.dxForYAxisLabel.bind(this)) .attr("dy", this.dyForYAxisLabel.bind(this)) .text(this.textForYAxisLabel.bind(this)); (withTransition ? axisY2Label.transition() : axisY2Label) .attr("x", this.xForY2AxisLabel.bind(this)) .attr("dx", this.dxForY2AxisLabel.bind(this)) .attr("dy", this.dyForY2AxisLabel.bind(this)) .text(this.textForY2AxisLabel.bind(this)); }; Axis.prototype.getPadding = function getPadding(padding, key, defaultValue, domainLength) { var p = typeof padding === 'number' ? padding : padding[key]; if (!isValue(p)) { return defaultValue; } if (padding.unit === 'ratio') { return padding[key] * domainLength; } // assume padding is pixels if unit is not specified return this.convertPixelsToAxisPadding(p, domainLength); }; Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) { var $$ = this.owner, length = $$.config.axis_rotated ? $$.width : $$.height; return domainLength * (pixels / length); }; Axis.prototype.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) { var tickValues = values, targetCount, start, end, count, interval, i, tickValue; if (tickCount) { targetCount = isFunction(tickCount) ? tickCount() : tickCount; // compute ticks according to tickCount if (targetCount === 1) { tickValues = [values[0]]; } else if (targetCount === 2) { tickValues = [values[0], values[values.length - 1]]; } else if (targetCount > 2) { count = targetCount - 2; start = values[0]; end = values[values.length - 1]; interval = (end - start) / (count + 1); // re-construct unique values tickValues = [start]; for (i = 0; i < count; i++) { tickValue = +start + interval * (i + 1); tickValues.push(forTimeSeries ? new Date(tickValue) : tickValue); } tickValues.push(end); } } if (!forTimeSeries) { tickValues = tickValues.sort(function (a, b) { return a - b; }); } return tickValues; }; Axis.prototype.generateTransitions = function generateTransitions(duration) { var $$ = this.owner, axes = $$.axes; return { axisX: duration ? axes.x.transition().duration(duration) : axes.x, axisY: duration ? axes.y.transition().duration(duration) : axes.y, axisY2: duration ? axes.y2.transition().duration(duration) : axes.y2, axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx }; }; Axis.prototype.redraw = function redraw(transitions, isHidden) { var $$ = this.owner; $$.axes.x.style("opacity", isHidden ? 0 : 1); $$.axes.y.style("opacity", isHidden ? 0 : 1); $$.axes.y2.style("opacity", isHidden ? 0 : 1); $$.axes.subx.style("opacity", isHidden ? 0 : 1); transitions.axisX.call($$.xAxis); transitions.axisY.call($$.yAxis); transitions.axisY2.call($$.y2Axis); transitions.axisSubX.call($$.subXAxis); }; c3_chart_internal_fn.getClipPath = function (id) { var isIE9 = window.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0; return "url(" + (isIE9 ? "" : document.URL.split('#')[0]) + "#" + id + ")"; }; c3_chart_internal_fn.appendClip = function (parent, id) { return parent.append("clipPath").attr("id", id).append("rect"); }; c3_chart_internal_fn.getAxisClipX = function (forHorizontal) { // axis line width + padding for left var left = Math.max(30, this.margin.left); return forHorizontal ? -(1 + left) : -(left - 1); }; c3_chart_internal_fn.getAxisClipY = function (forHorizontal) { return forHorizontal ? -20 : -this.margin.top; }; c3_chart_internal_fn.getXAxisClipX = function () { var $$ = this; return $$.getAxisClipX(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipY = function () { var $$ = this; return $$.getAxisClipY(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipX = function () { var $$ = this; return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipY = function () { var $$ = this; return $$.getAxisClipY($$.config.axis_rotated); }; c3_chart_internal_fn.getAxisClipWidth = function (forHorizontal) { var $$ = this, left = Math.max(30, $$.margin.left), right = Math.max(30, $$.margin.right); // width + axis line width + padding for left/right return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20; }; c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) { // less than 20 is not enough to show the axis label 'outer' without legend return (forHorizontal ? this.margin.bottom : (this.margin.top + this.height)) + 20; }; c3_chart_internal_fn.getXAxisClipWidth = function () { var $$ = this; return $$.getAxisClipWidth(!$$.config.axis_rotated); }; c3_chart_internal_fn.getXAxisClipHeight = function () { var $$ = this; return $$.getAxisClipHeight(!$$.config.axis_rotated); }; c3_chart_internal_fn.getYAxisClipWidth = function () { var $$ = this; return $$.getAxisClipWidth($$.config.axis_rotated) + ($$.config.axis_y_inner ? 20 : 0); }; c3_chart_internal_fn.getYAxisClipHeight = function () { var $$ = this; return $$.getAxisClipHeight($$.config.axis_rotated); }; c3_chart_internal_fn.initPie = function () { var $$ = this, d3 = $$.d3, config = $$.config; $$.pie = d3.layout.pie().value(function (d) { return d.values.reduce(function (a, b) { return a + b.value; }, 0); }); if (!config.data_order) { $$.pie.sort(null); } }; c3_chart_internal_fn.updateRadius = function () { var $$ = this, config = $$.config, w = config.gauge_width || config.donut_width; $$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2; $$.radius = $$.radiusExpanded * 0.95; $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; $$.innerRadius = $$.hasType('donut') || $$.hasType('gauge') ? $$.radius * $$.innerRadiusRatio : 0; }; c3_chart_internal_fn.updateArc = function () { var $$ = this; $$.svgArc = $$.getSvgArc(); $$.svgArcExpanded = $$.getSvgArcExpanded(); $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); }; c3_chart_internal_fn.updateAngle = function (d) { var $$ = this, config = $$.config, found = false, index = 0, gMin, gMax, gTic, gValue; if (!config) { return null; } $$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function (t) { if (! found && t.data.id === d.data.id) { found = true; d = t; d.index = index; } index++; }); if (isNaN(d.startAngle)) { d.startAngle = 0; } if (isNaN(d.endAngle)) { d.endAngle = d.startAngle; } if ($$.isGaugeType(d.data)) { gMin = config.gauge_min; gMax = config.gauge_max; gTic = (Math.PI * (config.gauge_fullCircle ? 2 : 1)) / (gMax - gMin); gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin); d.startAngle = config.gauge_startingAngle; d.endAngle = d.startAngle + gTic * gValue; } return found ? d : null; }; c3_chart_internal_fn.getSvgArc = function () { var $$ = this, arc = $$.d3.svg.arc().outerRadius($$.radius).innerRadius($$.innerRadius), newArc = function (d, withoutUpdate) { var updated; if (withoutUpdate) { return arc(d); } // for interpolate updated = $$.updateAngle(d); return updated ? arc(updated) : "M 0 0"; }; // TODO: extends all function newArc.centroid = arc.centroid; return newArc; }; c3_chart_internal_fn.getSvgArcExpanded = function (rate) { var $$ = this, arc = $$.d3.svg.arc().outerRadius($$.radiusExpanded * (rate ? rate : 1)).innerRadius($$.innerRadius); return function (d) { var updated = $$.updateAngle(d); return updated ? arc(updated) : "M 0 0"; }; }; c3_chart_internal_fn.getArc = function (d, withoutUpdate, force) { return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0"; }; c3_chart_internal_fn.transformForArcLabel = function (d) { var $$ = this, config = $$.config, updated = $$.updateAngle(d), c, x, y, h, ratio, translate = ""; if (updated && !$$.hasType('gauge')) { c = this.svgArc.centroid(updated); x = isNaN(c[0]) ? 0 : c[0]; y = isNaN(c[1]) ? 0 : c[1]; h = Math.sqrt(x * x + y * y); if ($$.hasType('donut') && config.donut_label_ratio) { ratio = isFunction(config.donut_label_ratio) ? config.donut_label_ratio(d, $$.radius, h) : config.donut_label_ratio; } else if ($$.hasType('pie') && config.pie_label_ratio) { ratio = isFunction(config.pie_label_ratio) ? config.pie_label_ratio(d, $$.radius, h) : config.pie_label_ratio; } else { ratio = $$.radius && h ? (36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * $$.radius / h : 0; } translate = "translate(" + (x * ratio) + ',' + (y * ratio) + ")"; } return translate; }; c3_chart_internal_fn.getArcRatio = function (d) { var $$ = this, config = $$.config, whole = Math.PI * ($$.hasType('gauge') && !config.gauge_fullCircle ? 1 : 2); return d ? (d.endAngle - d.startAngle) / whole : null; }; c3_chart_internal_fn.convertToArcData = function (d) { return this.addName({ id: d.data.id, value: d.value, ratio: this.getArcRatio(d), index: d.index }); }; c3_chart_internal_fn.textForArcLabel = function (d) { var $$ = this, updated, value, ratio, id, format; if (! $$.shouldShowArcLabel()) { return ""; } updated = $$.updateAngle(d); value = updated ? updated.value : null; ratio = $$.getArcRatio(updated); id = d.data.id; if (! $$.hasType('gauge') && ! $$.meetsArcLabelThreshold(ratio)) { return ""; } format = $$.getArcLabelFormat(); return format ? format(value, ratio, id) : $$.defaultArcValueFormat(value, ratio); }; c3_chart_internal_fn.expandArc = function (targetIds) { var $$ = this, interval; // MEMO: avoid to cancel transition if ($$.transiting) { interval = window.setInterval(function () { if (!$$.transiting) { window.clearInterval(interval); if ($$.legend.selectAll('.c3-legend-item-focused').size() > 0) { $$.expandArc(targetIds); } } }, 10); return; } targetIds = $$.mapToTargetIds(targetIds); $$.svg.selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)).each(function (d) { if (! $$.shouldExpand(d.data.id)) { return; } $$.d3.select(this).selectAll('path') .transition().duration($$.expandDuration(d.data.id)) .attr("d", $$.svgArcExpanded) .transition().duration($$.expandDuration(d.data.id) * 2) .attr("d", $$.svgArcExpandedSub) .each(function (d) { if ($$.isDonutType(d.data)) { // callback here } }); }); }; c3_chart_internal_fn.unexpandArc = function (targetIds) { var $$ = this; if ($$.transiting) { return; } targetIds = $$.mapToTargetIds(targetIds); $$.svg.selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)).selectAll('path') .transition().duration(function(d) { return $$.expandDuration(d.data.id); }) .attr("d", $$.svgArc); $$.svg.selectAll('.' + CLASS.arc) .style("opacity", 1); }; c3_chart_internal_fn.expandDuration = function (id) { var $$ = this, config = $$.config; if ($$.isDonutType(id)) { return config.donut_expand_duration; } else if ($$.isGaugeType(id)) { return config.gauge_expand_duration; } else if ($$.isPieType(id)) { return config.pie_expand_duration; } else { return 50; } }; c3_chart_internal_fn.shouldExpand = function (id) { var $$ = this, config = $$.config; return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand); }; c3_chart_internal_fn.shouldShowArcLabel = function () { var $$ = this, config = $$.config, shouldShow = true; if ($$.hasType('donut')) { shouldShow = config.donut_label_show; } else if ($$.hasType('pie')) { shouldShow = config.pie_label_show; } // when gauge, always true return shouldShow; }; c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) { var $$ = this, config = $$.config, threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold; return ratio >= threshold; }; c3_chart_internal_fn.getArcLabelFormat = function () { var $$ = this, config = $$.config, format = config.pie_label_format; if ($$.hasType('gauge')) { format = config.gauge_label_format; } else if ($$.hasType('donut')) { format = config.donut_label_format; } return format; }; c3_chart_internal_fn.getArcTitle = function () { var $$ = this; return $$.hasType('donut') ? $$.config.donut_title : ""; }; c3_chart_internal_fn.updateTargetsForArc = function (targets) { var $$ = this, main = $$.main, mainPieUpdate, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$), classFocus = $$.classFocus.bind($$); mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) .data($$.pie(targets)) .attr("class", function (d) { return classChartArc(d) + classFocus(d.data); }); mainPieEnter = mainPieUpdate.enter().append("g") .attr("class", classChartArc); mainPieEnter.append('g') .attr('class', classArcs); mainPieEnter.append("text") .attr("dy", $$.hasType('gauge') ? "-.1em" : ".35em") .style("opacity", 0) .style("text-anchor", "middle") .style("pointer-events", "none"); // MEMO: can not keep same color..., but not bad to update color in redraw //mainPieUpdate.exit().remove(); }; c3_chart_internal_fn.initArc = function () { var $$ = this; $$.arcs = $$.main.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartArcs) .attr("transform", $$.getTranslate('arc')); $$.arcs.append('text') .attr('class', CLASS.chartArcsTitle) .style("text-anchor", "middle") .text($$.getArcTitle()); }; c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, mainArc; mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) .data($$.arcData.bind($$)); mainArc.enter().append('path') .attr("class", $$.classArc.bind($$)) .style("fill", function (d) { return $$.color(d.data); }) .style("cursor", function (d) { return config.interaction_enabled && config.data_selection_isselectable(d) ? "pointer" : null; }) .style("opacity", 0) .each(function (d) { if ($$.isGaugeType(d.data)) { d.startAngle = d.endAngle = config.gauge_startingAngle; } this._current = d; }); mainArc .attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; }) .style("opacity", function (d) { return d === this._current ? 0 : 1; }) .on('mouseover', config.interaction_enabled ? function (d) { var updated, arcData; if ($$.transiting) { // skip while transiting return; } updated = $$.updateAngle(d); if (updated) { arcData = $$.convertToArcData(updated); // transitions $$.expandArc(updated.data.id); $$.api.focus(updated.data.id); $$.toggleFocusLegend(updated.data.id, true); $$.config.data_onmouseover(arcData, this); } } : null) .on('mousemove', config.interaction_enabled ? function (d) { var updated = $$.updateAngle(d), arcData, selectedData; if (updated) { arcData = $$.convertToArcData(updated), selectedData = [arcData]; $$.showTooltip(selectedData, this); } } : null) .on('mouseout', config.interaction_enabled ? function (d) { var updated, arcData; if ($$.transiting) { // skip while transiting return; } updated = $$.updateAngle(d); if (updated) { arcData = $$.convertToArcData(updated); // transitions $$.unexpandArc(updated.data.id); $$.api.revert(); $$.revertLegend(); $$.hideTooltip(); $$.config.data_onmouseout(arcData, this); } } : null) .on('click', config.interaction_enabled ? function (d, i) { var updated = $$.updateAngle(d), arcData; if (updated) { arcData = $$.convertToArcData(updated); if ($$.toggleShape) { $$.toggleShape(this, arcData, i); } $$.config.data_onclick.call($$.api, arcData, this); } } : null) .each(function () { $$.transiting = true; }) .transition().duration(duration) .attrTween("d", function (d) { var updated = $$.updateAngle(d), interpolate; if (! updated) { return function () { return "M 0 0"; }; } // if (this._current === d) { // this._current = { // startAngle: Math.PI*2, // endAngle: Math.PI*2, // }; // } if (isNaN(this._current.startAngle)) { this._current.startAngle = 0; } if (isNaN(this._current.endAngle)) { this._current.endAngle = this._current.startAngle; } interpolate = d3.interpolate(this._current, updated); this._current = interpolate(0); return function (t) { var interpolated = interpolate(t); interpolated.data = d.data; // data.id will be updated by interporator return $$.getArc(interpolated, true); }; }) .attr("transform", withTransform ? "scale(1)" : "") .style("fill", function (d) { return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data.id); }) // Where gauge reading color would receive customization. .style("opacity", 1) .call($$.endall, function () { $$.transiting = false; }); mainArc.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); main.selectAll('.' + CLASS.chartArc).select('text') .style("opacity", 0) .attr('class', function (d) { return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; }) .text($$.textForArcLabel.bind($$)) .attr("transform", $$.transformForArcLabel.bind($$)) .style('font-size', function (d) { return $$.isGaugeType(d.data) ? Math.round($$.radius / 5) + 'px' : ''; }) .transition().duration(duration) .style("opacity", function (d) { return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; }); main.select('.' + CLASS.chartArcsTitle) .style("opacity", $$.hasType('donut') || $$.hasType('gauge') ? 1 : 0); if ($$.hasType('gauge')) { $$.arcs.select('.' + CLASS.chartArcsBackground) .attr("d", function () { var d = { data: [{value: config.gauge_max}], startAngle: config.gauge_startingAngle, endAngle: -1 * config.gauge_startingAngle }; return $$.getArc(d, true, true); }); $$.arcs.select('.' + CLASS.chartArcsGaugeUnit) .attr("dy", ".75em") .text(config.gauge_label_show ? config.gauge_units : ''); $$.arcs.select('.' + CLASS.chartArcsGaugeMin) .attr("dx", -1 * ($$.innerRadius + (($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2))) + "px") .attr("dy", "1.2em") .text(config.gauge_label_show ? config.gauge_min : ''); $$.arcs.select('.' + CLASS.chartArcsGaugeMax) .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2)) + "px") .attr("dy", "1.2em") .text(config.gauge_label_show ? config.gauge_max : ''); } }; c3_chart_internal_fn.initGauge = function () { var arcs = this.arcs; if (this.hasType('gauge')) { arcs.append('path') .attr("class", CLASS.chartArcsBackground); arcs.append("text") .attr("class", CLASS.chartArcsGaugeUnit) .style("text-anchor", "middle") .style("pointer-events", "none"); arcs.append("text") .attr("class", CLASS.chartArcsGaugeMin) .style("text-anchor", "middle") .style("pointer-events", "none"); arcs.append("text") .attr("class", CLASS.chartArcsGaugeMax) .style("text-anchor", "middle") .style("pointer-events", "none"); } }; c3_chart_internal_fn.getGaugeLabelHeight = function () { return this.config.gauge_label_show ? 20 : 0; }; c3_chart_internal_fn.initRegion = function () { var $$ = this; $$.region = $$.main.append('g') .attr("clip-path", $$.clipPath) .attr("class", CLASS.regions); }; c3_chart_internal_fn.updateRegion = function (duration) { var $$ = this, config = $$.config; // hide if arc type $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) .data(config.regions); $$.mainRegion.enter().append('g') .append('rect') .style("fill-opacity", 0); $$.mainRegion .attr('class', $$.classRegion.bind($$)); $$.mainRegion.exit().transition().duration(duration) .style("opacity", 0) .remove(); }; c3_chart_internal_fn.redrawRegion = function (withTransition) { var $$ = this, regions = $$.mainRegion.selectAll('rect').each(function () { // data is binded to g and it's not transferred to rect (child node) automatically, // then data of each rect has to be updated manually. // TODO: there should be more efficient way to solve this? var parentData = $$.d3.select(this.parentNode).datum(); $$.d3.select(this).datum(parentData); }), x = $$.regionX.bind($$), y = $$.regionY.bind($$), w = $$.regionWidth.bind($$), h = $$.regionHeight.bind($$); return [ (withTransition ? regions.transition() : regions) .attr("x", x) .attr("y", y) .attr("width", w) .attr("height", h) .style("fill-opacity", function (d) { return isValue(d.opacity) ? d.opacity : 0.1; }) ]; }; c3_chart_internal_fn.regionX = function (d) { var $$ = this, config = $$.config, xPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; } else { xPos = config.axis_rotated ? 0 : ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0); } return xPos; }; c3_chart_internal_fn.regionY = function (d) { var $$ = this, config = $$.config, yPos, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { yPos = config.axis_rotated ? 0 : ('end' in d ? yScale(d.end) : 0); } else { yPos = config.axis_rotated ? ('start' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) : 0) : 0; } return yPos; }; c3_chart_internal_fn.regionWidth = function (d) { var $$ = this, config = $$.config, start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { end = config.axis_rotated ? ('end' in d ? yScale(d.end) : $$.width) : $$.width; } else { end = config.axis_rotated ? $$.width : ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.width); } return end < start ? 0 : end - start; }; c3_chart_internal_fn.regionHeight = function (d) { var $$ = this, config = $$.config, start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; if (d.axis === 'y' || d.axis === 'y2') { end = config.axis_rotated ? $$.height : ('start' in d ? yScale(d.start) : $$.height); } else { end = config.axis_rotated ? ('end' in d ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) : $$.height) : $$.height; } return end < start ? 0 : end - start; }; c3_chart_internal_fn.isRegionOnX = function (d) { return !d.axis || d.axis === 'x'; }; c3_chart_internal_fn.drag = function (mouse) { var $$ = this, config = $$.config, main = $$.main, d3 = $$.d3; var sx, sy, mx, my, minX, maxX, minY, maxY; if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable if (config.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior if (!config.data_selection_multiple) { return; } // skip when single selection because drag is used for multiple selection sx = $$.dragStart[0]; sy = $$.dragStart[1]; mx = mouse[0]; my = mouse[1]; minX = Math.min(sx, mx); maxX = Math.max(sx, mx); minY = (config.data_selection_grouped) ? $$.margin.top : Math.min(sy, my); maxY = (config.data_selection_grouped) ? $$.height : Math.max(sy, my); main.select('.' + CLASS.dragarea) .attr('x', minX) .attr('y', minY) .attr('width', maxX - minX) .attr('height', maxY - minY); // TODO: binary search when multiple xs main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape) .filter(function (d) { return config.data_selection_isselectable(d); }) .each(function (d, i) { var shape = d3.select(this), isSelected = shape.classed(CLASS.SELECTED), isIncluded = shape.classed(CLASS.INCLUDED), _x, _y, _w, _h, toggle, isWithin = false, box; if (shape.classed(CLASS.circle)) { _x = shape.attr("cx") * 1; _y = shape.attr("cy") * 1; toggle = $$.togglePoint; isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; } else if (shape.classed(CLASS.bar)) { box = getPathBox(this); _x = box.x; _y = box.y; _w = box.width; _h = box.height; toggle = $$.togglePath; isWithin = !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); } else { // line/area selection not supported yet return; } if (isWithin ^ isIncluded) { shape.classed(CLASS.INCLUDED, !isIncluded); // TODO: included/unincluded callback here shape.classed(CLASS.SELECTED, !isSelected); toggle.call($$, !isSelected, shape, d, i); } }); }; c3_chart_internal_fn.dragstart = function (mouse) { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.dragStart = mouse; $$.main.select('.' + CLASS.chart).append('rect') .attr('class', CLASS.dragarea) .style('opacity', 0.1); $$.dragging = true; }; c3_chart_internal_fn.dragend = function () { var $$ = this, config = $$.config; if ($$.hasArcType()) { return; } if (! config.data_selection_enabled) { return; } // do nothing if not selectable $$.main.select('.' + CLASS.dragarea) .transition().duration(100) .style('opacity', 0) .remove(); $$.main.selectAll('.' + CLASS.shape) .classed(CLASS.INCLUDED, false); $$.dragging = false; }; c3_chart_internal_fn.selectPoint = function (target, d, i) { var $$ = this, config = $$.config, cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), r = $$.pointSelectR.bind($$); config.data_onselected.call($$.api, d, target.node()); // add selected-circle on low layer g $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .data([d]) .enter().append('circle') .attr("class", function () { return $$.generateClass(CLASS.selectedCircle, i); }) .attr("cx", cx) .attr("cy", cy) .attr("stroke", function () { return $$.color(d); }) .attr("r", function (d) { return $$.pointSelectR(d) * 1.4; }) .transition().duration(100) .attr("r", r); }; c3_chart_internal_fn.unselectPoint = function (target, d, i) { var $$ = this; $$.config.data_onunselected.call($$.api, d, target.node()); // remove selected-circle from low layer g $$.main.select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)).selectAll('.' + CLASS.selectedCircle + '-' + i) .transition().duration(100).attr('r', 0) .remove(); }; c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); }; c3_chart_internal_fn.selectPath = function (target, d) { var $$ = this; $$.config.data_onselected.call($$, d, target.node()); if ($$.config.interaction_brighten) { target.transition().duration(100) .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); } }; c3_chart_internal_fn.unselectPath = function (target, d) { var $$ = this; $$.config.data_onunselected.call($$, d, target.node()); if ($$.config.interaction_brighten) { target.transition().duration(100) .style("fill", function () { return $$.color(d); }); } }; c3_chart_internal_fn.togglePath = function (selected, target, d, i) { selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); }; c3_chart_internal_fn.getToggle = function (that, d) { var $$ = this, toggle; if (that.nodeName === 'circle') { if ($$.isStepType(d)) { // circle is hidden in step chart, so treat as within the click area toggle = function () {}; // TODO: how to select step chart? } else { toggle = $$.togglePoint; } } else if (that.nodeName === 'path') { toggle = $$.togglePath; } return toggle; }; c3_chart_internal_fn.toggleShape = function (that, d, i) { var $$ = this, d3 = $$.d3, config = $$.config, shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), toggle = $$.getToggle(that, d).bind($$); if (config.data_selection_enabled && config.data_selection_isselectable(d)) { if (!config.data_selection_multiple) { $$.main.selectAll('.' + CLASS.shapes + (config.data_selection_grouped ? $$.getTargetSelectorSuffix(d.id) : "")).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this); if (shape.classed(CLASS.SELECTED)) { toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } }); } shape.classed(CLASS.SELECTED, !isSelected); toggle(!isSelected, shape, d, i); } }; c3_chart_internal_fn.initBrush = function () { var $$ = this, d3 = $$.d3; $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); $$.brush.update = function () { if ($$.context) { $$.context.select('.' + CLASS.brush).call(this); } return this; }; $$.brush.scale = function (scale) { return $$.config.axis_rotated ? this.y(scale) : this.x(scale); }; }; c3_chart_internal_fn.initSubchart = function () { var $$ = this, config = $$.config, context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')), visibility = config.subchart_show ? 'visible' : 'hidden'; context.style('visibility', visibility); // Define g for chart area context.append('g') .attr("clip-path", $$.clipPathForSubchart) .attr('class', CLASS.chart); // Define g for bar chart area context.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartBars); // Define g for line chart area context.select('.' + CLASS.chart).append("g") .attr("class", CLASS.chartLines); // Add extent rect for Brush context.append("g") .attr("clip-path", $$.clipPath) .attr("class", CLASS.brush) .call($$.brush); // ATTENTION: This must be called AFTER chart added // Add Axis $$.axes.subx = context.append("g") .attr("class", CLASS.axisX) .attr("transform", $$.getTranslate('subx')) .attr("clip-path", config.axis_rotated ? "" : $$.clipPathForXAxis) .style("visibility", config.subchart_axis_x_show ? visibility : 'hidden'); }; c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { var $$ = this, context = $$.context, config = $$.config, contextLineEnter, contextLineUpdate, contextBarEnter, contextBarUpdate, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); if (config.subchart_show) { //-- Bar --// contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) .data(targets) .attr('class', classChartBar); contextBarEnter = contextBarUpdate.enter().append('g') .style('opacity', 0) .attr('class', classChartBar); // Bars for each data contextBarEnter.append('g') .attr("class", classBars); //-- Line --// contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) .data(targets) .attr('class', classChartLine); contextLineEnter = contextLineUpdate.enter().append('g') .style('opacity', 0) .attr('class', classChartLine); // Lines for each data contextLineEnter.append("g") .attr("class", classLines); // Area contextLineEnter.append("g") .attr("class", classAreas); //-- Brush --// context.selectAll('.' + CLASS.brush + ' rect') .attr(config.axis_rotated ? "width" : "height", config.axis_rotated ? $$.width2 : $$.height2); } }; c3_chart_internal_fn.updateBarForSubchart = function (durationForExit) { var $$ = this; $$.contextBar = $$.context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) .data($$.barData.bind($$)); $$.contextBar.enter().append('path') .attr("class", $$.classBar.bind($$)) .style("stroke", 'none') .style("fill", $$.color); $$.contextBar .style("opacity", $$.initialOpacity.bind($$)); $$.contextBar.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { (withTransition ? this.contextBar.transition(Math.random().toString()).duration(duration) : this.contextBar) .attr('d', drawBarOnSub) .style('opacity', 1); }; c3_chart_internal_fn.updateLineForSubchart = function (durationForExit) { var $$ = this; $$.contextLine = $$.context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) .data($$.lineData.bind($$)); $$.contextLine.enter().append('path') .attr('class', $$.classLine.bind($$)) .style('stroke', $$.color); $$.contextLine .style("opacity", $$.initialOpacity.bind($$)); $$.contextLine.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { (withTransition ? this.contextLine.transition(Math.random().toString()).duration(duration) : this.contextLine) .attr("d", drawLineOnSub) .style('opacity', 1); }; c3_chart_internal_fn.updateAreaForSubchart = function (durationForExit) { var $$ = this, d3 = $$.d3; $$.contextArea = $$.context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) .data($$.lineData.bind($$)); $$.contextArea.enter().append('path') .attr("class", $$.classArea.bind($$)) .style("fill", $$.color) .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); $$.contextArea .style("opacity", 0); $$.contextArea.exit().transition().duration(durationForExit) .style('opacity', 0) .remove(); }; c3_chart_internal_fn.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { (withTransition ? this.contextArea.transition(Math.random().toString()).duration(duration) : this.contextArea) .attr("d", drawAreaOnSub) .style("fill", this.color) .style("opacity", this.orgAreaOpacity); }; c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { var $$ = this, d3 = $$.d3, config = $$.config, drawAreaOnSub, drawBarOnSub, drawLineOnSub; $$.context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); // subchart if (config.subchart_show) { // reflect main chart to extent on subchart if zoomed if (d3.event && d3.event.type === 'zoom') { $$.brush.extent($$.x.orgDomain()).update(); } // update subchart elements if needed if (withSubchart) { // extent rect if (!$$.brush.empty()) { $$.brush.extent($$.x.orgDomain()).update(); } // setup drawer - MEMO: this must be called after axis updated drawAreaOnSub = $$.generateDrawArea(areaIndices, true); drawBarOnSub = $$.generateDrawBar(barIndices, true); drawLineOnSub = $$.generateDrawLine(lineIndices, true); $$.updateBarForSubchart(duration); $$.updateLineForSubchart(duration); $$.updateAreaForSubchart(duration); $$.redrawBarForSubchart(drawBarOnSub, duration, duration); $$.redrawLineForSubchart(drawLineOnSub, duration, duration); $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); } } }; c3_chart_internal_fn.redrawForBrush = function () { var $$ = this, x = $$.x; $$.redraw({ withTransition: false, withY: $$.config.zoom_rescale, withSubchart: false, withUpdateXDomain: true, withDimension: false }); $$.config.subchart_onbrush.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.transformContext = function (withTransition, transitions) { var $$ = this, subXAxis; if (transitions && transitions.axisSubX) { subXAxis = transitions.axisSubX; } else { subXAxis = $$.context.select('.' + CLASS.axisX); if (withTransition) { subXAxis = subXAxis.transition(); } } $$.context.attr("transform", $$.getTranslate('context')); subXAxis.attr("transform", $$.getTranslate('subx')); }; c3_chart_internal_fn.getDefaultExtent = function () { var $$ = this, config = $$.config, extent = isFunction(config.axis_x_extent) ? config.axis_x_extent($$.getXDomain($$.data.targets)) : config.axis_x_extent; if ($$.isTimeSeries()) { extent = [$$.parseDate(extent[0]), $$.parseDate(extent[1])]; } return extent; }; c3_chart_internal_fn.initZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, startEvent; $$.zoom = d3.behavior.zoom() .on("zoomstart", function () { startEvent = d3.event.sourceEvent; $$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null; config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); }) .on("zoom", function () { $$.redrawForZoom.call($$); }) .on('zoomend', function () { var event = d3.event.sourceEvent; // if click, do nothing. otherwise, click interaction will be canceled. if (event && startEvent.clientX === event.clientX && startEvent.clientY === event.clientY) { return; } $$.redrawEventRect(); $$.updateZoom(); config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); }); $$.zoom.scale = function (scale) { return config.axis_rotated ? this.y(scale) : this.x(scale); }; $$.zoom.orgScaleExtent = function () { var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; }; $$.zoom.updateScaleExtent = function () { var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.getZoomDomain()), extent = this.orgScaleExtent(); this.scaleExtent([extent[0] * ratio, extent[1] * ratio]); return this; }; }; c3_chart_internal_fn.getZoomDomain = function () { var $$ = this, config = $$.config, d3 = $$.d3, min = d3.min([$$.orgXDomain[0], config.zoom_x_min]), max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); return [min, max]; }; c3_chart_internal_fn.updateZoom = function () { var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; $$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null); $$.main.selectAll('.' + CLASS.eventRect).call(z).on("dblclick.zoom", null); }; c3_chart_internal_fn.redrawForZoom = function () { var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x; if (!config.zoom_enabled) { return; } if ($$.filterTargetsToShow($$.data.targets).length === 0) { return; } if (d3.event.sourceEvent.type === 'mousemove' && zoom.altDomain) { x.domain(zoom.altDomain); zoom.scale(x).updateScaleExtent(); return; } if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); } $$.redraw({ withTransition: false, withY: config.zoom_rescale, withSubchart: false, withEventRect: false, withDimension: false }); if (d3.event.sourceEvent.type === 'mousemove') { $$.cancelClick = true; } config.zoom_onzoom.call($$.api, x.orgDomain()); }; c3_chart_internal_fn.generateColor = function () { var $$ = this, config = $$.config, d3 = $$.d3, colors = config.data_colors, pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), callback = config.data_color, ids = []; return function (d) { var id = d.id || (d.data && d.data.id) || d, color; // if callback function is provided if (colors[id] instanceof Function) { color = colors[id](d); } // if specified, choose that color else if (colors[id]) { color = colors[id]; } // if not specified, choose from pattern else { if (ids.indexOf(id) < 0) { ids.push(id); } color = pattern[ids.indexOf(id) % pattern.length]; colors[id] = color; } return callback instanceof Function ? callback(color, d) : color; }; }; c3_chart_internal_fn.generateLevelColor = function () { var $$ = this, config = $$.config, colors = config.color_pattern, threshold = config.color_threshold, asValue = threshold.unit === 'value', values = threshold.values && threshold.values.length ? threshold.values : [], max = threshold.max || 100; return notEmpty(config.color_threshold) ? function (value) { var i, v, color = colors[colors.length - 1]; for (i = 0; i < values.length; i++) { v = asValue ? value : (value * 100 / max); if (v < values[i]) { color = colors[i]; break; } } return color; } : null; }; c3_chart_internal_fn.getYFormat = function (forArc) { var $$ = this, formatForY = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, formatForY2 = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; return function (v, ratio, id) { var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; return format.call($$, v, ratio); }; }; c3_chart_internal_fn.yFormat = function (v) { var $$ = this, config = $$.config, format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.y2Format = function (v) { var $$ = this, config = $$.config, format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; return format(v); }; c3_chart_internal_fn.defaultValueFormat = function (v) { return isValue(v) ? +v : ""; }; c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) { return (ratio * 100).toFixed(1) + '%'; }; c3_chart_internal_fn.dataLabelFormat = function (targetId) { var $$ = this, data_labels = $$.config.data_labels, format, defaultFormat = function (v) { return isValue(v) ? +v : ""; }; // find format according to axis id if (typeof data_labels.format === 'function') { format = data_labels.format; } else if (typeof data_labels.format === 'object') { if (data_labels.format[targetId]) { format = data_labels.format[targetId] === true ? defaultFormat : data_labels.format[targetId]; } else { format = function () { return ''; }; } } else { format = defaultFormat; } return format; }; c3_chart_internal_fn.hasCaches = function (ids) { for (var i = 0; i < ids.length; i++) { if (! (ids[i] in this.cache)) { return false; } } return true; }; c3_chart_internal_fn.addCache = function (id, target) { this.cache[id] = this.cloneTarget(target); }; c3_chart_internal_fn.getCaches = function (ids) { var targets = [], i; for (i = 0; i < ids.length; i++) { if (ids[i] in this.cache) { targets.push(this.cloneTarget(this.cache[ids[i]])); } } return targets; }; var CLASS = c3_chart_internal_fn.CLASS = { target: 'c3-target', chart: 'c3-chart', chartLine: 'c3-chart-line', chartLines: 'c3-chart-lines', chartBar: 'c3-chart-bar', chartBars: 'c3-chart-bars', chartText: 'c3-chart-text', chartTexts: 'c3-chart-texts', chartArc: 'c3-chart-arc', chartArcs: 'c3-chart-arcs', chartArcsTitle: 'c3-chart-arcs-title', chartArcsBackground: 'c3-chart-arcs-background', chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', selectedCircle: 'c3-selected-circle', selectedCircles: 'c3-selected-circles', eventRect: 'c3-event-rect', eventRects: 'c3-event-rects', eventRectsSingle: 'c3-event-rects-single', eventRectsMultiple: 'c3-event-rects-multiple', zoomRect: 'c3-zoom-rect', brush: 'c3-brush', focused: 'c3-focused', defocused: 'c3-defocused', region: 'c3-region', regions: 'c3-regions', title: 'c3-title', tooltipContainer: 'c3-tooltip-container', tooltip: 'c3-tooltip', tooltipName: 'c3-tooltip-name', shape: 'c3-shape', shapes: 'c3-shapes', line: 'c3-line', lines: 'c3-lines', bar: 'c3-bar', bars: 'c3-bars', circle: 'c3-circle', circles: 'c3-circles', arc: 'c3-arc', arcs: 'c3-arcs', area: 'c3-area', areas: 'c3-areas', empty: 'c3-empty', text: 'c3-text', texts: 'c3-texts', gaugeValue: 'c3-gauge-value', grid: 'c3-grid', gridLines: 'c3-grid-lines', xgrid: 'c3-xgrid', xgrids: 'c3-xgrids', xgridLine: 'c3-xgrid-line', xgridLines: 'c3-xgrid-lines', xgridFocus: 'c3-xgrid-focus', ygrid: 'c3-ygrid', ygrids: 'c3-ygrids', ygridLine: 'c3-ygrid-line', ygridLines: 'c3-ygrid-lines', axis: 'c3-axis', axisX: 'c3-axis-x', axisXLabel: 'c3-axis-x-label', axisY: 'c3-axis-y', axisYLabel: 'c3-axis-y-label', axisY2: 'c3-axis-y2', axisY2Label: 'c3-axis-y2-label', legendBackground: 'c3-legend-background', legendItem: 'c3-legend-item', legendItemEvent: 'c3-legend-item-event', legendItemTile: 'c3-legend-item-tile', legendItemHidden: 'c3-legend-item-hidden', legendItemFocused: 'c3-legend-item-focused', dragarea: 'c3-dragarea', EXPANDED: '_expanded_', SELECTED: '_selected_', INCLUDED: '_included_' }; c3_chart_internal_fn.generateClass = function (prefix, targetId) { return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); }; c3_chart_internal_fn.classText = function (d) { return this.generateClass(CLASS.text, d.index); }; c3_chart_internal_fn.classTexts = function (d) { return this.generateClass(CLASS.texts, d.id); }; c3_chart_internal_fn.classShape = function (d) { return this.generateClass(CLASS.shape, d.index); }; c3_chart_internal_fn.classShapes = function (d) { return this.generateClass(CLASS.shapes, d.id); }; c3_chart_internal_fn.classLine = function (d) { return this.classShape(d) + this.generateClass(CLASS.line, d.id); }; c3_chart_internal_fn.classLines = function (d) { return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); }; c3_chart_internal_fn.classCircle = function (d) { return this.classShape(d) + this.generateClass(CLASS.circle, d.index); }; c3_chart_internal_fn.classCircles = function (d) { return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); }; c3_chart_internal_fn.classBar = function (d) { return this.classShape(d) + this.generateClass(CLASS.bar, d.index); }; c3_chart_internal_fn.classBars = function (d) { return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); }; c3_chart_internal_fn.classArc = function (d) { return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); }; c3_chart_internal_fn.classArcs = function (d) { return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); }; c3_chart_internal_fn.classArea = function (d) { return this.classShape(d) + this.generateClass(CLASS.area, d.id); }; c3_chart_internal_fn.classAreas = function (d) { return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); }; c3_chart_internal_fn.classRegion = function (d, i) { return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : ''); }; c3_chart_internal_fn.classEvent = function (d) { return this.generateClass(CLASS.eventRect, d.index); }; c3_chart_internal_fn.classTarget = function (id) { var $$ = this; var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; if (additionalClassSuffix) { additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; } return $$.generateClass(CLASS.target, id) + additionalClass; }; c3_chart_internal_fn.classFocus = function (d) { return this.classFocused(d) + this.classDefocused(d); }; c3_chart_internal_fn.classFocused = function (d) { return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : ''); }; c3_chart_internal_fn.classDefocused = function (d) { return ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : ''); }; c3_chart_internal_fn.classChartText = function (d) { return CLASS.chartText + this.classTarget(d.id); }; c3_chart_internal_fn.classChartLine = function (d) { return CLASS.chartLine + this.classTarget(d.id); }; c3_chart_internal_fn.classChartBar = function (d) { return CLASS.chartBar + this.classTarget(d.id); }; c3_chart_internal_fn.classChartArc = function (d) { return CLASS.chartArc + this.classTarget(d.data.id); }; c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, '-') : ''; }; c3_chart_internal_fn.selectorTarget = function (id, prefix) { return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorTargets = function (ids, prefix) { var $$ = this; ids = ids || []; return ids.length ? ids.map(function (id) { return $$.selectorTarget(id, prefix); }) : null; }; c3_chart_internal_fn.selectorLegend = function (id) { return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); }; c3_chart_internal_fn.selectorLegends = function (ids) { var $$ = this; return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null; }; var isValue = c3_chart_internal_fn.isValue = function (v) { return v || v === 0; }, isFunction = c3_chart_internal_fn.isFunction = function (o) { return typeof o === 'function'; }, isString = c3_chart_internal_fn.isString = function (o) { return typeof o === 'string'; }, isUndefined = c3_chart_internal_fn.isUndefined = function (v) { return typeof v === 'undefined'; }, isDefined = c3_chart_internal_fn.isDefined = function (v) { return typeof v !== 'undefined'; }, ceil10 = c3_chart_internal_fn.ceil10 = function (v) { return Math.ceil(v / 10) * 10; }, asHalfPixel = c3_chart_internal_fn.asHalfPixel = function (n) { return Math.ceil(n) + 0.5; }, diffDomain = c3_chart_internal_fn.diffDomain = function (d) { return d[1] - d[0]; }, isEmpty = c3_chart_internal_fn.isEmpty = function (o) { return typeof o === 'undefined' || o === null || (isString(o) && o.length === 0) || (typeof o === 'object' && Object.keys(o).length === 0); }, notEmpty = c3_chart_internal_fn.notEmpty = function (o) { return !c3_chart_internal_fn.isEmpty(o); }, getOption = c3_chart_internal_fn.getOption = function (options, key, defaultValue) { return isDefined(options[key]) ? options[key] : defaultValue; }, hasValue = c3_chart_internal_fn.hasValue = function (dict, value) { var found = false; Object.keys(dict).forEach(function (key) { if (dict[key] === value) { found = true; } }); return found; }, sanitise = c3_chart_internal_fn.sanitise = function (str) { return typeof str === 'string' ? str.replace(/</g, '&lt;').replace(/>/g, '&gt;') : str; }, getPathBox = c3_chart_internal_fn.getPathBox = function (path) { var box = path.getBoundingClientRect(), items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], minX = items[0].x, minY = Math.min(items[0].y, items[1].y); return {x: minX, y: minY, width: box.width, height: box.height}; }; c3_chart_fn.focus = function (targetIds) { var $$ = this.internal, candidates; targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))), this.revert(); this.defocus(); candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); if ($$.hasArcType()) { $$.expandArc(targetIds); } $$.toggleFocusLegend(targetIds, true); $$.focusedTargetIds = targetIds; $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); }; c3_chart_fn.defocus = function (targetIds) { var $$ = this.internal, candidates; targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))), candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); if ($$.hasArcType()) { $$.unexpandArc(targetIds); } $$.toggleFocusLegend(targetIds, false); $$.focusedTargetIds = $$.focusedTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); $$.defocusedTargetIds = targetIds; }; c3_chart_fn.revert = function (targetIds) { var $$ = this.internal, candidates; targetIds = $$.mapToTargetIds(targetIds); candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); if ($$.hasArcType()) { $$.unexpandArc(targetIds); } if ($$.config.legend_show) { $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); $$.legend.selectAll($$.selectorLegends(targetIds)) .filter(function () { return $$.d3.select(this).classed(CLASS.legendItemFocused); }) .classed(CLASS.legendItemFocused, false); } $$.focusedTargetIds = []; $$.defocusedTargetIds = []; }; c3_chart_fn.show = function (targetIds, options) { var $$ = this.internal, targets; targetIds = $$.mapToTargetIds(targetIds); options = options || {}; $$.removeHiddenTargetIds(targetIds); targets = $$.svg.selectAll($$.selectorTargets(targetIds)); targets.transition() .style('opacity', 1, 'important') .call($$.endall, function () { targets.style('opacity', null).style('opacity', 1); }); if (options.withLegend) { $$.showLegend(targetIds); } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); }; c3_chart_fn.hide = function (targetIds, options) { var $$ = this.internal, targets; targetIds = $$.mapToTargetIds(targetIds); options = options || {}; $$.addHiddenTargetIds(targetIds); targets = $$.svg.selectAll($$.selectorTargets(targetIds)); targets.transition() .style('opacity', 0, 'important') .call($$.endall, function () { targets.style('opacity', null).style('opacity', 0); }); if (options.withLegend) { $$.hideLegend(targetIds); } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); }; c3_chart_fn.toggle = function (targetIds, options) { var that = this, $$ = this.internal; $$.mapToTargetIds(targetIds).forEach(function (targetId) { $$.isTargetToShow(targetId) ? that.hide(targetId, options) : that.show(targetId, options); }); }; c3_chart_fn.zoom = function (domain) { var $$ = this.internal; if (domain) { if ($$.isTimeSeries()) { domain = domain.map(function (x) { return $$.parseDate(x); }); } $$.brush.extent(domain); $$.redraw({withUpdateXDomain: true, withY: $$.config.zoom_rescale}); $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); } return $$.brush.extent(); }; c3_chart_fn.zoom.enable = function (enabled) { var $$ = this.internal; $$.config.zoom_enabled = enabled; $$.updateAndRedraw(); }; c3_chart_fn.unzoom = function () { var $$ = this.internal; $$.brush.clear().update(); $$.redraw({withUpdateXDomain: true}); }; c3_chart_fn.zoom.max = function (max) { var $$ = this.internal, config = $$.config, d3 = $$.d3; if (max === 0 || max) { config.zoom_x_max = d3.max([$$.orgXDomain[1], max]); } else { return config.zoom_x_max; } }; c3_chart_fn.zoom.min = function (min) { var $$ = this.internal, config = $$.config, d3 = $$.d3; if (min === 0 || min) { config.zoom_x_min = d3.min([$$.orgXDomain[0], min]); } else { return config.zoom_x_min; } }; c3_chart_fn.zoom.range = function (range) { if (arguments.length) { if (isDefined(range.max)) { this.domain.max(range.max); } if (isDefined(range.min)) { this.domain.min(range.min); } } else { return { max: this.domain.max(), min: this.domain.min() }; } }; c3_chart_fn.load = function (args) { var $$ = this.internal, config = $$.config; // update xs if specified if (args.xs) { $$.addXs(args.xs); } // update names if exists if ('names' in args) { c3_chart_fn.data.names.bind(this)(args.names); } // update classes if exists if ('classes' in args) { Object.keys(args.classes).forEach(function (id) { config.data_classes[id] = args.classes[id]; }); } // update categories if exists if ('categories' in args && $$.isCategorized()) { config.axis_x_categories = args.categories; } // update axes if exists if ('axes' in args) { Object.keys(args.axes).forEach(function (id) { config.data_axes[id] = args.axes[id]; }); } // update colors if exists if ('colors' in args) { Object.keys(args.colors).forEach(function (id) { config.data_colors[id] = args.colors[id]; }); } // use cache if exists if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { $$.load($$.getCaches(args.cacheIds), args.done); return; } // unload if needed if ('unload' in args) { // TODO: do not unload if target will load (included in url/rows/columns) $$.unload($$.mapToTargetIds((typeof args.unload === 'boolean' && args.unload) ? null : args.unload), function () { $$.loadFromArgs(args); }); } else { $$.loadFromArgs(args); } }; c3_chart_fn.unload = function (args) { var $$ = this.internal; args = args || {}; if (args instanceof Array) { args = {ids: args}; } else if (typeof args === 'string') { args = {ids: [args]}; } $$.unload($$.mapToTargetIds(args.ids), function () { $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); if (args.done) { args.done(); } }); }; c3_chart_fn.flow = function (args) { var $$ = this.internal, targets, data, notfoundIds = [], orgDataCount = $$.getMaxDataCount(), dataCount, domain, baseTarget, baseValue, length = 0, tail = 0, diff, to; if (args.json) { data = $$.convertJsonToData(args.json, args.keys); } else if (args.rows) { data = $$.convertRowsToData(args.rows); } else if (args.columns) { data = $$.convertColumnsToData(args.columns); } else { return; } targets = $$.convertDataToTargets(data, true); // Update/Add data $$.data.targets.forEach(function (t) { var found = false, i, j; for (i = 0; i < targets.length; i++) { if (t.id === targets[i].id) { found = true; if (t.values[t.values.length - 1]) { tail = t.values[t.values.length - 1].index + 1; } length = targets[i].values.length; for (j = 0; j < length; j++) { targets[i].values[j].index = tail + j; if (!$$.isTimeSeries()) { targets[i].values[j].x = tail + j; } } t.values = t.values.concat(targets[i].values); targets.splice(i, 1); break; } } if (!found) { notfoundIds.push(t.id); } }); // Append null for not found targets $$.data.targets.forEach(function (t) { var i, j; for (i = 0; i < notfoundIds.length; i++) { if (t.id === notfoundIds[i]) { tail = t.values[t.values.length - 1].index + 1; for (j = 0; j < length; j++) { t.values.push({ id: t.id, index: tail + j, x: $$.isTimeSeries() ? $$.getOtherTargetX(tail + j) : tail + j, value: null }); } } } }); // Generate null values for new target if ($$.data.targets.length) { targets.forEach(function (t) { var i, missing = []; for (i = $$.data.targets[0].values[0].index; i < tail; i++) { missing.push({ id: t.id, index: i, x: $$.isTimeSeries() ? $$.getOtherTargetX(i) : i, value: null }); } t.values.forEach(function (v) { v.index += tail; if (!$$.isTimeSeries()) { v.x += tail; } }); t.values = missing.concat(t.values); }); } $$.data.targets = $$.data.targets.concat(targets); // add remained // check data count because behavior needs to change when it's only one dataCount = $$.getMaxDataCount(); baseTarget = $$.data.targets[0]; baseValue = baseTarget.values[0]; // Update length to flow if needed if (isDefined(args.to)) { length = 0; to = $$.isTimeSeries() ? $$.parseDate(args.to) : args.to; baseTarget.values.forEach(function (v) { if (v.x < to) { length++; } }); } else if (isDefined(args.length)) { length = args.length; } // If only one data, update the domain to flow from left edge of the chart if (!orgDataCount) { if ($$.isTimeSeries()) { if (baseTarget.values.length > 1) { diff = baseTarget.values[baseTarget.values.length - 1].x - baseValue.x; } else { diff = baseValue.x - $$.getXDomain($$.data.targets)[0]; } } else { diff = 1; } domain = [baseValue.x - diff, baseValue.x]; $$.updateXDomain(null, true, true, false, domain); } else if (orgDataCount === 1) { if ($$.isTimeSeries()) { diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; $$.updateXDomain(null, true, true, false, domain); } } // Set targets $$.updateTargets($$.data.targets); // Redraw with new targets $$.redraw({ flow: { index: baseValue.index, length: length, duration: isValue(args.duration) ? args.duration : $$.config.transition_duration, done: args.done, orgDataCount: orgDataCount, }, withLegend: true, withTransition: orgDataCount > 1, withTrimXDomain: false, withUpdateXAxis: true, }); }; c3_chart_internal_fn.generateFlow = function (args) { var $$ = this, config = $$.config, d3 = $$.d3; return function () { var targets = args.targets, flow = args.flow, drawBar = args.drawBar, drawLine = args.drawLine, drawArea = args.drawArea, cx = args.cx, cy = args.cy, xv = args.xv, xForText = args.xForText, yForText = args.yForText, duration = args.duration; var translateX, scaleX = 1, transform, flowIndex = flow.index, flowLength = flow.length, flowStart = $$.getValueOnIndex($$.data.targets[0].values, flowIndex), flowEnd = $$.getValueOnIndex($$.data.targets[0].values, flowIndex + flowLength), orgDomain = $$.x.domain(), domain, durationForFlow = flow.duration || duration, done = flow.done || function () {}, wait = $$.generateWait(); var xgrid = $$.xgrid || d3.selectAll([]), xgridLines = $$.xgridLines || d3.selectAll([]), mainRegion = $$.mainRegion || d3.selectAll([]), mainText = $$.mainText || d3.selectAll([]), mainBar = $$.mainBar || d3.selectAll([]), mainLine = $$.mainLine || d3.selectAll([]), mainArea = $$.mainArea || d3.selectAll([]), mainCircle = $$.mainCircle || d3.selectAll([]); // set flag $$.flowing = true; // remove head data after rendered $$.data.targets.forEach(function (d) { d.values.splice(0, flowLength); }); // update x domain to generate axis elements for flow domain = $$.updateXDomain(targets, true, true); // update elements related to x scale if ($$.updateXGrid) { $$.updateXGrid(true); } // generate transform to flow if (!flow.orgDataCount) { // if empty if ($$.data.targets[0].values.length !== 1) { translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); } else { if ($$.isTimeSeries()) { flowStart = $$.getValueOnIndex($$.data.targets[0].values, 0); flowEnd = $$.getValueOnIndex($$.data.targets[0].values, $$.data.targets[0].values.length - 1); translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); } else { translateX = diffDomain(domain) / 2; } } } else if (flow.orgDataCount === 1 || (flowStart && flowStart.x) === (flowEnd && flowEnd.x)) { translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); } else { if ($$.isTimeSeries()) { translateX = ($$.x(orgDomain[0]) - $$.x(domain[0])); } else { translateX = ($$.x(flowStart.x) - $$.x(flowEnd.x)); } } scaleX = (diffDomain(orgDomain) / diffDomain(domain)); transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; $$.hideXGridFocus(); d3.transition().ease('linear').duration(durationForFlow).each(function () { wait.add($$.axes.x.transition().call($$.xAxis)); wait.add(mainBar.transition().attr('transform', transform)); wait.add(mainLine.transition().attr('transform', transform)); wait.add(mainArea.transition().attr('transform', transform)); wait.add(mainCircle.transition().attr('transform', transform)); wait.add(mainText.transition().attr('transform', transform)); wait.add(mainRegion.filter($$.isRegionOnX).transition().attr('transform', transform)); wait.add(xgrid.transition().attr('transform', transform)); wait.add(xgridLines.transition().attr('transform', transform)); }) .call(wait, function () { var i, shapes = [], texts = [], eventRects = []; // remove flowed elements if (flowLength) { for (i = 0; i < flowLength; i++) { shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); texts.push('.' + CLASS.text + '-' + (flowIndex + i)); eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); } $$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); $$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); $$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); $$.svg.select('.' + CLASS.xgrid).remove(); } // draw again for removing flowed elements and reverting attr xgrid .attr('transform', null) .attr($$.xgridAttr); xgridLines .attr('transform', null); xgridLines.select('line') .attr("x1", config.axis_rotated ? 0 : xv) .attr("x2", config.axis_rotated ? $$.width : xv); xgridLines.select('text') .attr("x", config.axis_rotated ? $$.width : 0) .attr("y", xv); mainBar .attr('transform', null) .attr("d", drawBar); mainLine .attr('transform', null) .attr("d", drawLine); mainArea .attr('transform', null) .attr("d", drawArea); mainCircle .attr('transform', null) .attr("cx", cx) .attr("cy", cy); mainText .attr('transform', null) .attr('x', xForText) .attr('y', yForText) .style('fill-opacity', $$.opacityForText.bind($$)); mainRegion .attr('transform', null); mainRegion.select('rect').filter($$.isRegionOnX) .attr("x", $$.regionX.bind($$)) .attr("width", $$.regionWidth.bind($$)); if (config.interaction_enabled) { $$.redrawEventRect(); } // callback for end of flow done(); $$.flowing = false; }); }; }; c3_chart_fn.selected = function (targetId) { var $$ = this.internal, d3 = $$.d3; return d3.merge( $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) .filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) ); }; c3_chart_fn.select = function (ids, indices, resetOther) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d) && !isSelected) { toggle(true, shape.classed(CLASS.SELECTED, true), d, i); } } else if (isDefined(resetOther) && resetOther) { if (isSelected) { toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } }); }; c3_chart_fn.unselect = function (ids, indices) { var $$ = this.internal, d3 = $$.d3, config = $$.config; if (! config.data_selection_enabled) { return; } $$.main.selectAll('.' + CLASS.shapes).selectAll('.' + CLASS.shape).each(function (d, i) { var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); // line/area selection not supported yet if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { return; } if (isTargetId && isTargetIndex) { if (config.data_selection_isselectable(d)) { if (isSelected) { toggle(false, shape.classed(CLASS.SELECTED, false), d, i); } } } }); }; c3_chart_fn.transform = function (type, targetIds) { var $$ = this.internal, options = ['pie', 'donut'].indexOf(type) >= 0 ? {withTransform: true} : null; $$.transformTo(targetIds, type, options); }; c3_chart_internal_fn.transformTo = function (targetIds, type, optionsForRedraw) { var $$ = this, withTransitionForAxis = !$$.hasArcType(), options = optionsForRedraw || {withTransitionForAxis: withTransitionForAxis}; options.withTransitionForTransform = false; $$.transiting = false; $$.setTargetType(targetIds, type); $$.updateTargets($$.data.targets); // this is needed when transforming to arc $$.updateAndRedraw(options); }; c3_chart_fn.groups = function (groups) { var $$ = this.internal, config = $$.config; if (isUndefined(groups)) { return config.data_groups; } config.data_groups = groups; $$.redraw(); return config.data_groups; }; c3_chart_fn.xgrids = function (grids) { var $$ = this.internal, config = $$.config; if (! grids) { return config.grid_x_lines; } config.grid_x_lines = grids; $$.redrawWithoutRescale(); return config.grid_x_lines; }; c3_chart_fn.xgrids.add = function (grids) { var $$ = this.internal; return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); }; c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple var $$ = this.internal; $$.removeGridLines(params, true); }; c3_chart_fn.ygrids = function (grids) { var $$ = this.internal, config = $$.config; if (! grids) { return config.grid_y_lines; } config.grid_y_lines = grids; $$.redrawWithoutRescale(); return config.grid_y_lines; }; c3_chart_fn.ygrids.add = function (grids) { var $$ = this.internal; return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); }; c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple var $$ = this.internal; $$.removeGridLines(params, false); }; c3_chart_fn.regions = function (regions) { var $$ = this.internal, config = $$.config; if (!regions) { return config.regions; } config.regions = regions; $$.redrawWithoutRescale(); return config.regions; }; c3_chart_fn.regions.add = function (regions) { var $$ = this.internal, config = $$.config; if (!regions) { return config.regions; } config.regions = config.regions.concat(regions); $$.redrawWithoutRescale(); return config.regions; }; c3_chart_fn.regions.remove = function (options) { var $$ = this.internal, config = $$.config, duration, classes, regions; options = options || {}; duration = $$.getOption(options, "duration", config.transition_duration); classes = $$.getOption(options, "classes", [CLASS.region]); regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { return '.' + c; })); (duration ? regions.transition().duration(duration) : regions) .style('opacity', 0) .remove(); config.regions = config.regions.filter(function (region) { var found = false; if (!region['class']) { return true; } region['class'].split(' ').forEach(function (c) { if (classes.indexOf(c) >= 0) { found = true; } }); return !found; }); return config.regions; }; c3_chart_fn.data = function (targetIds) { var targets = this.internal.data.targets; return typeof targetIds === 'undefined' ? targets : targets.filter(function (t) { return [].concat(targetIds).indexOf(t.id) >= 0; }); }; c3_chart_fn.data.shown = function (targetIds) { return this.internal.filterTargetsToShow(this.data(targetIds)); }; c3_chart_fn.data.values = function (targetId) { var targets, values = null; if (targetId) { targets = this.data(targetId); values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null; } return values; }; c3_chart_fn.data.names = function (names) { this.internal.clearLegendItemTextBoxCache(); return this.internal.updateDataAttributes('names', names); }; c3_chart_fn.data.colors = function (colors) { return this.internal.updateDataAttributes('colors', colors); }; c3_chart_fn.data.axes = function (axes) { return this.internal.updateDataAttributes('axes', axes); }; c3_chart_fn.category = function (i, category) { var $$ = this.internal, config = $$.config; if (arguments.length > 1) { config.axis_x_categories[i] = category; $$.redraw(); } return config.axis_x_categories[i]; }; c3_chart_fn.categories = function (categories) { var $$ = this.internal, config = $$.config; if (!arguments.length) { return config.axis_x_categories; } config.axis_x_categories = categories; $$.redraw(); return config.axis_x_categories; }; // TODO: fix c3_chart_fn.color = function (id) { var $$ = this.internal; return $$.color(id); // more patterns }; c3_chart_fn.x = function (x) { var $$ = this.internal; if (arguments.length) { $$.updateTargetX($$.data.targets, x); $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } return $$.data.xs; }; c3_chart_fn.xs = function (xs) { var $$ = this.internal; if (arguments.length) { $$.updateTargetXs($$.data.targets, xs); $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } return $$.data.xs; }; c3_chart_fn.axis = function () {}; c3_chart_fn.axis.labels = function (labels) { var $$ = this.internal; if (arguments.length) { Object.keys(labels).forEach(function (axisId) { $$.axis.setLabelText(axisId, labels[axisId]); }); $$.axis.updateLabels(); } // TODO: return some values? }; c3_chart_fn.axis.max = function (max) { var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof max === 'object') { if (isValue(max.x)) { config.axis_x_max = max.x; } if (isValue(max.y)) { config.axis_y_max = max.y; } if (isValue(max.y2)) { config.axis_y2_max = max.y2; } } else { config.axis_y_max = config.axis_y2_max = max; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } else { return { x: config.axis_x_max, y: config.axis_y_max, y2: config.axis_y2_max }; } }; c3_chart_fn.axis.min = function (min) { var $$ = this.internal, config = $$.config; if (arguments.length) { if (typeof min === 'object') { if (isValue(min.x)) { config.axis_x_min = min.x; } if (isValue(min.y)) { config.axis_y_min = min.y; } if (isValue(min.y2)) { config.axis_y2_min = min.y2; } } else { config.axis_y_min = config.axis_y2_min = min; } $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); } else { return { x: config.axis_x_min, y: config.axis_y_min, y2: config.axis_y2_min }; } }; c3_chart_fn.axis.range = function (range) { if (arguments.length) { if (isDefined(range.max)) { this.axis.max(range.max); } if (isDefined(range.min)) { this.axis.min(range.min); } } else { return { max: this.axis.max(), min: this.axis.min() }; } }; c3_chart_fn.legend = function () {}; c3_chart_fn.legend.show = function (targetIds) { var $$ = this.internal; $$.showLegend($$.mapToTargetIds(targetIds)); $$.updateAndRedraw({withLegend: true}); }; c3_chart_fn.legend.hide = function (targetIds) { var $$ = this.internal; $$.hideLegend($$.mapToTargetIds(targetIds)); $$.updateAndRedraw({withLegend: true}); }; c3_chart_fn.resize = function (size) { var $$ = this.internal, config = $$.config; config.size_width = size ? size.width : null; config.size_height = size ? size.height : null; this.flush(); }; c3_chart_fn.flush = function () { var $$ = this.internal; $$.updateAndRedraw({withLegend: true, withTransition: false, withTransitionForTransform: false}); }; c3_chart_fn.destroy = function () { var $$ = this.internal; window.clearInterval($$.intervalForObserveInserted); if ($$.resizeTimeout !== undefined) { window.clearTimeout($$.resizeTimeout); } if (window.detachEvent) { window.detachEvent('onresize', $$.resizeFunction); } else if (window.removeEventListener) { window.removeEventListener('resize', $$.resizeFunction); } else { var wrapper = window.onresize; // check if no one else removed our wrapper and remove our resizeFunction from it if (wrapper && wrapper.add && wrapper.remove) { wrapper.remove($$.resizeFunction); } } $$.selectChart.classed('c3', false).html(""); // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. Object.keys($$).forEach(function (key) { $$[key] = null; }); return null; }; c3_chart_fn.tooltip = function () {}; c3_chart_fn.tooltip.show = function (args) { var $$ = this.internal, index, mouse; // determine mouse position on the chart if (args.mouse) { mouse = args.mouse; } // determine focus data if (args.data) { if ($$.isMultipleX()) { // if multiple xs, target point will be determined by mouse mouse = [$$.x(args.data.x), $$.getYScale(args.data.id)(args.data.value)]; index = null; } else { // TODO: when tooltip_grouped = false index = isValue(args.data.index) ? args.data.index : $$.getIndexByX(args.data.x); } } else if (typeof args.x !== 'undefined') { index = $$.getIndexByX(args.x); } else if (typeof args.index !== 'undefined') { index = args.index; } // emulate mouse events to show $$.dispatchEvent('mouseover', index, mouse); $$.dispatchEvent('mousemove', index, mouse); $$.config.tooltip_onshow.call($$, args.data); }; c3_chart_fn.tooltip.hide = function () { // TODO: get target data by checking the state of focus this.internal.dispatchEvent('mouseout', 0); this.internal.config.tooltip_onhide.call(this); }; // Features: // 1. category axis // 2. ceil values of translate/x/y to int for half pixel antialiasing // 3. multiline tick text var tickTextCharSize; function c3_axis(d3, params) { var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize, tickPadding = 3, tickValues = null, tickFormat, tickArguments; var tickOffset = 0, tickCulling = true, tickCentered; params = params || {}; outerTickSize = params.withOuterTick ? 6 : 0; function axisX(selection, x) { selection.attr("transform", function (d) { return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)"; }); } function axisY(selection, y) { selection.attr("transform", function (d) { return "translate(0," + Math.ceil(y(d)) + ")"; }); } function scaleExtent(domain) { var start = domain[0], stop = domain[domain.length - 1]; return start < stop ? [ start, stop ] : [ stop, start ]; } function generateTicks(scale) { var i, domain, ticks = []; if (scale.ticks) { return scale.ticks.apply(scale, tickArguments); } domain = scale.domain(); for (i = Math.ceil(domain[0]); i < domain[1]; i++) { ticks.push(i); } if (ticks.length > 0 && ticks[0] > 0) { ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); } return ticks; } function copyScale() { var newScale = scale.copy(), domain; if (params.isCategory) { domain = scale.domain(); newScale.domain([domain[0], domain[1] - 1]); } return newScale; } function textFormatted(v) { var formatted = tickFormat ? tickFormat(v) : v; return typeof formatted !== 'undefined' ? formatted : ''; } function getSizeFor1Char(tick) { if (tickTextCharSize) { return tickTextCharSize; } var size = { h: 11.5, w: 5.5 }; tick.select('text').text(textFormatted).each(function (d) { var box = this.getBoundingClientRect(), text = textFormatted(d), h = box.height, w = text ? (box.width / text.length) : undefined; if (h && w) { size.h = h; size.w = w; } }).text(''); tickTextCharSize = size; return size; } function transitionise(selection) { return params.withoutTransition ? selection : d3.transition(selection); } function axis(g) { g.each(function () { var g = axis.g = d3.select(this); var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = copyScale(); var ticks = tickValues ? tickValues : generateTicks(scale1), tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6), // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. tickExit = tick.exit().remove(), tickUpdate = transitionise(tick).style("opacity", 1), tickTransform, tickX, tickY; var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), transitionise(path)); tickEnter.append("line"); tickEnter.append("text"); var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); if (params.isCategory) { tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); tickX = tickCentered ? 0 : tickOffset; tickY = tickCentered ? tickOffset : 0; } else { tickOffset = tickX = 0; } var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = []; var tickLength = Math.max(innerTickSize, 0) + tickPadding, isVertical = orient === 'left' || orient === 'right'; // this should be called only when category axis function splitTickText(d, maxWidth) { var tickText = textFormatted(d), subtext, spaceIndex, textWidth, splitted = []; if (Object.prototype.toString.call(tickText) === "[object Array]") { return tickText; } if (!maxWidth || maxWidth <= 0) { maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 12) : 110; } function split(splitted, text) { spaceIndex = undefined; for (var i = 1; i < text.length; i++) { if (text.charAt(i) === ' ') { spaceIndex = i; } subtext = text.substr(0, i + 1); textWidth = sizeFor1Char.w * subtext.length; // if text width gets over tick width, split by space index or crrent index if (maxWidth < textWidth) { return split( splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)), text.slice(spaceIndex ? spaceIndex + 1 : i) ); } } return splitted.concat(text); } return split(splitted, tickText + ""); } function tspanDy(d, i) { var dy = sizeFor1Char.h; if (i === 0) { if (orient === 'left' || orient === 'right') { dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3); } else { dy = ".71em"; } } return dy; } function tickSize(d) { var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset); return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0; } text = tick.select("text"); tspan = text.selectAll('tspan') .data(function (d, i) { var splitted = params.tickMultiline ? splitTickText(d, params.tickWidth) : [].concat(textFormatted(d)); counts[i] = splitted.length; return splitted.map(function (s) { return { index: i, splitted: s }; }); }); tspan.enter().append('tspan'); tspan.exit().remove(); tspan.text(function (d) { return d.splitted; }); var rotate = params.tickTextRotate; function textAnchorForText(rotate) { if (!rotate) { return 'middle'; } return rotate > 0 ? "start" : "end"; } function textTransform(rotate) { if (!rotate) { return ''; } return "rotate(" + rotate + ")"; } function dxForText(rotate) { if (!rotate) { return 0; } return 8 * Math.sin(Math.PI * (rotate / 180)); } function yForText(rotate) { if (!rotate) { return tickLength; } return 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1); } switch (orient) { case "bottom": { tickTransform = axisX; lineEnter.attr("y2", innerTickSize); textEnter.attr("y", tickLength); lineUpdate.attr("x1", tickX).attr("x2", tickX).attr("y2", tickSize); textUpdate.attr("x", 0).attr("y", yForText(rotate)) .style("text-anchor", textAnchorForText(rotate)) .attr("transform", textTransform(rotate)); tspan.attr('x', 0).attr("dy", tspanDy).attr('dx', dxForText(rotate)); pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); break; } case "top": { // TODO: rotated tick text tickTransform = axisX; lineEnter.attr("y2", -innerTickSize); textEnter.attr("y", -tickLength); lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); textUpdate.attr("x", 0).attr("y", -tickLength); text.style("text-anchor", "middle"); tspan.attr('x', 0).attr("dy", "0em"); pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); break; } case "left": { tickTransform = axisY; lineEnter.attr("x2", -innerTickSize); textEnter.attr("x", -tickLength); lineUpdate.attr("x2", -innerTickSize).attr("y1", tickY).attr("y2", tickY); textUpdate.attr("x", -tickLength).attr("y", tickOffset); text.style("text-anchor", "end"); tspan.attr('x', -tickLength).attr("dy", tspanDy); pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); break; } case "right": { tickTransform = axisY; lineEnter.attr("x2", innerTickSize); textEnter.attr("x", tickLength); lineUpdate.attr("x2", innerTickSize).attr("y2", 0); textUpdate.attr("x", tickLength).attr("y", 0); text.style("text-anchor", "start"); tspan.attr('x', tickLength).attr("dy", tspanDy); pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize); break; } } if (scale1.rangeBand) { var x = scale1, dx = x.rangeBand() / 2; scale0 = scale1 = function (d) { return x(d) + dx; }; } else if (scale0.rangeBand) { scale0 = scale1; } else { tickExit.call(tickTransform, scale1); } tickEnter.call(tickTransform, scale0); tickUpdate.call(tickTransform, scale1); }); } axis.scale = function (x) { if (!arguments.length) { return scale; } scale = x; return axis; }; axis.orient = function (x) { if (!arguments.length) { return orient; } orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom"; return axis; }; axis.tickFormat = function (format) { if (!arguments.length) { return tickFormat; } tickFormat = format; return axis; }; axis.tickCentered = function (isCentered) { if (!arguments.length) { return tickCentered; } tickCentered = isCentered; return axis; }; axis.tickOffset = function () { return tickOffset; }; axis.tickInterval = function () { var interval, length; if (params.isCategory) { interval = tickOffset * 2; } else { length = axis.g.select('path.domain').node().getTotalLength() - outerTickSize * 2; interval = length / axis.g.selectAll('line').size(); } return interval === Infinity ? 0 : interval; }; axis.ticks = function () { if (!arguments.length) { return tickArguments; } tickArguments = arguments; return axis; }; axis.tickCulling = function (culling) { if (!arguments.length) { return tickCulling; } tickCulling = culling; return axis; }; axis.tickValues = function (x) { if (typeof x === 'function') { tickValues = function () { return x(scale.domain()); }; } else { if (!arguments.length) { return tickValues; } tickValues = x; } return axis; }; return axis; } c3_chart_internal_fn.isSafari = function () { var ua = window.navigator.userAgent; return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0; }; c3_chart_internal_fn.isChrome = function () { var ua = window.navigator.userAgent; return ua.indexOf('Chrome') >= 0; }; /* jshint ignore:start */ // PhantomJS doesn't have support for Function.prototype.bind, which has caused confusion. Use // this polyfill to avoid the confusion. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== 'function') { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function() {}, fBound = function() { return fToBind.apply(this instanceof fNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } //SVGPathSeg API polyfill //https://github.com/progers/pathseg // //This is a drop-in replacement for the SVGPathSeg and SVGPathSegList APIs that were removed from //SVG2 (https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html), including the latest spec //changes which were implemented in Firefox 43 and Chrome 46. //Chrome 48 removes these APIs, so this polyfill is required. (function() { "use strict"; if (!("SVGPathSeg" in window)) { // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg window.SVGPathSeg = function(type, typeAsLetter, owningPathSegList) { this.pathSegType = type; this.pathSegTypeAsLetter = typeAsLetter; this._owningPathSegList = owningPathSegList; } SVGPathSeg.PATHSEG_UNKNOWN = 0; SVGPathSeg.PATHSEG_CLOSEPATH = 1; SVGPathSeg.PATHSEG_MOVETO_ABS = 2; SVGPathSeg.PATHSEG_MOVETO_REL = 3; SVGPathSeg.PATHSEG_LINETO_ABS = 4; SVGPathSeg.PATHSEG_LINETO_REL = 5; SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; SVGPathSeg.PATHSEG_ARC_ABS = 10; SVGPathSeg.PATHSEG_ARC_REL = 11; SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; // Notify owning PathSegList on any changes so they can be synchronized back to the path element. SVGPathSeg.prototype._segmentChanged = function() { if (this._owningPathSegList) this._owningPathSegList.segmentChanged(this); } window.SVGPathSegClosePath = function(owningPathSegList) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CLOSEPATH, "z", owningPathSegList); } SVGPathSegClosePath.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegClosePath.prototype.toString = function() { return "[object SVGPathSegClosePath]"; } SVGPathSegClosePath.prototype._asPathString = function() { return this.pathSegTypeAsLetter; } SVGPathSegClosePath.prototype.clone = function() { return new SVGPathSegClosePath(undefined); } window.SVGPathSegMovetoAbs = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_MOVETO_ABS, "M", owningPathSegList); this._x = x; this._y = y; } SVGPathSegMovetoAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegMovetoAbs.prototype.toString = function() { return "[object SVGPathSegMovetoAbs]"; } SVGPathSegMovetoAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegMovetoAbs.prototype.clone = function() { return new SVGPathSegMovetoAbs(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegMovetoAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegMovetoAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegMovetoRel = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_MOVETO_REL, "m", owningPathSegList); this._x = x; this._y = y; } SVGPathSegMovetoRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegMovetoRel.prototype.toString = function() { return "[object SVGPathSegMovetoRel]"; } SVGPathSegMovetoRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegMovetoRel.prototype.clone = function() { return new SVGPathSegMovetoRel(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegMovetoRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegMovetoRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoAbs = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_ABS, "L", owningPathSegList); this._x = x; this._y = y; } SVGPathSegLinetoAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoAbs.prototype.toString = function() { return "[object SVGPathSegLinetoAbs]"; } SVGPathSegLinetoAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegLinetoAbs.prototype.clone = function() { return new SVGPathSegLinetoAbs(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegLinetoAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegLinetoAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoRel = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_REL, "l", owningPathSegList); this._x = x; this._y = y; } SVGPathSegLinetoRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoRel.prototype.toString = function() { return "[object SVGPathSegLinetoRel]"; } SVGPathSegLinetoRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegLinetoRel.prototype.clone = function() { return new SVGPathSegLinetoRel(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegLinetoRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegLinetoRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoCubicAbs = function(owningPathSegList, x, y, x1, y1, x2, y2) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, "C", owningPathSegList); this._x = x; this._y = y; this._x1 = x1; this._y1 = y1; this._x2 = x2; this._y2 = y2; } SVGPathSegCurvetoCubicAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoCubicAbs.prototype.toString = function() { return "[object SVGPathSegCurvetoCubicAbs]"; } SVGPathSegCurvetoCubicAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y; } SVGPathSegCurvetoCubicAbs.prototype.clone = function() { return new SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); } Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "x1", { get: function() { return this._x1; }, set: function(x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "y1", { get: function() { return this._y1; }, set: function(y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "x2", { get: function() { return this._x2; }, set: function(x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicAbs.prototype, "y2", { get: function() { return this._y2; }, set: function(y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoCubicRel = function(owningPathSegList, x, y, x1, y1, x2, y2) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, "c", owningPathSegList); this._x = x; this._y = y; this._x1 = x1; this._y1 = y1; this._x2 = x2; this._y2 = y2; } SVGPathSegCurvetoCubicRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoCubicRel.prototype.toString = function() { return "[object SVGPathSegCurvetoCubicRel]"; } SVGPathSegCurvetoCubicRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y; } SVGPathSegCurvetoCubicRel.prototype.clone = function() { return new SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); } Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "x1", { get: function() { return this._x1; }, set: function(x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "y1", { get: function() { return this._y1; }, set: function(y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "x2", { get: function() { return this._x2; }, set: function(x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicRel.prototype, "y2", { get: function() { return this._y2; }, set: function(y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoQuadraticAbs = function(owningPathSegList, x, y, x1, y1) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, "Q", owningPathSegList); this._x = x; this._y = y; this._x1 = x1; this._y1 = y1; } SVGPathSegCurvetoQuadraticAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoQuadraticAbs.prototype.toString = function() { return "[object SVGPathSegCurvetoQuadraticAbs]"; } SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x + " " + this._y; } SVGPathSegCurvetoQuadraticAbs.prototype.clone = function() { return new SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); } Object.defineProperty(SVGPathSegCurvetoQuadraticAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticAbs.prototype, "x1", { get: function() { return this._x1; }, set: function(x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticAbs.prototype, "y1", { get: function() { return this._y1; }, set: function(y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoQuadraticRel = function(owningPathSegList, x, y, x1, y1) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, "q", owningPathSegList); this._x = x; this._y = y; this._x1 = x1; this._y1 = y1; } SVGPathSegCurvetoQuadraticRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoQuadraticRel.prototype.toString = function() { return "[object SVGPathSegCurvetoQuadraticRel]"; } SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x1 + " " + this._y1 + " " + this._x + " " + this._y; } SVGPathSegCurvetoQuadraticRel.prototype.clone = function() { return new SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); } Object.defineProperty(SVGPathSegCurvetoQuadraticRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticRel.prototype, "x1", { get: function() { return this._x1; }, set: function(x1) { this._x1 = x1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticRel.prototype, "y1", { get: function() { return this._y1; }, set: function(y1) { this._y1 = y1; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegArcAbs = function(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_ARC_ABS, "A", owningPathSegList); this._x = x; this._y = y; this._r1 = r1; this._r2 = r2; this._angle = angle; this._largeArcFlag = largeArcFlag; this._sweepFlag = sweepFlag; } SVGPathSegArcAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegArcAbs.prototype.toString = function() { return "[object SVGPathSegArcAbs]"; } SVGPathSegArcAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._r1 + " " + this._r2 + " " + this._angle + " " + (this._largeArcFlag ? "1" : "0") + " " + (this._sweepFlag ? "1" : "0") + " " + this._x + " " + this._y; } SVGPathSegArcAbs.prototype.clone = function() { return new SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); } Object.defineProperty(SVGPathSegArcAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "r1", { get: function() { return this._r1; }, set: function(r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "r2", { get: function() { return this._r2; }, set: function(r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "angle", { get: function() { return this._angle; }, set: function(angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "largeArcFlag", { get: function() { return this._largeArcFlag; }, set: function(largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcAbs.prototype, "sweepFlag", { get: function() { return this._sweepFlag; }, set: function(sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegArcRel = function(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_ARC_REL, "a", owningPathSegList); this._x = x; this._y = y; this._r1 = r1; this._r2 = r2; this._angle = angle; this._largeArcFlag = largeArcFlag; this._sweepFlag = sweepFlag; } SVGPathSegArcRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegArcRel.prototype.toString = function() { return "[object SVGPathSegArcRel]"; } SVGPathSegArcRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._r1 + " " + this._r2 + " " + this._angle + " " + (this._largeArcFlag ? "1" : "0") + " " + (this._sweepFlag ? "1" : "0") + " " + this._x + " " + this._y; } SVGPathSegArcRel.prototype.clone = function() { return new SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); } Object.defineProperty(SVGPathSegArcRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "r1", { get: function() { return this._r1; }, set: function(r1) { this._r1 = r1; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "r2", { get: function() { return this._r2; }, set: function(r2) { this._r2 = r2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "angle", { get: function() { return this._angle; }, set: function(angle) { this._angle = angle; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "largeArcFlag", { get: function() { return this._largeArcFlag; }, set: function(largeArcFlag) { this._largeArcFlag = largeArcFlag; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegArcRel.prototype, "sweepFlag", { get: function() { return this._sweepFlag; }, set: function(sweepFlag) { this._sweepFlag = sweepFlag; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoHorizontalAbs = function(owningPathSegList, x) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, "H", owningPathSegList); this._x = x; } SVGPathSegLinetoHorizontalAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoHorizontalAbs.prototype.toString = function() { return "[object SVGPathSegLinetoHorizontalAbs]"; } SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x; } SVGPathSegLinetoHorizontalAbs.prototype.clone = function() { return new SVGPathSegLinetoHorizontalAbs(undefined, this._x); } Object.defineProperty(SVGPathSegLinetoHorizontalAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoHorizontalRel = function(owningPathSegList, x) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, "h", owningPathSegList); this._x = x; } SVGPathSegLinetoHorizontalRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoHorizontalRel.prototype.toString = function() { return "[object SVGPathSegLinetoHorizontalRel]"; } SVGPathSegLinetoHorizontalRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x; } SVGPathSegLinetoHorizontalRel.prototype.clone = function() { return new SVGPathSegLinetoHorizontalRel(undefined, this._x); } Object.defineProperty(SVGPathSegLinetoHorizontalRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoVerticalAbs = function(owningPathSegList, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, "V", owningPathSegList); this._y = y; } SVGPathSegLinetoVerticalAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoVerticalAbs.prototype.toString = function() { return "[object SVGPathSegLinetoVerticalAbs]"; } SVGPathSegLinetoVerticalAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._y; } SVGPathSegLinetoVerticalAbs.prototype.clone = function() { return new SVGPathSegLinetoVerticalAbs(undefined, this._y); } Object.defineProperty(SVGPathSegLinetoVerticalAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegLinetoVerticalRel = function(owningPathSegList, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, "v", owningPathSegList); this._y = y; } SVGPathSegLinetoVerticalRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegLinetoVerticalRel.prototype.toString = function() { return "[object SVGPathSegLinetoVerticalRel]"; } SVGPathSegLinetoVerticalRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._y; } SVGPathSegLinetoVerticalRel.prototype.clone = function() { return new SVGPathSegLinetoVerticalRel(undefined, this._y); } Object.defineProperty(SVGPathSegLinetoVerticalRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoCubicSmoothAbs = function(owningPathSegList, x, y, x2, y2) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, "S", owningPathSegList); this._x = x; this._y = y; this._x2 = x2; this._y2 = y2; } SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function() { return "[object SVGPathSegCurvetoCubicSmoothAbs]"; } SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y; } SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function() { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); } Object.defineProperty(SVGPathSegCurvetoCubicSmoothAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothAbs.prototype, "x2", { get: function() { return this._x2; }, set: function(x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothAbs.prototype, "y2", { get: function() { return this._y2; }, set: function(y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoCubicSmoothRel = function(owningPathSegList, x, y, x2, y2) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, "s", owningPathSegList); this._x = x; this._y = y; this._x2 = x2; this._y2 = y2; } SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function() { return "[object SVGPathSegCurvetoCubicSmoothRel]"; } SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x2 + " " + this._y2 + " " + this._x + " " + this._y; } SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function() { return new SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); } Object.defineProperty(SVGPathSegCurvetoCubicSmoothRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothRel.prototype, "x2", { get: function() { return this._x2; }, set: function(x2) { this._x2 = x2; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoCubicSmoothRel.prototype, "y2", { get: function() { return this._y2; }, set: function(y2) { this._y2 = y2; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoQuadraticSmoothAbs = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, "T", owningPathSegList); this._x = x; this._y = y; } SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function() { return "[object SVGPathSegCurvetoQuadraticSmoothAbs]"; } SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function() { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticSmoothAbs.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); window.SVGPathSegCurvetoQuadraticSmoothRel = function(owningPathSegList, x, y) { SVGPathSeg.call(this, SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, "t", owningPathSegList); this._x = x; this._y = y; } SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create(SVGPathSeg.prototype); SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function() { return "[object SVGPathSegCurvetoQuadraticSmoothRel]"; } SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function() { return this.pathSegTypeAsLetter + " " + this._x + " " + this._y; } SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function() { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); } Object.defineProperty(SVGPathSegCurvetoQuadraticSmoothRel.prototype, "x", { get: function() { return this._x; }, set: function(x) { this._x = x; this._segmentChanged(); }, enumerable: true }); Object.defineProperty(SVGPathSegCurvetoQuadraticSmoothRel.prototype, "y", { get: function() { return this._y; }, set: function(y) { this._y = y; this._segmentChanged(); }, enumerable: true }); // Add createSVGPathSeg* functions to SVGPathElement. // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement. SVGPathElement.prototype.createSVGPathSegClosePath = function() { return new SVGPathSegClosePath(undefined); } SVGPathElement.prototype.createSVGPathSegMovetoAbs = function(x, y) { return new SVGPathSegMovetoAbs(undefined, x, y); } SVGPathElement.prototype.createSVGPathSegMovetoRel = function(x, y) { return new SVGPathSegMovetoRel(undefined, x, y); } SVGPathElement.prototype.createSVGPathSegLinetoAbs = function(x, y) { return new SVGPathSegLinetoAbs(undefined, x, y); } SVGPathElement.prototype.createSVGPathSegLinetoRel = function(x, y) { return new SVGPathSegLinetoRel(undefined, x, y); } SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function(x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); } SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function(x, y, x1, y1, x2, y2) { return new SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); } SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function(x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); } SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function(x, y, x1, y1) { return new SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); } SVGPathElement.prototype.createSVGPathSegArcAbs = function(x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } SVGPathElement.prototype.createSVGPathSegArcRel = function(x, y, r1, r2, angle, largeArcFlag, sweepFlag) { return new SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); } SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function(x) { return new SVGPathSegLinetoHorizontalAbs(undefined, x); } SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function(x) { return new SVGPathSegLinetoHorizontalRel(undefined, x); } SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function(y) { return new SVGPathSegLinetoVerticalAbs(undefined, y); } SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function(y) { return new SVGPathSegLinetoVerticalRel(undefined, y); } SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function(x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); } SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function(x, y, x2, y2) { return new SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); } SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function(x, y) { return new SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); } SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function(x, y) { return new SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); } } if (!("SVGPathSegList" in window)) { // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList window.SVGPathSegList = function(pathElement) { this._pathElement = pathElement; this._list = this._parsePath(this._pathElement.getAttribute("d")); // Use a MutationObserver to catch changes to the path's "d" attribute. this._mutationObserverConfig = { "attributes": true, "attributeFilter": ["d"] }; this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); } Object.defineProperty(SVGPathSegList.prototype, "numberOfItems", { get: function() { this._checkPathSynchronizedToList(); return this._list.length; }, enumerable: true }); // Add the pathSegList accessors to SVGPathElement. // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData Object.defineProperty(SVGPathElement.prototype, "pathSegList", { get: function() { if (!this._pathSegList) this._pathSegList = new SVGPathSegList(this); return this._pathSegList; }, enumerable: true }); // FIXME: The following are not implemented and simply return SVGPathElement.pathSegList. Object.defineProperty(SVGPathElement.prototype, "normalizedPathSegList", { get: function() { return this.pathSegList; }, enumerable: true }); Object.defineProperty(SVGPathElement.prototype, "animatedPathSegList", { get: function() { return this.pathSegList; }, enumerable: true }); Object.defineProperty(SVGPathElement.prototype, "animatedNormalizedPathSegList", { get: function() { return this.pathSegList; }, enumerable: true }); // Process any pending mutations to the path element and update the list as needed. // This should be the first call of all public functions and is needed because // MutationObservers are not synchronous so we can have pending asynchronous mutations. SVGPathSegList.prototype._checkPathSynchronizedToList = function() { this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); } SVGPathSegList.prototype._updateListFromPathMutations = function(mutationRecords) { if (!this._pathElement) return; var hasPathMutations = false; mutationRecords.forEach(function(record) { if (record.attributeName == "d") hasPathMutations = true; }); if (hasPathMutations) this._list = this._parsePath(this._pathElement.getAttribute("d")); } // Serialize the list and update the path's 'd' attribute. SVGPathSegList.prototype._writeListToPath = function() { this._pathElementMutationObserver.disconnect(); this._pathElement.setAttribute("d", SVGPathSegList._pathSegArrayAsString(this._list)); this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); } // When a path segment changes the list needs to be synchronized back to the path element. SVGPathSegList.prototype.segmentChanged = function(pathSeg) { this._writeListToPath(); } SVGPathSegList.prototype.clear = function() { this._checkPathSynchronizedToList(); this._list.forEach(function(pathSeg) { pathSeg._owningPathSegList = null; }); this._list = []; this._writeListToPath(); } SVGPathSegList.prototype.initialize = function(newItem) { this._checkPathSynchronizedToList(); this._list = [newItem]; newItem._owningPathSegList = this; this._writeListToPath(); return newItem; } SVGPathSegList.prototype._checkValidIndex = function(index) { if (isNaN(index) || index < 0 || index >= this.numberOfItems) throw "INDEX_SIZE_ERR"; } SVGPathSegList.prototype.getItem = function(index) { this._checkPathSynchronizedToList(); this._checkValidIndex(index); return this._list[index]; } SVGPathSegList.prototype.insertItemBefore = function(newItem, index) { this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. if (index > this.numberOfItems) index = this.numberOfItems; if (newItem._owningPathSegList) { // SVG2 spec says to make a copy. newItem = newItem.clone(); } this._list.splice(index, 0, newItem); newItem._owningPathSegList = this; this._writeListToPath(); return newItem; } SVGPathSegList.prototype.replaceItem = function(newItem, index) { this._checkPathSynchronizedToList(); if (newItem._owningPathSegList) { // SVG2 spec says to make a copy. newItem = newItem.clone(); } this._checkValidIndex(index); this._list[index] = newItem; newItem._owningPathSegList = this; this._writeListToPath(); return newItem; } SVGPathSegList.prototype.removeItem = function(index) { this._checkPathSynchronizedToList(); this._checkValidIndex(index); var item = this._list[index]; this._list.splice(index, 1); this._writeListToPath(); return item; } SVGPathSegList.prototype.appendItem = function(newItem) { this._checkPathSynchronizedToList(); if (newItem._owningPathSegList) { // SVG2 spec says to make a copy. newItem = newItem.clone(); } this._list.push(newItem); newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute. this._writeListToPath(); return newItem; } SVGPathSegList._pathSegArrayAsString = function(pathSegArray) { var string = ""; var first = true; pathSegArray.forEach(function(pathSeg) { if (first) { first = false; string += pathSeg._asPathString(); } else { string += " " + pathSeg._asPathString(); } }); return string; } // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. SVGPathSegList.prototype._parsePath = function(string) { if (!string || string.length == 0) return []; var owningPathSegList = this; var Builder = function() { this.pathSegList = []; } Builder.prototype.appendSegment = function(pathSeg) { this.pathSegList.push(pathSeg); } var Source = function(string) { this._string = string; this._currentIndex = 0; this._endIndex = this._string.length; this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN; this._skipOptionalSpaces(); } Source.prototype._isCurrentSpace = function() { var character = this._string[this._currentIndex]; return character <= " " && (character == " " || character == "\n" || character == "\t" || character == "\r" || character == "\f"); } Source.prototype._skipOptionalSpaces = function() { while (this._currentIndex < this._endIndex && this._isCurrentSpace()) this._currentIndex++; return this._currentIndex < this._endIndex; } Source.prototype._skipOptionalSpacesOrDelimiter = function() { if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) != ",") return false; if (this._skipOptionalSpaces()) { if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == ",") { this._currentIndex++; this._skipOptionalSpaces(); } } return this._currentIndex < this._endIndex; } Source.prototype.hasMoreData = function() { return this._currentIndex < this._endIndex; } Source.prototype.peekSegmentType = function() { var lookahead = this._string[this._currentIndex]; return this._pathSegTypeFromChar(lookahead); } Source.prototype._pathSegTypeFromChar = function(lookahead) { switch (lookahead) { case "Z": case "z": return SVGPathSeg.PATHSEG_CLOSEPATH; case "M": return SVGPathSeg.PATHSEG_MOVETO_ABS; case "m": return SVGPathSeg.PATHSEG_MOVETO_REL; case "L": return SVGPathSeg.PATHSEG_LINETO_ABS; case "l": return SVGPathSeg.PATHSEG_LINETO_REL; case "C": return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; case "c": return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; case "Q": return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; case "q": return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; case "A": return SVGPathSeg.PATHSEG_ARC_ABS; case "a": return SVGPathSeg.PATHSEG_ARC_REL; case "H": return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; case "h": return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; case "V": return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; case "v": return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; case "S": return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; case "s": return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; case "T": return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; case "t": return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; default: return SVGPathSeg.PATHSEG_UNKNOWN; } } Source.prototype._nextCommandHelper = function(lookahead, previousCommand) { // Check for remaining coordinates in the current command. if ((lookahead == "+" || lookahead == "-" || lookahead == "." || (lookahead >= "0" && lookahead <= "9")) && previousCommand != SVGPathSeg.PATHSEG_CLOSEPATH) { if (previousCommand == SVGPathSeg.PATHSEG_MOVETO_ABS) return SVGPathSeg.PATHSEG_LINETO_ABS; if (previousCommand == SVGPathSeg.PATHSEG_MOVETO_REL) return SVGPathSeg.PATHSEG_LINETO_REL; return previousCommand; } return SVGPathSeg.PATHSEG_UNKNOWN; } Source.prototype.initialCommandIsMoveTo = function() { // If the path is empty it is still valid, so return true. if (!this.hasMoreData()) return true; var command = this.peekSegmentType(); // Path must start with moveTo. return command == SVGPathSeg.PATHSEG_MOVETO_ABS || command == SVGPathSeg.PATHSEG_MOVETO_REL; } // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF Source.prototype._parseNumber = function() { var exponent = 0; var integer = 0; var frac = 1; var decimal = 0; var sign = 1; var expsign = 1; var startIndex = this._currentIndex; this._skipOptionalSpaces(); // Read the sign. if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == "+") this._currentIndex++; else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == "-") { this._currentIndex++; sign = -1; } if (this._currentIndex == this._endIndex || ((this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9") && this._string.charAt(this._currentIndex) != ".")) // The first character of a number must be one of [0-9+-.]. return undefined; // Read the integer part, build right-to-left. var startIntPartIndex = this._currentIndex; while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9") this._currentIndex++; // Advance to first non-digit. if (this._currentIndex != startIntPartIndex) { var scanIntPartIndex = this._currentIndex - 1; var multiplier = 1; while (scanIntPartIndex >= startIntPartIndex) { integer += multiplier * (this._string.charAt(scanIntPartIndex--) - "0"); multiplier *= 10; } } // Read the decimals. if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) == ".") { this._currentIndex++; // There must be a least one digit following the . if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9") return undefined; while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9") decimal += (this._string.charAt(this._currentIndex++) - "0") * (frac *= 0.1); } // Read the exponent part. if (this._currentIndex != startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) == "e" || this._string.charAt(this._currentIndex) == "E") && (this._string.charAt(this._currentIndex + 1) != "x" && this._string.charAt(this._currentIndex + 1) != "m")) { this._currentIndex++; // Read the sign of the exponent. if (this._string.charAt(this._currentIndex) == "+") { this._currentIndex++; } else if (this._string.charAt(this._currentIndex) == "-") { this._currentIndex++; expsign = -1; } // There must be an exponent. if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < "0" || this._string.charAt(this._currentIndex) > "9") return undefined; while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= "0" && this._string.charAt(this._currentIndex) <= "9") { exponent *= 10; exponent += (this._string.charAt(this._currentIndex) - "0"); this._currentIndex++; } } var number = integer + decimal; number *= sign; if (exponent) number *= Math.pow(10, expsign * exponent); if (startIndex == this._currentIndex) return undefined; this._skipOptionalSpacesOrDelimiter(); return number; } Source.prototype._parseArcFlag = function() { if (this._currentIndex >= this._endIndex) return undefined; var flag = false; var flagChar = this._string.charAt(this._currentIndex++); if (flagChar == "0") flag = false; else if (flagChar == "1") flag = true; else return undefined; this._skipOptionalSpacesOrDelimiter(); return flag; } Source.prototype.parseSegment = function() { var lookahead = this._string[this._currentIndex]; var command = this._pathSegTypeFromChar(lookahead); if (command == SVGPathSeg.PATHSEG_UNKNOWN) { // Possibly an implicit command. Not allowed if this is the first command. if (this._previousCommand == SVGPathSeg.PATHSEG_UNKNOWN) return null; command = this._nextCommandHelper(lookahead, this._previousCommand); if (command == SVGPathSeg.PATHSEG_UNKNOWN) return null; } else { this._currentIndex++; } this._previousCommand = command; switch (command) { case SVGPathSeg.PATHSEG_MOVETO_REL: return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_MOVETO_ABS: return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_REL: return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_ABS: return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); case SVGPathSeg.PATHSEG_CLOSEPATH: this._skipOptionalSpaces(); return new SVGPathSegClosePath(owningPathSegList); case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: var points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: var points = {x1: this._parseNumber(), y1: this._parseNumber(), x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: var points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2); case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: var points = {x2: this._parseNumber(), y2: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2); case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: var points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1); case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: var points = {x1: this._parseNumber(), y1: this._parseNumber(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1); case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); case SVGPathSeg.PATHSEG_ARC_REL: var points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); case SVGPathSeg.PATHSEG_ARC_ABS: var points = {x1: this._parseNumber(), y1: this._parseNumber(), arcAngle: this._parseNumber(), arcLarge: this._parseArcFlag(), arcSweep: this._parseArcFlag(), x: this._parseNumber(), y: this._parseNumber()}; return new SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); default: throw "Unknown path seg type." } } var builder = new Builder(); var source = new Source(string); if (!source.initialCommandIsMoveTo()) return []; while (source.hasMoreData()) { var pathSeg = source.parseSegment(); if (!pathSeg) return []; builder.appendSegment(pathSeg); } return builder.pathSegList; } } }()); /* jshint ignore:end */ if (typeof define === 'function' && define.amd) { define("c3", ["d3"], function () { return c3; }); } else if ('undefined' !== typeof exports && 'undefined' !== typeof module) { module.exports = c3; } else { window.c3 = c3; } })(window);
joshuadeleon/typingclassifier
ML.TypingClassifier/Scripts/c3-0.4.11/c3.js
JavaScript
mit
375,568
[ 30522, 1006, 3853, 1006, 3332, 1007, 1063, 1005, 2224, 9384, 1005, 1025, 1013, 1008, 3795, 9375, 1010, 11336, 1010, 14338, 1010, 5478, 1008, 1013, 13075, 1039, 2509, 1027, 1063, 2544, 1024, 1000, 1014, 1012, 1018, 1012, 2340, 1000, 1065, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // daemon.cpp // ~~~~~~~~~~ // // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include <boost/asio/io_service.hpp> #include <boost/asio/ip/udp.hpp> #include <boost/asio/signal_set.hpp> #include <boost/array.hpp> #include <boost/bind.hpp> #include <ctime> #include <iostream> #include <syslog.h> #include <unistd.h> using boost::asio::ip::udp; class udp_daytime_server { public: udp_daytime_server(boost::asio::io_service& io_service) : socket_(io_service, udp::endpoint(udp::v4(), 13)) { start_receive(); } private: void start_receive() { socket_.async_receive_from( boost::asio::buffer(recv_buffer_), remote_endpoint_, boost::bind(&udp_daytime_server::handle_receive, this, _1)); } void handle_receive(const boost::system::error_code& ec) { if (!ec || ec == boost::asio::error::message_size) { using namespace std; // For time_t, time and ctime; time_t now = time(0); std::string message = ctime(&now); boost::system::error_code ignored_ec; socket_.send_to(boost::asio::buffer(message), remote_endpoint_, 0, ignored_ec); } start_receive(); } udp::socket socket_; udp::endpoint remote_endpoint_; boost::array<char, 1> recv_buffer_; }; int main() { try { boost::asio::io_service io_service; // Initialise the server before becoming a daemon. If the process is // started from a shell, this means any errors will be reported back to the // user. udp_daytime_server server(io_service); // Register signal handlers so that the daemon may be shut down. You may // also want to register for other signals, such as SIGHUP to trigger a // re-read of a configuration file. boost::asio::signal_set signals(io_service, SIGINT, SIGTERM); signals.async_wait( boost::bind(&boost::asio::io_service::stop, &io_service)); // Inform the io_service that we are about to become a daemon. The // io_service cleans up any internal resources, such as threads, that may // interfere with forking. io_service.notify_fork(boost::asio::io_service::fork_prepare); // Fork the process and have the parent exit. If the process was started // from a shell, this returns control to the user. Forking a new process is // also a prerequisite for the subsequent call to setsid(). if (pid_t pid = fork()) { if (pid > 0) { // We're in the parent process and need to exit. // // When the exit() function is used, the program terminates without // invoking local variables' destructors. Only global variables are // destroyed. As the io_service object is a local variable, this means // we do not have to call: // // io_service.notify_fork(boost::asio::io_service::fork_parent); // // However, this line should be added before each call to exit() if // using a global io_service object. An additional call: // // io_service.notify_fork(boost::asio::io_service::fork_prepare); // // should also precede the second fork(). exit(0); } else { syslog(LOG_ERR | LOG_USER, "First fork failed: %m"); return 1; } } // Make the process a new session leader. This detaches it from the // terminal. setsid(); // A process inherits its working directory from its parent. This could be // on a mounted filesystem, which means that the running daemon would // prevent this filesystem from being unmounted. Changing to the root // directory avoids this problem. chdir("/"); // The file mode creation mask is also inherited from the parent process. // We don't want to restrict the permissions on files created by the // daemon, so the mask is cleared. umask(0); // A second fork ensures the process cannot acquire a controlling terminal. if (pid_t pid = fork()) { if (pid > 0) { exit(0); } else { syslog(LOG_ERR | LOG_USER, "Second fork failed: %m"); return 1; } } // Close the standard streams. This decouples the daemon from the terminal // that started it. close(0); close(1); close(2); // We don't want the daemon to have any standard input. if (open("/dev/null", O_RDONLY) < 0) { syslog(LOG_ERR | LOG_USER, "Unable to open /dev/null: %m"); return 1; } // Send standard output to a log file. const char* output = "/tmp/asio.daemon.out"; const int flags = O_WRONLY | O_CREAT | O_APPEND; const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; if (open(output, flags, mode) < 0) { syslog(LOG_ERR | LOG_USER, "Unable to open output file %s: %m", output); return 1; } // Also send standard error to the same log file. if (dup(1) < 0) { syslog(LOG_ERR | LOG_USER, "Unable to dup output descriptor: %m"); return 1; } // Inform the io_service that we have finished becoming a daemon. The // io_service uses this opportunity to create any internal file descriptors // that need to be private to the new process. io_service.notify_fork(boost::asio::io_service::fork_child); // The io_service can now be used normally. syslog(LOG_INFO | LOG_USER, "Daemon started"); io_service.run(); syslog(LOG_INFO | LOG_USER, "Daemon stopped"); } catch (std::exception& e) { syslog(LOG_ERR | LOG_USER, "Exception: %s", e.what()); std::cerr << "Exception: " << e.what() << std::endl; } }
rkq/cxxexp
third-party/src/boost_1_56_0/libs/asio/example/cpp03/fork/daemon.cpp
C++
mit
5,804
[ 30522, 1013, 1013, 1013, 1013, 12828, 1012, 18133, 2361, 1013, 1013, 1066, 1066, 1066, 1066, 1066, 1066, 1066, 1066, 1066, 1066, 1013, 1013, 1013, 1013, 9385, 1006, 1039, 1007, 2494, 1011, 2297, 5696, 1049, 1012, 12849, 7317, 17896, 1006, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import URL from 'url'; import * as packageCache from '../../util/cache/package'; import { GitlabHttp } from '../../util/http/gitlab'; import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { GitlabTag } from './types'; const gitlabApi = new GitlabHttp(); export const id = 'gitlab-tags'; export const customRegistrySupport = true; export const defaultRegistryUrls = ['https://gitlab.com']; export const registryStrategy = 'first'; const cacheNamespace = 'datasource-gitlab'; function getCacheKey(depHost: string, repo: string): string { const type = 'tags'; return `${depHost}:${repo}:${type}`; } export async function getReleases({ registryUrl: depHost, lookupName: repo, }: GetReleasesConfig): Promise<ReleaseResult | null> { const cachedResult = await packageCache.get<ReleaseResult>( cacheNamespace, getCacheKey(depHost, repo) ); // istanbul ignore if if (cachedResult) { return cachedResult; } const urlEncodedRepo = encodeURIComponent(repo); // tag const url = URL.resolve( depHost, `/api/v4/projects/${urlEncodedRepo}/repository/tags?per_page=100` ); const gitlabTags = ( await gitlabApi.getJson<GitlabTag[]>(url, { paginate: true, }) ).body; const dependency: ReleaseResult = { sourceUrl: URL.resolve(depHost, repo), releases: null, }; dependency.releases = gitlabTags.map(({ name, commit }) => ({ version: name, gitRef: name, releaseTimestamp: commit?.created_at, })); const cacheMinutes = 10; await packageCache.set( cacheNamespace, getCacheKey(depHost, repo), dependency, cacheMinutes ); return dependency; }
singapore/renovate
lib/datasource/gitlab-tags/index.ts
TypeScript
mit
1,669
[ 30522, 12324, 24471, 2140, 2013, 1005, 24471, 2140, 1005, 1025, 12324, 1008, 2004, 7427, 3540, 5403, 2013, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 21183, 4014, 1013, 17053, 1013, 7427, 1005, 1025, 12324, 1063, 21025, 19646, 7875, 11039, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width" /> <link rel="shortcut icon" type="image/x-icon" href="../../../../../../favicon.ico" /> <title>com.google.android.gms.gcm | Android Developers</title> <!-- STYLESHEETS --> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto+Condensed"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold" title="roboto"> <link href="../../../../../../assets/css/default.css?v=2" rel="stylesheet" type="text/css"> <!-- FULLSCREEN STYLESHEET --> <link href="../../../../../../assets/css/fullscreen.css" rel="stylesheet" class="fullscreen" type="text/css"> <!-- JAVASCRIPT --> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script src="../../../../../../assets/js/android_3p-bundle.js" type="text/javascript"></script> <script type="text/javascript"> var toRoot = "../../../../../../"; var metaTags = []; var devsite = false; </script> <script src="../../../../../../assets/js/docs.js?v=2" type="text/javascript"></script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-5831155-1', 'android.com'); ga('create', 'UA-49880327-2', 'android.com', {'name': 'universal'}); // New tracker); ga('send', 'pageview'); ga('universal.send', 'pageview'); // Send page view for new tracker. </script> </head> <body class="gc-documentation develop"> <div id="doc-api-level" class="" style="display:none"></div> <a name="top"></a> <a name="top"></a> <!-- Header --> <div id="header-wrapper"> <div id="header"> <div class="wrap" id="header-wrap"> <div class="col-3 logo"> <a href="../../../../../../index.html"> <img src="../../../../../../assets/images/dac_logo.png" srcset="../../../../../../assets/images/dac_logo@2x.png 2x" width="123" height="25" alt="Android Developers" /> </a> <div class="btn-quicknav" id="btn-quicknav"> <a href="#" class="arrow-inactive">Quicknav</a> <a href="#" class="arrow-active">Quicknav</a> </div> </div> <ul class="nav-x col-9"> <li class="design"> <a href="../../../../../../design/index.html" zh-tw-lang="設計" zh-cn-lang="设计" ru-lang="Проектирование" ko-lang="디자인" ja-lang="設計" es-lang="Diseñar" >Design</a></li> <li class="develop"><a href="../../../../../../develop/index.html" zh-tw-lang="開發" zh-cn-lang="开发" ru-lang="Разработка" ko-lang="개발" ja-lang="開発" es-lang="Desarrollar" >Develop</a></li> <li class="distribute last"><a href="../../../../../../distribute/googleplay/index.html" zh-tw-lang="發佈" zh-cn-lang="分发" ru-lang="Распространение" ko-lang="배포" ja-lang="配布" es-lang="Distribuir" >Distribute</a></li> </ul> <div class="menu-container"> <div class="moremenu"> <div id="more-btn"></div> </div> <div class="morehover" id="moremenu"> <div class="top"></div> <div class="mid"> <div class="header">Links</div> <ul> <li><a href="https://play.google.com/apps/publish/" target="_googleplay">Google Play Developer Console</a></li> <li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li> <li><a href="../../../../../../about/index.html">About Android</a></li> </ul> <div class="header">Android Sites</div> <ul> <li><a href="http://www.android.com">Android.com</a></li> <li class="active"><a>Android Developers</a></li> <li><a href="http://source.android.com">Android Open Source Project</a></li> </ul> <br class="clearfix" /> </div><!-- end 'mid' --> <div class="bottom"></div> </div><!-- end 'moremenu' --> <div class="search" id="search-container"> <div class="search-inner"> <div id="search-btn"></div> <div class="left"></div> <form onsubmit="return submit_search()"> <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q" onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)" onkeydown="return search_changed(event, true, '../../../../../../')" onkeyup="return search_changed(event, false, '../../../../../../')" /> </form> <div class="right"></div> <a class="close hide">close</a> <div class="left"></div> <div class="right"></div> </div><!-- end search-inner --> </div><!-- end search-container --> <div class="search_filtered_wrapper reference"> <div class="suggest-card reference no-display"> <ul class="search_filtered"> </ul> </div> </div> <div class="search_filtered_wrapper docs"> <div class="suggest-card dummy no-display">&nbsp;</div> <div class="suggest-card develop no-display"> <ul class="search_filtered"> </ul> <div class="child-card guides no-display"> </div> <div class="child-card training no-display"> </div> <div class="child-card samples no-display"> </div> </div> <div class="suggest-card design no-display"> <ul class="search_filtered"> </ul> </div> <div class="suggest-card distribute no-display"> <ul class="search_filtered"> </ul> </div> </div> </div><!-- end menu-container (search and menu widget) --> <!-- Expanded quicknav --> <div id="quicknav" class="col-13"> <ul> <li class="about"> <ul> <li><a href="../../../../../../about/index.html">About</a></li> <li><a href="../../../../../../wear/index.html">Wear</a></li> <li><a href="../../../../../../tv/index.html">TV</a></li> <li><a href="../../../../../../auto/index.html">Auto</a></li> </ul> </li> <li class="design"> <ul> <li><a href="../../../../../../design/index.html">Get Started</a></li> <li><a href="../../../../../../design/devices.html">Devices</a></li> <li><a href="../../../../../../design/style/index.html">Style</a></li> <li><a href="../../../../../../design/patterns/index.html">Patterns</a></li> <li><a href="../../../../../../design/building-blocks/index.html">Building Blocks</a></li> <li><a href="../../../../../../design/downloads/index.html">Downloads</a></li> <li><a href="../../../../../../design/videos/index.html">Videos</a></li> </ul> </li> <li class="develop"> <ul> <li><a href="../../../../../../training/index.html" zh-tw-lang="訓練課程" zh-cn-lang="培训" ru-lang="Курсы" ko-lang="교육" ja-lang="トレーニング" es-lang="Capacitación" >Training</a></li> <li><a href="../../../../../../guide/index.html" zh-tw-lang="API 指南" zh-cn-lang="API 指南" ru-lang="Руководства по API" ko-lang="API 가이드" ja-lang="API ガイド" es-lang="Guías de la API" >API Guides</a></li> <li><a href="../../../../../../reference/packages.html" zh-tw-lang="參考資源" zh-cn-lang="参考" ru-lang="Справочник" ko-lang="참조문서" ja-lang="リファレンス" es-lang="Referencia" >Reference</a></li> <li><a href="../../../../../../sdk/index.html" zh-tw-lang="相關工具" zh-cn-lang="工具" ru-lang="Инструменты" ko-lang="도구" ja-lang="ツール" es-lang="Herramientas" >Tools</a> </li> <li><a href="../../../../../../google/index.html">Google Services</a> </li> </ul> </li> <li class="distribute last"> <ul> <li><a href="../../../../../../distribute/googleplay/index.html">Google Play</a></li> <li><a href="../../../../../../distribute/essentials/index.html">Essentials</a></li> <li><a href="../../../../../../distribute/users/index.html">Get Users</a></li> <li><a href="../../../../../../distribute/engage/index.html">Engage &amp; Retain</a></li> <li><a href="../../../../../../distribute/monetize/index.html">Monetize</a></li> <li><a href="../../../../../../distribute/tools/index.html">Tools &amp; Reference</a></li> <li><a href="../../../../../../distribute/stories/index.html">Developer Stories</a></li> </ul> </li> </ul> </div><!-- /Expanded quicknav --> </div><!-- end header-wrap.wrap --> </div><!-- end header --> <!-- Secondary x-nav --> <div id="nav-x"> <div class="wrap"> <ul class="nav-x col-9 develop" style="width:100%"> <li class="training"><a href="../../../../../../training/index.html" zh-tw-lang="訓練課程" zh-cn-lang="培训" ru-lang="Курсы" ko-lang="교육" ja-lang="トレーニング" es-lang="Capacitación" >Training</a></li> <li class="guide"><a href="../../../../../../guide/index.html" zh-tw-lang="API 指南" zh-cn-lang="API 指南" ru-lang="Руководства по API" ko-lang="API 가이드" ja-lang="API ガイド" es-lang="Guías de la API" >API Guides</a></li> <li class="reference"><a href="../../../../../../reference/packages.html" zh-tw-lang="參考資源" zh-cn-lang="参考" ru-lang="Справочник" ko-lang="참조문서" ja-lang="リファレンス" es-lang="Referencia" >Reference</a></li> <li class="tools"><a href="../../../../../../sdk/index.html" zh-tw-lang="相關工具" zh-cn-lang="工具" ru-lang="Инструменты" ko-lang="도구" ja-lang="ツール" es-lang="Herramientas" >Tools</a></li> <li class="google"><a href="../../../../../../google/index.html" >Google Services</a> </li> </ul> </div> </div> <!-- /Sendondary x-nav DEVELOP --> <div id="searchResults" class="wrap" style="display:none;"> <h2 id="searchTitle">Results</h2> <div id="leftSearchControl" class="search-control">Loading...</div> </div> </div> <!--end header-wrapper --> <div id="sticky-header"> <div> <a class="logo" href="#top"></a> <a class="top" href="#top"></a> <ul class="breadcrumb"> <li class="current">com.google.android.gms.gcm</li> </ul> </div> </div> <div class="wrap clearfix" id="body-content"> <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement"> <div id="devdoc-nav"> <div id="api-nav-header"> <div id="api-level-toggle"> <label for="apiLevelCheckbox" class="disabled" title="Select your target API level to dim unavailable APIs">API level: </label> <div class="select-wrapper"> <select id="apiLevelSelector"> <!-- option elements added by buildApiLevelSelector() --> </select> </div> </div><!-- end toggle --> <div id="api-nav-title">Android APIs</div> </div><!-- end nav header --> <script> var SINCE_DATA = [ ]; buildApiLevelSelector(); </script> <div id="swapper"> <div id="nav-panels"> <div id="resize-packages-nav"> <div id="packages-nav" class="scroll-pane"> <ul> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/package-summary.html">com.google.android.gms</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/actions/package-summary.html">com.google.android.gms.actions</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/package-summary.html">com.google.android.gms.ads</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/doubleclick/package-summary.html">com.google.android.gms.ads.doubleclick</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/identifier/package-summary.html">com.google.android.gms.ads.identifier</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/mediation/package-summary.html">com.google.android.gms.ads.mediation</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/mediation/admob/package-summary.html">com.google.android.gms.ads.mediation.admob</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/mediation/customevent/package-summary.html">com.google.android.gms.ads.mediation.customevent</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/purchase/package-summary.html">com.google.android.gms.ads.purchase</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/ads/search/package-summary.html">com.google.android.gms.ads.search</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/analytics/package-summary.html">com.google.android.gms.analytics</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/analytics/ecommerce/package-summary.html">com.google.android.gms.analytics.ecommerce</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/appindexing/package-summary.html">com.google.android.gms.appindexing</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/appstate/package-summary.html">com.google.android.gms.appstate</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/auth/package-summary.html">com.google.android.gms.auth</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/auth/api/package-summary.html">com.google.android.gms.auth.api</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/cast/package-summary.html">com.google.android.gms.cast</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/common/package-summary.html">com.google.android.gms.common</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/common/annotation/package-summary.html">com.google.android.gms.common.annotation</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/common/api/package-summary.html">com.google.android.gms.common.api</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/common/data/package-summary.html">com.google.android.gms.common.data</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/common/images/package-summary.html">com.google.android.gms.common.images</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/drive/package-summary.html">com.google.android.gms.drive</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/drive/events/package-summary.html">com.google.android.gms.drive.events</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/drive/metadata/package-summary.html">com.google.android.gms.drive.metadata</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/drive/query/package-summary.html">com.google.android.gms.drive.query</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/drive/widget/package-summary.html">com.google.android.gms.drive.widget</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/fitness/package-summary.html">com.google.android.gms.fitness</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/fitness/data/package-summary.html">com.google.android.gms.fitness.data</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/fitness/request/package-summary.html">com.google.android.gms.fitness.request</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/fitness/result/package-summary.html">com.google.android.gms.fitness.result</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/fitness/service/package-summary.html">com.google.android.gms.fitness.service</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/package-summary.html">com.google.android.gms.games</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/achievement/package-summary.html">com.google.android.gms.games.achievement</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/event/package-summary.html">com.google.android.gms.games.event</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/leaderboard/package-summary.html">com.google.android.gms.games.leaderboard</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/multiplayer/package-summary.html">com.google.android.gms.games.multiplayer</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/multiplayer/realtime/package-summary.html">com.google.android.gms.games.multiplayer.realtime</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/multiplayer/turnbased/package-summary.html">com.google.android.gms.games.multiplayer.turnbased</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/quest/package-summary.html">com.google.android.gms.games.quest</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/request/package-summary.html">com.google.android.gms.games.request</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/games/snapshot/package-summary.html">com.google.android.gms.games.snapshot</a></li> <li class="selected api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/gcm/package-summary.html">com.google.android.gms.gcm</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/identity/intents/package-summary.html">com.google.android.gms.identity.intents</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/identity/intents/model/package-summary.html">com.google.android.gms.identity.intents.model</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/location/package-summary.html">com.google.android.gms.location</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/maps/package-summary.html">com.google.android.gms.maps</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/maps/model/package-summary.html">com.google.android.gms.maps.model</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/panorama/package-summary.html">com.google.android.gms.panorama</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/plus/package-summary.html">com.google.android.gms.plus</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/plus/model/moments/package-summary.html">com.google.android.gms.plus.model.moments</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/plus/model/people/package-summary.html">com.google.android.gms.plus.model.people</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/security/package-summary.html">com.google.android.gms.security</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/tagmanager/package-summary.html">com.google.android.gms.tagmanager</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/wallet/package-summary.html">com.google.android.gms.wallet</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/wallet/fragment/package-summary.html">com.google.android.gms.wallet.fragment</a></li> <li class="api apilevel-"> <a href="../../../../../../reference/com/google/android/gms/wearable/package-summary.html">com.google.android.gms.wearable</a></li> </ul><br/> </div> <!-- end packages-nav --> </div> <!-- end resize-packages --> <div id="classes-nav" class="scroll-pane"> <ul> <li><h2>Classes</h2> <ul> <li class="api apilevel-"><a href="../../../../../../reference/com/google/android/gms/gcm/GoogleCloudMessaging.html">GoogleCloudMessaging</a></li> <li class="api apilevel-"><a href="../../../../../../reference/com/google/android/gms/gcm/Task.html">Task</a></li> </ul> </li> </ul><br/> </div><!-- end classes --> </div><!-- end nav-panels --> <div id="nav-tree" style="display:none" class="scroll-pane"> <div id="tree-list"></div> </div><!-- end nav-tree --> </div><!-- end swapper --> <div id="nav-swap"> <a class="fullscreen">fullscreen</a> <a href='#' onclick='swapNav();return false;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a> </div> </div> <!-- end devdoc-nav --> </div> <!-- end side-nav --> <script type="text/javascript"> // init fullscreen based on user pref var fullscreen = readCookie("fullscreen"); if (fullscreen != 0) { if (fullscreen == "false") { toggleFullscreen(false); } else { toggleFullscreen(true); } } // init nav version for mobile if (isMobile) { swapNav(); // tree view should be used on mobile $('#nav-swap').hide(); } else { chooseDefaultNav(); if ($("#nav-tree").is(':visible')) { init_default_navtree("../../../../../../"); } } // scroll the selected page into view $(document).ready(function() { scrollIntoView("packages-nav"); scrollIntoView("classes-nav"); }); </script> <div class="col-12" id="doc-col"> <div id="api-info-block"> <div class="api-level"> </div> </div> <div id="jd-header"> package <h1>com.google.android.gms.gcm</h1> </div><!-- end header --> <div id="naMessage"></div> <div id="jd-content" class="api apilevel-"> <h2>Classes</h2> <div class="jd-sumtable"> <table class="jd-sumtable-expando"> <tr class="alt-color api apilevel-" > <td class="jd-linkcol"><a href="../../../../../../reference/com/google/android/gms/gcm/GoogleCloudMessaging.html">GoogleCloudMessaging</a></td> <td class="jd-descrcol" width="100%"><p>The class you use to write a GCM-enabled client application that runs on an Android device.&nbsp;</td> </tr> <tr class=" api apilevel-" > <td class="jd-linkcol"><a href="../../../../../../reference/com/google/android/gms/gcm/Task.html">Task</a></td> <td class="jd-descrcol" width="100%">Encapsulates the parameters of a task that you will schedule on the GcmNetworkManager.&nbsp;</td> </tr> </table> </div> <div id="footer" class="wrap" > <div id="copyright"> Except as noted, this content is licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. For details and restrictions, see the <a href="../../../../../../license.html"> Content License</a>. </div> <div id="build_info"> Android GmsCore 1474901&nbsp;r &mdash; <script src="../../../../../../timestamp.js" type="text/javascript"></script> <script>document.write(BUILD_TIMESTAMP)</script> </div> <div id="footerlinks"> <p> <a href="../../../../../../about/index.html">About Android</a>&nbsp;&nbsp;|&nbsp; <a href="../../../../../../legal.html">Legal</a>&nbsp;&nbsp;|&nbsp; <a href="../../../../../../support.html">Support</a> </p> </div> </div> <!-- end footer --> </div><!-- end jd-content --> </div><!-- doc-content --> </div> <!-- end body-content --> </body> </html>
DarkoDanchev/BeerDrop-Game-
BeerDrop-android/libs/google_play_services/docs/reference/com/google/android/gms/gcm/package-summary.html
HTML
gpl-2.0
27,456
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869, 13462, 1027, 21183, 2546, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/******************************************************************************* * Copyright 2016 Intuit * <p> * 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ package com.intuit.wasabi.auditlogobjects; import com.intuit.wasabi.eventlog.events.BucketCreateEvent; import com.intuit.wasabi.eventlog.events.BucketEvent; import com.intuit.wasabi.eventlog.events.ChangeEvent; import com.intuit.wasabi.eventlog.events.EventLogEvent; import com.intuit.wasabi.eventlog.events.ExperimentChangeEvent; import com.intuit.wasabi.eventlog.events.ExperimentCreateEvent; import com.intuit.wasabi.eventlog.events.ExperimentEvent; import com.intuit.wasabi.eventlog.events.SimpleEvent; import com.intuit.wasabi.experimentobjects.Bucket; import com.intuit.wasabi.experimentobjects.Experiment; import org.junit.Assert; import org.junit.Test; import org.mockito.Mockito; import java.lang.reflect.Field; /** * Tests for {@link AuditLogEntryFactory}. */ public class AuditLogEntryFactoryTest { @Test public void testCreateFromEvent() throws Exception { new AuditLogEntryFactory(); EventLogEvent[] events = new EventLogEvent[]{ new SimpleEvent("SimpleEvent"), new ExperimentChangeEvent(Mockito.mock(Experiment.class), "Property", "before", "after"), new ExperimentCreateEvent(Mockito.mock(Experiment.class)), new BucketCreateEvent(Mockito.mock(Experiment.class), Mockito.mock(Bucket.class)) }; Field[] fields = AuditLogEntry.class.getFields(); for (Field field : fields) { field.setAccessible(true); } for (EventLogEvent event : events) { AuditLogEntry aleFactory = AuditLogEntryFactory.createFromEvent(event); AuditLogEntry aleManual = new AuditLogEntry( event.getTime(), event.getUser(), AuditLogAction.getActionForEvent(event), event instanceof ExperimentEvent ? ((ExperimentEvent) event).getExperiment() : null, event instanceof BucketEvent ? ((BucketEvent) event).getBucket().getLabel() : null, event instanceof ChangeEvent ? ((ChangeEvent) event).getPropertyName() : null, event instanceof ChangeEvent ? ((ChangeEvent) event).getBefore() : null, event instanceof ChangeEvent ? ((ChangeEvent) event).getAfter() : null ); for (Field field : fields) { Assert.assertEquals(field.get(aleManual), field.get(aleFactory)); } } } }
intuit/wasabi
modules/auditlog-objects/src/test/java/com/intuit/wasabi/auditlogobjects/AuditLogEntryFactoryTest.java
Java
apache-2.0
3,157
[ 30522, 1013, 30524, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/************************************************************************ $Id: rtbinit.h,v 1.2 2005/02/24 10:27:55 jonico Exp $ RTB - Team Framework: Framework for RealTime Battle robots to communicate efficiently in a team Copyright (C) 2004 The RTB- Team Framework Group: http://rtb-team.sourceforge.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA $Log: rtbinit.h,v $ Revision 1.2 2005/02/24 10:27:55 jonico Updated newest version of the framework Revision 1.2 2005/01/06 17:59:34 jonico Now all files in the repository have their new header format. **************************************************************************/ #ifndef RTBINIT_H #define RTBINIT_H #include "../stdnamespace.h" #include "../exceptions/parserexception.h" #include "../exceptions/ioexception.h" /** * Namespace RTBGlobal */namespace RTBGlobal { using std::string; using Exceptions::ParserException; using std::bad_exception; using Exceptions::RTBException; using Exceptions::IOException; /** * Class RTBInit */ class RTBInit { /* * Public stuff */ public: /* * Operations */ /** * Calls the RTBConfig Parser to parse the config file, register the pasring result in the MRC * @param configFileName Path to the file containing the absolute necessary configuration data */ static void ParseConfigFile (const string& configFileName) throw (ParserException, bad_exception); /** * This method first has to switch to blocking mode * This method has to send: * 1. The Robot Option USE_NON_BLOCKING 1 (this is tricky, we do not want to be killed by the RTB Server, so we chose non blocking for it, but set our descriptors to block * 2. The Robot Option SEND_ROTATION_REACHED with a specified value in the configuration file * 3. the name and the color of the robot if requested (first sequence) * This method has to read: * 1. The Initialize Command * 2. If it is not the first sequence in the tournament, the YourColour and YourNameCommand * This methods registers the following runtime properties: * 1. Section Main, Key FirstSequence : "true" / "false" * 2. Section Main, Key ActualColor : actual color as hex string, if first sequence, this value will be set to RobotHomeColor in section Main of the configuration file * 3. Section Main, Key ActualName: actual name of the roboter given by the server, if first sequence, this value will be set to RobotName in section Main of the configuration file */ static void SendInitialMessages() throw (IOException, bad_exception); /** * Starts the game as a client or as the RTB MasterServer (automatically found out by the MRC) * @return true, if no error occured in the whole sequence, false if something went wrong and we could not continue playing */ static bool StartGame () throw (RTBException, bad_exception); }; } #endif //RTBINIT_H
ezag/realtimebattle
rtb-team-framework/rtbglobal/rtbinit.h
C
gpl-2.0
3,567
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// This file was procedurally generated from the following sources: // - src/spread/sngl-err-obj-unresolvable.case // - src/spread/error/array.template /*--- description: Object Spread operator results in error when using an unresolvable reference (Array initializer) esid: sec-runtime-semantics-arrayaccumulation es6id: 12.2.5.2 features: [object-spread] flags: [generated] info: | SpreadElement : ...AssignmentExpression 1. Let spreadRef be the result of evaluating AssignmentExpression. 2. Let spreadObj be ? GetValue(spreadRef). 3. Let iterator be ? GetIterator(spreadObj). 4. Repeat a. Let next be ? IteratorStep(iterator). b. If next is false, return nextIndex. c. Let nextValue be ? IteratorValue(next). d. Let status be CreateDataProperty(array, ToString(ToUint32(nextIndex)), nextValue). e. Assert: status is true. f. Let nextIndex be nextIndex + 1. Pending Runtime Semantics: PropertyDefinitionEvaluation PropertyDefinition:...AssignmentExpression 1. Let exprValue be the result of evaluating AssignmentExpression. 2. Let fromValue be GetValue(exprValue). 3. ReturnIfAbrupt(fromValue). 4. Let excludedNames be a new empty List. 5. Return CopyDataProperties(object, fromValue, excludedNames). ---*/ assert.throws(ReferenceError, function() { [{...unresolvableReference}]; });
sebastienros/jint
Jint.Tests.Test262/test/language/expressions/array/spread-err-sngl-err-obj-unresolvable.js
JavaScript
bsd-2-clause
1,393
[ 30522, 1013, 1013, 2023, 5371, 2001, 24508, 2135, 7013, 2013, 1996, 2206, 4216, 1024, 1013, 1013, 1011, 5034, 2278, 1013, 3659, 1013, 1055, 3070, 2140, 1011, 9413, 2099, 1011, 27885, 3501, 1011, 4895, 6072, 4747, 12423, 1012, 2553, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This is a YAML 1.2 parser. // // See http://www.yaml.org/spec/1.2/spec.html for the full standard. // // This currently does not implement the following: // * Multi-line literal folding. // * Tag resolution. // * UTF-16. // * BOMs anywhere other than the first Unicode scalar value in the file. // // The most important class here is Stream. This represents a YAML stream with // 0, 1, or many documents. // // SourceMgr sm; // StringRef input = getInput(); // yaml::Stream stream(input, sm); // // for (yaml::document_iterator di = stream.begin(), de = stream.end(); // di != de; ++di) { // yaml::Node *n = di->getRoot(); // if (n) { // // Do something with n... // } else // break; // } // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_YAMLPARSER_H #define LLVM_SUPPORT_YAMLPARSER_H #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/SMLoc.h" #include <cassert> #include <cstddef> #include <iterator> #include <map> #include <memory> #include <string> #include <system_error> namespace llvm { class MemoryBufferRef; class SourceMgr; class raw_ostream; class Twine; namespace yaml { class Document; class document_iterator; class Node; class Scanner; struct Token; /// \brief Dump all the tokens in this stream to OS. /// \returns true if there was an error, false otherwise. bool dumpTokens(StringRef Input, raw_ostream &); /// \brief Scans all tokens in input without outputting anything. This is used /// for benchmarking the tokenizer. /// \returns true if there was an error, false otherwise. bool scanTokens(StringRef Input); /// \brief Escape \a Input for a double quoted scalar. std::string escape(StringRef Input); /// \brief This class represents a YAML stream potentially containing multiple /// documents. class Stream { public: /// \brief This keeps a reference to the string referenced by \p Input. Stream(StringRef Input, SourceMgr &, bool ShowColors = true, std::error_code *EC = nullptr); Stream(MemoryBufferRef InputBuffer, SourceMgr &, bool ShowColors = true, std::error_code *EC = nullptr); ~Stream(); document_iterator begin(); document_iterator end(); void skip(); bool failed(); bool validate() { skip(); return !failed(); } void printError(Node *N, const Twine &Msg); private: friend class Document; std::unique_ptr<Scanner> scanner; std::unique_ptr<Document> CurrentDoc; }; /// \brief Abstract base class for all Nodes. class Node { virtual void anchor(); public: enum NodeKind { NK_Null, NK_Scalar, NK_BlockScalar, NK_KeyValue, NK_Mapping, NK_Sequence, NK_Alias }; Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor, StringRef Tag); void *operator new(size_t Size, BumpPtrAllocator &Alloc, size_t Alignment = 16) noexcept { return Alloc.Allocate(Size, Alignment); } void operator delete(void *Ptr, BumpPtrAllocator &Alloc, size_t Size) noexcept { Alloc.Deallocate(Ptr, Size); } void operator delete(void *) noexcept = delete; /// \brief Get the value of the anchor attached to this node. If it does not /// have one, getAnchor().size() will be 0. StringRef getAnchor() const { return Anchor; } /// \brief Get the tag as it was written in the document. This does not /// perform tag resolution. StringRef getRawTag() const { return Tag; } /// \brief Get the verbatium tag for a given Node. This performs tag resoluton /// and substitution. std::string getVerbatimTag() const; SMRange getSourceRange() const { return SourceRange; } void setSourceRange(SMRange SR) { SourceRange = SR; } // These functions forward to Document and Scanner. Token &peekNext(); Token getNext(); Node *parseBlockNode(); BumpPtrAllocator &getAllocator(); void setError(const Twine &Message, Token &Location) const; bool failed() const; virtual void skip() {} unsigned int getType() const { return TypeID; } protected: std::unique_ptr<Document> &Doc; SMRange SourceRange; ~Node() = default; private: unsigned int TypeID; StringRef Anchor; /// \brief The tag as typed in the document. StringRef Tag; }; /// \brief A null value. /// /// Example: /// !!null null class NullNode final : public Node { void anchor() override; public: NullNode(std::unique_ptr<Document> &D) : Node(NK_Null, D, StringRef(), StringRef()) {} static bool classof(const Node *N) { return N->getType() == NK_Null; } }; /// \brief A scalar node is an opaque datum that can be presented as a /// series of zero or more Unicode scalar values. /// /// Example: /// Adena class ScalarNode final : public Node { void anchor() override; public: ScalarNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag, StringRef Val) : Node(NK_Scalar, D, Anchor, Tag), Value(Val) { SMLoc Start = SMLoc::getFromPointer(Val.begin()); SMLoc End = SMLoc::getFromPointer(Val.end()); SourceRange = SMRange(Start, End); } // Return Value without any escaping or folding or other fun YAML stuff. This // is the exact bytes that are contained in the file (after conversion to // utf8). StringRef getRawValue() const { return Value; } /// \brief Gets the value of this node as a StringRef. /// /// \param Storage is used to store the content of the returned StringRef iff /// it requires any modification from how it appeared in the source. /// This happens with escaped characters and multi-line literals. StringRef getValue(SmallVectorImpl<char> &Storage) const; static bool classof(const Node *N) { return N->getType() == NK_Scalar; } private: StringRef Value; StringRef unescapeDoubleQuoted(StringRef UnquotedValue, StringRef::size_type Start, SmallVectorImpl<char> &Storage) const; }; /// \brief A block scalar node is an opaque datum that can be presented as a /// series of zero or more Unicode scalar values. /// /// Example: /// | /// Hello /// World class BlockScalarNode final : public Node { void anchor() override; public: BlockScalarNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag, StringRef Value, StringRef RawVal) : Node(NK_BlockScalar, D, Anchor, Tag), Value(Value) { SMLoc Start = SMLoc::getFromPointer(RawVal.begin()); SMLoc End = SMLoc::getFromPointer(RawVal.end()); SourceRange = SMRange(Start, End); } /// \brief Gets the value of this node as a StringRef. StringRef getValue() const { return Value; } static bool classof(const Node *N) { return N->getType() == NK_BlockScalar; } private: StringRef Value; }; /// \brief A key and value pair. While not technically a Node under the YAML /// representation graph, it is easier to treat them this way. /// /// TODO: Consider making this not a child of Node. /// /// Example: /// Section: .text class KeyValueNode final : public Node { void anchor() override; public: KeyValueNode(std::unique_ptr<Document> &D) : Node(NK_KeyValue, D, StringRef(), StringRef()) {} /// \brief Parse and return the key. /// /// This may be called multiple times. /// /// \returns The key, or nullptr if failed() == true. Node *getKey(); /// \brief Parse and return the value. /// /// This may be called multiple times. /// /// \returns The value, or nullptr if failed() == true. Node *getValue(); void skip() override { getKey()->skip(); if (Node *Val = getValue()) Val->skip(); } static bool classof(const Node *N) { return N->getType() == NK_KeyValue; } private: Node *Key = nullptr; Node *Value = nullptr; }; /// \brief This is an iterator abstraction over YAML collections shared by both /// sequences and maps. /// /// BaseT must have a ValueT* member named CurrentEntry and a member function /// increment() which must set CurrentEntry to 0 to create an end iterator. template <class BaseT, class ValueT> class basic_collection_iterator : public std::iterator<std::input_iterator_tag, ValueT> { public: basic_collection_iterator() = default; basic_collection_iterator(BaseT *B) : Base(B) {} ValueT *operator->() const { assert(Base && Base->CurrentEntry && "Attempted to access end iterator!"); return Base->CurrentEntry; } ValueT &operator*() const { assert(Base && Base->CurrentEntry && "Attempted to dereference end iterator!"); return *Base->CurrentEntry; } operator ValueT *() const { assert(Base && Base->CurrentEntry && "Attempted to access end iterator!"); return Base->CurrentEntry; } /// Note on EqualityComparable: /// /// The iterator is not re-entrant, /// it is meant to be used for parsing YAML on-demand /// Once iteration started - it can point only to one entry at a time /// hence Base.CurrentEntry and Other.Base.CurrentEntry are equal /// iff Base and Other.Base are equal. bool operator==(const basic_collection_iterator &Other) const { if (Base && (Base == Other.Base)) { assert((Base->CurrentEntry == Other.Base->CurrentEntry) && "Equal Bases expected to point to equal Entries"); } return Base == Other.Base; } bool operator!=(const basic_collection_iterator &Other) const { return !(Base == Other.Base); } basic_collection_iterator &operator++() { assert(Base && "Attempted to advance iterator past end!"); Base->increment(); // Create an end iterator. if (!Base->CurrentEntry) Base = nullptr; return *this; } private: BaseT *Base = nullptr; }; // The following two templates are used for both MappingNode and Sequence Node. template <class CollectionType> typename CollectionType::iterator begin(CollectionType &C) { assert(C.IsAtBeginning && "You may only iterate over a collection once!"); C.IsAtBeginning = false; typename CollectionType::iterator ret(&C); ++ret; return ret; } template <class CollectionType> void skip(CollectionType &C) { // TODO: support skipping from the middle of a parsed collection ;/ assert((C.IsAtBeginning || C.IsAtEnd) && "Cannot skip mid parse!"); if (C.IsAtBeginning) for (typename CollectionType::iterator i = begin(C), e = C.end(); i != e; ++i) i->skip(); } /// \brief Represents a YAML map created from either a block map for a flow map. /// /// This parses the YAML stream as increment() is called. /// /// Example: /// Name: _main /// Scope: Global class MappingNode final : public Node { void anchor() override; public: enum MappingType { MT_Block, MT_Flow, MT_Inline ///< An inline mapping node is used for "[key: value]". }; MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag, MappingType MT) : Node(NK_Mapping, D, Anchor, Tag), Type(MT) {} friend class basic_collection_iterator<MappingNode, KeyValueNode>; using iterator = basic_collection_iterator<MappingNode, KeyValueNode>; template <class T> friend typename T::iterator yaml::begin(T &); template <class T> friend void yaml::skip(T &); iterator begin() { return yaml::begin(*this); } iterator end() { return iterator(); } void skip() override { yaml::skip(*this); } static bool classof(const Node *N) { return N->getType() == NK_Mapping; } private: MappingType Type; bool IsAtBeginning = true; bool IsAtEnd = false; KeyValueNode *CurrentEntry = nullptr; void increment(); }; /// \brief Represents a YAML sequence created from either a block sequence for a /// flow sequence. /// /// This parses the YAML stream as increment() is called. /// /// Example: /// - Hello /// - World class SequenceNode final : public Node { void anchor() override; public: enum SequenceType { ST_Block, ST_Flow, // Use for: // // key: // - val1 // - val2 // // As a BlockMappingEntry and BlockEnd are not created in this case. ST_Indentless }; SequenceNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag, SequenceType ST) : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST) {} friend class basic_collection_iterator<SequenceNode, Node>; using iterator = basic_collection_iterator<SequenceNode, Node>; template <class T> friend typename T::iterator yaml::begin(T &); template <class T> friend void yaml::skip(T &); void increment(); iterator begin() { return yaml::begin(*this); } iterator end() { return iterator(); } void skip() override { yaml::skip(*this); } static bool classof(const Node *N) { return N->getType() == NK_Sequence; } private: SequenceType SeqType; bool IsAtBeginning = true; bool IsAtEnd = false; bool WasPreviousTokenFlowEntry = true; // Start with an imaginary ','. Node *CurrentEntry = nullptr; }; /// \brief Represents an alias to a Node with an anchor. /// /// Example: /// *AnchorName class AliasNode final : public Node { void anchor() override; public: AliasNode(std::unique_ptr<Document> &D, StringRef Val) : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {} StringRef getName() const { return Name; } Node *getTarget(); static bool classof(const Node *N) { return N->getType() == NK_Alias; } private: StringRef Name; }; /// \brief A YAML Stream is a sequence of Documents. A document contains a root /// node. class Document { public: Document(Stream &ParentStream); /// \brief Root for parsing a node. Returns a single node. Node *parseBlockNode(); /// \brief Finish parsing the current document and return true if there are /// more. Return false otherwise. bool skip(); /// \brief Parse and return the root level node. Node *getRoot() { if (Root) return Root; return Root = parseBlockNode(); } const std::map<StringRef, StringRef> &getTagMap() const { return TagMap; } private: friend class Node; friend class document_iterator; /// \brief Stream to read tokens from. Stream &stream; /// \brief Used to allocate nodes to. All are destroyed without calling their /// destructor when the document is destroyed. BumpPtrAllocator NodeAllocator; /// \brief The root node. Used to support skipping a partially parsed /// document. Node *Root; /// \brief Maps tag prefixes to their expansion. std::map<StringRef, StringRef> TagMap; Token &peekNext(); Token getNext(); void setError(const Twine &Message, Token &Location) const; bool failed() const; /// \brief Parse %BLAH directives and return true if any were encountered. bool parseDirectives(); /// \brief Parse %YAML void parseYAMLDirective(); /// \brief Parse %TAG void parseTAGDirective(); /// \brief Consume the next token and error if it is not \a TK. bool expectToken(int TK); }; /// \brief Iterator abstraction for Documents over a Stream. class document_iterator { public: document_iterator() = default; document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {} bool operator==(const document_iterator &Other) { if (isAtEnd() || Other.isAtEnd()) return isAtEnd() && Other.isAtEnd(); return Doc == Other.Doc; } bool operator!=(const document_iterator &Other) { return !(*this == Other); } document_iterator operator++() { assert(Doc && "incrementing iterator past the end."); if (!(*Doc)->skip()) { Doc->reset(nullptr); } else { Stream &S = (*Doc)->stream; Doc->reset(new Document(S)); } return *this; } Document &operator*() { return *Doc->get(); } std::unique_ptr<Document> &operator->() { return *Doc; } private: bool isAtEnd() const { return !Doc || !*Doc; } std::unique_ptr<Document> *Doc = nullptr; }; } // end namespace yaml } // end namespace llvm #endif // LLVM_SUPPORT_YAMLPARSER_H
karies/root
interpreter/llvm/src/include/llvm/Support/YAMLParser.h
C
lgpl-2.1
16,420
[ 30522, 1013, 1013, 1027, 1027, 1027, 1011, 8038, 19968, 19362, 8043, 1012, 1044, 1011, 3722, 8038, 19968, 11968, 8043, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2015 fjz13. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. #include "MedusaCorePreCompiled.h" #include "SirenFieldAttribute.h" #include "Core/IO/Stream/IStream.h" #include "Core/Log/Log.h" MEDUSA_BEGIN; SirenFieldAttribute::~SirenFieldAttribute(void) { } bool SirenFieldAttribute::IsRequired() const { return !MEDUSA_FLAG_HAS(mMode, SirenFieldGenerateMode::Optional); } bool SirenFieldAttribute::OnLoaded() { StringPropertySet copy = mKeyValues; if (mKeyValues.RemoveKey("Optional")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::Optional); } if (mKeyValues.RemoveKey("?")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::Optional); } if (mKeyValues.RemoveKey("+")) { MEDUSA_FLAG_REMOVE(mMode, SirenFieldGenerateMode::Optional); } if (mKeyValues.RemoveKey("ForceKeyToPtr")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::ForceKeyToPtr); } if (mKeyValues.RemoveKey("ForceValueToPtr")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::ForceValueToPtr); } if (mKeyValues.RemoveKey("AddDictionaryMethods")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::AddDictionaryMethods); } if (mKeyValues.RemoveKey("SuppressMethod")) { MEDUSA_FLAG_ADD(mMode, SirenFieldGenerateMode::SuppressMethod); } return true; } StringRef SirenFieldAttribute::Modifier() const { if (IsRequired()) { return "Required"; } return "Optional"; } bool SirenFieldAttribute::LoadFrom(IStream& stream) { RETURN_FALSE_IF_FALSE(ISirenAttribute::LoadFrom(stream)); mMode = stream.Read<SirenFieldGenerateMode>(); return true; } bool SirenFieldAttribute::SaveTo(IStream& stream) const { RETURN_FALSE_IF_FALSE(ISirenAttribute::SaveTo(stream)); stream.Write(mMode); return true; } MEDUSA_END;
fjz13/Medusa
Medusa/MedusaCore/Core/Siren/Schema/Attribute/SirenFieldAttribute.cpp
C++
mit
1,822
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2325, 1042, 3501, 2480, 17134, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 10210, 1011, 2806, 1013, 1013, 6105, 2008, 2064, 2022, 2179, 1999, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!--买家订单关闭-退款阶段(暂时不需要,内容整合到订单关闭页面)--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <!--[if IE 8]> <html xmlns:ng="http://angularjs.org" class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html xmlns:ng="http://angularjs.org" class="no-js"> <!--<![endif]--> <html lang="en" ng-app="njyApp"> <head> <meta charset="UTF-8"> <meta name="renderer" content="webkit"><!-- 国产双核浏览器,启用极速模式 --> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="description" content=""> <meta name="viewport" content="width=device-width"> <meta http-equiv="Access-Control-Allow-Origin" content="*"> <base href="/"> <title>买家订单关闭-退款</title> <link rel="stylesheet" href="./css/common.css"> <link rel="stylesheet" href="./css/su-pu/seller-qr.css"> <link rel="stylesheet" href="./css/su-pu/buy-fk.css"> <link rel="stylesheet" href="./css/su-pu/buy-gb.css"> </head> <body ng-controller="myapp" ng-cloak class="ng-cloak"> <!--头部--> <div njy-pageheader></div> <!--农加易--> <div njy-pagelogo data-title="订单详情"></div> <div class="content w1200"> <div class="content-header"> <div class="content-header-l clearfix"> <p class="fz12 color3">订单号:59668039107</p> <strong>订单关闭</strong><br> <span class="fz12 color9">关闭类型:订单商品全部退款成功</span><br> <span></span> </div> <div class="content-header-r clearfix"> <span class="fz12 color9">订单创建时间:2017-07-19 12:37:12</span><br> <span class="fz12 color9">订单关闭时间:2017-07-19 12:37:12</span> </div> </div> <!--订单信息--> <div class="order-xx"> <p class="fz16 color6">订单信息</p> <div class="order-main"> <div class="order-mian-shr"> <span class="fz14 color6">收货人信息</span> <p class="fz12 color3"><i class="color6">收货信息:</i>老王,156022164,广州市天河区林和中路125号天宇花样二期裙楼4楼3wcoffice天宇清创社区4852900</p> </div> <div class="order-mian-gy"> <p class="gy fz14 color6">供应商信息</p> <div class="gy-l fz12 color3"> <p class="xx"><i class="color6">供应商信息:</i>广东省梅州李银河合作社</p> <p class="szd"><i class="color6">所在地:</i>广东省梅州市蕉岭县葱花大道123号</p> </div> <div class="gy-r fz12 color3"> <p class="lxr"><i class="color6">联系人:</i>李银河</p> <p class="lxfs"><i class="color6">联系方式:</i>1561204032</p> </div> </div> <div class="order-sh-ps"> <p class="gy fz14 color6">配送信息</p> <div class="gy-l fz12 color3"> <p><i class="color6">物流方式:</i>走快递</p> <p class="p0"><i class="color6">运费:</i>22.00元</p> </div> <div class="gy-l fz12 color3"> <p class="p55"><i class="w88 color6">发货方式:</i>第三方物流</p> <p class="p0 p55"><i class="w88 color6">预计到达时间:</i>2017年8月30</p> </div> <div class="gy-l brn fz12 color3"> <p class="p55"><i class="color6">物流公司:</i>顺丰速运</p> <p class="p0 p55"><i class="color6">物流单号:</i>654645345453</p> </div> </div> <div class="order-sh-ps"> <p class="gy fz14 color6">配送信息</p> <div class="gy-l fz12 color3"> <p><i class="color6">物流方式:</i>走快递</p> <p class="p0"><i class="color6">运费:</i>22.00元</p> </div> <div class="gy-l fz12 color3"> <p class="p55"><i class="w88 color6">发货方式:</i>私人司机</p> <p class="p0 p55"><i class="w88 color6">预计到达时间:</i>2017年8月30</p> </div> <div class="gy-l fz12 color3"> <p class="p55"><i class="color6">司机姓名:</i>欧阳顺丰</p> <p class="p0 p55"><i class="color6">手机号码:</i>654645345453</p> </div> <div class="gy-l brn fz12 color3"> <p class="p55"><i class="color6">车牌号码:</i>粤AK364</p> <p class="p0 p55"><i class="color6">车辆外观:</i>白色</p> </div> </div> <div class="order-mian-mjly"> <p class="mjly fz14 color6">买家留言</p> <span class="fz12 color3">买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,买家留言,</span> </div> <div class="order-mian-spxx"> <p class="fz14 color6">商品信息</p> <div class="spxx-list"> <ul class="spxx-title clearfix fz12 color3"> <li class="spxx-title-sp1">商品名称</li> <li class="spxx-title-sp2">状态</li> <li class="spxx-title-sp3">单价/规格</li> <li class="spxx-title-sp4">数量</li> <li class="spxx-title-sp5">小计</li> </ul> <div class="spxx-order fz12 color3"> <ul class="clearfix"> <li class="spxx-order-l1"> <div class="spxx-order-img"> <img src="./img/su-pu/commodity.jpg" alt=""> </div> <div class="spxx-order-a"> <a href="javascript:;">抬升有机红枫岭小番茄 mahota农产品新鲜素材上海同城配送</a> </div> </li> <li class="spxx-order-l2">待确认</li> <li class="spxx-order-l3"><strong>¥7.00</strong>/ <i class="color6">斤</i></li> <li class="spxx-order-l4">350</li> <li class="spxx-order-l5"><strong>¥2450.00</strong></li> </ul> </div> <div class="spxx-order fz12 color3"> <ul class="clearfix"> <li class="spxx-order-l1"> <div class="spxx-order-img"> <img src="./img/su-pu/commodity.jpg" alt=""> </div> <div class="spxx-order-a"> <a href="javascript:;">抬升有机红枫岭小番茄 mahota农产品新鲜素材上海同城配送</a> </div> </li> <li class="spxx-order-l2">待确认</li> <li class="spxx-order-l3"><strong>¥7.00</strong>/ <i class="color6">斤</i></li> <li class="spxx-order-l4">350</li> <li class="spxx-order-l5"><strong>¥2450.00</strong></li> </ul> </div> <p class="zje fz12 color3"> 商品总金额(不含运费):&nbsp;<strong class="zjecur">Y2450</strong> </p> <!--<p class="gj">--> <!--(供应商改价):&nbsp;<strong>Y2450</strong>--> <!--</p>--> <p class="yf fz12 color3"> 运费:&nbsp;<strong>Y2450</strong> </p> <p class="yf2 fz12 color3"> 已付:&nbsp;<strong class="fz16" style="color: #999">¥2450.00</strong>元 </p> </div> </div> </div> </div> </div> <!--尾部--> <div njy-pagefoot></div> <!--确认订单弹窗--> <div class="qrddAlert" style="display: none"> <div class="qrAlert"> 确认订单成功,请等待采购商付款 <button class="qrbtn"> 确认 </button> </div> </div> <!--js--> <script src="./js/My97DatePicker/WdatePicker.js"></script> <script src="./js/vendor/jquery-1.8.2.min.js"></script> <script src="./js/vendor/jquery.placeholder.js"></script> <script src="./js/lib/angular-1.2.32/angular.js"></script> <script src="./js/vendor/modernizr-2.6.2.min.js"></script> <script src="./js/config.js"></script> <script src="./js/util.js"></script> <script src="./js/directive/directives.js"></script> <script src="./js/model/model.js"></script> <script src="./js/index.js"></script> <script src="./js/su-pu/buy-gb-tk.js"></script> </body> </html>
souths/njy2
view/manage/purchase/buy-gb-tk.html
HTML
mit
9,588
[ 30522, 1026, 999, 1011, 1011, 100, 1825, 100, 100, 100, 100, 1011, 100, 100, 100, 100, 1987, 100, 100, 1744, 100, 100, 1989, 1773, 100, 100, 1792, 100, 100, 100, 100, 100, 100, 1976, 1988, 1011, 1011, 1028, 1026, 999, 9986, 13874, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!doctype html> <html class="default no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Graph | Graphs and Paths</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="../assets/css/main.css"> </head> <body> <header> <div class="tsd-page-toolbar"> <div class="container"> <div class="table-wrap"> <div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base=".."> <div class="field"> <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label> <input id="tsd-search-field" type="text" /> </div> <ul class="results"> <li class="state loading">Preparing search index...</li> <li class="state failure">The search index is not available</li> </ul> <a href="../index.html" class="title">Graphs and Paths</a> </div> <div class="table-cell" id="tsd-widgets"> <div id="tsd-filter"> <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a> <div class="tsd-filter-group"> <div class="tsd-select" id="tsd-filter-visibility"> <span class="tsd-select-label">All</span> <ul class="tsd-select-list"> <li data-value="public">Public</li> <li data-value="protected">Public/Protected</li> <li data-value="private" class="selected">All</li> </ul> </div> <input type="checkbox" id="tsd-filter-inherited" checked /> <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label> <input type="checkbox" id="tsd-filter-externals" checked /> <label class="tsd-widget" for="tsd-filter-externals">Externals</label> </div> </div> <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a> </div> </div> </div> </div> <div class="tsd-page-title"> <div class="container"> <ul class="tsd-breadcrumb"> <li> <a href="../index.html">Globals</a> </li> <li> <a href="graph.html">Graph</a> </li> </ul> <h1>Class Graph</h1> </div> </div> </header> <div class="container container-main"> <div class="row"> <div class="col-8 col-content"> <section class="tsd-panel tsd-comment"> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>A graph composed of <a href="../interfaces/node.html">Node</a>s and <a href="../interfaces/edge.html">Edge</a>s, representing 2-D spatial points and links between them. Provides methods for reading and analyzing its data.</p> </div> <p>The graph and all its data are immutable. No method will modify the <code>Graph</code> instance on which it is called, although some will return new instances.</p> <p>New <code>Graph</code> instances are created using <a href="graph.html#create">Graph.create</a>, which takes <a href="../interfaces/simplenode.html">SimpleNode</a>s and <a href="../interfaces/simpleedge.html">SimpleEdge</a>s as arguments. Upon construction, the graph creates corresponding <a href="../interfaces/node.html">Node</a> and <a href="../interfaces/edge.html">Edge</a> instances which contain additional information. All <code>Graph</code> methods will return these <code>Node</code>s rather than the original <code>SimpleNode</code>s, and likewise for edges.</p> <p>Example usage:</p> <pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Graph <span class="hljs-keyword">from</span> <span class="hljs-string">"graphs-and-paths"</span>; <span class="hljs-keyword">const</span> nodes = [ { <span class="hljs-attr">id</span>: <span class="hljs-string">"A"</span>, <span class="hljs-attr">location</span>: { <span class="hljs-attr">x</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">y</span>: <span class="hljs-number">0</span> } }, { <span class="hljs-attr">id</span>: <span class="hljs-string">"B"</span>, <span class="hljs-attr">location</span>: { <span class="hljs-attr">x</span>: <span class="hljs-number">3</span>, <span class="hljs-attr">y</span>: <span class="hljs-number">0</span> } }, { <span class="hljs-attr">id</span>: <span class="hljs-string">"C"</span>, <span class="hljs-attr">location</span>: { <span class="hljs-attr">x</span>: <span class="hljs-number">0</span>, <span class="hljs-attr">y</span>: <span class="hljs-number">4</span> } } ]; <span class="hljs-keyword">const</span> edges = [ { <span class="hljs-attr">id</span>: <span class="hljs-string">"AB"</span>, <span class="hljs-attr">startNodeId</span>: <span class="hljs-string">"A"</span>, <span class="hljs-attr">endNodeId</span>: <span class="hljs-string">"B"</span> }, { <span class="hljs-attr">id</span>: <span class="hljs-string">"BC"</span>, <span class="hljs-attr">startNodeId</span>: <span class="hljs-string">"B"</span>, <span class="hljs-attr">endNodeId</span>: <span class="hljs-string">"C"</span> }, { <span class="hljs-attr">id</span>: <span class="hljs-string">"CA"</span>, <span class="hljs-attr">startNodeId</span>: <span class="hljs-string">"C"</span>, <span class="hljs-attr">endNodeId</span>: <span class="hljs-string">"A"</span> } ]; <span class="hljs-keyword">const</span> graph = Graph.create(nodes, edges); graph.getNode(<span class="hljs-string">"A"</span>); <span class="hljs-comment">// { id: "A", location: { x: 0, y: 0 }, edgeIds: ["AB", "CA"] }</span> graph.getLocation(<span class="hljs-string">"AB"</span>, <span class="hljs-number">2</span>); <span class="hljs-comment">// { x: 2, y: 0 }</span> graph.getShortestPath( { <span class="hljs-attr">edgeId</span>: <span class="hljs-string">"CA"</span>, <span class="hljs-attr">distance</span>: <span class="hljs-number">3</span> }, { <span class="hljs-attr">edgeId</span>: <span class="hljs-string">"BC"</span>, <span class="hljs-attr">distance</span>: <span class="hljs-number">1</span> } ).locations; <span class="hljs-comment">// [</span> <span class="hljs-comment">// { x: 0, y: 1 },</span> <span class="hljs-comment">// { x: 0, y: 0 },</span> <span class="hljs-comment">// { x: 3, y: 0 },</span> <span class="hljs-comment">// { x: 2.4, y: 0.8 }</span> <span class="hljs-comment">// ]</span> </code></pre> </div> </section> <section class="tsd-panel tsd-hierarchy"> <h3>Hierarchy</h3> <ul class="tsd-hierarchy"> <li> <span class="target">Graph</span> </li> </ul> </section> <section class="tsd-panel-group tsd-index-group"> <h2>Index</h2> <section class="tsd-panel tsd-index-panel"> <div class="tsd-index-content"> <section class="tsd-index-section "> <h3>Methods</h3> <ul class="tsd-index-list"> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#coalesced" class="tsd-kind-icon">coalesced</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getalledges" class="tsd-kind-icon">get<wbr>All<wbr>Edges</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getallnodes" class="tsd-kind-icon">get<wbr>All<wbr>Nodes</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getclosestpoint" class="tsd-kind-icon">get<wbr>Closest<wbr>Point</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getconnectedcomponentofnode" class="tsd-kind-icon">get<wbr>Connected<wbr>Component<wbr>OfNode</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getconnectedcomponents" class="tsd-kind-icon">get<wbr>Connected<wbr>Components</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getedge" class="tsd-kind-icon">get<wbr>Edge</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getedgesofnode" class="tsd-kind-icon">get<wbr>Edges<wbr>OfNode</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getendpointsofedge" class="tsd-kind-icon">get<wbr>Endpoints<wbr>OfEdge</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getlocation" class="tsd-kind-icon">get<wbr>Location</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getneighbors" class="tsd-kind-icon">get<wbr>Neighbors</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getnode" class="tsd-kind-icon">get<wbr>Node</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getotherendpoint" class="tsd-kind-icon">get<wbr>Other<wbr>Endpoint</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#getshortestpath" class="tsd-kind-icon">get<wbr>Shortest<wbr>Path</a></li> <li class="tsd-kind-method tsd-parent-kind-class"><a href="graph.html#withclosestpointmesh" class="tsd-kind-icon">with<wbr>Closest<wbr>Point<wbr>Mesh</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="graph.html#advancealonglocations" class="tsd-kind-icon">advance<wbr>Along<wbr>Locations</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="graph.html#advancealongpath" class="tsd-kind-icon">advance<wbr>Along<wbr>Path</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="graph.html#create" class="tsd-kind-icon">create</a></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="graph.html#distance" class="tsd-kind-icon">distance</a></li> </ul> </section> </div> </section> </section> <section class="tsd-panel-group tsd-member-group "> <h2>Methods</h2> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="coalesced" class="tsd-anchor"></a> <h3>coalesced</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">coalesced<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="graph.html" class="tsd-signature-type">Graph</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L483">graph.ts:483</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Creates a new <code>Graph</code> instance with the same shape but with a reduced number of nodes and edges. Each instance of multiple nodes and edges in a chain with no forks is converted into a single edge, where the removed nodes are converted into inner locations of the new edge. In particular, the new graph will have no nodes of degree 2 except for nodes with only one edge connecting to themselves. This may significantly increase the speed of certain calculations, such as <a href="graph.html#getshortestpath">getShortestPath</a>.</p> </div> <p>A newly created edge will have the lowest ID of the edges which were combined to form it, where numbers are considered lower than strings.</p> </div> <h4 class="tsd-returns-title">Returns <a href="graph.html" class="tsd-signature-type">Graph</a></h4> <p>A new coalesced <code>Graph</code> instance.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getalledges" class="tsd-anchor"></a> <h3>get<wbr>All<wbr>Edges</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>All<wbr>Edges<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L355">graph.ts:355</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-returns-title">Returns <a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a><span class="tsd-signature-symbol">[]</span></h4> <p>All the edges present in this graph, in the order that they were originally provided to <a href="graph.html#create">Graph.create</a>.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getallnodes" class="tsd-anchor"></a> <h3>get<wbr>All<wbr>Nodes</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>All<wbr>Nodes<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L347">graph.ts:347</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-returns-title">Returns <a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">[]</span></h4> <p>All the nodes present in this graph, in the order that they were originally provided to <a href="graph.html#create">Graph.create</a>.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getclosestpoint" class="tsd-anchor"></a> <h3>get<wbr>Closest<wbr>Point</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Closest<wbr>Point<span class="tsd-signature-symbol">(</span>location<span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L744">graph.ts:744</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the closest point on the graph to a given location. This requires the graph to have a spatial index. To enable this, first use <a href="graph.html#withclosestpointmesh">withClosestPointMesh</a> to obtain a new graph instance with an index enabled. Calling this method on a graph with no index will throw.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>location: <a href="../interfaces/location.html" class="tsd-signature-type">Location</a></h5> <div class="tsd-comment tsd-typography"> <p>A location.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a></h4> <p>The point on the graph closest to the given location, up to a precision determined by the graph&#39;s mesh.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getconnectedcomponentofnode" class="tsd-anchor"></a> <h3>get<wbr>Connected<wbr>Component<wbr>OfNode</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Connected<wbr>Component<wbr>OfNode<span class="tsd-signature-symbol">(</span>nodeId<span class="tsd-signature-symbol">: </span><a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="graph.html" class="tsd-signature-type">Graph</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L563">graph.ts:563</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>nodeId: <a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a></h5> <div class="tsd-comment tsd-typography"> <p>A node ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="graph.html" class="tsd-signature-type">Graph</a></h4> <p>A new <code>Graph</code> instance representing the connected component containing the node with the given ID.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getconnectedcomponents" class="tsd-anchor"></a> <h3>get<wbr>Connected<wbr>Components</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Connected<wbr>Components<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="graph.html" class="tsd-signature-type">Graph</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L545">graph.ts:545</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-returns-title">Returns <a href="graph.html" class="tsd-signature-type">Graph</a><span class="tsd-signature-symbol">[]</span></h4> <p>A list of new <code>Graph</code> instances, each representing a single connected component of this instance.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getedge" class="tsd-anchor"></a> <h3>get<wbr>Edge</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Edge<span class="tsd-signature-symbol">(</span>edgeId<span class="tsd-signature-symbol">: </span><a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L379">graph.ts:379</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>edgeId: <a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a></h5> <div class="tsd-comment tsd-typography"> <p>An edge ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a></h4> <p>The <code>Edge</code> associated with the given ID, or <code>undefined</code> if none exists. Note that the type signature is a lie (it claims to be non-nullable). This is for convenience. Lookup will usually be of known edge IDs, and this is consistent with the typings for index lookup in objects.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getedgesofnode" class="tsd-anchor"></a> <h3>get<wbr>Edges<wbr>OfNode</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Edges<wbr>OfNode<span class="tsd-signature-symbol">(</span>nodeId<span class="tsd-signature-symbol">: </span><a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L387">graph.ts:387</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>nodeId: <a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a></h5> <div class="tsd-comment tsd-typography"> <p>A node ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/edge.html" class="tsd-signature-type">Edge</a><span class="tsd-signature-symbol">[]</span></h4> <p>All edges which have the node with the given ID as an endpoint.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getendpointsofedge" class="tsd-anchor"></a> <h3>get<wbr>Endpoints<wbr>OfEdge</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Endpoints<wbr>OfEdge<span class="tsd-signature-symbol">(</span>edgeId<span class="tsd-signature-symbol">: </span><a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">[</span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">, </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L397">graph.ts:397</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>edgeId: <a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a></h5> <div class="tsd-comment tsd-typography"> <p>An edge ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">[</span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">, </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">]</span></h4> <p>The two nodes which are endpoints of the edge with the given ID.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getlocation" class="tsd-anchor"></a> <h3>get<wbr>Location</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Location<span class="tsd-signature-symbol">(</span>edgePoint<span class="tsd-signature-symbol">: </span><a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L449">graph.ts:449</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the Cartesian coordinates of the point a certain distance along an edge. Does not throw on out-of-bounds distances. Instead negative distances return the start of the edge and distances greater than the length return the end of the edge. This is to avoid unexpected behavior due to floating-point imprecision issues.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>edgePoint: <a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a></h5> <div class="tsd-comment tsd-typography"> <p>A point specified as a certain distance along an edge.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/location.html" class="tsd-signature-type">Location</a></h4> <p>The Cartesian coordinates of the given point.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getneighbors" class="tsd-anchor"></a> <h3>get<wbr>Neighbors</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Neighbors<span class="tsd-signature-symbol">(</span>nodeId<span class="tsd-signature-symbol">: </span><a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L433">graph.ts:433</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>nodeId: <a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a></h5> <div class="tsd-comment tsd-typography"> <p>A node ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/node.html" class="tsd-signature-type">Node</a><span class="tsd-signature-symbol">[]</span></h4> <p>All nodes which are connected to the node with the given ID by an edge.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getnode" class="tsd-anchor"></a> <h3>get<wbr>Node</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Node<span class="tsd-signature-symbol">(</span>nodeId<span class="tsd-signature-symbol">: </span><a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L367">graph.ts:367</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>nodeId: <a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a></h5> <div class="tsd-comment tsd-typography"> <p>A node ID.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/node.html" class="tsd-signature-type">Node</a></h4> <p>The <code>Node</code> associated with the given ID, or <code>undefined</code> if none exists. Note that the type signature is a lie (it claims to be non-nullable). This is for convenience. Lookup will usually be of known node IDs, and this is consistent with the typings for index lookup in objects.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getotherendpoint" class="tsd-anchor"></a> <h3>get<wbr>Other<wbr>Endpoint</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Other<wbr>Endpoint<span class="tsd-signature-symbol">(</span>edgeId<span class="tsd-signature-symbol">: </span><a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a>, nodeId<span class="tsd-signature-symbol">: </span><a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/node.html" class="tsd-signature-type">Node</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L415">graph.ts:415</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Given an edge and one of its endpoints, return the other endpoint. Throws if either of the IDs is nonexistent, or if the node is not an endpoint of the edge.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>edgeId: <a href="../index.html#edgeid" class="tsd-signature-type">EdgeId</a></h5> <div class="tsd-comment tsd-typography"> <p>An edge ID.</p> </div> </li> <li> <h5>nodeId: <a href="../index.html#nodeid" class="tsd-signature-type">NodeId</a></h5> <div class="tsd-comment tsd-typography"> <p>A node ID, referencing one of the endpoints of the edge.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/node.html" class="tsd-signature-type">Node</a></h4> <p>The node which is the other endpoint of the edge with the given ID.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="getshortestpath" class="tsd-anchor"></a> <h3>get<wbr>Shortest<wbr>Path</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">get<wbr>Shortest<wbr>Path<span class="tsd-signature-symbol">(</span>start<span class="tsd-signature-symbol">: </span><a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a>, end<span class="tsd-signature-symbol">: </span><a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/path.html" class="tsd-signature-type">Path</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L593">graph.ts:593</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns the shortest path between two points on the graph. Throws if no such path exists.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>start: <a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a></h5> <div class="tsd-comment tsd-typography"> <p>A point along the graph.</p> </div> </li> <li> <h5>end: <a href="../interfaces/edgepoint.html" class="tsd-signature-type">EdgePoint</a></h5> <div class="tsd-comment tsd-typography"> <p>Another point along the graph.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/path.html" class="tsd-signature-type">Path</a></h4> <p>The shortest path from the first point to the second.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"> <a name="withclosestpointmesh" class="tsd-anchor"></a> <h3>with<wbr>Closest<wbr>Point<wbr>Mesh</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"> <li class="tsd-signature tsd-kind-icon">with<wbr>Closest<wbr>Point<wbr>Mesh<span class="tsd-signature-symbol">(</span>precision<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="graph.html" class="tsd-signature-type">Graph</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L700">graph.ts:700</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Does preprocessing to enable <a href="graph.html#getclosestpoint">getClosestPoint</a> by creating a spatial index of points along the graph.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>precision: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>How fine the mesh should be. Lower precision is more accurate but takes more time to precompute and more memory. As a rule-of-thumb, <a href="graph.html#getclosestpoint">getClosestPoint</a> will be accurate to within <code>precision</code> distance.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="graph.html" class="tsd-signature-type">Graph</a></h4> <p>A new <code>Graph</code> instance with a spatial index enabled.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a name="advancealonglocations" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagStatic">Static</span> advance<wbr>Along<wbr>Locations</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"> <li class="tsd-signature tsd-kind-icon">advance<wbr>Along<wbr>Locations<span class="tsd-signature-symbol">(</span>locations<span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">[]</span>, distance<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">[]</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L158">graph.ts:158</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Helper function for computing progress down a path after advancing along it for a given distance. If the distance is greater than the total length of the path, then advances to the end of the path. Throws on negative distances.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>locations: <a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">[]</span></h5> <div class="tsd-comment tsd-typography"> <p>A list of locations representing a path.</p> </div> </li> <li> <h5>distance: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>A distance down the path.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">[]</span></h4> <p>A new list of locations representing the remaining part of <code>locations</code> after advancing <code>distance</code> along the path.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a name="advancealongpath" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagStatic">Static</span> advance<wbr>Along<wbr>Path</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"> <li class="tsd-signature tsd-kind-icon">advance<wbr>Along<wbr>Path<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><a href="../interfaces/path.html" class="tsd-signature-type">Path</a>, distance<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/path.html" class="tsd-signature-type">Path</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L205">graph.ts:205</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> <div class="lead"> <p>Returns a new path obtained by truncating the given path by the provided distance. That is, the start point of the path moves forward, and any nodes and edges that it passes are dropped. Throws an error if distance is negative.</p> </div> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>path: <a href="../interfaces/path.html" class="tsd-signature-type">Path</a></h5> <div class="tsd-comment tsd-typography"> <p>A path.</p> </div> </li> <li> <h5>distance: <span class="tsd-signature-type">number</span></h5> <div class="tsd-comment tsd-typography"> <p>A distance to travel along the path.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="../interfaces/path.html" class="tsd-signature-type">Path</a></h4> <p>The remaining portion of <code>path</code> after traveling <code>distance</code> along it.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a name="create" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagStatic">Static</span> create</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"> <li class="tsd-signature tsd-kind-icon">create<span class="tsd-signature-symbol">(</span>nodes<span class="tsd-signature-symbol">: </span><a href="../interfaces/simplenode.html" class="tsd-signature-type">SimpleNode</a><span class="tsd-signature-symbol">[]</span>, edges<span class="tsd-signature-symbol">: </span><a href="../interfaces/simpleedge.html" class="tsd-signature-type">SimpleEdge</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="graph.html" class="tsd-signature-type">Graph</a></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L85">graph.ts:85</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>nodes: <a href="../interfaces/simplenode.html" class="tsd-signature-type">SimpleNode</a><span class="tsd-signature-symbol">[]</span></h5> <div class="tsd-comment tsd-typography"> <p>A list of nodes.</p> </div> </li> <li> <h5>edges: <a href="../interfaces/simpleedge.html" class="tsd-signature-type">SimpleEdge</a><span class="tsd-signature-symbol">[]</span></h5> <div class="tsd-comment tsd-typography"> <p>A list of edges.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <a href="graph.html" class="tsd-signature-type">Graph</a></h4> <p>A new <code>Graph</code> instance with the specified nodes and edges.</p> </li> </ul> </section> <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a name="distance" class="tsd-anchor"></a> <h3><span class="tsd-flag ts-flagStatic">Static</span> distance</h3> <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static"> <li class="tsd-signature tsd-kind-icon">distance<span class="tsd-signature-symbol">(</span>location1<span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a>, location2<span class="tsd-signature-symbol">: </span><a href="../interfaces/location.html" class="tsd-signature-type">Location</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li> </ul> <ul class="tsd-descriptions"> <li class="tsd-description"> <aside class="tsd-sources"> <ul> <li>Defined in <a href="https://github.com/dphilipson/graphs-and-paths/blob/b41ed52/src/graph.ts#L143">graph.ts:143</a></li> </ul> </aside> <div class="tsd-comment tsd-typography"> </div> <h4 class="tsd-parameters-title">Parameters</h4> <ul class="tsd-parameters"> <li> <h5>location1: <a href="../interfaces/location.html" class="tsd-signature-type">Location</a></h5> <div class="tsd-comment tsd-typography"> <p>A location.</p> </div> </li> <li> <h5>location2: <a href="../interfaces/location.html" class="tsd-signature-type">Location</a></h5> <div class="tsd-comment tsd-typography"> <p>Another location.</p> </div> </li> </ul> <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4> <p>The straight-line distance between <code>location1</code> and <code>location2</code>.</p> </li> </ul> </section> </section> </div> <div class="col-4 col-menu menu-sticky-wrap menu-highlight"> <nav class="tsd-navigation primary"> <ul> <li class="globals "> <a href="../index.html"><em>Globals</em></a> </li> </ul> </nav> <nav class="tsd-navigation secondary menu-sticky"> <ul class="before-current"> </ul> <ul class="current"> <li class="current tsd-kind-class"> <a href="graph.html" class="tsd-kind-icon">Graph</a> <ul> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#coalesced" class="tsd-kind-icon">coalesced</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getalledges" class="tsd-kind-icon">get<wbr>All<wbr>Edges</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getallnodes" class="tsd-kind-icon">get<wbr>All<wbr>Nodes</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getclosestpoint" class="tsd-kind-icon">get<wbr>Closest<wbr>Point</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getconnectedcomponentofnode" class="tsd-kind-icon">get<wbr>Connected<wbr>Component<wbr>OfNode</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getconnectedcomponents" class="tsd-kind-icon">get<wbr>Connected<wbr>Components</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getedge" class="tsd-kind-icon">get<wbr>Edge</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getedgesofnode" class="tsd-kind-icon">get<wbr>Edges<wbr>OfNode</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getendpointsofedge" class="tsd-kind-icon">get<wbr>Endpoints<wbr>OfEdge</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getlocation" class="tsd-kind-icon">get<wbr>Location</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getneighbors" class="tsd-kind-icon">get<wbr>Neighbors</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getnode" class="tsd-kind-icon">get<wbr>Node</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getotherendpoint" class="tsd-kind-icon">get<wbr>Other<wbr>Endpoint</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#getshortestpath" class="tsd-kind-icon">get<wbr>Shortest<wbr>Path</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class"> <a href="graph.html#withclosestpointmesh" class="tsd-kind-icon">with<wbr>Closest<wbr>Point<wbr>Mesh</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a href="graph.html#advancealonglocations" class="tsd-kind-icon">advance<wbr>Along<wbr>Locations</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a href="graph.html#advancealongpath" class="tsd-kind-icon">advance<wbr>Along<wbr>Path</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a href="graph.html#create" class="tsd-kind-icon">create</a> </li> <li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static"> <a href="graph.html#distance" class="tsd-kind-icon">distance</a> </li> </ul> </li> </ul> <ul class="after-current"> <li class=" tsd-kind-interface"> <a href="../interfaces/edge.html" class="tsd-kind-icon">Edge</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/edgepoint.html" class="tsd-kind-icon">Edge<wbr>Point</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/location.html" class="tsd-kind-icon">Location</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/node.html" class="tsd-kind-icon">Node</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/orientededge.html" class="tsd-kind-icon">Oriented<wbr>Edge</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/path.html" class="tsd-kind-icon">Path</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/simpleedge.html" class="tsd-kind-icon">Simple<wbr>Edge</a> </li> <li class=" tsd-kind-interface"> <a href="../interfaces/simplenode.html" class="tsd-kind-icon">Simple<wbr>Node</a> </li> <li class=" tsd-kind-type-alias"> <a href="../index.html#edgeid" class="tsd-kind-icon">Edge<wbr>Id</a> </li> <li class=" tsd-kind-type-alias"> <a href="../index.html#nodeid" class="tsd-kind-icon">Node<wbr>Id</a> </li> </ul> </nav> </div> </div> </div> <footer class="with-border-bottom"> <div class="container"> <h2>Legend</h2> <div class="tsd-legend-group"> <ul class="tsd-legend"> <li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li> <li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li> <li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li> <li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li> <li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li> <li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li> <li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li> <li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li> <li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li> <li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li> <li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li> <li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li> <li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li> <li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li> <li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li> <li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li> <li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li> <li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li> </ul> <ul class="tsd-legend"> <li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li> <li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li> </ul> </div> </div> </footer> <div class="container tsd-generator"> <p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p> </div> <div class="overlay"></div> <script src="../assets/js/main.js"></script> <script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script> </body> </html>
dphilipson/graphs-and-paths
docs/classes/graph.html
HTML
mit
55,048
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 2465, 1027, 1000, 12398, 2053, 1011, 1046, 2015, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 8299, 1011, 104...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Cacic\CommonBundle\Controller; use Doctrine\Common\Util\Debug; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Cacic\CommonBundle\Entity\SoftwareEstacao; use Cacic\CommonBundle\Form\Type\SoftwareEstacaoType; class SoftwareEstacaoController extends Controller { /** * * Tela de listagem dos softwares por estação * @param int $page */ public function indexAction( $page ) { return $this->render( 'CacicCommonBundle:SoftwareEstacao:index.html.twig', array( 'SoftwareEstacao' => $this->getDoctrine()->getRepository( 'CacicCommonBundle:SoftwareEstacao' )->paginar( $this->get( 'knp_paginator' ), $page ) )); } /** * * Tela de cadastro de software por estação * @param Request $request */ public function cadastrarAction(Request $request) { $SoftwareEstacao = new SoftwareEstacao(); $form = $this->createForm( new SoftwareEstacaoType(), $SoftwareEstacao ); if ( $request->isMethod('POST') ) { $form->bind( $request ); if ( $form->isValid() ) { $this->getDoctrine()->getManager()->persist( $SoftwareEstacao ); $this->getDoctrine()->getManager()->flush();// Efetuar a edição do Software Estacao $this->get('session')->getFlashBag()->add('success', 'Dados salvos com sucesso!'); return $this->redirect( $this->generateUrl( 'cacic_software_estacao_index', array( 'idComputador' => $SoftwareEstacao->getIdComputador()->getIdComputador() ) ) ); } } return $this->render( 'CacicCommonBundle:SoftwareEstacao:cadastrar.html.twig', array( 'form' => $form->createView() ) ); } /** * Página de editar dados do Software Estacao * @param int $idComputador * @param int $idSoftware */ public function editarAction( $idComputador, Request $request ) { $SoftwareEstacao = $this->getDoctrine()->getRepository('CacicCommonBundle:SoftwareEstacao') ->find( array( 'idComputador'=>$idComputador ) ); if ( ! $SoftwareEstacao ) throw $this->createNotFoundException( 'Software de Estacao não encontrado' ); $form = $this->createForm( new SoftwareEstacaoType(), $SoftwareEstacao ); if ( $request->isMethod('POST') ) { $form->bind( $request ); if ( $form->isValid() ) { $this->getDoctrine()->getManager()->persist( $SoftwareEstacao ); $this->getDoctrine()->getManager()->flush();// Efetuar a edição do Software Estacao $this->get('session')->getFlashBag()->add('success', 'Dados salvos com sucesso!'); return $this->redirect( $this->generateUrl( 'cacic_software_estacao_editar', array( 'idComputador' => $SoftwareEstacao->getIdComputador()->getIdComputador() ) ) ); } } return $this->render( 'CacicCommonBundle:SoftwareEstacao:cadastrar.html.twig', array( 'form' => $form->createView() ) ); } /** * * [AJAX] Exclusão de Software Estacao já cadastrado * @param integer $idSoftwareEstacao */ public function excluirAction( Request $request ) { if ( ! $request->isXmlHttpRequest() ) // Verifica se se trata de uma requisição AJAX throw $this->createNotFoundException( 'Página não encontrada' ); $SoftwareEstacao = $this->getDoctrine()->getRepository('CacicCommonBundle:SoftwareEstacao')->find( $request->get('compositeKeys') ); if ( ! $SoftwareEstacao ) throw $this->createNotFoundException( 'Software Estação não encontrado' ); $em = $this->getDoctrine()->getManager(); $em->remove( $SoftwareEstacao ); $em->flush(); $response = new Response( json_encode( array('status' => 'ok') ) ); $response->headers->set('Content-Type', 'application/json'); return $response; } /** * * Relatorio de Autorizacoes Cadastradas */ public function autorizacoesAction() { return $this->render( 'CacicCommonBundle:SoftwareEstacao:autorizacoes.html.twig', array( 'registros' => $this->getDoctrine()->getRepository('CacicCommonBundle:SoftwareEstacao')->gerarRelatorioAutorizacoes() ) ); } }
lightbase/cacic
src/Cacic/CommonBundle/Controller/SoftwareEstacaoController.php
PHP
mit
4,723
[ 30522, 1026, 1029, 25718, 3415, 15327, 6187, 19053, 1032, 2691, 27265, 2571, 1032, 11486, 1025, 2224, 8998, 1032, 2691, 1032, 21183, 4014, 1032, 2139, 8569, 2290, 1025, 2224, 25353, 2213, 14876, 4890, 1032, 6922, 1032, 8299, 14876, 18426, 3...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang='en'> <head> <title>pservers-pattern-07-f-manual.svg</title> <meta charset='utf-8'> </head> <body> <h1>Source SVG: pservers-pattern-07-f-manual.svg</h1> <svg id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!--======================================================================--> <!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =--> <!--= Institute of Technology, European Research Consortium for =--> <!--= Informatics and Mathematics (ERCIM), Keio University). =--> <!--= All Rights Reserved. =--> <!--= See http://www.w3.org/Consortium/Legal/. =--> <!--======================================================================--> <title id="test-title">$RCSfile: pservers-pattern-07-f.svg,v $</title> <defs> <font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F"> <font-face-src> <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> </font-face-src> </font-face> </defs> <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> <defs> <pattern id="pattern1" patternUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" viewBox="0 0 10 10"> <circle cx="5" cy="5" r="1.7" fill="red" /> </pattern> <pattern id="pattern2" xlink:href="#invalidlink" patternUnits="userSpaceOnUse" x="0" y="0" width="100" height="100" viewBox="0 0 10 10"> <circle cx="5" cy="5" r="2" fill="lime" /> </pattern> </defs> <rect fill="url(#pattern1)" stroke="none" x="1" y="1" width="200" height="200" /> <rect fill="url(#pattern2)" stroke="none" x="1" y="1" width="200" height="200" /> </g> <g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> <text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.2 $</text> </g> <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> <!-- comment out this watermark once the test is approved --> <g id="draft-watermark"> <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> </g> </svg> </body> </html>
shinglyu/servo
tests/wpt/web-platform-tests/conformance-checkers/html-svg/pservers-pattern-07-f-isvalid.html
HTML
mpl-2.0
2,562
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1005, 4372, 1005, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 8827, 2121, 14028, 1011, 5418, 1011, 5718, 1011, 1042, 1011, 6410, 1012, 17917, 2290, 1026, 1013, 2516, 1028, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package GT::Signals::Prices::RecordPriceLow; # Copyright 2000-2002 Raphaël Hertzog, Fabien Fulhaber # This file is distributed under the terms of the General Public License # version 2 or (at your option) any later version. use strict; use vars qw(@ISA @NAMES @DEFAULT_ARGS); # Standards-Version: 1.0 use GT::Signals; use GT::Prices; use GT::Indicators; use GT::Indicators::Generic::MinInPeriod; @ISA = qw(GT::Signals); @NAMES = ("RecordPriceLow[#*]"); @DEFAULT_ARGS = ("30", "{I:Prices LOW}"); sub initialize { my ($self) = @_; $self->{'min'} = GT::Indicators::Generic::MinInPeriod->new([ $self->{'args'}->get_arg_constant(1) - 1, $self->{'args'}->get_arg_names(2) ]); $self->add_indicator_dependency($self->{'min'}, 2); $self->add_prices_dependency($self->{'args'}->get_arg_constant(1)); } sub detect { my ($self, $calc, $i) = @_; my $q = $calc->prices; my $min_name = $self->{'min'}->get_name; return if ($calc->signals->is_available($self->get_name, $i)); return if (! $self->check_dependencies($calc, $i)); # We're doing a new low if ( $self->{'args'}->get_arg_values($calc, $i, 2) < $calc->indicators->get($min_name, $i - 1) ) { $calc->signals->set($self->get_name, $i, 1); } else { $calc->signals->set($self->get_name, $i, 0); } } 1;
hunterfu/it-manager
stock_tech/GeniusTrader/GT/Signals/Prices/RecordPriceLow.pm
Perl
lgpl-3.0
1,325
[ 30522, 7427, 14181, 1024, 1024, 7755, 1024, 1024, 7597, 1024, 1024, 2501, 18098, 6610, 8261, 1025, 1001, 9385, 2456, 1011, 2526, 12551, 2014, 5753, 8649, 1010, 6904, 11283, 2078, 11865, 2140, 25459, 2121, 1001, 2023, 5371, 2003, 5500, 2104,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Field\Providers; use Pluma\Support\Providers\ServiceProvider; class FieldServiceProvider extends ServiceProvider { /** * Array of observable models. * * @var array */ protected $observables = [ [\Field\Models\Field::class, '\Field\Observers\FieldObserver'], ]; /** * Registered middlewares on the * Service Providers Level. * * @var mixed */ protected $middlewares = [ // ]; /** * The policy mappings for the application. * * @var array */ protected $policies = [ \Field\Models\Field::class => \Field\Policies\FieldPolicy::class, ]; /** * Bootstrap any application services. * * @return void */ public function boot() { parent::boot(); } /** * Register the service provider. * * @return void */ public function register() { // } }
lioneil/pluma
core/submodules/Form/submodules/Field/Providers/FieldServiceProvider.php
PHP
mit
967
[ 30522, 1026, 1029, 25718, 3415, 15327, 2492, 1032, 11670, 1025, 2224, 22088, 2050, 1032, 2490, 1032, 11670, 1032, 2326, 21572, 17258, 2121, 1025, 2465, 4249, 2121, 7903, 13699, 12298, 18688, 8908, 2326, 21572, 17258, 2121, 1063, 1013, 1008, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (C) 2015 Google, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using System; using GoogleMobileAds.Api; namespace GoogleMobileAds.Common { internal interface IRewardBasedVideoAdClient { // Ad event fired when the reward based video ad has been received. event EventHandler<EventArgs> OnAdLoaded; // Ad event fired when the reward based video ad has failed to load. event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad; // Ad event fired when the reward based video ad is opened. event EventHandler<EventArgs> OnAdOpening; // Ad event fired when the reward based video ad has started playing. event EventHandler<EventArgs> OnAdStarted; // Ad event fired when the reward based video ad has rewarded the user. event EventHandler<Reward> OnAdRewarded; // Ad event fired when the reward based video ad is closed. event EventHandler<EventArgs> OnAdClosed; // Ad event fired when the reward based video ad is leaving the application. event EventHandler<EventArgs> OnAdLeavingApplication; // Creates a reward based video ad and adds it to the view hierarchy. void CreateRewardBasedVideoAd(); // Requests a new ad for the reward based video ad. void LoadAd(AdRequest request, string adUnitId); // Determines whether the reward based video has loaded. bool IsLoaded(); // Shows the reward based video ad on the screen. void ShowRewardBasedVideoAd(); } }
andrewlord1990/unity-advert-bridge
src/AdvertBridge/Assets/GoogleMobileAds/Common/IRewardBasedVideoAdClient.cs
C#
apache-2.0
2,078
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2325, 8224, 1010, 4297, 1012, 1013, 1013, 1013, 1013, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1013, 1013, 2017, 2089, 2025, 2224, 20...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * Firal * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://firal.org/licenses/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to firal-dev@googlegroups.com so we can send you a copy immediately. * * @category Firal * @package Firal_Di * @copyright Copyright (c) 2009-2010 Firal (http://firal.org/) * @license http://firal.org/licenses/new-bsd New BSD License */ /** * An event * * @category Firal * @package Firal_Di * @copyright Copyright (c) 2009-2010 Firal (http://firal.org/) * @license http://firal.org/licenses/new-bsd New BSD License */ class Default_DiContainer extends Firal_Di_Container_ContainerAbstract { /** * Get the user service * * @return Default_Service_User */ public function getUserService() { if (!isset($this->_storage['userService'])) { $this->_storage['userService'] = new Default_Service_User($this->getUserMapper()); } return $this->_storage['userService']; } /** * Get the user mapper * * @return Default_Model_Mapper_UserInterface */ public function getUserMapper() { if (!isset($this->_storage['userMapper'])) { $this->_storage['userMapper'] = new Default_Model_Mapper_UserCache( new Default_Model_Mapper_User(), $this->_config['mapper']['cache'] ); } return $this->_storage['userMapper']; } /** * Get the config service * * @return Default_Service_Config */ public function getConfigService() { if (!isset($this->_storage['configService'])) { $this->_storage['configService'] = new Default_Service_Config($this->getConfigMapper()); } return $this->_storage['configService']; } /** * Get the config mapper * * @return Default_Model_Mapper_ConfigInterface */ public function getConfigMapper() { if (!isset($this->_storage['configMapper'])) { $this->_storage['configMapper'] = new Default_Model_Mapper_ConfigCache( new Default_Model_Mapper_Config(), $this->_config['mapper']['cache'] ); } return $this->_storage['configMapper']; } }
firal/Firal
application/modules/default/DiContainer.php
PHP
bsd-3-clause
2,542
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 21554, 2389, 1008, 1008, 6105, 1008, 1008, 2023, 3120, 5371, 2003, 3395, 2000, 1996, 2047, 18667, 2094, 6105, 2008, 2003, 24378, 1008, 2007, 2023, 7427, 1999, 1996, 5371, 6105, 1012, 19067, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* PR middle-end/47893 */ /* { dg-do run } */ /* { dg-options "-O2" } */ /* { dg-options "-O2 -mtune=atom -fno-omit-frame-pointer -fno-strict-aliasing" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ extern void abort (void); struct S { unsigned s1:4, s2:2, s3:2, s4:2, s5:2, s6:1, s7:1, s8:1, s9:1, s10:1; int s11:16; unsigned s12:4; int s13:16; unsigned s14:2; int s15:16; unsigned s16:4; int s17:16; unsigned s18:2; }; struct T { unsigned t[3]; }; struct U { unsigned u1, u2; }; struct V; struct W { char w1[24]; struct V *w2; unsigned w3; char w4[28912]; unsigned int w5; char w6[60]; }; struct X { unsigned int x[2]; }; struct V { int v1; struct X v2[3]; char v3[28]; }; struct Y { void *y1; char y2[3076]; struct T y3[32]; char y4[1052]; }; volatile struct S v1 = { .s15 = -1, .s16 = 15, .s17 = -1, .s18 = 3 }; __attribute__ ((noinline, noclone)) int fn1 (int x) { int r; __asm__ volatile ("" : "=r" (r) : "0" (1), "r" (x) : "memory"); return r; } volatile int cnt; __attribute__ ((noinline, noclone)) #ifdef __i386__ __attribute__ ((regparm (2))) #endif struct S fn2 (struct Y *x, const struct X *y) { if (++cnt > 1) abort (); __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); return v1; } __attribute__ ((noinline, noclone)) void fn3 (void *x, unsigned y, const struct S *z, unsigned w) { __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z), "r" (w) : "memory"); } volatile struct U v2; __attribute__ ((noinline, noclone)) struct U fn4 (void *x, unsigned y) { __asm__ volatile ("" : : "r" (x), "r" (y) : "memory"); return v2; } __attribute__ ((noinline, noclone)) struct S fn5 (void *x) { __asm__ volatile ("" : : "r" (x) : "memory"); return v1; } volatile struct T v3; __attribute__ ((noinline, noclone)) struct T fn6 (void *x) { __asm__ volatile ("" : : "r" (x) : "memory"); return v3; } __attribute__ ((noinline, noclone)) struct T fn7 (void *x, unsigned y, unsigned z) { __asm__ volatile ("" : : "r" (x), "r" (y), "r" (z) : "memory"); return v3; } static void fn8 (struct Y *x, const struct V *y) { void *a = x->y1; struct S b[4]; unsigned i, c; c = fn1 (y->v1); for (i = 0; i < c; i++) b[i] = fn2 (x, &y->v2[i]); fn3 (a, y->v1, b, c); } static inline void fn9 (void *x, struct S y __attribute__((unused))) { fn4 (x, 8); } static void fn10 (struct Y *x) { void *a = x->y1; struct T b __attribute__((unused)) = fn6 (a); fn9 (a, fn5 (a)); } __attribute__((noinline, noclone)) int fn11 (unsigned int x, void *y, const struct W *z, unsigned int w, const char *v, const char *u) { struct Y a, *t; unsigned i; t = &a; __builtin_memset (t, 0, sizeof *t); t->y1 = y; if (x == 0) { if (z->w3 & 1) fn10 (t); for (i = 0; i < w; i++) { if (v[i] == 0) t->y3[i] = fn7 (y, 0, u[i]); else return 0; } } else for (i = 0; i < w; i++) t->y3[i] = fn7 (y, v[i], u[i]); for (i = 0; i < z->w5; i++) fn8 (t, &z->w2[i]); return 0; } volatile int i; const char *volatile p = ""; int main () { struct V v = { .v1 = 0 }; struct W w = { .w5 = 1, .w2 = &v }; fn11 (i + 1, (void *) p, &w, i, (const char *) p, (const char *) p); if (cnt != 1) abort (); return 0; }
SanDisk-Open-Source/SSD_Dashboard
uefi/gcc/gcc-4.6.3/gcc/testsuite/gcc.dg/pr47893.c
C
gpl-2.0
3,260
[ 30522, 1013, 1008, 10975, 2690, 1011, 2203, 1013, 4700, 2620, 2683, 2509, 1008, 1013, 1013, 1008, 1063, 1040, 2290, 1011, 2079, 2448, 1065, 1008, 1013, 1013, 1008, 1063, 1040, 2290, 1011, 7047, 1000, 1011, 1051, 2475, 1000, 1065, 1008, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
UPDATE `achievement_criteria_data` SET `value1`=2 WHERE `criteria_id`=12979 AND `type`=12; UPDATE `achievement_criteria_data` SET `value1`=1 WHERE `criteria_id`=12971 AND `type`=12;
arkzabor/invictus-arena
sql/updates/world/2013_01_29_01_world_achievement_criteria_data.sql
SQL
gpl-2.0
182
[ 30522, 10651, 1036, 6344, 1035, 9181, 1035, 2951, 1036, 2275, 1036, 3643, 2487, 1036, 1027, 1016, 2073, 1036, 9181, 1035, 8909, 1036, 1027, 14378, 2581, 2683, 1998, 1036, 2828, 1036, 1027, 2260, 1025, 10651, 1036, 6344, 1035, 9181, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.mossle.bpm.data; import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; import javax.annotation.Resource; import com.mossle.bpm.persistence.manager.BpmConfBaseManager; import com.mossle.bpm.persistence.manager.BpmConfListenerManager; import com.mossle.bpm.persistence.manager.BpmConfNodeManager; import com.mossle.core.csv.CsvProcessor; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ProcessListenerDeployer { private static Logger logger = LoggerFactory .getLogger(ProcessListenerDeployer.class); private BpmConfBaseManager bpmConfBaseManager; private BpmConfListenerManager bpmConfListenerManager; private BpmConfNodeManager bpmConfNodeManager; private String defaultTenantId = "1"; @PostConstruct public void init() throws Exception { String processListenerDataFilePath = "data/process-listener.csv"; String processListenerDataEncoding = "UTF-8"; ProcessListenerCallback processListenerCallback = new ProcessListenerCallback(); processListenerCallback.setBpmConfBaseManager(bpmConfBaseManager); processListenerCallback.setBpmConfNodeManager(bpmConfNodeManager); processListenerCallback .setBpmConfListenerManager(bpmConfListenerManager); new CsvProcessor().process(processListenerDataFilePath, processListenerDataEncoding, processListenerCallback); } @Resource public void setBpmConfBaseManager(BpmConfBaseManager bpmConfBaseManager) { this.bpmConfBaseManager = bpmConfBaseManager; } @Resource public void setBpmConfNodeManager(BpmConfNodeManager bpmConfNodeManager) { this.bpmConfNodeManager = bpmConfNodeManager; } @Resource public void setBpmConfListenerManager( BpmConfListenerManager bpmConfListenerManager) { this.bpmConfListenerManager = bpmConfListenerManager; } }
xuhuisheng/lemon
src/main/java/com/mossle/bpm/data/ProcessListenerDeployer.java
Java
apache-2.0
2,001
[ 30522, 7427, 4012, 1012, 10636, 2571, 1012, 17531, 2213, 1012, 2951, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 2862, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 4949, 1025, 12324, 9262, 2595, 1012, 5754, 17287, 3508, 1012, 2695, 8663, 336...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef _GAINRATIOSPLITCRIT_ #define _GAINRATIOSPLITCRIT_ #include "EntropyBasedSplitCrit.h" #include <string> #include <limits> // Forward class declarations: class Distribution; /** * Class for computing the gain ratio for a given distribution. * */ class GainRatioSplitCrit : public EntropyBasedSplitCrit { public: /** * This method is a straightforward implementation of the gain * ratio criterion for the given distribution. */ double splitCritValue(Distribution &bags) const; /** * This method computes the gain ratio in the same way C4.5 does. * * @param bags the distribution * @param totalnoInst the weight of ALL instances * @param numerator the info gain */ double splitCritValue(Distribution &bags, double totalnoInst, double numerator) const; private: /** * Help method for computing the split entropy. */ double splitEnt(Distribution &bags, double totalnoInst) const; }; #endif //#ifndef _GAINRATIOSPLITCRIT_
sudarsun/c48
c48/GainRatioSplitCrit.h
C
unlicense
1,059
[ 30522, 1001, 2065, 13629, 2546, 1035, 5114, 8609, 10735, 24759, 4183, 26775, 4183, 1035, 1001, 9375, 1035, 5114, 8609, 10735, 24759, 4183, 26775, 4183, 1035, 1001, 2421, 1000, 23077, 15058, 5104, 24759, 4183, 26775, 4183, 1012, 1044, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#! /usr/bin/env python3 import asyncio import subprocess import numpy as np import time comm = None class Camera: def __init__(self, notify): self._process = None self._now_pos = np.array([0., 0., 0.]) self._running = False self._notify = notify @asyncio.coroutine def connect(self): self._process = yield from asyncio.create_subprocess_exec( 'python2', 'camera.py', stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE ) self._running = True @asyncio.coroutine def run(self): while self._running: data = yield from self._process.stdout.readline() print(data) self._now_pos = np.array(list(map(float, data.split()))) yield from self._notify(time.time(), self._now_pos) def stop(self): self._running = False self._process.terminate()
AlphaLambdaMuPi/CamDrone
camera3.py
Python
mit
937
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 18750, 2509, 12324, 2004, 6038, 9793, 12324, 4942, 21572, 9623, 2015, 12324, 16371, 8737, 2100, 2004, 27937, 12324, 2051, 4012, 2213, 1027, 3904, 2465, 4950, 1024, 13366, 103...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php Class Automattic_Readme { function Automattic_Readme() { // This space intentially blank } function parse_readme( $file ) { $file_contents = @implode('', @file($file)); return $this->parse_readme_contents( $file_contents ); } function parse_readme_contents( $file_contents ) { $file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents); $file_contents = trim($file_contents); if ( 0 === strpos( $file_contents, "\xEF\xBB\xBF" ) ) $file_contents = substr( $file_contents, 3 ); // === Plugin Name === // Must be the very first thing. if ( !preg_match('|^===(.*)===|', $file_contents, $_name) ) return array(); // require a name $name = trim($_name[1], '='); $name = $this->sanitize_text( $name ); $file_contents = $this->chop_string( $file_contents, $_name[0] ); // Requires at least: 1.5 if ( preg_match('|Requires at least:(.*)|i', $file_contents, $_requires_at_least) ) $requires_at_least = $this->sanitize_text($_requires_at_least[1]); else $requires_at_least = NULL; // Tested up to: 2.1 if ( preg_match('|Tested up to:(.*)|i', $file_contents, $_tested_up_to) ) $tested_up_to = $this->sanitize_text( $_tested_up_to[1] ); else $tested_up_to = NULL; // Stable tag: 10.4-ride-the-fire-eagle-danger-day if ( preg_match('|Stable tag:(.*)|i', $file_contents, $_stable_tag) ) $stable_tag = $this->sanitize_text( $_stable_tag[1] ); else $stable_tag = NULL; // we assume trunk, but don't set it here to tell the difference between specified trunk and default trunk // Tags: some tag, another tag, we like tags if ( preg_match('|Tags:(.*)|i', $file_contents, $_tags) ) { $tags = preg_split('|,[\s]*?|', trim($_tags[1])); foreach ( array_keys($tags) as $t ) $tags[$t] = $this->sanitize_text( $tags[$t] ); } else { $tags = array(); } // Contributors: markjaquith, mdawaffe, zefrank $contributors = array(); if ( preg_match('|Contributors:(.*)|i', $file_contents, $_contributors) ) { $temp_contributors = preg_split('|,[\s]*|', trim($_contributors[1])); foreach ( array_keys($temp_contributors) as $c ) { $tmp_sanitized = $this->user_sanitize( $temp_contributors[$c] ); if ( strlen(trim($tmp_sanitized)) > 0 ) $contributors[$c] = $tmp_sanitized; unset($tmp_sanitized); } } // Donate Link: URL if ( preg_match('|Donate link:\s+(.*)|i', $file_contents, $_donate_link) ) $donate_link = esc_url( $_donate_link[1] ); else $donate_link = NULL; // License: GPLv2 (Lots of plugins have this, so lets pull it out so it doesn't get into our short description) if ( preg_match('|License:(.*)|i', $file_contents, $_license) ) $license = $this->sanitize_text( $_license[1] ); else $license = NULL; // License URI: URL if ( preg_match( '|License URI:\s+(.*)|i', $file_contents, $_license_uri ) ) $license_uri = esc_url( $_license_uri[1] ); else $license_uri = null; // togs, conts, etc are optional and order shouldn't matter. So we chop them only after we've grabbed their values. foreach ( array('tags', 'contributors', 'requires_at_least', 'tested_up_to', 'stable_tag', 'donate_link', 'license', 'license_uri') as $chop ) { if ( $$chop ) { $_chop = '_' . $chop; $file_contents = $this->chop_string( $file_contents, ${$_chop}[0] ); } } $file_contents = trim($file_contents); // short-description fu if ( !preg_match('/(^(.*?))^[\s]*=+?[\s]*.+?[\s]*=+?/ms', $file_contents, $_short_description) ) $_short_description = array( 1 => &$file_contents, 2 => &$file_contents ); $short_desc_filtered = $this->sanitize_text( $_short_description[2] ); $short_desc_length = strlen($short_desc_filtered); $short_description = substr($short_desc_filtered, 0, 150); if ( $short_desc_length > strlen($short_description) ) $truncated = true; else $truncated = false; if ( $_short_description[1] ) $file_contents = $this->chop_string( $file_contents, $_short_description[1] ); // yes, the [1] is intentional // == Section == // Break into sections // $_sections[0] will be the title of the first section, $_sections[1] will be the content of the first section // the array alternates from there: title2, content2, title3, content3... and so forth $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); $sections = array(); for ( $i=1; $i <= count($_sections); $i +=2 ) { $_sections[$i] = preg_replace('/^[\s]*=[\s]+(.+?)[\s]+=/m', '<h4>$1</h4>', $_sections[$i]); $_sections[$i] = $this->filter_text( $_sections[$i], true ); $title = $this->sanitize_text( $_sections[$i-1] ); $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]); } // Special sections // This is where we nab our special sections, so we can enforce their order and treat them differently, if needed // upgrade_notice is not a section, but parse it like it is for now $final_sections = array(); foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) { if ( isset($sections[$special_section]) ) { $final_sections[$special_section] = $sections[$special_section]['content']; unset($sections[$special_section]); } } if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) ) $final_sections['changelog'] = $final_sections['change_log']; $final_screenshots = array(); if ( isset($final_sections['screenshots']) ) { preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER); if ( $screenshots ) { foreach ( (array) $screenshots as $ss ) $final_screenshots[] = $ss[1]; } } // Parse the upgrade_notice section specially: // 1.0 => blah, 1.1 => fnord $upgrade_notice = array(); if ( isset($final_sections['upgrade_notice']) ) { $split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); for ( $i = 0; $i < count( $split ); $i += 2 ) { if ( empty( $split[$i + 1] ) ) { break; } $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 ); } unset( $final_sections['upgrade_notice'] ); } // No description? // No problem... we'll just fall back to the old style of description // We'll even let you use markup this time! $excerpt = false; if ( !isset($final_sections['description']) ) { $final_sections = array_merge(array('description' => $this->filter_text( $_short_description[2], true )), $final_sections); $excerpt = true; } // dump the non-special sections into $remaining_content // their order will be determined by their original order in the readme.txt $remaining_content = ''; foreach ( $sections as $s_name => $s_data ) { $title_id = esc_attr($s_data['title']); $title_id = str_replace(' ','-',$title_id); $remaining_content .= "\n<h3 id='{$title_id}'>{$s_data['title']}</h3>\n{$s_data['content']}"; } $remaining_content = trim($remaining_content); // All done! // $r['tags'] and $r['contributors'] are simple arrays // $r['sections'] is an array with named elements $r = array( 'name' => $name, 'tags' => $tags, 'requires_at_least' => $requires_at_least, 'tested_up_to' => $tested_up_to, 'stable_tag' => $stable_tag, 'contributors' => $contributors, 'donate_link' => $donate_link, 'license' => $license, 'license_uri' => $license_uri, 'short_description' => $short_description, 'screenshots' => $final_screenshots, 'is_excerpt' => $excerpt, 'is_truncated' => $truncated, 'sections' => $final_sections, 'remaining_content' => $remaining_content, 'upgrade_notice' => $upgrade_notice ); return $r; } function chop_string( $string, $chop ) { // chop a "prefix" from a string: Agressive! uses strstr not 0 === strpos if ( $_string = strstr($string, $chop) ) { $_string = substr($_string, strlen($chop)); return trim($_string); } else { return trim($string); } } function user_sanitize( $text, $strict = false ) { // whitelisted chars if ( function_exists('user_sanitize') ) // bbPress native return user_sanitize( $text, $strict ); if ( $strict ) { $text = preg_replace('/[^a-z0-9-]/i', '', $text); $text = preg_replace('|-+|', '-', $text); } else { $text = preg_replace('/[^a-z0-9_-]/i', '', $text); } return $text; } function sanitize_text( $text ) { // not fancy $text = strip_tags($text); $text = esc_html($text); $text = trim($text); return $text; } function filter_text( $text, $markdown = false ) { // fancy, Markdown $text = trim($text); $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE if ( $markdown ) { // Parse markdown. if ( !function_exists('Markdown') ) require( AUTOMATTIC_README_MARKDOWN ); $text = Markdown($text); } $allowed = array( 'a' => array( 'href' => array(), 'title' => array(), 'rel' => array()), 'blockquote' => array('cite' => array()), 'br' => array(), 'cite' => array(), 'p' => array(), 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), 'h3' => array(), 'h4' => array() ); $text = balanceTags($text); $text = wp_kses( $text, $allowed ); $text = trim($text); return $text; } function code_trick( $text, $markdown ) { // Don't use bbPress native function - it's incompatible with Markdown // If doing markdown, first take any user formatted code blocks and turn them into backticks so that // markdown will preserve things like underscores in code blocks if ( $markdown ) $text = preg_replace_callback("!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( __CLASS__,'decodeit'), $text); $text = str_replace(array("\r\n", "\r"), "\n", $text); if ( !$markdown ) { // This gets the "inline" code blocks, but can't be used with Markdown. $text = preg_replace_callback("|(`)(.*?)`|", array( __CLASS__, 'encodeit'), $text); // This gets the "block level" code blocks and converts them to PRE CODE $text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text); } else { // // Markdown can do inline code, we convert bbPress style block level code to Markdown style // $text = preg_replace_callback("!(^|\n)([ \t]*?)`(.*?)`!s", array( __CLASS__, 'indent'), $text); // Markdown seems to be choking on block level stuff too. Let's just encode it and be done with it. $text = preg_replace_callback("!(^|\n)`(.*?)`!s", array( __CLASS__, 'encodeit'), $text); } return $text; } function indent( $matches ) { $text = $matches[3]; $text = preg_replace('|^|m', $matches[2] . ' ', $text); return $matches[1] . $text; } function encodeit( $matches ) { if ( function_exists('encodeit') ) // bbPress native return encodeit( $matches ); $text = trim($matches[2]); $text = htmlspecialchars($text, ENT_QUOTES); $text = str_replace(array("\r\n", "\r"), "\n", $text); $text = preg_replace("|\n\n\n+|", "\n\n", $text); $text = str_replace('&amp;lt;', '&lt;', $text); $text = str_replace('&amp;gt;', '&gt;', $text); $text = "<code>$text</code>"; if ( "`" != $matches[1] ) $text = "<pre>$text</pre>"; return $text; } function decodeit( $matches ) { if ( function_exists('decodeit') ) // bbPress native return decodeit( $matches ); $text = $matches[2]; $trans_table = array_flip(get_html_translation_table(HTML_ENTITIES)); $text = strtr($text, $trans_table); $text = str_replace('<br />', '', $text); $text = str_replace('&#38;', '&', $text); $text = str_replace('&#39;', "'", $text); if ( '<pre><code>' == $matches[1] ) $text = "\n$text\n"; return "`$text`"; } } // end class
jonasbelcina/palmonade
wp-content/plugins/github-updater-5.3.4/vendor/parse-readme.php
PHP
gpl-2.0
12,074
[ 30522, 1026, 1029, 25718, 2465, 8285, 18900, 4588, 1035, 3191, 4168, 1063, 3853, 8285, 18900, 4588, 1035, 3191, 4168, 1006, 1007, 1063, 1013, 1013, 2023, 2686, 7848, 4818, 2135, 8744, 1065, 3853, 11968, 3366, 1035, 3191, 4168, 1006, 1002, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * java-gnome, a UI library for writing GTK and GNOME programs from Java! * * Copyright © 2011 Operational Dynamics Consulting, Pty Ltd and Others * * The code in this file, and the program it is a part of, is made available * to you by its authors as open source software: you can redistribute it * and/or modify it under the terms of the GNU General Public License version * 2 ("GPL") as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GPL for more details. * * You should have received a copy of the GPL along with this program. If not, * see http://www.gnu.org/licenses/. The authors of this program may be * contacted through http://java-gnome.sourceforge.net/. * * Linking this library statically or dynamically with other modules is making * a combined work based on this library. Thus, the terms and conditions of * the GPL cover the whole combination. As a special exception (the * "Claspath Exception"), the copyright holders of this library give you * permission to link this library with independent modules to produce an * executable, regardless of the license terms of these independent modules, * and to copy and distribute the resulting executable under terms of your * choice, provided that you also meet, for each linked independent module, * the terms and conditions of the license of that module. An independent * module is a module which is not derived from or based on this library. If * you modify this library, you may extend the Classpath Exception to your * version of the library, but you are not obligated to do so. If you do not * wish to do so, delete this exception statement from your version. */ package org.gnome.gtk; /** * Manual code allowing us to handle some data returned by GtkStyleContext * methods. * * @author Guillaume Mazoyer */ final class GtkStyleContextOverride extends Plumbing { static final RegionFlags hasRegion(StyleContext self, String region) { int result; if (self == null) { throw new IllegalArgumentException("self can't be null"); } synchronized (lock) { result = gtk_style_context_contains_region(pointerOf(self), region); return (RegionFlags) enumFor(RegionFlags.class, result); } } private static native final int gtk_style_context_contains_region(long self, String region); static final String[] getClasses(StyleContext self) { String[] result; if (self == null) { throw new IllegalArgumentException("self can't be null"); } synchronized (lock) { result = gtk_style_context_get_classes(pointerOf(self)); return result; } } private static native final String[] gtk_style_context_get_classes(long self); static final String[] getRegions(StyleContext self) { String[] result; if (self == null) { throw new IllegalArgumentException("self can't be null"); } synchronized (lock) { result = gtk_style_context_get_regions(pointerOf(self)); return result; } } private static native final String[] gtk_style_context_get_regions(long self); }
cyberpython/java-gnome
src/bindings/org/gnome/gtk/GtkStyleContextOverride.java
Java
gpl-2.0
3,406
[ 30522, 1013, 1008, 1008, 9262, 1011, 25781, 1010, 1037, 21318, 3075, 2005, 3015, 14181, 2243, 1998, 25781, 3454, 2013, 9262, 999, 1008, 1008, 9385, 1075, 2249, 6515, 10949, 10552, 1010, 13866, 2100, 5183, 1998, 2500, 1008, 1008, 1996, 3642,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# -*- test-case-name: twisted.pb.test.test_promise -*- from twisted.python import util, failure from twisted.internet import defer id = util.unsignedID EVENTUAL, FULFILLED, BROKEN = range(3) class Promise: """I am a promise of a future result. I am a lot like a Deferred, except that my promised result is usually an instance. I make it possible to schedule method invocations on this future instance, returning Promises for the results. Promises are always in one of three states: Eventual, Fulfilled, and Broken. (see http://www.erights.org/elib/concurrency/refmech.html for a pretty picture). They start as Eventual, meaning we do not yet know whether they will resolve or not. In this state, method invocations are queued. Eventually the Promise will be 'resolved' into either the Fulfilled or the Broken state. Fulfilled means that the promise contains a live object to which methods can be dispatched synchronously. Broken promises are incapable of invoking methods: they all result in Failure. Method invocation is always asynchronous: it always returns a Promise. """ # all our internal methods are private, to avoid colliding with normal # method names that users may invoke on our eventual target. _state = EVENTUAL _resolution = None def __init__(self, d): self._watchers = [] self._pendingMethods = [] d.addCallbacks(self._ready, self._broken) def _wait_for_resolution(self): if self._state == EVENTUAL: d = defer.Deferred() self._watchers.append(d) else: d = defer.succeed(self._resolution) return d def _ready(self, resolution): self._resolution = resolution self._state = FULFILLED self._run_methods() def _broken(self, f): self._resolution = f self._state = BROKEN self._run_methods() def _invoke_method(self, name, args, kwargs): if isinstance(self._resolution, failure.Failure): return self._resolution method = getattr(self._resolution, name) res = method(*args, **kwargs) return res def _run_methods(self): for (name, args, kwargs, result_deferred) in self._pendingMethods: d = defer.maybeDeferred(self._invoke_method, name, args, kwargs) d.addBoth(result_deferred.callback) del self._pendingMethods for d in self._watchers: d.callback(self._resolution) del self._watchers def __repr__(self): return "<Promise %#x>" % id(self) def __getattr__(self, name): if name.startswith("__"): raise AttributeError def newmethod(*args, **kwargs): return self._add_method(name, args, kwargs) return newmethod def _add_method(self, name, args, kwargs): if self._state == EVENTUAL: d = defer.Deferred() self._pendingMethods.append((name, args, kwargs, d)) else: d = defer.maybeDeferred(self._invoke_method, name, args, kwargs) return Promise(d) def when(p): """Turn a Promise into a Deferred that will fire with the enclosed object when it is ready. Use this when you actually need to schedule something to happen in a synchronous fashion. Most of the time, you can just invoke methods on the Promise as if it were immediately available.""" assert isinstance(p, Promise) return p._wait_for_resolution()
tquilian/exelearningTest
twisted/pb/promise.py
Python
gpl-2.0
3,532
[ 30522, 1001, 1011, 1008, 1011, 3231, 1011, 2553, 1011, 2171, 1024, 6389, 1012, 1052, 2497, 1012, 3231, 1012, 3231, 1035, 4872, 1011, 1008, 1011, 2013, 6389, 1012, 18750, 12324, 21183, 4014, 1010, 4945, 2013, 6389, 1012, 4274, 12324, 13366, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
{% include 'header.html' %} <!-- Main --> <section id="main" class="container"> <section class="box blog-post"> <div style="text-align:center;font-size:6em;font-weigth:bold;margin:1em 0">ERROR 404</div> </section> </section> {% include 'footer.html' %}
cbazureau/website
www/cedric/src/view/error.html
HTML
mit
263
[ 30522, 1063, 1003, 2421, 1005, 20346, 1012, 16129, 1005, 1003, 1065, 1026, 999, 1011, 1011, 2364, 1011, 1011, 1028, 1026, 2930, 8909, 1027, 1000, 2364, 1000, 2465, 1027, 1000, 11661, 1000, 1028, 1026, 2930, 2465, 1027, 1000, 3482, 9927, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Globalization; using System.ComponentModel; namespace System.Configuration { public sealed class InfiniteTimeSpanConverter : ConfigurationConverterBase { private static readonly TypeConverter s_timeSpanConverter = TypeDescriptor.GetConverter(typeof(TimeSpan)); public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(TimeSpan)); return (TimeSpan)value == TimeSpan.MaxValue ? "Infinite" : s_timeSpanConverter.ConvertToInvariantString(value); } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { return (string)data == "Infinite" ? TimeSpan.MaxValue : s_timeSpanConverter.ConvertFromInvariantString((string)data); } } }
nbarbettini/corefx
src/System.Configuration.ConfigurationManager/src/System/Configuration/InfiniteTimeSpanConverter.cs
C#
mit
1,124
[ 30522, 1013, 1013, 7000, 2000, 1996, 1012, 5658, 3192, 2104, 2028, 2030, 2062, 10540, 1012, 1013, 1013, 1996, 1012, 5658, 3192, 15943, 2023, 5371, 2000, 2017, 2104, 1996, 10210, 6105, 1012, 1013, 1013, 2156, 1996, 6105, 5371, 1999, 1996, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable server timing config.server_timing = true # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise exceptions for disallowed deprecations. config.active_support.disallowed_deprecation = :raise # Tell Active Support which deprecation messages to disallow. config.active_support.disallowed_deprecation_warnings = [] # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true end ENV['OXALATES_PASSWORD'] ||= BCrypt::Password.create('password')
adamstegman/oxalates
config/environments/development.rb
Ruby
mit
2,203
[ 30522, 5478, 1000, 3161, 1035, 2490, 1013, 4563, 1035, 4654, 2102, 1013, 16109, 1013, 2051, 1000, 15168, 1012, 4646, 1012, 9530, 8873, 27390, 2063, 2079, 1001, 10906, 9675, 2182, 2097, 2202, 23359, 2058, 2216, 1999, 9530, 8873, 2290, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# office2html node module to convert office files to html requires unoconv to be installed https://github.com/dagwieers/unoconv convert office files (docx, pptx, xlsx) to an html document ### Usage: ``` var office2html = require(office2html), generateHtml = office2html.generateHtml; generateHtml('test/test.pptx', function(err, result) { console.log(result); }); ``` ### Test: put a office document (docx, pptx, xlsx) in the test folder.
gbaudry303/office2html
README.md
Markdown
gpl-2.0
448
[ 30522, 1001, 2436, 2475, 11039, 19968, 13045, 11336, 2000, 10463, 2436, 6764, 2000, 16129, 5942, 27776, 8663, 2615, 2000, 2022, 5361, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 4830, 2290, 9148, 22862, 1013, 27776, 8663, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
## # This file is part of WhatWeb and may be subject to # redistribution and commercial restrictions. Please see the WhatWeb # web site for more information on licensing and terms of use. # https://morningstarsecurity.com/research/whatweb ## Plugin.define do name "SDCMS" authors [ "Brendan Coles <bcoles@gmail.com>", # 2011-10-29 ] version "0.1" description "SDCMS - CMS - Requires ASP and Access/MsSql" website "http://www.sdcms.cn/" # Google results as at 2011-10-29 # # 410 for "Powered By SDCMS" # Dorks # dorks [ '"Powered By SDCMS"' ] # Matches # matches [ # Powered by link # Version Detection { :version=>/<br>Powered By <a href=['"]http:\/\/www\.sdcms\.cn['"] target=['"]_blank['"]>SDCMS ([^<]+)<\/a>/ }, # dl id="con_three_1" class="index_photo" { :text=>'<dl id="con_three_1" class="index_photo">' }, ] end
urbanadventurer/WhatWeb
plugins/sdcms.rb
Ruby
gpl-2.0
831
[ 30522, 1001, 1001, 1001, 2023, 5371, 2003, 2112, 1997, 2054, 8545, 2497, 1998, 2089, 2022, 3395, 2000, 1001, 25707, 1998, 3293, 9259, 1012, 3531, 2156, 1996, 2054, 8545, 2497, 1001, 4773, 2609, 2005, 2062, 2592, 2006, 13202, 1998, 3408, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<ion-view view-title="Settings"> <ion-content> <ion-list> <label class="item item-input item-select"> <div class="input-label"> Default Congregation </div> <select ng-options="c.name as c.fullName for c in settingsCtrl.congregations track by $index " ng-model="settingsCtrl.settings.defaultCongregation" ng-change="settingsCtrl.save()"> </select> </label> </ion-list> </ion-content> <ion-footer-bar align-title="left" class="bar-assertive"> <div class="bar bar-footer bar-balanced"> <div class="title">Save</div> </div> </ion-footer-bar> </ion-view>
rllc/llc-archives-mobile
www/modules/settings/settings.html
HTML
apache-2.0
676
[ 30522, 1026, 10163, 1011, 3193, 3193, 1011, 2516, 1027, 1000, 10906, 1000, 1028, 1026, 10163, 1011, 4180, 1028, 1026, 10163, 1011, 2862, 1028, 1026, 3830, 2465, 1027, 1000, 8875, 8875, 1011, 7953, 8875, 1011, 7276, 1000, 1028, 1026, 4487, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
typedef struct effect_uuid_s { uint32_t timeLow; uint16_t timeMid; uint16_t timeHiAndVersion; uint16_t clockSeq; uint8_t node[6]; } effect_uuid_t; // Maximum length of character strings in structures defines by this API. #define EFFECT_STRING_LEN_MAX 64 // NULL UUID definition (matches SL_IID_NULL_) #define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \ { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } } static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER; static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_; static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210"; // The effect descriptor contains necessary information to facilitate the enumeration of the effect // engines present in a library. typedef struct effect_descriptor_s { effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect effect_uuid_t uuid; // UUID for this particular implementation uint32_t apiVersion; // Version of the effect control API implemented uint32_t flags; // effect engine capabilities/requirements flags (see below) uint16_t cpuLoad; // CPU load indication (see below) uint16_t memoryUsage; // Data Memory usage (see below) char name[EFFECT_STRING_LEN_MAX]; // human readable effect name char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name } effect_descriptor_t; // CPU load and memory usage indication: each effect implementation must provide an indication of // its CPU and memory usage for the audio effect framework to limit the number of effects // instantiated at a given time on a given platform. // The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS. // The memory usage is expressed in KB and includes only dynamically allocated memory // Definitions for flags field of effect descriptor. // +---------------------------+-----------+----------------------------------- // | description | bits | values // +---------------------------+-----------+----------------------------------- // | connection mode | 0..2 | 0 insert: after track process // | | | 1 auxiliary: connect to track auxiliary // | | | output and use send level // | | | 2 replace: replaces track process function; // | | | must implement SRC, volume and mono to stereo. // | | | 3 pre processing: applied below audio HAL on input // | | | 4 post processing: applied below audio HAL on output // | | | 5 - 7 reserved // +---------------------------+-----------+----------------------------------- // | insertion preference | 3..5 | 0 none // | | | 1 first of the chain // | | | 2 last of the chain // | | | 3 exclusive (only effect in the insert chain) // | | | 4..7 reserved // +---------------------------+-----------+----------------------------------- // | Volume management | 6..8 | 0 none // | | | 1 implements volume control // | | | 2 requires volume indication // | | | 4 reserved // +---------------------------+-----------+----------------------------------- // | Device indication | 9..11 | 0 none // | | | 1 requires device updates // | | | 2, 4 reserved // +---------------------------+-----------+----------------------------------- // | Sample input mode | 12..13 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG // | | | command must specify a buffer descriptor // | | | 2 provider: process() function uses the // | | | bufferProvider indicated by the // | | | EFFECT_CMD_SET_CONFIG command to request input. // | | | buffers. // | | | 3 both: both input modes are supported // +---------------------------+-----------+----------------------------------- // | Sample output mode | 14..15 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG // | | | command must specify a buffer descriptor // | | | 2 provider: process() function uses the // | | | bufferProvider indicated by the // | | | EFFECT_CMD_SET_CONFIG command to request output // | | | buffers. // | | | 3 both: both output modes are supported // +---------------------------+-----------+----------------------------------- // | Hardware acceleration | 16..17 | 0 No hardware acceleration // | | | 1 non tunneled hw acceleration: the process() function // | | | reads the samples, send them to HW accelerated // | | | effect processor, reads back the processed samples // | | | and returns them to the output buffer. // | | | 2 tunneled hw acceleration: the process() function is // | | | transparent. The effect interface is only used to // | | | control the effect engine. This mode is relevant for // | | | global effects actually applied by the audio // | | | hardware on the output stream. // +---------------------------+-----------+----------------------------------- // | Audio Mode indication | 18..19 | 0 none // | | | 1 requires audio mode updates // | | | 2..3 reserved // +---------------------------+-----------+----------------------------------- // | Audio source indication | 20..21 | 0 none // | | | 1 requires audio source updates // | | | 2..3 reserved // +---------------------------+-----------+----------------------------------- // | Effect offload supported | 22 | 0 The effect cannot be offloaded to an audio DSP // | | | 1 The effect can be offloaded to an audio DSP // +---------------------------+-----------+----------------------------------- // Insert mode #define EFFECT_FLAG_TYPE_SHIFT 0 #define EFFECT_FLAG_TYPE_SIZE 3 #define EFFECT_FLAG_TYPE_MASK (((1 << EFFECT_FLAG_TYPE_SIZE) -1) \ << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_INSERT (0 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_AUXILIARY (1 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_REPLACE (2 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_PRE_PROC (3 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_POST_PROC (4 << EFFECT_FLAG_TYPE_SHIFT) // Insert preference #define EFFECT_FLAG_INSERT_SHIFT (EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE) #define EFFECT_FLAG_INSERT_SIZE 3 #define EFFECT_FLAG_INSERT_MASK (((1 << EFFECT_FLAG_INSERT_SIZE) -1) \ << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_ANY (0 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_FIRST (1 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_LAST (2 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_EXCLUSIVE (3 << EFFECT_FLAG_INSERT_SHIFT) // Volume control #define EFFECT_FLAG_VOLUME_SHIFT (EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE) #define EFFECT_FLAG_VOLUME_SIZE 3 #define EFFECT_FLAG_VOLUME_MASK (((1 << EFFECT_FLAG_VOLUME_SIZE) -1) \ << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_CTRL (1 << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_IND (2 << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_NONE (0 << EFFECT_FLAG_VOLUME_SHIFT) // Device indication #define EFFECT_FLAG_DEVICE_SHIFT (EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE) #define EFFECT_FLAG_DEVICE_SIZE 3 #define EFFECT_FLAG_DEVICE_MASK (((1 << EFFECT_FLAG_DEVICE_SIZE) -1) \ << EFFECT_FLAG_DEVICE_SHIFT) #define EFFECT_FLAG_DEVICE_IND (1 << EFFECT_FLAG_DEVICE_SHIFT) #define EFFECT_FLAG_DEVICE_NONE (0 << EFFECT_FLAG_DEVICE_SHIFT) // Sample input modes #define EFFECT_FLAG_INPUT_SHIFT (EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE) #define EFFECT_FLAG_INPUT_SIZE 2 #define EFFECT_FLAG_INPUT_MASK (((1 << EFFECT_FLAG_INPUT_SIZE) -1) \ << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_DIRECT (1 << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_PROVIDER (2 << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_BOTH (3 << EFFECT_FLAG_INPUT_SHIFT) // Sample output modes #define EFFECT_FLAG_OUTPUT_SHIFT (EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE) #define EFFECT_FLAG_OUTPUT_SIZE 2 #define EFFECT_FLAG_OUTPUT_MASK (((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) \ << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_DIRECT (1 << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_PROVIDER (2 << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_BOTH (3 << EFFECT_FLAG_OUTPUT_SHIFT) // Hardware acceleration mode #define EFFECT_FLAG_HW_ACC_SHIFT (EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE) #define EFFECT_FLAG_HW_ACC_SIZE 2 #define EFFECT_FLAG_HW_ACC_MASK (((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) \ << EFFECT_FLAG_HW_ACC_SHIFT) #define EFFECT_FLAG_HW_ACC_SIMPLE (1 << EFFECT_FLAG_HW_ACC_SHIFT) #define EFFECT_FLAG_HW_ACC_TUNNEL (2 << EFFECT_FLAG_HW_ACC_SHIFT) // Audio mode indication #define EFFECT_FLAG_AUDIO_MODE_SHIFT (EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE) #define EFFECT_FLAG_AUDIO_MODE_SIZE 2 #define EFFECT_FLAG_AUDIO_MODE_MASK (((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) \ << EFFECT_FLAG_AUDIO_MODE_SHIFT) #define EFFECT_FLAG_AUDIO_MODE_IND (1 << EFFECT_FLAG_AUDIO_MODE_SHIFT) #define EFFECT_FLAG_AUDIO_MODE_NONE (0 << EFFECT_FLAG_AUDIO_MODE_SHIFT) // Audio source indication #define EFFECT_FLAG_AUDIO_SOURCE_SHIFT (EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE) #define EFFECT_FLAG_AUDIO_SOURCE_SIZE 2 #define EFFECT_FLAG_AUDIO_SOURCE_MASK (((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1) \ << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) #define EFFECT_FLAG_AUDIO_SOURCE_IND (1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) #define EFFECT_FLAG_AUDIO_SOURCE_NONE (0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) // Effect offload indication #define EFFECT_FLAG_OFFLOAD_SHIFT (EFFECT_FLAG_AUDIO_SOURCE_SHIFT + \ EFFECT_FLAG_AUDIO_SOURCE_SIZE) #define EFFECT_FLAG_OFFLOAD_SIZE 1 #define EFFECT_FLAG_OFFLOAD_MASK (((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) \ << EFFECT_FLAG_OFFLOAD_SHIFT) #define EFFECT_FLAG_OFFLOAD_SUPPORTED (1 << EFFECT_FLAG_OFFLOAD_SHIFT) #define EFFECT_MAKE_API_VERSION(M, m) (((M)<<16) | ((m) & 0xFFFF)) #define EFFECT_API_VERSION_MAJOR(v) ((v)>>16) #define EFFECT_API_VERSION_MINOR(v) ((m) & 0xFFFF) ///////////////////////////////////////////////// // Effect control interface ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // type and return its address as effect_handle_t typedef struct effect_interface_s **effect_handle_t; // Forward definition of type audio_buffer_t typedef struct audio_buffer_s audio_buffer_t; // Effect control interface definition struct effect_interface_s { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to command code // The return code should be restricted to indicate problems related to the this // API specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); }; // //--- Standardized command codes for command() function // enum effect_command_e { EFFECT_CMD_INIT, // initialize effect engine EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t) EFFECT_CMD_RESET, // reset effect engine EFFECT_CMD_ENABLE, // enable effect process EFFECT_CMD_DISABLE, // disable effect process EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t) EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred EFFECT_CMD_GET_PARAM, // get parameter EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t) EFFECT_CMD_SET_VOLUME, // set volume EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...) EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t) EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t) EFFECT_CMD_GET_CONFIG, // read effect engine configuration EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature. EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t) EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one, // send the ioHandle of the effect thread EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code }; //================================================================================================== // command: EFFECT_CMD_INIT //-------------------------------------------------------------------------------------------------- // description: // Initialize effect engine: All configurations return to default //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Apply new audio parameters configurations for input and output buffers //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_config_t) // data: effect_config_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_RESET //-------------------------------------------------------------------------------------------------- // description: // Reset the effect engine. Keep configuration but resets state and buffer content //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_ENABLE //-------------------------------------------------------------------------------------------------- // description: // Enable the process. Called by the framework before the first call to process() //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_DISABLE //-------------------------------------------------------------------------------------------------- // description: // Disable the process. Called by the framework after the last call to process() //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_PARAM //-------------------------------------------------------------------------------------------------- // description: // Set a parameter and apply it immediately //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_PARAM_DEFERRED //-------------------------------------------------------------------------------------------------- // description: // Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_PARAM_COMMIT //-------------------------------------------------------------------------------------------------- // description: // Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_GET_PARAM //-------------------------------------------------------------------------------------------------- // description: // Get a parameter value //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param // data: effect_param_t + param //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //================================================================================================== // command: EFFECT_CMD_SET_DEVICE //-------------------------------------------------------------------------------------------------- // description: // Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t // for device values. // The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this // command when the device changes //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_VOLUME //-------------------------------------------------------------------------------------------------- // description: // Set and get volume. Used by audio framework to delegate volume control to effect engine. // The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in // its descriptor to receive this command before every call to process() function // If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return // the volume that should be applied before the effect is processed. The overall volume (the volume // actually applied by the effect engine multiplied by the returned value) should match the value // indicated in the command. //-------------------------------------------------------------------------------------------------- // command format: // size: n * sizeof(uint32_t) // data: volume for each channel defined in effect_config_t for output buffer expressed in // 8.24 fixed point format //-------------------------------------------------------------------------------------------------- // reply format: // size: n * sizeof(uint32_t) / 0 // data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor: // volume for each channel defined in effect_config_t for output buffer expressed in // 8.24 fixed point format // - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor: // N/A // It is legal to receive a null pointer as pReplyData in which case the effect framework has // delegated volume control to another effect //================================================================================================== // command: EFFECT_CMD_SET_AUDIO_MODE //-------------------------------------------------------------------------------------------------- // description: // Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its // descriptor to receive this command when the audio mode changes. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: audio_mode_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_CONFIG_REVERSE //-------------------------------------------------------------------------------------------------- // description: // Apply new audio parameters configurations for input and output buffers of reverse stream. // An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_config_t) // data: effect_config_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_INPUT_DEVICE //-------------------------------------------------------------------------------------------------- // description: // Set the capture device the audio input path is connected to. See audio.h, audio_devices_t // for device values. // The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this // command when the device changes //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_GET_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Read audio parameters configurations for input and output buffers //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_config_t) // data: effect_config_t //================================================================================================== // command: EFFECT_CMD_GET_CONFIG_REVERSE //-------------------------------------------------------------------------------------------------- // description: // Read audio parameters configurations for input and output buffers of reverse stream //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_config_t) // data: effect_config_t //================================================================================================== // command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS //-------------------------------------------------------------------------------------------------- // description: // Queries for supported configurations for a particular feature (e.g. get the supported // combinations of main and auxiliary channels for a noise suppressor). // The command parameter is the feature identifier (See effect_feature_e for a list of defined // features) followed by the maximum number of configuration descriptor to return. // The reply is composed of: // - status (uint32_t): // - 0 if feature is supported // - -ENOSYS if the feature is not supported, // - -ENOMEM if the feature is supported but the total number of supported configurations // exceeds the maximum number indicated by the caller. // - total number of supported configurations (uint32_t) // - an array of configuration descriptors. // The actual number of descriptors returned must not exceed the maximum number indicated by // the caller. //-------------------------------------------------------------------------------------------------- // command format: // size: 2 x sizeof(uint32_t) // data: effect_feature_e + maximum number of configurations to return //-------------------------------------------------------------------------------------------------- // reply format: // size: 2 x sizeof(uint32_t) + n x sizeof (<config descriptor>) // data: status + total number of configurations supported + array of n config descriptors //================================================================================================== // command: EFFECT_CMD_GET_FEATURE_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Retrieves current configuration for a given feature. // The reply status is: // - 0 if feature is supported // - -ENOSYS if the feature is not supported, //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: effect_feature_e //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) + sizeof (<config descriptor>) // data: status + config descriptor //================================================================================================== // command: EFFECT_CMD_SET_FEATURE_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Sets current configuration for a given feature. // The reply status is: // - 0 if feature is supported // - -ENOSYS if the feature is not supported, // - -EINVAL if the configuration is invalid //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) + sizeof (<config descriptor>) // data: effect_feature_e + config descriptor //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) // data: status //================================================================================================== // command: EFFECT_CMD_SET_AUDIO_SOURCE //-------------------------------------------------------------------------------------------------- // description: // Set the audio source the capture path is configured for (Camcorder, voice recognition...). // See audio.h, audio_source_t for values. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_OFFLOAD //-------------------------------------------------------------------------------------------------- // description: // 1.indicate if the playback thread the effect is attached to is offloaded or not // 2.update the io handle of the playback thread the effect is attached to //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_offload_param_t) // data: effect_offload_param_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // command: EFFECT_CMD_FIRST_PROPRIETARY //-------------------------------------------------------------------------------------------------- // description: // All proprietary effect commands must use command codes above this value. The size and format of // command and response fields is free in this case //================================================================================================== // Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t // structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with // regard to the channel mask definition in audio.h, audio_channel_mask_t e.g : // Stereo: left, right // 5 point 1: front left, front right, front center, low frequency, back left, back right // The buffer size is expressed in frame count, a frame being composed of samples for all // channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by // definition typedef struct audio_buffer_s { size_t frameCount; // number of frames in buffer union { void* raw; // raw pointer to start of buffer float* f32; // pointer to float 32 bit data at start of buffer int32_t* s32; // pointer to signed 32 bit data at start of buffer int16_t* s16; // pointer to signed 16 bit data at start of buffer uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer }; } audio_buffer_t; typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer); typedef struct buffer_provider_s { buffer_function_t getBuffer; // retrieve next buffer buffer_function_t releaseBuffer; // release used buffer void *cookie; // for use by client of buffer provider functions } buffer_provider_t; // The buffer_config_s structure specifies the input or output audio format // to be used by the effect engine. It is part of the effect_config_t // structure that defines both input and output buffer configurations and is // passed by the EFFECT_CMD_SET_CONFIG or EFFECT_CMD_SET_CONFIG_REVERSE command. typedef struct buffer_config_s { audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly uint32_t samplingRate; // sampling rate uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h) buffer_provider_t bufferProvider; // buffer provider uint8_t format; // Audio format (see audio_format_t in audio.h) uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e) uint16_t mask; // indicates which of the above fields is valid } buffer_config_t; // Values for "accessMode" field of buffer_config_t: // overwrite, read only, accumulate (read/modify/write) typedef enum { EFFECT_BUFFER_ACCESS_WRITE, EFFECT_BUFFER_ACCESS_READ, EFFECT_BUFFER_ACCESS_ACCUMULATE } effect_buffer_access_e; // effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_CONFIG // command to configure audio parameters and buffers for effect engine input and output. typedef struct effect_config_s { buffer_config_t inputCfg; buffer_config_t outputCfg; } effect_config_t; // effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM // command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command. // psize and vsize represent the actual size of parameter and value. // // NOTE: the start of value field inside the data field is always on a 32 bit boundary: // // +-----------+ // | status | sizeof(int) // +-----------+ // | psize | sizeof(int) // +-----------+ // | vsize | sizeof(int) // +-----------+ // | | | | // ~ parameter ~ > psize | // | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int) // +-----------+ | // | padding | | // +-----------+ // | | | // ~ value ~ > vsize // | | | // +-----------+ typedef struct effect_param_s { int32_t status; // Transaction status (unused for command, used for reply) uint32_t psize; // Parameter size uint32_t vsize; // Value size char data[]; // Start of Parameter + Value data } effect_param_t; ///////////////////////////////////////////////// // Effect library interface ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. All effects // created with the same session ID are connected in series and process the same signal // stream. Knowing that two effects are part of the same effect chain can help the // library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to at audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" // Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field // in buffer_config_t must be taken into account when executing the EFFECT_CMD_SET_CONFIG command #define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account #define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account #define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account #define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account #define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account #define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account #define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \ EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \ EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER) enum { AUDIO_IO_HANDLE_NONE = 0, AUDIO_MODULE_HANDLE_NONE = 0, AUDIO_PORT_HANDLE_NONE = 0, AUDIO_PATCH_HANDLE_NONE = 0, }; typedef enum { AUDIO_STREAM_DEFAULT = -1, // (-1) AUDIO_STREAM_MIN = 0, AUDIO_STREAM_VOICE_CALL = 0, AUDIO_STREAM_SYSTEM = 1, AUDIO_STREAM_RING = 2, AUDIO_STREAM_MUSIC = 3, AUDIO_STREAM_ALARM = 4, AUDIO_STREAM_NOTIFICATION = 5, AUDIO_STREAM_BLUETOOTH_SCO = 6, AUDIO_STREAM_ENFORCED_AUDIBLE = 7, AUDIO_STREAM_DTMF = 8, AUDIO_STREAM_TTS = 9, AUDIO_STREAM_ACCESSIBILITY = 10, #ifndef AUDIO_NO_SYSTEM_DECLARATIONS /** For dynamic policy output mixes. Only used by the audio policy */ AUDIO_STREAM_REROUTING = 11, /** For audio flinger tracks volume. Only used by the audioflinger */ AUDIO_STREAM_PATCH = 12, #endif // AUDIO_NO_SYSTEM_DECLARATIONS } audio_stream_type_t; typedef enum { AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4, AUDIO_SOURCE_CAMCORDER = 5, AUDIO_SOURCE_VOICE_RECOGNITION = 6, AUDIO_SOURCE_VOICE_COMMUNICATION = 7, AUDIO_SOURCE_REMOTE_SUBMIX = 8, AUDIO_SOURCE_UNPROCESSED = 9, AUDIO_SOURCE_FM_TUNER = 1998, #ifndef AUDIO_NO_SYSTEM_DECLARATIONS /** * A low-priority, preemptible audio source for for background software * hotword detection. Same tuning as VOICE_RECOGNITION. * Used only internally by the framework. */ AUDIO_SOURCE_HOTWORD = 1999, #endif // AUDIO_NO_SYSTEM_DECLARATIONS } audio_source_t; typedef enum { AUDIO_SESSION_OUTPUT_STAGE = -1, // (-1) AUDIO_SESSION_OUTPUT_MIX = 0, AUDIO_SESSION_ALLOCATE = 0, AUDIO_SESSION_NONE = 0, } audio_session_t; typedef enum { AUDIO_FORMAT_INVALID = 0xFFFFFFFFu, AUDIO_FORMAT_DEFAULT = 0, AUDIO_FORMAT_PCM = 0x00000000u, AUDIO_FORMAT_MP3 = 0x01000000u, AUDIO_FORMAT_AMR_NB = 0x02000000u, AUDIO_FORMAT_AMR_WB = 0x03000000u, AUDIO_FORMAT_AAC = 0x04000000u, AUDIO_FORMAT_HE_AAC_V1 = 0x05000000u, AUDIO_FORMAT_HE_AAC_V2 = 0x06000000u, AUDIO_FORMAT_VORBIS = 0x07000000u, AUDIO_FORMAT_OPUS = 0x08000000u, AUDIO_FORMAT_AC3 = 0x09000000u, AUDIO_FORMAT_E_AC3 = 0x0A000000u, AUDIO_FORMAT_DTS = 0x0B000000u, AUDIO_FORMAT_DTS_HD = 0x0C000000u, AUDIO_FORMAT_IEC61937 = 0x0D000000u, AUDIO_FORMAT_DOLBY_TRUEHD = 0x0E000000u, AUDIO_FORMAT_EVRC = 0x10000000u, AUDIO_FORMAT_EVRCB = 0x11000000u, AUDIO_FORMAT_EVRCWB = 0x12000000u, AUDIO_FORMAT_EVRCNW = 0x13000000u, AUDIO_FORMAT_AAC_ADIF = 0x14000000u, AUDIO_FORMAT_WMA = 0x15000000u, AUDIO_FORMAT_WMA_PRO = 0x16000000u, AUDIO_FORMAT_AMR_WB_PLUS = 0x17000000u, AUDIO_FORMAT_MP2 = 0x18000000u, AUDIO_FORMAT_QCELP = 0x19000000u, AUDIO_FORMAT_DSD = 0x1A000000u, AUDIO_FORMAT_FLAC = 0x1B000000u, AUDIO_FORMAT_ALAC = 0x1C000000u, AUDIO_FORMAT_APE = 0x1D000000u, AUDIO_FORMAT_AAC_ADTS = 0x1E000000u, AUDIO_FORMAT_SBC = 0x1F000000u, AUDIO_FORMAT_APTX = 0x20000000u, AUDIO_FORMAT_APTX_HD = 0x21000000u, AUDIO_FORMAT_AC4 = 0x22000000u, AUDIO_FORMAT_LDAC = 0x23000000u, AUDIO_FORMAT_MAT = 0x24000000u, AUDIO_FORMAT_MAIN_MASK = 0xFF000000u, AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFu, /* Subformats */ AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1u, AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2u, AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3u, AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4u, AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5u, AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6u, AUDIO_FORMAT_MP3_SUB_NONE = 0x0u, AUDIO_FORMAT_AMR_SUB_NONE = 0x0u, AUDIO_FORMAT_AAC_SUB_MAIN = 0x1u, AUDIO_FORMAT_AAC_SUB_LC = 0x2u, AUDIO_FORMAT_AAC_SUB_SSR = 0x4u, AUDIO_FORMAT_AAC_SUB_LTP = 0x8u, AUDIO_FORMAT_AAC_SUB_HE_V1 = 0x10u, AUDIO_FORMAT_AAC_SUB_SCALABLE = 0x20u, AUDIO_FORMAT_AAC_SUB_ERLC = 0x40u, AUDIO_FORMAT_AAC_SUB_LD = 0x80u, AUDIO_FORMAT_AAC_SUB_HE_V2 = 0x100u, AUDIO_FORMAT_AAC_SUB_ELD = 0x200u, AUDIO_FORMAT_AAC_SUB_XHE = 0x300u, AUDIO_FORMAT_VORBIS_SUB_NONE = 0x0u, AUDIO_FORMAT_E_AC3_SUB_JOC = 0x1u, AUDIO_FORMAT_MAT_SUB_1_0 = 0x1u, AUDIO_FORMAT_MAT_SUB_2_0 = 0x2u, AUDIO_FORMAT_MAT_SUB_2_1 = 0x3u, /* Aliases */ AUDIO_FORMAT_PCM_16_BIT = 0x1u, // (PCM | PCM_SUB_16_BIT) AUDIO_FORMAT_PCM_8_BIT = 0x2u, // (PCM | PCM_SUB_8_BIT) AUDIO_FORMAT_PCM_32_BIT = 0x3u, // (PCM | PCM_SUB_32_BIT) AUDIO_FORMAT_PCM_8_24_BIT = 0x4u, // (PCM | PCM_SUB_8_24_BIT) AUDIO_FORMAT_PCM_FLOAT = 0x5u, // (PCM | PCM_SUB_FLOAT) AUDIO_FORMAT_PCM_24_BIT_PACKED = 0x6u, // (PCM | PCM_SUB_24_BIT_PACKED) AUDIO_FORMAT_AAC_MAIN = 0x4000001u, // (AAC | AAC_SUB_MAIN) AUDIO_FORMAT_AAC_LC = 0x4000002u, // (AAC | AAC_SUB_LC) AUDIO_FORMAT_AAC_SSR = 0x4000004u, // (AAC | AAC_SUB_SSR) AUDIO_FORMAT_AAC_LTP = 0x4000008u, // (AAC | AAC_SUB_LTP) AUDIO_FORMAT_AAC_HE_V1 = 0x4000010u, // (AAC | AAC_SUB_HE_V1) AUDIO_FORMAT_AAC_SCALABLE = 0x4000020u, // (AAC | AAC_SUB_SCALABLE) AUDIO_FORMAT_AAC_ERLC = 0x4000040u, // (AAC | AAC_SUB_ERLC) AUDIO_FORMAT_AAC_LD = 0x4000080u, // (AAC | AAC_SUB_LD) AUDIO_FORMAT_AAC_HE_V2 = 0x4000100u, // (AAC | AAC_SUB_HE_V2) AUDIO_FORMAT_AAC_ELD = 0x4000200u, // (AAC | AAC_SUB_ELD) AUDIO_FORMAT_AAC_XHE = 0x4000300u, // (AAC | AAC_SUB_XHE) AUDIO_FORMAT_AAC_ADTS_MAIN = 0x1e000001u, // (AAC_ADTS | AAC_SUB_MAIN) AUDIO_FORMAT_AAC_ADTS_LC = 0x1e000002u, // (AAC_ADTS | AAC_SUB_LC) AUDIO_FORMAT_AAC_ADTS_SSR = 0x1e000004u, // (AAC_ADTS | AAC_SUB_SSR) AUDIO_FORMAT_AAC_ADTS_LTP = 0x1e000008u, // (AAC_ADTS | AAC_SUB_LTP) AUDIO_FORMAT_AAC_ADTS_HE_V1 = 0x1e000010u, // (AAC_ADTS | AAC_SUB_HE_V1) AUDIO_FORMAT_AAC_ADTS_SCALABLE = 0x1e000020u, // (AAC_ADTS | AAC_SUB_SCALABLE) AUDIO_FORMAT_AAC_ADTS_ERLC = 0x1e000040u, // (AAC_ADTS | AAC_SUB_ERLC) AUDIO_FORMAT_AAC_ADTS_LD = 0x1e000080u, // (AAC_ADTS | AAC_SUB_LD) AUDIO_FORMAT_AAC_ADTS_HE_V2 = 0x1e000100u, // (AAC_ADTS | AAC_SUB_HE_V2) AUDIO_FORMAT_AAC_ADTS_ELD = 0x1e000200u, // (AAC_ADTS | AAC_SUB_ELD) AUDIO_FORMAT_AAC_ADTS_XHE = 0x1e000300u, // (AAC_ADTS | AAC_SUB_XHE) AUDIO_FORMAT_E_AC3_JOC = 0xA000001u, // (E_AC3 | E_AC3_SUB_JOC) AUDIO_FORMAT_MAT_1_0 = 0x24000001u, // (MAT | MAT_SUB_1_0) AUDIO_FORMAT_MAT_2_0 = 0x24000002u, // (MAT | MAT_SUB_2_0) AUDIO_FORMAT_MAT_2_1 = 0x24000003u, // (MAT | MAT_SUB_2_1) } audio_format_t; enum { FCC_2 = 2, FCC_8 = 8, }; enum { AUDIO_CHANNEL_REPRESENTATION_POSITION = 0x0u, AUDIO_CHANNEL_REPRESENTATION_INDEX = 0x2u, AUDIO_CHANNEL_NONE = 0x0u, AUDIO_CHANNEL_INVALID = 0xC0000000u, AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1u, AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2u, AUDIO_CHANNEL_OUT_FRONT_CENTER = 0x4u, AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 0x8u, AUDIO_CHANNEL_OUT_BACK_LEFT = 0x10u, AUDIO_CHANNEL_OUT_BACK_RIGHT = 0x20u, AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40u, AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80u, AUDIO_CHANNEL_OUT_BACK_CENTER = 0x100u, AUDIO_CHANNEL_OUT_SIDE_LEFT = 0x200u, AUDIO_CHANNEL_OUT_SIDE_RIGHT = 0x400u, AUDIO_CHANNEL_OUT_TOP_CENTER = 0x800u, AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000u, AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000u, AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000u, AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 0x8000u, AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 0x10000u, AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000u, AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT = 0x40000u, AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT = 0x80000u, AUDIO_CHANNEL_OUT_MONO = 0x1u, // OUT_FRONT_LEFT AUDIO_CHANNEL_OUT_STEREO = 0x3u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT AUDIO_CHANNEL_OUT_2POINT1 = 0xBu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY AUDIO_CHANNEL_OUT_2POINT0POINT2 = 0xC0003u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT AUDIO_CHANNEL_OUT_2POINT1POINT2 = 0xC000Bu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY AUDIO_CHANNEL_OUT_3POINT0POINT2 = 0xC0007u, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT AUDIO_CHANNEL_OUT_3POINT1POINT2 = 0xC000Fu, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY AUDIO_CHANNEL_OUT_QUAD = 0x33u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_BACK_LEFT | OUT_BACK_RIGHT AUDIO_CHANNEL_OUT_QUAD_BACK = 0x33u, // OUT_QUAD AUDIO_CHANNEL_OUT_QUAD_SIDE = 0x603u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_SIDE_LEFT | OUT_SIDE_RIGHT AUDIO_CHANNEL_OUT_SURROUND = 0x107u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_BACK_CENTER AUDIO_CHANNEL_OUT_PENTA = 0x37u, // OUT_QUAD | OUT_FRONT_CENTER AUDIO_CHANNEL_OUT_5POINT1 = 0x3Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT AUDIO_CHANNEL_OUT_5POINT1_BACK = 0x3Fu, // OUT_5POINT1 AUDIO_CHANNEL_OUT_5POINT1_SIDE = 0x60Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_SIDE_LEFT | OUT_SIDE_RIGHT AUDIO_CHANNEL_OUT_5POINT1POINT2 = 0xC003Fu, // OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT AUDIO_CHANNEL_OUT_5POINT1POINT4 = 0x2D03Fu, // OUT_5POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT AUDIO_CHANNEL_OUT_6POINT1 = 0x13Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT | OUT_BACK_CENTER AUDIO_CHANNEL_OUT_7POINT1 = 0x63Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT | OUT_SIDE_LEFT | OUT_SIDE_RIGHT AUDIO_CHANNEL_OUT_7POINT1POINT2 = 0xC063Fu, // OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT AUDIO_CHANNEL_OUT_7POINT1POINT4 = 0x2D63Fu, // OUT_7POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT AUDIO_CHANNEL_IN_LEFT = 0x4u, AUDIO_CHANNEL_IN_RIGHT = 0x8u, AUDIO_CHANNEL_IN_FRONT = 0x10u, AUDIO_CHANNEL_IN_BACK = 0x20u, AUDIO_CHANNEL_IN_LEFT_PROCESSED = 0x40u, AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80u, AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100u, AUDIO_CHANNEL_IN_BACK_PROCESSED = 0x200u, AUDIO_CHANNEL_IN_PRESSURE = 0x400u, AUDIO_CHANNEL_IN_X_AXIS = 0x800u, AUDIO_CHANNEL_IN_Y_AXIS = 0x1000u, AUDIO_CHANNEL_IN_Z_AXIS = 0x2000u, AUDIO_CHANNEL_IN_BACK_LEFT = 0x10000u, AUDIO_CHANNEL_IN_BACK_RIGHT = 0x20000u, AUDIO_CHANNEL_IN_CENTER = 0x40000u, AUDIO_CHANNEL_IN_LOW_FREQUENCY = 0x100000u, AUDIO_CHANNEL_IN_TOP_LEFT = 0x200000u, AUDIO_CHANNEL_IN_TOP_RIGHT = 0x400000u, AUDIO_CHANNEL_IN_VOICE_UPLINK = 0x4000u, AUDIO_CHANNEL_IN_VOICE_DNLINK = 0x8000u, AUDIO_CHANNEL_IN_MONO = 0x10u, // IN_FRONT AUDIO_CHANNEL_IN_STEREO = 0xCu, // IN_LEFT | IN_RIGHT AUDIO_CHANNEL_IN_FRONT_BACK = 0x30u, // IN_FRONT | IN_BACK AUDIO_CHANNEL_IN_6 = 0xFCu, // IN_LEFT | IN_RIGHT | IN_FRONT | IN_BACK | IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED AUDIO_CHANNEL_IN_2POINT0POINT2 = 0x60000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT AUDIO_CHANNEL_IN_2POINT1POINT2 = 0x70000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY AUDIO_CHANNEL_IN_3POINT0POINT2 = 0x64000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT AUDIO_CHANNEL_IN_3POINT1POINT2 = 0x74000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY AUDIO_CHANNEL_IN_5POINT1 = 0x17000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = 0x4010u, // IN_VOICE_UPLINK | IN_MONO AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = 0x8010u, // IN_VOICE_DNLINK | IN_MONO AUDIO_CHANNEL_IN_VOICE_CALL_MONO = 0xC010u, // IN_VOICE_UPLINK_MONO | IN_VOICE_DNLINK_MONO AUDIO_CHANNEL_COUNT_MAX = 30u, AUDIO_CHANNEL_INDEX_HDR = 0x80000000u, // REPRESENTATION_INDEX << COUNT_MAX AUDIO_CHANNEL_INDEX_MASK_1 = 0x80000001u, // INDEX_HDR | (1 << 1) - 1 AUDIO_CHANNEL_INDEX_MASK_2 = 0x80000003u, // INDEX_HDR | (1 << 2) - 1 AUDIO_CHANNEL_INDEX_MASK_3 = 0x80000007u, // INDEX_HDR | (1 << 3) - 1 AUDIO_CHANNEL_INDEX_MASK_4 = 0x8000000Fu, // INDEX_HDR | (1 << 4) - 1 AUDIO_CHANNEL_INDEX_MASK_5 = 0x8000001Fu, // INDEX_HDR | (1 << 5) - 1 AUDIO_CHANNEL_INDEX_MASK_6 = 0x8000003Fu, // INDEX_HDR | (1 << 6) - 1 AUDIO_CHANNEL_INDEX_MASK_7 = 0x8000007Fu, // INDEX_HDR | (1 << 7) - 1 AUDIO_CHANNEL_INDEX_MASK_8 = 0x800000FFu, // INDEX_HDR | (1 << 8) - 1 };
james34602/JamesDSPManager
Tutorials/src/essential.h
C
gpl-2.0
65,033
[ 30522, 21189, 12879, 2358, 6820, 6593, 3466, 1035, 1057, 21272, 1035, 1055, 1063, 21318, 3372, 16703, 1035, 1056, 2051, 8261, 1025, 21318, 3372, 16048, 1035, 1056, 2051, 4328, 2094, 1025, 21318, 3372, 16048, 1035, 1056, 2051, 14204, 2094, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using System.Collections.Generic; using Server.Items; namespace Server.Mobiles { public class SBWeaver: SBInfo { private List<GenericBuyInfo> m_BuyInfo = new InternalBuyInfo(); private IShopSellInfo m_SellInfo = new InternalSellInfo(); public SBWeaver() { } public override IShopSellInfo SellInfo { get { return m_SellInfo; } } public override List<GenericBuyInfo> BuyInfo { get { return m_BuyInfo; } } public class InternalBuyInfo : List<GenericBuyInfo> { public InternalBuyInfo() { Add( new GenericBuyInfo( typeof( Dyes ), 8, 20, 0xFA9, 0 ) ); Add( new GenericBuyInfo( typeof( DyeTub ), 8, 20, 0xFAB, 0 ) ); Add( new GenericBuyInfo( typeof( UncutCloth ), 3, 20, 0x1761, 0 ) ); Add( new GenericBuyInfo( typeof( UncutCloth ), 3, 20, 0x1762, 0 ) ); Add( new GenericBuyInfo( typeof( UncutCloth ), 3, 20, 0x1763, 0 ) ); Add( new GenericBuyInfo( typeof( UncutCloth ), 3, 20, 0x1764, 0 ) ); Add( new GenericBuyInfo( typeof( BoltOfCloth ), 100, 20, 0xf9B, 0 ) ); Add( new GenericBuyInfo( typeof( BoltOfCloth ), 100, 20, 0xf9C, 0 ) ); Add( new GenericBuyInfo( typeof( BoltOfCloth ), 100, 20, 0xf96, 0 ) ); Add( new GenericBuyInfo( typeof( BoltOfCloth ), 100, 20, 0xf97, 0 ) ); Add( new GenericBuyInfo( typeof( DarkYarn ), 18, 20, 0xE1D, 0 ) ); Add( new GenericBuyInfo( typeof( LightYarn ), 18, 20, 0xE1E, 0 ) ); Add( new GenericBuyInfo( typeof( LightYarnUnraveled ), 18, 20, 0xE1F, 0 ) ); Add( new GenericBuyInfo( typeof( Scissors ), 11, 20, 0xF9F, 0 ) ); } } public class InternalSellInfo : GenericSellInfo { public InternalSellInfo() { Add( typeof( Scissors ), 6 ); Add( typeof( Dyes ), 4 ); Add( typeof( DyeTub ), 4 ); Add( typeof( UncutCloth ), 1 ); Add( typeof( BoltOfCloth ), 50 ); Add( typeof( LightYarnUnraveled ), 9 ); Add( typeof( LightYarn ), 9 ); Add( typeof( DarkYarn ), 9 ); } } } }
ggobbe/hyel
Scripts/Mobiles/Vendors/SBInfo/SBWeaver.cs
C#
gpl-2.0
2,048
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 8241, 1012, 5167, 1025, 3415, 15327, 8241, 1012, 4684, 2015, 1063, 2270, 2465, 24829, 8545, 22208, 1024, 24829, 2378, 14876, 1063, 2797, 2862, 1026, 12391, 8569, 2581...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: ! 'PEACE HEROES: The Martyrs of the Mavi Marmara' joomla_id: 1219 joomla_url: peace-heroes-the-martyrs-of-the-mavi-marmara date: 2010-06-06 16:47:32.000000000 +02:00 --- <p align="center"><em>Martyr: a person who is put to death or endures great suffering on behalf of any belief, principle, or cause.</em></p> <p>By Cindy Sheehan</p> <p>The Free Gaza Movement’s purpose is to break the siege of Gaza and get needed humanitarian aid into that concentration camp on the Mediterranean Sea. I have seen many Israelis blatantly lie in interviews that there is “no humanitarian crisis in Gaza.”</p> <p>According to reputable NGO’s and other aid organizations: 4/5 of Gazans depend on outside humanitarian aid for survival; 70% are food insecure; there are less than 133 hospital beds for every 100,000 people (less than ¼ the capacity of Israel) with dozens of basic medicines unavailable; because of the profound lack of building materials, homes are being constructed from mud; power is severely limited and Gazans have been isolated from the entire world due to the enormous walls surrounding the region that contains 1.5 million people. Sounds like a humanitarian crisis to me—and indeed, to most people that aren’t easily fooled by Zionist propaganda.</p> <p>Collective Punishment is the punishment of an entire group of people as a result of the behavior of one or more other individuals or groups and is strictly banned by the Geneva Conventions. This is exactly what the State of Israel is doing to the people of Gaza—with near impunity. Punishing the entire region of Gaza for Hamas is like everyone else in the world getting together to build a wall around the USA and starve us to death because George Bush was “elected,” not once, but twice.</p> <p>The activists who sailed on the Freedom Flotilla that was brutally attacked by the IDF (Israel Defense Force) that resulted in the deaths of at least 9 people (several are still missing), were not terrorists or terrorist sympathizers—they are sympathetic with the plight of the people of Gaza and have been willing to face the wrath of a psychotically paranoid state to call attention to the blockade.</p> <p>So many people have died in the struggle for peace and justice all over the world. One of the boats in the flotilla was named after courageous Rachel Corrie, a young American-Jewish peace activist who sacrificed her own life to prevent Palestinian homes from being destroyed by the State of Israel with US made bulldozers. Now, a ship is named after Rachel, and her legacy to free Palestinians from the wrath of an illegal and immoral occupation is still alive.</p> <p>My own son, Casey, my hero, was also a victim of US Imperialism and arrogance. No matter how hard I struggle, I can’t bring him back, but I hope my efforts help to save other lives and Casey’s legacy lives through my efforts.</p> <p>What happened to the Martyrs of the Mavi Marmara is beyond tragic—it’s unthinkable and was a shocking act—even for the State of Israel, but it did happen. Nothing can change the fact that at least nine people are dead that should still be here with us today. What is, is. So what do we do about it now?</p> <p>The autopsy report on the nine confirmed deaths show that 30 bullets were taken from the nine bodies. That’s not self-defense, that’s targeted assassination. From such a negative event, a great positive has occurred—Israel, by this monstrous act, has shone its own spotlight on at least two things: 1) there is no end to its paranoia and its inappropriate and disproportionate reactions, and 2) its barbaric siege on Gaza.</p> <p>To honor the deaths of the Martyrs of the Mavi Marmara, we must never allow their deaths to be in vain. The Free Gaza and Free Palestine movements must continue to show the courage of the martyrs who were willing to sacrifice even to the “last full measure of devotion” to make the world a better place for the suffering peoples of Gaza.</p> <p>I stand in awe of such love and commitment as much I wish it wasn’t so, or didn’t have to be so.</p>
freegazaorg/freegazaorg.github.io
ninth-trip/_posts/2010-06-06-peace-heroes-the-martyrs-of-the-mavi-marmara.markdown
Markdown
gpl-2.0
4,188
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 999, 1005, 3521, 7348, 1024, 1996, 18945, 1997, 1996, 5003, 5737, 9388, 28225, 1005, 28576, 19968, 2050, 1035, 8909, 1024, 12606, 2683, 28576, 19968, 2050, 1035, 24471, 2140, 1024, 3521...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <ABI43_0_0React/ABI43_0_0renderer/components/root/RootShadowNode.h> #include <ABI43_0_0React/ABI43_0_0renderer/core/ConcreteComponentDescriptor.h> namespace ABI43_0_0facebook { namespace ABI43_0_0React { using RootComponentDescriptor = ConcreteComponentDescriptor<RootShadowNode>; } // namespace ABI43_0_0React } // namespace ABI43_0_0facebook
exponentjs/exponent
ios/versioned-react-native/ABI43_0_0/ReactNative/ReactCommon/react/renderer/components/root/ABI43_0_0RootComponentDescriptor.h
C
bsd-3-clause
559
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 9130, 1010, 4297, 1012, 1998, 2049, 18460, 1012, 1008, 1008, 2023, 3120, 3642, 2003, 7000, 2104, 1996, 10210, 6105, 2179, 1999, 1996, 1008, 6105, 5371, 1999, 1996, 7117, 14176, 1997, 2023, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
GPG Suite 2015.09 ================= September 24th, 2015 GPGMail 2.6b2 ------------- ### Pre-release version info * This beta will be disabled, once the next stable version of GPGMail is released. If you want to continue using GPGMail after that, you will have to acquire a valid license. ### Adds support for OS X 10.11 El Capitan * GPGMail has been updated to support the latest OS from Apple. Enjoy! ### Bugfixes * Greatly improves reliability * Fixes the appearance of the security indicator to look better as a toolbar item * Properly displays error messages when a gpg operation fails as the user attemtps to send a message. * The signature detail view is now properly displayed again. * Fixes an issue where the sign and encrypt status were not properly saved in the draft and hence couldn't be properly restored when continuing editing a draft. GPGMail 2.5.2 ------------- ### Smooth upgrade to El Capitan * Instead of seeing the "incompatible Bundle"-message, when you launch Mail with GPGMail installed after upgrading to El Capitan, you will have the option to install our newest beta for El Capitan or disable GPGMail ### Bugfixes * GPGMail handles binary pgp messages as expected again. The regression was introduced in GPG Suite 2015.08. [#843] * Adds better support for variants of inline PGP in HTML messages. Libmacgpg 0.6.1 --------------- ### Bugfixes * The most common crash in GPG suite 2015.08 was a crash in Libmacgpg when parsing PGP messages. [#150]
GPGTools/GPGTools_Installer
Release Notes/2015.09.md
Markdown
gpl-3.0
1,492
[ 30522, 14246, 2290, 7621, 2325, 1012, 5641, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 30524, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1001, 1001, 1001, 3653, 1011, 2713, 2544, 18558, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
real = complex(1, 1).real imag = complex(1, 1).imag print(real, imag)
balarsen/Scrabble
scrabble/test.py
Python
bsd-3-clause
72
[ 30522, 2613, 1027, 3375, 1006, 1015, 1010, 1015, 1007, 1012, 2613, 10047, 8490, 1027, 3375, 1006, 1015, 1010, 1015, 1007, 1012, 10047, 8490, 6140, 1006, 2613, 1010, 10047, 8490, 1007, 102, 0, 0, 0, 0, 30524, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // This source file is part of appleseed. // Visit https://appleseedhq.net/ for additional information and resources. // // This software is released under the MIT license. // // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization // // 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 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. // // appleseed.foundation headers. #include "foundation/core/concepts/noncopyable.h" #include "foundation/math/aabb.h" #include "foundation/math/bsp.h" #include "foundation/math/intersection/rayaabb.h" #include "foundation/math/ray.h" #include "foundation/math/split.h" #include "foundation/math/vector.h" #include "foundation/utility/test.h" // Standard headers. #include <algorithm> #include <cstddef> #include <limits> #include <memory> #include <utility> #include <vector> using namespace foundation; using namespace std; TEST_SUITE(Foundation_Math_BSP_Node) { typedef bsp::Node<double> NodeType; TEST_CASE(TestLeafNode) { NodeType node; node.make_leaf(); EXPECT_TRUE(node.is_leaf()); node.set_leaf_index(42); EXPECT_TRUE(node.is_leaf()); EXPECT_EQ(42, node.get_leaf_index()); const size_t LeafIndex = (size_t(1) << 31) - 1; node.set_leaf_index(LeafIndex); EXPECT_TRUE(node.is_leaf()); EXPECT_EQ(LeafIndex, node.get_leaf_index()); node.set_leaf_size(33); EXPECT_TRUE(node.is_leaf()); EXPECT_EQ(LeafIndex, node.get_leaf_index()); } TEST_CASE(TestInteriorNode) { NodeType node; node.make_interior(); EXPECT_TRUE(node.is_interior()); node.set_child_node_index(42); EXPECT_TRUE(node.is_interior()); EXPECT_EQ(42, node.get_child_node_index()); const size_t ChildIndex = (size_t(1) << 29) - 1; node.set_child_node_index(ChildIndex); EXPECT_TRUE(node.is_interior()); EXPECT_EQ(ChildIndex, node.get_child_node_index()); node.set_split_dim(1); EXPECT_TRUE(node.is_interior()); EXPECT_EQ(ChildIndex, node.get_child_node_index()); EXPECT_EQ(1, node.get_split_dim()); node.set_split_abs(66.0); EXPECT_TRUE(node.is_interior()); EXPECT_EQ(ChildIndex, node.get_child_node_index()); EXPECT_EQ(1, node.get_split_dim()); EXPECT_EQ(66.0, node.get_split_abs()); } } TEST_SUITE(Foundation_Math_BSP_Intersector) { class Leaf : public NonCopyable { public: void clear() { m_boxes.clear(); } size_t get_size() const { return m_boxes.size(); } void insert(const AABB3d& box) { m_boxes.push_back(box); } const AABB3d& get_box(const size_t i) const { return m_boxes[i]; } AABB3d get_bbox() const { AABB3d bbox; bbox.invalidate(); for (size_t i = 0; i < m_boxes.size(); ++i) bbox.insert(m_boxes[i]); return bbox; } size_t get_memory_size() const { return 0; } private: vector<AABB3d> m_boxes; }; struct LeafFactory : public NonCopyable { Leaf* create_leaf() { return new Leaf(); } }; struct LeafSplitter : public NonCopyable { typedef bsp::LeafInfo<double, 3> LeafInfoType; typedef Split<double> SplitType; bool m_first_leaf; LeafSplitter() : m_first_leaf(true) { } double get_priority( const Leaf& leaf, const LeafInfoType& leaf_info) { const double priority = m_first_leaf ? 1.0 : 0.0; m_first_leaf = false; return priority; } bool split( const Leaf& leaf, const LeafInfoType& leaf_info, SplitType& split) { split.m_dimension = 0; split.m_abscissa = 0.0; return true; } void sort( const Leaf& leaf, const LeafInfoType& leaf_info, const SplitType& split, Leaf& left_leaf, const LeafInfoType& left_leaf_info, Leaf& right_leaf, const LeafInfoType& right_leaf_info) { for (size_t i = 0; i < leaf.get_size(); ++i) { const AABB3d& box = leaf.get_box(i); if (box.max[split.m_dimension] <= split.m_abscissa) { left_leaf.insert(box); } else if (box.min[split.m_dimension] >= split.m_abscissa) { right_leaf.insert(box); } else { left_leaf.insert(box); right_leaf.insert(box); } } } }; class LeafVisitor : public NonCopyable { public: LeafVisitor() : m_visited_leaf_count(0) , m_closest_hit(numeric_limits<double>::max()) { } double visit( const Leaf* leaf, // todo: why not a reference? const Ray3d& ray, const RayInfo3d& ray_info) { ++m_visited_leaf_count; for (size_t i = 0; i < leaf->get_size(); ++i) { const AABB3d& box = leaf->get_box(i); double distance; if (intersect(ray, ray_info, box, distance)) m_closest_hit = min(m_closest_hit, distance); } return m_closest_hit; } size_t get_visited_leaf_count() const { return m_visited_leaf_count; } double get_closest_hit() const { return m_closest_hit; } private: size_t m_visited_leaf_count; double m_closest_hit; }; struct Fixture { typedef bsp::Tree<double, 3, Leaf> Tree; typedef bsp::Intersector<double, Tree, LeafVisitor, Ray3d> Intersector; Tree m_tree; LeafVisitor m_leaf_visitor; // todo: Visitor or LeafVisitor? Intersector m_intersector; bsp::TraversalStatistics m_traversal_stats; Fixture() { unique_ptr<Leaf> root_leaf(new Leaf()); root_leaf->insert(AABB3d(Vector3d(-1.0, -0.5, -0.2), Vector3d(0.0, 0.5, 0.2))); root_leaf->insert(AABB3d(Vector3d(0.0, -0.5, -0.7), Vector3d(1.0, 0.5, 0.7))); bsp::Builder<Tree, LeafFactory, LeafSplitter> builder; LeafFactory leaf_factory; LeafSplitter leaf_splitter; builder.build(m_tree, move(root_leaf), leaf_factory, leaf_splitter); } }; #ifdef FOUNDATION_BSP_ENABLE_TRAVERSAL_STATS #define TRAVERSAL_STATISTICS , m_traversal_stats #else #define TRAVERSAL_STATISTICS #endif #pragma warning (push) #pragma warning (disable : 4723) // potential division by 0 TEST_CASE_F(Intersect_GivenRayEmbeddedInSplitPlane_VisitsBothLeaves, Fixture) { Ray3d ray(Vector3d(0.0, 0.0, 1.0), Vector3d(0.0, 0.0, -1.0)); m_intersector.intersect(m_tree, ray, RayInfo3d(ray), m_leaf_visitor TRAVERSAL_STATISTICS); EXPECT_EQ(2, m_leaf_visitor.get_visited_leaf_count()); EXPECT_FEQ(1.0 - 0.7, m_leaf_visitor.get_closest_hit()); } TEST_CASE_F(Intersect_GivenRayPiercingLeftNode_VisitsLeftNode, Fixture) { Ray3d ray(Vector3d(-0.5, 0.0, 1.0), Vector3d(0.0, 0.0, -1.0)); m_intersector.intersect(m_tree, ray, RayInfo3d(ray), m_leaf_visitor TRAVERSAL_STATISTICS); EXPECT_EQ(1, m_leaf_visitor.get_visited_leaf_count()); EXPECT_FEQ(1.0 - 0.2, m_leaf_visitor.get_closest_hit()); } TEST_CASE_F(Intersect_GivenRayPiercingRightNode_VisitsRightNode, Fixture) { Ray3d ray(Vector3d(0.5, 0.0, 1.0), Vector3d(0.0, 0.0, -1.0)); m_intersector.intersect(m_tree, ray, RayInfo3d(ray), m_leaf_visitor TRAVERSAL_STATISTICS); EXPECT_EQ(1, m_leaf_visitor.get_visited_leaf_count()); EXPECT_FEQ(1.0 - 0.7, m_leaf_visitor.get_closest_hit()); } #pragma warning (pop) #undef TRAVERSAL_STATISTICS }
Biart95/appleseed
src/appleseed/foundation/meta/tests/test_bsp.cpp
C++
mit
9,612
[ 30522, 1013, 1013, 1013, 1013, 2023, 3120, 5371, 2003, 2112, 1997, 18108, 13089, 1012, 1013, 1013, 3942, 16770, 1024, 1013, 1013, 18108, 13089, 2232, 4160, 1012, 5658, 1013, 2005, 3176, 2592, 1998, 4219, 1012, 1013, 1013, 1013, 1013, 2023, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * @package Joomla.Installation * @subpackage Controller * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Controller class to initialise the database for the Joomla Installer. * * @package Joomla.Installation * @subpackage Controller * @since 3.1 */ class InstallationControllerInstallDatabase extends JControllerBase { /** * Execute the controller. * * @return void * * @since 3.1 */ public function execute() { // Get the application /* @var InstallationApplicationWeb $app */ $app = $this->getApplication(); // Check for request forgeries. JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Get the setup model. $model = new InstallationModelSetup; // Get the options from the session $options = $model->getOptions(); // Get the database model. $db = new InstallationModelDatabase; // Attempt to create the database tables. $return = $db->createTables($options); $r = new stdClass; $r->view = 'install'; // Check if the database was initialised if (!$return) { $r->view = 'database'; } $app->sendJsonResponse($r); } }
hkhateeb/esshar
installationxxxx/controller/install/database.php
PHP
gpl-2.0
1,334
[ 30522, 1026, 1029, 25718, 30524, 6105, 2544, 1016, 2030, 2101, 1025, 2156, 6105, 1012, 19067, 2102, 1008, 1013, 4225, 1006, 1005, 1035, 15333, 2595, 8586, 1005, 1007, 2030, 3280, 1025, 1013, 1008, 1008, 1008, 11486, 2465, 2000, 3988, 5562, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * QueueSamplerMXBean.java - MXBean interface describing the management * operations and attributes for the QueueSampler MXBean. In this case * there is a read-only attribute "QueueSample" and an operation "clearQueue". */ package com.jmx.example; public interface QueueSamplerMXBean { public QueueSample getQueueSample(); public void clearQueue(); }
niteshbisht/alg_dynamix
javabase/src/main/java/com/jmx/example/QueueSamplerMXBean.java
Java
mit
367
[ 30522, 1013, 1008, 1008, 24240, 21559, 10814, 10867, 2595, 4783, 2319, 1012, 9262, 1011, 25630, 4783, 2319, 8278, 7851, 1996, 2968, 1008, 3136, 1998, 12332, 2005, 1996, 24240, 21559, 10814, 2099, 25630, 4783, 2319, 1012, 1999, 2023, 2553, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/eks/model/DeregisterClusterRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::EKS::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; DeregisterClusterRequest::DeregisterClusterRequest() : m_nameHasBeenSet(false) { } Aws::String DeregisterClusterRequest::SerializePayload() const { return {}; }
awslabs/aws-sdk-cpp
aws-cpp-sdk-eks/source/model/DeregisterClusterRequest.cpp
C++
apache-2.0
512
[ 30522, 1013, 1008, 1008, 1008, 9385, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 15895, 1011, 1016, 1012, 1014, 1012, 1008, 1013, 1001, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html lang="en"> <head> <title>C - Debugging with GDB</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Debugging with GDB"> <meta name="generator" content="makeinfo 4.8"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Supported-Languages.html#Supported-Languages" title="Supported Languages"> <link rel="next" href="D.html#D" title="D"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Free Software'' and ``Free Software Needs Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom.'' --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <p> <a name="C"></a> Next:&nbsp;<a rel="next" accesskey="n" href="D.html#D">D</a>, Up:&nbsp;<a rel="up" accesskey="u" href="Supported-Languages.html#Supported-Languages">Supported Languages</a> <hr> </div> <h4 class="subsection">15.4.1 C and C<tt>++</tt></h4> <p><a name="index-C-and-C_0040t_007b_002b_002b_007d-947"></a><a name="index-expressions-in-C-or-C_0040t_007b_002b_002b_007d-948"></a> Since C and C<tt>++</tt> are so closely related, many features of <span class="sc">gdb</span> apply to both languages. Whenever this is the case, we discuss those languages together. <p><a name="index-C_0040t_007b_002b_002b_007d-949"></a><a name="index-g_t_0040code_007bg_002b_002b_007d_002c-_0040sc_007bgnu_007d-C_0040t_007b_002b_002b_007d-compiler-950"></a><a name="index-g_t_0040sc_007bgnu_007d-C_0040t_007b_002b_002b_007d-951"></a>The C<tt>++</tt> debugging facilities are jointly implemented by the C<tt>++</tt> compiler and <span class="sc">gdb</span>. Therefore, to debug your C<tt>++</tt> code effectively, you must compile your C<tt>++</tt> programs with a supported C<tt>++</tt> compiler, such as <span class="sc">gnu</span> <code>g++</code>, or the HP ANSI C<tt>++</tt> compiler (<code>aCC</code>). <ul class="menu"> <li><a accesskey="1" href="C-Operators.html#C-Operators">C Operators</a>: C and C<tt>++</tt> operators <li><a accesskey="2" href="C-Constants.html#C-Constants">C Constants</a>: C and C<tt>++</tt> constants <li><a accesskey="3" href="C-Plus-Plus-Expressions.html#C-Plus-Plus-Expressions">C Plus Plus Expressions</a>: C<tt>++</tt> expressions <li><a accesskey="4" href="C-Defaults.html#C-Defaults">C Defaults</a>: Default settings for C and C<tt>++</tt> <li><a accesskey="5" href="C-Checks.html#C-Checks">C Checks</a>: C and C<tt>++</tt> type and range checks <li><a accesskey="6" href="Debugging-C.html#Debugging-C">Debugging C</a>: <span class="sc">gdb</span> and C <li><a accesskey="7" href="Debugging-C-Plus-Plus.html#Debugging-C-Plus-Plus">Debugging C Plus Plus</a>: <span class="sc">gdb</span> features for C<tt>++</tt> <li><a accesskey="8" href="Decimal-Floating-Point.html#Decimal-Floating-Point">Decimal Floating Point</a>: Numbers in Decimal Floating Point format </ul> </body></html>
ChangsoonKim/STM32F7DiscTutor
toolchain/osx/gcc-arm-none-eabi-6-2017-q1-update/share/doc/gcc-arm-none-eabi/html/gdb/C.html
HTML
mit
4,070
[ 30522, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 1039, 1011, 2139, 8569, 12588, 2007, 1043, 18939, 1026, 1013, 2516, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Code Size 规则 ## Too Many Parameters <dl> <dt>标识名</dt> <dd>too_many_parameters</dd> <dt>文件名</dt> <dd>TooManyParametersRule.swift</dd> <dt>严重级别</dt> <dd>Minor</dd> <dt>分类</dt> <dd>Code Size</dd> </dl> Methods with too many parameters are hard to understand and maintain, and are thirsty for refactorings, like [Replace Parameter With Method](http://www.refactoring.com/catalog/replaceParameterWithMethod.html), [Introduce Parameter Object](http://www.refactoring.com/catalog/introduceParameterObject.html), or [Preserve Whole Object](http://www.refactoring.com/catalog/preserveWholeObject.html). ##### Thresholds: <dl> <dt>MAX_PARAMETERS_COUNT</dt> <dd>The reporting threshold for too many parameters, default value is 10.</dd> </dl> ##### Examples: ###### Example 1 ``` func example( a: Int, b: Int, c: Int, ... z: Int ) {} ``` ##### References: Fowler, Martin (1999). *Refactoring: Improving the design of existing code.* Addison Wesley. ## Long Line <dl> <dt>标识名</dt> <dd>long_line</dd> <dt>文件名</dt> <dd>LongLineRule.swift</dd> <dt>严重级别</dt> <dd>Minor</dd> <dt>分类</dt> <dd>Code Size</dd> </dl> When a line of code is very long, it largely harms the readability. Break long lines of code into multiple lines. ##### Thresholds: <dl> <dt>LONG_LINE</dt> <dd>The long line reporting threshold, default value is 100.</dd> </dl> ##### Examples: ###### Example 1 ``` let a012345678901234567890123456789...1234567890123456789012345678901234567890123456789 ```
yanagiba/swift-lint
Documentation/Rules/CodeSize_CN.md
Markdown
apache-2.0
1,535
[ 30522, 1001, 3642, 2946, 100, 100, 1001, 1001, 2205, 2116, 11709, 1026, 21469, 1028, 1026, 26718, 1028, 100, 100, 1795, 1026, 1013, 26718, 1028, 1026, 20315, 1028, 2205, 1035, 2116, 1035, 11709, 1026, 1013, 20315, 1028, 1026, 26718, 1028, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Hibbert is a very simple power monitor, which (at the moment) supports Linux. It has no dependencies aside from a Linux system with the /sys/class/power_supply interface. Hibbert periodically checks the battery status, and if the battery is below a certain percentage (default: 5) and not charging, then it tries to execute ~/.hibbertt as a shell script, or /etc/hibbertt should ~/.hibbertt not exist. Shibbert is also built, which is just a simpler hibbert which doesn't act as a daemon and is just meant to be run from cron if that's more your thing. Tips: You can have more than one entry for a user/group in sudoers, if you define things like pm-hibernate as NOPASSWD for yourself then you can hibernate or suspend as your trigger. There may also be a way to do this from logind or something.
tekkenfreak3/Hibbert
README.md
Markdown
isc
798
[ 30522, 7632, 29325, 2102, 2003, 1037, 2200, 3722, 2373, 8080, 1010, 2029, 1006, 2012, 1996, 2617, 1007, 6753, 11603, 1012, 2009, 30524, 1006, 12398, 1024, 1019, 1007, 1998, 2025, 13003, 1010, 2059, 2009, 5363, 2000, 15389, 1066, 1013, 1012,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* -*- mode: c; c-basic-offset: 8; -*- * vim: noexpandtab sw=8 ts=8 sts=0: * * Copyright (C) 2002, 2004 Oracle. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 021110-1307, USA. */ #include <linux/fs.h> #include <linux/slab.h> #include <linux/highmem.h> #include <linux/pagemap.h> #include <asm/byteorder.h> #include <linux/swap.h> #include <linux/pipe_fs_i.h> #include <linux/mpage.h> #include <linux/quotaops.h> #include <linux/blkdev.h> #include <linux/uio.h> #include <cluster/masklog.h> #include "ocfs2.h" #include "alloc.h" #include "aops.h" #include "dlmglue.h" #include "extent_map.h" #include "file.h" #include "inode.h" #include "journal.h" #include "suballoc.h" #include "super.h" #include "symlink.h" #include "refcounttree.h" #include "ocfs2_trace.h" #include "buffer_head_io.h" #include "dir.h" #include "namei.h" #include "sysfile.h" static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { int err = -EIO; int status; struct ocfs2_dinode *fe = NULL; struct buffer_head *bh = NULL; struct buffer_head *buffer_cache_bh = NULL; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); void *kaddr; trace_ocfs2_symlink_get_block( (unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)iblock, bh_result, create); BUG_ON(ocfs2_inode_is_fast_symlink(inode)); if ((iblock << inode->i_sb->s_blocksize_bits) > PATH_MAX + 1) { mlog(ML_ERROR, "block offset > PATH_MAX: %llu", (unsigned long long)iblock); goto bail; } status = ocfs2_read_inode_block(inode, &bh); if (status < 0) { mlog_errno(status); goto bail; } fe = (struct ocfs2_dinode *) bh->b_data; if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb, le32_to_cpu(fe->i_clusters))) { err = -ENOMEM; mlog(ML_ERROR, "block offset is outside the allocated size: " "%llu\n", (unsigned long long)iblock); goto bail; } /* We don't use the page cache to create symlink data, so if * need be, copy it over from the buffer cache. */ if (!buffer_uptodate(bh_result) && ocfs2_inode_is_new(inode)) { u64 blkno = le64_to_cpu(fe->id2.i_list.l_recs[0].e_blkno) + iblock; buffer_cache_bh = sb_getblk(osb->sb, blkno); if (!buffer_cache_bh) { err = -ENOMEM; mlog(ML_ERROR, "couldn't getblock for symlink!\n"); goto bail; } /* we haven't locked out transactions, so a commit * could've happened. Since we've got a reference on * the bh, even if it commits while we're doing the * copy, the data is still good. */ if (buffer_jbd(buffer_cache_bh) && ocfs2_inode_is_new(inode)) { kaddr = kmap_atomic(bh_result->b_page); if (!kaddr) { mlog(ML_ERROR, "couldn't kmap!\n"); goto bail; } memcpy(kaddr + (bh_result->b_size * iblock), buffer_cache_bh->b_data, bh_result->b_size); kunmap_atomic(kaddr); set_buffer_uptodate(bh_result); } brelse(buffer_cache_bh); } map_bh(bh_result, inode->i_sb, le64_to_cpu(fe->id2.i_list.l_recs[0].e_blkno) + iblock); err = 0; bail: brelse(bh); return err; } int ocfs2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { int err = 0; unsigned int ext_flags; u64 max_blocks = bh_result->b_size >> inode->i_blkbits; u64 p_blkno, count, past_eof; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); trace_ocfs2_get_block((unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)iblock, bh_result, create); if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) mlog(ML_NOTICE, "get_block on system inode 0x%p (%lu)\n", inode, inode->i_ino); if (S_ISLNK(inode->i_mode)) { /* this always does I/O for some reason. */ err = ocfs2_symlink_get_block(inode, iblock, bh_result, create); goto bail; } err = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno, &count, &ext_flags); if (err) { mlog(ML_ERROR, "Error %d from get_blocks(0x%p, %llu, 1, " "%llu, NULL)\n", err, inode, (unsigned long long)iblock, (unsigned long long)p_blkno); goto bail; } if (max_blocks < count) count = max_blocks; /* * ocfs2 never allocates in this function - the only time we * need to use BH_New is when we're extending i_size on a file * system which doesn't support holes, in which case BH_New * allows __block_write_begin() to zero. * * If we see this on a sparse file system, then a truncate has * raced us and removed the cluster. In this case, we clear * the buffers dirty and uptodate bits and let the buffer code * ignore it as a hole. */ if (create && p_blkno == 0 && ocfs2_sparse_alloc(osb)) { clear_buffer_dirty(bh_result); clear_buffer_uptodate(bh_result); goto bail; } /* Treat the unwritten extent as a hole for zeroing purposes. */ if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) map_bh(bh_result, inode->i_sb, p_blkno); bh_result->b_size = count << inode->i_blkbits; if (!ocfs2_sparse_alloc(osb)) { if (p_blkno == 0) { err = -EIO; mlog(ML_ERROR, "iblock = %llu p_blkno = %llu blkno=(%llu)\n", (unsigned long long)iblock, (unsigned long long)p_blkno, (unsigned long long)OCFS2_I(inode)->ip_blkno); mlog(ML_ERROR, "Size %llu, clusters %u\n", (unsigned long long)i_size_read(inode), OCFS2_I(inode)->ip_clusters); dump_stack(); goto bail; } } past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); trace_ocfs2_get_block_end((unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)past_eof); if (create && (iblock >= past_eof)) set_buffer_new(bh_result); bail: if (err < 0) err = -EIO; return err; } int ocfs2_read_inline_data(struct inode *inode, struct page *page, struct buffer_head *di_bh) { void *kaddr; loff_t size; struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; if (!(le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL)) { ocfs2_error(inode->i_sb, "Inode %llu lost inline data flag\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); return -EROFS; } size = i_size_read(inode); if (size > PAGE_SIZE || size > ocfs2_max_inline_data_with_xattr(inode->i_sb, di)) { ocfs2_error(inode->i_sb, "Inode %llu has with inline data has bad size: %Lu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)size); return -EROFS; } kaddr = kmap_atomic(page); if (size) memcpy(kaddr, di->id2.i_data.id_data, size); /* Clear the remaining part of the page */ memset(kaddr + size, 0, PAGE_SIZE - size); flush_dcache_page(page); kunmap_atomic(kaddr); SetPageUptodate(page); return 0; } static int ocfs2_readpage_inline(struct inode *inode, struct page *page) { int ret; struct buffer_head *di_bh = NULL; BUG_ON(!PageLocked(page)); BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)); ret = ocfs2_read_inode_block(inode, &di_bh); if (ret) { mlog_errno(ret); goto out; } ret = ocfs2_read_inline_data(inode, page, di_bh); out: unlock_page(page); brelse(di_bh); return ret; } static int ocfs2_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; struct ocfs2_inode_info *oi = OCFS2_I(inode); loff_t start = (loff_t)page->index << PAGE_SHIFT; int ret, unlock = 1; trace_ocfs2_readpage((unsigned long long)oi->ip_blkno, (page ? page->index : 0)); ret = ocfs2_inode_lock_with_page(inode, NULL, 0, page); if (ret != 0) { if (ret == AOP_TRUNCATED_PAGE) unlock = 0; mlog_errno(ret); goto out; } if (down_read_trylock(&oi->ip_alloc_sem) == 0) { /* * Unlock the page and cycle ip_alloc_sem so that we don't * busyloop waiting for ip_alloc_sem to unlock */ ret = AOP_TRUNCATED_PAGE; unlock_page(page); unlock = 0; down_read(&oi->ip_alloc_sem); up_read(&oi->ip_alloc_sem); goto out_inode_unlock; } /* * i_size might have just been updated as we grabed the meta lock. We * might now be discovering a truncate that hit on another node. * block_read_full_page->get_block freaks out if it is asked to read * beyond the end of a file, so we check here. Callers * (generic_file_read, vm_ops->fault) are clever enough to check i_size * and notice that the page they just read isn't needed. * * XXX sys_readahead() seems to get that wrong? */ if (start >= i_size_read(inode)) { zero_user(page, 0, PAGE_SIZE); SetPageUptodate(page); ret = 0; goto out_alloc; } if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) ret = ocfs2_readpage_inline(inode, page); else ret = block_read_full_page(page, ocfs2_get_block); unlock = 0; out_alloc: up_read(&OCFS2_I(inode)->ip_alloc_sem); out_inode_unlock: ocfs2_inode_unlock(inode, 0); out: if (unlock) unlock_page(page); return ret; } /* * This is used only for read-ahead. Failures or difficult to handle * situations are safe to ignore. * * Right now, we don't bother with BH_Boundary - in-inode extent lists * are quite large (243 extents on 4k blocks), so most inodes don't * grow out to a tree. If need be, detecting boundary extents could * trivially be added in a future version of ocfs2_get_block(). */ static int ocfs2_readpages(struct file *filp, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { int ret, err = -EIO; struct inode *inode = mapping->host; struct ocfs2_inode_info *oi = OCFS2_I(inode); loff_t start; struct page *last; /* * Use the nonblocking flag for the dlm code to avoid page * lock inversion, but don't bother with retrying. */ ret = ocfs2_inode_lock_full(inode, NULL, 0, OCFS2_LOCK_NONBLOCK); if (ret) return err; if (down_read_trylock(&oi->ip_alloc_sem) == 0) { ocfs2_inode_unlock(inode, 0); return err; } /* * Don't bother with inline-data. There isn't anything * to read-ahead in that case anyway... */ if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) goto out_unlock; /* * Check whether a remote node truncated this file - we just * drop out in that case as it's not worth handling here. */ last = list_entry(pages->prev, struct page, lru); start = (loff_t)last->index << PAGE_SHIFT; if (start >= i_size_read(inode)) goto out_unlock; err = mpage_readpages(mapping, pages, nr_pages, ocfs2_get_block); out_unlock: up_read(&oi->ip_alloc_sem); ocfs2_inode_unlock(inode, 0); return err; } /* Note: Because we don't support holes, our allocation has * already happened (allocation writes zeros to the file data) * so we don't have to worry about ordered writes in * ocfs2_writepage. * * ->writepage is called during the process of invalidating the page cache * during blocked lock processing. It can't block on any cluster locks * to during block mapping. It's relying on the fact that the block * mapping can't have disappeared under the dirty pages that it is * being asked to write back. */ static int ocfs2_writepage(struct page *page, struct writeback_control *wbc) { trace_ocfs2_writepage( (unsigned long long)OCFS2_I(page->mapping->host)->ip_blkno, page->index); return block_write_full_page(page, ocfs2_get_block, wbc); } /* Taken from ext3. We don't necessarily need the full blown * functionality yet, but IMHO it's better to cut and paste the whole * thing so we can avoid introducing our own bugs (and easily pick up * their fixes when they happen) --Mark */ int walk_page_buffers( handle_t *handle, struct buffer_head *head, unsigned from, unsigned to, int *partial, int (*fn)( handle_t *handle, struct buffer_head *bh)) { struct buffer_head *bh; unsigned block_start, block_end; unsigned blocksize = head->b_size; int err, ret = 0; struct buffer_head *next; for ( bh = head, block_start = 0; ret == 0 && (bh != head || !block_start); block_start = block_end, bh = next) { next = bh->b_this_page; block_end = block_start + blocksize; if (block_end <= from || block_start >= to) { if (partial && !buffer_uptodate(bh)) *partial = 1; continue; } err = (*fn)(handle, bh); if (!ret) ret = err; } return ret; } static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) { sector_t status; u64 p_blkno = 0; int err = 0; struct inode *inode = mapping->host; trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)block); /* We don't need to lock journal system files, since they aren't * accessed concurrently from multiple nodes. */ if (!INODE_JOURNAL(inode)) { err = ocfs2_inode_lock(inode, NULL, 0); if (err) { if (err != -ENOENT) mlog_errno(err); goto bail; } down_read(&OCFS2_I(inode)->ip_alloc_sem); } if (!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) err = ocfs2_extent_map_get_blocks(inode, block, &p_blkno, NULL, NULL); if (!INODE_JOURNAL(inode)) { up_read(&OCFS2_I(inode)->ip_alloc_sem); ocfs2_inode_unlock(inode, 0); } if (err) { mlog(ML_ERROR, "get_blocks() failed, block = %llu\n", (unsigned long long)block); mlog_errno(err); goto bail; } bail: status = err ? 0 : p_blkno; return status; } static int ocfs2_releasepage(struct page *page, gfp_t wait) { if (!page_has_buffers(page)) return 0; return try_to_free_buffers(page); } static void ocfs2_figure_cluster_boundaries(struct ocfs2_super *osb, u32 cpos, unsigned int *start, unsigned int *end) { unsigned int cluster_start = 0, cluster_end = PAGE_SIZE; if (unlikely(PAGE_SHIFT > osb->s_clustersize_bits)) { unsigned int cpp; cpp = 1 << (PAGE_SHIFT - osb->s_clustersize_bits); cluster_start = cpos % cpp; cluster_start = cluster_start << osb->s_clustersize_bits; cluster_end = cluster_start + osb->s_clustersize; } BUG_ON(cluster_start > PAGE_SIZE); BUG_ON(cluster_end > PAGE_SIZE); if (start) *start = cluster_start; if (end) *end = cluster_end; } /* * 'from' and 'to' are the region in the page to avoid zeroing. * * If pagesize > clustersize, this function will avoid zeroing outside * of the cluster boundary. * * from == to == 0 is code for "zero the entire cluster region" */ static void ocfs2_clear_page_regions(struct page *page, struct ocfs2_super *osb, u32 cpos, unsigned from, unsigned to) { void *kaddr; unsigned int cluster_start, cluster_end; ocfs2_figure_cluster_boundaries(osb, cpos, &cluster_start, &cluster_end); kaddr = kmap_atomic(page); if (from || to) { if (from > cluster_start) memset(kaddr + cluster_start, 0, from - cluster_start); if (to < cluster_end) memset(kaddr + to, 0, cluster_end - to); } else { memset(kaddr + cluster_start, 0, cluster_end - cluster_start); } kunmap_atomic(kaddr); } /* * Nonsparse file systems fully allocate before we get to the write * code. This prevents ocfs2_write() from tagging the write as an * allocating one, which means ocfs2_map_page_blocks() might try to * read-in the blocks at the tail of our file. Avoid reading them by * testing i_size against each block offset. */ static int ocfs2_should_read_blk(struct inode *inode, struct page *page, unsigned int block_start) { u64 offset = page_offset(page) + block_start; if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) return 1; if (i_size_read(inode) > offset) return 1; return 0; } /* * Some of this taken from __block_write_begin(). We already have our * mapping by now though, and the entire write will be allocating or * it won't, so not much need to use BH_New. * * This will also skip zeroing, which is handled externally. */ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, struct inode *inode, unsigned int from, unsigned int to, int new) { int ret = 0; struct buffer_head *head, *bh, *wait[2], **wait_bh = wait; unsigned int block_end, block_start; unsigned int bsize = 1 << inode->i_blkbits; if (!page_has_buffers(page)) create_empty_buffers(page, bsize, 0); head = page_buffers(page); for (bh = head, block_start = 0; bh != head || !block_start; bh = bh->b_this_page, block_start += bsize) { block_end = block_start + bsize; clear_buffer_new(bh); /* * Ignore blocks outside of our i/o range - * they may belong to unallocated clusters. */ if (block_start >= to || block_end <= from) { if (PageUptodate(page)) set_buffer_uptodate(bh); continue; } /* * For an allocating write with cluster size >= page * size, we always write the entire page. */ if (new) set_buffer_new(bh); if (!buffer_mapped(bh)) { map_bh(bh, inode->i_sb, *p_blkno); unmap_underlying_metadata(bh->b_bdev, bh->b_blocknr); } if (PageUptodate(page)) { if (!buffer_uptodate(bh)) set_buffer_uptodate(bh); } else if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_new(bh) && ocfs2_should_read_blk(inode, page, block_start) && (block_start < from || block_end > to)) { ll_rw_block(REQ_OP_READ, 0, 1, &bh); *wait_bh++=bh; } *p_blkno = *p_blkno + 1; } /* * If we issued read requests - let them complete. */ while(wait_bh > wait) { wait_on_buffer(*--wait_bh); if (!buffer_uptodate(*wait_bh)) ret = -EIO; } if (ret == 0 || !new) return ret; /* * If we get -EIO above, zero out any newly allocated blocks * to avoid exposing stale data. */ bh = head; block_start = 0; do { block_end = block_start + bsize; if (block_end <= from) goto next_bh; if (block_start >= to) break; zero_user(page, block_start, bh->b_size); set_buffer_uptodate(bh); mark_buffer_dirty(bh); next_bh: block_start = block_end; bh = bh->b_this_page; } while (bh != head); return ret; } #if (PAGE_SIZE >= OCFS2_MAX_CLUSTERSIZE) #define OCFS2_MAX_CTXT_PAGES 1 #else #define OCFS2_MAX_CTXT_PAGES (OCFS2_MAX_CLUSTERSIZE / PAGE_SIZE) #endif #define OCFS2_MAX_CLUSTERS_PER_PAGE (PAGE_SIZE / OCFS2_MIN_CLUSTERSIZE) struct ocfs2_unwritten_extent { struct list_head ue_node; struct list_head ue_ip_node; u32 ue_cpos; u32 ue_phys; }; /* * Describe the state of a single cluster to be written to. */ struct ocfs2_write_cluster_desc { u32 c_cpos; u32 c_phys; /* * Give this a unique field because c_phys eventually gets * filled. */ unsigned c_new; unsigned c_clear_unwritten; unsigned c_needs_zero; }; struct ocfs2_write_ctxt { /* Logical cluster position / len of write */ u32 w_cpos; u32 w_clen; /* First cluster allocated in a nonsparse extend */ u32 w_first_new_cpos; /* Type of caller. Must be one of buffer, mmap, direct. */ ocfs2_write_type_t w_type; struct ocfs2_write_cluster_desc w_desc[OCFS2_MAX_CLUSTERS_PER_PAGE]; /* * This is true if page_size > cluster_size. * * It triggers a set of special cases during write which might * have to deal with allocating writes to partial pages. */ unsigned int w_large_pages; /* * Pages involved in this write. * * w_target_page is the page being written to by the user. * * w_pages is an array of pages which always contains * w_target_page, and in the case of an allocating write with * page_size < cluster size, it will contain zero'd and mapped * pages adjacent to w_target_page which need to be written * out in so that future reads from that region will get * zero's. */ unsigned int w_num_pages; struct page *w_pages[OCFS2_MAX_CTXT_PAGES]; struct page *w_target_page; /* * w_target_locked is used for page_mkwrite path indicating no unlocking * against w_target_page in ocfs2_write_end_nolock. */ unsigned int w_target_locked:1; /* * ocfs2_write_end() uses this to know what the real range to * write in the target should be. */ unsigned int w_target_from; unsigned int w_target_to; /* * We could use journal_current_handle() but this is cleaner, * IMHO -Mark */ handle_t *w_handle; struct buffer_head *w_di_bh; struct ocfs2_cached_dealloc_ctxt w_dealloc; struct list_head w_unwritten_list; }; void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) { int i; for(i = 0; i < num_pages; i++) { if (pages[i]) { unlock_page(pages[i]); mark_page_accessed(pages[i]); put_page(pages[i]); } } } static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc) { int i; /* * w_target_locked is only set to true in the page_mkwrite() case. * The intent is to allow us to lock the target page from write_begin() * to write_end(). The caller must hold a ref on w_target_page. */ if (wc->w_target_locked) { BUG_ON(!wc->w_target_page); for (i = 0; i < wc->w_num_pages; i++) { if (wc->w_target_page == wc->w_pages[i]) { wc->w_pages[i] = NULL; break; } } mark_page_accessed(wc->w_target_page); put_page(wc->w_target_page); } ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); } static void ocfs2_free_unwritten_list(struct inode *inode, struct list_head *head) { struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_unwritten_extent *ue = NULL, *tmp = NULL; list_for_each_entry_safe(ue, tmp, head, ue_node) { list_del(&ue->ue_node); spin_lock(&oi->ip_lock); list_del(&ue->ue_ip_node); spin_unlock(&oi->ip_lock); kfree(ue); } } static void ocfs2_free_write_ctxt(struct inode *inode, struct ocfs2_write_ctxt *wc) { ocfs2_free_unwritten_list(inode, &wc->w_unwritten_list); ocfs2_unlock_pages(wc); brelse(wc->w_di_bh); kfree(wc); } static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp, struct ocfs2_super *osb, loff_t pos, unsigned len, ocfs2_write_type_t type, struct buffer_head *di_bh) { u32 cend; struct ocfs2_write_ctxt *wc; wc = kzalloc(sizeof(struct ocfs2_write_ctxt), GFP_NOFS); if (!wc) return -ENOMEM; wc->w_cpos = pos >> osb->s_clustersize_bits; wc->w_first_new_cpos = UINT_MAX; cend = (pos + len - 1) >> osb->s_clustersize_bits; wc->w_clen = cend - wc->w_cpos + 1; get_bh(di_bh); wc->w_di_bh = di_bh; wc->w_type = type; if (unlikely(PAGE_SHIFT > osb->s_clustersize_bits)) wc->w_large_pages = 1; else wc->w_large_pages = 0; ocfs2_init_dealloc_ctxt(&wc->w_dealloc); INIT_LIST_HEAD(&wc->w_unwritten_list); *wcp = wc; return 0; } /* * If a page has any new buffers, zero them out here, and mark them uptodate * and dirty so they'll be written out (in order to prevent uninitialised * block data from leaking). And clear the new bit. */ static void ocfs2_zero_new_buffers(struct page *page, unsigned from, unsigned to) { unsigned int block_start, block_end; struct buffer_head *head, *bh; BUG_ON(!PageLocked(page)); if (!page_has_buffers(page)) return; bh = head = page_buffers(page); block_start = 0; do { block_end = block_start + bh->b_size; if (buffer_new(bh)) { if (block_end > from && block_start < to) { if (!PageUptodate(page)) { unsigned start, end; start = max(from, block_start); end = min(to, block_end); zero_user_segment(page, start, end); set_buffer_uptodate(bh); } clear_buffer_new(bh); mark_buffer_dirty(bh); } } block_start = block_end; bh = bh->b_this_page; } while (bh != head); } /* * Only called when we have a failure during allocating write to write * zero's to the newly allocated region. */ static void ocfs2_write_failure(struct inode *inode, struct ocfs2_write_ctxt *wc, loff_t user_pos, unsigned user_len) { int i; unsigned from = user_pos & (PAGE_SIZE - 1), to = user_pos + user_len; struct page *tmppage; if (wc->w_target_page) ocfs2_zero_new_buffers(wc->w_target_page, from, to); for(i = 0; i < wc->w_num_pages; i++) { tmppage = wc->w_pages[i]; if (tmppage && page_has_buffers(tmppage)) { if (ocfs2_should_order_data(inode)) ocfs2_jbd2_file_inode(wc->w_handle, inode); block_commit_write(tmppage, from, to); } } } static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno, struct ocfs2_write_ctxt *wc, struct page *page, u32 cpos, loff_t user_pos, unsigned user_len, int new) { int ret; unsigned int map_from = 0, map_to = 0; unsigned int cluster_start, cluster_end; unsigned int user_data_from = 0, user_data_to = 0; ocfs2_figure_cluster_boundaries(OCFS2_SB(inode->i_sb), cpos, &cluster_start, &cluster_end); /* treat the write as new if the a hole/lseek spanned across * the page boundary. */ new = new | ((i_size_read(inode) <= page_offset(page)) && (page_offset(page) <= user_pos)); if (page == wc->w_target_page) { map_from = user_pos & (PAGE_SIZE - 1); map_to = map_from + user_len; if (new) ret = ocfs2_map_page_blocks(page, p_blkno, inode, cluster_start, cluster_end, new); else ret = ocfs2_map_page_blocks(page, p_blkno, inode, map_from, map_to, new); if (ret) { mlog_errno(ret); goto out; } user_data_from = map_from; user_data_to = map_to; if (new) { map_from = cluster_start; map_to = cluster_end; } } else { /* * If we haven't allocated the new page yet, we * shouldn't be writing it out without copying user * data. This is likely a math error from the caller. */ BUG_ON(!new); map_from = cluster_start; map_to = cluster_end; ret = ocfs2_map_page_blocks(page, p_blkno, inode, cluster_start, cluster_end, new); if (ret) { mlog_errno(ret); goto out; } } /* * Parts of newly allocated pages need to be zero'd. * * Above, we have also rewritten 'to' and 'from' - as far as * the rest of the function is concerned, the entire cluster * range inside of a page needs to be written. * * We can skip this if the page is up to date - it's already * been zero'd from being read in as a hole. */ if (new && !PageUptodate(page)) ocfs2_clear_page_regions(page, OCFS2_SB(inode->i_sb), cpos, user_data_from, user_data_to); flush_dcache_page(page); out: return ret; } /* * This function will only grab one clusters worth of pages. */ static int ocfs2_grab_pages_for_write(struct address_space *mapping, struct ocfs2_write_ctxt *wc, u32 cpos, loff_t user_pos, unsigned user_len, int new, struct page *mmap_page) { int ret = 0, i; unsigned long start, target_index, end_index, index; struct inode *inode = mapping->host; loff_t last_byte; target_index = user_pos >> PAGE_SHIFT; /* * Figure out how many pages we'll be manipulating here. For * non allocating write, we just change the one * page. Otherwise, we'll need a whole clusters worth. If we're * writing past i_size, we only need enough pages to cover the * last page of the write. */ if (new) { wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb); start = ocfs2_align_clusters_to_page_index(inode->i_sb, cpos); /* * We need the index *past* the last page we could possibly * touch. This is the page past the end of the write or * i_size, whichever is greater. */ last_byte = max(user_pos + user_len, i_size_read(inode)); BUG_ON(last_byte < 1); end_index = ((last_byte - 1) >> PAGE_SHIFT) + 1; if ((start + wc->w_num_pages) > end_index) wc->w_num_pages = end_index - start; } else { wc->w_num_pages = 1; start = target_index; } end_index = (user_pos + user_len - 1) >> PAGE_SHIFT; for(i = 0; i < wc->w_num_pages; i++) { index = start + i; if (index >= target_index && index <= end_index && wc->w_type == OCFS2_WRITE_MMAP) { /* * ocfs2_pagemkwrite() is a little different * and wants us to directly use the page * passed in. */ lock_page(mmap_page); /* Exit and let the caller retry */ if (mmap_page->mapping != mapping) { WARN_ON(mmap_page->mapping); unlock_page(mmap_page); ret = -EAGAIN; goto out; } get_page(mmap_page); wc->w_pages[i] = mmap_page; wc->w_target_locked = true; } else if (index >= target_index && index <= end_index && wc->w_type == OCFS2_WRITE_DIRECT) { /* Direct write has no mapping page. */ wc->w_pages[i] = NULL; continue; } else { wc->w_pages[i] = find_or_create_page(mapping, index, GFP_NOFS); if (!wc->w_pages[i]) { ret = -ENOMEM; mlog_errno(ret); goto out; } } wait_for_stable_page(wc->w_pages[i]); if (index == target_index) wc->w_target_page = wc->w_pages[i]; } out: if (ret) wc->w_target_locked = false; return ret; } /* * Prepare a single cluster for write one cluster into the file. */ static int ocfs2_write_cluster(struct address_space *mapping, u32 *phys, unsigned int new, unsigned int clear_unwritten, unsigned int should_zero, struct ocfs2_alloc_context *data_ac, struct ocfs2_alloc_context *meta_ac, struct ocfs2_write_ctxt *wc, u32 cpos, loff_t user_pos, unsigned user_len) { int ret, i; u64 p_blkno; struct inode *inode = mapping->host; struct ocfs2_extent_tree et; int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); if (new) { u32 tmp_pos; /* * This is safe to call with the page locks - it won't take * any additional semaphores or cluster locks. */ tmp_pos = cpos; ret = ocfs2_add_inode_data(OCFS2_SB(inode->i_sb), inode, &tmp_pos, 1, !clear_unwritten, wc->w_di_bh, wc->w_handle, data_ac, meta_ac, NULL); /* * This shouldn't happen because we must have already * calculated the correct meta data allocation required. The * internal tree allocation code should know how to increase * transaction credits itself. * * If need be, we could handle -EAGAIN for a * RESTART_TRANS here. */ mlog_bug_on_msg(ret == -EAGAIN, "Inode %llu: EAGAIN return during allocation.\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); if (ret < 0) { mlog_errno(ret); goto out; } } else if (clear_unwritten) { ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), wc->w_di_bh); ret = ocfs2_mark_extent_written(inode, &et, wc->w_handle, cpos, 1, *phys, meta_ac, &wc->w_dealloc); if (ret < 0) { mlog_errno(ret); goto out; } } /* * The only reason this should fail is due to an inability to * find the extent added. */ ret = ocfs2_get_clusters(inode, cpos, phys, NULL, NULL); if (ret < 0) { mlog(ML_ERROR, "Get physical blkno failed for inode %llu, " "at logical cluster %u", (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos); goto out; } BUG_ON(*phys == 0); p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *phys); if (!should_zero) p_blkno += (user_pos >> inode->i_sb->s_blocksize_bits) & (u64)(bpc - 1); for(i = 0; i < wc->w_num_pages; i++) { int tmpret; /* This is the direct io target page. */ if (wc->w_pages[i] == NULL) { p_blkno++; continue; } tmpret = ocfs2_prepare_page_for_write(inode, &p_blkno, wc, wc->w_pages[i], cpos, user_pos, user_len, should_zero); if (tmpret) { mlog_errno(tmpret); if (ret == 0) ret = tmpret; } } /* * We only have cleanup to do in case of allocating write. */ if (ret && new) ocfs2_write_failure(inode, wc, user_pos, user_len); out: return ret; } static int ocfs2_write_cluster_by_desc(struct address_space *mapping, struct ocfs2_alloc_context *data_ac, struct ocfs2_alloc_context *meta_ac, struct ocfs2_write_ctxt *wc, loff_t pos, unsigned len) { int ret, i; loff_t cluster_off; unsigned int local_len = len; struct ocfs2_write_cluster_desc *desc; struct ocfs2_super *osb = OCFS2_SB(mapping->host->i_sb); for (i = 0; i < wc->w_clen; i++) { desc = &wc->w_desc[i]; /* * We have to make sure that the total write passed in * doesn't extend past a single cluster. */ local_len = len; cluster_off = pos & (osb->s_clustersize - 1); if ((cluster_off + local_len) > osb->s_clustersize) local_len = osb->s_clustersize - cluster_off; ret = ocfs2_write_cluster(mapping, &desc->c_phys, desc->c_new, desc->c_clear_unwritten, desc->c_needs_zero, data_ac, meta_ac, wc, desc->c_cpos, pos, local_len); if (ret) { mlog_errno(ret); goto out; } len -= local_len; pos += local_len; } ret = 0; out: return ret; } /* * ocfs2_write_end() wants to know which parts of the target page it * should complete the write on. It's easiest to compute them ahead of * time when a more complete view of the write is available. */ static void ocfs2_set_target_boundaries(struct ocfs2_super *osb, struct ocfs2_write_ctxt *wc, loff_t pos, unsigned len, int alloc) { struct ocfs2_write_cluster_desc *desc; wc->w_target_from = pos & (PAGE_SIZE - 1); wc->w_target_to = wc->w_target_from + len; if (alloc == 0) return; /* * Allocating write - we may have different boundaries based * on page size and cluster size. * * NOTE: We can no longer compute one value from the other as * the actual write length and user provided length may be * different. */ if (wc->w_large_pages) { /* * We only care about the 1st and last cluster within * our range and whether they should be zero'd or not. Either * value may be extended out to the start/end of a * newly allocated cluster. */ desc = &wc->w_desc[0]; if (desc->c_needs_zero) ocfs2_figure_cluster_boundaries(osb, desc->c_cpos, &wc->w_target_from, NULL); desc = &wc->w_desc[wc->w_clen - 1]; if (desc->c_needs_zero) ocfs2_figure_cluster_boundaries(osb, desc->c_cpos, NULL, &wc->w_target_to); } else { wc->w_target_from = 0; wc->w_target_to = PAGE_SIZE; } } /* * Check if this extent is marked UNWRITTEN by direct io. If so, we need not to * do the zero work. And should not to clear UNWRITTEN since it will be cleared * by the direct io procedure. * If this is a new extent that allocated by direct io, we should mark it in * the ip_unwritten_list. */ static int ocfs2_unwritten_check(struct inode *inode, struct ocfs2_write_ctxt *wc, struct ocfs2_write_cluster_desc *desc) { struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_unwritten_extent *ue = NULL, *new = NULL; int ret = 0; if (!desc->c_needs_zero) return 0; retry: spin_lock(&oi->ip_lock); /* Needs not to zero no metter buffer or direct. The one who is zero * the cluster is doing zero. And he will clear unwritten after all * cluster io finished. */ list_for_each_entry(ue, &oi->ip_unwritten_list, ue_ip_node) { if (desc->c_cpos == ue->ue_cpos) { BUG_ON(desc->c_new); desc->c_needs_zero = 0; desc->c_clear_unwritten = 0; goto unlock; } } if (wc->w_type != OCFS2_WRITE_DIRECT) goto unlock; if (new == NULL) { spin_unlock(&oi->ip_lock); new = kmalloc(sizeof(struct ocfs2_unwritten_extent), GFP_NOFS); if (new == NULL) { ret = -ENOMEM; goto out; } goto retry; } /* This direct write will doing zero. */ new->ue_cpos = desc->c_cpos; new->ue_phys = desc->c_phys; desc->c_clear_unwritten = 0; list_add_tail(&new->ue_ip_node, &oi->ip_unwritten_list); list_add_tail(&new->ue_node, &wc->w_unwritten_list); new = NULL; unlock: spin_unlock(&oi->ip_lock); out: if (new) kfree(new); return ret; } /* * Populate each single-cluster write descriptor in the write context * with information about the i/o to be done. * * Returns the number of clusters that will have to be allocated, as * well as a worst case estimate of the number of extent records that * would have to be created during a write to an unwritten region. */ static int ocfs2_populate_write_desc(struct inode *inode, struct ocfs2_write_ctxt *wc, unsigned int *clusters_to_alloc, unsigned int *extents_to_split) { int ret; struct ocfs2_write_cluster_desc *desc; unsigned int num_clusters = 0; unsigned int ext_flags = 0; u32 phys = 0; int i; *clusters_to_alloc = 0; *extents_to_split = 0; for (i = 0; i < wc->w_clen; i++) { desc = &wc->w_desc[i]; desc->c_cpos = wc->w_cpos + i; if (num_clusters == 0) { /* * Need to look up the next extent record. */ ret = ocfs2_get_clusters(inode, desc->c_cpos, &phys, &num_clusters, &ext_flags); if (ret) { mlog_errno(ret); goto out; } /* We should already CoW the refcountd extent. */ BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED); /* * Assume worst case - that we're writing in * the middle of the extent. * * We can assume that the write proceeds from * left to right, in which case the extent * insert code is smart enough to coalesce the * next splits into the previous records created. */ if (ext_flags & OCFS2_EXT_UNWRITTEN) *extents_to_split = *extents_to_split + 2; } else if (phys) { /* * Only increment phys if it doesn't describe * a hole. */ phys++; } /* * If w_first_new_cpos is < UINT_MAX, we have a non-sparse * file that got extended. w_first_new_cpos tells us * where the newly allocated clusters are so we can * zero them. */ if (desc->c_cpos >= wc->w_first_new_cpos) { BUG_ON(phys == 0); desc->c_needs_zero = 1; } desc->c_phys = phys; if (phys == 0) { desc->c_new = 1; desc->c_needs_zero = 1; desc->c_clear_unwritten = 1; *clusters_to_alloc = *clusters_to_alloc + 1; } if (ext_flags & OCFS2_EXT_UNWRITTEN) { desc->c_clear_unwritten = 1; desc->c_needs_zero = 1; } ret = ocfs2_unwritten_check(inode, wc, desc); if (ret) { mlog_errno(ret); goto out; } num_clusters--; } ret = 0; out: return ret; } static int ocfs2_write_begin_inline(struct address_space *mapping, struct inode *inode, struct ocfs2_write_ctxt *wc) { int ret; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct page *page; handle_t *handle; struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); goto out; } page = find_or_create_page(mapping, 0, GFP_NOFS); if (!page) { ocfs2_commit_trans(osb, handle); ret = -ENOMEM; mlog_errno(ret); goto out; } /* * If we don't set w_num_pages then this page won't get unlocked * and freed on cleanup of the write context. */ wc->w_pages[0] = wc->w_target_page = page; wc->w_num_pages = 1; ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { ocfs2_commit_trans(osb, handle); mlog_errno(ret); goto out; } if (!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) ocfs2_set_inode_data_inline(inode, di); if (!PageUptodate(page)) { ret = ocfs2_read_inline_data(inode, page, wc->w_di_bh); if (ret) { ocfs2_commit_trans(osb, handle); goto out; } } wc->w_handle = handle; out: return ret; } int ocfs2_size_fits_inline_data(struct buffer_head *di_bh, u64 new_size) { struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; if (new_size <= le16_to_cpu(di->id2.i_data.id_count)) return 1; return 0; } static int ocfs2_try_to_write_inline_data(struct address_space *mapping, struct inode *inode, loff_t pos, unsigned len, struct page *mmap_page, struct ocfs2_write_ctxt *wc) { int ret, written = 0; loff_t end = pos + len; struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_dinode *di = NULL; trace_ocfs2_try_to_write_inline_data((unsigned long long)oi->ip_blkno, len, (unsigned long long)pos, oi->ip_dyn_features); /* * Handle inodes which already have inline data 1st. */ if (oi->ip_dyn_features & OCFS2_INLINE_DATA_FL) { if (mmap_page == NULL && ocfs2_size_fits_inline_data(wc->w_di_bh, end)) goto do_inline_write; /* * The write won't fit - we have to give this inode an * inline extent list now. */ ret = ocfs2_convert_inline_data_to_extents(inode, wc->w_di_bh); if (ret) mlog_errno(ret); goto out; } /* * Check whether the inode can accept inline data. */ if (oi->ip_clusters != 0 || i_size_read(inode) != 0) return 0; /* * Check whether the write can fit. */ di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; if (mmap_page || end > ocfs2_max_inline_data_with_xattr(inode->i_sb, di)) return 0; do_inline_write: ret = ocfs2_write_begin_inline(mapping, inode, wc); if (ret) { mlog_errno(ret); goto out; } /* * This signals to the caller that the data can be written * inline. */ written = 1; out: return written ? written : ret; } /* * This function only does anything for file systems which can't * handle sparse files. * * What we want to do here is fill in any hole between the current end * of allocation and the end of our write. That way the rest of the * write path can treat it as an non-allocating write, which has no * special case code for sparse/nonsparse files. */ static int ocfs2_expand_nonsparse_inode(struct inode *inode, struct buffer_head *di_bh, loff_t pos, unsigned len, struct ocfs2_write_ctxt *wc) { int ret; loff_t newsize = pos + len; BUG_ON(ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))); if (newsize <= i_size_read(inode)) return 0; ret = ocfs2_extend_no_holes(inode, di_bh, newsize, pos); if (ret) mlog_errno(ret); /* There is no wc if this is call from direct. */ if (wc) wc->w_first_new_cpos = ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode)); return ret; } static int ocfs2_zero_tail(struct inode *inode, struct buffer_head *di_bh, loff_t pos) { int ret = 0; BUG_ON(!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))); if (pos > i_size_read(inode)) ret = ocfs2_zero_extend(inode, di_bh, pos); return ret; } int ocfs2_write_begin_nolock(struct address_space *mapping, loff_t pos, unsigned len, ocfs2_write_type_t type, struct page **pagep, void **fsdata, struct buffer_head *di_bh, struct page *mmap_page) { int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS; unsigned int clusters_to_alloc, extents_to_split, clusters_need = 0; struct ocfs2_write_ctxt *wc; struct inode *inode = mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_dinode *di; struct ocfs2_alloc_context *data_ac = NULL; struct ocfs2_alloc_context *meta_ac = NULL; handle_t *handle; struct ocfs2_extent_tree et; int try_free = 1, ret1; try_again: ret = ocfs2_alloc_write_ctxt(&wc, osb, pos, len, type, di_bh); if (ret) { mlog_errno(ret); return ret; } if (ocfs2_supports_inline_data(osb)) { ret = ocfs2_try_to_write_inline_data(mapping, inode, pos, len, mmap_page, wc); if (ret == 1) { ret = 0; goto success; } if (ret < 0) { mlog_errno(ret); goto out; } } /* Direct io change i_size late, should not zero tail here. */ if (type != OCFS2_WRITE_DIRECT) { if (ocfs2_sparse_alloc(osb)) ret = ocfs2_zero_tail(inode, di_bh, pos); else ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, len, wc); if (ret) { mlog_errno(ret); goto out; } } ret = ocfs2_check_range_for_refcount(inode, pos, len); if (ret < 0) { mlog_errno(ret); goto out; } else if (ret == 1) { clusters_need = wc->w_clen; ret = ocfs2_refcount_cow(inode, di_bh, wc->w_cpos, wc->w_clen, UINT_MAX); if (ret) { mlog_errno(ret); goto out; } } ret = ocfs2_populate_write_desc(inode, wc, &clusters_to_alloc, &extents_to_split); if (ret) { mlog_errno(ret); goto out; } clusters_need += clusters_to_alloc; di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; trace_ocfs2_write_begin_nolock( (unsigned long long)OCFS2_I(inode)->ip_blkno, (long long)i_size_read(inode), le32_to_cpu(di->i_clusters), pos, len, type, mmap_page, clusters_to_alloc, extents_to_split); /* * We set w_target_from, w_target_to here so that * ocfs2_write_end() knows which range in the target page to * write out. An allocation requires that we write the entire * cluster range. */ if (clusters_to_alloc || extents_to_split) { /* * XXX: We are stretching the limits of * ocfs2_lock_allocators(). It greatly over-estimates * the work to be done. */ ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), wc->w_di_bh); ret = ocfs2_lock_allocators(inode, &et, clusters_to_alloc, extents_to_split, &data_ac, &meta_ac); if (ret) { mlog_errno(ret); goto out; } if (data_ac) data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv; credits = ocfs2_calc_extend_credits(inode->i_sb, &di->id2.i_list); } else if (type == OCFS2_WRITE_DIRECT) /* direct write needs not to start trans if no extents alloc. */ goto success; /* * We have to zero sparse allocated clusters, unwritten extent clusters, * and non-sparse clusters we just extended. For non-sparse writes, * we know zeros will only be needed in the first and/or last cluster. */ if (wc->w_clen && (wc->w_desc[0].c_needs_zero || wc->w_desc[wc->w_clen - 1].c_needs_zero)) cluster_of_pages = 1; else cluster_of_pages = 0; ocfs2_set_target_boundaries(osb, wc, pos, len, cluster_of_pages); handle = ocfs2_start_trans(osb, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); goto out; } wc->w_handle = handle; if (clusters_to_alloc) { ret = dquot_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); if (ret) goto out_commit; } ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { mlog_errno(ret); goto out_quota; } /* * Fill our page array first. That way we've grabbed enough so * that we can zero and flush if we error after adding the * extent. */ ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len, cluster_of_pages, mmap_page); if (ret && ret != -EAGAIN) { mlog_errno(ret); goto out_quota; } /* * ocfs2_grab_pages_for_write() returns -EAGAIN if it could not lock * the target page. In this case, we exit with no error and no target * page. This will trigger the caller, page_mkwrite(), to re-try * the operation. */ if (ret == -EAGAIN) { BUG_ON(wc->w_target_page); ret = 0; goto out_quota; } ret = ocfs2_write_cluster_by_desc(mapping, data_ac, meta_ac, wc, pos, len); if (ret) { mlog_errno(ret); goto out_quota; } if (data_ac) ocfs2_free_alloc_context(data_ac); if (meta_ac) ocfs2_free_alloc_context(meta_ac); success: if (pagep) *pagep = wc->w_target_page; *fsdata = wc; return 0; out_quota: if (clusters_to_alloc) dquot_free_space(inode, ocfs2_clusters_to_bytes(osb->sb, clusters_to_alloc)); out_commit: ocfs2_commit_trans(osb, handle); out: /* * The mmapped page won't be unlocked in ocfs2_free_write_ctxt(), * even in case of error here like ENOSPC and ENOMEM. So, we need * to unlock the target page manually to prevent deadlocks when * retrying again on ENOSPC, or when returning non-VM_FAULT_LOCKED * to VM code. */ if (wc->w_target_locked) unlock_page(mmap_page); ocfs2_free_write_ctxt(inode, wc); if (data_ac) { ocfs2_free_alloc_context(data_ac); data_ac = NULL; } if (meta_ac) { ocfs2_free_alloc_context(meta_ac); meta_ac = NULL; } if (ret == -ENOSPC && try_free) { /* * Try to free some truncate log so that we can have enough * clusters to allocate. */ try_free = 0; ret1 = ocfs2_try_to_free_truncate_log(osb, clusters_need); if (ret1 == 1) goto try_again; if (ret1 < 0) mlog_errno(ret1); } return ret; } static int ocfs2_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) { int ret; struct buffer_head *di_bh = NULL; struct inode *inode = mapping->host; ret = ocfs2_inode_lock(inode, &di_bh, 1); if (ret) { mlog_errno(ret); return ret; } /* * Take alloc sem here to prevent concurrent lookups. That way * the mapping, zeroing and tree manipulation within * ocfs2_write() will be safe against ->readpage(). This * should also serve to lock out allocation from a shared * writeable region. */ down_write(&OCFS2_I(inode)->ip_alloc_sem); ret = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_BUFFER, pagep, fsdata, di_bh, NULL); if (ret) { mlog_errno(ret); goto out_fail; } brelse(di_bh); return 0; out_fail: up_write(&OCFS2_I(inode)->ip_alloc_sem); brelse(di_bh); ocfs2_inode_unlock(inode, 1); return ret; } static void ocfs2_write_end_inline(struct inode *inode, loff_t pos, unsigned len, unsigned *copied, struct ocfs2_dinode *di, struct ocfs2_write_ctxt *wc) { void *kaddr; if (unlikely(*copied < len)) { if (!PageUptodate(wc->w_target_page)) { *copied = 0; return; } } kaddr = kmap_atomic(wc->w_target_page); memcpy(di->id2.i_data.id_data + pos, kaddr + pos, *copied); kunmap_atomic(kaddr); trace_ocfs2_write_end_inline( (unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)pos, *copied, le16_to_cpu(di->id2.i_data.id_count), le16_to_cpu(di->i_dyn_features)); } int ocfs2_write_end_nolock(struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, void *fsdata) { int i, ret; unsigned from, to, start = pos & (PAGE_SIZE - 1); struct inode *inode = mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_write_ctxt *wc = fsdata; struct ocfs2_dinode *di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; handle_t *handle = wc->w_handle; struct page *tmppage; BUG_ON(!list_empty(&wc->w_unwritten_list)); if (handle) { ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { copied = ret; mlog_errno(ret); goto out; } } if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { ocfs2_write_end_inline(inode, pos, len, &copied, di, wc); goto out_write_size; } if (unlikely(copied < len) && wc->w_target_page) { if (!PageUptodate(wc->w_target_page)) copied = 0; ocfs2_zero_new_buffers(wc->w_target_page, start+copied, start+len); } if (wc->w_target_page) flush_dcache_page(wc->w_target_page); for(i = 0; i < wc->w_num_pages; i++) { tmppage = wc->w_pages[i]; /* This is the direct io target page. */ if (tmppage == NULL) continue; if (tmppage == wc->w_target_page) { from = wc->w_target_from; to = wc->w_target_to; BUG_ON(from > PAGE_SIZE || to > PAGE_SIZE || to < from); } else { /* * Pages adjacent to the target (if any) imply * a hole-filling write in which case we want * to flush their entire range. */ from = 0; to = PAGE_SIZE; } if (page_has_buffers(tmppage)) { if (handle && ocfs2_should_order_data(inode)) ocfs2_jbd2_file_inode(handle, inode); block_commit_write(tmppage, from, to); } } out_write_size: /* Direct io do not update i_size here. */ if (wc->w_type != OCFS2_WRITE_DIRECT) { pos += copied; if (pos > i_size_read(inode)) { i_size_write(inode, pos); mark_inode_dirty(inode); } inode->i_blocks = ocfs2_inode_sector_count(inode); di->i_size = cpu_to_le64((u64)i_size_read(inode)); inode->i_mtime = inode->i_ctime = current_time(inode); di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec); di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); ocfs2_update_inode_fsync_trans(handle, inode, 1); } if (handle) ocfs2_journal_dirty(handle, wc->w_di_bh); out: /* unlock pages before dealloc since it needs acquiring j_trans_barrier * lock, or it will cause a deadlock since journal commit threads holds * this lock and will ask for the page lock when flushing the data. * put it here to preserve the unlock order. */ ocfs2_unlock_pages(wc); if (handle) ocfs2_commit_trans(osb, handle); ocfs2_run_deallocs(osb, &wc->w_dealloc); brelse(wc->w_di_bh); kfree(wc); return copied; } static int ocfs2_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata) { int ret; struct inode *inode = mapping->host; ret = ocfs2_write_end_nolock(mapping, pos, len, copied, fsdata); up_write(&OCFS2_I(inode)->ip_alloc_sem); ocfs2_inode_unlock(inode, 1); return ret; } struct ocfs2_dio_write_ctxt { struct list_head dw_zero_list; unsigned dw_zero_count; int dw_orphaned; pid_t dw_writer_pid; }; static struct ocfs2_dio_write_ctxt * ocfs2_dio_alloc_write_ctx(struct buffer_head *bh, int *alloc) { struct ocfs2_dio_write_ctxt *dwc = NULL; if (bh->b_private) return bh->b_private; dwc = kmalloc(sizeof(struct ocfs2_dio_write_ctxt), GFP_NOFS); if (dwc == NULL) return NULL; INIT_LIST_HEAD(&dwc->dw_zero_list); dwc->dw_zero_count = 0; dwc->dw_orphaned = 0; dwc->dw_writer_pid = task_pid_nr(current); bh->b_private = dwc; *alloc = 1; return dwc; } static void ocfs2_dio_free_write_ctx(struct inode *inode, struct ocfs2_dio_write_ctxt *dwc) { ocfs2_free_unwritten_list(inode, &dwc->dw_zero_list); kfree(dwc); } /* * TODO: Make this into a generic get_blocks function. * * From do_direct_io in direct-io.c: * "So what we do is to permit the ->get_blocks function to populate * bh.b_size with the size of IO which is permitted at this offset and * this i_blkbits." * * This function is called directly from get_more_blocks in direct-io.c. * * called like this: dio->get_blocks(dio->inode, fs_startblk, * fs_count, map_bh, dio->rw == WRITE); */ static int ocfs2_dio_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_write_ctxt *wc; struct ocfs2_write_cluster_desc *desc = NULL; struct ocfs2_dio_write_ctxt *dwc = NULL; struct buffer_head *di_bh = NULL; u64 p_blkno; loff_t pos = iblock << inode->i_sb->s_blocksize_bits; unsigned len, total_len = bh_result->b_size; int ret = 0, first_get_block = 0; len = osb->s_clustersize - (pos & (osb->s_clustersize - 1)); len = min(total_len, len); mlog(0, "get block of %lu at %llu:%u req %u\n", inode->i_ino, pos, len, total_len); /* * Because we need to change file size in ocfs2_dio_end_io_write(), or * we may need to add it to orphan dir. So can not fall to fast path * while file size will be changed. */ if (pos + total_len <= i_size_read(inode)) { down_read(&oi->ip_alloc_sem); /* This is the fast path for re-write. */ ret = ocfs2_get_block(inode, iblock, bh_result, create); up_read(&oi->ip_alloc_sem); if (buffer_mapped(bh_result) && !buffer_new(bh_result) && ret == 0) goto out; /* Clear state set by ocfs2_get_block. */ bh_result->b_state = 0; } dwc = ocfs2_dio_alloc_write_ctx(bh_result, &first_get_block); if (unlikely(dwc == NULL)) { ret = -ENOMEM; mlog_errno(ret); goto out; } if (ocfs2_clusters_for_bytes(inode->i_sb, pos + total_len) > ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode)) && !dwc->dw_orphaned) { /* * when we are going to alloc extents beyond file size, add the * inode to orphan dir, so we can recall those spaces when * system crashed during write. */ ret = ocfs2_add_inode_to_orphan(osb, inode); if (ret < 0) { mlog_errno(ret); goto out; } dwc->dw_orphaned = 1; } ret = ocfs2_inode_lock(inode, &di_bh, 1); if (ret) { mlog_errno(ret); goto out; } down_write(&oi->ip_alloc_sem); if (first_get_block) { if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) ret = ocfs2_zero_tail(inode, di_bh, pos); else ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, total_len, NULL); if (ret < 0) { mlog_errno(ret); goto unlock; } } ret = ocfs2_write_begin_nolock(inode->i_mapping, pos, len, OCFS2_WRITE_DIRECT, NULL, (void **)&wc, di_bh, NULL); if (ret) { mlog_errno(ret); goto unlock; } desc = &wc->w_desc[0]; p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, desc->c_phys); BUG_ON(p_blkno == 0); p_blkno += iblock & (u64)(ocfs2_clusters_to_blocks(inode->i_sb, 1) - 1); map_bh(bh_result, inode->i_sb, p_blkno); bh_result->b_size = len; if (desc->c_needs_zero) set_buffer_new(bh_result); /* May sleep in end_io. It should not happen in a irq context. So defer * it to dio work queue. */ set_buffer_defer_completion(bh_result); if (!list_empty(&wc->w_unwritten_list)) { struct ocfs2_unwritten_extent *ue = NULL; ue = list_first_entry(&wc->w_unwritten_list, struct ocfs2_unwritten_extent, ue_node); BUG_ON(ue->ue_cpos != desc->c_cpos); /* The physical address may be 0, fill it. */ ue->ue_phys = desc->c_phys; list_splice_tail_init(&wc->w_unwritten_list, &dwc->dw_zero_list); dwc->dw_zero_count++; } ret = ocfs2_write_end_nolock(inode->i_mapping, pos, len, len, wc); BUG_ON(ret != len); ret = 0; unlock: up_write(&oi->ip_alloc_sem); ocfs2_inode_unlock(inode, 1); brelse(di_bh); out: if (ret < 0) ret = -EIO; return ret; } static void ocfs2_dio_end_io_write(struct inode *inode, struct ocfs2_dio_write_ctxt *dwc, loff_t offset, ssize_t bytes) { struct ocfs2_cached_dealloc_ctxt dealloc; struct ocfs2_extent_tree et; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_unwritten_extent *ue = NULL; struct buffer_head *di_bh = NULL; struct ocfs2_dinode *di; struct ocfs2_alloc_context *data_ac = NULL; struct ocfs2_alloc_context *meta_ac = NULL; handle_t *handle = NULL; loff_t end = offset + bytes; int ret = 0, credits = 0, locked = 0; ocfs2_init_dealloc_ctxt(&dealloc); /* We do clear unwritten, delete orphan, change i_size here. If neither * of these happen, we can skip all this. */ if (list_empty(&dwc->dw_zero_list) && end <= i_size_read(inode) && !dwc->dw_orphaned) goto out; /* ocfs2_file_write_iter will get i_mutex, so we need not lock if we * are in that context. */ if (dwc->dw_writer_pid != task_pid_nr(current)) { inode_lock(inode); locked = 1; } ret = ocfs2_inode_lock(inode, &di_bh, 1); if (ret < 0) { mlog_errno(ret); goto out; } down_write(&oi->ip_alloc_sem); /* Delete orphan before acquire i_mutex. */ if (dwc->dw_orphaned) { BUG_ON(dwc->dw_writer_pid != task_pid_nr(current)); end = end > i_size_read(inode) ? end : 0; ret = ocfs2_del_inode_from_orphan(osb, inode, di_bh, !!end, end); if (ret < 0) mlog_errno(ret); } di = (struct ocfs2_dinode *)di_bh; ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); ret = ocfs2_lock_allocators(inode, &et, 0, dwc->dw_zero_count*2, &data_ac, &meta_ac); if (ret) { mlog_errno(ret); goto unlock; } credits = ocfs2_calc_extend_credits(inode->i_sb, &di->id2.i_list); handle = ocfs2_start_trans(osb, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); mlog_errno(ret); goto unlock; } ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh, OCFS2_JOURNAL_ACCESS_WRITE); if (ret) { mlog_errno(ret); goto commit; } list_for_each_entry(ue, &dwc->dw_zero_list, ue_node) { ret = ocfs2_mark_extent_written(inode, &et, handle, ue->ue_cpos, 1, ue->ue_phys, meta_ac, &dealloc); if (ret < 0) { mlog_errno(ret); break; } } if (end > i_size_read(inode)) { ret = ocfs2_set_inode_size(handle, inode, di_bh, end); if (ret < 0) mlog_errno(ret); } commit: ocfs2_commit_trans(osb, handle); unlock: up_write(&oi->ip_alloc_sem); ocfs2_inode_unlock(inode, 1); brelse(di_bh); out: if (data_ac) ocfs2_free_alloc_context(data_ac); if (meta_ac) ocfs2_free_alloc_context(meta_ac); ocfs2_run_deallocs(osb, &dealloc); if (locked) inode_unlock(inode); ocfs2_dio_free_write_ctx(inode, dwc); } /* * ocfs2_dio_end_io is called by the dio core when a dio is finished. We're * particularly interested in the aio/dio case. We use the rw_lock DLM lock * to protect io on one node from truncation on another. */ static int ocfs2_dio_end_io(struct kiocb *iocb, loff_t offset, ssize_t bytes, void *private) { struct inode *inode = file_inode(iocb->ki_filp); int level; if (bytes <= 0) return 0; /* this io's submitter should not have unlocked this before we could */ BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); if (private) ocfs2_dio_end_io_write(inode, private, offset, bytes); ocfs2_iocb_clear_rw_locked(iocb); level = ocfs2_iocb_rw_locked_level(iocb); ocfs2_rw_unlock(inode, level); return 0; } static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); get_block_t *get_block; /* * Fallback to buffered I/O if we see an inode without * extents. */ if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) return 0; /* Fallback to buffered I/O if we do not support append dio. */ if (iocb->ki_pos + iter->count > i_size_read(inode) && !ocfs2_supports_append_dio(osb)) return 0; if (iov_iter_rw(iter) == READ) get_block = ocfs2_get_block; else get_block = ocfs2_dio_get_block; return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter, get_block, ocfs2_dio_end_io, NULL, 0); } const struct address_space_operations ocfs2_aops = { .readpage = ocfs2_readpage, .readpages = ocfs2_readpages, .writepage = ocfs2_writepage, .write_begin = ocfs2_write_begin, .write_end = ocfs2_write_end, .bmap = ocfs2_bmap, .direct_IO = ocfs2_direct_IO, .invalidatepage = block_invalidatepage, .releasepage = ocfs2_releasepage, .migratepage = buffer_migrate_page, .is_partially_uptodate = block_is_partially_uptodate, .error_remove_page = generic_error_remove_page, };
wanahmadzainie/linux-mainline
fs/ocfs2/aops.c
C
gpl-2.0
62,615
[ 30522, 1013, 1008, 1011, 1008, 1011, 5549, 1024, 1039, 1025, 1039, 1011, 3937, 1011, 16396, 1024, 1022, 1025, 1011, 1008, 1011, 1008, 6819, 2213, 1024, 2053, 10288, 9739, 11927, 7875, 25430, 1027, 1022, 24529, 1027, 1022, 8541, 1027, 1014, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2016 Cisco and/or its affiliates. * 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. */ #include <vnet/lisp-gpe/lisp_gpe.h> lisp_gpe_main_t lisp_gpe_main; static int lisp_gpe_rewrite (lisp_gpe_tunnel_t * t) { u8 *rw = 0; lisp_gpe_header_t * lisp0; int len; if (ip_addr_version(&t->src) == IP4) { ip4_header_t * ip0; ip4_udp_lisp_gpe_header_t * h0; len = sizeof(*h0); vec_validate_aligned(rw, len - 1, CLIB_CACHE_LINE_BYTES); h0 = (ip4_udp_lisp_gpe_header_t *) rw; /* Fixed portion of the (outer) ip4 header */ ip0 = &h0->ip4; ip0->ip_version_and_header_length = 0x45; ip0->ttl = 254; ip0->protocol = IP_PROTOCOL_UDP; /* we fix up the ip4 header length and checksum after-the-fact */ ip_address_copy_addr(&ip0->src_address, &t->src); ip_address_copy_addr(&ip0->dst_address, &t->dst); ip0->checksum = ip4_header_checksum (ip0); /* UDP header, randomize src port on something, maybe? */ h0->udp.src_port = clib_host_to_net_u16 (4341); h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_lisp_gpe); /* LISP-gpe header */ lisp0 = &h0->lisp; } else { ip6_header_t * ip0; ip6_udp_lisp_gpe_header_t * h0; len = sizeof(*h0); vec_validate_aligned(rw, len - 1, CLIB_CACHE_LINE_BYTES); h0 = (ip6_udp_lisp_gpe_header_t *) rw; /* Fixed portion of the (outer) ip6 header */ ip0 = &h0->ip6; ip0->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 (0x6 << 28); ip0->hop_limit = 254; ip0->protocol = IP_PROTOCOL_UDP; /* we fix up the ip6 header length after-the-fact */ ip_address_copy_addr(&ip0->src_address, &t->src); ip_address_copy_addr(&ip0->dst_address, &t->dst); /* UDP header, randomize src port on something, maybe? */ h0->udp.src_port = clib_host_to_net_u16 (4341); h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_lisp_gpe); /* LISP-gpe header */ lisp0 = &h0->lisp; } lisp0->flags = t->flags; lisp0->ver_res = t->ver_res; lisp0->res = t->res; lisp0->next_protocol = t->next_protocol; lisp0->iid = clib_host_to_net_u32 (t->vni); t->rewrite = rw; return 0; } #define foreach_copy_field \ _(encap_fib_index) \ _(decap_fib_index) \ _(decap_next_index) \ _(vni) static u32 add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 * tun_index_res) { lisp_gpe_main_t * lgm = &lisp_gpe_main; lisp_gpe_tunnel_t *t = 0; uword * p; int rv; lisp_gpe_tunnel_key_t key; /* prepare tunnel key */ memset(&key, 0, sizeof(key)); ip_prefix_copy(&key.eid, &gid_address_ippref(&a->deid)); ip_address_copy(&key.dst_loc, &a->dlocator); key.iid = clib_host_to_net_u32 (a->vni); p = mhash_get (&lgm->lisp_gpe_tunnel_by_key, &key); if (a->is_add) { /* adding a tunnel: tunnel must not already exist */ if (p) return VNET_API_ERROR_INVALID_VALUE; if (a->decap_next_index >= LISP_GPE_INPUT_N_NEXT) return VNET_API_ERROR_INVALID_DECAP_NEXT; pool_get_aligned (lgm->tunnels, t, CLIB_CACHE_LINE_BYTES); memset (t, 0, sizeof (*t)); /* copy from arg structure */ #define _(x) t->x = a->x; foreach_copy_field; #undef _ ip_address_copy(&t->src, &a->slocator); ip_address_copy(&t->dst, &a->dlocator); /* if vni is non-default */ if (a->vni) { t->flags = LISP_GPE_FLAGS_I; t->vni = a->vni; } t->flags |= LISP_GPE_FLAGS_P; t->next_protocol = ip_prefix_version(&key.eid) == IP4 ? LISP_GPE_NEXT_PROTO_IP4 : LISP_GPE_NEXT_PROTO_IP6; rv = lisp_gpe_rewrite (t); if (rv) { pool_put(lgm->tunnels, t); return rv; } mhash_set(&lgm->lisp_gpe_tunnel_by_key, &key, t - lgm->tunnels, 0); /* return tunnel index */ if (tun_index_res) tun_index_res[0] = t - lgm->tunnels; } else { /* deleting a tunnel: tunnel must exist */ if (!p) { clib_warning("Tunnel for eid %U doesn't exist!", format_gid_address, &a->deid); return VNET_API_ERROR_NO_SUCH_ENTRY; } t = pool_elt_at_index(lgm->tunnels, p[0]); mhash_unset(&lgm->lisp_gpe_tunnel_by_key, &key, 0); vec_free(t->rewrite); pool_put(lgm->tunnels, t); } return 0; } static int add_del_negative_fwd_entry (lisp_gpe_main_t * lgm, vnet_lisp_gpe_add_del_fwd_entry_args_t * a) { ip_adjacency_t adj; ip_prefix_t * dpref = &gid_address_ippref(&a->deid); ip_prefix_t * spref = &gid_address_ippref(&a->seid); /* setup adjacency for eid */ memset (&adj, 0, sizeof(adj)); adj.n_adj = 1; /* fill in 'legal' data to avoid issues */ adj.lookup_next_index = (ip_prefix_version(dpref) == IP4) ? lgm->ip4_lookup_next_lgpe_ip4_lookup : lgm->ip6_lookup_next_lgpe_ip6_lookup; adj.rewrite_header.sw_if_index = ~0; adj.rewrite_header.next_index = ~0; switch (a->action) { case NO_ACTION: /* TODO update timers? */ case FORWARD_NATIVE: /* TODO check if route/next-hop for eid exists in fib and add * more specific for the eid with the next-hop found */ case SEND_MAP_REQUEST: /* insert tunnel that always sends map-request */ adj.explicit_fib_index = (ip_prefix_version(dpref) == IP4) ? LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP: LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP; /* add/delete route for prefix */ return ip_sd_fib_add_del_route (lgm, dpref, spref, a->table_id, &adj, a->is_add); case DROP: /* for drop fwd entries, just add route, no need to add encap tunnel */ adj.explicit_fib_index = (ip_prefix_version(dpref) == IP4 ? LGPE_IP4_LOOKUP_NEXT_DROP : LGPE_IP6_LOOKUP_NEXT_DROP); /* add/delete route for prefix */ return ip_sd_fib_add_del_route (lgm, dpref, spref, a->table_id, &adj, a->is_add); default: return -1; } } int vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a, u32 * hw_if_indexp) { lisp_gpe_main_t * lgm = &lisp_gpe_main; ip_adjacency_t adj, * adjp; u32 adj_index, rv, tun_index = ~0; ip_prefix_t * dpref, * spref; uword * lookup_next_index, * lgpe_sw_if_index, * lnip; u8 ip_ver; if (vnet_lisp_gpe_enable_disable_status() == 0) { clib_warning ("LISP is disabled!"); return VNET_API_ERROR_LISP_DISABLED; } /* treat negative fwd entries separately */ if (a->is_negative) return add_del_negative_fwd_entry (lgm, a); dpref = &gid_address_ippref(&a->deid); spref = &gid_address_ippref(&a->seid); ip_ver = ip_prefix_version(dpref); /* add/del tunnel to tunnels pool and prepares rewrite */ rv = add_del_ip_tunnel (a, &tun_index); if (rv) return rv; /* setup adjacency for eid */ memset (&adj, 0, sizeof(adj)); adj.n_adj = 1; /* fill in lookup_next_index with a 'legal' value to avoid problems */ adj.lookup_next_index = (ip_ver == IP4) ? lgm->ip4_lookup_next_lgpe_ip4_lookup : lgm->ip6_lookup_next_lgpe_ip6_lookup; if (a->is_add) { /* send packets that hit this adj to lisp-gpe interface output node in * requested vrf. */ lnip = (ip_ver == IP4) ? lgm->lgpe_ip4_lookup_next_index_by_table_id : lgm->lgpe_ip6_lookup_next_index_by_table_id; lookup_next_index = hash_get(lnip, a->table_id); lgpe_sw_if_index = hash_get(lgm->tunnel_term_sw_if_index_by_vni, a->vni); /* the assumption is that the interface must've been created before * programming the dp */ ASSERT(lookup_next_index != 0); ASSERT(lgpe_sw_if_index != 0); /* hijack explicit fib index to store lisp interface node index and * if_address_index for the tunnel index */ adj.explicit_fib_index = lookup_next_index[0]; adj.if_address_index = tun_index; adj.rewrite_header.sw_if_index = lgpe_sw_if_index[0]; } /* add/delete route for prefix */ rv = ip_sd_fib_add_del_route (lgm, dpref, spref, a->table_id, &adj, a->is_add); /* check that everything worked */ if (CLIB_DEBUG && a->is_add) { adj_index = ip_sd_fib_get_route (lgm, dpref, spref, a->table_id); ASSERT(adj_index != 0); adjp = ip_get_adjacency ((ip_ver == IP4) ? lgm->lm4 : lgm->lm6, adj_index); ASSERT(adjp != 0); ASSERT(adjp->if_address_index == tun_index); } return rv; } static clib_error_t * lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { unformat_input_t _line_input, * line_input = &_line_input; u8 is_add = 1; ip_address_t slocator, dlocator, *slocators = 0, *dlocators = 0; ip_prefix_t * prefp; gid_address_t * eids = 0, eid; clib_error_t * error = 0; u32 i; int rv; prefp = &gid_address_ippref(&eid); /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "del")) is_add = 0; else if (unformat (line_input, "add")) is_add = 1; else if (unformat (line_input, "eid %U slocator %U dlocator %U", unformat_ip_prefix, prefp, unformat_ip_address, &slocator, unformat_ip_address, &dlocator)) { vec_add1 (eids, eid); vec_add1 (slocators, slocator); vec_add1 (dlocators, dlocator); } else { error = unformat_parse_error (line_input); goto done; } } unformat_free (line_input); if (vec_len (eids) + vec_len (slocators) == 0) { error = clib_error_return (0, "expected ip4/ip6 eids/locators."); goto done; } if (vec_len (eids) != vec_len (slocators)) { error = clib_error_return (0, "number of eids not equal to that of " "locators."); goto done; } for (i = 0; i < vec_len(eids); i++) { vnet_lisp_gpe_add_del_fwd_entry_args_t a; memset (&a, 0, sizeof(a)); a.is_add = is_add; a.deid = eids[i]; a.slocator = slocators[i]; a.dlocator = dlocators[i]; rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0); if (0 != rv) { error = clib_error_return(0, "failed to %s gpe maptunnel!", is_add ? "add" : "delete"); break; } } done: vec_free(eids); vec_free(slocators); vec_free(dlocators); return error; } VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = { .path = "lisp gpe maptunnel", .short_help = "lisp gpe maptunnel eid <eid> sloc <src-locator> " "dloc <dst-locator> [del]", .function = lisp_gpe_add_del_fwd_entry_command_fn, }; static u8 * format_decap_next (u8 * s, va_list * args) { u32 next_index = va_arg (*args, u32); switch (next_index) { case LISP_GPE_INPUT_NEXT_DROP: return format (s, "drop"); case LISP_GPE_INPUT_NEXT_IP4_INPUT: return format (s, "ip4"); case LISP_GPE_INPUT_NEXT_IP6_INPUT: return format (s, "ip6"); default: return format (s, "unknown %d", next_index); } return s; } u8 * format_lisp_gpe_tunnel (u8 * s, va_list * args) { lisp_gpe_tunnel_t * t = va_arg (*args, lisp_gpe_tunnel_t *); lisp_gpe_main_t * lgm = &lisp_gpe_main; s = format (s, "[%d] %U (src) %U (dst) fibs: encap %d, decap %d", t - lgm->tunnels, format_ip_address, &t->src, format_ip_address, &t->dst, t->encap_fib_index, t->decap_fib_index); s = format (s, " decap next %U\n", format_decap_next, t->decap_next_index); s = format (s, "lisp ver %d ", (t->ver_res>>6)); #define _(n,v) if (t->flags & v) s = format (s, "%s-bit ", #n); foreach_lisp_gpe_flag_bit; #undef _ s = format (s, "next_protocol %d ver_res %x res %x\n", t->next_protocol, t->ver_res, t->res); s = format (s, "iid %d (0x%x)\n", t->vni, t->vni); return s; } static clib_error_t * show_lisp_gpe_tunnel_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { lisp_gpe_main_t * lgm = &lisp_gpe_main; lisp_gpe_tunnel_t * t; if (pool_elts (lgm->tunnels) == 0) vlib_cli_output (vm, "No lisp-gpe tunnels configured..."); pool_foreach (t, lgm->tunnels, ({ vlib_cli_output (vm, "%U", format_lisp_gpe_tunnel, t); })); return 0; } VLIB_CLI_COMMAND (show_lisp_gpe_tunnel_command, static) = { .path = "show lisp gpe tunnel", .function = show_lisp_gpe_tunnel_command_fn, }; u8 vnet_lisp_gpe_enable_disable_status(void) { lisp_gpe_main_t * lgm = &lisp_gpe_main; return lgm->is_en; } clib_error_t * vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t * a) { lisp_gpe_main_t * lgm = &lisp_gpe_main; vnet_main_t * vnm = lgm->vnet_main; if (a->is_en) { /* add lgpe_ip4_lookup as possible next_node for ip4 lookup */ if (lgm->ip4_lookup_next_lgpe_ip4_lookup == ~0) { lgm->ip4_lookup_next_lgpe_ip4_lookup = vlib_node_add_next ( vnm->vlib_main, ip4_lookup_node.index, lgpe_ip4_lookup_node.index); } /* add lgpe_ip6_lookup as possible next_node for ip6 lookup */ if (lgm->ip6_lookup_next_lgpe_ip6_lookup == ~0) { lgm->ip6_lookup_next_lgpe_ip6_lookup = vlib_node_add_next ( vnm->vlib_main, ip6_lookup_node.index, lgpe_ip6_lookup_node.index); } else { /* ask cp to re-add ifaces and defaults */ } lgm->is_en = 1; } else { CLIB_UNUSED(uword * val); hash_pair_t * p; u32 * table_ids = 0, * table_id; lisp_gpe_tunnel_key_t * tunnels = 0, * tunnel; vnet_lisp_gpe_add_del_fwd_entry_args_t _at, * at = &_at; vnet_lisp_gpe_add_del_iface_args_t _ai, * ai= &_ai; /* remove all tunnels */ mhash_foreach(tunnel, val, &lgm->lisp_gpe_tunnel_by_key, ({ vec_add1(tunnels, tunnel[0]); })); vec_foreach(tunnel, tunnels) { memset(at, 0, sizeof(at[0])); at->is_add = 0; gid_address_type(&at->deid) = GID_ADDR_IP_PREFIX; ip_prefix_copy(&gid_address_ippref(&at->deid), &tunnel->eid); ip_address_copy(&at->dlocator, &tunnel->dst_loc); vnet_lisp_gpe_add_del_fwd_entry (at, 0); } vec_free(tunnels); /* disable all ifaces */ hash_foreach_pair(p, lgm->lisp_gpe_hw_if_index_by_table_id, ({ vec_add1(table_ids, p->key); })); vec_foreach(table_id, table_ids) { ai->is_add = 0; ai->table_id = table_id[0]; /* disables interface and removes defaults */ vnet_lisp_gpe_add_del_iface(ai, 0); } vec_free(table_ids); lgm->is_en = 0; } return 0; } static clib_error_t * lisp_gpe_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { unformat_input_t _line_input, * line_input = &_line_input; u8 is_en = 1; vnet_lisp_gpe_enable_disable_args_t _a, * a = &_a; /* Get a line of input. */ if (! unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "enable")) is_en = 1; else if (unformat (line_input, "disable")) is_en = 0; else { return clib_error_return (0, "parse error: '%U'", format_unformat_error, line_input); } } a->is_en = is_en; return vnet_lisp_gpe_enable_disable (a); } VLIB_CLI_COMMAND (enable_disable_lisp_gpe_command, static) = { .path = "lisp gpe", .short_help = "lisp gpe [enable|disable]", .function = lisp_gpe_enable_disable_command_fn, }; static clib_error_t * lisp_show_iface_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { lisp_gpe_main_t * lgm = &lisp_gpe_main; hash_pair_t * p; vlib_cli_output (vm, "%=10s%=12s", "vrf", "hw_if_index"); hash_foreach_pair (p, lgm->lisp_gpe_hw_if_index_by_table_id, ({ vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]); })); return 0; } VLIB_CLI_COMMAND (lisp_show_iface_command) = { .path = "show lisp gpe interface", .short_help = "show lisp gpe interface", .function = lisp_show_iface_command_fn, }; clib_error_t * lisp_gpe_init (vlib_main_t *vm) { lisp_gpe_main_t * lgm = &lisp_gpe_main; clib_error_t * error = 0; if ((error = vlib_call_init_function (vm, ip_main_init))) return error; if ((error = vlib_call_init_function (vm, ip4_lookup_init))) return error; lgm->vnet_main = vnet_get_main(); lgm->vlib_main = vm; lgm->im4 = &ip4_main; lgm->im6 = &ip6_main; lgm->lm4 = &ip4_main.lookup_main; lgm->lm6 = &ip6_main.lookup_main; lgm->ip4_lookup_next_lgpe_ip4_lookup = ~0; lgm->ip6_lookup_next_lgpe_ip6_lookup = ~0; mhash_init (&lgm->lisp_gpe_tunnel_by_key, sizeof(uword), sizeof(lisp_gpe_tunnel_key_t)); udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe, lisp_gpe_ip4_input_node.index, 1 /* is_ip4 */); udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe6, lisp_gpe_ip6_input_node.index, 0 /* is_ip4 */); return 0; } u8 * format_vnet_lisp_gpe_status (u8 * s, va_list * args) { lisp_gpe_main_t * lgm = &lisp_gpe_main; return format (s, "%s", lgm->is_en ? "enabled" : "disabled"); } VLIB_INIT_FUNCTION(lisp_gpe_init);
muharif/vpp
vnet/vnet/lisp-gpe/lisp_gpe.c
C
apache-2.0
18,936
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2355, 26408, 1998, 1013, 2030, 2049, 18460, 1012, 1008, 30524, 1012, 1008, 2017, 2089, 6855, 1037, 6100, 1997, 1996, 6105, 2012, 1024, 1008, 1008, 8299, 1024, 1013, 1013, 7479, 1012, 15895, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.codepoetics.protonpack.selectors; import java.util.Comparator; import java.util.Objects; import java.util.stream.Stream; public final class Selectors { private Selectors() { } public static <T> Selector<T> roundRobin() { return new Selector<T>() { private int startIndex = 0; @Override public Integer apply(T[] options) { int result = startIndex; while (options[result] == null) { result = (result + 1) % options.length; } startIndex = (result + 1) % options.length; return result; } }; } public static <T extends Comparable<T>> Selector<T> takeMin() { return takeMin(Comparator.naturalOrder()); } public static <T> Selector<T> takeMin(Comparator<? super T> comparator) { return new Selector<T>() { private int startIndex = 0; @Override public Integer apply(T[] options) { T smallest = Stream.of(options).filter(Objects::nonNull).min(comparator).get(); int result = startIndex; while (options[result] == null || comparator.compare(smallest, options[result]) != 0) { result = (result + 1) % options.length; } startIndex = (result + 1) % options.length; return result; } }; } public static <T extends Comparable<T>> Selector<T> takeMax() { return takeMax(Comparator.naturalOrder()); } public static <T> Selector<T> takeMax(Comparator<? super T> comparator) { return takeMin(comparator.reversed()); } }
poetix/protonpack
src/main/java/com/codepoetics/protonpack/selectors/Selectors.java
Java
mit
1,740
[ 30522, 7427, 4012, 1012, 3642, 6873, 16530, 2015, 1012, 20843, 23947, 1012, 27000, 2015, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 4012, 28689, 4263, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 5200, 1025, 12324, 9262, 1012, 21183, 4014, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include <stdio.h> #include <iostream> using namespace std; int c[1001], n, m; bool ispos(int cap) { int sum = 0, cnt = 1; for (int i=0; i<n; i++) if ((sum+=c[i]) > cap) { sum = c[i]; if (++cnt > m) return false; } return true; } int main() { while (scanf("%d%d", &n, &m)==2) { int lo=0, hi=0; for (int i=0; i<n; i++) { scanf("%d", c+i); lo=max(lo, c[i]); hi+=c[i]; } while (lo <= hi) { int mid = (lo+hi)>>1; if (ispos(mid)) hi = mid-1; else lo = mid+1; } printf("%d\n", hi+1); } }
arash16/prays
UVA/vol-114/11413.cpp
C++
mit
713
[ 30522, 1001, 2421, 1026, 2358, 20617, 1012, 1044, 1028, 1001, 2421, 1026, 16380, 25379, 1028, 2478, 3415, 15327, 2358, 2094, 1025, 20014, 1039, 1031, 2531, 2487, 1033, 1010, 1050, 1010, 1049, 1025, 22017, 2140, 2003, 6873, 2015, 1006, 20014...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Mersenne Twister pseudo-random number generator functions. Copyright 2002, 2003, 2013, 2014 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. The GNU MP Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with the GNU MP Library. If not, see https://www.gnu.org/licenses/. */ #include "gmp-impl.h" #include "randmt.h" /* Calculate (b^e) mod (2^n-k) for e=1074888996, n=19937 and k=20023, needed by the seeding function below. */ static void mangle_seed (mpz_ptr r) { mpz_t t, b; unsigned long e = 0x40118124; unsigned long bit = 0x20000000; mpz_init2 (t, 19937L); mpz_init_set (b, r); do { mpz_mul (r, r, r); reduce: for (;;) { mpz_tdiv_q_2exp (t, r, 19937L); if (SIZ (t) == 0) break; mpz_tdiv_r_2exp (r, r, 19937L); mpz_addmul_ui (r, t, 20023L); } if ((e & bit) != 0) { e ^= bit; mpz_mul (r, r, b); goto reduce; } bit >>= 1; } while (bit != 0); mpz_clear (t); mpz_clear (b); } /* Seeding function. Uses powering modulo a non-Mersenne prime to obtain a permutation of the input seed space. The modulus is 2^19937-20023, which is probably prime. The power is 1074888996. In order to avoid seeds 0 and 1 generating invalid or strange output, the input seed is first manipulated as follows: seed1 = seed mod (2^19937-20027) + 2 so that seed1 lies between 2 and 2^19937-20026 inclusive. Then the powering is performed as follows: seed2 = (seed1^1074888996) mod (2^19937-20023) and then seed2 is used to bootstrap the buffer. This method aims to give guarantees that: a) seed2 will never be zero, b) seed2 will very seldom have a very low population of ones in its binary representation, and c) every seed between 0 and 2^19937-20028 (inclusive) will yield a different sequence. CAVEATS: The period of the seeding function is 2^19937-20027. This means that with seeds 2^19937-20027, 2^19937-20026, ... the exact same sequences are obtained as with seeds 0, 1, etc.; it also means that seed -1 produces the same sequence as seed 2^19937-20028, etc. */ static void randseed_mt (gmp_randstate_t rstate, mpz_srcptr seed) { int i; size_t cnt; gmp_rand_mt_struct *p; mpz_t mod; /* Modulus. */ mpz_t seed1; /* Intermediate result. */ p = (gmp_rand_mt_struct *) RNG_STATE (rstate); mpz_init2 (mod, 19938L); mpz_init2 (seed1, 19937L); mpz_setbit (mod, 19937L); mpz_sub_ui (mod, mod, 20027L); mpz_mod (seed1, seed, mod); /* Reduce `seed' modulo `mod'. */ mpz_clear (mod); mpz_add_ui (seed1, seed1, 2L); /* seed1 is now ready. */ mangle_seed (seed1); /* Perform the mangling by powering. */ /* Copy the last bit into bit 31 of mt[0] and clear it. */ p->mt[0] = (mpz_tstbit (seed1, 19936L) != 0) ? 0x80000000 : 0; mpz_clrbit (seed1, 19936L); /* Split seed1 into N-1 32-bit chunks. */ mpz_export (&p->mt[1], &cnt, -1, sizeof (p->mt[1]), 0, 8 * sizeof (p->mt[1]) - 32, seed1); mpz_clear (seed1); cnt++; ASSERT (cnt <= N); while (cnt < N) p->mt[cnt++] = 0; /* Warm the generator up if necessary. */ if (WARM_UP != 0) for (i = 0; i < WARM_UP / N; i++) __gmp_mt_recalc_buffer (p->mt); p->mti = WARM_UP % N; } static const gmp_randfnptr_t Mersenne_Twister_Generator = { randseed_mt, __gmp_randget_mt, __gmp_randclear_mt, __gmp_randiset_mt }; /* Initialize MT-specific data. */ void gmp_randinit_mt (gmp_randstate_t rstate) { __gmp_randinit_mt_noseed (rstate); RNG_FNPTR (rstate) = (void *) &Mersenne_Twister_Generator; }
alisw/GMP
rand/randmts.c
C
lgpl-3.0
4,482
[ 30522, 1013, 1008, 21442, 5054, 2638, 9792, 2121, 18404, 1011, 6721, 2193, 13103, 4972, 1012, 9385, 2526, 1010, 2494, 1010, 2286, 1010, 2297, 2489, 4007, 3192, 1010, 4297, 1012, 2023, 5371, 30524, 2003, 2489, 4007, 1025, 2017, 2064, 2417, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
"""import portalocker with portalocker.Lock('text.txt', timeout=5) as fh: fh.write("Sono in testLoxk2.py") """ from lockfile import LockFile lock = LockFile('text.txt') with lock: print lock.path, 'is locked.' with open('text.txt', "a") as file: file.write("Sono in testLock2.py")
giulioribe/car-pooling
testLock2.py
Python
gpl-3.0
303
[ 30522, 1000, 1000, 1000, 12324, 9445, 7432, 2121, 2007, 9445, 7432, 2121, 1012, 5843, 1006, 1005, 3793, 1012, 19067, 2102, 1005, 1010, 2051, 5833, 1027, 1019, 1007, 2004, 1042, 2232, 1024, 1042, 2232, 1012, 4339, 1006, 1000, 2365, 2080, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- title: Comment Section --- Sample comment section mblazonry can input to components. Elements can be added and removed easily. Base organism contains an icon+header section with text input and submit button.
JackGarrard/mblazonry_ARI
source/_patterns/02-organisms/activity window/comment-section.md
Markdown
mit
212
[ 30522, 1011, 1011, 1011, 2516, 1024, 7615, 2930, 1011, 1011, 1011, 7099, 7615, 2930, 16914, 2721, 11597, 2854, 2064, 7953, 2000, 6177, 1012, 3787, 2064, 2022, 2794, 1998, 3718, 4089, 1012, 30524, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: "Front-end" date: 2016-04-28 15:43:00 categories: bookmark tags: js regexp pattern css --- * content {:toc} * [JS 之正则表达式](http://www.cnblogs.com/changxiangyi/archive/2012/03/21/2409639.html) * [CSS如何工作](https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Getting_started/How_CSS_works)
levioZ/levioZ.github.io
_posts/2016-04-28-bookmark-front_end.md
Markdown
mit
341
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 2392, 1011, 2203, 1000, 3058, 1024, 2355, 1011, 5840, 1011, 2654, 2321, 1024, 4724, 1024, 4002, 7236, 1024, 2338, 10665, 22073, 1024, 1046, 2015, 19723, 10288, 2361, 5418, 20116, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
TITLE "INITDIR - Initialize disk directory for P2DOS Stamps" ;===========================================================================; ; I N I T D I R ; ;---------------------------------------------------------------------------; ; Copyright (C) 1988 by Harold F. Bower ; ;---------------------------------------------------------------------------; ; Derived from 2 Oct 86 Disassembly of INITDIR.COM provided with P2DOS ; ; ; ; Revision: ; ; 1.2 - 11 Apr 93 - Modified Header for ZCNFG24 configurability. HFB ; ; 1.1 - 7 Mar 89 - Added "Quiet" mode with ZCNFG configurability. HFB ; ; 1.0 - 16 Sep 88 - Release Version HFB ; ;===========================================================================; include darkstar.equ VERS EQU 12 ; Current version DATE MACRO DEFB ' 12 Apr 93' ENDM BASE EQU 0000H ; Base address of CP/M system BDOS EQU 0005H ; Bdos Call entry point FCB EQU 005CH ; Default CP/M File Control Block BUFF EQU 0080H ; Default CP/M buffer location SECSIZ EQU 128 ; Logical sector size IDLEN EQU 32 ; Length of Directory entry BELL EQU 07H BS EQU 08H TAB EQU 09H LF EQU 0AH CR EQU 0DH .Z80 CSEG ENTER: JP START ; Jump to execution DEFB 'Z3ENV' ; Dummy header, not used DEFB 1 Z3EADR: DEFW 0001H DEFW ENTER ; ..filler to Name field DEFB 'INITDIR ',0 ; Program name for ZCNFG ; Configuration file is INITDIR.CFG QUIET: DEFB 0FFH ; 0=Verbose, FF=Quiet START: LD (STACK),SP ; Save SP and set new stack LD SP,STACK LD DE,PROMPT ; Print opening banner CALL WRTLIN LD C,25 ; Get current logged drive CALL BDOS LD (DEFDRV),A ; Save entry drive LD HL,BUFF ; See if anything was entered LD B,(HL) ; Get char count to B INC B ; ..Precompensate for following dec LOOP1: DEC B ; Are we out of chars in input? JR Z,INTACT ; ..jump to interactive if so INC HL ; Advance to first char in args LD A,(HL) CP '/' ; Do we have Help request? JP Z,HELP ; ..jump if so CP ' ' ; Is it a Space? JR Z,LOOP1 ; ..jump to check next char if so CP TAB ; Is it a Tab char? JR Z,LOOP1 ; ..jump to check next char if so LD (EXPERT),A ; We have a character, save as flag CP 'A' ; Check for legal drive JR C,NGVCT ; ..Go error if Bad drive CP 'P'+1 JR C,OKDRV ; We have a valid drive letter, proceed NGVCT: JP NOGOOD ; ..else go to bad drive error exit INTACL: LD SP,STACK ; Reset the stack for next pass LD DE,MESG1 ; See if another drive is desired CALL WRTLIN LD DE,DPROM1 ; Print the Y/N part of prompt CALL WRTLIN CALL GETCH ; Get user response CP 'Y' ; Is it a "Y"? JP NZ,EXIT0 ; ..jump to exit if Not ;..else fall thru to do again.. CALL RSELEC ; Begin by resynchronizing drives CALL CRLF ; ..and clearing some space INTACT: XOR A ; Show that we are in Interactive mode LD (EXPERT),A ; ..by clearing flag LD HL,DRVNUM ; Clear variables for next pass LD B,STACK-DRVNUM ; ..for this many bytes CLRL: LD (HL),A INC HL DJNZ CLRL ; ..loop thru til done GETDRV: LD DE,MESG0 ; Ask user for drive letter CALL WRTLIN CALL GETCH ; ..and get letter in Uppercase CP 'A' ; Check for legal drive letter JR C,NODRV ; ..jump if < A CP 'P'+1 JR C,OKDRV ; ..jump if Not > P NODRV: LD DE,MESG2 ; Else Beep and erase the entry CALL WRTLIN JR GETDRV ; ..and loop til valid OKDRV: LD (DRVNUM),A ; Save drive letter LD A,(QUIET) ; Proceed w/o Confirmation prompt? OR A JR NZ,OKDRV0 ; ..jump if so LD DE,DPROMP ; Ask user to confirm drive CALL WRTLIN LD A,(DRVNUM) ; ..followed by the drive LD E,A LD C,2 CALL BDOS LD DE,DPROM0 ; Then print the end of the prompt CALL GETACT ; ..and get user response OKDRV0: LD A,(DRVNUM) ; Get the drive letter SUB 'A' ; ..and make binary PUSH AF ; Save drive for later LD E,A CALL LOGDOS ; Log onto the requested drive LD E,0 LD C,32 ; Log into User 0 CALL BDOS LD HL,TDFCB ; Initialize the FCB in case re-executing XOR A ; Use Null value LD (HL),A ; Set to current drive LD DE,12 ; Offset to EX ADD HL,DE LD B,24 ; Need 24 nulls here INITL: LD (HL),A INC HL DJNZ INITL ; ..loop til all done LD DE,TDFCB LD C,17 ; Is there a !!!TIME&.DAT file? CALL BDOS INC A ; Was it found? LD DE,EXMSG ; We found a time file, prompt for activity CALL NZ,GETACT ; ..go here if found and abort if not "Y" POP AF ; Get the drive back, and continue LD C,A CALL BSELDK ; Select the drive LD A,H ; DPH address returned in HL OR L JP Z,NOGOOD ; ..exit if can't log on LD E,(HL) ; Get skew table address in DE INC HL LD D,(HL) LD (SKWTBL),DE ; ..and save LD DE,9 ADD HL,DE ; Offset to DPB address LD E,(HL) ; ..and get it INC HL LD D,(HL) PUSH DE POP IX ; IX now points to DPB LD HL,RAMBUF LD D,(IX+08H) ; DIRMAX-1 to DE LD E,(IX+07H) INC DE ; make = DIRMAX LD (DIRMAX),DE ; ..and save SRL D ; Find # logical sctrs in directory RR E SRL D RR E LD (NDIRSC),DE ; ..and save LD BC,0 ; Enter: BC = Logical sector number ; DE = Number of directory sectors ; HL = Buffer address LD A,(QUIET) ; Do it quietly? OR A JR NZ,LODDIR ; ..jump if so PUSH HL ; Save the registers PUSH DE PUSH BC LD DE,TMSG1 ; Tell the user we are Reading CALL WRTLIN POP BC POP DE POP HL LODDIR: CALL RDBLOK ; Read a block of data PUSH DE LD DE,SECSIZ ADD HL,DE ; Increment DMA address POP DE INC BC ; Increment logical sector # EX DE,HL OR A SBC HL,BC ; See if we have read all ADD HL,BC EX DE,HL JR NZ,LODDIR ; ..loop until all directory read LD A,(RAMBUF+96) CP '!' ; Check for Time/Date marker JR NZ,INITIL ; ..jump if not set LD DE,ALREDY JP ABORT ; ..else exit with error message INITIL: LD HL,RAMBUF ; Count valid filenames in directory LD DE,(DIRMAX) LD BC,0 ; Start with count = 0 CNTLOP: LD A,(HL) CP 0E5H ; If not deleted file.. JR Z,NOCNT CP '!' ; ..or time/date file.. JR Z,NOCNT INC BC ; ..bump count NOCNT: LD A,L ADD A,IDLEN ; Increment to next entry LD L,A JR NC,LL0 INC H LL0: DEC DE ; Decrement file count LD A,D OR E JR NZ,CNTLOP ; Loop if more to go ; Entries * 4/3 = required space. Check for adequate space SLA C ; # Files * 4 RL B SLA C RL B LD DE,0 LL1: DEC BC ; Divide by 3 DEC BC DEC BC INC DE ; (count in DE) BIT 7,B ; ..quit when < 0 JR Z,LL1 LD HL,(DIRMAX) EX DE,HL OR A SBC HL,DE ; Check DIRMAX > required LD DE,NOSPAC JP NC,ABORT ; ..jump if Not Ok ; Initialize Date/Time buffer with date in format: ; 0 8 10 18 20H ; | | | | | ; !nnHMnnHM00nnHMnnHM00nnHMnnHM000 LD HL,DBUFFR ; Set initial Date/Time field LD (HL),'!' ; Date/Time flag INC HL LD B,3 ; Repeat 3 times LL2: PUSH BC EX DE,HL LD HL,DATTIM LD BC,4 ; Move Create date LDIR LD HL,DATTIM LD BC,4 ; ..and modified date LDIR EX DE,HL LD (HL),0 ; ..followed by 2 nulls INC HL LD (HL),0 INC HL POP BC DJNZ LL2 LD (HL),0 ; End with final null ; Move valid directory entries to default buffer and write ; them to disk 3 at a time with time & date added. LD A,(QUIET) ; Do it quietly? OR A JR NZ,WRT0 ; ..jump if so LD DE,TMSG2 ; Tell the User we are writing CALL WRTLIN WRT0: LD HL,RAMBUF LD DE,0 LD (SCWRTN),DE LD DE,(DIRMAX) LD C,3 WRTNAM: LD A,(HL) CP 0E5H JR Z,NOCNT1 CP '!' JR Z,NOCNT1 PUSH DE LD A,C ; Start with count/index ADD A,A ; ..shifted * 32 ADD A,A ADD A,A ADD A,A ADD A,A NEG ; Invert order ADD A,0E0H ; ..compensate LD E,A LD D,0 ; Now have addr in default buffer CALL MOVE32 DEC C JR NZ,WRTNA0 ; Loop if more LD DE,BUFF+96 ; When 3 moved.. PUSH HL LD HL,DBUFFR ; ..put date & time in last slot CALL MOVE32 CALL WRBLOK ; ..and write the sector LD C,3 ; Set up for 3 more POP HL ; ..restoring regs.. WRTNA0: POP DE JR WRTNA1 ; ..and re-enter loop NOCNT1: PUSH DE LD DE,IDLEN ADD HL,DE ; Increment by 32 for next entry POP DE WRTNA1: DEC DE ; Count down number of entries LD A,D OR E JR NZ,WRTNAM ; Loop til done with whole dir LD A,C ; See if final sector written CP 3 JR Z,L0316 ; Jump if just finished write LD DE,BUFF+96 PUSH HL LD HL,DBUFFR ; ..else move time & date CALL MOVE32 POP HL LD A,C ; Calculate next entry position ADD A,A ADD A,A ADD A,A ADD A,A ADD A,A NEG ADD A,0E0H LD L,A LD H,0 LD DE,BUFF+96 ; ..set ending position LL3: OR A SBC HL,DE ADD HL,DE JR Z,L0313 LD (HL),0E5H ; ..and fill unused w/delete marks INC HL JR LL3 L0313: CALL WRBLOK ; Write partial directory sector L0316: LD HL,(SCWRTN) LD DE,(NDIRSC) OR A SBC HL,DE ADD HL,DE ;1.2 JP Z,EXIT ; ..quit when done JR Z,WRLAST ;1.2 ..jump to clear buffer and exit when done LD HL,BUFF LD B,96 L0328: LD (HL),0E5H INC HL DJNZ L0328 EX DE,HL LD HL,DBUFFR LD BC,IDLEN LDIR ; Move 32 bytes CALL WRBLOK JR L0316 WRLAST: LD BC,0001 ;1.2 Force Directory write of current Sector CALL BWRIT ;1.2 .write it! JP EXIT ;1.2 ..and Quit NOGOOD: LD DE,BADDRV CALL WRTLIN ; Print Bad drive error HELP0: LD DE,HLPMSG JP ABORT ; Print Help message, relog drive and quit HELP: OR 0FFH ; If help request, show we're not interactive LD (EXPERT),A JR HELP0 ; ..and jump back to common code RDBLOK: PUSH BC PUSH DE PUSH HL LD HL,0 LD D,(IX+01H) ; Get Sectors/Track LD E,(IX+00H) LD A,16+1 L044A: OR A SBC HL,DE CCF JR C,L0452 ADD HL,DE OR A L0452: RL C ; Shift carry bits in to BC RL B DEC A JR Z,L045F ; ..exit when thru RL L ; Shift HL left RL H JR L044A L045F: PUSH HL LD H,(IX+0EH) ; Get track offset LD L,(IX+0DH) ADD HL,BC LD B,H ; Move current track to BC LD C,L CALL BSTTRK ; ..and set controller POP BC ; Restore logical sector LD DE,(SKWTBL) CALL BSKEW ; ..and get physical sector LD B,H LD C,L CALL BSTSEC ; Set the sector POP BC PUSH BC CALL BSTDMA ; Set transfer address CALL BREAD ; ..and read a sector OR A JR NZ,LODBAD ; Jump error if Error POP HL POP DE POP BC RET LODBAD: LD DE,RDERR JR ABORT WRBLOK: PUSH BC PUSH DE PUSH HL LD HL,0 LD BC,(SCWRTN) LD D,(IX+01H) ; Get Sectors/Track to DE LD E,(IX+00H) LD A,17 L04BF: OR A SBC HL,DE CCF JR C,L04C7 ADD HL,DE OR A L04C7: RL C RL B DEC A JR Z,L04D4 RL L RL H JR L04BF L04D4: PUSH HL LD H,(IX+0EH) ; Get track offset LD L,(IX+0DH) ADD HL,BC LD B,H LD C,L CALL BSTTRK POP BC LD DE,(SKWTBL) CALL BSKEW LD B,H LD C,L CALL BSTSEC LD BC,BUFF CALL BSTDMA ;1.2 LD BC,0001 ; Force a Directory Write LD BC,0000 ; No forced writes CALL BWRIT OR A JR Z,L0523 LD DE,WRTERR JR ABORT L0523: LD BC,(SCWRTN) INC BC LD (SCWRTN),BC POP HL POP DE POP BC RET RSELEC: LD A,(DEFDRV) ; Get entry drive from storage LD C,A ; ..set regs LD B,0 PUSH BC ; Save drive vector LD DE,0001H ; ..to login drive CALL BSELDK ; Do it via BIOS to sync POP DE ; Restore drive vector for Dos Call LOGDOS: LD C,14 ; ..and relog DOS JP BDOS ;..... ; Abort to DOS. Print message, resync and return gracefully ; ENTER: DE Points to error message ABORT: PUSH DE ; Save error address CALL RSELEC ; Re-Sync BIOS and BDOS POP DE CALL WRTLIN EXIT: LD A,(EXPERT) ; Get the Mode Flag OR A ; Are we Interactive? JP Z,INTACL ; ..jump if so EXIT0: LD SP,(STACK) ; Restore stack pointer RET ; ..and return ;..... ; Write a Carriage Return/Line Feed combination to Console CRLF: LD DE,CRLFM ; Point to CRLF string ;..and fall thru to write line ;..... ; Print message addressed in DE WRTLIN: LD C,9 ; Print error message JP BDOS ;..... ; Print message addressed in DE, and get character from operator ; Return with Zero Set (Z) if "Y" or "y", else abort GETACT: CALL WRTLIN LD DE,DPROM1 ; Print "Y/N" part of prompt CALL WRTLIN CALL GETCH ; Get console char in uppercase CP 'Y' RET Z ; ..or "Y" CALL RSELEC ; User entered No response, so reselect JR EXIT ; ..and quit ;..... ; Get char from Console in Uppercase via DOS call GETCH: LD C,1 ; Get console char command CALL BDOS CP 3 ; Is it a Control-C? JR Z,EXIT0 ; ..Quit here if so CP 'a' ; Is it less than "a"? RET C ; ..return if so CP 'z'+1 ; Is it Greater than "z"? RET NC ; ..return if so AND 5FH ; Else make uppercase RET ;..... ; Move 32 bytes from memory addressed by HL to that addressed by DE MOVE32: LD B,32 MOV32A: LD A,(HL) LD (DE),A INC HL INC DE DJNZ MOV32A RET ;----------------------------------------------- ; BIOS Vectors and interface ;----------------------------------------------- ; BSELDK: PUSH BC ; LD BC,18H ; JR GOBIOS ; ; BSTTRK: PUSH BC ; LD BC,1BH ; JR GOBIOS ; ; BSTSEC: PUSH BC ; LD BC,1EH ; JR GOBIOS ; ; BSTDMA: PUSH BC ; LD BC,21H ; JR GOBIOS ; ; BREAD: PUSH BC ; LD BC,24H ; JR GOBIOS ; ; BWRIT: PUSH BC ; LD BC,27H ; JR GOBIOS ; ; BSKEW: PUSH BC ; LD BC,2DH ; JR GOBIOS ; ; GOBIOS: EX (SP),HL ; PUSH HL ; LD HL,(BASE+1) ; ADD HL,BC ; POP BC ; EX (SP),HL ; RET BIOSCB: BCFFUN: DEFB 0 BCFA: DEFB 0 BCFBC: DEFW 0 BCFDE: DEFW 0 BCFHL: DEFW 0 BXFUN EQU 0 BXA EQU 1 BXBC EQU 2 BXDE EQU 4 BXHL EQU 6 BSELDK: PUSH IX LD (IX+BXFUN),9 LD (IX+BXBC),BC PUSH DE LD E,0 ; force login LD (IX+BXDE),DE POP DE CALL GOBIOS LD HL,(IX+BXHL) POP IX RET BSTTRK: PUSH IX LD (IX+BXFUN),10 LD (IX+BXBC),BC CALL GOBIOS POP IX RET BSTSEC: PUSH IX LD (IX+BXFUN),11 LD (IX+BXBC),BC CALL GOBIOS POP IX RET BSTDMA: PUSH IX LD (IX+BXFUN),12 LD (IX+BXBC),BC CALL GOBIOS POP IX RET BREAD: PUSH IX LD (IX+BXFUN),13 CALL GOBIOS LD A,(IX+BXA) POP IX RET BWRIT: PUSH IX LD (IX+BXFUN),14 CALL GOBIOS LD A,(IX+BXA) POP IX RET BSKEW: PUSH IX LD (IX+BXFUN),16 LD (IX+BXBC),BC LD (IX+BXDE),DE CALL GOBIOS LD HL,(IX+BXHL) POP IX RET GOBIOS: PUSH DE PUSH BC LD C,32 ; direct BIOS call LD DE,BIOSCB CALL BDOS POP BC POP DE RET ;..... ; System messages BADDRV: DEFB CR,LF,LF,BELL,'Illegal drive name$' ALREDY: DEFB CR,LF,BELL,'Directory already initialized$' NOSPAC: DEFB CR,LF,BELL,'Not enough directory space on disk$' PROMPT: DEFB CR,LF,'INITDIR Ver ',VERS/10+'0','.',VERS MOD 10 + '0' DATE DEFB CR,LF,'Custom version for Z80 Darkstar (NEZ80) by P. Betti 20141017' DEFB CR,LF,LF DEFB ' Initializing a Disk for P2DOS Date/Time Stamps which' DEFB ' already ',CR,LF DEFB ' contains files marked with DateStamper Stamps may ' DEFB 'invalidate',CR,LF DEFB ' the existing DateStamper Times and Dates!',CR,LF,'$' DPROMP: DEFB CR,LF,' Confirm Initialize Drive $' DPROM0: DEFB ': $' DPROM1: DEFB '(Y/[N]) : $' MESG0: DEFB CR,LF,LF,'Initialize which Disk for P2DOS Date/Time Stamps? : $' MESG1: DEFB CR,LF,LF,'Initialize another Disk? $' MESG2: DEFB BELL,BS,' ',BS,'$' RDERR: DEFB CR,LF,BELL,'Directory read error$' WRTERR: DEFB CR,LF,BELL,'Directory write error$' HLPMSG: DEFB CR,LF DEFB 'Usage: Prepare disk for CP/M-3 (P2DOS) style date/time' DEFB ' stamping',CR,LF,LF DEFB 'Syntax:',CR,LF DEFB ' INITDIR - Enter Interactive Mode',CR,LF DEFB ' INITDIR d: - Initialize drive "d"',CR,LF DEFB ' INITDIR // - Display this message',CR,LF,LF DEFB 'Note: ZCNFG may be used to configure a flag to suppress',CR,LF DEFB ' drive confirmation prompt and status messages',CR,LF,'$' CRLFM: DEFB CR,LF,'$' EXMSG: DEFB BELL,CR,LF,'--> DateStamper !!!TIME&.DAT File Found <--',CR,LF DEFB ' Proceed anyway $' TMSG1: DEFB CR,LF,'...Reading Directory Entries...$' TMSG2: DEFB CR,LF,'...Writing Initialized Directory...$' DBG1: DEFB CR,LF,'p1$' DBG2: DEFB CR,LF,'p2$' DBG3: DEFB CR,LF,'p3$' DBG4: DEFB CR,LF,'p4$' DBG5: DEFB CR,LF,'p5$' ;--------------------------------------------------------- ; D A T A A R E A ;--------------------------------------------------------- DATTIM: DEFB 0,0,0,0,0 ; Initial date value TDFCB: DEFB 0,'!!!TIME&DAT',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 DEFB 0,0,0,0 EXPERT: DEFS 1 ; Expert Flag (0=Expert, <>0=Interactive) DEFDRV: DEFS 1 ; Drive logged by Dos on Entry DRVNUM: DEFS 1 ; Storage for drive letter DIRMAX: DEFS 2 ; Number of directory entries on disk NDIRSC: DEFS 2 ; Number of directory sectors SCWRTN: DEFS 2 ; Number of sectors read/written SKWTBL: DEFS 2 ; Address of skew table DBUFFR: DEFS IDLEN ; 32-byte directory date/time buffer DEFS 80 ; Room for stack STACK: DEFS 2 ; Location to save entry stack pointer RAMBUF: ; Buffer starts here, goes up END
pbetti/ZDS
CPM3/tests/initdir.asm
Assembly
gpl-3.0
16,970
[ 30522, 2516, 1000, 1999, 4183, 4305, 2099, 1011, 3988, 4697, 9785, 14176, 2005, 1052, 2475, 12269, 12133, 1000, 1025, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module.exports = function(EmailAddress) { };
soltrinox/vator-api-dev
common/models/email-address.js
JavaScript
mit
46
[ 30522, 11336, 1012, 14338, 1027, 3853, 1006, 10373, 4215, 16200, 4757, 1007, 1063, 1065, 1025, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.marakana.android.fibonaccicommon; import android.os.Parcel; import android.os.Parcelable; public class FibonacciRequest implements Parcelable { public static enum Type { RECURSIVE_JAVA, ITERATIVE_JAVA, RECURSIVE_NATIVE, ITERATIVE_NATIVE } private long n; private Type type; public FibonacciRequest(long n, Type type) { this.n = n; if (type == null) { throw new NullPointerException("Type must not be null"); } this.type = type; } /** Constructors used implicitly with Parcelable */ public FibonacciRequest() { this.n = 0; this.type = Type.RECURSIVE_JAVA; } public FibonacciRequest(Parcel in) { readFromParcel(in); } /** Public Accessors */ public long getN() { return n; } public Type getType() { return type; } /** Explicit Parcelable Requirements */ public int describeContents() { return 0; } public void writeToParcel(Parcel parcel, int flags) { parcel.writeLong(this.n); parcel.writeInt(this.type.ordinal()); } /** Implicit Parcelable Requirements */ public void readFromParcel(Parcel in) { this.n = in.readLong(); this.type = Type.values()[in.readInt()]; } public static final Parcelable.Creator<FibonacciRequest> CREATOR = new Parcelable.Creator<FibonacciRequest>() { public FibonacciRequest createFromParcel(Parcel in) { return new FibonacciRequest(in); } public FibonacciRequest[] newArray(int size) { return new FibonacciRequest[size]; } }; }
xe1gyq/androidlearning
training/NewCircle/github/FibonacciBinderDemo/FibonacciCommon/src/com/marakana/android/fibonaccicommon/FibonacciRequest.java
Java
apache-2.0
1,464
[ 30522, 7427, 30524, 12324, 11924, 1012, 9808, 1012, 20463, 3085, 1025, 2270, 2465, 10882, 11735, 6305, 6895, 2890, 15500, 22164, 20463, 3085, 1063, 2270, 10763, 4372, 2819, 2828, 1063, 28667, 9236, 3512, 1035, 9262, 1010, 2009, 25284, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.nouribygi.masnavi.database; import android.app.SearchManager; import android.content.ContentProvider; import android.content.ContentResolver; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.net.Uri; import com.nouribygi.masnavi.util.MasnaviSettings; public class MasnaviDataProvider extends ContentProvider { public static String AUTHORITY = "com.nouribygi.masnavi.database.MasnaviDataProvider"; public static final Uri SEARCH_URI = Uri.parse("content://" + AUTHORITY + "/masnavi/search"); public static final String VERSES_MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd.com.nouribygi.masnavi"; public static final String AYAH_MIME_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd.com.nouribygi.masnavi"; // UriMatcher stuff private static final int SEARCH_VERSES = 0; private static final int GET_VERSE = 1; private static final int SEARCH_SUGGEST = 2; private static final UriMatcher sURIMatcher = buildUriMatcher(); private DatabaseHandler mDatabase = null; private static UriMatcher buildUriMatcher() { UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH); matcher.addURI(AUTHORITY, "masnavi/search", SEARCH_VERSES); matcher.addURI(AUTHORITY, "masnavi/search/*", SEARCH_VERSES); matcher.addURI(AUTHORITY, "masnavi/search/*/*", SEARCH_VERSES); matcher.addURI(AUTHORITY, "masnavi/verse/#/#", GET_VERSE); matcher.addURI(AUTHORITY, "masnavi/verse/*/#/#", GET_VERSE); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); return matcher; } @Override public boolean onCreate() { mDatabase = DatabaseHandler.getInstance(getContext()); return true; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { String query = ""; if (selectionArgs.length >= 1) query = selectionArgs[0]; int bookCode = MasnaviSettings.getSelectedBook(getContext()); return mDatabase.search(query, bookCode); } @Override public String getType(Uri uri) { switch (sURIMatcher.match(uri)) { case SEARCH_VERSES: return VERSES_MIME_TYPE; case GET_VERSE: return AYAH_MIME_TYPE; case SEARCH_SUGGEST: return SearchManager.SUGGEST_MIME_TYPE; default: throw new IllegalArgumentException("Unknown URL " + uri); } } @Override public Uri insert(Uri uri, ContentValues values) { throw new UnsupportedOperationException(); } @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { throw new UnsupportedOperationException(); } @Override public int delete(Uri uri, String selection, String[] selectionArgs) { throw new UnsupportedOperationException(); } }
nouribygi/Masnavi
app/src/main/java/com/nouribygi/masnavi/database/MasnaviDataProvider.java
Java
apache-2.0
3,332
[ 30522, 7427, 4012, 1012, 2053, 9496, 3762, 5856, 1012, 16137, 2532, 5737, 1012, 7809, 1025, 12324, 11924, 1012, 10439, 1012, 3945, 24805, 4590, 1025, 12324, 11924, 1012, 4180, 1012, 4180, 21572, 17258, 2121, 1025, 12324, 11924, 1012, 4180, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php class Printemps{ private static $colors=array( "balck" => "30", "red" => "31", "green" => "32", "yellow" => "33", "blue" => "34", "purple" => "35", "lblue" => "36", "gray" => "37", ); public static function Color($str,$color,$bg=0){ $code=self::$colors[$color]; return ($bg>0?"\033[$bg"."m":"")."\033[".$code."m $str \033[0m"; } }
face-orm/face-embryo
lib/Printemps.php
PHP
bsd-3-clause
468
[ 30522, 1026, 1029, 25718, 2465, 6140, 6633, 4523, 1063, 2797, 10763, 1002, 6087, 1027, 9140, 1006, 1000, 28352, 3600, 1000, 1027, 1028, 1000, 2382, 1000, 1010, 1000, 2417, 1000, 1027, 1028, 1000, 2861, 1000, 1010, 1000, 2665, 1000, 1027, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!-- BODY options, add following classes to body to change options // Footer options 1. 'footer-fixed' - Fixed footer --> <footer class="app-footer"> Version: <b>ALPHA.2018.05.21</b> © 2018 WYD. All rights reserved. <span class="float-right"> <a href="http://omfgdogs.com">About Us</a> </span> <span class="float-right"> <a href="changelog.html">Changelog</a> &nbsp;&nbsp;&nbsp; </span> </footer>
earphone/wydsodifficult.github.io
footer.html
HTML
mit
448
[ 30522, 1026, 999, 1011, 1011, 2303, 7047, 1010, 5587, 2206, 4280, 2000, 2303, 2000, 2689, 7047, 1013, 1013, 3329, 2121, 7047, 1015, 1012, 1005, 3329, 2121, 1011, 4964, 1005, 1011, 4964, 3329, 2121, 1011, 1011, 1028, 1026, 3329, 2121, 2465...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# message trace ---- ## 1. Message trace data's key properties | Producer End| Consumer End| Broker End| | --- | --- | --- | | produce message | consume message | message's topic | | send message time | delivery time, delivery rounds  | message store location | | whether the message was sent successfully | whether message was consumed successfully | message's key | | send cost-time | consume cost-time | message's tag value | ## 2. Enable message trace in cluster deployment ### 2.1 Broker's configuration file following by Broker's properties file configuration that enable message trace: ``` brokerClusterName=DefaultCluster brokerName=broker-a brokerId=0 deleteWhen=04 fileReservedTime=48 brokerRole=ASYNC_MASTER flushDiskType=ASYNC_FLUSH storePathRootDir=/data/rocketmq/rootdir-a-m storePathCommitLog=/data/rocketmq/commitlog-a-m autoCreateSubscriptionGroup=true ## if msg tracing is open,the flag will be true traceTopicEnable=true listenPort=10911 brokerIP1=XX.XX.XX.XX1 namesrvAddr=XX.XX.XX.XX:9876 ``` ### 2.2 Common mode Each Broker node in RocketMQ cluster used for storing message trace data that client collected and sent. So, there is no requirements and limitations to the size of Broker node in RocketMQ cluster. ### 2.3 IO physical isolation mode For huge amounts of message trace data scenario, we can select any one Broker node in RocketMQ cluster used for storing message trace data special, thus, common message data's IO are isolated from message trace data's IO in physical, not impact each other. In this mode, RocketMQ cluster must have at least two Broker nodes, the one that defined as storing message trace data. ### 2.4 Start Broker that enable message trace `nohup sh mqbroker -c ../conf/2m-noslave/broker-a.properties &` ## 3. Save the definition of topic that with support message trace RocketMQ's message trace feature supports two types of storage. ### 3.1 System level TraceTopic Be default, message trace data is stored in system level TraceTopic(topic name: **RMQ_SYS_TRACE_TOPIC**). That topic will be created at startup of broker(As mentioned above, set **traceTopicEnable** to **true** in Broker's configuration). ### 3.2 User defined TraceTopic If user don't want to store message trace data in system level TraceTopic, he can create user defined TraceTopic used for storing message trace data(that is, create common topic for storing message trace data). The following part will introduce how client SDK support user defined TraceTopic. ## 4. Client SDK demo with message trace feature For business system adapting to use RocketMQ's message trace feature easily, in design phase, the author add a switch parameter(**enableMsgTrace**) for enable message trace; add a custom parameter(**customizedTraceTopic**) for user defined TraceTopic. ### 4.1 Enable message trace when sending messages ``` DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName",true); producer.setNamesrvAddr("XX.XX.XX.XX1"); producer.start(); try { { Message msg = new Message("TopicTest", "TagA", "OrderID188", "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.send(msg); System.out.printf("%s%n", sendResult); } } catch (Exception e) { e.printStackTrace(); } ``` ### 4.2 Enable message trace when subscribe messages ``` DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1",true); consumer.subscribe("TopicTest", "*"); consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.setConsumeTimestamp("20181109221800"); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) { System.out.printf("%s Receive New Messages: %s %n", Thread.currentThread().getName(), msgs); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } }); consumer.start(); System.out.printf("Consumer Started.%n"); ``` ### 4.3 Self-defined topic support message trace Adjusting instantiation of DefaultMQProducer and DefaultMQPushConsumer as following code to support user defined TraceTopic. ``` ##Topic_test11111 should be created by user, used for storing message trace data. DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName",true,"Topic_test11111"); ...... DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1",true,"Topic_test11111"); ...... ```
Vansee/RocketMQ
docs/en/msg_trace/user_guide.md
Markdown
apache-2.0
4,842
[ 30522, 1001, 4471, 7637, 1011, 1011, 1011, 1011, 1001, 1001, 1015, 1012, 4471, 7637, 2951, 1005, 1055, 3145, 5144, 1064, 3135, 2203, 1064, 7325, 2203, 1064, 20138, 2203, 1064, 1064, 1011, 1011, 1011, 1064, 1011, 1011, 1011, 1064, 1011, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * MtMail - e-mail module for Zend Framework * * @link http://github.com/mtymek/MtMail * @copyright Copyright (c) 2013-2017 Mateusz Tymek * @license BSD 2-Clause */ namespace MtMail\Factory; use Interop\Container\ContainerInterface; use MtMail\ComposerPlugin\DefaultHeaders; class DefaultHeadersPluginFactory { public function __invoke(ContainerInterface $serviceLocator) { if (!method_exists($serviceLocator, 'configure')) { $serviceLocator = $serviceLocator->getServiceLocator(); } $config = $serviceLocator->get('Configuration'); $plugin = new DefaultHeaders(); if (isset($config['mt_mail']['default_headers'])) { $plugin->setHeaders($config['mt_mail']['default_headers']); } return $plugin; } }
mtymek/MtMail
src/Factory/DefaultHeadersPluginFactory.php
PHP
bsd-2-clause
817
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 11047, 21397, 1011, 1041, 1011, 5653, 11336, 2005, 16729, 2094, 7705, 1008, 1008, 1030, 4957, 8299, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 11047, 25219, 2243, 1013, 11047, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.github.ysl3000.quantum.impl; import com.github.ysl3000.quantum.QuantumConnectors; import com.github.ysl3000.quantum.impl.circuits.CircuitManager; import com.github.ysl3000.quantum.impl.utils.MessageLogger; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; public class ConfigConverter { private QuantumConnectors plugin; private MessageLogger messageLogger; public ConfigConverter(QuantumConnectors plugin, MessageLogger messageLogger) { this.plugin = plugin; this.messageLogger = messageLogger; } //1.2.3 circuits.yml Converter public void convertOldCircuitsYml() { File oldYmlFile = new File(plugin.getDataFolder(), "circuits.yml"); if (oldYmlFile.exists()) { messageLogger.log(messageLogger.getMessage("found_old_file").replace("%file%", oldYmlFile.getName())); FileConfiguration oldYml = YamlConfiguration.loadConfiguration(oldYmlFile); for (String worldName : oldYml.getValues(false).keySet()) { ArrayList<Map<String, Object>> tempCircuitObjs = new ArrayList<>(); for (int x = 0; ; x++) { String path = worldName + ".circuit_" + x; if (oldYml.get(path) == null) { break; } Map<String, Object> tempCircuitObj = new HashMap<String, Object>(); String[] senderXYZ = oldYml.get(path + ".sender").toString().split(","); tempCircuitObj.put("x", Integer.parseInt(senderXYZ[0])); tempCircuitObj.put("y", Integer.parseInt(senderXYZ[1])); tempCircuitObj.put("z", Integer.parseInt(senderXYZ[2])); //they'll all be the same, should only ever be one anyway String receiversType = oldYml.get(path + ".type").toString(); ArrayList<Map<String, Object>> tempReceiverObjs = new ArrayList<Map<String, Object>>(); for (Object receiver : oldYml.getList(path + ".receivers")) { Map<String, Object> tempReceiverObj = new HashMap<String, Object>(); String[] sReceiverLoc = receiver.toString().split(","); tempReceiverObj.put("x", Integer.parseInt(sReceiverLoc[0])); tempReceiverObj.put("y", Integer.parseInt(sReceiverLoc[1])); tempReceiverObj.put("z", Integer.parseInt(sReceiverLoc[2])); tempReceiverObj.put("d", 0); tempReceiverObj.put("t", Integer.parseInt(receiversType)); tempReceiverObjs.add(tempReceiverObj); } tempCircuitObj.put("r", tempReceiverObjs); tempCircuitObjs.add(tempCircuitObj); } File newYmlFile = new File(plugin.getDataFolder(), worldName + ".circuits.yml"); FileConfiguration newYml = YamlConfiguration.loadConfiguration(newYmlFile); newYml.set("fileVersion", 2); newYml.set("circuits", tempCircuitObjs); try { newYml.save(newYmlFile); } catch (IOException ex) { messageLogger.error(messageLogger.getMessage("unable_to_save").replace("%file%", newYmlFile.getName())); Logger.getLogger(CircuitManager.class.getName()).log(Level.SEVERE, null, ex); } } File testFile = new File(plugin.getDataFolder(), "circuits.yml.bak"); new File(plugin.getDataFolder(), "circuits.yml").renameTo(testFile); } } }
ysl3000/Quantum-Connectors
QuantumPlugin/src/main/java/com/github/ysl3000/quantum/impl/ConfigConverter.java
Java
mit
3,964
[ 30522, 7427, 4012, 1012, 21025, 2705, 12083, 1012, 1061, 14540, 14142, 8889, 1012, 8559, 1012, 17727, 2140, 1025, 12324, 4012, 1012, 21025, 2705, 12083, 1012, 1061, 14540, 14142, 8889, 1012, 8559, 1012, 8559, 8663, 2638, 24817, 1025, 12324, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Bigbank\Gcm; /** * Gcm response parser */ class Response { /** * Unique ID (number) identifying the multicast message. * * @var integer */ private $multicastId = null; /** * Unique id identifying the single message. * * Only have value if single or topic message is sent to google * * @var int */ private $messageId = null; /** * Number of messages that were processed without an error. * * @var integer */ private $success = null; /** * Number of messages that could not be processed. * * @var integer */ private $failure = null; /** * Number of results that contain a canonical registration ID. * * @var integer */ private $canonicalIds = null; /** * Holds single message error * * @var string */ private $error = null; /** * Array of objects representing the status of the messages processed. * The objects are listed in the same order as the request * (i.e., for each registration ID in the request, its result is listed in the same index in the response) * and they can have these fields: * message_id: String representing the message when it was successfully processed. * registration_id: If set, means that GCM processed the message but it has another canonical * registration ID for that device, so sender should replace the IDs on future requests * (otherwise they might be rejected). This field is never set if there is an error in the request. * error: String describing an error that occurred while processing the message for that recipient. * The possible values are the same as documented in the above table, plus "Unavailable" * (meaning GCM servers were busy and could not process the message for that particular recipient, * so it could be retried). * * @var array */ private $results = []; /** * @param Message $message * @param string $responseBody json string of google cloud message server response * * @throws Exception */ public function __construct(Message $message, $responseBody) { $data = \json_decode($responseBody, true); if ($data === null) { throw new Exception("Malformed response body. " . $responseBody, Exception::MALFORMED_RESPONSE); } if (!$data['error']) { $this->messageId = (isset($data['message_id'])) ? $data['message_id'] : null; $this->multicastId = $data['multicast_id']; $this->failure = $data['failure']; $this->success = (!$this->multicastId) ? 1 : $data['success']; $this->canonicalIds = $data['canonical_ids']; $this->results = []; $this->parseResults($message, $data); } else { $this->error = $data['error']; $this->messageId = (isset($data['message_id'])) ? $data['message_id'] : null; $this->failure = (!isset($data['failure'])) ? 1 : $data['failure']; } } /** * @return int */ public function getMulticastId() { return $this->multicastId; } /** * @return int|null */ public function getMessageId() { return $this->messageId; } /** * @return int */ public function getSuccessCount() { return $this->success; } /** * @return int */ public function getFailureCount() { return $this->failure; } /** * @return int */ public function getNewRegistrationIdsCount() { return $this->canonicalIds; } /** * @return array */ public function getResults() { return $this->results; } /** * @return string */ public function getError() { return $this->error; } /** * Return an array of expired registration ids linked to new id * All old registration ids must be updated to new ones in DB * * @return array oldRegistrationId => newRegistrationId */ public function getNewRegistrationIds() { if ($this->getNewRegistrationIdsCount() == 0) { return []; } $filteredResults = array_filter($this->results, function ($result) { return isset($result['registration_id']); }); $data = array_map(function ($result) { return $result['registration_id']; }, $filteredResults); return $data; } /** * Returns an array containing invalid registration ids * They must be removed from DB because the application was uninstalled from the device. * * @return array */ public function getInvalidRegistrationIds() { if ($this->getFailureCount() == 0) { return []; } $filteredResults = array_filter($this->results, function ($result) { return ( isset($result['error']) && ( ($result['error'] == "NotRegistered") || ($result['error'] == "InvalidRegistration") ) ); }); return array_keys($filteredResults); } /** * Returns an array of registration ids for which you must resend a message, * cause devices are not available now. * * @return array */ public function getUnavailableRegistrationIds() { if ($this->getFailureCount() == 0) { return []; } $filteredResults = array_filter($this->results, function ($result) { return ( isset($result['error']) && ($result['error'] == "Unavailable") ); }); return array_keys($filteredResults); } /** * Parse result array with correct data * * @param Message $message * @param array $response */ private function parseResults(Message $message, array $response) { if (is_array($message->getRecipients())) { foreach ($message->getRecipients() as $key => $registrationId) { $this->results[$registrationId] = $response['results'][$key]; } } else { $this->results[$message->getRecipients()] = $response['results']; } } }
bigbank-as/GCM
src/Bigbank/Gcm/Response.php
PHP
apache-2.0
6,729
[ 30522, 1026, 1029, 25718, 3415, 15327, 2502, 9299, 1032, 1043, 27487, 1025, 1013, 1008, 1008, 1008, 1043, 27487, 3433, 11968, 8043, 1008, 1013, 2465, 3433, 1063, 1013, 1008, 1008, 1008, 4310, 8909, 1006, 2193, 1007, 12151, 1996, 4800, 10526...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/// bedrock/main.cpp /// ================= /// Process entry point for Bedrock server. /// #include <dlfcn.h> #include <iostream> #include <signal.h> #include <sys/resource.h> #include <sys/stat.h> #include <bedrockVersion.h> #include <BedrockServer.h> #include <BedrockPlugin.h> #include <plugins/Cache.h> #include <plugins/DB.h> #include <plugins/Jobs.h> #include <plugins/MySQL.h> #include <libstuff/libstuff.h> #include <sqlitecluster/SQLite.h> ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void RetrySystem(const string& command) { // We might be waiting for some threads to unlink, so retry a few times int numRetries = 3; SINFO("Trying to run '" << command << "' up to " << numRetries << " times..."); while (numRetries--) { // Try it and see if it works int returnCode = system(command.c_str()); if (returnCode) { // Didn't work SWARN("'" << command << "' failed with return code " << returnCode << ", waiting 5s and retrying " << numRetries << " more times"); this_thread::sleep_for(chrono::seconds(5)); } else { // Done! SINFO("Successfully ran '" << command << "'"); return; } } // Didn't work -- fatal error SERROR("Failed to run '" << command << "', aborting."); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void VacuumDB(const string& db) { RetrySystem("sqlite3 " + db + " 'VACUUM;'"); } ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// #define BACKUP_DIR "/var/tmp/" void BackupDB(const string& dbPath) { const string& dbFile = string(basename((char*)dbPath.c_str())); SINFO("Starting " << dbFile << " database backup."); SASSERT(SFileCopy(dbPath, BACKUP_DIR + dbFile)); SINFO("Finished " << dbFile << " database backup."); const string& dbWalPath = dbPath + "-wal"; SINFO("Checking for existence of " << dbWalPath); if (SFileExists(dbWalPath)) { SALERT("WAL file exists for " << dbFile << ". Backing up"); SASSERT(SFileCopy(dbWalPath, BACKUP_DIR + string(basename((char*)dbWalPath.c_str())))); SINFO("Finished " << dbFile << "-wal database backup."); } const string& dbShmPath = dbPath + "-shm"; SINFO("Checking for existence of " << dbShmPath); if (SFileExists(dbShmPath)) { SALERT("SHM file exists for " << dbFile << ". Backing up"); SASSERT(SFileCopy(dbShmPath, BACKUP_DIR + string(basename((char*)dbShmPath.c_str())))); SINFO("Finished " << dbFile << "-shm database backup."); } } set<string> loadPlugins(SData& args) { list<string> plugins = SParseList(args["-plugins"]); // We'll return the names of the plugins we've loaded, which don't necessarily match the file names we're passed. // Those are stored here. set <string> postProcessedNames; // Register all of our built-in plugins. BedrockPlugin::g_registeredPluginList.emplace(make_pair("DB", [](BedrockServer& s){return new BedrockPlugin_DB(s);})); BedrockPlugin::g_registeredPluginList.emplace(make_pair("JOBS", [](BedrockServer& s){return new BedrockPlugin_Jobs(s);})); BedrockPlugin::g_registeredPluginList.emplace(make_pair("CACHE", [](BedrockServer& s){return new BedrockPlugin_Cache(s);})); BedrockPlugin::g_registeredPluginList.emplace(make_pair("MYSQL", [](BedrockServer& s){return new BedrockPlugin_MySQL(s);})); for (string pluginName : plugins) { // If it's one of our standard plugins, just move on to the next one. if (BedrockPlugin::g_registeredPluginList.find(SToUpper(pluginName)) != BedrockPlugin::g_registeredPluginList.end()) { postProcessedNames.emplace(SToUpper(pluginName)); continue; } // Any non-standard plugin is loaded from a shared library. If a name is passed without a trailing '.so', we // will add it, and look for a file with that name. A file should be passed with either a complete absolute // path, or the file should exist in a place that dlopen() can find it (like, /usr/lib). // We look for the 'base name' of the plugin. I.e., the filename excluding a path or extension. We'll look for // a symbol based on this name to call to instantiate our plugin. size_t slash = pluginName.rfind('/'); size_t dot = pluginName.find('.', slash); string name = pluginName.substr(slash + 1, dot - slash - 1); string symbolName = "BEDROCK_PLUGIN_REGISTER_" + SToUpper(name); // Save the base name of the plugin. if(postProcessedNames.find(SToUpper(name)) != postProcessedNames.end()) { SWARN("Duplicate entry for plugin " << name << ", skipping."); continue; } postProcessedNames.insert(SToUpper(name)); // Add the file extension if it's missing. if (!SEndsWith(pluginName, ".so")) { pluginName += ".so"; } // Open the library. void* lib = dlopen(pluginName.c_str(), RTLD_NOW); if(!lib) { SWARN("Error loading bedrock plugin " << pluginName << ": " << dlerror()); } else { void* sym = dlsym(lib, symbolName.c_str()); if (!sym) { SWARN("Couldn't find symbol " << symbolName); } else { // Call the plugin registration function with the same name. BedrockPlugin::g_registeredPluginList.emplace(make_pair(SToUpper(name), (BedrockPlugin*(*)(BedrockServer&))sym)); } } } return postProcessedNames; } ///////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { // Process the command line SData args = SParseCommandLine(argc, argv); if (args.empty()) { // It's valid to run bedrock with no parameters provided, but unusual // -- let's provide some help just in case cout << "Protip: check syslog for details, or run 'bedrock -?' for help" << endl; } // Initialize the sqlite library before any other code has a chance to do anything with it. // Set the logging callback for sqlite errors. SASSERT(sqlite3_config(SQLITE_CONFIG_LOG, SQLite::_sqliteLogCallback, 0) == SQLITE_OK); // Enable memory-mapped files. int64_t mmapSizeGB = args.isSet("-mmapSizeGB") ? stoll(args["-mmapSizeGB"]) : 0; if (mmapSizeGB) { SINFO("Enabling Memory-Mapped I/O with " << mmapSizeGB << " GB."); const int64_t GB = 1024 * 1024 * 1024; SASSERT(sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, mmapSizeGB * GB, 16 * 1024 * GB) == SQLITE_OK); // Max is 16TB } // Disable a mutex around `malloc`, which is *EXTREMELY IMPORTANT* for multi-threaded performance. Without this // setting, all reads are essentially single-threaded as they'll all fight with each other for this mutex. SASSERT(sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0) == SQLITE_OK); sqlite3_initialize(); SASSERT(sqlite3_threadsafe()); // Disabled by default, but lets really beat it in. This way checkpointing does not need to wait on locks // created in this thread. SASSERT(sqlite3_enable_shared_cache(0) == SQLITE_OK); // Fork if requested if (args.isSet("-fork")) { // Do the fork int pid = fork(); SASSERT(pid >= 0); if (pid > 0) { // Successful fork -- write the pidfile (if requested) and exit if (args.isSet("-pidfile")) SASSERT(SFileSave(args["-pidfile"], SToStr(pid))); return 0; } // Daemonize // **NOTE: See http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize umask(0); SASSERT(setsid() >= 0); SASSERT(chdir("/") >= 0); if (!freopen("/dev/null", "r", stdin) || !freopen("/dev/null", "w", stdout) || !freopen("/dev/null", "w", stderr) ) { cout << "Couldn't daemonize." << endl; return -1; } } if (args.isSet("-version")) { // Just output the version cout << VERSION << endl; return 0; } if (args.isSet("-h") || args.isSet("-?") || args.isSet("-help")) { // Ouput very basic documentation cout << "Usage:" << endl; cout << "------" << endl; cout << "bedrock [-? | -h | -help]" << endl; cout << "bedrock -version" << endl; cout << "bedrock [-clean] [-v] [-db <filename>] [-serverHost <host:port>] [-nodeHost <host:port>] [-nodeName " "<name>] [-peerList <list>] [-priority <value>] [-plugins <list>] [-cacheSize <kb>] [-workerThreads <#>] " "[-versionOverride <version>]" << endl; cout << endl; cout << "Common Commands:" << endl; cout << "----------------" << endl; cout << "-?, -h, -help Outputs instructions and exits" << endl; cout << "-version Outputs version and exits" << endl; cout << "-v Enables verbose logging" << endl; cout << "-q Enables quiet logging" << endl; cout << "-clean Recreate a new database from scratch" << endl; cout << "-enableMultiWrite Enable multi-write mode (default: true)" << endl; cout << "-versionOverride <version> Pretends to be a different version when talking to peers" << endl; cout << "-db <filename> Use a database with the given name (default 'bedrock.db')" << endl; cout << "-serverHost <host:port> Listen on this host:port for cluster connections (default 'localhost:8888')" << endl; cout << "-nodeName <name> Name this specfic node in the cluster as indicated (defaults to '" << SGetHostName() << "')" << endl; cout << "-nodeHost <host:port> Listen on this host:port for connections from other nodes" << endl; cout << "-peerList <list> See below" << endl; cout << "-priority <value> See '-peerList Details' below (defaults to 100)" << endl; cout << "-plugins <list> Enable these plugins (defaults to 'db,jobs,cache,mysql')" << endl; cout << "-cacheSize <kb> number of KB to allocate for a page cache (defaults to 1GB)" << endl; cout << "-workerThreads <#> Number of worker threads to start (min 1, defaults to # of cores)" << endl; cout << "-queryLog <filename> Set the query log filename (default 'queryLog.csv', SIGUSR2/SIGQUIT to " "enable/disable)" << endl; cout << "-maxJournalSize <#commits> Number of commits to retain in the historical journal (default 1000000)" << endl; cout << "-synchronous <value> Set the PRAGMA schema.synchronous " "(defaults see https://sqlite.org/pragma.html#pragma_synchronous)" << endl; cout << endl; cout << "Quick Start Tips:" << endl; cout << "-----------------" << endl; cout << "In a hurry? Just run 'bedrock -clean' the first time, and it'll create a new database called " "'bedrock.db', then use all the defaults listed above. (After the first time, leave out the '-clean' " "to reuse the same database.) Once running, you can verify it's working using NetCat to manualy send " "a Ping request as follows:" << endl; cout << endl; cout << "$ bedrock -clean &" << endl; cout << "$ nc local 8888" << endl; cout << "Ping" << endl; cout << endl; cout << "200 OK" << endl; cout << endl; cout << "-peerList Details:" << endl; cout << "------------------" << endl; cout << "The -peerList parameter enables you to configure multiple Bedrock nodes into a redundant cluster. " "Bedrock supports any number of nodes: simply start each node with a comma-separated list of the " "'-nodeHost' of all other nodes. You can safely send any command to any node. Some best practices:" << endl; cout << endl; cout << "- Put each Bedrock node on a different server." << endl; cout << endl; cout << "- Assign each node a different priority (greater than 0). The highest priority node will be the " "'leader', which will coordinate distributed transactions." << endl; cout << endl; return 1; } // Start libstuff. Generally, we want to initialize libstuff immediately on any new thread, but we wait until after // the `fork` above has completed, as we can get strange behaviors from signal handlers across forked processes. SInitialize("main", (args.isSet("-overrideProcessName") ? args["-overrideProcessName"].c_str() : 0)); SLogLevel(LOG_INFO); if (args.isSet("-v")) { // Verbose logging SINFO("Enabling verbose logging"); SLogLevel(LOG_DEBUG); } else if (args.isSet("-q")) { // Quiet logging SLogLevel(LOG_WARNING); } // Set the defaults #define SETDEFAULT(_NAME_, _VAL_) \ do { \ if (!args.isSet(_NAME_)) \ args[_NAME_] = _VAL_; \ } while (false) SETDEFAULT("-db", "bedrock.db"); SETDEFAULT("-serverHost", "localhost:8888"); SETDEFAULT("-nodeHost", "localhost:8889"); SETDEFAULT("-commandPortPrivate", "localhost:8890"); SETDEFAULT("-controlPort", "localhost:9999"); SETDEFAULT("-nodeName", SGetHostName()); SETDEFAULT("-cacheSize", SToStr(1024 * 1024)); // 1024 * 1024KB = 1GB. SETDEFAULT("-plugins", "db,jobs,cache,mysql"); SETDEFAULT("-priority", "100"); SETDEFAULT("-maxJournalSize", "1000000"); SETDEFAULT("-queryLog", "queryLog.csv"); SETDEFAULT("-enableMultiWrite", "true"); args["-plugins"] = SComposeList(loadPlugins(args)); // Reset the database if requested if (args.isSet("-clean")) { // Remove it SDEBUG("Resetting database"); string db = args["-db"]; unlink(db.c_str()); } else if (args.isSet("-bootstrap")) { // Allow for bootstraping a node with no database file in place. SINFO("Loading in bootstrap mode, skipping check for database existance."); } else { // Otherwise verify the database exists SDEBUG("Verifying database exists"); SASSERT(SFileExists(args["-db"])); } // Set our soft limit to the same as our hard limit to allow for more file handles. struct rlimit limits; if (!getrlimit(RLIMIT_NOFILE, &limits)) { limits.rlim_cur = limits.rlim_max; if (setrlimit(RLIMIT_NOFILE, &limits)) { SERROR("Couldn't set FD limit"); } } else { SERROR("Couldn't get FD limit"); } // Log stack traces if we have unhandled exceptions. set_terminate(STerminateHandler); // Create our BedrockServer object so we can keep it for the life of the // program. SINFO("Starting bedrock server"); BedrockServer* _server = new BedrockServer(args); BedrockServer& server = *_server; // Keep going until someone kills it (either via TERM or Control^C) while (!(SGetSignal(SIGTERM) || SGetSignal(SIGINT))) { if (SGetSignals()) { // Log and clear any outstanding signals. SALERT("Uncaught signals (" << SGetSignalDescription() << "), ignoring."); SClearSignals(); } // Counters for seeing how long we spend in postPoll. chrono::steady_clock::duration pollCounter(0); chrono::steady_clock::duration postPollCounter(0); chrono::steady_clock::time_point start = chrono::steady_clock::now(); uint64_t nextActivity = STimeNow(); while (!server.shutdownComplete()) { if (server.shouldBackup() && server.isDetached()) { BackupDB(args["-db"]); server.setDetach(false); } // Wait and process fd_map fdm; server.prePoll(fdm); const uint64_t now = STimeNow(); auto timeBeforePoll = chrono::steady_clock::now(); S_poll(fdm, max(nextActivity, now) - now); nextActivity = STimeNow() + STIME_US_PER_S; // 1s max period auto timeAfterPoll = chrono::steady_clock::now(); server.postPoll(fdm, nextActivity); auto timeAfterPostPoll = chrono::steady_clock::now(); pollCounter += timeAfterPoll - timeBeforePoll; postPollCounter += timeAfterPostPoll - timeAfterPoll; // Every 10s, log and reset. if (timeAfterPostPoll > (start + 10s)) { SINFO("[performance] main poll loop timing: " << chrono::duration_cast<chrono::milliseconds>(timeAfterPostPoll - start).count() << " ms elapsed. " << chrono::duration_cast<chrono::milliseconds>(pollCounter).count() << " ms in poll. " << chrono::duration_cast<chrono::milliseconds>(postPollCounter).count() << " ms in postPoll."); pollCounter = chrono::microseconds::zero(); postPollCounter = chrono::microseconds::zero(); start = timeAfterPostPoll; } } if (server.shutdownWhileDetached) { // We need to actually shut down here. break; } } SINFO("Deleting BedrockServer"); delete _server; SINFO("BedrockServer deleted"); // Finished with our signal handler. SStopSignalThread(); // All done SINFO("Graceful process shutdown complete"); return 0; }
Expensify/Bedrock
main.cpp
C++
lgpl-3.0
18,498
[ 30522, 1013, 1013, 1013, 28272, 1013, 2364, 1012, 18133, 2361, 1013, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1013, 1013, 1013, 2832, 4443, 2391, 2005, 28272, 8241, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Firstfilerepository First Assignment
sheikh1994/Firstfilerepository
README.md
Markdown
apache-2.0
39
[ 30522, 1001, 2034, 8873, 3917, 13699, 20049, 7062, 2034, 8775, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#! /usr/bin/php <?php /** * @author Xavier Schepler * @copyright Réseau Quetelet */ require_once 'inc/headers.php'; function help() { echo <<<HEREDOC ********************************************* * Question data bank administration utility * ********************************************* Allows the *listing*, the *creation*, the *update*, or the *deletion* of administration accounts. List useradmin --list OR useradmin -l Create useradmin --add login OR useradmin -a login Delete useradmin --delete login OR useradmin -d login Password useradmin --password login OR useradmin -p login HEREDOC; exit(0); } function read_line_hidden() { system('stty -echo'); $line = ''; while (($c = fgetc(STDIN)) != "\n") { $line .= $c; } system('stty echo'); return $line; } function _list() { $userMapper = new DB_Mapper_User; $list = $userMapper->findAll(); if (($l = count($list)) == 0) { echo "No account.\n"; exit(0); } for ($i = 0; $i < $l; $i++) { echo $list[$i]['user_name'], "\n"; } } function add($login, $password) { $userMapper = new DB_Mapper_User; $user = new DB_Model_User; $user->set_user_name($login); $user->set_password($password); try { $id = $userMapper->save($user); } catch (Exception $e) { echo "An error occured.\n", $e; exit(1); } if ( ! $id) { echo "An error occured.\n"; exit(1); } echo "Login \"$login\" with password \"$password\" successfuly created.\n"; exit(0); } function delete($login) { $userMapper = new DB_Mapper_User; $l = $userMapper->deleteByLogin($login); if ($l > 0) { echo "Account \"$login\" deleted.\n"; exit(0); } else { echo "No account was deleted.\n"; exit(1); } } function update($login, $password) { $userMapper = new DB_Mapper_User; $user = $userMapper->findByLogin($login); if ( ! $user) { echo "No user for login \"$login\"\n"; exit(1); } else { $user->set_password($password); try { $id = $userMapper->save($user); } catch (Exception $e) { echo "An error occured.\n$e\n"; exit(1); } if ($id) { echo "Password changed to \"$password\" for login \"$login\".\n"; exit(1); } else { echo "An error occured.\n"; exit(0); } } } try { $opts = new Zend_Console_Getopt( array( 'help|h' => 'Show an help message and exits.', 'list|l' => 'List all registered accounts', 'add|a=s' => 'Add an account.', 'delete|d=s' => 'Delete an account.', 'password|p=s' => 'Change an account password.', ) ); } catch (Exception $e) { echo $e->getUsageMessage(); exit(1); } try { if ( ! $opts->toArray()) { echo $opts->getUsageMessage(); exit(0); } } catch (Exception $e) { echo $opts->getUsageMessage(); exit(1); } if ($opts->getOption('help')) { help(); } if ($list = $opts->getOption('list')) { _list(); } if ($login = $opts->getOption('add')) { $userMapper = new DB_Mapper_User; if ($userMapper->loginExists($login)) { echo "An account named \"$login\" already exists.\n"; exit(1); } echo "Enter password for user $login :\n"; $password = read_line_hidden(); echo "Retype password for user $login :\n"; $_password = read_line_hidden(); if ($password != $_password) { echo "Passwords didn\'t match\n"; exit(1); } add($login, $password); } if ($login = $opts->getOption('delete')) { delete($login); } if ($login = $opts->getOption('update')) { echo "Enter password for user $login :\n"; $password = read_line_hidden(); echo "Retype password for user $login :\n"; $_password = read_line_hidden(); if ($password != $_password) { echo "Passwords didn\'t match\n"; exit(1); } update($login, $password); }
CDSP-SCPO/BasedeQuestions
php/app/scripts/useradmin.php
PHP
gpl-3.0
3,699
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 25718, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 1030, 3166, 10062, 8040, 5369, 10814, 2099, 1008, 1030, 9385, 24501, 10207, 10861, 9834, 3388, 1008, 1013, 5478, 1035, 2320, 1005, 4297,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (C) 2019 Timo Vesalainen <timo.vesalainen@iki.fi> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.vesalainen.time; import java.time.Instant; import org.junit.Test; import static org.junit.Assert.*; /** * * @author Timo Vesalainen <timo.vesalainen@iki.fi> */ public class MutableInstantTest { public MutableInstantTest() { } @Test public void test1() { MutableInstant mi = new MutableInstant(10, -1); assertEquals(9, mi.second()); assertEquals(999999999L, mi.nano()); } @Test public void test2() { MutableInstant mi = new MutableInstant(10, 1000000000); assertEquals(11, mi.second()); assertEquals(0L, mi.nano()); } @Test public void testPlus() { MutableInstant mi = MutableInstant.now(); Instant exp = mi.instant(); assertEquals(exp.toEpochMilli(), mi.millis()); assertTrue(mi.isEqual(exp)); long v = 12345678912345L; mi.plus(v); assertTrue(mi.isEqual(exp.plusNanos(v))); } @Test public void testUntil() { long v = 12345678912345L; MutableInstant mi1 = MutableInstant.now(); MutableInstant mi2 = new MutableInstant(mi1); assertTrue(mi1.compareTo(mi2)==0); mi2.plus(v); assertTrue(mi1.compareTo(mi2)<0); assertTrue(mi2.compareTo(mi1)>0); assertEquals(v, mi1.until(mi2)); mi2.plus(-v); assertEquals(mi1, mi2); } @Test public void testNanoTime() { MutableInstant mi1 = MutableInstant.now(); MutableInstant mi2 = new MutableInstant(0, System.nanoTime()); long d = mi1.until(mi2); mi2.plus(-d); assertEquals(mi1, mi2); } }
tvesalainen/util
util/src/test/java/org/vesalainen/time/MutableInstantTest.java
Java
gpl-3.0
2,464
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 30524, 1013, 2030, 19933, 1008, 2009, 2104, 1996, 3408, 1997, 1996, 27004, 2236, 2270, 6105, 2004, 2405, 2011, 1008, 1996, 2489, 4007, 3192, 1010, 2593, 2544, 1017, 1997, 1996, 6105, 1010, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Aesir ========= [![Build Status](https://travis-ci.org/sirlag/AesirSpring.svg?branch=master)](https://travis-ci.org/sirlag/AesirSpring) Named after the norse council of gods, Aesir is a tool designed to allow users to quickly and easily find groups to work on time sensitive projects with. Aesir is also designed to allow users to create their own instance of the site for local deploy, so that a game jam or a high school teacher could use the Aesir project to organize their event. Frameworks ========= - [Spring.io MVC](https://spring.io/) - [Vaadin web Framework](https://vaadin.com/home) - [Gradle](https://gradle.org/) TODO ========= See the issue tracker, located conveniently to the right.
sirlag/AesirSpring
README.md
Markdown
mpl-2.0
703
[ 30522, 29347, 29481, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1031, 999, 1031, 3857, 3570, 1033, 1006, 16770, 1024, 1013, 1013, 10001, 1011, 25022, 1012, 8917, 1013, 2909, 17802, 1013, 29347, 29481, 13102, 4892, 1012, 17917, 22...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...