code stringlengths 4 991k | repo_name stringlengths 6 116 | path stringlengths 4 249 | language stringclasses 30 values | license stringclasses 15 values | size int64 4 991k | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
/**
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.pnc.rest.provider;
import org.jboss.pnc.model.ProductMilestone;
import org.jboss.pnc.model.ProductMilestoneRelease;
import org.jboss.pnc.rest.restmodel.ProductMilestoneReleaseRest;
import org.jboss.pnc.spi.datastore.repositories.PageInfoProducer;
import org.jboss.pnc.spi.datastore.repositories.ProductMilestoneReleaseRepository;
import org.jboss.pnc.spi.datastore.repositories.ProductMilestoneRepository;
import org.jboss.pnc.spi.datastore.repositories.SortInfoProducer;
import org.jboss.pnc.spi.datastore.repositories.api.RSQLPredicateProducer;
import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.function.Function;
@Stateless
public class ProductMilestoneReleaseProvider extends AbstractProvider<ProductMilestoneRelease, ProductMilestoneReleaseRest> {
private ProductMilestoneRepository milestoneRepository;
private ProductMilestoneReleaseRepository releaseRepository;
@Inject
public ProductMilestoneReleaseProvider(ProductMilestoneReleaseRepository releaseRepository,
ProductMilestoneRepository milestoneRepository,
RSQLPredicateProducer rsqlPredicateProducer,
SortInfoProducer sortInfoProducer, PageInfoProducer pageInfoProducer) {
super(releaseRepository, rsqlPredicateProducer, sortInfoProducer, pageInfoProducer);
this.releaseRepository = releaseRepository;
this.milestoneRepository = milestoneRepository;
}
// needed for EJB/CDI
@Deprecated
public ProductMilestoneReleaseProvider() {
}
@Override
protected Function<? super ProductMilestoneRelease, ? extends ProductMilestoneReleaseRest> toRESTModel() {
return ProductMilestoneReleaseRest::new;
}
@Override
protected Function<? super ProductMilestoneReleaseRest, ? extends ProductMilestoneRelease> toDBModel() {
throw new IllegalStateException("ProductMilestoneRelease entity is not to be created via REST");
}
public ProductMilestoneReleaseRest latestForMilestone(Integer milestoneId) {
ProductMilestone milestone = milestoneRepository.queryById(milestoneId);
ProductMilestoneRelease release = milestone == null ? null : releaseRepository.findLatestByMilestone(milestone);
return release == null ? null : toRESTModel().apply(release);
}
}
| dans123456/pnc | rest/src/main/java/org/jboss/pnc/rest/provider/ProductMilestoneReleaseProvider.java | Java | apache-2.0 | 3,113 | [
30522,
1013,
1008,
1008,
1008,
1046,
15853,
2015,
1010,
2188,
1997,
2658,
2330,
3120,
1012,
1008,
9385,
2297,
2417,
6045,
1010,
4297,
1012,
1010,
1998,
3265,
16884,
1008,
2004,
5393,
2011,
1996,
1030,
3166,
22073,
1012,
1008,
1008,
7000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef DICOMVIEW_H_
#define DICOMVIEW_H_
#include <QmitkAbstractView.h>
#include <berryQtViewPart.h>
#include "ui_QmitkDicomViewControls.h"
/**
* \brief A view class suited for the DicomPerspective within the custom viewer plug-in.
*
* This view class contributes dicom import functionality to the DicomPerspective.
* The view controls are provided within CreatePartControl() by the QmitkDicomExternalDataWidget
* class. A DicomView instance is part of the DicomPerspective for Dicom import functionality.
*/
// //! [DicomViewDecl]
class DicomView : public QmitkAbstractView
// //! [DicomViewDecl]
{
Q_OBJECT
public:
/**
* String based view identifier.
*/
static const std::string VIEW_ID;
/**
* Standard constructor.
*/
DicomView();
/**
* Standard destructor.
*/
virtual ~DicomView();
/**
* Creates the view control widgets provided by the QmitkDicomExternalDataWidget class.
* Widgets associated with unused functionality are being removed and DICOM import and data
* storage transfer funcionality being connected to the appropriate slots.
*/
virtual void CreateQtPartControl(QWidget *parent) override;
protected Q_SLOTS:
/**
* Loads the DICOM series specified by the given string parameter and adds the resulting data
* node to the data storage. Subsequently switches to the ViewerPerspective for further
* data examination.
*/
void AddDataNodeFromDICOM(QHash<QString, QVariant> eventProperties);
protected:
void SetFocus() override;
Ui::QmitkDicomViewControls m_Controls;
QWidget *m_Parent;
};
#endif /*DICOMVIEW_H_*/
| iwegner/MITK | Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.h | C | bsd-3-clause | 2,112 | [
30522,
1013,
1008,
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... |
module.exports = function( grunt ) {
// Project configuration.
grunt.initConfig(
{
pkg : grunt.file.readJSON( "bower.json" ),
jshint : {
options : {
jshintrc : true
},
src : {
src : [
"src/*.js"
]
}
},
uglify : {
js : {
src : "src/<%= pkg.name %>.js",
dest : "dist/<%= pkg.name %>.min.js"
}
},
watch : {
files : [ "src/*.js" ],
tasks : [ "jshint" ]
}
}
);
grunt.loadNpmTasks( "grunt-contrib-jshint" );
grunt.loadNpmTasks( "grunt-contrib-uglify" );
grunt.loadNpmTasks( "grunt-contrib-watch" );
grunt.registerTask( "default", [ "jshint", "uglify" ] );
};
| oliversalzburg/ng-i18n-node | Gruntfile.js | JavaScript | mit | 659 | [
30522,
11336,
1012,
14338,
1027,
3853,
1006,
20696,
1007,
1063,
1013,
1013,
2622,
9563,
1012,
20696,
1012,
1999,
4183,
8663,
8873,
2290,
1006,
1063,
1052,
2243,
2290,
1024,
20696,
1012,
5371,
1012,
3191,
22578,
2239,
1006,
1000,
6812,
2121,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 map;
$(document).ready(function(){
var a=document.getElementById('map');
map = new GMaps({el: a,
//el: '#map',
lat: 55.763585,
lng: 37.560883,
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl : true,
zoomControlOpt: {
style : 'SMALL',
position: 'TOP_LEFT'
}
});
var logo=$('#logo').attr('src');
//alert(logo);
var icon = {
url: '/bundles/realty/map_icon.png', // url
scaledSize: new google.maps.Size(40, 40), // scaled size
origin: new google.maps.Point(0,0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
//var icon='/bundles/realty/map_icon.png';
var markers=$('#PagesAllGoogleMap').val();
markers= JSON.parse(markers);
var PagesAllGoogleMap_path=$('#PagesAllGoogleMap_path').val();
for (var i =0; i<markers.length;i++)
{
if (markers[i]['city'] && markers[i]['street'] ) {
var address=markers[i]['city']+', '+markers[i]['street']+', '+markers[i]['house'];
var image='';
if (markers[i]['image_path']) {
image='<img src="/'+markers[i]['image_path']+'">';
}
var price='';
if (markers[i]['price']) {
price='<p>Price: '+markers[i]['price']+' USD</p>';
}
var totalArea='';
if (markers[i]['totalArea']) {
totalArea='<p>Total Area: '+markers[i]['totalArea']+'m2</p>';
}
var floor='';
if (markers[i]['totalArea']) {
floor='<p>Floor: '+markers[i]['numberOfFloors']+'/'+markers[i]['floor']+'</p>';
}
var contentHtml='<div class="bubblewrap">' +
'<a style="display:block;text-decoration:none" href="'+PagesAllGoogleMap_path+markers[i]['path']+'">' +
'<div class="mapContainer">' +
'<div class="mapPhoto">' + image +
'</div>' +
'<div class="mapDataC">' +
'<p><i class="fa fa-map-marker" aria-hidden="true"></i>'+address+'</p>' +
'<p>'+totalArea+'</p>' +
'<p>'+floor+'</p>' +
'<p>'+price+'</p>' +
'</div>' +
'<div class="view_div"><i class="info_window_arrow fa fa-5x fa-angle-right"></i></div>' +
'</div>' +
'</a>' +
'</div>';
// ************************
// grnertae makers content theme hlml css
// ************************
mapMake(address,icon,contentHtml);
}
}
function mapMake(address, icon, contentHtml )
{
GMaps.geocode({
address: address,
callback: function(results, status, html1) {
if (status == 'OK') {
var latlng = results[0].geometry.location;
map.setCenter(latlng.lat(), latlng.lng());
map.addMarker({
lat: latlng.lat(),
lng: latlng.lng(),
// title: 'Lima',
icon: icon,
infoWindow: {
content: contentHtml
}
});
}
}
});
}
}); | seinyan/NDM | src/RealtyBundle/Resources/public/realty_bundle_gmap.js | JavaScript | mit | 3,420 | [
30522,
13075,
4949,
1025,
1002,
1006,
6254,
1007,
1012,
3201,
1006,
3853,
1006,
1007,
1063,
13075,
1037,
1027,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1005,
4949,
1005,
1007,
1025,
4949,
1027,
2047,
20917,
4523,
1006,
1063,
3449,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.int_watch.conf 13957 2005-12-20 15:33:08Z tanders $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "statPPTP.h"
#include "triton.h"
/*
* The variables we want to tie the relevant OIDs to.
* The agent will handle all GET and (if applicable) SET requests
* to these variables automatically, changing the values as needed.
*/
void pptp_get_stat(unsigned int **, unsigned int **);
static unsigned int *stat_starting;
static unsigned int *stat_active;
/*
* Our initialization routine, called automatically by the agent
* (Note that the function name must match init_FILENAME())
*/
void
init_statPPTP(void)
{
netsnmp_handler_registration *reg;
netsnmp_watcher_info *winfo;
static oid statPPTPStarting_oid[] = { 1,3,6,1,4,1,8072,100,1,3,1 };
static oid statPPTPActive_oid[] = { 1,3,6,1,4,1,8072,100,1,3,2 };
/*
* a debugging statement. Run the agent with -DstatPPTP to see
* the output of this debugging statement.
*/
DEBUGMSGTL(("statPPTP", "Initializing the statPPTP module\n"));
if (!triton_module_loaded("pptp"))
return;
pptp_get_stat(&stat_starting, &stat_active);
/*
* Register scalar watchers for each of the MIB objects.
* The ASN type and RO/RW status are taken from the MIB definition,
* but can be adjusted if needed.
*
* In most circumstances, the scalar watcher will handle all
* of the necessary processing. But the NULL parameter in the
* netsnmp_create_handler_registration() call can be used to
* supply a user-provided handler if necessary.
*
* This approach can also be used to handle Counter64, string-
* and OID-based watched scalars (although variable-sized writeable
* objects will need some more specialised initialisation).
*/
DEBUGMSGTL(("statPPTP",
"Initializing statPPTPStarting scalar integer. Default value = %d\n",
0));
reg = netsnmp_create_handler_registration(
"statPPTPStarting", NULL,
statPPTPStarting_oid, OID_LENGTH(statPPTPStarting_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
stat_starting, sizeof(*stat_starting),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPTPStarting" );
}
DEBUGMSGTL(("statPPTP",
"Initializing statPPTPActive scalar integer. Default value = %d\n",
0));
reg = netsnmp_create_handler_registration(
"statPPTPActive", NULL,
statPPTPActive_oid, OID_LENGTH(statPPTPActive_oid),
HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info(
stat_active, sizeof(*stat_active),
ASN_INTEGER, WATCHER_FIXED_SIZE);
if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
snmp_log( LOG_ERR, "Failed to register watched statPPTPActive" );
}
DEBUGMSGTL(("statPPTP",
"Done initalizing statPPTP module\n"));
}
| musman2012/commented-accel | accel-pppd/extra/net-snmp/statPPTP.c | C | gpl-2.0 | 3,252 | [
30522,
1013,
1008,
1008,
3602,
1024,
2023,
5371,
2761,
8285,
1011,
7013,
2011,
2771,
2497,
2475,
2278,
2478,
1008,
1024,
2771,
2497,
2475,
2278,
1012,
20014,
1035,
3422,
1012,
9530,
2546,
16621,
28311,
2384,
1011,
2260,
1011,
2322,
2321,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 operation
import (
"fmt"
"os"
"github.com/runabove/sail/internal"
"github.com/spf13/cobra"
)
var cmdOperationAttach = &cobra.Command{
Use: "attach",
Short: "Attach to an ongoing operation output: sail operation attach [applicationName] <operationId>",
Long: `Attach to an ongoing operation output: sail operation attach [applicationName] <operationId>
Example: sail operation attach devel/redis fa853ede-6c05-4823-8b20-46a5389fe0de
If the applicationName is not passed, the default application name will be used (the user's username).
`,
Run: func(cmd *cobra.Command, args []string) {
switch len(args) {
case 1:
// applicationName was not passed. Using default one.
applicationName := internal.GetUserName()
operationAttach(applicationName, args[0])
case 2:
operationAttach(args[0], args[1])
default:
fmt.Fprintln(os.Stderr, "Invalid usage. sail operation attach [applicationName] <operationId>. Please see sail operation attach --help")
}
},
}
func operationAttach(app, operationID string) {
// Split namespace and service
internal.StreamPrint("GET", fmt.Sprintf("/applications/%s/operation/%s/attach", app, operationID), nil)
internal.ExitAfterCtrlC()
}
| runabove/sail | operation/attach.go | GO | bsd-3-clause | 1,209 | [
30522,
7427,
3169,
12324,
1006,
1000,
4718,
2102,
1000,
1000,
9808,
1000,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
2448,
7875,
21818,
1013,
9498,
1013,
4722,
1000,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
11867,
2546,
17134,
1013,
166... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
class AppAdmin::FilterSetsController < AppAdmin::BaseController
def index
@filter_sets = MediaResource.filter_sets
end
def destroy
@filter_set = MediaResource.find(params[:id])
@filter_set.destroy!
redirect_to app_admin_filter_sets_url, flash: {success: "The Filter Set has been deleted."}
rescue => e
redirect_to app_admin_filter_sets_url, flash: {error: e.to_s}
end
end
| zhdk/madek | app/controllers/app_admin/filter_sets_controller.rb | Ruby | gpl-3.0 | 406 | [
30522,
2465,
10439,
4215,
10020,
1024,
1024,
17736,
8454,
8663,
13181,
10820,
1026,
10439,
4215,
10020,
1024,
1024,
2918,
8663,
13181,
10820,
13366,
5950,
1030,
11307,
1035,
4520,
1027,
2865,
6072,
8162,
3401,
1012,
11307,
1035,
4520,
2203,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# encoding: utf-8
#
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Author: Kyle Lahnakoski (kyle@lahnakoski.com)
#
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import smtplib
import sys
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from mo_logs import Log
from mo_dots import listwrap
from mo_dots import coalesce
from mo_kwargs import override
class Emailer:
@override
def __init__(
self,
from_address,
to_address,
host,
username,
password,
subject="catchy title",
port=465,
use_ssl=1,
kwargs=None
):
self.settings = kwargs
self.server = None
def __enter__(self):
if self.server is not None:
Log.error("Got a problem")
if self.settings.use_ssl:
self.server = smtplib.SMTP_SSL(self.settings.host, self.settings.port)
else:
self.server = smtplib.SMTP(self.settings.host, self.settings.port)
if self.settings.username and self.settings.password:
self.server.login(self.settings.username, self.settings.password)
return self
def __exit__(self, type, value, traceback):
try:
self.server.quit()
except Exception as e:
Log.warning("Problem with smtp server quit(), ignoring problem", e)
self.server = None
def send_email(self,
from_address=None,
to_address=None,
subject=None,
text_data=None,
html_data=None
):
"""Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@example.com") or with real names
(e.g. "John Smith <jsmith@example.com>").
text_data and html_data are both strings. You can specify one or both.
If you specify both, the email will be sent as a MIME multipart
alternative, i.e., the recipient will see the HTML content if his
viewer supports it; otherwise he'll see the text content.
"""
settings = self.settings
from_address = coalesce(from_address, settings["from"], settings.from_address)
to_address = listwrap(coalesce(to_address, settings.to_address, settings.to_addrs))
if not from_address or not to_address:
raise Exception("Both from_addr and to_addrs must be specified")
if not text_data and not html_data:
raise Exception("Must specify either text_data or html_data")
if not html_data:
msg = MIMEText(text_data)
elif not text_data:
msg = MIMEText(html_data, 'html')
else:
msg = MIMEMultipart('alternative')
msg.attach(MIMEText(text_data, 'plain'))
msg.attach(MIMEText(html_data, 'html'))
msg['Subject'] = coalesce(subject, settings.subject)
msg['From'] = from_address
msg['To'] = ', '.join(to_address)
if self.server:
# CALL AS PART OF A SMTP SESSION
self.server.sendmail(from_address, to_address, msg.as_string())
else:
# CALL AS STAND-ALONE
with self:
self.server.sendmail(from_address, to_address, msg.as_string())
if sys.hexversion < 0x020603f0:
# versions earlier than 2.6.3 have a bug in smtplib when sending over SSL:
# http://bugs.python.org/issue4066
# Unfortunately the stock version of Python in Snow Leopard is 2.6.1, so
# we patch it here to avoid having to install an updated Python version.
import socket
import ssl
def _get_socket_fixed(self, host, port, timeout):
if self.debuglevel > 0:
print>> sys.stderr, 'connect:', (host, port)
new_socket = socket.create_connection((host, port), timeout)
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
self.file = smtplib.SSLFakeFile(new_socket)
return new_socket
smtplib.SMTP_SSL._get_socket = _get_socket_fixed
| klahnakoski/Bugzilla-ETL | vendor/pyLibrary/env/emailer.py | Python | mpl-2.0 | 4,306 | [
30522,
1001,
17181,
1024,
21183,
2546,
1011,
1022,
1001,
1001,
1001,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1001,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1012,
2065,
1037,
6100,
1997,
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... |
#
# My first attempt at python
# calibrate accelerometer
#
import re
import scipy
from scipy import optimize
from scipy import linalg
from pylab import *
#
# parse the log
#
def read_log(ac_id, filename, sensor):
f = open(filename, 'r')
pattern = re.compile("(\S+) "+ac_id+" IMU_"+sensor+"_RAW (\S+) (\S+) (\S+)")
list_meas = []
while 1:
line = f.readline().strip()
if line == '':
break
m=re.match(pattern, line)
if m:
list_meas.append([float(m.group(2)), float(m.group(3)), float(m.group(4))])
return scipy.array(list_meas)
#
# select only non-noisy data
#
def filter_meas(meas, window_size, noise_threshold):
filtered_meas = []
filtered_idx = []
for i in range(window_size,len(meas)-window_size):
noise = meas[i-window_size:i+window_size,:].std(axis=0)
if linalg.norm(noise) < noise_threshold:
filtered_meas.append(meas[i,:])
filtered_idx.append(i)
return scipy.array(filtered_meas), filtered_idx
#
# initial boundary based calibration
#
def get_min_max_guess(meas, scale):
max_meas = meas[:,:].max(axis=0)
min_meas = meas[:,:].min(axis=0)
n = (max_meas + min_meas) / 2
sf = 2*scale/(max_meas - min_meas)
return scipy.array([n[0], n[1], n[2], sf[0], sf[1], sf[2]])
#
# scale the set of measurements
#
def scale_measurements(meas, p):
l_comp = [];
l_norm = [];
for m in meas[:,]:
sm = (m - p[0:3])*p[3:6]
l_comp.append(sm)
l_norm.append(linalg.norm(sm))
return scipy.array(l_comp), scipy.array(l_norm)
#
# print xml for airframe file
#
def print_xml(p, sensor, res):
print ""
print "<define name=\""+sensor+"_X_NEUTRAL\" value=\""+str(int(round(p[0])))+"\"/>"
print "<define name=\""+sensor+"_Y_NEUTRAL\" value=\""+str(int(round(p[1])))+"\"/>"
print "<define name=\""+sensor+"_Z_NEUTRAL\" value=\""+str(int(round(p[2])))+"\"/>"
print "<define name=\""+sensor+"_X_SENS\" value=\""+str(p[3]*2**res)+"\" integer=\"16\"/>"
print "<define name=\""+sensor+"_Y_SENS\" value=\""+str(p[4]*2**res)+"\" integer=\"16\"/>"
print "<define name=\""+sensor+"_Z_SENS\" value=\""+str(p[5]*2**res)+"\" integer=\"16\"/>"
filename = 'log_accel_booz2_a2'
ac_id = "151"
if 1:
sensor = "ACCEL"
sensor_ref = 9.81
sensor_res = 10
noise_window = 20;
noise_threshold = 40;
else:
sensor = "MAG"
sensor_ref = 1.
sensor_res = 11
noise_window = 10;
noise_threshold = 1000;
print "reading file "+filename+" for aircraft "+ac_id+" and sensor "+sensor
measurements = read_log(ac_id, filename, sensor)
print "found "+str(len(measurements))+" records"
flt_meas, flt_idx = filter_meas(measurements, noise_window, noise_threshold)
print "remaining "+str(len(flt_meas))+" after low pass"
p0 = get_min_max_guess(flt_meas, sensor_ref)
cp0, np0 = scale_measurements(flt_meas, p0)
print "initial guess : "+str(np0.mean())+" "+str(np0.std())
print p0
def err_func(p,meas,y):
cp, np = scale_measurements(meas, p)
err = y*scipy.ones(len(meas)) - np
return err
p1, success = optimize.leastsq(err_func, p0[:], args=(flt_meas, sensor_ref))
cp1, np1 = scale_measurements(flt_meas, p1)
print "optimized guess : "+str(np1.mean())+" "+str(np1.std())
print p1
print_xml(p1, sensor, sensor_res)
subplot(3,1,1)
plot(measurements[:,0])
plot(measurements[:,1])
plot(measurements[:,2])
plot(flt_idx, flt_meas[:,0], 'ro')
plot(flt_idx, flt_meas[:,1], 'ro')
plot(flt_idx, flt_meas[:,2], 'ro')
subplot(3,2,3)
plot(cp0[:,0]);
plot(cp0[:,1]);
plot(cp0[:,2]);
plot(-sensor_ref*scipy.ones(len(flt_meas)));
plot(sensor_ref*scipy.ones(len(flt_meas)));
subplot(3,2,4)
plot(np0);
plot(sensor_ref*scipy.ones(len(flt_meas)));
subplot(3,2,5)
plot(cp1[:,0]);
plot(cp1[:,1]);
plot(cp1[:,2]);
plot(-sensor_ref*scipy.ones(len(flt_meas)));
plot(sensor_ref*scipy.ones(len(flt_meas)));
subplot(3,2,6)
plot(np1);
plot(sensor_ref*scipy.ones(len(flt_meas)));
show();
| pchickey/paparazzi-linux-release | sw/tools/calibration/calib.py | Python | gpl-2.0 | 3,989 | [
30522,
1001,
1001,
2026,
2034,
3535,
2012,
18750,
1001,
10250,
12322,
11657,
16222,
12260,
21716,
15141,
1001,
12324,
2128,
12324,
16596,
7685,
2013,
16596,
7685,
12324,
23569,
27605,
4371,
2013,
16596,
7685,
12324,
27022,
2140,
2290,
2013,
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... |
import * as React from 'react';
import { DocumentCard } from './DocumentCard';
import { DocumentCardTitle } from './DocumentCardTitle';
import { DocumentCardPreview } from './DocumentCardPreview';
import { DocumentCardLocation } from './DocumentCardLocation';
import { DocumentCardActivity } from './DocumentCardActivity';
import { DocumentCardActions } from './DocumentCardActions';
import { PersonaInitialsColor } from '../../Persona';
import { ImageFit } from '../../Image';
import { IButtonProps } from '../../Button';
export interface IDocumentCard {
}
export interface IDocumentCardProps extends React.Props<DocumentCard> {
/**
* Optional callback to access the IDocumentCard interface. Use this instead of ref for accessing
* the public methods and properties of the component.
*/
componentRef?: (component: IDocumentCard) => void;
/**
* The type of DocumentCard to display.
* @default DocumentCardType.normal
*/
type?: DocumentCardType;
/**
* Function to call when the card is clicked or keyboard Enter/Space is pushed.
*/
onClick?: (ev?: React.SyntheticEvent<HTMLElement>) => void;
/**
* A URL to navigate to when the card is clicked. If a function has also been provided,
* it will be used instead of the URL.
*/
onClickHref?: string;
/**
* Optional class for document card.
*/
className?: string;
/**
* Hex color value of the line below the card, which should correspond to the document type.
* This should only be supplied when using the 'compact' card layout.
*/
accentColor?: string;
}
export enum DocumentCardType {
/**
* Standard DocumentCard.
*/
normal = 0,
/**
* Compact layout. Displays the preview beside the details, rather than above.
*/
compact = 1
}
export interface IDocumentCardPreviewProps extends React.Props<DocumentCardPreview> {
/**
* One or more preview images to display.
*/
previewImages: IDocumentCardPreviewImage[];
/**
* The function return string that will describe the number of overflow documents.
* such as (overflowCount: number) => `+${ overflowCount } more`,
*/
getOverflowDocumentCountText?: (overflowCount: number) => string;
}
export interface IDocumentCardPreviewImage {
/**
* File name for the document this preview represents.
*/
name?: string;
/**
* URL to view the file.
*/
url?: string;
/**
* Path to the preview image.
*/
previewImageSrc?: string;
/**
* Deprecated at v1.3.6, to be removed at >= v2.0.0.
* @deprecated
*/
errorImageSrc?: string;
/**
* Path to the icon associated with this document type.
*/
iconSrc?: string;
/**
* If provided, forces the preview image to be this width.
*/
width?: number;
/**
* If provided, forces the preview image to be this height.
*/
height?: number;
/**
* Used to determine how to size the image to fit the dimensions of the component.
* If both dimensions are provided, then the image is fit using ImageFit.scale, otherwise ImageFit.none is used.
*/
imageFit?: ImageFit;
/**
* Hex color value of the line below the preview, which should correspond to the document type.
*/
accentColor?: string;
}
export interface IDocumentCardTitleProps extends React.Props<DocumentCardTitle> {
/**
* Title text. If the card represents more than one document, this should be the title of one document and a "+X" string. For example, a collection of four documents would have a string of "Document.docx +3".
*/
title: string;
/**
* Whether we truncate the title to fit within the box. May have a performance impact.
* @defaultvalue true
*/
shouldTruncate?: boolean;
}
export interface IDocumentCardLocationProps extends React.Props<DocumentCardLocation> {
/**
* Text for the location of the document.
*/
location: string;
/**
* URL to navigate to for this location.
*/
locationHref?: string;
/**
* Function to call when the location is clicked.
*/
onClick?: (ev?: React.MouseEvent<HTMLElement>) => void;
/**
* Aria label for the link to the document location.
*/
ariaLabel?: string;
}
export interface IDocumentCardActivityProps extends React.Props<DocumentCardActivity> {
/**
* Describes the activity that has taken place, such as "Created Feb 23, 2016".
*/
activity: string;
/**
* One or more people who are involved in this activity.
*/
people: IDocumentCardActivityPerson[];
}
export interface IDocumentCardActivityPerson {
/**
* The name of the person.
*/
name: string;
/**
* Path to the profile photo of the person.
*/
profileImageSrc: string;
/**
* The user's initials to display in the profile photo area when there is no image.
*/
initials?: string;
/**
* The background color when the user's initials are displayed.
* @defaultvalue PersonaInitialsColor.blue
*/
initialsColor?: PersonaInitialsColor;
}
export interface IDocumentCardActionsProps extends React.Props<DocumentCardActions> {
/**
* The actions available for this document.
*/
actions: IButtonProps[];
/**
* The number of views this document has received.
*/
views?: Number;
}
| SpatialMap/SpatialMapDev | node_modules/office-ui-fabric-react/src/components/DocumentCard/DocumentCard.Props.ts | TypeScript | mit | 5,213 | [
30522,
12324,
1008,
2004,
10509,
2013,
1005,
10509,
1005,
1025,
12324,
1063,
6254,
11522,
1065,
2013,
1005,
1012,
1013,
6254,
11522,
1005,
1025,
12324,
1063,
6254,
11522,
3775,
9286,
1065,
2013,
1005,
1012,
1013,
6254,
11522,
3775,
9286,
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... |
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Interlude</title>
</head>
<link href="css/interlude.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
<script src="lib/interlude.js"></script>
<script src="lib/CV_particles.js"></script>
<style>
#sample
{
position: absolute;
left: 10%;
top: 10%;
width: 80%;
height: 80%;
background: yellow;
}
</style>
<script>
function start() {
var o = {};
o.div = "sample";
o.centered = true;
// var a = new Interlude.Loading(o);
// var x = new Interlude.Forms(o);
var p = {};
p.div = "sample";
var z = new Particles(p);
};
$( document ).ready(function() {
$("#sample").click(function(){
start();
});
});
</script>
<body>
<!-- Invisible comment -->
<div id = "sample"></div>
</body>
</html> | Phalanstere/interlude | index.html | HTML | mit | 1,138 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
2139,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
25347,
1026,
1013,
2516,
1028,
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... |
Author: Andrew Shibata
This project is Stat 159 Homework 3.
The report generated by the code reproduces section 3.2 (Mulitple Linear Regression) of the book *An Introduction to Statistical Learning*
License:
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. | andrewshibata/stat159-hw3 | README.md | Markdown | gpl-3.0 | 563 | [
30522,
3166,
1024,
4080,
11895,
14479,
2050,
2023,
2622,
2003,
28093,
18914,
19453,
1017,
1012,
1996,
3189,
7013,
2011,
1996,
3642,
21376,
2015,
2930,
1017,
1012,
1016,
1006,
14163,
15909,
10814,
7399,
26237,
1007,
1997,
1996,
2338,
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... |
/*
* Copyright (C) 2004-2010 Stephen Ostermiller
* http://ostermiller.org/contact.pl?regarding=Java+Utilities
*
* 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.
*
* See LICENSE.txt for details.
*/
package com.Ostermiller.util;
import java.io.*;
import java.util.ArrayList;
/**
* An input stream which reads sequentially from multiple sources.
* More information about this class is available from <a target="_top" href=
* "http://ostermiller.org/utils/">ostermiller.org</a>.
*
* @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
* @since ostermillerutils 1.04.00
*/
public class ConcatInputStream extends InputStream {
/**
* Current index to inputStreamQueue
*
* @since ostermillerutils 1.04.01
*/
private int inputStreamQueueIndex = 0;
/**
* Queue of inputStreams that have yet to be read from.
*
* @since ostermillerutils 1.04.01
*/
private ArrayList<InputStream> inputStreamQueue = new ArrayList<InputStream>();
/**
* A cache of the current inputStream from the inputStreamQueue
* to avoid unneeded access to the queue which must
* be synchronized.
*
* @since ostermillerutils 1.04.01
*/
private InputStream currentInputStream = null;
/**
* true iff the client may add more inputStreams.
*
* @since ostermillerutils 1.04.01
*/
private boolean doneAddingInputStreams = false;
/**
* Causes the addInputStream method to throw IllegalStateException
* and read() methods to return -1 (end of stream)
* when there is no more available data.
* <p>
* Calling this method when this class is no longer accepting
* more inputStreams has no effect.
*
* @since ostermillerutils 1.04.01
*/
public void lastInputStreamAdded(){
doneAddingInputStreams = true;
}
/**
* Add the given inputStream to the queue of inputStreams from which to
* concatenate data.
*
* @param in InputStream to add to the concatenation.
* @throws IllegalStateException if more inputStreams can't be added because lastInputStreamAdded() has been called, close() has been called, or a constructor with inputStream parameters was used.
*
* @since ostermillerutils 1.04.01
*/
public void addInputStream(InputStream in){
synchronized(inputStreamQueue){
if (in == null) throw new NullPointerException();
if (closed) throw new IllegalStateException("ConcatInputStream has been closed");
if (doneAddingInputStreams) throw new IllegalStateException("Cannot add more inputStreams - the last inputStream has already been added.");
inputStreamQueue.add(in);
}
}
/**
* Add the given inputStream to the queue of inputStreams from which to
* concatenate data.
*
* @param in InputStream to add to the concatenation.
* @throws IllegalStateException if more inputStreams can't be added because lastInputStreamAdded() has been called, close() has been called, or a constructor with inputStream parameters was used.
* @throws NullPointerException the array of inputStreams, or any of the contents is null.
*
* @since ostermillerutils 1.04.01
*/
public void addInputStreams(InputStream[] in){
for (InputStream element: in) {
addInputStream(element);
}
}
/**
* Gets the current inputStream, looking at the next
* one in the list if the current one is null.
*
* @since ostermillerutils 1.04.01
*/
private InputStream getCurrentInputStream(){
if (currentInputStream == null && inputStreamQueueIndex < inputStreamQueue.size()){
synchronized(inputStreamQueue){
// inputStream queue index is advanced only by the nextInputStream()
// method. Don't do it here.
currentInputStream = inputStreamQueue.get(inputStreamQueueIndex);
}
}
return currentInputStream;
}
/**
* Indicate that we are done with the current inputStream and we should
* advance to the next inputStream.
*
* @since ostermillerutils 1.04.01
*/
private void advanceToNextInputStream(){
currentInputStream = null;
inputStreamQueueIndex++;
}
/**
* True iff this the close() method has been called on this stream.
*
* @since ostermillerutils 1.04.00
*/
private boolean closed = false;
/**
* Create a new input stream that can dynamically accept new sources.
* <p>
* New sources should be added using the addInputStream() method.
* When all sources have been added the lastInputStreamAdded() should
* be called so that read methods can return -1 (end of stream).
* <p>
* Adding new sources may by interleaved with read calls.
*
* @since ostermillerutils 1.04.01
*/
public ConcatInputStream(){
// Empty constructor
}
/**
* Create a new InputStream with one source.
*
* @param in InputStream to use as a source.
*
* @throws NullPointerException if in is null
*
* @since ostermillerutils 1.04.00
*/
public ConcatInputStream(InputStream in){
addInputStream(in);
lastInputStreamAdded();
}
/**
* Create a new InputStream with two sources.
*
* @param in1 first InputStream to use as a source.
* @param in2 second InputStream to use as a source.
*
* @throws NullPointerException if either source is null.
*
* @since ostermillerutils 1.04.00
*/
public ConcatInputStream(InputStream in1, InputStream in2){
addInputStream(in1);
addInputStream(in2);
lastInputStreamAdded();
}
/**
* Create a new InputStream with an arbitrary number of sources.
*
* @param in InputStreams to use as a sources.
*
* @throws NullPointerException if the input array on any element is null.
*
* @since ostermillerutils 1.04.00
*/
public ConcatInputStream(InputStream[] in){
addInputStreams(in);
lastInputStreamAdded();
}
/**
* Reads the next byte of data from the underlying streams. The value byte is
* returned as an int in the range 0 to 255. If no byte is available because
* the end of the stream has been reached, the value -1 is returned. This method
* blocks until input data is available, the end of the stream is detected, or
* an exception is thrown.
* <p>
* If this class in not done accepting input streams and the end of the last known
* stream is reached, this method will block forever unless another thread
* adds an input stream or interrupts.
*
* @return the next byte of data, or -1 if the end of the stream is reached.
*
* @throws IOException if an I/O error occurs.
*/
@Override public int read() throws IOException {
if (closed) throw new IOException("InputStream closed");
int r = -1;
while (r == -1){
InputStream in = getCurrentInputStream();
if (in == null){
if (doneAddingInputStreams) return -1;
try {
Thread.sleep(100);
} catch (InterruptedException iox){
throw new IOException("Interrupted");
}
} else {
r = in.read();
if (r == -1) advanceToNextInputStream();
}
}
return r;
}
/**
* Reads some number of bytes from the underlying streams and stores them into
* the buffer array b. The number of bytes actually read is returned as an
* integer. This method blocks until input data is available, end of file is
* detected, or an exception is thrown.
* <p>
* If the length of b is zero,
* then no bytes are read and 0 is returned; otherwise, there is an attempt
* to read at least one byte.
* <p>
* The read(b) method for class InputStream has the same effect as:<br>
* read(b, 0, b.length)
* <p>
* If this class in not done accepting input streams and the end of the last known
* stream is reached, this method will block forever unless another thread
* adds an input stream or interrupts.
*
* @param b - Destination buffer
* @return The number of bytes read, or -1 if the end of the stream has been reached
*
* @throws IOException - If an I/O error occurs
* @throws NullPointerException - If b is null.
*
* @since ostermillerutils 1.04.00
*/
@Override public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
/**
* Reads up to length bytes of data from the underlying streams into an array of bytes.
* An attempt is made to read as many as length bytes, but a smaller number may be read,
* possibly zero. The number of bytes actually read is returned as an integer.
* <p>
* If length is zero,
* then no bytes are read and 0 is returned; otherwise, there is an attempt
* to read at least one byte.
* <p>
* This method blocks until input data is available
* <p>
* If this class in not done accepting input streams and the end of the last known
* stream is reached, this method will block forever unless another thread
* adds an input stream or interrupts.
*
* @param b Destination buffer
* @param off Offset at which to start storing bytes
* @param len Maximum number of bytes to read
* @return The number of bytes read, or -1 if the end of the stream has been reached
*
* @throws IOException - If an I/O error occurs
* @throws NullPointerException - If b is null.
* @throws IndexOutOfBoundsException - if length or offset are not possible.
*/
@Override public int read(byte[] b, int off, int len) throws IOException {
if (off < 0 || len < 0 || off + len > b.length) throw new IllegalArgumentException();
if (closed) throw new IOException("InputStream closed");
int r = -1;
while (r == -1){
InputStream in = getCurrentInputStream();
if (in == null){
if (doneAddingInputStreams) return -1;
try {
Thread.sleep(100);
} catch (InterruptedException iox){
throw new IOException("Interrupted");
}
} else {
r = in.read(b, off, len);
if (r == -1) advanceToNextInputStream();
}
}
return r;
}
/**
* Skips over and discards n bytes of data from this input stream. The skip method
* may, for a variety of reasons, end up skipping over some smaller number of bytes,
* possibly 0. This may result from any of a number of conditions; reaching end of
* file before n bytes have been skipped is only one possibility. The actual number
* of bytes skipped is returned. If n is negative, no bytes are skipped.
* <p>
* If this class in not done accepting input streams and the end of the last known
* stream is reached, this method will block forever unless another thread
* adds an input stream or interrupts.
*
* @param n he number of characters to skip
* @return The number of characters actually skipped
*
* @throws IOException If an I/O error occurs
*
* @since ostermillerutils 1.04.00
*/
@Override public long skip(long n) throws IOException {
if (closed) throw new IOException("InputStream closed");
if (n <= 0) return 0;
long s = -1;
while (s <= 0){
InputStream in = getCurrentInputStream();
if (in == null){
if (doneAddingInputStreams) return 0;
try {
Thread.sleep(100);
} catch (InterruptedException iox){
throw new IOException("Interrupted");
}
} else {
s = in.skip(n);
// When nothing was skipped it is a bit of a puzzle.
// The most common cause is that the end of the underlying
// stream was reached. In which case calling skip on it
// will always return zero. If somebody were calling skip
// until it skipped everything they needed, there would
// be an infinite loop if we were to return zero here.
// If we get zero, let us try to read one character so
// we can see if we are at the end of the stream. If so,
// we will move to the next.
if (s <= 0) {
// read() will advance to the next stream for us, so don't do it again
s = ((read()==-1)?-1:1);
}
}
}
return s;
}
/**
* Returns the number of bytes that can be read (or skipped over) from this input
* stream without blocking by the next caller of a method for this input stream.
* The next caller might be the same thread or or another thread.
*
* @throws IOException If an I/O error occurs
*
* @since ostermillerutils 1.04.00
*/
@Override public int available() throws IOException {
if (closed) throw new IOException("InputStream closed");
InputStream in = getCurrentInputStream();
if (in == null) return 0;
return in.available();
}
/**
* Closes this input stream and releases any system resources associated with the stream.
*
* @since ostermillerutils 1.04.00
*/
@Override public void close() throws IOException {
if (closed) return;
for (Object element: inputStreamQueue) {
((InputStream)element).close();
}
closed = true;
}
/**
* Mark not supported
*
* @since ostermillerutils 1.04.00
*/
@Override public void mark(int readlimit){
// Mark not supported -- do nothing
}
/**
* Reset not supported.
*
* @throws IOException because reset is not supported.
*
* @since ostermillerutils 1.04.00
*/
@Override public void reset() throws IOException {
throw new IOException("Reset not supported");
}
/**
* Does not support mark.
*
* @return false
*
* @since ostermillerutils 1.04.00
*/
@Override public boolean markSupported(){
return false;
}
}
| stephenostermiller/ostermillerutils | src/main/java/com/Ostermiller/util/ConcatInputStream.java | Java | gpl-2.0 | 13,411 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2432,
1011,
30524,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
6105,
2004,
2405,
2011,
1008,
1996,
2489,
4007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Locomotive
module LiquidExtras
module Filters
module Math
def round(input, digits = 0)
input.to_f.round(digits)
end
end
::Liquid::Template.register_filter(Math)
end
end
end
| warp/liquid_extras | lib/locomotive/liquid_extras/filters/math.rb | Ruby | mit | 239 | [
30522,
11336,
8098,
11336,
6381,
10288,
6494,
2015,
11336,
17736,
11336,
8785,
13366,
2461,
1006,
7953,
1010,
16648,
1027,
1014,
1007,
7953,
1012,
2000,
1035,
1042,
1012,
2461,
1006,
16648,
1007,
2203,
2203,
1024,
1024,
6381,
1024,
1024,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//// [inferTypes1.ts]
type Unpacked<T> =
T extends (infer U)[] ? U :
T extends (...args: any[]) => infer U ? U :
T extends Promise<infer U> ? U :
T;
type T00 = Unpacked<string>; // string
type T01 = Unpacked<string[]>; // string
type T02 = Unpacked<() => string>; // string
type T03 = Unpacked<Promise<string>>; // string
type T04 = Unpacked<Unpacked<Promise<string>[]>>; // string
type T05 = Unpacked<any>; // any
type T06 = Unpacked<never>; // never
function f1(s: string) {
return { a: 1, b: s };
}
class C {
x = 0;
y = 0;
}
type T10 = ReturnType<() => string>; // string
type T11 = ReturnType<(s: string) => void>; // void
type T12 = ReturnType<(<T>() => T)>; // {}
type T13 = ReturnType<(<T extends U, U extends number[]>() => T)>; // number[]
type T14 = ReturnType<typeof f1>; // { a: number, b: string }
type T15 = ReturnType<any>; // any
type T16 = ReturnType<never>; // never
type T17 = ReturnType<string>; // Error
type T18 = ReturnType<Function>; // Error
type U10 = InstanceType<typeof C>; // C
type U11 = InstanceType<any>; // any
type U12 = InstanceType<never>; // never
type U13 = InstanceType<string>; // Error
type U14 = InstanceType<Function>; // Error
type ArgumentType<T extends (x: any) => any> = T extends (a: infer A) => any ? A : any;
type T20 = ArgumentType<() => void>; // {}
type T21 = ArgumentType<(x: string) => number>; // string
type T22 = ArgumentType<(x?: string) => number>; // string | undefined
type T23 = ArgumentType<(...args: string[]) => number>; // string
type T24 = ArgumentType<(x: string, y: string) => number>; // Error
type T25 = ArgumentType<Function>; // Error
type T26 = ArgumentType<any>; // any
type T27 = ArgumentType<never>; // never
type X1<T extends { x: any, y: any }> = T extends { x: infer X, y: infer Y } ? [X, Y] : any;
type T30 = X1<{ x: any, y: any }>; // [any, any]
type T31 = X1<{ x: number, y: string }>; // [number, string]
type T32 = X1<{ x: number, y: string, z: boolean }>; // [number, string]
type X2<T> = T extends { a: infer U, b: infer U } ? U : never;
type T40 = X2<{}>; // never
type T41 = X2<{ a: string }>; // never
type T42 = X2<{ a: string, b: string }>; // string
type T43 = X2<{ a: number, b: string }>; // string | number
type T44 = X2<{ a: number, b: string, c: boolean }>; // string | number
type X3<T> = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;
type T50 = X3<{}>; // never
type T51 = X3<{ a: (x: string) => void }>; // never
type T52 = X3<{ a: (x: string) => void, b: (x: string) => void }>; // string
type T53 = X3<{ a: (x: number) => void, b: (x: string) => void }>; // string & number
type T54 = X3<{ a: (x: number) => void, b: () => void }>; // number
type T60 = infer U; // Error
type T61<T> = infer A extends infer B ? infer C : infer D; // Error
type T62<T> = U extends (infer U)[] ? U : U; // Error
type T63<T> = T extends (infer A extends infer B ? infer C : infer D) ? string : number;
type T70<T extends string> = { x: T };
type T71<T> = T extends T70<infer U> ? T70<U> : never;
type T72<T extends number> = { y: T };
type T73<T> = T extends T72<infer U> ? T70<U> : never; // Error
type T74<T extends number, U extends string> = { x: T, y: U };
type T75<T> = T extends T74<infer U, infer U> ? T70<U> | T72<U> | T74<U, U> : never;
type T76<T extends T[], U extends T> = { x: T };
type T77<T> = T extends T76<infer X, infer Y> ? T76<X, Y> : never;
type T78<T> = T extends T76<infer X, infer X> ? T76<X, X> : never;
type Foo<T extends string, U extends T> = [T, U];
type Bar<T> = T extends Foo<infer X, infer Y> ? Foo<X, Y> : never;
type T90 = Bar<[string, string]>; // [string, string]
type T91 = Bar<[string, "a"]>; // [string, "a"]
type T92 = Bar<[string, "a"] & { x: string }>; // [string, "a"]
type T93 = Bar<["a", string]>; // never
type T94 = Bar<[number, number]>; // never
// Example from #21496
type JsonifiedObject<T extends object> = { [K in keyof T]: Jsonified<T[K]> };
type Jsonified<T> =
T extends string | number | boolean | null ? T
: T extends undefined | Function ? never // undefined and functions are removed
: T extends { toJSON(): infer R } ? R // toJSON is called if it exists (e.g. Date)
: T extends object ? JsonifiedObject<T>
: "what is this";
type Example = {
str: "literalstring",
fn: () => void,
date: Date,
customClass: MyClass,
obj: {
prop: "property",
clz: MyClass,
nested: { attr: Date }
},
}
declare class MyClass {
toJSON(): "correct";
}
type JsonifiedExample = Jsonified<Example>;
declare let ex: JsonifiedExample;
const z1: "correct" = ex.customClass;
const z2: string = ex.obj.nested.attr;
// Repros from #21631
type A1<T, U extends A1<any, any>> = [T, U];
type B1<S> = S extends A1<infer T, infer U> ? [T, U] : never;
type A2<T, U extends void> = [T, U];
type B2<S> = S extends A2<infer T, infer U> ? [T, U] : never;
type C2<S, U extends void> = S extends A2<infer T, U> ? [T, U] : never;
// Repro from #21735
type A<T> = T extends string ? { [P in T]: void; } : T;
type B<T> = string extends T ? { [P in T]: void; } : T; // Error
// Repro from #22302
type MatchingKeys<T, U, K extends keyof T = keyof T> =
K extends keyof T ? T[K] extends U ? K : never : never;
type VoidKeys<T> = MatchingKeys<T, void>;
interface test {
a: 1,
b: void
}
type T80 = MatchingKeys<test, void>;
type T81 = VoidKeys<test>;
// Repro from #22221
type MustBeString<T extends string> = T;
type EnsureIsString<T> = T extends MustBeString<infer U> ? U : never;
type Test1 = EnsureIsString<"hello">; // "hello"
type Test2 = EnsureIsString<42>; // never
//// [inferTypes1.js]
"use strict";
function f1(s) {
return { a: 1, b: s };
}
var C = /** @class */ (function () {
function C() {
this.x = 0;
this.y = 0;
}
return C;
}());
var z1 = ex.customClass;
var z2 = ex.obj.nested.attr;
| domchen/typescript-plus | tests/baselines/reference/inferTypes1.js | JavaScript | apache-2.0 | 5,975 | [
30522,
1013,
1013,
1013,
1013,
1031,
1999,
7512,
13874,
2015,
2487,
1012,
24529,
1033,
2828,
4895,
23947,
2098,
1026,
1056,
1028,
30524,
1999,
7512,
1057,
1028,
1029,
1057,
1024,
1056,
1025,
2828,
1056,
8889,
1027,
4895,
23947,
2098,
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... |
# ethereumjs-icap
[](https://www.npmjs.org/package/ethereumjs-icap)
[](https://travis-ci.org/ethereumjs/ethereumjs-icap)
[](https://coveralls.io/r/ethereumjs/ethereumjs-icap)
[](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode
Utilities for handling [ICAP](https://github.com/ethereum/wiki/wiki/ICAP:-Inter-exchange-Client-Address-Protocol) addresses.
It works in Node.js as well as in the browser via `browserify`. When minified for a browser, it should be less than 4K in size.
## API
* `fromAddress(address, print, nonstd)` - try encoding an address into an IBAN
* `fromAsset(asset, print)` - try encoding an asset description into an IBAN
* `toAddress(iban)` - try decoding an IBAN into an address
* `toAsset(iban)` - try decoding an IBAN into an asset description
* `encode(address/asset)` - encode an address or asset description into an IBAN
* `decode(iban)` - decode an IBAN into an address or asset description
* `encodeBBAN(address/asset)` - encode an address or asset description into a BBAN
* `decodeBBAN(bban)` - decode a BBAN into an address or asset description
* `isICAP(iban)` - return true if input is a valid ICAP, otherwise false
* `isAddress(iban)` - return true if the input is a valid ICAP with an address, otherwise false
* `isAsset(iban)` - return true if the input is a valid ICAP with an asset description, otherwise false
All of the above methods will throw exceptions on invalid inputs. The `to*` and `from*` method will also check for the expected inputs and outputs.
The `print` parameter above, when set to true, will create an IBAN in the *print format*, which is space delimited groups of four characters: `XE73 38O0 73KY GTWW ZN0F 2WZ0 R8PX 5ZPP ZS`
The `address` parameter only supports `0x` prefixed input and will include that in the output.
The `nonstd` parameter of `fromAddress`, when set to true, will turn on support for the *basic ICAP format* generating an invalid IBAN, but encoding the entire 160 bits of an Ethereum address.
## Examples
```js
ICAP.fromAsset({
asset: 'ETH',
institution: 'XREG',
client: 'GAVOFYORK'
})
// returns 'XE81ETHXREGGAVOFYORK'
ICAP.fromAddress('0x00c5496aee77c1ba1f0854206a26dda82a81d6d8')
// returns 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS'
ICAP.toAsset('XE81ETHXREGGAVOFYORK')
// returns {
// asset: 'ETH',
// institution: 'XREG',
// client: 'GAVOFYORK'
// }
ICAP.toAddress('XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS')
// returns '0x00c5496aee77c1ba1f0854206a26dda82a81d6d8'
```
## *Direct* address generation
A *direct address ICAP* is an address less than 155 bits of length and therefore it safely fits into the length restrictions of IBAN (and the checksum method used).
That upper limit is `0x03ffffffffffffffffffffffffffffffffffffff` or `XE91GTJRJEU5043IEF993XWE21DBF0BVGF`.
The following simple bruteforce code can be used to generate such addresses:
```js
const ethUtil = require('ethereumjs-util')
function generateDirectAddress () {
while(true) {
var privateKey = crypto.randomBytes(32) // or your favourite other random method
if (ethUtil.privateToAddress(privateKey)[0] <= 3) {
return privateKey
}
}
}
```
Alternatively [`ethereumjs-wallet`](http://npmjs.com/packages/ethereumjs-wallet) can be used to generate compatible addresses.
| ethereumjs/ethereumjs-icap | README.md | Markdown | mit | 3,666 | [
30522,
1001,
28855,
14820,
22578,
1011,
24582,
9331,
1031,
999,
1031,
27937,
2213,
7427,
1033,
1006,
16770,
1024,
1013,
1013,
10047,
2290,
1012,
11824,
1012,
22834,
1013,
27937,
2213,
1013,
1058,
1013,
28855,
14820,
22578,
1011,
24582,
9331,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//
// BPPopToast.h
// BPKITsDemo
//
// Created by mikeooye on 15-3-28.
// Copyright (c) 2015年 ihojin. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface BPPopToast : UIView
@property (copy, nonatomic) NSString *text;
- (void)popToastAtRect:(CGRect)rect inView:(UIView *)view;
@end
@interface NSString (BPPopToast)
- (void)popToastAtRect:(CGRect)rect inView:(UIView *)view;
@end | mikeooye/BPKITs | Views/BPPopToast.h | C | mit | 397 | [
30522,
1013,
1013,
1013,
1013,
17531,
16340,
3406,
14083,
1012,
1044,
1013,
1013,
17531,
23615,
16150,
6633,
2080,
1013,
1013,
1013,
1013,
2580,
2011,
3505,
9541,
6672,
2006,
2321,
1011,
1017,
1011,
2654,
1012,
1013,
1013,
9385,
1006,
1039,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2009 Niek Linnenbank, 2012 Felipe Cabrera, 2014 Daniel Martin
*
* 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/>.
*/
#include <TerminalCodes.h>
#include "Shell.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
int Shell::run()
{
char *cmdStr;
char host[128], cwd[128] = "/home/";
/* Retrieve current hostname. */
gethostname(host, sizeof(host));
strncat(cwd,host,strlen(host));
chdir(cwd);
usrdir = cwd;
/* Ejecutamos la rutina de inicio
* execute("sh init");
* printf("\r\n");
*/
/* Lee los comandos. */
while(true) {
/* Imprime el prompt. */
prompt();
/* Espera un comando. */
cmdStr = getCommand();
/* Enough input? */
if (strlen(cmdStr) == 0)
continue;
/* Ejecuta el comando. */
execute(cmdStr);
}
return EXIT_SUCCESS;
}
int Shell::execute(char *command)
{
char *argv[MAX_ARGV];
char tmp[128];
ShellCommand *cmd;
Size argc;
int pid, status;
/* Argumento valido? */
if (!strlen(command))
return EXIT_SUCCESS;
/* Comenzamos a extraer los argumentos. */
argc = parse(command, argv, MAX_ARGV);
/* Do we have a matching ShellCommand? */
if (!(cmd = ShellCommand::byName(argv[0]))) {
/* If not, try to execute it as a file directly. */
if ((pid = forkexec(argv[0], (const char **) argv)) >= 0) {
waitpid(pid, &status, 0);
return status;
}
/* Try to find it on the livecd filesystem. (temporary hardcoded PATH) */
else if ((snprintf(tmp, sizeof(tmp), "/bin/%s/%s", argv[0], argv[0]) &&
((pid = forkexec(tmp, (const char **) argv)) >= 0)) ||
(snprintf(tmp, sizeof(tmp), "/sbin/%s/%s", argv[0], argv[0]) &&
((pid = forkexec(tmp, (const char **) argv)) >= 0)) ||
(snprintf(tmp, sizeof(tmp), "/usr/bin/%s/%s", argv[0], argv[0]) &&
((pid = forkexec(tmp, (const char **) argv)) >= 0)))
{
waitpid(pid, &status, 0);
return status;
}
else
printf("%s: %s\r\n", argv[0],strerror(errno));
}
/* Argumentos suficientes? */
else if (argc - 1 < cmd->getMinimumParams())
printf("%s: no se han especificado los argumentos (%u minimo)\r\n",
cmd->getName(), cmd->getMinimumParams());
/* Lo ejecutamos. */
else
return cmd->execute(argc - 1, argv + 1);
/* Not successful. */
return EXIT_FAILURE;
}
char * Shell::getCommand()
{
char line[1024];
gets(line);
return line;
}
void Shell::prompt()
{
char host[128], cwd[128];
/* Retrieve current hostname. */
gethostname(host, sizeof(host));
/* Retrieve current working directory. */
getcwd(cwd, sizeof(cwd));
printf(WHITE GREEN "%s@amaya-os:" BLUE "%s" WHITE "$ ",
host, cwd);
}
Size Shell::parse(char *cmdline, char **argv, Size maxArgv)
{
Size argc;
for (argc = 0; argc < maxArgv && *cmdline; argc++) {
while (*cmdline && *cmdline == ' ')
cmdline++;
argv[argc] = cmdline;
while (*cmdline && *cmdline != ' ')
cmdline++;
if (*cmdline) *cmdline++ = ZERO;
}
argv[argc] = ZERO;
return argc;
}
| dalmemail/AmayaOS-English | bin/sh/Shell.cpp | C++ | gpl-3.0 | 4,103 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2268,
9152,
5937,
11409,
10224,
9299,
1010,
2262,
17095,
9298,
24068,
1010,
2297,
3817,
3235,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
Plugin Name: amCharts Data Loader
Description: This plugin adds external data loading capabilities to all amCharts libraries.
Author: Martynas Majeris, amCharts
Version: 1.0.2
Author URI: http://www.amcharts.com/
Copyright 2015 amCharts
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.
Please note that the above license covers only this plugin. It by all means does
not apply to any other amCharts products that are covered by different licenses.
*/
/**
* TODO:
* incremental load
* XML support (?)
*/
/**
* Initialize language prompt container
*/
AmCharts.translations.dataLoader = {}
/**
* Set init handler
*/
AmCharts.addInitHandler( function ( chart ) {
/**
* Check if dataLoader is set (initialize it)
*/
if ( undefined === chart.dataLoader || ! isObject( chart.dataLoader ) )
chart.dataLoader = {};
/**
* Check charts version for compatibility:
* the first compatible version is 3.13
*/
var version = chart.version.split( '.' );
if ( ( Number( version[0] ) < 3 ) || ( 3 == Number( version[0] ) && ( Number( version[1] ) < 13 ) ) )
return;
/**
* Define object reference for easy access
*/
var l = chart.dataLoader;
l.remaining = 0;
/**
* Set defaults
*/
var defaults = {
'async': true,
'format': 'json',
'showErrors': true,
'showCurtain': true,
'noStyles': false,
'reload': 0,
'timestamp': false,
'delimiter': ',',
'skip': 0,
'useColumnNames': false,
'reverse': false,
'reloading': false,
'complete': false,
'error': false
};
/**
* Load all files in a row
*/
if ( 'stock' === chart.type ) {
// delay this a little bit so the chart has the chance to build itself
setTimeout( function () {
// preserve animation
if ( 0 > chart.panelsSettings.startDuration ) {
l.startDuration = chart.panelsSettings.startDuration;
chart.panelsSettings.startDuration = 0;
}
// cycle through all of the data sets
for ( var x = 0; x < chart.dataSets.length; x++ ) {
var ds = chart.dataSets[ x ];
// load data
if ( undefined !== ds.dataLoader && undefined !== ds.dataLoader.url ) {
ds.dataProvider = [];
applyDefaults( ds.dataLoader );
loadFile( ds.dataLoader.url, ds, ds.dataLoader, 'dataProvider' );
}
// load events data
if ( undefined !== ds.eventDataLoader && undefined !== ds.eventDataLoader.url ) {
ds.events = [];
applyDefaults( ds.eventDataLoader );
loadFile( ds.eventDataLoader.url, ds, ds.eventDataLoader, 'stockEvents' );
}
}
}, 100 );
}
else {
applyDefaults( l );
if ( undefined === l.url )
return;
// preserve animation
if ( undefined !== chart.startDuration && ( 0 < chart.startDuration ) ) {
l.startDuration = chart.startDuration;
chart.startDuration = 0;
}
chart.dataProvider = [];
loadFile( l.url, chart, l, 'dataProvider' );
}
/**
* Loads a file and determines correct parsing mechanism for it
*/
function loadFile( url, holder, options, providerKey ) {
// set default providerKey
if ( undefined === providerKey )
providerKey = 'dataProvider';
// show curtain
if ( options.showCurtain )
showCurtain( undefined, options.noStyles );
// increment loader count
l.remaining++;
// load the file
AmCharts.loadFile( url, options, function ( response ) {
// error?
if ( false === response ) {
callFunction( options.error, url, options );
raiseError( AmCharts.__( 'Error loading the file', chart.language ) + ': ' + url, false, options );
}
else {
// determine the format
if ( undefined === options.format ) {
// TODO
options.format = 'json';
}
// lowercase
options.format = options.format.toLowerCase();
// invoke parsing function
switch( options.format ) {
case 'json':
holder[providerKey] = AmCharts.parseJSON( response, options );
if ( false === holder[providerKey] ) {
callFunction( options.error, options );
raiseError( AmCharts.__( 'Error parsing JSON file', chart.language ) + ': ' + l.url, false, options );
holder[providerKey] = [];
return;
}
else {
holder[providerKey] = postprocess( holder[providerKey], options );
callFunction( options.load, options );
}
break;
case 'csv':
holder[providerKey] = AmCharts.parseCSV( response, options );
if ( false === holder[providerKey] ) {
callFunction( options.error, options );
raiseError( AmCharts.__( 'Error parsing CSV file', chart.language ) + ': ' + l.url, false, options );
holder[providerKey] = [];
return;
}
else {
holder[providerKey] = postprocess( holder[providerKey], options );
callFunction( options.load, options );
}
break;
default:
callFunction( options.error, options );
raiseError( AmCharts.__( 'Unsupported data format', chart.language ) + ': ' + options.format, false, options.noStyles );
return;
break;
}
// decrement remaining counter
l.remaining--;
// we done?
if ( 0 === l.remaining ) {
// callback
callFunction( options.complete );
// take in the new data
if ( options.async ) {
if ( 'map' === chart.type )
chart.validateNow( true );
else {
// take in new data
chart.validateData();
// make the chart animate again
if ( l.startDuration ) {
if ( 'stock' === chart.type ) {
chart.panelsSettings.startDuration = l.startDuration;
for ( var x = 0; x < chart.panels.length; x++ ) {
chart.panels[x].startDuration = l.startDuration;
chart.panels[x].animateAgain();
}
}
else {
chart.startDuration = l.startDuration;
chart.animateAgain();
}
}
}
}
// restore default period
if ( 'stock' === chart.type && ! options.reloading )
chart.periodSelector.setDefaultPeriod();
// remove curtain
removeCurtain();
}
// schedule another load of necessary
if ( options.reload ) {
if ( options.timeout )
clearTimeout( options.timeout );
options.timeout = setTimeout( loadFile, 1000 * options.reload, url, holder, options );
options.reloading = true;
}
}
} );
}
/**
* Checks if postProcess is set and invokes the handler
*/
function postprocess ( data, options ) {
if ( undefined !== options.postProcess && isFunction( options.postProcess ) )
try {
return options.postProcess.call( this, data, options );
}
catch ( e ) {
raiseError( AmCharts.__( 'Error loading file', chart.language ) + ': ' + options.url, false, options );
return data;
}
else
return data;
}
/**
* Returns true if argument is object
*/
function isArray ( obj ) {
return obj instanceof Array;
}
/**
* Returns true if argument is array
*/
function isObject ( obj ) {
return 'object' === typeof( obj );
}
/**
* Returns true is argument is a function
*/
function isFunction ( obj ) {
return 'function' === typeof( obj );
}
/**
* Applies defaults to config object
*/
function applyDefaults ( obj ) {
for ( var x = 0; x < defaults.length; x++ ) {
setDefault( obj, x, defaults[ x ] );
}
}
/**
* Checks if object property is set, sets with a default if it isn't
*/
function setDefault ( obj, key, value ) {
if ( undefined === obj[ key ] )
obj[ key ] = value;
}
/**
* Raises an internal error (writes it out to console)
*/
function raiseError ( msg, error, options ) {
if ( options.showErrors )
showCurtain( msg, options.noStyles );
else {
removeCurtain();
console.log( msg );
}
}
/**
* Shows curtain over chart area
*/
function showCurtain ( msg, noStyles ) {
// remove previous curtain if there is one
removeCurtain();
// did we pass in the message?
if ( undefined === msg )
msg = AmCharts.__( 'Loading data...', chart.language );
// create and populate curtain element
var curtain =document.createElement( 'div' );
curtain.setAttribute( 'id', chart.div.id + '-curtain' );
curtain.className = 'amcharts-dataloader-curtain';
if ( true !== noStyles ) {
curtain.style.position = 'absolute';
curtain.style.top = 0;
curtain.style.left = 0;
curtain.style.width = ( undefined !== chart.realWidth ? chart.realWidth : chart.divRealWidth ) + 'px';
curtain.style.height = ( undefined !== chart.realHeight ? chart.realHeight : chart.divRealHeight ) + 'px';
curtain.style.textAlign = 'center';
curtain.style.display = 'table';
curtain.style.fontSize = '20px';
curtain.style.background = 'rgba(255, 255, 255, 0.3)';
curtain.innerHTML = '<div style="display: table-cell; vertical-align: middle;">' + msg + '</div>';
}
else {
curtain.innerHTML = msg;
}
chart.containerDiv.appendChild( curtain );
l.curtain = curtain;
}
/**
* Removes the curtain
*/
function removeCurtain () {
try {
if ( undefined !== l.curtain )
chart.containerDiv.removeChild( l.curtain );
}
catch ( e ) {
// do nothing
}
l.curtain = undefined;
}
/**
* Execute callback function
*/
function callFunction ( func, param1, param2 ) {
if ( 'function' === typeof func )
func.call( l, param1, param2 );
}
}, [ 'pie', 'serial', 'xy', 'funnel', 'radar', 'gauge', 'gantt', 'stock', 'map' ] );
/**
* Returns prompt in a chart language (set by chart.language) if it is
* available
*/
if ( undefined === AmCharts.__ ) {
AmCharts.__ = function ( msg, language ) {
if ( undefined !== language
&& undefined !== AmCharts.translations.dataLoader[ chart.language ]
&& undefined !== AmCharts.translations.dataLoader[ chart.language ][ msg ] )
return AmCharts.translations.dataLoader[ chart.language ][ msg ];
else
return msg;
}
}
/**
* Loads a file from url and calls function handler with the result
*/
AmCharts.loadFile = function ( url, options, handler ) {
// create the request
if ( window.XMLHttpRequest ) {
// IE7+, Firefox, Chrome, Opera, Safari
var request = new XMLHttpRequest();
} else {
// code for IE6, IE5
var request = new ActiveXObject( 'Microsoft.XMLHTTP' );
}
// set handler for data if async loading
request.onreadystatechange = function () {
if ( 4 == request.readyState && 404 == request.status )
handler.call( this, false );
else if ( 4 == request.readyState && 200 == request.status )
handler.call( this, request.responseText );
}
// load the file
try {
request.open( 'GET', options.timestamp ? AmCharts.timestampUrl( url ) : url, options.async );
request.send();
}
catch ( e ) {
handler.call( this, false );
}
};
/**
* Parses JSON string into an object
*/
AmCharts.parseJSON = function ( response, options ) {
try {
if ( undefined !== JSON )
return JSON.parse( response );
else
return eval( response );
}
catch ( e ) {
return false;
}
}
/**
* Prases CSV string into an object
*/
AmCharts.parseCSV = function ( response, options ) {
// parse CSV into array
var data = AmCharts.CSVToArray( response, options.delimiter );
// init resuling array
var res = [];
var cols = [];
// first row holds column names?
if ( options.useColumnNames ) {
cols = data.shift();
// normalize column names
for ( var x = 0; x < cols.length; x++ ) {
// trim
var col = cols[ x ].replace( /^\s+|\s+$/gm, '' );
// check for empty
if ( '' === col )
col = 'col' + x;
cols[ x ] = col;
}
if ( 0 < options.skip )
options.skip--;
}
// skip rows
for ( var i = 0; i < options.skip; i++ )
data.shift();
// iterate through the result set
var row;
while ( row = options.reverse ? data.pop() : data.shift() ) {
var dataPoint = {};
for ( var i = 0; i < row.length; i++ ) {
var col = undefined === cols[ i ] ? 'col' + i : cols[ i ];
dataPoint[ col ] = row[ i ];
}
res.push( dataPoint );
}
return res;
}
/**
* Parses CSV data into array
* Taken from here: (thanks!)
* http://www.bennadel.com/blog/1504-ask-ben-parsing-csv-strings-with-javascript-exec-regular-expression-command.htm
*/
AmCharts.CSVToArray = function ( strData, strDelimiter ){
// Check to see if the delimiter is defined. If not,
// then default to comma.
strDelimiter = (strDelimiter || ",");
// Create a regular expression to parse the CSV values.
var objPattern = new RegExp(
(
// Delimiters.
"(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +
// Quoted fields.
"(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +
// Standard fields.
"([^\"\\" + strDelimiter + "\\r\\n]*))"
),
"gi"
);
// Create an array to hold our data. Give the array
// a default empty first row.
var arrData = [[]];
// Create an array to hold our individual pattern
// matching groups.
var arrMatches = null;
// Keep looping over the regular expression matches
// until we can no longer find a match.
while (arrMatches = objPattern.exec( strData )){
// Get the delimiter that was found.
var strMatchedDelimiter = arrMatches[ 1 ];
// Check to see if the given delimiter has a length
// (is not the start of string) and if it matches
// field delimiter. If id does not, then we know
// that this delimiter is a row delimiter.
if (
strMatchedDelimiter.length &&
(strMatchedDelimiter != strDelimiter)
){
// Since we have reached a new row of data,
// add an empty row to our data array.
arrData.push( [] );
}
// Now that we have our delimiter out of the way,
// let's check to see which kind of value we
// captured (quoted or unquoted).
if (arrMatches[ 2 ]){
// We found a quoted value. When we capture
// this value, unescape any double quotes.
var strMatchedValue = arrMatches[ 2 ].replace(
new RegExp( "\"\"", "g" ),
"\""
);
} else {
// We found a non-quoted value.
var strMatchedValue = arrMatches[ 3 ];
}
// Now that we have our value string, let's add
// it to the data array.
arrData[ arrData.length - 1 ].push( strMatchedValue );
}
// Return the parsed data.
return( arrData );
}
/**
* Appends timestamp to the url
*/
AmCharts.timestampUrl = function ( url ) {
var p = url.split( '?' );
if ( 1 === p.length )
p[1] = new Date().getTime();
else
p[1] += '&' + new Date().getTime();
return p.join( '?' );
} | abhikalotra/Salon-Solutions | theme/backend/assets/global/plugins/amcharts/ammap/plugins/dataloader/dataloader.js | JavaScript | mit | 16,824 | [
30522,
1013,
1008,
13354,
2378,
2171,
1024,
21962,
10686,
2015,
2951,
7170,
2121,
6412,
1024,
2023,
13354,
2378,
9909,
6327,
2951,
10578,
9859,
2000,
2035,
21962,
10686,
2015,
8860,
1012,
3166,
1024,
12578,
11649,
16686,
11124,
2015,
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... |
/*
* 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.
*/
#pragma once
#include <aws/comprehend/Comprehend_EXPORTS.h>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace Comprehend
{
namespace Model
{
/**
* <p>Detailed information about the accuracy of an entity recognizer for a
* specific entity type. </p><p><h3>See Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/EntityTypesEvaluationMetrics">AWS
* API Reference</a></p>
*/
class AWS_COMPREHEND_API EntityTypesEvaluationMetrics
{
public:
EntityTypesEvaluationMetrics();
EntityTypesEvaluationMetrics(Aws::Utils::Json::JsonView jsonValue);
EntityTypesEvaluationMetrics& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p>A measure of the usefulness of the recognizer results for a specific entity
* type in the test data. High precision means that the recognizer returned
* substantially more relevant results than irrelevant ones. </p>
*/
inline double GetPrecision() const{ return m_precision; }
/**
* <p>A measure of the usefulness of the recognizer results for a specific entity
* type in the test data. High precision means that the recognizer returned
* substantially more relevant results than irrelevant ones. </p>
*/
inline bool PrecisionHasBeenSet() const { return m_precisionHasBeenSet; }
/**
* <p>A measure of the usefulness of the recognizer results for a specific entity
* type in the test data. High precision means that the recognizer returned
* substantially more relevant results than irrelevant ones. </p>
*/
inline void SetPrecision(double value) { m_precisionHasBeenSet = true; m_precision = value; }
/**
* <p>A measure of the usefulness of the recognizer results for a specific entity
* type in the test data. High precision means that the recognizer returned
* substantially more relevant results than irrelevant ones. </p>
*/
inline EntityTypesEvaluationMetrics& WithPrecision(double value) { SetPrecision(value); return *this;}
/**
* <p>A measure of how complete the recognizer results are for a specific entity
* type in the test data. High recall means that the recognizer returned most of
* the relevant results.</p>
*/
inline double GetRecall() const{ return m_recall; }
/**
* <p>A measure of how complete the recognizer results are for a specific entity
* type in the test data. High recall means that the recognizer returned most of
* the relevant results.</p>
*/
inline bool RecallHasBeenSet() const { return m_recallHasBeenSet; }
/**
* <p>A measure of how complete the recognizer results are for a specific entity
* type in the test data. High recall means that the recognizer returned most of
* the relevant results.</p>
*/
inline void SetRecall(double value) { m_recallHasBeenSet = true; m_recall = value; }
/**
* <p>A measure of how complete the recognizer results are for a specific entity
* type in the test data. High recall means that the recognizer returned most of
* the relevant results.</p>
*/
inline EntityTypesEvaluationMetrics& WithRecall(double value) { SetRecall(value); return *this;}
/**
* <p>A measure of how accurate the recognizer results are for for a specific
* entity type in the test data. It is derived from the <code>Precision</code> and
* <code>Recall</code> values. The <code>F1Score</code> is the harmonic average of
* the two scores. The highest score is 1, and the worst score is 0. </p>
*/
inline double GetF1Score() const{ return m_f1Score; }
/**
* <p>A measure of how accurate the recognizer results are for for a specific
* entity type in the test data. It is derived from the <code>Precision</code> and
* <code>Recall</code> values. The <code>F1Score</code> is the harmonic average of
* the two scores. The highest score is 1, and the worst score is 0. </p>
*/
inline bool F1ScoreHasBeenSet() const { return m_f1ScoreHasBeenSet; }
/**
* <p>A measure of how accurate the recognizer results are for for a specific
* entity type in the test data. It is derived from the <code>Precision</code> and
* <code>Recall</code> values. The <code>F1Score</code> is the harmonic average of
* the two scores. The highest score is 1, and the worst score is 0. </p>
*/
inline void SetF1Score(double value) { m_f1ScoreHasBeenSet = true; m_f1Score = value; }
/**
* <p>A measure of how accurate the recognizer results are for for a specific
* entity type in the test data. It is derived from the <code>Precision</code> and
* <code>Recall</code> values. The <code>F1Score</code> is the harmonic average of
* the two scores. The highest score is 1, and the worst score is 0. </p>
*/
inline EntityTypesEvaluationMetrics& WithF1Score(double value) { SetF1Score(value); return *this;}
private:
double m_precision;
bool m_precisionHasBeenSet;
double m_recall;
bool m_recallHasBeenSet;
double m_f1Score;
bool m_f1ScoreHasBeenSet;
};
} // namespace Model
} // namespace Comprehend
} // namespace Aws
| cedral/aws-sdk-cpp | aws-cpp-sdk-comprehend/include/aws/comprehend/model/EntityTypesEvaluationMetrics.h | C | apache-2.0 | 5,933 | [
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... |
package com.android.shelter.user;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import com.android.shelter.HomeActivity;
import com.android.shelter.R;
import com.android.shelter.user.landlord.PostPropertyActivity;
import com.facebook.login.widget.LoginButton;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.SignInButton;
public class LoginActivity extends AppCompatActivity implements View.OnClickListener{
private static final String TAG = "LoginActivity";
private static final int RC_SIGN_IN = 9001;
private UserSessionManager mUserSessionManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUserSessionManager = UserSessionManager.get(getApplicationContext());
mUserSessionManager.registerUserUpdateCallbacks(this, new IUserSessionUpdate() {
@Override
public void signInSuccessfull() {
Log.d(TAG, "Sign in successfull finsihing the activity");
Intent intent = getIntent();
if(intent.hasExtra(HomeActivity.EXTRA_SHOW_POST_PROPERTY) && intent.getBooleanExtra(HomeActivity.EXTRA_SHOW_POST_PROPERTY, false)){
Intent postProperty = PostPropertyActivity.newIntent(getApplicationContext(), null);
startActivityForResult(postProperty, HomeActivity.REQUEST_FRAGMENT);
}
setResult(HomeActivity.REQUEST_LOGIN);
finish();
}
@Override
public void signOutSuccessfull() {
Log.d(TAG, "Logout successfull");
}
});
setContentView(R.layout.activity_login);
LoginButton loginButton = (LoginButton) findViewById(R.id.authButton);
mUserSessionManager.registerFacebookLoginCallback(loginButton);
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
mUserSessionManager.setGoogleSignInButtonScopes(signInButton);
signInButton.setSize(SignInButton.SIZE_WIDE);
signInButton.setOnClickListener(this);
signInButton.setOnClickListener(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
@Override
protected void onStart() {
super.onStart();
//mUserSessionManager.onStartUpInitialization();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mUserSessionManager.callFacebookOnActivityResult(requestCode, resultCode, data);
Log.i(TAG, "OnActivityResult...");
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
mUserSessionManager.handleSignInResult(result);
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.sign_in_button:
signIn();
break;
}
}
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mUserSessionManager.getGoogleApiClient());
startActivityForResult(signInIntent, RC_SIGN_IN);
}
}
| CMPE277Shelter/shelterApp | Shelter/app/src/main/java/com/android/shelter/user/LoginActivity.java | Java | mit | 3,544 | [
30522,
7427,
4012,
1012,
11924,
1012,
7713,
1012,
5310,
1025,
12324,
11924,
1012,
10439,
1012,
4023,
1025,
12324,
11924,
1012,
4180,
1012,
7848,
1025,
12324,
11924,
1012,
9808,
1012,
14012,
1025,
12324,
11924,
1012,
2490,
1012,
1058,
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... |
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* 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 NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK 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.
*
* @flow
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {
Text,
TextInput,
View,
StyleSheet,
} = ReactNative;
var TextEventsExample = React.createClass({
getInitialState: function() {
return {
curText: '<No Event>',
prevText: '<No Event>',
prev2Text: '<No Event>',
};
},
updateText: function(text) {
this.setState((state) => {
return {
curText: text,
prevText: state.curText,
prev2Text: state.prevText,
};
});
},
render: function() {
return (
<View>
<TextInput
autoCapitalize="none"
placeholder="Enter text to see events"
autoCorrect={false}
onFocus={() => this.updateText('onFocus')}
onBlur={() => this.updateText('onBlur')}
onChange={(event) => this.updateText(
'onChange text: ' + event.nativeEvent.text
)}
onEndEditing={(event) => this.updateText(
'onEndEditing text: ' + event.nativeEvent.text
)}
onSubmitEditing={(event) => this.updateText(
'onSubmitEditing text: ' + event.nativeEvent.text
)}
style={styles.singleLine}
/>
<Text style={styles.eventLabel}>
{this.state.curText}{'\n'}
(prev: {this.state.prevText}){'\n'}
(prev2: {this.state.prev2Text})
</Text>
</View>
);
}
});
class AutoExpandingTextInput extends React.Component {
constructor(props) {
super(props);
this.state = {
text: 'React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.',
height: 0,
};
}
render() {
return (
<TextInput
{...this.props}
multiline={true}
onContentSizeChange={(event) => {
this.setState({height: event.nativeEvent.contentSize.height});
}}
onChangeText={(text) => {
this.setState({text});
}}
style={[styles.default, {height: Math.max(35, this.state.height)}]}
value={this.state.text}
/>
);
}
}
class RewriteExample extends React.Component {
constructor(props) {
super(props);
this.state = {text: ''};
}
render() {
var limit = 20;
var remainder = limit - this.state.text.length;
var remainderColor = remainder > 5 ? 'blue' : 'red';
return (
<View style={styles.rewriteContainer}>
<TextInput
multiline={false}
maxLength={limit}
onChangeText={(text) => {
text = text.replace(/ /g, '_');
this.setState({text});
}}
style={styles.default}
value={this.state.text}
/>
<Text style={[styles.remainder, {color: remainderColor}]}>
{remainder}
</Text>
</View>
);
}
}
class TokenizedTextExample extends React.Component {
constructor(props) {
super(props);
this.state = {text: 'Hello #World'};
}
render() {
//define delimiter
let delimiter = /\s+/;
//split string
let _text = this.state.text;
let token, index, parts = [];
while (_text) {
delimiter.lastIndex = 0;
token = delimiter.exec(_text);
if (token === null) {
break;
}
index = token.index;
if (token[0].length === 0) {
index = 1;
}
parts.push(_text.substr(0, index));
parts.push(token[0]);
index = index + token[0].length;
_text = _text.slice(index);
}
parts.push(_text);
//highlight hashtags
parts = parts.map((text) => {
if (/^#/.test(text)) {
return <Text key={text} style={styles.hashtag}>{text}</Text>;
} else {
return text;
}
});
return (
<View>
<TextInput
multiline={true}
style={styles.multiline}
onChangeText={(text) => {
this.setState({text});
}}>
<Text>{parts}</Text>
</TextInput>
</View>
);
}
}
var BlurOnSubmitExample = React.createClass({
focusNextField(nextField) {
this.refs[nextField].focus();
},
render: function() {
return (
<View>
<TextInput
ref="1"
style={styles.singleLine}
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.focusNextField('2')}
/>
<TextInput
ref="2"
style={styles.singleLine}
keyboardType="email-address"
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.focusNextField('3')}
/>
<TextInput
ref="3"
style={styles.singleLine}
keyboardType="url"
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.focusNextField('4')}
/>
<TextInput
ref="4"
style={styles.singleLine}
keyboardType="numeric"
placeholder="blurOnSubmit = false"
blurOnSubmit={false}
onSubmitEditing={() => this.focusNextField('5')}
/>
<TextInput
ref="5"
style={styles.singleLine}
keyboardType="numbers-and-punctuation"
placeholder="blurOnSubmit = true"
returnKeyType="done"
/>
</View>
);
}
});
var styles = StyleSheet.create({
multiline: {
height: 60,
fontSize: 16,
padding: 4,
marginBottom: 10,
},
eventLabel: {
margin: 3,
fontSize: 12,
},
singleLine: {
fontSize: 16,
padding: 4,
},
singleLineWithHeightTextInput: {
height: 30,
},
hashtag: {
color: 'blue',
fontWeight: 'bold',
},
});
exports.title = '<TextInput>';
exports.description = 'Single and multi-line text inputs.';
exports.examples = [
{
title: 'Auto-focus',
render: function() {
return (
<TextInput
autoFocus={true}
style={styles.singleLine}
accessibilityLabel="I am the accessibility label for text input"
/>
);
}
},
{
title: "Live Re-Write (<sp> -> '_')",
render: function() {
return <RewriteExample />;
}
},
{
title: 'Auto-capitalize',
render: function() {
var autoCapitalizeTypes = [
'none',
'sentences',
'words',
'characters',
];
var examples = autoCapitalizeTypes.map((type) => {
return (
<TextInput
key={type}
autoCapitalize={type}
placeholder={'autoCapitalize: ' + type}
style={styles.singleLine}
/>
);
});
return <View>{examples}</View>;
}
},
{
title: 'Auto-correct',
render: function() {
return (
<View>
<TextInput
autoCorrect={true}
placeholder="This has autoCorrect"
style={styles.singleLine}
/>
<TextInput
autoCorrect={false}
placeholder="This does not have autoCorrect"
style={styles.singleLine}
/>
</View>
);
}
},
{
title: 'Keyboard types',
render: function() {
var keyboardTypes = [
'default',
'email-address',
'numeric',
'phone-pad',
];
var examples = keyboardTypes.map((type) => {
return (
<TextInput
key={type}
keyboardType={type}
placeholder={'keyboardType: ' + type}
style={styles.singleLine}
/>
);
});
return <View>{examples}</View>;
}
},
{
title: 'Blur on submit',
render: function(): ReactElement { return <BlurOnSubmitExample />; },
},
{
title: 'Event handling',
render: function(): ReactElement { return <TextEventsExample />; },
},
{
title: 'Colors and text inputs',
render: function() {
return (
<View>
<TextInput
style={[styles.singleLine]}
defaultValue="Default color text"
/>
<TextInput
style={[styles.singleLine, {color: 'green'}]}
defaultValue="Green Text"
/>
<TextInput
placeholder="Default placeholder text color"
style={styles.singleLine}
/>
<TextInput
placeholder="Red placeholder text color"
placeholderTextColor="red"
style={styles.singleLine}
/>
<TextInput
placeholder="Default underline color"
style={styles.singleLine}
/>
<TextInput
placeholder="Blue underline color"
style={styles.singleLine}
underlineColorAndroid="blue"
/>
<TextInput
defaultValue="Same BackgroundColor as View "
style={[styles.singleLine, {backgroundColor: 'rgba(100, 100, 100, 0.3)'}]}>
<Text style={{backgroundColor: 'rgba(100, 100, 100, 0.3)'}}>
Darker backgroundColor
</Text>
</TextInput>
<TextInput
defaultValue="Highlight Color is red"
selectionColor={'red'}
style={styles.singleLine}>
</TextInput>
</View>
);
}
},
{
title: 'Text input, themes and heights',
render: function() {
return (
<TextInput
placeholder="If you set height, beware of padding set from themes"
style={[styles.singleLineWithHeightTextInput]}
/>
);
}
},
{
title: 'fontFamily, fontWeight and fontStyle',
render: function() {
return (
<View>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif'}]}
placeholder="Custom fonts like Sans-Serif are supported"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif', fontWeight: 'bold'}]}
placeholder="Sans-Serif bold"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif', fontStyle: 'italic'}]}
placeholder="Sans-Serif italic"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'serif'}]}
placeholder="Serif"
/>
</View>
);
}
},
{
title: 'Passwords',
render: function() {
return (
<View>
<TextInput
defaultValue="iloveturtles"
secureTextEntry={true}
style={styles.singleLine}
/>
<TextInput
secureTextEntry={true}
style={[styles.singleLine, {color: 'red'}]}
placeholder="color is supported too"
placeholderTextColor="red"
/>
</View>
);
}
},
{
title: 'Editable',
render: function() {
return (
<TextInput
defaultValue="Can't touch this! (>'-')> ^(' - ')^ <('-'<) (>'-')> ^(' - ')^"
editable={false}
style={styles.singleLine}
/>
);
}
},
{
title: 'Multiline',
render: function() {
return (
<View>
<TextInput
autoCorrect={true}
placeholder="multiline, aligned top-left"
placeholderTextColor="red"
multiline={true}
style={[styles.multiline, {textAlign: "left", textAlignVertical: "top"}]}
/>
<TextInput
autoCorrect={true}
placeholder="multiline, aligned center"
placeholderTextColor="green"
multiline={true}
style={[styles.multiline, {textAlign: "center", textAlignVertical: "center"}]}
/>
<TextInput
autoCorrect={true}
multiline={true}
style={[styles.multiline, {color: 'blue'}, {textAlign: "right", textAlignVertical: "bottom"}]}>
<Text style={styles.multiline}>multiline with children, aligned bottom-right</Text>
</TextInput>
</View>
);
}
},
{
title: 'Fixed number of lines',
platform: 'android',
render: function() {
return (
<View>
<TextInput numberOfLines={2}
multiline={true}
placeholder="Two line input"
/>
<TextInput numberOfLines={5}
multiline={true}
placeholder="Five line input"
/>
</View>
);
}
},
{
title: 'Auto-expanding',
render: function() {
return (
<View>
<AutoExpandingTextInput
placeholder="height increases with content"
enablesReturnKeyAutomatically={true}
returnKeyType="done"
/>
</View>
);
}
},
{
title: 'Attributed text',
render: function() {
return <TokenizedTextExample />;
}
},
{
title: 'Return key',
render: function() {
var returnKeyTypes = [
'none',
'go',
'search',
'send',
'done',
'previous',
'next',
];
var returnKeyLabels = [
'Compile',
'React Native',
];
var examples = returnKeyTypes.map((type) => {
return (
<TextInput
key={type}
returnKeyType={type}
placeholder={'returnKeyType: ' + type}
style={styles.singleLine}
/>
);
});
var types = returnKeyLabels.map((type) => {
return (
<TextInput
key={type}
returnKeyLabel={type}
placeholder={'returnKeyLabel: ' + type}
style={styles.singleLine}
/>
);
});
return <View>{examples}{types}</View>;
}
},
{
title: 'Inline Images',
render: function() {
return (
<View>
<TextInput
inlineImageLeft="ic_menu_black_24dp"
placeholder="This has drawableLeft set"
style={styles.singleLine}
/>
<TextInput
inlineImageLeft="ic_menu_black_24dp"
inlineImagePadding={30}
placeholder="This has drawableLeft and drawablePadding set"
style={styles.singleLine}
/>
<TextInput
placeholder="This does not have drawable props set"
style={styles.singleLine}
/>
</View>
);
}
},
];
| mrspeaker/react-native | Examples/UIExplorer/js/TextInputExample.android.js | JavaScript | bsd-3-clause | 15,828 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2286,
1011,
2556,
1010,
9130,
1010,
4297,
1012,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
3120,
3642,
2003,
7000,
2104,
1996,
18667,
2094,
1011,
2806,
6105,
2179,
1999,
1996,
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... |
<!--
JBoss, Home of Professional Open Source
Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.
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.
-->
<html xmlns:wicket="http://wicket.sourceforge.net/">
<head>
<title>wicket-war</title>
</head>
<body>
<h1>
<span wicket:id="welcomeMessage"></span>
</h1>
<table border="1" cellpadding="8">
<tr>
<td width="200">Name</td>
<td width="200">Email</td>
<td width="200"> </td>
</tr>
<tr wicket:id="contacts">
<td><span wicket:id="name">[name]</span></td>
<td><span wicket:id="email">[email]</span></td>
<td><a href="#" wicket:id="delete">[delete]</a></td>
</tr>
</table>
<wicket:link><a href="InsertContact.html">Insert a new Contact</a></wicket:link>
</body>
</html>
| ejlp12/quickstart | wicket-war/src/main/java/org/jboss/as/quickstarts/wicketWar/pages/ListContacts.html | HTML | apache-2.0 | 1,559 | [
30522,
1026,
999,
1011,
1011,
1046,
15853,
2015,
1010,
2188,
1997,
2658,
2330,
3120,
9385,
2262,
1010,
2417,
6045,
1010,
4297,
1012,
1998,
1013,
2030,
2049,
18460,
1010,
1998,
3265,
16884,
2011,
1996,
1030,
6048,
6415,
1012,
2156,
1996,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# s-vertical-rhythm-class
Return the vertical-rhythm setting scope class
Return **{ [String](http://www.sass-lang.com/documentation/file.SASS_REFERENCE.html#sass-script-strings) }** The vertical-rhythm scope class from settings.vertical-rhythm.scope-class
Author : Olivier Bossel [olivier.bossel@gmail.com](mailto:olivier.bossel@gmail.com) [https://olivierbossel.com](https://olivierbossel.com) | Coffeekraken/sugar | doc/src/sass/core/functions/_s-vertical-rhythm-class.md | Markdown | mit | 397 | [
30522,
1001,
1055,
1011,
7471,
1011,
6348,
1011,
2465,
2709,
1996,
7471,
1011,
6348,
4292,
9531,
2465,
2709,
1008,
1008,
1063,
1031,
5164,
1033,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
21871,
2015,
1011,
11374,
1012,
4012,
1013,
12653,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2010 by Kai Dombrowe <just89@gmx.de> *
* *
* 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., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
// own
#include "videopage.h"
// JoschyCore
#include <joschycore/manager.h>
#include <joschycore/plugininfo.h>
#include <joschycore/abstractprovider.h>
// KDE
#include <kmessagebox.h>
#include <kdebug.h>
// Qt
#include <QtCore/QFile>
VideoPage::VideoPage(QWidget *parent)
: QWizardPage(parent), m_provider(0)
{
setupUi(this);
registerField("Video*", videoRequester, "text", SIGNAL(textChanged(QString)));
registerField("Title*", titleEdit);
registerField("Description*", descriptionEdit, "plainText", SIGNAL(textChanged()));
registerField("Category*", categoryCombo, "currentText", SIGNAL(currentIndexChanged(QString)));
registerField("Tags*", tagBox, "items", SIGNAL(changed()));
connect(descriptionEdit, SIGNAL(textChanged()), this, SLOT(descriptionChanged()));
descriptionEdit->setCheckSpellingEnabled(true);
}
VideoPage::~VideoPage()
{
if (m_provider) {
Joschy::Manager::self()->unloadProvider(m_provider);
}
}
void VideoPage::initializePage()
{
if (m_provider) {
Joschy::Manager::self()->unloadProvider(m_provider);
m_provider = 0;
}
Joschy::AbstractProvider *plugin = Joschy::Manager::self()->createProvider(field("Provider").toString(),
"QNetworkLayer");
if (!plugin) {
KMessageBox::error(this, i18n("Cannot load: %1", field("Provider").toString()));
return;
}
m_provider = plugin;
categorysChanged(plugin->categorys());
connect(m_provider, SIGNAL(categorysChanged(QStringList)), this,
SLOT(categorysChanged(QStringList)));
videoRequester->setText(m_video);
}
void VideoPage::setVideo(const QString &video)
{
m_video = video;
}
void VideoPage::categorysChanged(const QStringList &categorys)
{
categoryCombo->clear();
categoryCombo->addItems(categorys);
}
void VideoPage::descriptionChanged()
{
QString text = descriptionEdit->toPlainText();
if (text.length() > 5000) {
text.resize(5000);
descriptionEdit->setText(text);
}
}
#include "videopage.moc"
| hippich/recorditnow | src/upload/videopage.cpp | C++ | gpl-2.0 | 3,534 | [
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... |
<?php
/**
* The sidebar containing the main widget area.
*
* @package smoothie
*/
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
}
?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #secondary -->
| ashwinmt/wp-ny | wp-content/themes/smoothie/sidebar.php | PHP | gpl-2.0 | 276 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1996,
2217,
8237,
4820,
1996,
2364,
15536,
24291,
2181,
1012,
1008,
1008,
1030,
7427,
5744,
2666,
1008,
1013,
2065,
1006,
999,
2003,
1035,
3161,
1035,
2217,
8237,
1006,
1005,
2217,
8237,
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 lang="en">
<head>
<title>What is the Drop Box tool?</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="sakai.dropbox, main" name="description">
<meta content="student folders" name="search">
<link href="/library/skin/tool_base.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8">
<link href="/library/skin/morpheus-default/tool.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8">
<link href="/sakai-help-tool/css/help.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8">
<link href="/library/js/jquery/featherlight/0.4.0/featherlight.min.css" media="screen" rel="stylesheet" type="text/css" charset="utf-8">
<script src="/library/webjars/jquery/1.11.3/jquery.min.js" type="text/javascript" charset="utf-8"></script><script src="/library/js/jquery/featherlight/0.4.0/featherlight.min.js" type="text/javascript" charset="utf-8"></script><script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='featherlight']").featherlight({
type: { image:true },
closeOnClick: 'anywhere'
});
});
</script>
</head>
<body>
<div id="wrapper">
<div id="article-content">
<div id="article-header">
<h1 class="article-title">What is the Drop Box tool?</h1>
</div>
<div id="article-description">
<p>The Drop Box tool creates a folder for each student in the course. Students are only able to access their own folder. Students and instructors can both place files in the Drop Box folders. </p>
<p>The Drop Box mirrors the file management features and functionality of the Resources tool. See <a href="content.hlp?docId=whatistheResourcestool">What is the Resources tool?</a> for more information on how to add, upload, edit, and delete files and folders within Drop Box. (As with Resources, multiple files can also be uploaded using <a href="content.hlp?docId=howdoIdraganddropfilesfrommycomputertoaResourcesfolder">Drag and Drop</a>.)</p>
</div> <div id="steps-container"> <div id="step-6360" class="step-container"> <h2 class="step-title">To access this tool, select Drop Box from the Tool Menu in your site.</h2> <div class="step-image-container">
<img src="/library/image/help/en/What-is-the-Drop-Box-tool-/To-access-this-tool--select-Drop-Box-from-the-Tool.png" width="146" height="126" class="step-image" alt="To access this tool, select Drop Box from the Tool Menu in your site.">
</div> </div>
<div class="clear"></div> <div id="step-6361" class="step-container"> <h2 class="step-title">Example: Folders for each student</h2> <div class="step-image-container step-image-fullsize">
<img src="/library/image/help/en/What-is-the-Drop-Box-tool-/Example--Folders-for-each-student-sm.png" width="640" height="285" class="step-image" alt="Example: Folders for each student"><div class="step-image-caption">
<a href="/library/image/help/en/What-is-the-Drop-Box-tool-/Example--Folders-for-each-student.png" rel="featherlight" target="_blank">Zoom</a>
</div>
</div>
<div class="step-instructions"><p>Folders with the plus sign contain files.</p></div> </div>
<div class="clear"></div> </div>
</div>
</div>
</body>
</html>
| joserabal/sakai | help/help/src/sakai_screensteps_dropBoxInstructorGuide/What-is-the-Drop-Box-tool-.html | HTML | apache-2.0 | 3,465 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
30524,
18804,
4180,
1027,
1000,
7842,
11151,
1012,
4530,
8758,
1010,
2364,
1000,
2171,
1027,
1000,
6412,
1000,
1028,
1026,
18804,
4180,
1027,
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... |
#ifndef SRC_LIB_NGSI9_UPDATECONTEXTAVAILABILITYSUBSCRIPTIONRESPONSE_H_
#define SRC_LIB_NGSI9_UPDATECONTEXTAVAILABILITYSUBSCRIPTIONRESPONSE_H_
/*
*
* Copyright 2013 Telefonica Investigacion y Desarrollo, S.A.U
*
* This file is part of Orion Context Broker.
*
* Orion Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion Context Broker 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 Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* iot_support at tid dot es
*
* Author: Ken Zangelin
*/
#include <string>
#include <vector>
#include "ngsi/SubscriptionId.h"
#include "ngsi/Duration.h"
#include "ngsi/StatusCode.h"
#include "ngsi/Request.h"
/* ****************************************************************************
*
* UpdateContextAvailabilitySubscriptionResponse -
*/
typedef struct UpdateContextAvailabilitySubscriptionResponse
{
SubscriptionId subscriptionId; // Mandatory
Duration duration; // Optional
StatusCode errorCode; // Optional
UpdateContextAvailabilitySubscriptionResponse();
UpdateContextAvailabilitySubscriptionResponse(StatusCode& _errorCode);
~UpdateContextAvailabilitySubscriptionResponse();
std::string toJsonV1(void);
std::string check(const std::string& predetectedError);
} UpdateContextAvailabilitySubscriptionResponse;
#endif // SRC_LIB_NGSI9_UPDATECONTEXTAVAILABILITYSUBSCRIPTIONRESPONSE_H_
| Fiware/data.Orion | src/lib/ngsi9/UpdateContextAvailabilitySubscriptionResponse.h | C | agpl-3.0 | 1,996 | [
30522,
1001,
2065,
13629,
2546,
5034,
2278,
1035,
5622,
2497,
1035,
12835,
5332,
2683,
1035,
10651,
8663,
18209,
12462,
11733,
8553,
6342,
5910,
23235,
3258,
6072,
26029,
3366,
1035,
1044,
1035,
1001,
9375,
5034,
2278,
1035,
5622,
2497,
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... |
/*
* Copyright 2018, Flávio Keglevich
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.fkeglevich.rawdumper.camera.feature;
import com.fkeglevich.rawdumper.camera.async.direct.AsyncParameterSender;
import com.fkeglevich.rawdumper.camera.data.DataRange;
import com.fkeglevich.rawdumper.camera.parameter.Parameter;
import com.fkeglevich.rawdumper.camera.parameter.ParameterCollection;
import com.fkeglevich.rawdumper.camera.parameter.value.ValueValidator;
/**
* TODO: Add class header
*
* Created by Flávio Keglevich on 09/05/17.
*/
public abstract class RangeFeature<T extends Comparable<T>> extends WritableFeature<T, DataRange<T>>
{
private final AsyncParameterSender asyncParameterSender;
RangeFeature(AsyncParameterSender asyncParameterSender, Parameter<T> featureParameter, ParameterCollection parameterCollection, ValueValidator<T, DataRange<T>> validator)
{
super(featureParameter, parameterCollection, validator);
this.asyncParameterSender = asyncParameterSender;
}
public abstract void setValueAsProportion(double proportion);
void setValueAsync(T value)
{
checkFeatureAvailability(this);
if (!getValidator().isValid(value))
throw new IllegalArgumentException();
asyncParameterSender.sendParameterAsync(parameter, value);
}
}
| fkeglevich/Raw-Dumper | app/src/main/java/com/fkeglevich/rawdumper/camera/feature/RangeFeature.java | Java | apache-2.0 | 1,858 | [
30522,
1013,
1008,
1008,
9385,
2760,
1010,
13109,
28471,
17710,
9354,
12933,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <grp.h>
#include <string.h>
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/*
compile instructions (using c static library, for security, to eliminate
shared library that could be manipulated):
g++ -static untrusted_execute.c -o untrusted_execute
change permissions & set suid: (must be root)
chown root untrusted_execute
chgrp DAEMON_USER untrusted_execute
chmod 4550 untrusted_execute
*/
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
int main(int argc, char* argv[]) {
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Verify that we have at least two arguments, which untrusted user
to run as, and the name of the program to run... */
if (argc < 3) {
fprintf(stderr,"untrusted_execute: ERROR! WRONG NUMBER OF ARGUMENTS\n");
exit(1);
}
int length = strnlen(argv[1], 16);
/* verify the untrusted username which must be of the form "untrustedNN" */
if (length != 11 || strstr(argv[1],"untrusted") != argv[1]) {
fprintf(stderr,"untrusted_execute: ERROR! Invalid untrusted user %s\n", argv[1]);
exit(1);
}
char which_untrusted_string[3];
strncpy(which_untrusted_string,argv[1]+9,2);
which_untrusted_string[2]='\0';
int which_untrusted = atoi(which_untrusted_string);
int res;
uid_t euid;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* THIS PROGRAM ASSUMES THAT A SPECIAL UNTRUSTED USER & GROUP EXISTS IN THE SYSTEM
IF THEIR IDS CHANGE THIS PROGRAM MUST BE EDITED
THE SUID BIT & PERMISSIONS MUST BE SET CORRECTLY ON THE EXECUTABLE
*/
static const uid_t ROOT_UID = 0; /* root's user id & group id */
static const uid_t NUM_UNTRUSTED = __INSTALL__FILLIN__NUM_UNTRUSTED__; /* num untrusted users */
static const uid_t FIRST_UNTRUSTED_UID = __INSTALL__FILLIN__FIRST_UNTRUSTED_UID__; /* untrusted's user id */
static const uid_t FIRST_UNTRUSTED_GID = __INSTALL__FILLIN__FIRST_UNTRUSTED_GID__; /* untrusted's group id */
static const uid_t DAEMON_UID = __INSTALL__FILLIN__DAEMON_UID__; /* submitty_daemon's user id */
static const uid_t DAEMON_GID = __INSTALL__FILLIN__DAEMON_GID__; /* submitty_daemon's group id */
if (which_untrusted < 0 || which_untrusted >= NUM_UNTRUSTED) {
fprintf(stderr,"untrusted_execute: INVALID UNTRUSTED ID %d\n", which_untrusted);
exit(1);
}
uid_t MY_UNTRUSTED_UID = FIRST_UNTRUSTED_UID + which_untrusted;
uid_t MY_UNTRUSTED_GID = FIRST_UNTRUSTED_GID + which_untrusted;
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Sanity check, this program must be run by submitty_daemon, with
effective uid root (suid root bit must be set) */
if (geteuid() != ROOT_UID || getuid() != DAEMON_UID) {
fprintf(stderr,"INTERNAL ERROR: BAD USER\n");
fprintf(stderr,"uid:%d euid:%d",getuid(),geteuid());
exit(1);
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Check the file permissions of this program
owner of this file: root
group of this file: DAEMON_GROUP
suid bit should be set
user(root) rx
group(DAEMON_GROUP) rx
other nothing
*/
/* We assume we're on Linux! */
struct stat stat_data;
res = stat("/proc/self/exe", &stat_data);
if (res != 0) {
fprintf(stderr,"INTERNAL ERROR: FAILED TO STAT SELF\n");
perror("stat error: ");
exit(1);
}
static const int CORRECT_PERMS = S_IFREG|S_ISUID|S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP;
if (stat_data.st_mode != CORRECT_PERMS) {
fprintf(stderr,"INTERNAL ERROR: file permissions 0x%x (vs 0x%x) are invalid!\n", stat_data.st_mode,
CORRECT_PERMS);
exit(1);
}
if (stat_data.st_uid != ROOT_UID ||
stat_data.st_gid != DAEMON_GID) {
fprintf(stderr,"INTERNAL ERROR: file uid %d gid %d are invalid\n", stat_data.st_uid, stat_data.st_gid);
exit(1);
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Drop privileges (groups, gid, uid) */
/* make sure to clear out the secondary groups first */
gid_t my_gid = MY_UNTRUSTED_GID;
res = setgroups (1,&my_gid);
if (res != 0) {
fprintf(stderr,"INTERNAL ERROR: FAILED TO DROP GROUPS (setgroups)\n");
perror("setgroups error: ");
exit(1);
}
/* switch the group id to the untrusted group id */
res = setresgid(MY_UNTRUSTED_GID, MY_UNTRUSTED_GID, MY_UNTRUSTED_GID);
if (res != 0) {
fprintf(stderr,"INTERNAL ERROR: FAILED TO DROP GROUP PRIVS\n");
perror("setresgid error: ");
exit(1);
}
/* switch the user id to the untrusted user id */
res = setresuid(MY_UNTRUSTED_UID, MY_UNTRUSTED_UID, MY_UNTRUSTED_UID);
if (res != 0) {
fprintf(stderr,"INTERNAL ERROR: FAILED TO DROP USER PRIVS\n");
perror("setresuid error: ");
exit(1);
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* chop off this executable, and run the the program specified by the rest of the args */
char *envp[1] = {NULL};
/* clears the environment variables, etc. */
execve(argv[2], argv+2, envp);
perror("exec");
fprintf(stderr,"INTERNAL ERROR: exec failed\n");
fprintf(stderr,"%s\n",argv[1]);
exit (1);
}
| RCOS-Grading-Server/HWserver | .setup/untrusted_execute.c | C | bsd-3-clause | 5,460 | [
30522,
1001,
2421,
1026,
4895,
2923,
2094,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
19422,
12322,
1012,
1044,
1028,
1001,
2421,
1026,
25353,
2015,
1013,
4127,
1012,
1044,
1028,
1001,
2421,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* EmptyTrashSignal class
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version 2014.11.1
*/
namespace eZ\Publish\Core\SignalSlot\Signal\TrashService;
use eZ\Publish\Core\SignalSlot\Signal;
/**
* EmptyTrashSignal class
* @package eZ\Publish\Core\SignalSlot\Signal\TrashService
*/
class EmptyTrashSignal extends Signal
{
}
| ataxel/tp | vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/SignalSlot/Signal/TrashService/EmptyTrashSignal.php | PHP | gpl-2.0 | 472 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4064,
6494,
4095,
5332,
16989,
2140,
2465,
1008,
1008,
1030,
9385,
9385,
1006,
1039,
1007,
1041,
2480,
3001,
2004,
1012,
2035,
2916,
9235,
1012,
1008,
1030,
6105,
2005,
2440,
9385,
1998,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2006 Subclipse project and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Subclipse project committers - initial API and implementation
******************************************************************************/
package org.tigris.subversion.subclipse.ui.authentication;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.tigris.subversion.subclipse.ui.IHelpContextIds;
import org.tigris.subversion.subclipse.ui.Policy;
import org.tigris.subversion.subclipse.ui.dialogs.SubclipseTrayDialog;
public class UserPromptDialog extends SubclipseTrayDialog {
private String realm;
private String username;
private boolean save;
private boolean maySave;
private Text userText;
private Button saveButton;
private Button okButton;
private static int WIDTH = 300;
public UserPromptDialog(Shell parentShell, String realm, String username, boolean maySave) {
super(parentShell);
this.realm = realm;
this.username = username;
this.maySave = maySave;
}
protected Control createDialogArea(Composite parent) {
Composite rtnGroup = (Composite)super.createDialogArea(parent);
getShell().setText(Policy.bind("UserPromptDialog.title")); //$NON-NLS-1$
GridLayout layout = new GridLayout();
layout.numColumns = 2;
rtnGroup.setLayout(layout);
rtnGroup.setLayoutData(
new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Label realmLabel = new Label(rtnGroup, SWT.NONE);
realmLabel.setText(Policy.bind("PasswordPromptDialog.repository")); //$NON-NLS-1$
Text realmText = new Text(rtnGroup, SWT.BORDER);
GridData gd = new GridData();
gd.widthHint = WIDTH;
realmText.setLayoutData(gd);
realmText.setEditable(false);
realmText.setText(realm);
Label userLabel = new Label(rtnGroup, SWT.NONE);
userLabel.setText(Policy.bind("UserPromptDialog.username")); //$NON-NLS-1$
userText = new Text(rtnGroup, SWT.BORDER);
gd = new GridData();
gd.widthHint = WIDTH;
userText.setLayoutData(gd);
userText.setText(username == null? "": username);
userText.selectAll();
if (maySave) {
saveButton = new Button(rtnGroup, SWT.CHECK);
saveButton.setText(Policy.bind("UserPromptDialog.save")); //$NON-NLS-1$
gd = new GridData();
gd.horizontalSpan = 2;
saveButton.setLayoutData(gd);
}
// set F1 help
PlatformUI.getWorkbench().getHelpSystem().setHelp(rtnGroup, IHelpContextIds.USER_PROMPT_DIALOG);
userText.setFocus();
return rtnGroup;
}
public Button createButton(Composite parent, int id, String label, boolean isDefault) {
Button button = super.createButton(parent, id, label, isDefault);
if (id == IDialogConstants.OK_ID) {
okButton = button;
okButton.setEnabled(true);
}
return button;
}
protected void okPressed() {
username = userText.getText().trim();
if (maySave) save = saveButton.getSelection();
super.okPressed();
}
public boolean isSave() {
return save;
}
public String getUsername() {
return username;
}
}
| apicloudcom/APICloud-Studio | org.tigris.subversion.subclipse.ui/src/org/tigris/subversion/subclipse/ui/authentication/UserPromptDialog.java | Java | gpl-3.0 | 3,794 | [
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... |
<html><body>
<h4>Windows 10 x64 (19042.610)</h4><br>
<h2>_OBJECT_REF_INFO</h2>
<font face="arial"> +0x000 ObjectHeader : Ptr64 <a href="./_OBJECT_HEADER.html">_OBJECT_HEADER</a><br>
+0x008 NextRef : Ptr64 Void<br>
+0x010 ImageFileName : [16] UChar<br>
+0x020 NextPos : Uint2B<br>
+0x022 MaxStacks : Uint2B<br>
+0x024 StackInfo : [0] <a href="./_OBJECT_REF_STACK_INFO.html">_OBJECT_REF_STACK_INFO</a><br>
</font></body></html> | epikcraw/ggool | public/Windows 10 x64 (19042.610)/_OBJECT_REF_INFO.html | HTML | mit | 490 | [
30522,
30524,
1006,
5692,
2475,
1012,
19827,
1007,
1026,
1013,
1044,
2549,
1028,
1026,
7987,
1028,
1026,
1044,
2475,
1028,
1035,
4874,
1035,
25416,
1035,
18558,
1026,
1013,
1044,
2475,
1028,
1026,
15489,
2227,
1027,
1000,
9342,
2140,
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... |
using System;
using System.Threading;
using System.Threading.Tasks;
using Moq;
using Moq.Protected;
using Riganti.Utils.Infrastructure.Core;
using Xunit;
#if EFCORE
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Riganti.Utils.Infrastructure.EntityFrameworkCore.Transactions;
#else
using System.Data.Entity;
using Riganti.Utils.Infrastructure.EntityFramework.Transactions;
#endif
#if EFCORE
namespace Riganti.Utils.Infrastructure.EntityFrameworkCore.Tests.UnitOfWork
#else
namespace Riganti.Utils.Infrastructure.EntityFramework.Tests.UnitOfWork
#endif
{
public class EntityFrameworkUnitOfWorkTests
{
[Fact]
public void Commit_CallCommitCoreOnlyIfHasOwnDbContext()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
unitOfWorkRegistryStub.RegisterUnitOfWork(unitOfWorkParent);
var unitOfWorkChildMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkChild = unitOfWorkChildMock.Object)
{
unitOfWorkChild.Commit();
}
unitOfWorkChildMock.Protected().Verify("CommitCore", Times.Never());
unitOfWorkParent.Commit();
}
unitOfWorkParentMock.Protected().Verify("CommitCore", Times.Once());
}
[Fact]
public void Commit_CorrectChildRequestIgnoredBehavior()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
Assert.Throws<ChildCommitPendingException>(() =>
{
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
using (var unitOfWorkChild = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
unitOfWorkChild.Commit();
}
}
});
// test that unit of work provider keeps working after caught exception
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
}
}
}
[Fact]
public void Commit_CorrectMultipleLayeredReuseParentBehavior()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
using (var unitOfWorkParent = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 1st level, context 1
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 2nd level, context 1
using (unitOfWorkProvider.Create(DbContextOptions.AlwaysCreateOwnContext))
{
// 3rd level, context 2
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 4th level, context 2
using (var unitOfWorkParent3 = unitOfWorkProvider.Create(DbContextOptions.AlwaysCreateOwnContext))
{
// 5th level, context 3
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 6th level, context 3
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
}
using (var unitOfWorkChild3 = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 7th level, context 3 commit requested
unitOfWorkChild3.Commit();
}
}
// commit mandatory, context 3 commit pending
unitOfWorkParent3.Commit();
}
}
}
}
// commit optional, no reusing child commit pending
unitOfWorkParent.Commit();
}
}
[Fact]
public void Commit_UOWHasNotParrent_CallCommitCore()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
unitOfWorkParent.Commit();
}
unitOfWorkParentMock.Protected().Verify("CommitCore", Times.Once());
}
[Fact]
public void CommitAsync_UOWHasChild_CallCommitCore()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
unitOfWorkRegistryStub.RegisterUnitOfWork(unitOfWorkParent);
using (var unitOfWorkChild = new EntityFrameworkUnitOfWork(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext))
{
unitOfWorkChild.Commit();
}
unitOfWorkParent.Commit();
}
unitOfWorkParentMock.Protected().Verify("CommitCore", Times.Once());
}
[Fact]
public async Task CommitAsync_CallCommitCoreOnlyIfHasOwnDbContext()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
unitOfWorkRegistryStub.RegisterUnitOfWork(unitOfWorkParent);
var unitOfWorkChildMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkChild = unitOfWorkChildMock.Object)
{
await unitOfWorkChild.CommitAsync();
}
unitOfWorkChildMock.Protected().Verify("CommitAsyncCore", Times.Never(), new CancellationToken());
await unitOfWorkParent.CommitAsync();
}
unitOfWorkParentMock.Protected().Verify("CommitAsyncCore", Times.Once(), new CancellationToken());
}
[Fact]
public async Task CommitAsync_ThrowIfChildCommitRequestedNotFulfilledByRoot()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
await Assert.ThrowsAsync<ChildCommitPendingException>(async () =>
{
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
using (var unitOfWorkChild = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
await unitOfWorkChild.CommitAsync();
}
}
});
// test that unit of work provider keeps working after caught exception
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
}
}
}
[Fact]
public async Task CommitAsync_CorrectMultipleLayeredReuseParentBehavior()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
using (var unitOfWorkParent = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 1st level, context 1
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 2nd level, context 1
using (unitOfWorkProvider.Create(DbContextOptions.AlwaysCreateOwnContext))
{
// 3rd level, context 2
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 4th level, context 2
using (var unitOfWorkParent3 = unitOfWorkProvider.Create(DbContextOptions.AlwaysCreateOwnContext))
{
// 5th level, context 3
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 6th level, context 3
using (unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
}
using (var unitOfWorkChild3 = unitOfWorkProvider.Create(DbContextOptions.ReuseParentContext))
{
// 7th level, context 3 commit requested
await unitOfWorkChild3.CommitAsync();
}
}
// commit mandatory, context 3 commit pending
await unitOfWorkParent3.CommitAsync();
}
}
}
}
// commit optional, no reusing child commit pending
await unitOfWorkParent.CommitAsync();
}
}
[Fact]
public async Task CommitAsync_UOWHasNotParrent_CallCommitCore()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
await unitOfWorkParent.CommitAsync();
}
unitOfWorkParentMock.Protected().Verify("CommitAsyncCore", Times.Once(), new CancellationToken());
}
[Fact]
public async Task Commit_UOWHasChild_CallCommitCore()
{
Func<DbContext> dbContextFactory = () => new Mock<DbContext>().Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWorkParentMock = new Mock<EntityFrameworkUnitOfWork>(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext) { CallBase = true };
using (var unitOfWorkParent = unitOfWorkParentMock.Object)
{
unitOfWorkRegistryStub.RegisterUnitOfWork(unitOfWorkParent);
using (var unitOfWorkChild = new EntityFrameworkUnitOfWork(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext))
{
await unitOfWorkChild.CommitAsync();
}
await unitOfWorkParent.CommitAsync();
}
unitOfWorkParentMock.Protected().Verify("CommitAsyncCore", Times.Once(), new CancellationToken());
}
[Fact]
public async Task Commit_Transaction_CallRollback()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scopeMock = new Mock<UnitOfWorkTransactionScope<InMemoryDbContext>>(unitOfWorkProvider);
var scope = scopeMock.Object;
await scope.ExecuteAsync(async uowParent =>
{
Assert.True(uowParent.IsInTransaction);
await uowParent.CommitAsync();
Assert.Equal(1, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
using (var uowChild = (EntityFrameworkUnitOfWork<InMemoryDbContext>)unitOfWorkProvider.Create())
{
await uowChild.CommitAsync();
Assert.Equal(1, uowChild.CommitsCount);
Assert.False(uowChild.CommitPending);
Assert.Equal(2, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
}
throw Assert.Throws<RollbackRequestedException>(() => { uowParent.RollbackTransaction(); });
});
scopeMock.Protected().Verify("AfterRollback", Times.Once());
}
[Fact]
public async Task Commit_Transaction_CallRollback_UserCatch()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scopeMock = new Mock<UnitOfWorkTransactionScope<InMemoryDbContext>>(unitOfWorkProvider);
var scope = scopeMock.Object;
await scope.ExecuteAsync(async uowParent =>
{
Assert.True(uowParent.IsInTransaction);
await uowParent.CommitAsync();
using (var uowChild = (EntityFrameworkUnitOfWork<InMemoryDbContext>)unitOfWorkProvider.Create())
{
await uowChild.CommitAsync();
try
{
uowParent.RollbackTransaction();
}
catch (Exception)
{
// user catches any exceptions
}
}
});
scopeMock.Protected().Verify("AfterRollback", Times.Once());
}
[Fact]
public async Task Commit_Transaction_CallRollback_OnException()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scope = unitOfWorkProvider.CreateTransactionScope();
var exceptionKey = Guid.NewGuid().ToString();
try
{
await scope.ExecuteAsync(async uowParent =>
{
Assert.True(uowParent.IsInTransaction);
await uowParent.CommitAsync();
throw new Exception(exceptionKey);
});
}
catch (Exception e) when (e.Message == exceptionKey)
{
// test exception caught, passed
}
}
[Fact]
public async Task Commit_Transaction_CallCommit()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scopeMock = new Mock<UnitOfWorkTransactionScope<InMemoryDbContext>>(unitOfWorkProvider);
var scope = scopeMock.Object;
await scope.ExecuteAsync(async uowParent =>
{
Assert.True(uowParent.IsInTransaction);
await uowParent.CommitAsync();
Assert.Equal(1, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
});
scopeMock.Protected().Verify("AfterCommit", Times.Once());
}
[Fact]
public async Task Commit_Transaction_CallCommit_Nesting()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scopeMock = new Mock<UnitOfWorkTransactionScope<InMemoryDbContext>>(unitOfWorkProvider);
var scope = scopeMock.Object;
await scope.ExecuteAsync(async uowParent =>
{
Assert.True(uowParent.IsInTransaction);
await uowParent.CommitAsync();
Assert.Equal(1, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
using (var uowChild = (EntityFrameworkUnitOfWork<InMemoryDbContext>)unitOfWorkProvider.Create())
{
await uowChild.CommitAsync();
Assert.Equal(1, uowChild.CommitsCount);
Assert.False(uowChild.CommitPending);
Assert.Equal(2, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
using (var uowChildChild = (EntityFrameworkUnitOfWork<InMemoryDbContext>)unitOfWorkProvider.Create())
{
await uowChildChild.CommitAsync();
}
Assert.Equal(2, uowChild.CommitsCount);
Assert.False(uowChild.CommitPending);
Assert.Equal(3, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
}
});
scopeMock.Protected().Verify("AfterCommit", Times.Once());
}
[Fact]
public void Commit_Transaction_CallCommit_Sync()
{
var dbContextFactory = GetContextFactory();
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider<InMemoryDbContext>(unitOfWorkRegistryStub, dbContextFactory);
var scopeMock = new Mock<UnitOfWorkTransactionScope<InMemoryDbContext>>(unitOfWorkProvider);
var scope = scopeMock.Object;
scope.Execute(uowParent =>
{
Assert.True(uowParent.IsInTransaction);
uowParent.Commit();
Assert.Equal(1, uowParent.CommitsCount);
Assert.False(uowParent.CommitPending);
});
scopeMock.Protected().Verify("AfterCommit", Times.Once());
}
[Fact]
public void TryGetDbContext_UnitOfWorkRegistryHasUnitOfWork_ReturnCorrectDbContext()
{
var dbContext = new Mock<DbContext>().Object;
Func<DbContext> dbContextFactory = () => dbContext;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var unitOfWork = new EntityFrameworkUnitOfWork(unitOfWorkProvider, dbContextFactory, DbContextOptions.ReuseParentContext);
unitOfWorkRegistryStub.RegisterUnitOfWork(unitOfWork);
var uowDbContext = EntityFrameworkUnitOfWork.TryGetDbContext(unitOfWorkProvider);
Assert.NotNull(uowDbContext);
Assert.Same(dbContext, uowDbContext);
}
[Fact]
public void TryGetDbContext_UnitOfWorkRegistryHasNotUnitOfWork_ReturnsNull()
{
var dbContext = new Mock<DbContext>().Object;
Func<DbContext> dbContextFactory = () => dbContext;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
var value = EntityFrameworkUnitOfWork.TryGetDbContext(unitOfWorkProvider);
Assert.Null(value);
}
[Fact]
public async Task CommitAsync_WithCancellationTokenInNestedUow_SavedChangesInParentUow()
{
var dbContext = new Mock<DbContext>();
Func<DbContext> dbContextFactory = () => dbContext.Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
using (var uow = unitOfWorkProvider.Create())
{
using (var nested = unitOfWorkProvider.Create())
{
await nested.CommitAsync(new CancellationToken());
// verify, that method has NEVER been called
dbContext.Verify(x => x.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Never);
}
await uow.CommitAsync(new CancellationToken());
// verify, that method has been called ONCE
dbContext.Verify(x => x.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Once);
}
}
[Fact]
public async Task CommitAsync_WithoutCancellationTokenInNestedUow_SavedChangesInParentUow()
{
var dbContext = new Mock<DbContext>();
Func<DbContext> dbContextFactory = () => dbContext.Object;
var unitOfWorkRegistryStub = new ThreadLocalUnitOfWorkRegistry();
var unitOfWorkProvider = new EntityFrameworkUnitOfWorkProvider(unitOfWorkRegistryStub, dbContextFactory);
using (var uow = unitOfWorkProvider.Create())
{
using (var nested = unitOfWorkProvider.Create())
{
await nested.CommitAsync();
// verify, that method has NEVER been called
dbContext.Verify(x => x.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Never);
}
await uow.CommitAsync();
// verify, that method has been called ONCE
dbContext.Verify(x => x.SaveChangesAsync(It.IsAny<CancellationToken>()), Times.Once);
}
}
public class InMemoryDbContext : DbContext
{
#if EFCORE
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning));
}
}
#endif
}
private static Func<InMemoryDbContext> GetContextFactory()
{
return () =>
#if EFCORE
new InMemoryDbContext();
#else
new Mock<InMemoryDbContext>().Object;
#endif
}
}
} | riganti/infrastructure | src/Infrastructure/Tests/Riganti.Utils.Infrastructure.EntityFramework.Tests/UnitOfWork/EntityFrameworkUnitOfWorkTests.cs | C# | apache-2.0 | 25,742 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
11689,
2075,
1025,
2478,
2291,
1012,
30524,
4563,
1025,
2478,
15990,
3490,
2102,
1025,
1001,
2065,
1041,
11329,
5686,
2478,
7513,
1012,
9178,
15643,
6198,
17345,
1025,
2478,
7513,
1012,
9178,
15643... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 xml:lang="en-GB" lang="en-GB" xmlns="http://www.w3.org/1999/xhtml">
<head lang="en-GB">
<title>Ross Gammon’s Family Tree - CUTCLIFFE, Elsie Bluett</title>
<meta charset="UTF-8" />
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
<meta name ="apple-mobile-web-app-capable" content="yes" />
<meta name="generator" content="Gramps 4.2.8 http://gramps-project.org/" />
<meta name="author" content="" />
<link href="../../../images/favicon2.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../../css/narrative-screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../../../css/narrative-print.css" media="print" rel="stylesheet" type="text/css" />
<link href="../../../css/ancestortree.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1 id="SiteTitle">Ross Gammon’s Family Tree</h1>
</div>
<div class="wrapper" id="nav" role="navigation">
<div class="container">
<ul class="menu" id="dropmenu">
<li class = "CurrentSection"><a href="../../../individuals.html" title="Individuals">Individuals</a></li>
<li><a href="../../../index.html" title="Surnames">Surnames</a></li>
<li><a href="../../../families.html" title="Families">Families</a></li>
<li><a href="../../../events.html" title="Events">Events</a></li>
<li><a href="../../../places.html" title="Places">Places</a></li>
<li><a href="../../../sources.html" title="Sources">Sources</a></li>
<li><a href="../../../repositories.html" title="Repositories">Repositories</a></li>
<li><a href="../../../media.html" title="Media">Media</a></li>
<li><a href="../../../thumbnails.html" title="Thumbnails">Thumbnails</a></li>
</ul>
</div>
</div>
<div class="content" id="IndividualDetail">
<h3>CUTCLIFFE, Elsie Bluett<sup><small></small></sup></h3>
<div id="summaryarea">
<table class="infolist">
<tr>
<td class="ColumnAttribute">Birth Name</td>
<td class="ColumnValue">
CUTCLIFFE, Elsie Bluett <a href="#sref1a">1a</a>
</td>
</tr>
<tr>
<td class="ColumnAttribute">Gramps ID</td>
<td class="ColumnValue">I1366</td>
</tr>
<tr>
<td class="ColumnAttribute">Gender</td>
<td class="ColumnValue">female</td>
</tr>
</table>
</div>
<div class="subsection" id="events">
<h4>Events</h4>
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
<a href="../../../evt/e/b/d15f5fcb02f296c186f8e0533be.html" title="Birth">
Birth
<span class="grampsid"> [E1780]</span>
</a>
</td>
<td class="ColumnDate">1871-08-24</td>
<td class="ColumnPlace"> </td>
<td class="ColumnDescription"> </td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</div>
<div class="subsection" id="parents">
<h4>Parents</h4>
<table class="infolist">
<thead>
<tr>
<th class="ColumnAttribute">Relation to main person</th>
<th class="ColumnValue">Name</th>
<th class="ColumnValue">Relation within this family (if not by birth)</th>
</tr>
</thead>
<tbody>
</tbody>
<tr>
<td class="ColumnAttribute">Father</td>
<td class="ColumnValue">
<a href="../../../ppl/c/b/d15f5fcacf7664da4466332c1bc.html">CUTCLIFFE, John Charles<span class="grampsid"> [I1347]</span></a>
</td>
</tr>
<tr>
<td class="ColumnAttribute">Mother</td>
<td class="ColumnValue">
<a href="../../../ppl/d/4/d15f5fcad2e28636f62996ca74d.html">BLUETT, Susan Maria<span class="grampsid"> [I1348]</span></a>
</td>
</tr>
<tr>
<td class="ColumnAttribute"> Brother</td>
<td class="ColumnValue"> <a href="../../../ppl/8/f/d15f5fcae085343d5dd9e4133f8.html">CUTCLIFFE, Ashton Bluett<span class="grampsid"> [I1354]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Brother</td>
<td class="ColumnValue"> <a href="../../../ppl/2/5/d15f5fcaf06612b1f6389f8752.html">CUTCLIFFE, Arthur L. Bluett<span class="grampsid"> [I1360]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue"> <a href="../../../ppl/8/e/d15f5fcb01f5c01703d45e4c6e8.html">CUTCLIFFE, Elsie Bluett<span class="grampsid"> [I1366]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Brother</td>
<td class="ColumnValue"> <a href="../../../ppl/c/b/d15f5fc67d387cec9198de7cbc.html">CUTCLIFFE, Mostyn Elton Bluett<span class="grampsid"> [I0995]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Brother</td>
<td class="ColumnValue"> <a href="../../../ppl/9/d/d15f5fcaf6170d4eaf132ce34d9.html">CUTCLIFFE, Neville Bluett<span class="grampsid"> [I1362]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Sister</td>
<td class="ColumnValue"> <a href="../../../ppl/f/0/d15f5fcb0be2210b8c9caac940f.html">CUTCLIFFE, Muriel Bluett<span class="grampsid"> [I1369]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Brother</td>
<td class="ColumnValue"> <a href="../../../ppl/4/6/d15f5fcafc771ef90b20671eb64.html">CUTCLIFFE, DeCourcy Bluett<span class="grampsid"> [I1364]</span></a></td>
<td class="ColumnValue"></td>
</tr>
<tr>
<td class="ColumnAttribute"> Sister</td>
<td class="ColumnValue"> <a href="../../../ppl/d/d/d15f5fcb04bc3554ac77fee8dd.html">CUTCLIFFE, Evelyn Mabel Bluett<span class="grampsid"> [I1367]</span></a></td>
<td class="ColumnValue"></td>
</tr>
</table>
</div>
<div class="subsection narrative">
<h4>Narrative</h4>
<div class="grampsstylednote">
<p>
Died an infant.
</p>
</div>
</div>
<div class="subsection" id="attributes">
<h4>Attributes</h4>
<table class="infolist attrlist">
<thead>
<tr>
<th class="ColumnType">Type</th>
<th class="ColumnValue">Value</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnType">_UID</td>
<td class="ColumnValue">0C2DD58DB619514ABAD126079B1CF6AA1475</td>
<td class="ColumnNotes"><div></div></td>
<td class="ColumnSources"> </td>
</tr>
</tbody>
</table>
</div>
<div class="subsection" id="pedigree">
<h4>Pedigree</h4>
<ol class="pedigreegen">
<li>
<a href="../../../ppl/c/b/d15f5fcacf7664da4466332c1bc.html">CUTCLIFFE, John Charles<span class="grampsid"> [I1347]</span></a>
<ol>
<li class="spouse">
<a href="../../../ppl/d/4/d15f5fcad2e28636f62996ca74d.html">BLUETT, Susan Maria<span class="grampsid"> [I1348]</span></a>
<ol>
<li>
<a href="../../../ppl/8/f/d15f5fcae085343d5dd9e4133f8.html">CUTCLIFFE, Ashton Bluett<span class="grampsid"> [I1354]</span></a>
</li>
<li class="thisperson">
CUTCLIFFE, Elsie Bluett
</li>
<li>
<a href="../../../ppl/2/5/d15f5fcaf06612b1f6389f8752.html">CUTCLIFFE, Arthur L. Bluett<span class="grampsid"> [I1360]</span></a>
</li>
<li>
<a href="../../../ppl/c/b/d15f5fc67d387cec9198de7cbc.html">CUTCLIFFE, Mostyn Elton Bluett<span class="grampsid"> [I0995]</span></a>
</li>
<li>
<a href="../../../ppl/9/d/d15f5fcaf6170d4eaf132ce34d9.html">CUTCLIFFE, Neville Bluett<span class="grampsid"> [I1362]</span></a>
</li>
<li>
<a href="../../../ppl/f/0/d15f5fcb0be2210b8c9caac940f.html">CUTCLIFFE, Muriel Bluett<span class="grampsid"> [I1369]</span></a>
</li>
<li>
<a href="../../../ppl/4/6/d15f5fcafc771ef90b20671eb64.html">CUTCLIFFE, DeCourcy Bluett<span class="grampsid"> [I1364]</span></a>
</li>
<li>
<a href="../../../ppl/d/d/d15f5fcb04bc3554ac77fee8dd.html">CUTCLIFFE, Evelyn Mabel Bluett<span class="grampsid"> [I1367]</span></a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</div>
<div class="subsection" id="tree">
<h4>Ancestors</h4>
<div id="treeContainer" style="width:735px; height:602px;">
<div class="boxbg female AncCol0" style="top: 269px; left: 6px;">
<a class="noThumb" href="../../../ppl/8/e/d15f5fcb01f5c01703d45e4c6e8.html">
CUTCLIFFE, Elsie Bluett
</a>
</div>
<div class="shadow" style="top: 274px; left: 10px;"></div>
<div class="bvline" style="top: 301px; left: 165px; width: 15px"></div>
<div class="gvline" style="top: 306px; left: 165px; width: 20px"></div>
<div class="boxbg male AncCol1" style="top: 119px; left: 196px;">
<a class="noThumb" href="../../../ppl/c/b/d15f5fcacf7664da4466332c1bc.html">
CUTCLIFFE, John Charles
</a>
</div>
<div class="shadow" style="top: 124px; left: 200px;"></div>
<div class="bvline" style="top: 151px; left: 180px; width: 15px;"></div>
<div class="gvline" style="top: 156px; left: 185px; width: 20px;"></div>
<div class="bhline" style="top: 151px; left: 180px; height: 150px;"></div>
<div class="gvline" style="top: 156px; left: 185px; height: 150px;"></div>
<div class="bvline" style="top: 151px; left: 355px; width: 15px"></div>
<div class="gvline" style="top: 156px; left: 355px; width: 20px"></div>
<div class="boxbg male AncCol2" style="top: 44px; left: 386px;">
<a class="noThumb" href="../../../ppl/a/4/d15f5fdc3b569c0841879e90b4a.html">
CUTCLIFFE, Charles Newell
</a>
</div>
<div class="shadow" style="top: 49px; left: 390px;"></div>
<div class="bvline" style="top: 76px; left: 370px; width: 15px;"></div>
<div class="gvline" style="top: 81px; left: 375px; width: 20px;"></div>
<div class="bhline" style="top: 76px; left: 370px; height: 75px;"></div>
<div class="gvline" style="top: 81px; left: 375px; height: 75px;"></div>
<div class="bvline" style="top: 76px; left: 545px; width: 15px"></div>
<div class="gvline" style="top: 81px; left: 545px; width: 20px"></div>
<div class="boxbg male AncCol3" style="top: 7px; left: 576px;">
<a class="noThumb" href="../../../ppl/5/4/d15f5fbdb3847b2b1db2093db45.html">
CUTCLIFFE, Charles of Barnstaple of Barnstaple
</a>
</div>
<div class="shadow" style="top: 12px; left: 580px;"></div>
<div class="bvline" style="top: 39px; left: 560px; width: 15px;"></div>
<div class="gvline" style="top: 44px; left: 565px; width: 20px;"></div>
<div class="bhline" style="top: 39px; left: 560px; height: 37px;"></div>
<div class="gvline" style="top: 44px; left: 565px; height: 37px;"></div>
<div class="boxbg female AncCol3" style="top: 81px; left: 576px;">
<a class="noThumb" href="../../../ppl/b/f/d15f5fc68be3adb7f1d3dd3d5fb.html">
PEARCE, Bridget or Brigette of South Molton of South Molton
</a>
</div>
<div class="shadow" style="top: 86px; left: 580px;"></div>
<div class="bvline" style="top: 113px; left: 560px; width: 15px;"></div>
<div class="gvline" style="top: 118px; left: 565px; width: 20px;"></div>
<div class="bhline" style="top: 76px; left: 560px; height: 37px;"></div>
<div class="gvline" style="top: 81px; left: 565px; height: 37px;"></div>
<div class="boxbg female AncCol2" style="top: 194px; left: 386px;">
<a class="noThumb" href="../../../ppl/6/e/d15f5fcac77eded320819f42e6.html">
WALTON, Emma (or Watton)
</a>
</div>
<div class="shadow" style="top: 199px; left: 390px;"></div>
<div class="bvline" style="top: 226px; left: 370px; width: 15px;"></div>
<div class="gvline" style="top: 231px; left: 375px; width: 20px;"></div>
<div class="bhline" style="top: 151px; left: 370px; height: 75px;"></div>
<div class="gvline" style="top: 156px; left: 375px; height: 75px;"></div>
<div class="boxbg female AncCol1" style="top: 419px; left: 196px;">
<a class="noThumb" href="../../../ppl/d/4/d15f5fcad2e28636f62996ca74d.html">
BLUETT, Susan Maria
</a>
</div>
<div class="shadow" style="top: 424px; left: 200px;"></div>
<div class="bvline" style="top: 451px; left: 180px; width: 15px;"></div>
<div class="gvline" style="top: 456px; left: 185px; width: 20px;"></div>
<div class="bhline" style="top: 301px; left: 180px; height: 150px;"></div>
<div class="gvline" style="top: 306px; left: 185px; height: 150px;"></div>
</div>
</div>
<div class="subsection" id="sourcerefs">
<h4>Source References</h4>
<ol>
<li>
<a href="../../../src/5/0/d15f5fb6d26ad69bdfd4fe2605.html" title="Cutcliffe-Willis marriage, 4 Nov 1811, Combe Martin, Devon , England" name ="sref1">
Cutcliffe-Willis marriage, 4 Nov 1811, Combe Martin, Devon , England
<span class="grampsid"> [S0202]</span>
</a>
<ol>
<li id="sref1a">
<ul>
<li>
Page: No. 284
</li>
<li>
Confidence: Very High
</li>
<li>
Source text: <div class="grampsstylednote"><p> </p><p>[Entry Recording Date : 4 NOV 1811]</p></div>
</li>
<li>
General: <p></p>
</li>
</ul>
</li>
</ol>
</li>
</ol>
</div>
</div>
<div class="fullclear"></div>
<div id="footer">
<p id="createdate">
Generated by <a href="http://gramps-project.org/">Gramps</a> 4.2.8<br />Last change was the 2015-08-05 19:54:05<br />Created for <a href="../../../ppl/9/e/d15f5fb48902c4fc1b421d249e9.html">GAMMON, Francis</a>
</p>
<p id="copyright">
</p>
</div>
</body>
</html>
| RossGammon/the-gammons.net | RossFamilyTree/ppl/8/e/d15f5fcb01f5c01703d45e4c6e8.html | HTML | gpl-3.0 | 14,548 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
20950,
1024,
11374,
1027,
1000,
4372,
1011,
16351,
1000,
11374,
1027,
1000,
4372,
1011,
16351,
1000,
20950,
3619,
1027,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
891... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/* tslint:disable:max-classes-per-file */
import { forEach } from 'ramda';
import Interactor from '../CourseInteractor';
import InteractorLoader from '../CourseInteractorLoader';
import { ICourseStorage } from '../ICourseStorage';
import { IProgressStorage } from '../IProgressStorage';
import { ISerializedCourse } from '../ISerializedCourse';
import { ISerializedProgress, Progress } from '../ISerializedProgress';
const courses: { [propName: string]: ISerializedCourse } = {
'09438926-b170-4005-a6e8-5dd8fba83cde': {
id: '09438926-b170-4005-a6e8-5dd8fba83cde',
title: 'Foo bar',
children: [
{
id: '01f23c2a-b681-43db-9d27-5d8d59f62aed',
children: [
{
id: '23e20d5b-ad8e-41be-9891-5ca7b12675c4',
type: 'foo'
}
]
},
{
id: 'e194f80b-7312-43a2-995e-060f64631782',
children: [
{
id: '84fdc1a1-e3bf-4a87-8360-0c3b7beec179',
foo: 'bar',
type: 'foo'
}
]
}
]
}
};
const progresses: ISerializedProgress = {};
class MockCourseStorage implements ICourseStorage {
public getCourse(id: string) {
return new Promise<ISerializedCourse>((resolve, reject) => {
if (courses[id]) {
resolve(courses[id]);
}
reject(new Error(`There exists no course with id ${id}`));
});
}
}
class MockProgressStorage implements IProgressStorage {
public getProgress(id: string) {
return Promise.resolve(progresses);
}
public setProgress(id: string, progress: ISerializedProgress): Promise<void> {
return Promise.resolve();
}
public resetProgress() {
return Promise.resolve();
}
}
let interactorLoader: InteractorLoader;
let interactor: Interactor;
beforeEach(() => {
const storage = new MockCourseStorage();
const progress = new MockProgressStorage();
interactorLoader = new InteractorLoader(storage, progress);
});
it('loadCourse loads the course from storage if it exists', () =>
interactorLoader.loadCourse('09438926-b170-4005-a6e8-5dd8fba83cde'));
it('loadCourse fails if the course does not exist', () => {
return interactorLoader
.loadCourse('c990eacb-12af-4085-8b50-25d95d114984')
.catch(err => {
expect(err).toBeInstanceOf(Error);
});
});
describe('getStructure', () => {
beforeEach(() =>
interactorLoader
.loadCourse('09438926-b170-4005-a6e8-5dd8fba83cde')
.then(i => {
interactor = i;
})
);
it('returns the whole tree by default', () => {
expect(interactor.getStructure()).toMatchSnapshot();
});
it('returns only the first levels if a level is passed', () => {
expect(interactor.getStructure(1)).toMatchSnapshot();
});
});
describe('reset children progress', () => {
beforeEach(() =>
interactorLoader
.loadCourse('09438926-b170-4005-a6e8-5dd8fba83cde')
.then(i => {
interactor = i;
})
);
it('resets progress correctly', () => {
const root = '09438926-b170-4005-a6e8-5dd8fba83cde';
const children = [
'01f23c2a-b681-43db-9d27-5d8d59f62aed',
'23e20d5b-ad8e-41be-9891-5ca7b12675c4',
'e194f80b-7312-43a2-995e-060f64631782',
'84fdc1a1-e3bf-4a87-8360-0c3b7beec179'
];
forEach(
id => {
interactor.markAsCorrect(id);
},
[root, ...children]
);
interactor.resetChildrenProgress(root);
expect(interactor.getProgress(root).progress).toBe(Progress.Correct);
forEach(id => {
expect(interactor.getProgress(id).progress).toBe(Progress.Unseen);
}, children);
});
});
| serlo-org/serlo-abc | packages/entities-interactor/__tests__/CourseInteractor.ts | TypeScript | apache-2.0 | 3,604 | [
30522,
1013,
1008,
24529,
4115,
2102,
1024,
4487,
19150,
1024,
4098,
1011,
4280,
1011,
2566,
1011,
5371,
1008,
1013,
12324,
1063,
18921,
6776,
1065,
2013,
1005,
8223,
2850,
1005,
1025,
12324,
11835,
2953,
2013,
1005,
1012,
1012,
1013,
2607,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/**
* @(#)MediaExportParameters.java
*
* This file is part of the Non-Linear Book project.
* Copyright (c) 2012-2016 Anton P. Kolosov
* Authors: Anton P. Kolosov, et al.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3
* as published by the Free Software Foundation with the addition of the
* following permission added to Section 15 as permitted in Section 7(a):
* FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
* ANTON P. KOLOSOV. ANTON P. KOLOSOV DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
* OF THIRD PARTY RIGHTS
*
* 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 Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, see http://www.gnu.org/licenses or write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA, 02110-1301 USA.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License.
*
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the Non-Linear Book software without
* disclosing the source code of your own applications.
*
* For more information, please contact Anton P. Kolosov at this
* address: antokolos@gmail.com
*
* Copyright (c) 2012 Anton P. Kolosov All rights reserved.
*/
package com.nlbhub.nlb.domain;
import com.nlbhub.nlb.api.PropertyManager;
/**
* The MediaExportParameters class represents parameters used when saving media files during export of the scheme
* to some end format (such as INSTEAD game).
*
* @author Anton P. Kolosov
* @version 1.0 8/9/12
*/
public class MediaExportParameters {
public enum Preset {CUSTOM, DEFAULT, NOCHANGE, COMPRESSED};
private static final MediaExportParameters NOCHANGE = new MediaExportParameters(Preset.NOCHANGE, false, 0);
private static final MediaExportParameters COMPRESSED = new MediaExportParameters(Preset.COMPRESSED, true, 80);
private static final MediaExportParameters DEFAULT = (
new MediaExportParameters(
Preset.DEFAULT,
PropertyManager.getSettings().getDefaultConfig().getExport().isConvertpng2jpg(),
PropertyManager.getSettings().getDefaultConfig().getExport().getQuality()
)
);
private Preset m_preset = Preset.CUSTOM;
private boolean m_convertPNG2JPG;
private int m_quality;
public static MediaExportParameters fromPreset(Preset preset) {
switch (preset) {
case NOCHANGE:
return MediaExportParameters.NOCHANGE;
case COMPRESSED:
return MediaExportParameters.COMPRESSED;
default:
return MediaExportParameters.DEFAULT;
}
}
public static MediaExportParameters getDefault() {
return DEFAULT;
}
/*
public MediaExportParameters(boolean convertPNG2JPG, int quality) {
m_preset = Preset.CUSTOM;
m_convertPNG2JPG = convertPNG2JPG;
m_quality = quality;
}
*/
private MediaExportParameters(Preset preset, boolean convertPNG2JPG, int quality) {
m_preset = preset;
m_convertPNG2JPG = convertPNG2JPG;
m_quality = quality;
}
public Preset getPreset() {
return m_preset;
}
public boolean isConvertPNG2JPG() {
return m_convertPNG2JPG;
}
public int getQuality() {
return m_quality;
}
}
| Antokolos/NLB | NLBL/src/main/java/com/nlbhub/nlb/domain/MediaExportParameters.java | Java | agpl-3.0 | 3,959 | [
30522,
1013,
1008,
1008,
1008,
1030,
1006,
1001,
1007,
2865,
10288,
6442,
28689,
22828,
2015,
1012,
9262,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
2512,
1011,
7399,
2338,
2622,
1012,
1008,
9385,
1006,
1039,
1007,
2262,
1011,
2355,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 org.eclipse.imp.pdb.facts.exceptions;
import org.eclipse.imp.pdb.facts.type.Type;
public class UnexpectedResultTypeException extends FactTypeUseException {
private static final long serialVersionUID = 1551922923060851569L;
private Type result;
public UnexpectedResultTypeException(Type result, Throwable cause) {
super("Unexpected result " + result, cause);
this.result = result;
}
public Type getResult() {
return result;
}
}
| cwi-swat/pdb.values | src/org/eclipse/imp/pdb/facts/exceptions/UnexpectedResultTypeException.java | Java | epl-1.0 | 452 | [
30522,
7427,
8917,
1012,
13232,
1012,
17727,
1012,
22851,
2497,
1012,
8866,
1012,
11790,
1025,
12324,
8917,
1012,
13232,
1012,
17727,
1012,
22851,
2497,
1012,
8866,
1012,
2828,
1012,
2828,
1025,
2270,
2465,
9223,
6072,
11314,
13874,
10288,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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_self
//= require spree/backend/handlebars_extensions
//= require spree/backend/variant_autocomplete
//= require spree/backend/taxon_autocomplete
//= require spree/backend/option_type_autocomplete
//= require spree/backend/user_picker
//= require spree/backend/product_picker
//= require spree/backend/option_value_picker
//= require spree/backend/taxons
//= require spree/backend/highlight_negative_numbers
/**
This is a collection of javascript functions and whatnot
under the spree namespace that do stuff we find helpful.
Hopefully, this will evolve into a propper class.
**/
Spree.ready(function() {
// Highlight hovered table column
$('table').on("mouseenter", 'td.actions a, td.actions button', function(){
var tr = $(this).closest('tr');
var klass = 'highlight action-' + $(this).data('action')
tr.addClass(klass)
var observer = new MutationObserver(function(mutations) {
tr.removeClass(klass);
this.disconnect();
});
observer.observe(tr.get(0), { childList: true });
// Using .one() instead of .on() prevents multiple callbacks to be attached
// to this event if mouseentered multiple times.
$(this).one("mouseleave", function() {
tr.removeClass(klass);
observer.disconnect();
});
});
});
$.fn.visible = function(cond) { this[cond ? 'show' : 'hide' ]() };
// Apply to individual radio button that makes another element visible when checked
$.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){
if(!this.get(0)){ return }
var showValue = this.get(0).value;
var radioGroup = $("input[name='" + this.get(0).name + "']");
radioGroup.each(function(){
$(this).click(function(){
$(dependentElementSelector).visible(this.checked && this.value == showValue)
});
if(this.checked){ this.click() }
});
}
Spree.ready(function(){
var uniqueId = 1;
$('.spree_add_fields').click(function() {
var target = $(this).data("target");
var new_table_row = $(target + ' tr:visible:last').clone();
var new_id = new Date().getTime() + (uniqueId++);
new_table_row.find("input, select").each(function () {
var el = $(this);
el.val("");
// Replace last occurrence of a number
el.prop("id", el.prop("id").replace(/\d+(?=[^\d]*$)/, new_id))
el.prop("name", el.prop("name").replace(/\d+(?=[^\d]*$)/, new_id))
})
// When cloning a new row, set the href of all icons to be an empty "#"
// This is so that clicking on them does not perform the actions for the
// duplicated row
new_table_row.find("a").each(function () {
var el = $(this);
el.prop('href', '#');
})
$(target).prepend(new_table_row);
})
$('body').on('click', '.delete-resource', function() {
var el = $(this);
if (confirm(el.data("confirm"))) {
Spree.ajax({
type: 'POST',
url: $(this).prop("href"),
data: {
_method: 'delete',
},
dataType: 'script',
success: function(response) {
el.parents("tr").fadeOut('hide', function() {
$(this).remove();
});
},
error: function(response, textStatus, errorThrown) {
show_flash('error', response.responseText);
}
});
}
return false;
});
$('body').on('click', 'a.spree_remove_fields', function() {
var el = $(this);
el.prev("input[type=hidden]").val("1");
el.closest(".fields").hide();
if (el.prop("href").substr(-1) == '#') {
el.parents("tr").fadeOut('hide');
}else if (el.prop("href")) {
Spree.ajax({
type: 'POST',
url: el.prop("href"),
data: {
_method: 'delete',
},
success: function(response) {
el.parents("tr").fadeOut('hide');
},
error: function(response, textStatus, errorThrown) {
show_flash('error', response.responseText);
}
})
}
return false;
});
window.Spree.advanceOrder = function() {
Spree.ajax({
type: "PUT",
async: false,
data: {
token: Spree.api_key
},
url: Spree.routes.checkouts_api + "/" + window.order_number + "/advance"
}).done(function() {
window.location.reload();
});
}
});
| pervino/solidus | backend/app/assets/javascripts/spree/backend/admin.js | JavaScript | bsd-3-clause | 4,270 | [
30522,
1013,
1013,
1027,
5478,
1035,
2969,
1013,
1013,
1027,
5478,
11867,
9910,
1013,
2067,
10497,
1013,
5047,
8237,
2015,
1035,
14305,
1013,
1013,
1027,
5478,
11867,
9910,
1013,
2067,
10497,
1013,
8349,
1035,
8285,
9006,
10814,
2618,
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... |
package atomicstryker.dynamiclights.client;
import net.minecraft.entity.Entity;
/**
*
* @author AtomicStryker
*
* Usage of this class:
* You can use this Interface to create your own Dynamic Light Sources to use with Dynamic Lights.
* Implement this interface, write code as you see fit, and then use the method:
*
* DynamicLights.addLightSource(IDynamicLightSource yourLightObjectHere) to get Dynamic Lights to use it.
*
* When you want your Light to turn off, simply call
*
* DynamicLights.removeLightSource(IDynamicLightSource yourLightObjectHere)
*
*
* You could also just return a Light Level <1, but that would leave your Light in the aggressively iterated List -
* please do not do that.
*
*/
public interface IDynamicLightSource
{
/**
* Entity the Dynamic Light Source is associated with.
* The Light will always be centered on this Entity and move with it.
* Any Entity can only be associated with a single Light!
* If the Entity is dead (eg. Entity.isDead() returns true), the Light will be removed aswell.
*/
public Entity getAttachmentEntity();
/**
* Values above 15 will not be considered, 15 is the MC max level. Values below 1 are considered disabled.
* Values can be changed on the fly.
* @return int value of Minecraft Light level at the Dynamic Light Source
*/
public int getLightLevel();
}
| nalimleinad/Battlegear2 | src/api/java/atomicstryker/dynamiclights/client/IDynamicLightSource.java | Java | gpl-3.0 | 1,405 | [
30522,
7427,
9593,
3367,
2854,
5484,
1012,
8790,
15733,
1012,
7396,
1025,
12324,
5658,
1012,
3067,
10419,
1012,
9178,
1012,
9178,
1025,
1013,
1008,
1008,
1008,
1008,
1030,
3166,
9593,
3367,
2854,
5484,
1008,
1008,
8192,
1997,
2023,
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... |
Getting Started With FOSUserBundle
==================================
The Symfony2 security component provides a flexible security framework that
allows you to load users from configuration, a database, or anywhere else
you can imagine. The FOSUserBundle builds on top of this to make it quick
and easy to store users in a database.
So, if you need to persist and fetch the users in your system to and from
a database, then you're in the right place.
## Prerequisites
This version of the bundle requires Symfony 2.1+. If you are using Symfony
2.0.x, please use the 1.2.x releases of the bundle.
### Translations
If you wish to use default texts provided in this bundle, you have to make
sure you have translator enabled in your config.
``` yaml
# app/config/config.yml
framework:
translator: ~
```
For more information about translations, check [Symfony documentation](http://symfony.com/doc/current/book/translation.html).
## Installation
Installation is a quick (I promise!) 7 step process:
1. Download FOSUserBundle using composer
2. Enable the Bundle
3. Create your User class
4. Configure your application's security.yml
5. Configure the FOSUserBundle
6. Import FOSUserBundle routing
7. Update your database schema
### Step 1: Download FOSUserBundle using composer
Add FOSUserBundle by running the command:
``` bash
$ php composer.phar require friendsofsymfony/user-bundle "~2.0@dev"
```
Composer will install the bundle to your project's `vendor/friendsofsymfony` directory.
### Step 2: Enable the bundle
Enable the bundle in the kernel:
``` php
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new FOS\UserBundle\FOSUserBundle(),
);
}
```
### Step 3: Create your User class
The goal of this bundle is to persist some `User` class to a database (MySql,
MongoDB, CouchDB, etc). Your first job, then, is to create the `User` class
for your application. This class can look and act however you want: add any
properties or methods you find useful. This is *your* `User` class.
The bundle provides base classes which are already mapped for most fields
to make it easier to create your entity. Here is how you use it:
1. Extend the base `User` class (from the ``Model`` folder if you are using
any of the doctrine variants, or ``Propel`` for propel)
2. Map the `id` field. It must be protected as it is inherited from the parent class.
**Warning:**
> When you extend from the mapped superclass provided by the bundle, don't
> redefine the mapping for the other fields as it is provided by the bundle.
Your `User` class can live inside any bundle in your application. For example,
if you work at "Acme" company, then you might create a bundle called `AcmeUserBundle`
and place your `User` class in it.
In the following sections, you'll see examples of how your `User` class should
look, depending on how you're storing your users (Doctrine ORM, MongoDB ODM,
or CouchDB ODM).
**Note:**
> The doc uses a bundle named `AcmeUserBundle`. If you want to use the same
> name, you need to register it in your kernel. But you can of course place
> your user class in the bundle you want.
**Warning:**
> If you override the __construct() method in your User class, be sure
> to call parent::__construct(), as the base User class depends on
> this to initialize some fields.
#### a) Doctrine ORM User class
If you're persisting your users via the Doctrine ORM, then your `User` class
should live in the `Entity` namespace of your bundle and look like this to
start:
##### Annotations
``` php
<?php
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
```
**Note:**
> `User` is a reserved keyword in SQL so you cannot use it as table name.
##### yaml
If you use yml to configure Doctrine you must add two files. The Entity and the orm.yml:
```php
<?php
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*/
class User extends BaseUser
{
public function __construct()
{
parent::__construct();
// your own logic
}
}
```
```yaml
# src/Acme/UserBundle/Resources/config/doctrine/User.orm.yml
Acme\UserBundle\Entity\User:
type: entity
table: fos_user
id:
id:
type: integer
generator:
strategy: AUTO
```
##### xml
If you use xml to configure Doctrine you must add two files. The Entity and the orm.xml:
```php
<?php
// src/Acme/UserBundle/Entity/User.php
namespace Acme\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*/
class User extends BaseUser
{
public function __construct()
{
parent::__construct();
// your own logic
}
}
```
```xml
<?xml version="1.0" encoding="utf-8"?>
<!-- src/Acme/UserBundle/Resources/config/doctrine/User.orm.xml -->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Acme\UserBundle\Entity\User" table="fos_user">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>
```
#### b) MongoDB User class
If you're persisting your users via the Doctrine MongoDB ODM, then your `User`
class should live in the `Document` namespace of your bundle and look like
this to start:
``` php
<?php
// src/Acme/UserBundle/Document/User.php
namespace Acme\UserBundle\Document;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class User extends BaseUser
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
```
#### c) CouchDB User class
If you're persisting your users via the Doctrine CouchDB ODM, then your `User`
class should live in the `CouchDocument` namespace of your bundle and look like
this to start:
``` php
<?php
// src/Acme/UserBundle/Document/User.php
namespace Acme\UserBundle\CouchDocument;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;
/**
* @CouchDB\Document
*/
class User extends BaseUser
{
/**
* @CouchDB\Id
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
```
**d) Propel User class**
If you don't want to add your own logic in your user class, you can simply use
`FOS\UserBundle\Propel\User` as user class and you don't have to create
another class.
If you want to add your own fields, you can extend the model class by overriding the database schema.
Just copy the `Resources/config/propel/schema.xml` file to `app/Resources/FOSUserBundle/config/propel/schema.xml`,
and customize it to fit your needs.
### Step 4: Configure your application's security.yml
In order for Symfony's security component to use the FOSUserBundle, you must
tell it to do so in the `security.yml` file. The `security.yml` file is where the
basic security configuration for your application is contained.
Below is a minimal example of the configuration necessary to use the FOSUserBundle
in your application:
``` yaml
# app/config/security.yml
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: security.csrf.token_manager # Use form.csrf_provider instead for Symfony <2.4
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
```
Under the `providers` section, you are making the bundle's packaged user provider
service available via the alias `fos_userbundle`. The id of the bundle's user
provider service is `fos_user.user_provider.username`.
Next, take a look at and examine the `firewalls` section. Here we have declared a
firewall named `main`. By specifying `form_login`, you have told the Symfony2
framework that any time a request is made to this firewall that leads to the
user needing to authenticate himself, the user will be redirected to a form
where he will be able to enter his credentials. It should come as no surprise
then that you have specified the user provider service we declared earlier as the
provider for the firewall to use as part of the authentication process.
**Note:**
> Although we have used the form login mechanism in this example, the FOSUserBundle
> user provider service is compatible with many other authentication methods as well.
> Please read the Symfony2 Security component documentation for more information on the
> other types of authentication methods.
The `access_control` section is where you specify the credentials necessary for
users trying to access specific parts of your application. The bundle requires
that the login form and all the routes used to create a user and reset the password
be available to unauthenticated users but use the same firewall as
the pages you want to secure with the bundle. This is why you have specified that
any request matching the `/login` pattern or starting with `/register` or
`/resetting` have been made available to anonymous users. You have also specified
that any request beginning with `/admin` will require a user to have the
`ROLE_ADMIN` role.
For more information on configuring the `security.yml` file please read the Symfony2
security component [documentation](http://symfony.com/doc/current/book/security.html).
**Note:**
> Pay close attention to the name, `main`, that we have given to the firewall which
> the FOSUserBundle is configured in. You will use this in the next step when you
> configure the FOSUserBundle.
### Step 5: Configure the FOSUserBundle
Now that you have properly configured your application's `security.yml` to work
with the FOSUserBundle, the next step is to configure the bundle to work with
the specific needs of your application.
Add the following configuration to your `config.yml` file according to which type
of datastore you are using.
``` yaml
# app/config/config.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Acme\UserBundle\Entity\User
```
Or if you prefer XML:
``` xml
<!-- app/config/config.xml -->
<!-- other valid 'db-driver' values are 'mongodb' and 'couchdb' -->
<fos_user:config
db-driver="orm"
firewall-name="main"
user-class="Acme\UserBundle\Entity\User"
/>
```
Only three configuration values are required to use the bundle:
* The type of datastore you are using (`orm`, `mongodb`, `couchdb` or `propel`).
* The firewall name which you configured in Step 4.
* The fully qualified class name (FQCN) of the `User` class which you created in Step 3.
**Note:**
> FOSUserBundle uses a compiler pass to register mappings for the base
> User and Group model classes with the object manager that you configured
> it to use. (Unless specified explicitly, this is the default manager
> of your doctrine configuration.)
### Step 6: Import FOSUserBundle routing files
Now that you have activated and configured the bundle, all that is left to do is
import the FOSUserBundle routing files.
By importing the routing files you will have ready made pages for things such as
logging in, creating users, etc.
In YAML:
``` yaml
# app/config/routing.yml
fos_user:
resource: "@FOSUserBundle/Resources/config/routing/all.xml"
```
Or if you prefer XML:
``` xml
<!-- app/config/routing.xml -->
<import resource="@FOSUserBundle/Resources/config/routing/all.xml"/>
```
**Note:**
> In order to use the built-in email functionality (confirmation of the account,
> resetting of the password), you must activate and configure the SwiftmailerBundle.
### Step 7: Update your database schema
Now that the bundle is configured, the last thing you need to do is update your
database schema because you have added a new entity, the `User` class which you
created in Step 4.
For ORM run the following command.
``` bash
$ php app/console doctrine:schema:update --force
```
For MongoDB users you can run the following command to create the indexes.
``` bash
$ php app/console doctrine:mongodb:schema:create --index
```
For Propel users you have to install the [TypehintableBehavior](https://github.com/willdurand/TypehintableBehavior) before to
build your model. First, install it:
```json
{
"require": {
"willdurand/propel-typehintable-behavior": "~1.0"
}
}
```
You now can run the following command to create the model:
``` bash
$ php app/console propel:build
```
> To create SQL, run the command `propel:build --insert-sql` or use migration
> commands if you have an existing schema in your database.
You now can login at `http://app.com/app_dev.php/login`!
### Next Steps
Now that you have completed the basic installation and configuration of the
FOSUserBundle, you are ready to learn about more advanced features and usages
of the bundle.
The following documents are available:
- [Overriding Templates](overriding_templates.md)
- [Hooking into the controllers](controller_events.md)
- [Overriding Controllers](overriding_controllers.md)
- [Overriding Forms](overriding_forms.md)
- [Using the UserManager](user_manager.md)
- [Command Line Tools](command_line_tools.md)
- [Logging by username or email](logging_by_username_or_email.md)
- [Transforming a username to a user in forms](form_type.md)
- [Emails](emails.md)
- [Using the groups](groups.md)
- [More about the Doctrine implementations](doctrine.md)
- [Supplemental Documentation](supplemental.md)
- [Replacing the canonicalizer](canonicalizer.md)
- [Using a custom storage layer](custom_storage_layer.md)
- [Configuration Reference](configuration_reference.md)
- [Adding invitations to registration](adding_invitation_registration.md)
- [Advanced routing configuration](routing.md)
| ericpauwawe/gestCont | vendor/friendsofsymfony/user-bundle/Resources/doc/index.md | Markdown | mit | 15,006 | [
30522,
2893,
2318,
2007,
1042,
2891,
20330,
27265,
2571,
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,
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
/**
* User: Victor Häggqvist
* Date: 6/6/15
* Time: 10:05 PM
*/
namespace AppBundle\Sensor;
use AppBundle\Entity\Sensor;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query\ResultSetMapping;
use Exception;
use Guzzle\Plugin\Backoff\ReasonPhraseBackoffStrategy;
use Symfony\Component\Process\Process;
class SensorController {
/**
* @var EntityManager
*/
private $em;
function __construct(EntityManager $em) {
$this->em = $em;
}
/**
* Get registered sensors
* @return Sensor[]
*/
public function getSensors() {
return $this->em->getRepository('AppBundle:Sensor')->findAll();
}
/**
* Check on sensor hardware
* @param array $sensors Array of sensors
* @return boolean If sensors are ok
*/
public function checkSensors($sensors) {
if (!$sensors)
return false;
$attached = $this->getAttachedSensors();
if (is_array($attached)) { // if this is false, you are probably not on a rpi and just testing stuff
foreach ($sensors as $sensor) {
/** @var Sensor $sensor */
if (!in_array($sensor->getUid(), $attached))
return false;
}
return true;
}
return false;
}
/**
* Add new sensor to system
* @param Sensor $sensor A Sensor object
* @return boolean if addition was successful
*/
public function addSensor(Sensor $sensor) {
$this->em->getConnection()->beginTransaction();
try {
$this->em->persist($sensor);
$this->em->flush();
$conn = $this->em->getConnection();
$sql = sprintf("CREATE TABLE IF NOT EXISTS `sensor_%s` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`temp` int(11) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`))", preg_replace('/\s/', '_', $sensor->getName()));
$conn->exec($sql);
} catch (Exception $e) {
$this->em->getConnection()->rollback();
throw $e;
}
}
/**
* Get array of attached sensors
* @return array|boolean Array of hardware id's
*/
public function getAttachedSensors() {
$exc = shell_exec("ls /sys/bus/w1/devices/ | grep 28");
if (strpos($exc, '28') === false) // ie, grep empty
return false;
$sensors = preg_split("/[\s]/",trim($exc)); //put them in an array
return $sensors;
}
/**
* Drops all metrics form a collection
* @param string Sensor name
*/
public function dropSensorData($name) {
$rsm = new ResultSetMapping();
$this->em->createNativeQuery(sprintf("TRUNCATE `sensor_%s`", $name), $rsm)->execute();
$this->em->flush();
}
/**
* @param Sensor $sensor
* @return bool|string
*/
public function readSensor(Sensor $sensor) {
$process = new Process(sprintf('ls /sys/bus/w1/devices | grep %s', $sensor->getUid()));
$process->run();
$output = $process->getOutput();
if (strlen($output) > 0) {
$temp = $this->readSensorByUid($sensor->getUid());
if (strlen($temp) > 0)
return $temp;
return false;
}
return false;
}
/**
* @param $uid
* @return bool|string
*/
public function readSensorByUid($uid) {
$process = new Process(sprintf('cat /sys/bus/w1/devices/%s/w1_slave', $uid));
$process->run();
$read = $process->getOutput();
$lines = explode("\n", $read);
//get status
$parts = explode(" ", $lines[0]);
$ok = $parts[count($parts)-1];
if ($ok == "YES"){
//get temp
$parts = explode("=", $lines[1]);
$temp = $parts[count($parts)-1];
return $temp;
}else{
return false;
}
}
}
| victorhaggqvist/racktemp | src/AppBundle/Sensor/SensorController.php | PHP | gpl-3.0 | 4,052 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
5310,
1024,
5125,
5292,
13871,
28705,
1008,
3058,
1024,
1020,
1013,
1020,
1013,
2321,
1008,
2051,
1024,
2184,
1024,
5709,
7610,
1008,
1013,
3415,
15327,
10439,
27265,
2571,
1032,
13617,
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... |
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// shared_ptr
// template<class T, class A, class... Args>
// shared_ptr<T> allocate_shared(const A& a, Args&&... args);
#include <memory>
#include <new>
#include <cstdlib>
#include <cassert>
#include "test_allocator.h"
#include "min_allocator.h"
struct Zero
{
static int count;
Zero() {++count;}
Zero(Zero const &) {++count;}
~Zero() {--count;}
};
int Zero::count = 0;
struct One
{
static int count;
int value;
explicit One(int v) : value(v) {++count;}
One(One const & o) : value(o.value) {++count;}
~One() {--count;}
};
int One::count = 0;
struct Two
{
static int count;
int value;
Two(int v, int) : value(v) {++count;}
Two(Two const & o) : value(o.value) {++count;}
~Two() {--count;}
};
int Two::count = 0;
struct Three
{
static int count;
int value;
Three(int v, int, int) : value(v) {++count;}
Three(Three const & o) : value(o.value) {++count;}
~Three() {--count;}
};
int Three::count = 0;
template <class Alloc>
void test()
{
int const bad = -1;
{
std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc());
assert(Zero::count == 1);
}
assert(Zero::count == 0);
{
int const i = 42;
std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i);
assert(One::count == 1);
assert(p->value == i);
}
assert(One::count == 0);
{
int const i = 42;
std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad);
assert(Two::count == 1);
assert(p->value == i);
}
assert(Two::count == 0);
{
int const i = 42;
std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad);
assert(Three::count == 1);
assert(p->value == i);
}
assert(Three::count == 0);
}
int main()
{
{
int i = 67;
int const bad = -1;
std::shared_ptr<Two> p = std::allocate_shared<Two>(test_allocator<Two>(54), i, bad);
assert(test_allocator<Two>::alloc_count == 1);
assert(Two::count == 1);
assert(p->value == 67);
}
assert(Two::count == 0);
assert(test_allocator<Two>::alloc_count == 0);
test<bare_allocator<void> >();
#if TEST_STD_VER >= 11
test<min_allocator<void> >();
#endif
}
| youtube/cobalt | third_party/llvm-project/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_cxx03.pass.cpp | C++ | bsd-3-clause | 2,588 | [
30522,
1013,
1013,
1027,
1027,
1027,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
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... |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Taobao Cpp/Qt SDK: TaoApiCpp/response/WlbItemUpdateResponse.cpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Taobao Cpp/Qt SDK
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_5ced2c06884fa9bf5c2da90298abd959.html">TaoApiCpp</a></li><li class="navelem"><a class="el" href="dir_b6b3a706edffae716cf3dcaba65ad0ec.html">response</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">WlbItemUpdateResponse.cpp File Reference</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include <<a class="el" href="WlbItemUpdateResponse_8h_source.html">TaoApiCpp/response/WlbItemUpdateResponse.h</a>></code><br/>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Apr 14 2013 16:25:38 for Taobao Cpp/Qt SDK by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.3.1
</small></address>
</body>
</html>
| sd44/TaobaoCppQtSDK | doc/WlbItemUpdateResponse_8cpp.html | HTML | gpl-2.0 | 5,003 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
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... |
import Canvas from '../tool/Canvas.js';
import Animation from './Animation/Animation.js';
import Frame from './Animation/Frame.js';
import Player from '../engine/Player.js';
class Avatar {
static radius = 360;
static shakeTime = 300;
constructor(player, direction) {
this.player = player;
this.idle = Avatar.createLozange('#FFFD1B', '#BCBB14', 1, direction, 0.5, 0.75, 0.25);
this.idleShadow = Avatar.createLozange('#000000', '#000000', 0.1, direction, 0.5, 0.75, 0.25);
this.thrust = Avatar.createLozange('#F5DF0E', '#AB9B0A', 1, direction, 0.25, 1, 0.25);
this.thrustShadow = Avatar.createLozange('#000000', '#000000', 0.1, direction, 0.25, 1, 0.25);
this.shake = 0;
this.shakeTimout = null;
this.startShake = this.startShake.bind(this);
this.endShake = this.endShake.bind(this);
this.player.setWallEventListener(this.startShake);
}
static createFrames(color, colorDark, direction) {
const size = Avatar.radius * 2;
const canvas = new Canvas(size, size);
const context = canvas.context();
let frames = [
];
}
static createLozange(color, colorDark, alpha, direction, height, body, head) {
const canvasWidth = 2;
const canvasHeight = 2;
const size = Avatar.radius * 2;
const canvas = new Canvas(size * canvasWidth, size * canvasHeight);
const context = canvas.context;
const center = { x: canvasWidth / 2, y: canvasHeight / 2 };
const top = { x: center.x, y: center.y - (height / 2) };
const right = { x: center.x + head, y: center.y }
const bottom = { x: center.x, y: top.y + height };
const left = { x: center.x - body, y: center.y };
if (direction) {
canvas.reverse();
}
context.scale(size, size);
canvas.setAlpha(alpha);
canvas.setFill(color);
context.beginPath();
context.moveTo(left.x, left.y);
context.lineTo(top.x, top.y);
context.lineTo(right.x, right.y);
context.fill();
canvas.setFill(colorDark);
context.beginPath();
context.moveTo(left.x, left.y);
context.lineTo(bottom.x, bottom.y);
context.lineTo(right.x, right.y);
context.fill();
if (direction) {
canvas.reverse();
}
return canvas;
}
startShake() {
this.shake = Date.now();
this.shakeTimout = setTimeout(this.endShake, Avatar.shakeTime);
}
endShake() {
this.shake = false;
clearTimeout(this.shakeTimout);
}
getShake() {
if (!this.shake) {
return 0;
}
const time = (Date.now() - this.shake) / Avatar.shakeTime * 4 * Math.PI;
return Math.cos(time) * Avatar.radius / 25;
}
draw() {
return this.player.thrusting ? this.thrust.element : this.idle.element;
}
drawShadow() {
return this.player.thrusting ? this.thrustShadow.element : this.idleShadow.element;
}
getSize() {
const ratio = 1 + (this.player.getSpeedRatio() - 1) * 0.5;
return Avatar.radius / devicePixelRatio * ratio;
}
getDropShadow() {
return Avatar.radius * 0.1;
}
}
export default Avatar;
| thrustgame/thrust | src/view/Avatar.js | JavaScript | mit | 3,325 | [
30522,
12324,
10683,
2013,
1005,
1012,
1012,
1013,
6994,
1013,
10683,
1012,
1046,
2015,
1005,
1025,
12324,
7284,
2013,
1005,
1012,
1013,
7284,
1013,
7284,
1012,
1046,
2015,
1005,
1025,
12324,
4853,
2013,
1005,
1012,
1013,
7284,
1013,
4853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta charset="utf-8"/>
<title>API Documentation</title>
<meta name="author" content=""/>
<meta name="description" content=""/>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet">
<link href="../css/prism.css" rel="stylesheet" media="all"/>
<link href="../css/template.css" rel="stylesheet" media="all"/>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="../js/jquery.smooth-scroll.js"></script>
<script src="../js/prism.min.js"></script>
<!-- TODO: Add http://jscrollpane.kelvinluck.com/ to style the scrollbars for browsers not using webkit-->
<script type="text/javascript">
function loadExternalCodeSnippets() {
Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) {
var src = pre.getAttribute('data-src');
var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
var language = 'php';
var code = document.createElement('code');
code.className = 'language-' + language;
pre.textContent = '';
code.textContent = 'Loading…';
pre.appendChild(code);
var xhr = new XMLHttpRequest();
xhr.open('GET', src, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status < 400 && xhr.responseText) {
code.textContent = xhr.responseText;
Prism.highlightElement(code);
}
else if (xhr.status >= 400) {
code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
}
else {
code.textContent = '✖ Error: File does not exist or is empty';
}
}
};
xhr.send(null);
});
}
$(document).ready(function(){
loadExternalCodeSnippets();
});
$('#source-view').on('shown', function () {
loadExternalCodeSnippets();
})
</script>
<link rel="shortcut icon" href="../images/favicon.ico"/>
<link rel="apple-touch-icon" href="../images/apple-touch-icon.png"/>
<link rel="apple-touch-icon" sizes="72x72" href="../images/apple-touch-icon-72x72.png"/>
<link rel="apple-touch-icon" sizes="114x114" href="../images/apple-touch-icon-114x114.png"/>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<i class="icon-ellipsis-vertical"></i>
</a>
<a class="brand" href="../index.html">API Documentation</a>
<div class="nav-collapse">
<ul class="nav pull-right">
<li class="dropdown">
<a href="../index.html" class="dropdown-toggle" data-toggle="dropdown">
API Documentation <b class="caret"></b>
</a>
<ul class="dropdown-menu">
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Charts <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>
<a href="../graphs/class.html">
<i class="icon-list-alt"></i> Class hierarchy diagram
</a>
</li>
</ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Reports <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>
<a href="../reports/errors.html">
<i class="icon-list-alt"></i> Errors
</a>
</li>
<li>
<a href="../reports/markers.html">
<i class="icon-list-alt"></i> Markers
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<!--<div class="go_to_top">-->
<!--<a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a>-->
<!--</div>-->
</div>
<div id="___" class="container-fluid">
<section class="row-fluid">
<div class="span2 sidebar">
<div class="accordion" style="margin-bottom: 0">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle " data-toggle="collapse" data-target="#namespace-1823201278"></a>
<a href="../namespaces/default.html" style="margin-left: 30px; padding-left: 0">\</a>
</div>
<div id="namespace-1823201278" class="accordion-body collapse in">
<div class="accordion-inner">
<ul>
<li class="class"><a href="../classes/Partecipazione.html">Partecipazione</a></li>
<li class="class"><a href="../classes/Dimissione.html">Dimissione</a></li>
<li class="class"><a href="../classes/Zip.html">Zip</a></li>
<li class="class"><a href="../classes/Commento.html">Commento</a></li>
<li class="class"><a href="../classes/Utente.html">Utente</a></li>
<li class="class"><a href="../classes/Appartenenza.html">Appartenenza</a></li>
<li class="class"><a href="../classes/Anonimo.html">Anonimo</a></li>
<li class="class"><a href="../classes/Documento.html">Documento</a></li>
<li class="class"><a href="../classes/Mail.html">Mail</a></li>
<li class="class"><a href="../classes/Sessione.html">Sessione</a></li>
<li class="class"><a href="../classes/Entita.html">Entita</a></li>
<li class="class"><a href="../classes/Area.html">Area</a></li>
<li class="class"><a href="../classes/RichiestaTurno.html">RichiestaTurno</a></li>
<li class="class"><a href="../classes/Annunci.html">Annunci</a></li>
<li class="class"><a href="../classes/Gruppo.html">Gruppo</a></li>
<li class="class"><a href="../classes/Patentirichieste.html">Patentirichieste</a></li>
<li class="class"><a href="../classes/Reperibilita.html">Reperibilita</a></li>
<li class="class"><a href="../classes/GeocoderResult.html">GeocoderResult</a></li>
<li class="class"><a href="../classes/AppartenenzaGruppo.html">AppartenenzaGruppo</a></li>
<li class="class"><a href="../classes/Ricerca.html">Ricerca</a></li>
<li class="class"><a href="../classes/APIServer.html">APIServer</a></li>
<li class="class"><a href="../classes/Volontario.html">Volontario</a></li>
<li class="class"><a href="../classes/Veicoli.html">Veicoli</a></li>
<li class="class"><a href="../classes/Regionale.html">Regionale</a></li>
<li class="class"><a href="../classes/ElementoRichiesta.html">ElementoRichiesta</a></li>
<li class="class"><a href="../classes/ICalendar.html">ICalendar</a></li>
<li class="class"><a href="../classes/Errore.html">Errore</a></li>
<li class="class"><a href="../classes/File.html">File</a></li>
<li class="class"><a href="../classes/Quota.html">Quota</a></li>
<li class="class"><a href="../classes/Comitato.html">Comitato</a></li>
<li class="class"><a href="../classes/Oggetto.html">Oggetto</a></li>
<li class="class"><a href="../classes/Avatar.html">Avatar</a></li>
<li class="class"><a href="../classes/Persona.html">Persona</a></li>
<li class="class"><a href="../classes/Trasferimento.html">Trasferimento</a></li>
<li class="class"><a href="../classes/Turno.html">Turno</a></li>
<li class="class"><a href="../classes/Attivita.html">Attivita</a></li>
<li class="class"><a href="../classes/Provinciale.html">Provinciale</a></li>
<li class="class"><a href="../classes/PDF.html">PDF</a></li>
<li class="class"><a href="../classes/Estensione.html">Estensione</a></li>
<li class="class"><a href="../classes/Autorizzazione.html">Autorizzazione</a></li>
<li class="class"><a href="../classes/Coturno.html">Coturno</a></li>
<li class="class"><a href="../classes/Nazionale.html">Nazionale</a></li>
<li class="class"><a href="../classes/TitoloPersonale.html">TitoloPersonale</a></li>
<li class="class"><a href="../classes/Delegato.html">Delegato</a></li>
<li class="class"><a href="../classes/Email.html">Email</a></li>
<li class="class"><a href="../classes/Riserva.html">Riserva</a></li>
<li class="class"><a href="../classes/Excel.html">Excel</a></li>
<li class="class"><a href="../classes/GeoPolitica.html">GeoPolitica</a></li>
<li class="class"><a href="../classes/Geocoder.html">Geocoder</a></li>
<li class="class"><a href="../classes/GeoEntita.html">GeoEntita</a></li>
<li class="class"><a href="../classes/DT.html">DT</a></li>
<li class="class"><a href="../classes/Locale.html">Locale</a></li>
<li class="class"><a href="../classes/Titolo.html">Titolo</a></li>
<li class="class"><a href="../classes/ePDO.html">ePDO</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="row-fluid">
<div class="span10 offset2">
<div class="row-fluid">
<div class="span8 content file">
<nav>
</nav>
<a href="#source-view" role="button" class="pull-right btn" data-toggle="modal"><i class="icon-code"></i></a>
<h1><small>core/class</small>Volontario.class.php</h1>
<p><em></em></p>
<h2>Classes</h2>
<table class="table table-hover">
<tr>
<td><a href="../classes/Volontario.html">Volontario</a></td>
<td><em>Rappresenta una Entita generica nel database</em></td>
</tr>
</table>
</div>
<aside class="span4 detailsbar">
<dl>
<dt>Package</dt>
<dd><div class="namespace-wrapper">Gaia</div></dd>
</dl>
<h2>Tags</h2>
<table class="table table-condensed">
<tr><td colspan="2"><em>None found</em></td></tr>
</table>
</aside>
</div>
</div>
</section>
<div id="source-view" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="source-view-label" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="source-view-label"></h3>
</div>
<div class="modal-body">
<pre data-src="../files/core/class/Volontario.class.php.txt" class="language-php line-numbers"></pre>
</div>
</div>
<footer class="row-fluid">
<section class="span10 offset2">
<section class="row-fluid">
<section class="span10 offset1">
<section class="row-fluid footer-sections">
<section class="span4">
<h1><i class="icon-code"></i></h1>
<div>
<ul>
</ul>
</div>
</section>
<section class="span4">
<h1><i class="icon-bar-chart"></i></h1>
<div>
<ul>
<li><a href="">Class Hierarchy Diagram</a></li>
</ul>
</div>
</section>
<section class="span4">
<h1><i class="icon-pushpin"></i></h1>
<div>
<ul>
<li><a href="">Errors</a></li>
<li><a href="">Markers</a></li>
</ul>
</div>
</section>
</section>
</section>
</section>
<section class="row-fluid">
<section class="span10 offset1">
<hr />
Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor </a> and authored
on September 18th, 2013 at 18:37.
</section>
</section>
</section>
</footer>
</div>
</body>
</html>
| luca-dex/gaia | docs/files/core.class.Volontario.class.php.html | HTML | gpl-3.0 | 17,502 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
4180,
1027,
1000,
9381,
1027,
5080,
1011,
9381,
1010,
3988,
1011,
4094,
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... |
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with
** the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef S60CCAMERAENGINE_H
#define S60CCAMERAENGINE_H
// INCLUDES
#include <e32base.h>
#include <ecam.h> // for MCameraObserver(2)
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
#include <ccamautofocus.h> // for CCamAutoFocus, MCamAutoFocusObserver
#endif
// FORWARD DECLARATIONS
class MCameraEngineObserver;
class MCameraEngineImageCaptureObserver;
class MAdvancedSettingsObserver;
class MCameraViewfinderObserver;
/*
* CameraEngine handling ECam operations needed.
*/
NONSHARABLE_CLASS( CCameraEngine ) : public CBase,
public MCameraObserver,
public MCameraObserver2
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
,public MCamAutoFocusObserver
#endif
{
public: // Enums
enum TCameraEngineState
{
EEngineNotReady = 0, // 0 - No resources reserved
EEngineInitializing, // 1 - Reserving and Powering On
EEngineIdle, // 2 - Reseved and Powered On
EEngineCapturing, // 3 - Capturing Still Image
EEngineFocusing // 4 - Focusing
};
public: // Constructor & Destructor
static CCameraEngine* NewL( TInt aCameraHandle,
TInt aPriority,
MCameraEngineObserver* aObserver );
~CCameraEngine();
public:
/**
* External Advanced Settings callback observer.
*/
void SetAdvancedObserver(MAdvancedSettingsObserver *aAdvancedSettingsObserver);
/**
* External Image Capture callback observer.
*/
void SetImageCaptureObserver(MCameraEngineImageCaptureObserver *aImageCaptureObserver);
/**
* External Viewfinder callback observer.
*/
void SetViewfinderObserver(MCameraViewfinderObserver *aViewfinderObserver);
/**
* Static function that returns the number of cameras on the device.
*/
static TInt CamerasAvailable();
/**
* Returns the index of the currently active camera device
*/
TInt currentCameraIndex() const { return iCameraIndex; }
/**
* Returns the current state (TCameraEngineState)
* of the camera engine.
*/
TCameraEngineState State() const { return iEngineState; }
/**
* Returns true if the camera has been reserved and
* powered on, and not recording or capturing image
*/
TBool IsCameraReady() const;
/**
* Returns whether DirectScreen ViewFinder is supported by the platform
*/
TBool IsDirectViewFinderSupported() const;
/**
* Returns true if the camera supports AutoFocus.
*/
TBool IsAutoFocusSupported() const;
/**
* Returns camera info
*/
TCameraInfo *cameraInfo();
/**
* Captures an image. When complete, observer will receive
* MceoCapturedDataReady() or MceoCapturedBitmapReady() callback,
* depending on which image format was used in PrepareL().
* @leave May leave with KErrNotReady if camera is not
* reserved or prepared for capture.
*/
void CaptureL();
/**
* Cancels ongoing image capture
*/
void cancelCapture();
/**
* Reserves and powers on the camera. When complete,
* observer will receive MceoCameraReady() callback
*
*/
void ReserveAndPowerOn();
/**
* Releases and powers off the camera
*
*/
void ReleaseAndPowerOff();
/**
* Prepares for image capture.
* @param aCaptureSize requested capture size. On return,
* contains the selected size (closest match)
* @param aFormat Image format to use. Default is JPEG with
* EXIF information as provided by the camera module
* @leave KErrNotSupported, KErrNoMemory, KErrNotReady
*/
void PrepareL( TSize& aCaptureSize,
CCamera::TFormat aFormat = CCamera::EFormatExif );
/**
* Starts the viewfinder. Observer will receive
* MceoViewFinderFrameReady() callbacks periodically.
* @param aSize requested viewfinder size. On return,
* contains the selected size.
*
* @leave KErrNotSupported is viewfinding with bitmaps is not
* supported, KErrNotReady
*/
void StartViewFinderL( TSize& aSize );
/**
* Stops the viewfinder if active.
*/
void StopViewFinder();
void StartDirectViewFinderL(RWsSession& aSession,
CWsScreenDevice& aScreenDevice,
RWindowBase& aWindow,
TRect& aSize);
/**
* Releases memory for the last received viewfinder frame.
* Client must call this in response to MceoViewFinderFrameReady()
* callback, after drawing the viewfinder frame is complete.
*/
void ReleaseViewFinderBuffer();
/**
* Releases memory for the last captured image.
* Client must call this in response to MceoCapturedDataReady()
* or MceoCapturedBitmapReady()callback, after processing the
* data/bitmap is complete.
*/
void ReleaseImageBuffer();
/**
* Starts focusing. Does nothing if AutoFocus is not supported.
* When complete, observer will receive MceoFocusComplete()
* callback.
* @leave KErrInUse, KErrNotReady
*/
void StartFocusL();
/**
* Cancels the ongoing focusing operation.
*/
void FocusCancel();
/**
* Gets a bitfield of supported focus ranges.
* @param aSupportedRanges a bitfield of either TAutoFocusRange
* (S60 3.0/3.1 devices) or TFocusRange (S60 3.2 and onwards) values
*/
void SupportedFocusRanges( TInt& aSupportedRanges ) const;
/**
* Sets the focus range
* @param aFocusRange one of the values returned by
* SupportedFocusRanges().
*/
void SetFocusRange( TInt aFocusRange );
/**
* Returns a pointer to CCamera object used by the engine.
* Allows getting access to additional functionality
* from CCamera - do not use for functionality already provided
* by CCameraEngine methods.
*/
CCamera* Camera() { return iCamera; }
protected: // Protected constructors
CCameraEngine();
CCameraEngine( TInt aCameraHandle,
TInt aPriority,
MCameraEngineObserver* aObserver );
void ConstructL();
protected: // MCameraObserver
/**
* From MCameraObserver
* Gets called when CCamera::Reserve() is completed.
* (V2: Called internally from HandleEvent)
*/
virtual void ReserveComplete(TInt aError);
/**
* From MCameraObserver.
* Gets called when CCamera::PowerOn() is completed.
* (V2: Called internally from HandleEvent)
*/
virtual void PowerOnComplete(TInt aError);
/**
* From MCameraObserver.
* Gets called when CCamera::StartViewFinderBitmapsL() is completed.
* (V2: Called internally from ViewFinderReady)
*/
virtual void ViewFinderFrameReady( CFbsBitmap& aFrame );
/**
* From MCameraObserver.
* Gets called when CCamera::CaptureImage() is completed.
*/
virtual void ImageReady( CFbsBitmap* aBitmap, HBufC8* aData, TInt aError );
/**
* From MCameraObserver.
* Video capture not implemented.
*/
virtual void FrameBufferReady( MFrameBuffer* /*aFrameBuffer*/, TInt /*aError*/ ) {}
protected: // MCameraObserver2
/**
* From MCameraObserver2
* Camera event handler
*/
virtual void HandleEvent(const TECAMEvent &aEvent);
/**
* From MCameraObserver2
* Notifies the client of new viewfinder data
*/
virtual void ViewFinderReady(MCameraBuffer &aCameraBuffer, TInt aError);
/**
* From MCameraObserver2
* Notifies the client of a new captured image
*/
virtual void ImageBufferReady(MCameraBuffer &aCameraBuffer, TInt aError);
/**
* From MCameraObserver2
* Video capture not implemented.
*/
virtual void VideoBufferReady(MCameraBuffer& /*aCameraBuffer*/, TInt /*aError*/) {}
protected: // MCamAutoFocusObserver
/**
* From MCamAutoFocusObserver.
* Delivers notification of completion of auto focus initialisation to
* an interested party.
* @param aError Reason for completion of focus request.
*/
virtual void InitComplete( TInt aError );
/**
* From MCamAutoFocusObserver.
* Gets called when CCamAutoFocus::AttemptOptimisedFocusL() is
* completed.
* (V2: Called internally from HandleEvent)
*/
virtual void OptimisedFocusComplete( TInt aError );
private: // Internal functions
/**
* Internal function to handle ImageReady callbacks from
* both observer (V1 & V2) interfaces
*/
void HandleImageReady(const TInt aError, const bool isBitmap);
private: // Data
CCamera *iCamera;
MCameraEngineObserver *iObserver;
MCameraEngineImageCaptureObserver *iImageCaptureObserver;
MAdvancedSettingsObserver *iAdvancedSettingsObserver;
MCameraViewfinderObserver *iViewfinderObserver;
MCameraBuffer *iViewFinderBuffer;
/*
* Following pointers are for the image buffers:
* * Makes buffering of 2 concurrent image buffers possible
*/
MCameraBuffer *iImageBuffer1;
MCameraBuffer *iImageBuffer2;
TDesC8 *iImageData1;
TDesC8 *iImageData2;
CFbsBitmap *iImageBitmap1;
CFbsBitmap *iImageBitmap2;
TInt iCameraIndex;
TInt iPriority;
TCameraEngineState iEngineState;
TCameraInfo iCameraInfo;
CCamera::TFormat iImageCaptureFormat;
bool iNew2LImplementation;
int iLatestImageBufferIndex; // 0 = Buffer1, 1 = Buffer2
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
CCamAutoFocus* iAutoFocus;
CCamAutoFocus::TAutoFocusRange iAFRange;
#endif // S60_CAM_AUTOFOCUS_SUPPORT
};
#endif // S60CCAMERAENGINE_H
| robclark/qtmobility-1.1.0 | plugins/multimedia/symbian/ecam/s60cameraengine.h | C | lgpl-2.1 | 12,226 | [
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... |
# Rhodoglossum owensiae Hollenberg & I.A.Abbott, 1968 SPECIES
#### Status
SYNONYM
#### According to
World Register of Marine Species
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Rhodophyta/Florideophyceae/Gigartinales/Gigartinaceae/Mazzaella/Mazzaella californica/ Syn. Rhodoglossum owensiae/README.md | Markdown | apache-2.0 | 201 | [
30522,
1001,
1054,
6806,
16168,
10483,
17421,
14824,
19001,
7570,
12179,
4059,
1004,
1045,
1012,
1037,
1012,
14455,
1010,
3380,
2427,
1001,
1001,
1001,
1001,
3570,
10675,
1001,
1001,
1001,
1001,
2429,
2000,
2088,
4236,
1997,
3884,
2427,
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... |
'use strict';
var auth = require('../middleware/auth');
var express = require('express');
var router = express.Router();
var achievements = require('../common/achievements');
var User = require('../models').users;
var Action = require('../models').actions;
var Log = require('../models').logs;
/**
* @api {get} /user/action Get user's action list
* @apiGroup User Action
*
* @apiExample {curl} Example usage:
* # Get API token via /api/user/token
* export API_TOKEN=fc35e6b2f27e0f5ef...
*
* curl -i -X GET -H "Authorization: Bearer $API_TOKEN" \
* http://localhost:3000/api/user/action
*
* @apiSuccessExample {json} Success-Response:
* {
* "pending": {},
* "inProgress": {
* "55b230d69a8c96f177154fa1": {
* "_id": "55b230d69a8c96f177154fa1",
* "name": "Disable standby",
* "description": "Turn off and unplug standby power of TV, stereo, computer, etc.",
* "effort": 2,
* "impact": 2,
* "category": null,
* "startedDate": "2015-08-11T10:31:39.934Z"
* },
* "55b230d69a8c96f177154fa2": {
* "startedDate": "2015-08-11T10:43:33.485Z",
* "impact": 3,
* "effort": 4,
* "description": "Find and seal up leaks",
* "name": "Leaks",
* "_id": "55b230d69a8c96f177154fa2"
* }
* },
* "done": {},
* "declined": {},
* "na": {}
* }
*/
router.get('/', auth.authenticate(), function(req, res) {
res.json(req.user.actions);
Log.create({
userId: req.user._id,
category: 'User Action',
type: 'get',
data: {}
});
});
/**
* @api {get} /user/action/suggested Get list of suggested user actions
* @apiGroup User Action
* @apiDescription Returns top three most recent actions that the user has not tried
*
* @apiExample {curl} Example usage:
* # Get API token via /api/user/token
* export API_TOKEN=fc35e6b2f27e0f5ef...
*
* curl -i -X GET -H "Authorization: Bearer $API_TOKEN" \
* http://localhost:3000/api/user/action/suggested
*
* @apiSuccessExample {json} Success-Response:
* [
* {
* "__v": 0,
* "_id": "555f0163688305b57c7cef6c",
* "description": "Disabling standby can save up to 10% in total electricity costs.",
* "effort": 2,
* "impact": 2,
* "name": "Disable standby on your devices",
* "ratings": []
* },
* {
* ...
* }
* ]
*
* @apiVersion 1.0.0
*/
router.get('/suggested', auth.authenticate(), function(req, res) {
Action.getSuggested(req.user, res.successRes);
Log.create({
userId: req.user._id,
category: 'User Action',
type: 'getSuggested',
data: res.successRes
});
});
/**
* @api {post} /user/action/:actionId Change state for user action
* @apiGroup User Action
* @apiDescription Used to start/stop actions for a user.
*
* @apiParam {String} actionId Action's MongoId
* @apiParam {String} state Can be one of: 'pending', 'inProgress', 'alreadyDoing',
* 'done', 'canceled', 'declined', 'na'.
* @apiParam {Date} postponed Must be provided if state is 'pending'. Specifies
* at which time the user will be reminded of the action again.
*
* @apiExample {curl} Example usage:
* # Get API token via /api/user/token
* export API_TOKEN=fc35e6b2f27e0f5ef...
*
* curl -i -X POST -H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" -d \
* '{
* "state": "inProgress"
* }' \
* http://localhost:3000/api/user/action/55b230d69a8c96f177154fa1
*
* @apiSuccessExample {json} Success-Response:
* {
* "pending": {},
* "inProgress": {
* "55b230d69a8c96f177154fa1": {
* "_id": "55b230d69a8c96f177154fa1",
* "name": "Disable standby",
* "description": "Turn off and unplug standby power of TV, stereo, computer, etc.",
* "effort": 2,
* "impact": 2,
* "category": null,
* "startedDate": "2015-08-11T10:31:39.934Z"
* },
* "55b230d69a8c96f177154fa2": {
* "startedDate": "2015-08-11T10:43:33.485Z",
* "impact": 3,
* "effort": 4,
* "description": "Find and seal up leaks",
* "name": "Leaks",
* "_id": "55b230d69a8c96f177154fa2"
* }
* },
* "done": {},
* "declined": {},
* "na": {}
* }
*/
router.post('/:actionId', auth.authenticate(), function(req, res) {
User.setActionState(req.user, req.params.actionId, req.body.state, req.body.postponed,
function(err, user) {
if (!err) {
achievements.updateAchievement(req.user, 'actionsDone', function(oldVal) {
// make sure we never decerase the action count
return Math.max(oldVal, user.actions ? user.actions.done.length : 0);
});
}
res.successRes(err, user);
});
Log.create({
userId: req.user._id,
category: 'User Action',
type: 'update',
data: req.body
});
});
module.exports = router;
| CIVIS-project/YouPower | backend/routes/userAction.js | JavaScript | apache-2.0 | 4,813 | [
30522,
1005,
2224,
9384,
1005,
1025,
13075,
8740,
2705,
1027,
5478,
1006,
1005,
1012,
1012,
1013,
2690,
8059,
1013,
8740,
2705,
1005,
1007,
1025,
13075,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
13075,
2799,
2099,
1027,
4671,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 'resolv'
module Geocoder
class IpAddress < String
def loopback?
valid? and !!(self == "0.0.0.0" or self.match(/\A127\./) or self == "::1")
end
def valid?
!!((self =~ Resolv::IPv4::Regex) || (self =~ Resolv::IPv6::Regex))
end
end
end
| tiramizoo/geocoder | lib/geocoder/ip_address.rb | Ruby | mit | 275 | [
30522,
5478,
1005,
24501,
4747,
2615,
1005,
11336,
20248,
16044,
2099,
2465,
25249,
16200,
4757,
1026,
5164,
13366,
7077,
5963,
1029,
9398,
1029,
1998,
999,
999,
1006,
2969,
1027,
1027,
1000,
1014,
1012,
1014,
1012,
1014,
1012,
1014,
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... |
<?php
namespace AsseticBundle\Controller;
use AsseticBundle\AsseticBundleServiceAwareInterface;
use AsseticBundle\Service;
use Zend\Mvc\Controller\AbstractActionController;
class ConsoleController extends AbstractActionController implements AsseticBundleServiceAwareInterface
{
/**
* @var Service
*/
protected $assetic;
public function buildAction()
{
$config = $this->assetic->getConfiguration();
$config->setBuildOnRequest(true);
$this->assetic->build();
$manager = $this->assetic->getAssetManager();
$writer = $this->assetic->getAssetWriter();
$writer->writeManagerAssets($manager);
}
public function setupAction()
{
$config = $this->assetic->getConfiguration();
$mode = (null !== ($mode = $config->getUmask())) ? $mode : 0775;
$displayMode = decoct($mode);
$cachePath = $config->getCachePath();
$pathExists = is_dir($cachePath);
if ($cachePath && !$pathExists) {
mkdir($cachePath, $mode, true);
echo "Cache path created '$cachePath' with mode '$displayMode' \n";
} else if ($pathExists) {
echo "Creation of cache path '$cachePath' skipped - path exists \n";
} else {
echo "Creation of cache path '$cachePath' skipped - no path provided \n";
}
$webPath = $config->getWebPath();
$pathExists = is_dir($webPath);
if ($webPath && !$pathExists) {
mkdir($webPath, $mode, true);
echo "Web path created '$webPath' with mode '$displayMode' \n";
} else if ($pathExists) {
echo "Creation of web path '$webPath' skipped - path exists \n";
} else {
echo "Creation of web path '$webPath' skipped - no path provided \n";
}
}
public function setAsseticBundleService(Service $service)
{
$this->assetic = $service;
}
} | asward/PaInstDb | vendor/widmogrod/zf2-assetic-module/src/AsseticBundle/Controller/ConsoleController.php | PHP | bsd-3-clause | 1,936 | [
30522,
1026,
1029,
25718,
3415,
15327,
11412,
2594,
27265,
2571,
1032,
11486,
1025,
2224,
11412,
2594,
27265,
2571,
1032,
11412,
2594,
27265,
24527,
2099,
7903,
5243,
8059,
18447,
2121,
12172,
1025,
2224,
11412,
2594,
27265,
2571,
1032,
2326,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 main.tracer.state;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.json.JSONArray;
import org.json.JSONObject;
import main.tracer.FieldKey;
import main.tracer.TraceFilter;
/**
* A tracer state representing an {@code Object} in Java.
*/
public class ObjectState extends State {
private static final long serialVersionUID = 1L;
private static final String NAME = "name";
private static final String VALUE = "value";
// fields
private String className; // the name of the class
private Map<FieldKey, State> fields = new HashMap<>(); // a map of all the fields the class holds
private Map<FieldKey, State> originalFields = new HashMap<>();
/**
* Constructs a new instance of {@code ObjectState} with the specified
* class name.
*
* @param className
* - name of class
*/
public ObjectState(String className) {
this.className = className;
}
/**
* Returns the class name of the {@code Object} represented by
* this {@code ObjectState}.
*
* @return
* - class name of object
*/
public String getClassName() {
return className;
}
/**
* Returns the fields of the {@code Object} represented by this
* {@code ObjectState}.
*
* @return
* - fields of object
*/
public Map<FieldKey, State> getFields() {
return fields;
}
/**
* Sets the fields associated with this {@code ObjectState} with the specified
* fields.
*
* @param fields
* - fields to assign
*/
public void setFields(Map<FieldKey, State> fields) {
for (Map.Entry<FieldKey, State> m : fields.entrySet()){
originalFields.put(m.getKey(), m.getValue());
}
this.fields = fields;
}
/**
* Filter the visible fields of this {@code ObjectState} based on the
* specified {@code TraceFilter}.
*/
public void filterFields(TraceFilter f) {
//System.out.println(origonalFields);
fields.clear();
for (Map.Entry<FieldKey, State> m : originalFields.entrySet()){
fields.put(m.getKey(), m.getValue());
}
ArrayList<Map.Entry<FieldKey, State>> array = new ArrayList<>(getFields().entrySet());
for(int i = 0; i < array.size(); i++){
if(!f.isFieldTraced(array.get(i).getKey())){
fields.remove(array.get(i).getKey());//new
}
else {
array.get(i).getValue().filterFields(f);
}
}
}
/**
* Returns a JSON object representing this {@code ObjectState}.
*/
public JSONArray toJSON(){
JSONArray state = new JSONArray();
List<FieldKey> sortedFields = new ArrayList<FieldKey>(fields.keySet());
Collections.sort(sortedFields);
for(int i = 0; i < sortedFields.size(); i++){
JSONObject field = new JSONObject();
field.put(NAME, sortedFields.get(i).getName());
field.put(VALUE, fields.get(sortedFields.get(i)));
state.put(field);
}
return state;
}
/**
* Generates a hash code for this {@code ObjectState}.
*/
public int hashCode() {
return 0; // TODO
}
/**
* Returns true if this {@code ObjectState} is equivalent to the
* specified {@code Object}, otherwise returns false.
*/
public boolean equals(Object obj) {
return obj instanceof ObjectState && ((ObjectState)obj).getFields().equals(getFields());
}
/**
* Returns a {@code String} representation of this {@code ObjectState}.
*/
public String toString() {
return toString(new IdentityHashMap<State, String>());
}
/**
* Returns a {@code String} representation of this {@code ObjectState}
* based on whether this {@code ObjectState} has already been seen or not.
*/
public String toString(Map<State, String> alreadySeenObjects) {
// check if this object has already been seen
if(alreadySeenObjects.containsKey(this)){
return alreadySeenObjects.get(this);
}else{
// otherwise add this object to already seen objects
alreadySeenObjects.put(this, "OBJ" + alreadySeenObjects.size());
}
StringBuilder result = new StringBuilder();
result.append('{');
// sort the fields
List<FieldKey> sortedFields = new ArrayList<FieldKey>(fields.keySet());
Collections.sort(sortedFields, new Comparator<FieldKey>() {
@Override
public int compare(FieldKey o1, FieldKey o2) {
return o1.getName().compareTo(o2.getName());
}
});
// add fields to the string builder
boolean first = true;
for(FieldKey fk : sortedFields) {
if(first) first = false;
else result.append(',');
State value = fields.get(fk);
result.append(fk.getName());
result.append('=');
result.append(value.toString(alreadySeenObjects));
}
result.append('}');
return result.toString();
}
} | davidstreader/JavaAutomata | src/main/tracer/state/ObjectState.java | Java | gpl-2.0 | 4,682 | [
30522,
7427,
2364,
1012,
7637,
2099,
1012,
2110,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
9140,
9863,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
6407,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
4012,
28689,
4263,
1025,
12324,
9262,
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... |
// PR c++/51430
// { dg-do compile }
template<int> struct A
{
static const int x[] = 0; // { dg-error "in-class initialization|initializer fails" }
};
A<0> a;
| selmentdev/selment-toolchain | source/gcc-latest/gcc/testsuite/g++.dg/template/static32.C | C++ | gpl-3.0 | 163 | [
30522,
1013,
1013,
10975,
1039,
1009,
1009,
1013,
4868,
23777,
2692,
1013,
1013,
1063,
1040,
2290,
1011,
2079,
4012,
22090,
1065,
23561,
1026,
20014,
1028,
2358,
6820,
6593,
1037,
1063,
10763,
9530,
3367,
20014,
1060,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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... |
# String_PadLeft
`String_PadLeft` returns a new string that right-aligns the characters in the `source` string by padding them on the left with a specified `paddingChar` Unicode character, for a specified total length.
```csharp
String_PadLeft (
@source NVARCHAR (MAX),
@totalWidth INT,
@paddingChar NVARCHAR (1)
)
RETURNS NVARCHAR (MAX)
```
## Parameters
- **source**: The source string.
- **totalWidth**: The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
- **paddingChar**: A Unicode padding character.
## Returns
- A new string that is equivalent to the `source` string, but right-aligned and padded on the left with as many paddingChar characters as needed to create a length of `totalWidth`.
- If `totalWidth` is less than the length of the `source` string, the method returns a reference to the existing instance.
- If `totalWidth` is equal to the length of the `source` string, the method returns a new string that is identical to the `source` string.
## Example
```csharp
SELECT SQLNET::String_PadLeft('This is a String.', 20, '.')
SELECT SQLNET::String_PadLeft('This is a String.', 10, '.')
```
# String_PadLeft4k
It is equivalent to `String_PadLeft` except no NVARCHAR(MAX) parameters; it can be used when input data will never be over 4000 characters as this function offers better performance.
```csharp
String_PadLeft4k (
@source NVARCHAR (4000),
@totalWidth INT,
@paddingChar NVARCHAR (1)
)
RETURNS NVARCHAR (4000)
```
## Example
```csharp
SELECT SQLNET::String_PadLeft4k('This is a String.', 20, '.')
SELECT SQLNET::String_PadLeft4k('This is a String.', 10, '.')
``` | zzzprojects/Z.Expressions.Eval.SqlServer | docs2/pages/documentations/string/string-padleft.md | Markdown | mit | 1,698 | [
30522,
1001,
5164,
1035,
11687,
2571,
6199,
1036,
5164,
1035,
11687,
2571,
6199,
1036,
5651,
1037,
2047,
5164,
2008,
2157,
1011,
25705,
2015,
1996,
3494,
1999,
1996,
1036,
3120,
1036,
5164,
2011,
11687,
4667,
2068,
2006,
1996,
2187,
2007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* Created by PhpStorm.
* User: udit
* Date: 12/9/14
* Time: 10:43 AM
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WM_Revision' ) ) {
/**
* Class WM_Revision
*
* Handles all the functionality to track custom fields
*
* @since 0.4
*/
class WM_Revision {
/**
* @since 0.4
*/
function __construct() {
/**
* This hook filters the number of revisions to keep for a specific post.
*/
add_filter( 'wp_revisions_to_keep', array( $this, 'filter_revisions_to_keep' ), 999, 2 );
/**
* This hooks gets fired once a revision is stored in WP_Post table in DB.
*
* This gives us $revision_id. So we can make use of that and store our stuff into post meta for that particular revision.
* E.g., Taxonomy diff, meta diff., featured image diff, etc.
*
*/
add_action( '_wp_put_post_revision', array( $this, 'post_revision_process' ), 10, 1 );
/**
* Filter whether the post has changed since the last revision.
*
* By default a revision is saved only if one of the revisioned fields has changed.
* This filter can override that so a revision is saved even if nothing has changed.
*
* We will take care of our own fields and pass on the flag.
*/
add_filter( 'wp_save_post_revision_post_has_changed', array( $this, 'check_for_changes' ), 10, 3 );
/**
* We may have to call this dynamically within a for loop. depending upon how many custom fields that we are supporting.
*/
foreach ( array_keys( $this->get_custom_revision_fields() ) as $field ) {
add_filter( '_wp_post_revision_field_'.$field, array( $this, 'revision_field_content' ), 10, 4 );
}
/**
* This adds custom diff ui for custom revision fields
*/
add_filter( 'wp_get_revision_ui_diff', array( $this, 'revision_ui_diff' ), 10, 3 );
}
/**
* @param $num
* @param $post
*
* @return int
* @since 0.1
*/
function filter_revisions_to_keep( $num, $post ) {
// Check individual Post Limit
$revision_limit = get_post_meta( $post->ID, WM_Admin::$wm_revision_limit_meta_key, true );
if ( '' !== $revision_limit ) {
if ( ! is_numeric( $revision_limit ) ) {
$num = - 1;
} else {
$num = intval( $revision_limit );
}
} else {
$post_type = get_post_type( $post );
$revision_limit = get_option( WM_Settings::$revision_limit_key . $post_type, false );
if ( '' === $revision_limit || ! is_numeric( $revision_limit ) ) {
$num = - 1;
} else {
$num = intval( $revision_limit );
}
}
return $num;
}
/**
* @return array $revision_fields
* @since 0.5
*/
function get_custom_revision_fields() {
$revision_fields = array(
'post_author' => array(
'label' => __( 'Post Author', WM_TEXT_DOMAIN ),
'meta_key' => '_wm_post_author',
'meta_value' => function( $post ) {
$author = new WP_User( $post->post_author );
return $author->display_name . ' (' . $post->post_author . ')';
},
),
'post_status' => array(
'label' => __( 'Post Status', WM_TEXT_DOMAIN ),
'meta_key' => '_wm_post_status',
'meta_value' => function( $post ) {
$post_status = get_post_status_object( $post->post_status );
return $post_status->label;
},
),
'post_date' => array(
'label' => __( 'Post Date', WM_TEXT_DOMAIN ),
'meta_key' => '_wm_post_date',
'meta_value' => function( $post ) {
$datef = 'M j, Y @ H:i';
return date_i18n( $datef, strtotime( $post->post_date ) );
},
),
);
return $revision_fields;
}
/**
* @param $revision_id
* @since 0.4
*/
function post_revision_process( $revision_id ) {
$revision = get_post( $revision_id );
$post = get_post( $revision->post_parent );
foreach ( $this->get_custom_revision_fields() as $field => $fieldmeta ) {
update_post_meta( $post->ID, $fieldmeta['meta_key'] . '_' . $revision_id , call_user_func( $fieldmeta['meta_value'], $post ) );
}
}
/**
* @param $post_has_changed
* @param $last_revision
* @param $post
*
* @return mixed
* @since 0.4
*/
function check_for_changes( $post_has_changed, $last_revision, $post ) {
foreach ( $this->get_custom_revision_fields() as $field => $fieldmeta ) {
$post_value = normalize_whitespace( call_user_func( $fieldmeta['meta_value'], $post ) );
$revision_value = normalize_whitespace( apply_filters( "_wp_post_revision_field_$field", $last_revision->$field, $field, $last_revision, 'from' ) );
if ( $post_value != $revision_value ) {
$post_has_changed = true;
break;
}
}
return $post_has_changed;
}
/**
* Contextually filter a post revision field.
*
* The dynamic portion of the hook name, $field, corresponds to each of the post
* fields of the revision object being iterated over in a foreach statement.
*
* @param string $value The current revision field to compare to or from.
* @param string $field The current revision field.
* @param WP_Post $post The revision post object to compare to or from.
* @param string $context The context of whether the current revision is the old or the new one. Values are 'to' or 'from'.
*
* @return string $value
* @since 0.4
*/
function revision_field_content( $value, $field, $post, $context ) {
$revision_fields = $this->get_custom_revision_fields();
if ( array_key_exists( $field, $revision_fields ) ) {
$value = get_post_meta( $post->post_parent, $revision_fields[ $field ]['meta_key'] . '_' . $post->ID, true );
}
return $value;
}
/**
* Filter the fields displayed in the post revision diff UI.
*
* @since 4.1.0
*
* @param array $return Revision UI fields. Each item is an array of id, name and diff.
* @param WP_Post $compare_from The revision post to compare from.
* @param WP_Post $compare_to The revision post to compare to.
*
* @return array $return
* @since 0.5
*/
function revision_ui_diff( $return, $compare_from, $compare_to ) {
foreach ( $this->get_custom_revision_fields() as $field => $fieldmeta ) {
/**
* Contextually filter a post revision field.
*
* The dynamic portion of the hook name, `$field`, corresponds to each of the post
* fields of the revision object being iterated over in a foreach statement.
*
* @since 3.6.0
*
* @param string $compare_from->$field The current revision field to compare to or from.
* @param string $field The current revision field.
* @param WP_Post $compare_from The revision post object to compare to or from.
* @param string null The context of whether the current revision is the old
* or the new one. Values are 'to' or 'from'.
*/
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
/** This filter is documented in wp-admin/includes/revision.php */
$content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
$args = array(
'show_split_view' => true,
);
/**
* Filter revisions text diff options.
*
* Filter the options passed to {@see wp_text_diff()} when viewing a post revision.
*
* @since 4.1.0
*
* @param array $args {
* Associative array of options to pass to {@see wp_text_diff()}.
*
* @type bool $show_split_view True for split view (two columns), false for
* un-split view (single column). Default true.
* }
* @param string $field The current revision field.
* @param WP_Post $compare_from The revision post to compare from.
* @param WP_Post $compare_to The revision post to compare to.
*/
$args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to );
$diff = wp_text_diff( $content_from, $content_to, $args );
if ( $diff ) {
$return[] = array(
'id' => $field,
'name' => $fieldmeta['label'],
'diff' => $diff,
);
}
}
return $return;
}
}
}
| desaiuditd/watchman | revision/class-wm-revision.php | PHP | gpl-2.0 | 8,344 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2580,
2011,
25718,
19718,
1012,
1008,
5310,
1024,
20904,
4183,
1008,
3058,
1024,
2260,
1013,
1023,
1013,
2403,
1008,
2051,
1024,
2184,
1024,
4724,
2572,
1008,
1013,
1013,
1013,
6164,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# frozen_string_literal: true
require 'cucumber/core/test/timer'
module Cucumber
module Core
module Test
class Runner
attr_reader :event_bus, :running_test_case, :running_test_step
private :event_bus, :running_test_case, :running_test_step
def initialize(event_bus)
@event_bus = event_bus
end
def test_case(test_case, &descend)
@running_test_case = RunningTestCase.new
@running_test_step = nil
event_bus.test_case_starting(test_case)
descend.call(self)
event_bus.test_case_finished(test_case, running_test_case.result)
self
end
def test_step(test_step)
@running_test_step = test_step
event_bus.test_step_starting test_step
step_result = running_test_case.execute(test_step)
event_bus.test_step_finished test_step, step_result
@running_test_step = nil
self
end
def around_hook(hook, &continue)
result = running_test_case.execute(hook, &continue)
event_bus.test_step_finished running_test_step, result if running_test_step
@running_test_step = nil
self
end
def done
self
end
class RunningTestCase
def initialize
@timer = Timer.new.start
@status = Status::Unknown.new(Result::Unknown.new)
end
def execute(test_step, &continue)
status.execute(test_step, self, &continue)
end
def result
status.result(@timer.duration)
end
def failed(step_result)
@status = Status::Failing.new(step_result)
self
end
def passed(step_result)
@status = Status::Passing.new(step_result)
self
end
def pending(message, step_result)
@status = Status::Pending.new(step_result)
self
end
def skipped(step_result)
@status = Status::Skipping.new(step_result)
self
end
def undefined(step_result)
failed(step_result)
self
end
def exception(step_exception, step_result)
self
end
def duration(step_duration, step_result)
self
end
attr_reader :status
private :status
module Status
class Base
attr_reader :step_result
private :step_result
def initialize(step_result)
@step_result = step_result
end
def execute(test_step, monitor, &continue)
result = test_step.execute(monitor.result, &continue)
result = result.with_message(%(Undefined step: "#{test_step.name}")) if result.undefined?
result = result.with_appended_backtrace(test_step.source.last) if IsStepVisitor.new(test_step).step?
result.describe_to(monitor, result)
end
def result
raise NoMethodError, "Override me"
end
end
class Unknown < Base
def result(duration)
Result::Unknown.new
end
end
class Passing < Base
def result(duration)
Result::Passed.new(duration)
end
end
class Failing < Base
def execute(test_step, monitor, &continue)
test_step.skip(monitor.result)
end
def result(duration)
step_result.with_duration(duration)
end
end
Pending = Class.new(Failing)
class Skipping < Failing
def result(duration)
step_result.with_duration(duration)
end
end
end
end
end
end
end
end
| kamenlitchev/cucumber-ruby-core | lib/cucumber/core/test/runner.rb | Ruby | mit | 4,031 | [
30522,
1001,
7708,
1035,
5164,
1035,
18204,
1024,
2995,
5478,
1005,
12731,
24894,
5677,
1013,
4563,
1013,
3231,
1013,
25309,
1005,
11336,
12731,
24894,
5677,
11336,
4563,
11336,
3231,
2465,
5479,
2012,
16344,
1035,
8068,
1024,
2724,
1035,
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... |
<?php
/**
* Tests for Super_Awesome_Theme_Setting
*
* @package Super_Awesome_Theme
* @license GPL-2.0-or-later
* @link https://super-awesome-author.org/themes/super-awesome-theme/
*/
/**
* Tests for the Super_Awesome_Theme_Setting class.
*
* @group settings
*/
class Tests_Setting extends Super_Awesome_Theme_UnitTestCase {
/**
* Setting instance used for testing.
*
* @var Super_Awesome_Theme_Setting|null
*/
private $setting = null;
/**
* Sets up the setting instance to use for testing.
*/
public function setUp() {
$this->setting = new Super_Awesome_Theme_Setting(
'my_setting',
array(
Super_Awesome_Theme_Setting::PROP_DEFAULT => 3,
Super_Awesome_Theme_Setting::PROP_SANITIZE_CALLBACK => 'absint',
Super_Awesome_Theme_Setting::PROP_PARSE_CALLBACK => 'absint',
)
);
}
/**
* Tests retrieving a setting property.
*
* @covers Super_Awesome_Theme_Setting::get_prop
* @dataProvider data_get_prop
*
* @param string $prop Setting property.
* @param mixed $value Setting property value.
*/
public function test_get_prop( $prop, $value ) {
$this->assertSame( $value, $this->setting->get_prop( $prop ) );
}
/**
* Data provider for test_get_prop().
*
* @return array Data to pass to the test method.
*/
public function data_get_prop() {
$props = $this->get_expected_props();
$data = array();
foreach ( $props as $prop => $value ) {
$data[] = array( $prop, $value );
}
return $data;
}
/**
* Tests retrieving all setting properties.
*
* @covers Super_Awesome_Theme_Setting::get_props
* @covers Super_Awesome_Theme_Setting::__construct
* @covers Super_Awesome_Theme_Setting::get_defaults
*/
public function test_get_props() {
$this->assertSameSets( $this->get_expected_props(), $this->setting->get_props() );
}
/**
* Tests retrieving the current value for the setting when a value is set.
*
* @covers Super_Awesome_Theme_Setting::get_value
*/
public function test_get_value_with_value_set() {
set_theme_mod( 'my_setting', '5' );
$result = $this->setting->get_value();
remove_theme_mod( 'my_setting' );
$this->assertSame( 5, $result );
}
/**
* Tests retrieving the current value for the setting when no value is set.
*
* @covers Super_Awesome_Theme_Setting::get_value
*/
public function test_get_value_without_value_set() {
$this->assertSame( 3, $this->setting->get_value() );
}
/**
* Tests validating a setting value without any validation callback.
*
* @covers Super_Awesome_Theme_Setting::validate_value
* @covers Super_Awesome_Theme_Setting::default_validation_callback
*/
public function test_validate_value_without_callback() {
$this->assertTrue( $this->setting->validate_value( new WP_Error(), 'hello' ) );
}
/**
* Tests validating a valid setting value with a validation callback.
*
* @covers Super_Awesome_Theme_Setting::validate_value
*/
public function test_validate_value_with_callback_and_valid_value() {
$setting = new Super_Awesome_Theme_Setting(
'my_setting',
array(
Super_Awesome_Theme_Setting::PROP_VALIDATE_CALLBACK => array( $this, 'validation_callback_wp_error' ),
)
);
$this->assertTrue( $setting->validate_value( new WP_Error(), 41 ) );
}
/**
* Tests validating an invalid setting value with a validation callback using WP_Error.
*
* @covers Super_Awesome_Theme_Setting::validate_value
*/
public function test_validate_value_with_callback_and_invalid_value_and_wp_error() {
$setting = new Super_Awesome_Theme_Setting(
'my_setting',
array(
Super_Awesome_Theme_Setting::PROP_VALIDATE_CALLBACK => array( $this, 'validation_callback_wp_error' ),
)
);
$result = $setting->validate_value( new WP_Error(), 42 );
$this->assertWPError( $result );
$this->assertSame( 'no_42_allowed', $result->get_error_code() );
}
/**
* Tests validating an invalid setting value with a validation callback using a boolean.
*
* @covers Super_Awesome_Theme_Setting::validate_value
*/
public function test_validate_value_with_callback_and_invalid_value_and_bool() {
$setting = new Super_Awesome_Theme_Setting(
'my_setting',
array(
Super_Awesome_Theme_Setting::PROP_VALIDATE_CALLBACK => array( $this, 'validation_callback_bool' ),
)
);
$result = $setting->validate_value( new WP_Error(), 42 );
$this->assertWPError( $result );
$this->assertSame( 'invalid_value', $result->get_error_code() );
}
/**
* Tests sanitizing a setting value.
*
* @covers Super_Awesome_Theme_Setting::sanitize_value
* @covers Super_Awesome_Theme_Setting::default_sanitization_callback
*/
public function test_sanitize_value() {
$this->assertSame( 4, $this->setting->sanitize_value( '4' ) );
}
/**
* Tests parsing a setting value.
*
* @covers Super_Awesome_Theme_Setting::parse_value
* @covers Super_Awesome_Theme_Setting::default_parsing_callback
*/
public function test_parse_value() {
$this->assertSame( 4, $this->setting->parse_value( '4' ) );
}
/**
* Validation callback preventing a value from being 42, using WP_Error.
*
* @param WP_Error $validity Error object to add validation errors to.
* @param mixed $value Value to validate.
* @return bool|WP_Error True on success, error object on failure.
*/
public function validation_callback_wp_error( $validity, $value ) {
$value = (int) $value;
if ( 42 === $value ) {
$validity->add( 'no_42_allowed', 'The value must not be equal to 42.' );
}
return $validity;
}
/**
* Validation callback preventing a value from being 42, using a boolean.
*
* @param WP_Error $validity Error object to add validation errors to.
* @param mixed $value Value to validate.
* @return bool True on success, false on failure.
*/
public function validation_callback_bool( $validity, $value ) {
$value = (int) $value;
if ( 42 === $value ) {
return false;
}
return true;
}
/**
* Gets the expected props and values for the setting instance used for testing.
*
* @return array Array of $prop => $value pairs.
*/
private function get_expected_props() {
return array(
Super_Awesome_Theme_Setting::PROP_ID => 'my_setting',
Super_Awesome_Theme_Setting::PROP_CAPABILITY => 'edit_theme_options',
Super_Awesome_Theme_Setting::PROP_DEFAULT => 3,
Super_Awesome_Theme_Setting::PROP_VALIDATE_CALLBACK => null,
Super_Awesome_Theme_Setting::PROP_SANITIZE_CALLBACK => 'absint',
Super_Awesome_Theme_Setting::PROP_PARSE_CALLBACK => 'absint',
);
}
}
| taco-themes/boilerplate | tests/phpunit/tests/settings/test-setting.php | PHP | gpl-3.0 | 6,582 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
5852,
2005,
3565,
1035,
12476,
1035,
4323,
1035,
4292,
1008,
1008,
1030,
7427,
3565,
1035,
12476,
1035,
4323,
1008,
1030,
6105,
14246,
2140,
1011,
1016,
1012,
1014,
1011,
2030,
1011,
2101,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 de.superioz.moo.api.logging;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
/**
* This is just a simple formatter for a logger
*/
public class ConciseFormatter extends Formatter {
private final DateFormat date = new SimpleDateFormat("HH:mm:ss.sss");
private boolean stripColors = false;
public ConciseFormatter(boolean stripColors) {
this.stripColors = stripColors;
}
@Override
@SuppressWarnings("ThrowableResultIgnored")
public String format(LogRecord record) {
StringBuilder formatted = new StringBuilder();
formatted.append("[");
formatted.append(date.format(record.getMillis()));
formatted.append(" ");
formatted.append(record.getLevel().getName());
formatted.append("] ");
formatted.append(stripColors ? ConsoleColor.stripColors(formatMessage(record)) : formatMessage(record));
formatted.append('\n');
if(record.getThrown() != null) {
StringWriter writer = new StringWriter();
record.getThrown().printStackTrace(new PrintWriter(writer));
formatted.append(writer);
}
return formatted.toString();
}
}
| Superioz/MooProject | api/src/main/java/de/superioz/moo/api/logging/ConciseFormatter.java | Java | gpl-2.0 | 1,332 | [
30522,
7427,
2139,
1012,
3565,
3695,
2480,
1012,
9587,
2080,
1012,
17928,
1012,
15899,
1025,
12324,
9262,
1012,
22834,
1012,
6140,
15994,
1025,
12324,
9262,
1012,
22834,
1012,
5164,
15994,
1025,
12324,
9262,
1012,
3793,
1012,
3058,
14192,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#pragma once
// CMake uses config.cmake.h to generate config.h within the build folder.
#ifndef ALLPIX_CONFIG_H
#define ALLPIX_CONFIG_H
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
#define PACKAGE_VERSION "@ALLPIX_LIB_VERSION@"
#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
#endif
| Koensw/allpix-squared | cmake/config.cmake.h | C | mit | 293 | [
30522,
1001,
10975,
8490,
2863,
2320,
1013,
1013,
4642,
13808,
3594,
9530,
8873,
2290,
1012,
4642,
13808,
1012,
1044,
2000,
9699,
9530,
8873,
2290,
1012,
1044,
2306,
1996,
3857,
19622,
1012,
1001,
2065,
13629,
2546,
2035,
8197,
2595,
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... |
<?php
/* @var $this MessageController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs=array(
'Messages',
);
$this->menu=array(
array('label'=>'Create Message', 'url'=>array('create')),
array('label'=>'Manage Message', 'url'=>array('admin')),
);
?>
<h1>Messages</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
| OscarMesa/Multimedia | protected/views/message/index.php | PHP | apache-2.0 | 425 | [
30522,
1026,
1029,
25718,
1013,
1008,
1030,
13075,
1002,
2023,
4471,
8663,
13181,
10820,
1008,
1013,
1013,
1008,
1030,
13075,
1002,
2951,
21572,
17258,
2121,
6187,
15277,
2850,
2696,
21572,
17258,
2121,
1008,
1013,
1002,
2023,
1011,
1028,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 System.Linq;
using System.Text;
using System.Threading.Tasks;
using YamlDotNet.Serialization;
namespace Knet.Model
{
public class CContext
{
[YamlMember(Alias = "context")]
public CContextDetails ContextDetails { get; set; }
[YamlMember(Alias = "name")]
public string Name { get; set; }
}
}
| tonnyeremin/knet | Knet/Knet.Model/Configuration/Context.cs | C# | mit | 394 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
8038,
19968,
27364,
7159,
1012,
7642,
3989,
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... |
require "using"
require "facets/kernel/returning"
module Hopcroft
extend Using
Using.default_load_scheme = :autoload
using :Regex
using :Machine
using :Converters
end
| smtlaissezfaire/hopcroft | lib/hopcroft.rb | Ruby | gpl-3.0 | 180 | [
30522,
5478,
1000,
2478,
1000,
5478,
1000,
2227,
3215,
1013,
16293,
1013,
4192,
1000,
11336,
6154,
14716,
7949,
2478,
2478,
1012,
12398,
1035,
7170,
1035,
5679,
1027,
1024,
8285,
11066,
2478,
1024,
19723,
10288,
2478,
1024,
3698,
2478,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Oro\Bundle\NotificationBundle\Tests\Unit\Event;
use Oro\Bundle\NotificationBundle\Event\NotificationEvent;
class NotificationEventTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \stdClass
*/
protected $entity;
/**
* @var NotificationEvent
*/
protected $event;
protected function setUp()
{
$this->entity = new \stdClass();
$this->event = new NotificationEvent($this->entity);
}
public function testGetEntity()
{
$this->assertEquals($this->entity, $this->event->getEntity());
$this->event->setEntity(null);
$this->assertNull($this->event->getEntity());
}
}
| orocrm/platform | src/Oro/Bundle/NotificationBundle/Tests/Unit/Event/NotificationEventTest.php | PHP | mit | 683 | [
30522,
1026,
1029,
25718,
3415,
15327,
20298,
1032,
14012,
1032,
26828,
27265,
2571,
1032,
5852,
1032,
3131,
1032,
2724,
1025,
2224,
20298,
1032,
14012,
1032,
26828,
27265,
2571,
1032,
2724,
1032,
26828,
18697,
3372,
1025,
2465,
26828,
18697,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 os
from kivy.lang import Builder
from kivy.properties import NumericProperty, StringProperty
from kivy.uix.anchorlayout import AnchorLayout
from cobiv.modules.core.hud import Hud
Builder.load_file(os.path.abspath(os.path.join(os.path.dirname(__file__), 'progresshud.kv')))
class ProgressHud(Hud, AnchorLayout):
value = NumericProperty(0)
caption = StringProperty("")
def __init__(self, **kwargs):
super(ProgressHud, self).__init__(**kwargs)
| gokudomatic/cobiv | cobiv/modules/hud_components/progresshud/progresshud.py | Python | mit | 473 | [
30522,
12324,
9808,
2013,
11382,
10736,
1012,
11374,
12324,
12508,
2013,
11382,
10736,
1012,
5144,
12324,
16371,
25531,
21572,
4842,
3723,
1010,
5164,
21572,
4842,
3723,
2013,
11382,
10736,
1012,
21318,
2595,
1012,
8133,
8485,
5833,
12324,
81... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
'use strict';
var _ = require('./underscore-mixins.js');
var fnToNode = new Map();
exports.load = function (nodes, prefix) {
let uuid = require('uuid');
if (prefix != null && prefix.length > 0) {
prefix = prefix + ':';
} else {
prefix = '';
}
_(nodes).forEach(function (fn, name) {
if (_.isFunction(fn)) {
fnToNode.set(fn, {
name: prefix + name,
id: uuid.v4(),
fn: fn,
ingoingLinks: new Map(),
outgoingLinks: new Map(),
counter: 0
});
} else {
exports.load(fn, name);
}
});
};
exports.clone = function (fn, name) {
var node = fnToNode.get(fn);
var newNodeLoader = {};
newNodeLoader[name] = node.fn.bind({});
exports.load(newNodeLoader);
return newNodeLoader[name];
};
exports.debug = function () {
fnToNode.forEach(function (node) {
console.log(
_(Array.from(node.ingoingLinks.keys())).pluck('name'),
node.name,
_(Array.from(node.outgoingLinks.keys())).pluck('name')
);
});
};
var defaultLinkOptions = {
primary: true
};
exports.link = function (fn) {
var node = fnToNode.get(fn);
return {
to: function (toFn, options) {
options = _(options || {}).defaults(defaultLinkOptions);
var toNode = fnToNode.get(toFn);
toNode.ingoingLinks.set(node, options);
node.outgoingLinks.set(toNode, options);
}
};
};
exports.unlink = function (fn) {
var node = fnToNode.get(fn);
return {
from: function (fromFn) {
var fromNode = fnToNode.get(fromFn);
fromNode.ingoingLinks.delete(node);
node.outgoingLinks.delete(fromNode);
}
};
};
exports.remove = function (fn) {
var node = fnToNode.get(fn),
todo = [];
node.ingoingLinks.forEach(function (inOptions, inNode) {
todo.push(function () {
exports.unlink(inNode.fn).from(fn);
});
node.outgoingLinks.forEach(function (outOptions, outNode) {
todo.push(function () {
exports.unlink(fn).from(outNode.fn);
exports.link(inNode.fn).to(outNode.fn, outOptions);
});
});
});
_(todo).invoke('call');
};
exports.replace = function (fn) {
var node = fnToNode.get(fn),
todo = [];
return {
by: function (byFn) {
node.ingoingLinks.forEach(function (inOptions, inNode) {
todo.push(function () {
exports.unlink(inNode.fn).from(node.fn);
exports.link(inNode.fn).to(byFn, inOptions);
});
});
node.outgoingLinks.forEach(function (outOptions, outNode) {
todo.push(function () {
exports.unlink(node.fn).from(outNode.fn);
exports.link(byFn).to(outNode.fn, outOptions);
});
});
_(todo).invoke('call');
}
}
};
exports.before = function (fn) {
var node = fnToNode.get(fn),
todo = [];
return {
insert: function (beforeFn) {
node.ingoingLinks.forEach(function (inOptions, inNode) {
todo.push(function () {
exports.unlink(inNode.fn).from(node.fn);
exports.link(inNode.fn).to(beforeFn, inOptions);
});
});
todo.push(function () {
exports.link(beforeFn).to(node.fn);
});
_(todo).invoke('call');
}
};
};
exports.after = function (fn) {
var node = fnToNode.get(fn),
todo = [];
return {
insert: function (afterFn) {
node.outgoingLinks.forEach(function (outOptions, outNode) {
todo.push(function () {
exports.unlink(node.fn).from(outNode.fn);
exports.link(afterFn).to(outNode.fn, outOptions);
});
});
todo.push(function () {
exports.link(node.fn).to(afterFn);
});
_(todo).invoke('call');
}
};
};
var runEntryNode;
function linksToStream(links) {
let plumber = require('gulp-plumber');
return _(links).chain()
.pluck('fn')
.map(exports.run)
.compact()
.concatVinylStreams()
.value()
.pipe(plumber());
}
exports.run = function (fn) {
var result,
node = fnToNode.get(fn);
runEntryNode = runEntryNode || node;
if (node.lastResult != null) {
return node.lastResult;
}
var primaryStreams = [],
secondaryStreams = [];
node.ingoingLinks.forEach(function (options, node) {
if (options.primary) {
primaryStreams.push(node);
} else {
secondaryStreams.push(node);
}
});
var primaryStream = linksToStream(primaryStreams),
secondaryStream = linksToStream(secondaryStreams);
result = fn(primaryStream, secondaryStream);
if (runEntryNode === node) {
fnToNode.forEach(function (node) {
delete node.lastResult;
});
}
else {
node.lastResult = result;
}
return result;
};
function isNotAlone(node) {
return (node.ingoingLinks.size + node.outgoingLinks.size) > 0;
}
function isSource(node) {
return node.ingoingLinks.size === 0;
}
function isOutput(node) {
return node.outgoingLinks.size === 0;
}
exports.renderGraph = function (renderer, filepath, callback) {
let graphdot = require('./graphdot.js');
var graph = graphdot.digraph('one_gulp_streams_graph');
graph.set('label', 'one-gulp streams graph\n\n');
graph.set('fontname', 'sans-serif');
graph.set('fontsize', '20');
graph.set('labelloc', 't');
graph.set('pad', '0.5,0.5');
graph.set('nodesep', '0.3');
graph.set('splines', 'spline');
graph.set('ranksep', '1');
graph.set('rankdir', 'LR');
var promises = [];
fnToNode.forEach(function (node) {
var nodeOptions = {
label: node.name,
shape: 'rectangle',
fontname: 'sans-serif',
style: 'bold',
margin: '0.2,0.1'
};
if (isSource(node)) {
nodeOptions.shape = 'ellipse';
nodeOptions.color = 'lavender';
nodeOptions.fontcolor = 'lavender';
nodeOptions.margin = '0.1,0.1';
}
if (isOutput(node)) {
nodeOptions.color = 'limegreen';
nodeOptions.fontcolor = 'white';
nodeOptions.style = 'filled';
nodeOptions.margin = '0.25,0.25';
}
if (isNotAlone(node)) {
node.graphNode = graph.addNode(node.id, nodeOptions);
if (isSource(node)) {
var donePromise = new Promise(function (resolve, reject) {
node.fn()
.on('data', function () {
node.counter += 1;
node.graphNode.set('color', 'mediumslateblue');
node.graphNode.set('fontcolor', 'mediumslateblue');
node.graphNode.set('label', node.name + ' (' + node.counter + ')');
})
.on('error', reject)
.on('end', resolve);
});
promises.push(donePromise);
}
}
});
Promise.all(promises).then(function () {
fnToNode.forEach(function (node) {
node.ingoingLinks.forEach(function (options, linkedNode) {
var edgeOptions = {};
if (options.primary) {
edgeOptions.penwidth = '1.5';
} else {
edgeOptions.arrowhead = 'empty';
edgeOptions.style = 'dashed';
}
if (isSource(linkedNode)) {
edgeOptions.color = linkedNode.graphNode.get('color');
}
graph.addEdge(linkedNode.graphNode, node.graphNode, edgeOptions);
});
});
graphdot.renderToSvgFile(graph, renderer, filepath, callback);
});
}; | Alex-D/one-gulp | lib/dag.js | JavaScript | mit | 8,407 | [
30522,
1005,
2224,
9384,
1005,
1025,
13075,
1035,
1027,
5478,
1006,
1005,
1012,
1013,
2104,
9363,
2890,
1011,
4666,
7076,
1012,
1046,
2015,
1005,
1007,
1025,
13075,
1042,
15104,
10244,
1027,
2047,
4949,
1006,
1007,
1025,
14338,
1012,
7170,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// State.h: Defines the State class, encapsulating raw GL state
#ifndef LIBGLESV2_STATE_H_
#define LIBGLESV2_STATE_H_
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/angletypes.h"
#include "libGLESv2/VertexAttribute.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/TransformFeedback.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/Sampler.h"
namespace gl
{
class Query;
class VertexArray;
class Context;
struct Caps;
class State
{
public:
State();
~State();
void initialize(const Caps& caps, GLuint clientVersion);
void reset();
// State chunk getters
const RasterizerState &getRasterizerState() const;
const BlendState &getBlendState() const;
const DepthStencilState &getDepthStencilState() const;
// Clear behavior setters & state parameter block generation function
void setClearColor(float red, float green, float blue, float alpha);
void setClearDepth(float depth);
void setClearStencil(int stencil);
ClearParameters getClearParameters(GLbitfield mask) const;
// Write mask manipulation
void setColorMask(bool red, bool green, bool blue, bool alpha);
void setDepthMask(bool mask);
// Discard toggle & query
bool isRasterizerDiscardEnabled() const;
void setRasterizerDiscard(bool enabled);
// Face culling state manipulation
bool isCullFaceEnabled() const;
void setCullFace(bool enabled);
void setCullMode(GLenum mode);
void setFrontFace(GLenum front);
// Depth test state manipulation
bool isDepthTestEnabled() const;
void setDepthTest(bool enabled);
void setDepthFunc(GLenum depthFunc);
void setDepthRange(float zNear, float zFar);
void getDepthRange(float *zNear, float *zFar) const;
// Blend state manipulation
bool isBlendEnabled() const;
void setBlend(bool enabled);
void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);
void setBlendColor(float red, float green, float blue, float alpha);
void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);
const ColorF &getBlendColor() const;
// Stencil state maniupulation
bool isStencilTestEnabled() const;
void setStencilTest(bool enabled);
void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);
void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);
void setStencilWritemask(GLuint stencilWritemask);
void setStencilBackWritemask(GLuint stencilBackWritemask);
void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
GLint getStencilRef() const;
GLint getStencilBackRef() const;
// Depth bias/polygon offset state manipulation
bool isPolygonOffsetFillEnabled() const;
void setPolygonOffsetFill(bool enabled);
void setPolygonOffsetParams(GLfloat factor, GLfloat units);
// Multisample coverage state manipulation
bool isSampleAlphaToCoverageEnabled() const;
void setSampleAlphaToCoverage(bool enabled);
bool isSampleCoverageEnabled() const;
void setSampleCoverage(bool enabled);
void setSampleCoverageParams(GLclampf value, bool invert);
void getSampleCoverageParams(GLclampf *value, bool *invert);
// Scissor test state toggle & query
bool isScissorTestEnabled() const;
void setScissorTest(bool enabled);
void setScissorParams(GLint x, GLint y, GLsizei width, GLsizei height);
const Rectangle &getScissor() const;
// Dither state toggle & query
bool isDitherEnabled() const;
void setDither(bool enabled);
// Generic state toggle & query
void setEnableFeature(GLenum feature, bool enabled);
bool getEnableFeature(GLenum feature);
// Line width state setter
void setLineWidth(GLfloat width);
// Hint setters
void setGenerateMipmapHint(GLenum hint);
void setFragmentShaderDerivativeHint(GLenum hint);
// Viewport state setter/getter
void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
const Rectangle &getViewport() const;
// Texture binding & active texture unit manipulation
void setActiveSampler(unsigned int active);
unsigned int getActiveSampler() const;
void setSamplerTexture(GLenum type, Texture *texture);
Texture *getSamplerTexture(unsigned int sampler, GLenum type) const;
GLuint getSamplerTextureId(unsigned int sampler, GLenum type) const;
void detachTexture(GLuint texture);
// Sampler object binding manipulation
void setSamplerBinding(GLuint textureUnit, Sampler *sampler);
GLuint getSamplerId(GLuint textureUnit) const;
Sampler *getSampler(GLuint textureUnit) const;
void detachSampler(GLuint sampler);
// Renderbuffer binding manipulation
void setRenderbufferBinding(Renderbuffer *renderbuffer);
GLuint getRenderbufferId() const;
Renderbuffer *getCurrentRenderbuffer();
void detachRenderbuffer(GLuint renderbuffer);
// Framebuffer binding manipulation
void setReadFramebufferBinding(Framebuffer *framebuffer);
void setDrawFramebufferBinding(Framebuffer *framebuffer);
Framebuffer *getTargetFramebuffer(GLenum target) const;
Framebuffer *getReadFramebuffer();
Framebuffer *getDrawFramebuffer();
const Framebuffer *getReadFramebuffer() const;
const Framebuffer *getDrawFramebuffer() const;
bool removeReadFramebufferBinding(GLuint framebuffer);
bool removeDrawFramebufferBinding(GLuint framebuffer);
// Vertex array object binding manipulation
void setVertexArrayBinding(VertexArray *vertexArray);
GLuint getVertexArrayId() const;
VertexArray *getVertexArray() const;
bool removeVertexArrayBinding(GLuint vertexArray);
// Program binding manipulation
void setCurrentProgram(GLuint programId, Program *newProgram);
void setCurrentProgramBinary(ProgramBinary *binary);
GLuint getCurrentProgramId() const;
ProgramBinary *getCurrentProgramBinary() const;
// Transform feedback object (not buffer) binding manipulation
void setTransformFeedbackBinding(TransformFeedback *transformFeedback);
TransformFeedback *getCurrentTransformFeedback() const;
void detachTransformFeedback(GLuint transformFeedback);
// Query binding manipulation
bool isQueryActive() const;
void setActiveQuery(GLenum target, Query *query);
GLuint getActiveQueryId(GLenum target) const;
Query *getActiveQuery(GLenum target) const;
//// Typed buffer binding point manipulation ////
// GL_ARRAY_BUFFER
void setArrayBufferBinding(Buffer *buffer);
GLuint getArrayBufferId() const;
bool removeArrayBufferBinding(GLuint buffer);
// GL_UNIFORM_BUFFER - Both indexed and generic targets
void setGenericUniformBufferBinding(Buffer *buffer);
void setIndexedUniformBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size);
GLuint getIndexedUniformBufferId(GLuint index) const;
Buffer *getIndexedUniformBuffer(GLuint index) const;
// GL_TRANSFORM_FEEDBACK_BUFFER - Both indexed and generic targets
void setGenericTransformFeedbackBufferBinding(Buffer *buffer);
void setIndexedTransformFeedbackBufferBinding(GLuint index, Buffer *buffer, GLintptr offset, GLsizeiptr size);
GLuint getIndexedTransformFeedbackBufferId(GLuint index) const;
Buffer *getIndexedTransformFeedbackBuffer(GLuint index) const;
GLuint getIndexedTransformFeedbackBufferOffset(GLuint index) const;
size_t getTransformFeedbackBufferIndexRange() const;
// GL_COPY_[READ/WRITE]_BUFFER
void setCopyReadBufferBinding(Buffer *buffer);
void setCopyWriteBufferBinding(Buffer *buffer);
// GL_PIXEL[PACK/UNPACK]_BUFFER
void setPixelPackBufferBinding(Buffer *buffer);
void setPixelUnpackBufferBinding(Buffer *buffer);
// Retrieve typed buffer by target (non-indexed)
Buffer *getTargetBuffer(GLenum target) const;
// Vertex attrib manipulation
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
void setVertexAttribf(GLuint index, const GLfloat values[4]);
void setVertexAttribu(GLuint index, const GLuint values[4]);
void setVertexAttribi(GLuint index, const GLint values[4]);
void setVertexAttribState(unsigned int attribNum, Buffer *boundBuffer, GLint size, GLenum type,
bool normalized, bool pureInteger, GLsizei stride, const void *pointer);
const VertexAttribute &getVertexAttribState(unsigned int attribNum) const;
const VertexAttribCurrentValueData &getVertexAttribCurrentValue(unsigned int attribNum) const;
const void *getVertexAttribPointer(unsigned int attribNum) const;
// Pixel pack state manipulation
void setPackAlignment(GLint alignment);
GLint getPackAlignment() const;
void setPackReverseRowOrder(bool reverseRowOrder);
bool getPackReverseRowOrder() const;
const PixelPackState &getPackState() const;
// Pixel unpack state manipulation
void setUnpackAlignment(GLint alignment);
GLint getUnpackAlignment() const;
const PixelUnpackState &getUnpackState() const;
// State query functions
void getBooleanv(GLenum pname, GLboolean *params);
void getFloatv(GLenum pname, GLfloat *params);
void getIntegerv(GLenum pname, GLint *params);
bool getIndexedIntegerv(GLenum target, GLuint index, GLint *data);
bool getIndexedInteger64v(GLenum target, GLuint index, GLint64 *data);
bool hasMappedBuffer(GLenum target) const;
private:
DISALLOW_COPY_AND_ASSIGN(State);
// Cached values from Context's caps
GLuint mMaxDrawBuffers;
GLuint mMaxCombinedTextureImageUnits;
ColorF mColorClearValue;
GLclampf mDepthClearValue;
int mStencilClearValue;
RasterizerState mRasterizer;
bool mScissorTest;
Rectangle mScissor;
BlendState mBlend;
ColorF mBlendColor;
bool mSampleCoverage;
GLclampf mSampleCoverageValue;
bool mSampleCoverageInvert;
DepthStencilState mDepthStencil;
GLint mStencilRef;
GLint mStencilBackRef;
GLfloat mLineWidth;
GLenum mGenerateMipmapHint;
GLenum mFragmentShaderDerivativeHint;
Rectangle mViewport;
float mNearZ;
float mFarZ;
BindingPointer<Buffer> mArrayBuffer;
Framebuffer *mReadFramebuffer;
Framebuffer *mDrawFramebuffer;
BindingPointer<Renderbuffer> mRenderbuffer;
GLuint mCurrentProgramId;
BindingPointer<ProgramBinary> mCurrentProgramBinary;
typedef std::vector<VertexAttribCurrentValueData> VertexAttribVector;
VertexAttribVector mVertexAttribCurrentValues; // From glVertexAttrib
VertexArray *mVertexArray;
// Texture and sampler bindings
size_t mActiveSampler; // Active texture unit selector - GL_TEXTURE0
typedef std::vector< BindingPointer<Texture> > TextureBindingVector;
typedef std::map<GLenum, TextureBindingVector> TextureBindingMap;
TextureBindingMap mSamplerTextures;
typedef std::vector< BindingPointer<Sampler> > SamplerBindingVector;
SamplerBindingVector mSamplers;
typedef std::map< GLenum, BindingPointer<Query> > ActiveQueryMap;
ActiveQueryMap mActiveQueries;
BindingPointer<Buffer> mGenericUniformBuffer;
typedef std::vector< OffsetBindingPointer<Buffer> > BufferVector;
BufferVector mUniformBuffers;
BindingPointer<TransformFeedback> mTransformFeedback;
BindingPointer<Buffer> mGenericTransformFeedbackBuffer;
BufferVector mTransformFeedbackBuffers;
BindingPointer<Buffer> mCopyReadBuffer;
BindingPointer<Buffer> mCopyWriteBuffer;
PixelUnpackState mUnpack;
PixelPackState mPack;
};
}
#endif // LIBGLESV2_STATE_H_
| nandhanurrevanth/angle | src/libGLESv2/State.h | C | bsd-3-clause | 12,055 | [
30522,
1013,
1013,
1013,
1013,
9385,
1006,
1039,
1007,
2297,
1996,
6466,
2622,
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,
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... |
#!/bin/sh
#
# Copyright (c) 2012 Felipe Contreras
#
test_description='Test remote-bzr'
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
. "$TEST_DIRECTORY"/test-lib.sh
if ! test_have_prereq PYTHON
then
skip_all='skipping remote-bzr tests; python not available'
test_done
fi
if ! python -c 'import bzrlib'
then
skip_all='skipping remote-bzr tests; bzr not available'
test_done
fi
check () {
echo $3 >expected &&
git --git-dir=$1/.git log --format='%s' -1 $2 >actual
test_cmp expected actual
}
bzr whoami "A U Thor <author@example.com>"
test_expect_success 'cloning' '
(
bzr init bzrrepo &&
cd bzrrepo &&
echo one >content &&
bzr add content &&
bzr commit -m one
) &&
git clone "bzr::bzrrepo" gitrepo &&
check gitrepo HEAD one
'
test_expect_success 'pulling' '
(
cd bzrrepo &&
echo two >content &&
bzr commit -m two
) &&
(cd gitrepo && git pull) &&
check gitrepo HEAD two
'
test_expect_success 'pushing' '
(
cd gitrepo &&
echo three >content &&
git commit -a -m three &&
git push
) &&
echo three >expected &&
cat bzrrepo/content >actual &&
test_cmp expected actual
'
test_expect_success 'forced pushing' '
(
cd gitrepo &&
echo three-new >content &&
git commit -a --amend -m three-new &&
git push -f
) &&
(
cd bzrrepo &&
# the forced update overwrites the bzr branch but not the bzr
# working directory (it tries to merge instead)
bzr revert
) &&
echo three-new >expected &&
cat bzrrepo/content >actual &&
test_cmp expected actual
'
test_expect_success 'roundtrip' '
(
cd gitrepo &&
git pull &&
git log --format="%s" -1 origin/master >actual
) &&
echo three-new >expected &&
test_cmp expected actual &&
(cd gitrepo && git push && git pull) &&
(
cd bzrrepo &&
echo four >content &&
bzr commit -m four
) &&
(cd gitrepo && git pull && git push) &&
check gitrepo HEAD four &&
(
cd gitrepo &&
echo five >content &&
git commit -a -m five &&
git push && git pull
) &&
(cd bzrrepo && bzr revert) &&
echo five >expected &&
cat bzrrepo/content >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
EOF
test_expect_success 'special modes' '
(
cd bzrrepo &&
echo exec >executable
chmod +x executable &&
bzr add executable
bzr commit -m exec &&
ln -s content link
bzr add link
bzr commit -m link &&
mkdir dir &&
bzr add dir &&
bzr commit -m dir
) &&
(
cd gitrepo &&
git pull
git ls-tree HEAD >../actual
) &&
test_cmp expected actual &&
(
cd gitrepo &&
git cat-file -p HEAD:link >../actual
) &&
printf content >expected &&
test_cmp expected actual
'
cat >expected <<\EOF
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
EOF
test_expect_success 'moving directory' '
(
cd bzrrepo &&
mkdir movedir &&
echo one >movedir/one &&
echo two >movedir/two &&
bzr add movedir &&
bzr commit -m movedir &&
bzr mv movedir movedir-new &&
bzr commit -m movedir-new
) &&
(
cd gitrepo &&
git pull &&
git ls-tree HEAD >../actual
) &&
test_cmp expected actual
'
test_expect_success 'different authors' '
(
cd bzrrepo &&
echo john >>content &&
bzr commit -m john \
--author "Jane Rey <jrey@example.com>" \
--author "John Doe <jdoe@example.com>"
) &&
(
cd gitrepo &&
git pull &&
git show --format="%an <%ae>, %cn <%ce>" --quiet >../actual
) &&
echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" >expected &&
test_cmp expected actual
'
# cleanup previous stuff
rm -rf bzrrepo gitrepo
test_expect_success 'fetch utf-8 filenames' '
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
LC_ALL=en_US.UTF-8
export LC_ALL
(
bzr init bzrrepo &&
cd bzrrepo &&
echo test >>"ærø" &&
bzr add "ærø" &&
echo test >>"ø~?" &&
bzr add "ø~?" &&
bzr commit -m add-utf-8 &&
echo test >>"ærø" &&
bzr commit -m test-utf-8 &&
bzr rm "ø~?" &&
bzr mv "ærø" "ø~?" &&
bzr commit -m bzr-mv-utf-8
) &&
(
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
git -c core.quotepath=false ls-files >../actual
) &&
echo "ø~?" >expected &&
test_cmp expected actual
'
test_expect_success 'push utf-8 filenames' '
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
mkdir -p tmp && cd tmp &&
LC_ALL=en_US.UTF-8
export LC_ALL
(
bzr init bzrrepo &&
cd bzrrepo &&
echo one >>content &&
bzr add content &&
bzr commit -m one
) &&
(
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
echo test >>"ærø" &&
git add "ærø" &&
git commit -m utf-8 &&
git push
) &&
(cd bzrrepo && bzr ls >../actual) &&
printf "content\nærø\n" >expected &&
test_cmp expected actual
'
test_expect_success 'pushing a merge' '
test_when_finished "rm -rf bzrrepo gitrepo" &&
(
bzr init bzrrepo &&
cd bzrrepo &&
echo one >content &&
bzr add content &&
bzr commit -m one
) &&
git clone "bzr::bzrrepo" gitrepo &&
(
cd bzrrepo &&
echo two >content &&
bzr commit -m two
) &&
(
cd gitrepo &&
echo three >content &&
git commit -a -m three &&
git fetch &&
git merge origin/master || true &&
echo three >content &&
git commit -a --no-edit &&
git push
) &&
echo three >expected &&
cat bzrrepo/content >actual &&
test_cmp expected actual
'
cat >expected <<\EOF
origin/HEAD
origin/branch
origin/trunk
EOF
test_expect_success 'proper bzr repo' '
test_when_finished "rm -rf bzrrepo gitrepo" &&
bzr init-repo bzrrepo &&
(
bzr init bzrrepo/trunk &&
cd bzrrepo/trunk &&
echo one >>content &&
bzr add content &&
bzr commit -m one
) &&
(
bzr branch bzrrepo/trunk bzrrepo/branch &&
cd bzrrepo/branch &&
echo two >>content &&
bzr commit -m one
) &&
(
git clone "bzr::bzrrepo" gitrepo &&
cd gitrepo &&
git for-each-ref --format "%(refname:short)" refs/remotes/origin >../actual
) &&
test_cmp expected actual
'
test_expect_success 'strip' '
test_when_finished "rm -rf bzrrepo gitrepo" &&
(
bzr init bzrrepo &&
cd bzrrepo &&
echo one >>content &&
bzr add content &&
bzr commit -m one &&
echo two >>content &&
bzr commit -m two
) &&
git clone "bzr::bzrrepo" gitrepo &&
(
cd bzrrepo &&
bzr uncommit --force &&
echo three >>content &&
bzr commit -m three &&
echo four >>content &&
bzr commit -m four &&
bzr log --line | sed -e "s/^[0-9][0-9]*: //" >../expected
) &&
(
cd gitrepo &&
git fetch &&
git log --format="%an %ad %s" --date=short origin/master >../actual
) &&
test_cmp expected actual
'
test_expect_success 'export utf-8 authors' '
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && GIT_COMMITTER_NAME=\"C O Mitter\""
LC_ALL=en_US.UTF-8
export LC_ALL
GIT_COMMITTER_NAME="Grégoire"
export GIT_COMMITTER_NAME
bzr init bzrrepo &&
(
git init gitrepo &&
cd gitrepo &&
echo greg >>content &&
git add content &&
git commit -m one &&
git remote add bzr "bzr::../bzrrepo" &&
git push bzr master
) &&
(
cd bzrrepo &&
bzr log | grep "^committer: " >../actual
) &&
echo "committer: Grégoire <committer@example.com>" >expected &&
test_cmp expected actual
'
test_expect_success 'push different author' '
test_when_finished "rm -rf bzrrepo gitrepo" &&
bzr init bzrrepo &&
(
git init gitrepo &&
cd gitrepo &&
echo john >> content &&
git add content &&
git commit -m john --author "John Doe <jdoe@example.com>" &&
git remote add bzr "bzr::../bzrrepo" &&
git push bzr master
) &&
(
cd bzrrepo &&
bzr log | grep "^author: " > ../actual
) &&
echo "author: John Doe <jdoe@example.com>" > expected &&
test_cmp expected actual
'
test_done
| AmandaMoen/AmandaMoen | contrib/remote-helpers/test-bzr.sh | Shell | gpl-2.0 | 7,813 | [
30522,
1001,
999,
1013,
8026,
1013,
14021,
1001,
1001,
9385,
1006,
1039,
1007,
2262,
17095,
9530,
7913,
8180,
1001,
3231,
1035,
6412,
1027,
1005,
3231,
6556,
1011,
1038,
2480,
2099,
1005,
3231,
1011,
1050,
1000,
1002,
3231,
1035,
14176,
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... |
.content404
{
background: url(../images/404.png) no-repeat ;
background-size: 100%;
background-size:cover;
}
.mcontent{
height: 100%;
width:100%;
}
| Magicer/Home-Page | css/mstyle.css | CSS | apache-2.0 | 153 | [
30522,
1012,
4180,
12740,
2549,
1063,
4281,
1024,
24471,
2140,
1006,
1012,
1012,
1013,
4871,
1013,
24837,
1012,
1052,
3070,
1007,
2053,
1011,
9377,
1025,
4281,
1011,
2946,
1024,
2531,
1003,
1025,
4281,
1011,
2946,
1024,
3104,
1025,
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... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Collections.Generic;
using System.Text.Json;
using Azure.Core;
namespace Azure.Management.Network.Models
{
public partial class LocalNetworkGateway : IUtf8JsonSerializable
{
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Etag != null)
{
writer.WritePropertyName("etag");
writer.WriteStringValue(Etag);
}
if (Id != null)
{
writer.WritePropertyName("id");
writer.WriteStringValue(Id);
}
if (Name != null)
{
writer.WritePropertyName("name");
writer.WriteStringValue(Name);
}
if (Type != null)
{
writer.WritePropertyName("type");
writer.WriteStringValue(Type);
}
if (Location != null)
{
writer.WritePropertyName("location");
writer.WriteStringValue(Location);
}
if (Tags != null)
{
writer.WritePropertyName("tags");
writer.WriteStartObject();
foreach (var item in Tags)
{
writer.WritePropertyName(item.Key);
writer.WriteStringValue(item.Value);
}
writer.WriteEndObject();
}
writer.WritePropertyName("properties");
writer.WriteStartObject();
if (LocalNetworkAddressSpace != null)
{
writer.WritePropertyName("localNetworkAddressSpace");
writer.WriteObjectValue(LocalNetworkAddressSpace);
}
if (GatewayIpAddress != null)
{
writer.WritePropertyName("gatewayIpAddress");
writer.WriteStringValue(GatewayIpAddress);
}
if (Fqdn != null)
{
writer.WritePropertyName("fqdn");
writer.WriteStringValue(Fqdn);
}
if (BgpSettings != null)
{
writer.WritePropertyName("bgpSettings");
writer.WriteObjectValue(BgpSettings);
}
if (ResourceGuid != null)
{
writer.WritePropertyName("resourceGuid");
writer.WriteStringValue(ResourceGuid);
}
if (ProvisioningState != null)
{
writer.WritePropertyName("provisioningState");
writer.WriteStringValue(ProvisioningState.Value.ToString());
}
writer.WriteEndObject();
writer.WriteEndObject();
}
internal static LocalNetworkGateway DeserializeLocalNetworkGateway(JsonElement element)
{
string etag = default;
string id = default;
string name = default;
string type = default;
string location = default;
IDictionary<string, string> tags = default;
AddressSpace localNetworkAddressSpace = default;
string gatewayIpAddress = default;
string fqdn = default;
BgpSettings bgpSettings = default;
string resourceGuid = default;
ProvisioningState? provisioningState = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("etag"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
etag = property.Value.GetString();
continue;
}
if (property.NameEquals("id"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
id = property.Value.GetString();
continue;
}
if (property.NameEquals("name"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
name = property.Value.GetString();
continue;
}
if (property.NameEquals("type"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
type = property.Value.GetString();
continue;
}
if (property.NameEquals("location"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
location = property.Value.GetString();
continue;
}
if (property.NameEquals("tags"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (var property0 in property.Value.EnumerateObject())
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
dictionary.Add(property0.Name, null);
}
else
{
dictionary.Add(property0.Name, property0.Value.GetString());
}
}
tags = dictionary;
continue;
}
if (property.NameEquals("properties"))
{
foreach (var property0 in property.Value.EnumerateObject())
{
if (property0.NameEquals("localNetworkAddressSpace"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
localNetworkAddressSpace = AddressSpace.DeserializeAddressSpace(property0.Value);
continue;
}
if (property0.NameEquals("gatewayIpAddress"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
gatewayIpAddress = property0.Value.GetString();
continue;
}
if (property0.NameEquals("fqdn"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
fqdn = property0.Value.GetString();
continue;
}
if (property0.NameEquals("bgpSettings"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
bgpSettings = BgpSettings.DeserializeBgpSettings(property0.Value);
continue;
}
if (property0.NameEquals("resourceGuid"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
resourceGuid = property0.Value.GetString();
continue;
}
if (property0.NameEquals("provisioningState"))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
provisioningState = new ProvisioningState(property0.Value.GetString());
continue;
}
}
continue;
}
}
return new LocalNetworkGateway(id, name, type, location, tags, etag, localNetworkAddressSpace, gatewayIpAddress, fqdn, bgpSettings, resourceGuid, provisioningState);
}
}
}
| hyonholee/azure-sdk-for-net | sdk/testcommon/Azure.Management.Network.2020_04/src/Generated/Models/LocalNetworkGateway.Serialization.cs | C# | mit | 9,134 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
7513,
3840,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
7000,
2104,
1996,
10210,
6105,
1012,
1013,
1013,
1026,
8285,
1011,
7013,
1013,
1028,
1001,
19701,
3085,
4487,
19150,
2478,
2291,
1012,
6407,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/* eslint-env jest */
jest.unmock('../as-array');
import {
asArray,
} from '../as-array';
describe('asArray()', () => {
it('returns input as it is if an array', () => {
expect(asArray([1, 2, 3])).toEqual([1, 2, 3]);
});
it('converts scalar value to an array which contains it', () => {
expect(asArray(42)).toEqual([42]);
});
it('converts null and undefined to an empty array', () => {
expect(asArray(null)).toEqual([]);
expect(asArray(undefined)).toEqual([]);
});
});
| asha-nepal/AshaFusionCross | src/web/forms/fields/common/__tests__/as-array-test.js | JavaScript | apache-2.0 | 503 | [
30522,
1013,
1008,
9686,
4115,
2102,
1011,
4372,
2615,
15333,
3367,
1008,
1013,
15333,
3367,
1012,
4895,
5302,
3600,
1006,
1005,
1012,
1012,
1013,
2004,
1011,
9140,
1005,
1007,
1025,
12324,
1063,
17306,
11335,
2100,
1010,
1065,
2013,
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... |
#include "clar_libgit2.h"
#include "tag.h"
static const char *tag1_id = "b25fa35b38051e4ae45d4222e795f9df2e43f1d1";
static const char *tag2_id = "7b4384978d2493e851f9cca7858815fac9b10980";
static const char *tagged_commit = "e90810b8df3e80c413d903f631643c716887138d";
static const char *bad_tag_id = "eda9f45a2a98d4c17a09d681d88569fa4ea91755";
static const char *badly_tagged_commit = "e90810b8df3e80c413d903f631643c716887138d";
static const char *short_tag_id = "5da7760512a953e3c7c4e47e4392c7a4338fb729";
static const char *short_tagged_commit = "4a5ed60bafcf4638b7c8356bd4ce1916bfede93c";
static git_repository *g_repo;
// Fixture setup and teardown
void test_object_tag_read__initialize(void)
{
g_repo = cl_git_sandbox_init("testrepo");
}
void test_object_tag_read__cleanup(void)
{
cl_git_sandbox_cleanup();
}
void test_object_tag_read__parse(void)
{
// read and parse a tag from the repository
git_tag *tag1, *tag2;
git_commit *commit;
git_oid id1, id2, id_commit;
git_oid_fromstr(&id1, tag1_id);
git_oid_fromstr(&id2, tag2_id);
git_oid_fromstr(&id_commit, tagged_commit);
cl_git_pass(git_tag_lookup(&tag1, g_repo, &id1));
cl_assert_equal_s(git_tag_name(tag1), "test");
cl_assert(git_tag_type(tag1) == GIT_OBJ_TAG);
cl_git_pass(git_tag_target((git_object **)&tag2, tag1));
cl_assert(tag2 != NULL);
cl_assert(git_oid_cmp(&id2, git_tag_id(tag2)) == 0);
cl_git_pass(git_tag_target((git_object **)&commit, tag2));
cl_assert(commit != NULL);
cl_assert(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_free(tag1);
git_tag_free(tag2);
git_commit_free(commit);
}
void test_object_tag_read__parse_without_tagger(void)
{
// read and parse a tag without a tagger field
git_repository *bad_tag_repo;
git_tag *bad_tag;
git_commit *commit;
git_oid id, id_commit;
// TODO: This is a little messy
cl_git_pass(git_repository_open(&bad_tag_repo, cl_fixture("bad_tag.git")));
git_oid_fromstr(&id, bad_tag_id);
git_oid_fromstr(&id_commit, badly_tagged_commit);
cl_git_pass(git_tag_lookup(&bad_tag, bad_tag_repo, &id));
cl_assert(bad_tag != NULL);
cl_assert_equal_s(git_tag_name(bad_tag), "e90810b");
cl_assert(git_oid_cmp(&id, git_tag_id(bad_tag)) == 0);
cl_assert(bad_tag->tagger == NULL);
cl_git_pass(git_tag_target((git_object **)&commit, bad_tag));
cl_assert(commit != NULL);
cl_assert(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_free(bad_tag);
git_commit_free(commit);
git_repository_free(bad_tag_repo);
}
void test_object_tag_read__parse_without_message(void)
{
// read and parse a tag without a message field
git_repository *short_tag_repo;
git_tag *short_tag;
git_commit *commit;
git_oid id, id_commit;
// TODO: This is a little messy
cl_git_pass(git_repository_open(&short_tag_repo, cl_fixture("short_tag.git")));
git_oid_fromstr(&id, short_tag_id);
git_oid_fromstr(&id_commit, short_tagged_commit);
cl_git_pass(git_tag_lookup(&short_tag, short_tag_repo, &id));
cl_assert(short_tag != NULL);
cl_assert_equal_s(git_tag_name(short_tag), "no_description");
cl_assert(git_oid_cmp(&id, git_tag_id(short_tag)) == 0);
cl_assert(short_tag->message == NULL);
cl_git_pass(git_tag_target((git_object **)&commit, short_tag));
cl_assert(commit != NULL);
cl_assert(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_free(short_tag);
git_commit_free(commit);
git_repository_free(short_tag_repo);
}
| ralpheav/PM_GIT | libgit2/tests-clar/object/tag/read.c | C | mit | 3,533 | [
30522,
1001,
2421,
1000,
18856,
2906,
1035,
5622,
2497,
23806,
2475,
1012,
1044,
1000,
1001,
2421,
1000,
6415,
1012,
1044,
1000,
10763,
9530,
3367,
25869,
1008,
6415,
2487,
1035,
8909,
1027,
1000,
1038,
17788,
7011,
19481,
2497,
22025,
2692... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
<table id="member_table" class="mainTable padTable" style="width:100%;" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th style="width:3%;" ><?=$lang_id?></th>
<th style="width:22%;"><?=$lang_name?></th>
<th style="width:15%;"><?=$lang_total_friends?></th>
<th style="width:15%;"><?=$lang_total_reciprocal_friends?></th>
<th style="width:15%;"><?=$lang_total_blocked_friends?></th>
<th style="width:15%;"><?=$lang_friends_groups_public?></th>
<th style="width:15%;"><?=$lang_friends_groups_private?></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><?=$member['member_id']?></td>
<td><?=$member['screen_name']?></td>
<td><?=$member['total_friends']?></td>
<td><?=$member['total_reciprocal_friends']?></td>
<td><?=$member['total_blocked_friends']?></td>
<td><?=$member['friends_groups_public']?></td>
<td><?=$member['friends_groups_private']?></td>
</tr>
</tbody>
</table>
<?php if ( count( $friends ) == 0 ) : ?>
<p><span class="notice"><?=$member['screen_name']?><?=$lang__added_no_friends_yet?></span></p>
<?php else: ?>
<form action="<?=$form_uri?>" method="post" id="delete_friend_form">
<input type="hidden" name="XID" value="<?=$XID_SECURE_HASH?>" />
<input type="hidden" name="member_id" value="<?=$member['member_id']?>" />
<table class="mainTable padTable magicCheckboxTable"
style="width:100%;" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th style="width:3%;"> </th>
<th style="width:7%;">
<input class="checkbox" type="checkbox"
name="toggle_all_checkboxes" value="" /> <?=$lang_delete?>
</th>
<th style="width:30%;"><?=$lang_name?></th>
<th style="width:20%;"><?=$lang_date?></th>
<th style="width:15%;"><?=$lang_reciprocal?></th>
<th style="width:15%;"><?=$lang_blocked?></th>
<th style="width:10%;"><?=$lang_total_friends?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $friends as $key => $val ) :
$key = $key + 1 + $row_count;
$switch = $this->cycle('odd', 'even'); ?>
<tr class="<?=$switch?>">
<td><?=$key?></td>
<td>
<input class="checkbox" type="checkbox"
name="toggle[]" value="<?=$val['entry_id']?>" id="delete_box_<?=$key?>" />
</td>
<td>
<a href="<?=$val['friend_uri']?>"
title="<?=$lang_view_friends_of_?><?=$val['screen_name']?>">
<?=$val['screen_name']; ?></a>
</td>
<td><?=$val['date']?></td>
<td><?=$val['reciprocal']?></td>
<td><?=$val['block']?></td>
<td><?=$val['total_friends']?></td>
</tr>
<?php endforeach; ?>
<?php $switch = $this->cycle('odd', 'even'); ?>
<tr class="<?=$switch?>">
<td> </td>
<td colspan="6">
<input class="checkbox" type="checkbox"
name="toggle_all_checkboxes" value="" /> <strong><?=$lang_delete?></strong>
</td>
</tr>
<?php if ( $paginate !== '' ) : ?>
<?php $switch = $this->cycle('odd', 'even'); ?>
<tr class="<?=$switch?>">
<td colspan="7">
<?=$paginate?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<p><input type="submit" class="submit" value="<?=$lang_delete?>" /></p>
</form>
<?php endif; ?> | ProJobless/nyus | nyusocial/expressionengine/third_party/friends/views/members_friends.html | HTML | mit | 3,351 | [
30522,
1026,
2795,
8909,
1027,
1000,
2266,
1035,
2795,
1000,
2465,
1027,
1000,
2364,
10880,
11687,
10880,
1000,
2806,
1027,
1000,
9381,
1024,
2531,
1003,
1025,
1000,
4442,
19498,
2075,
1027,
1000,
1014,
1000,
3526,
15455,
4667,
1027,
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... |
#!/bin/bash -e
# Copyright (c) 2017 Stefan Katerkamp (katerkamp.de)
. target/maven-shared-archive-resources/bash/config.sh 2>/dev/null || (echo "ERROR. Fix: run from project basedir."; exit 1)
. $SHAREPATH/bash/lib.sh
echo "FONTS........."
runscript pull-googlefonts.sh
echo "GIT REPOS........."
runscript pull-repos.sh
echo "NPM PACKAGES........."
runscript pull-nodepkgs.sh
exit 0
| skaterkamp/szoo-faces | build-helpers/src/bash/make-pulls.sh | Shell | apache-2.0 | 389 | [
30522,
1001,
999,
1013,
8026,
1013,
24234,
1011,
1041,
1001,
9385,
1006,
1039,
1007,
2418,
8852,
5736,
22379,
8737,
1006,
5736,
22379,
8737,
1012,
2139,
1007,
1012,
4539,
1013,
5003,
8159,
1011,
4207,
1011,
8756,
1011,
4219,
1013,
24234,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 <apertium_xml2cpp.h>
#include <string>
#include <iostream>
namespace apertium {
namespace xml2cpp {
} // namespace xml2cpp
} // namespace apertium
| andreisfrent/apertium-transfer-xmlcpp | src/error/Error.cc | C++ | gpl-3.0 | 157 | [
30522,
1001,
2421,
1026,
23957,
28228,
2819,
1035,
20950,
2475,
21906,
2361,
1012,
1044,
1028,
1001,
2421,
1026,
5164,
1028,
1001,
2421,
1026,
16380,
25379,
1028,
3415,
15327,
23957,
28228,
2819,
1063,
3415,
30524,
2361,
1063,
1065,
1013,
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... |
import {makeInstanceAction} from '#/main/app/store/actions'
import {makeReducer} from '#/main/app/store/reducer'
import {makeFormReducer} from '#/main/app/content/form/store/reducer'
import {RESOURCE_LOAD} from '#/main/core/resource/store/actions'
import {selectors as rssSelectors} from '#/plugin/rss/resources/rss-feed/store/selectors'
import {selectors} from '#/plugin/rss/resources/rss-feed/editor/store/selectors'
const reducer = {
rssFeedForm: makeFormReducer(selectors.FORM_NAME, {}, {
originalData: makeReducer({}, {
[makeInstanceAction(RESOURCE_LOAD, rssSelectors.STORE_NAME)]: (state, action) => action.resourceData.slideshow || state
}),
data: makeReducer({}, {
[makeInstanceAction(RESOURCE_LOAD, rssSelectors.STORE_NAME)]: (state, action) => action.resourceData.slideshow || state
})
})
}
export {
reducer
}
| claroline/Distribution | plugin/rss/Resources/modules/resources/rss-feed/editor/store/reducer.js | JavaScript | gpl-3.0 | 858 | [
30522,
12324,
1063,
2191,
7076,
26897,
18908,
3258,
1065,
2013,
1005,
1001,
1013,
2364,
1013,
10439,
1013,
3573,
1013,
4506,
1005,
12324,
1063,
9338,
2098,
18796,
2099,
1065,
2013,
1005,
1001,
1013,
2364,
1013,
10439,
1013,
3573,
1013,
5547... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
from nltk.tokenize import sent_tokenize,word_tokenize
from nltk.corpus import stopwords
from collections import defaultdict
from string import punctuation
from heapq import nlargest
import re
"""
Modified from http://glowingpython.blogspot.co.uk/2014/09/text-summarization-with-nltk.html
"""
class FrequencySummarizer:
def __init__(self, low_thresh=0.1, high_thresh=0.9):
"""
Initialize the text summarizer.
Words that have a frequency term lower than low_thresh
or higer than high_thresh will be ignored.
"""
ignore = ['fig','figure','ibid', 'et al','cf','NB','N.B.']
self._low_thresh = low_thresh
self._high_thresh = high_thresh
self._stopwords = set(stopwords.words('english') + list(punctuation) + list(ignore))
def _compute_frequencies(self, word_tk):
freq = defaultdict(int)
for s in word_tk:
for word in s:
if word not in self._stopwords:
freq[word] += 1
# frequencies normalization and fitering
m = float(max(freq.values()))
for w in freq.keys():
freq[w] = freq[w]/m
if freq[w] >= self._high_thresh or freq[w] <= self._low_thresh:
del freq[w]
return freq
def summarize(self, text, n):
"""
Return a list of n sentences
which represent the summary of text.
"""
text = "".join([unicode(x) for x in text])
sents = sent_tokenize(text)
if n > len(sents):
n = len(sents)
word_tk = [word_tokenize(s.lower()) for s in sents]
self._freq = self._compute_frequencies(word_tk)
ranking = defaultdict(int)
for i,sent in enumerate(word_tk):
for w in sent:
if w in self._freq and len(w)>4: #Only count words of length>4 as significant
ranking[i] += self._freq[w]
sentsindx = self._rank(ranking, n)
return [sents[j].encode('ascii', errors='backslashreplace') for j in sentsindx]
def _rank(self, ranking, n):
""" return the first n sentences with highest ranking """
return nlargest(n, ranking, key=ranking.get)
| rebeccamorgan/easyskim | nat_proc/FrequencySummarizer.py | Python | apache-2.0 | 2,032 | [
30522,
2013,
17953,
2102,
2243,
1012,
19204,
4697,
12324,
2741,
1035,
19204,
4697,
1010,
2773,
1035,
19204,
4697,
2013,
17953,
2102,
2243,
1012,
13931,
12324,
2644,
22104,
2013,
6407,
12324,
12398,
29201,
2013,
5164,
12324,
26136,
6593,
14505... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Hyperframework\Cli;
use Hyperframework\Cli\Test\TestCase as Base;
class OptionConfigParserTest extends Base {
public function testParse() {
$result = OptionConfigParser::parse([[
'name' => 'test',
'short_name' => 't',
'repeatable' => true,
'required' => true,
'description' => 'description',
'argument' => [
'name' => 'arg',
'required' => false,
'values' => ['a', 'b'],
]
]]);
$optionConfig = $result[0];
$this->assertSame('description', $optionConfig->getDescription());
$this->assertSame('t', $optionConfig->getShortName());
$this->assertSame('test', $optionConfig->getName());
$this->assertTrue($optionConfig->isRequired());
$this->assertTrue($optionConfig->isRepeatable());
$argumentConfig = $optionConfig->getArgumentConfig();
$this->assertSame('arg', $argumentConfig->getName());
$this->assertFalse($argumentConfig->isRequired());
$this->assertSame(['a', 'b'], $argumentConfig->getValues());
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidConfigs() {
OptionConfigParser::parse(['config']);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testNameAndShortNameAreAllMissing() {
OptionConfigParser::parse([[]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidNameType() {
OptionConfigParser::parse([['name' => true]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidNameFormat() {
OptionConfigParser::parse([['name' => '']]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidShortNameType() {
OptionConfigParser::parse([['name' => true]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidShortNameFormat() {
OptionConfigParser::parse([['name' => '']]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testValuesConflictBetweenNameAndShortName() {
OptionConfigParser::parse([['name' => 'x', 'short_name' => 'y']]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidDescriptionType() {
OptionConfigParser::parse([['name' => 'test', 'description' => false]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testDuplicatedOptions() {
OptionConfigParser::parse([
['name' => 'test'],
['name' => 'test'],
]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidArgumentConfig() {
OptionConfigParser::parse([['name' => 'test', 'argument' => false]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testArgumentNameIsMissing() {
OptionConfigParser::parse([['name' => 'test', 'argument' => []]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidArgumentNameType() {
OptionConfigParser::parse([[
'name' => 'test', 'argument' => ['name' => true]
]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidArgumentNameFormat() {
OptionConfigParser::parse([[
'name' => 'test', 'argument' => ['name' => '']
]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidArgumentRequiredType() {
OptionConfigParser::parse([[
'name' => 'test', 'argument' => ['name' => 'arg', 'required' => '']
]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidArgumentValuesType() {
OptionConfigParser::parse([[
'name' => 'test', 'argument' => ['name' => 'arg', 'values' => '']
]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidValueType() {
OptionConfigParser::parse([[
'name' => 'test',
'argument' => ['name' => 'arg', 'values' => [true]]
]]);
}
/**
* @expectedException Hyperframework\Common\ConfigException
*/
public function testInvalidValueFormat() {
OptionConfigParser::parse([[
'name' => 'test',
'argument' => ['name' => 'arg', 'values' => ['']]
]]);
}
}
| azheng1984/jk2010 | vendor/hyperframework/hyperframework/test/cli/tests/OptionConfigParserTest.php | PHP | mit | 4,987 | [
30522,
1026,
1029,
25718,
3415,
15327,
23760,
15643,
6198,
1032,
18856,
2072,
1025,
2224,
23760,
15643,
6198,
1032,
18856,
2072,
1032,
3231,
1032,
3231,
18382,
2004,
2918,
1025,
2465,
5724,
8663,
8873,
21600,
11650,
8743,
4355,
8908,
2918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 "MainWindow.h"
MainWindow::MainWindow(QWidget *parent):
QWidget(parent){
this->core = new gurgle();
this->LoginW = new LoginWindow();
this->MessageList = new packageList();
this->SubscribeDialog = new LinkcSubscribeDialog(NULL,this->core);
this->MsgReceiver = new MessageReceiver(this,this->core);
this->connect(LoginW,SIGNAL(SIGN_SignInButtonClicked()),this,SLOT(SLOT_LoginWinSignInButtonClicked()));
this->connect(LoginW,SIGNAL(SIGN_CancelButtonClicked()),this,SLOT(SLOT_LoginWinCancelButtonClicked()));
this->LoginW->show();
this->hide();
// UI TEST
//this->LoginW->hide();
this->Ui_PresenceBase = new QWidget(this);
this->Ui_PresenceWidget = new QWidget(this->Ui_PresenceBase);
this->Ui_HeadWidget = new QWidget(this);
this->Ui_PresenceLayout = new QVBoxLayout;
this->Ui_PresenceBaseLayout = new QHBoxLayout;
this->Ui_Name = new LinkcPresenceEdit;
this->Ui_Mood = new LinkcPresenceEdit;
this->Ui_GroupScrollArea = new QScrollArea(this);
this->Ui_GroupSelect = new LinkcGroupSelect(this->Ui_GroupScrollArea);
this->Ui_SubscribedButton = new QPushButton(this);
this->Ui_UnsubscribedButton = new QPushButton(this);
this->Ui_SubscribedButton->setText(tr("Subscribe"));
this->Ui_UnsubscribedButton->setText(tr("Unsubscribe"));
this->Ui_PresenceBase->setLayout(this->Ui_PresenceBaseLayout);
this->Ui_PresenceWidget->setStyleSheet("background-color:white");
this->Ui_HeadWidget->setStyleSheet("background-color:yellow");
this->Ui_PresenceWidget->setLayout(this->Ui_PresenceLayout);
this->Ui_Name->setDefaultText(tr("NoName"));
this->Ui_Mood->setDefaultText(tr("Please press here to update your mood"));
this->Ui_PresenceBaseLayout->setMargin(0);
this->Ui_PresenceBaseLayout->addWidget(this->Ui_PresenceWidget);
this->Ui_PresenceBaseLayout->addSpacing(50);
this->Ui_PresenceLayout->setMargin(0);
this->Ui_PresenceLayout->setSpacing(5);
this->Ui_PresenceLayout->addWidget(this->Ui_Name);
this->Ui_PresenceLayout->addWidget(this->Ui_Mood);
this->setMaximumWidth(300);
this->setMinimumWidth(200);
this->setMinimumHeight(400);
this->Ui_GroupScrollArea->setParent(this);
this->Ui_GroupScrollArea->setGeometry(0,50,this->width(),this->height()-50);
this->Ui_GroupScrollArea->setVisible(true);
this->Ui_GroupScrollArea->setWidget(this->Ui_GroupSelect);
this->connect(this->Ui_Name,SIGNAL(ContentUpdated(QString)),this,SLOT(SLOT_PresenceNameUpdated(QString)));
this->connect(this->Ui_Mood,SIGNAL(ContentUpdated(QString)),this,SLOT(SLOT_PresenceMoodUpdated(QString)));
this->connect(this->Ui_GroupSelect,SIGNAL(itemDoubleClicked(LinkcGroupItem*,LinkcSubscribedItem*)),this,SLOT(SLOT_ItemDoubleClicked(LinkcGroupItem*,LinkcSubscribedItem*)));
this->connect(this->Ui_SubscribedButton,SIGNAL(clicked(bool)),this,SLOT(SLOT_SubscribedButtonClicked(bool)));
this->connect(this->Ui_UnsubscribedButton,SIGNAL(clicked(bool)),this,SLOT(SLOT_UnsubscribedButtonClicked(bool)));
this->connect(this->SubscribeDialog,SIGNAL(subscribeDone()),this,SLOT(SLOT_RefreshSubscribeList()));
this->connect(this->MsgReceiver,SIGNAL(messageReceived(QString,QString,int)),this,SLOT(SLOT_MessageReceived(QString,QString,int)));
this->setWindowTitle(tr("LinkC"));
}
MainWindow::~MainWindow(){
delete this->core;
delete this->LoginW;
delete this->MessageList;
delete this->SubscribeDialog;
delete this->Ui_Mood;
delete this->Ui_Name;
delete this->Ui_PresenceLayout;
delete this->Ui_PresenceWidget;
delete this->Ui_PresenceBaseLayout;
delete this->Ui_PresenceBase;
delete this->Ui_SubscribedButton;
delete this->Ui_UnsubscribedButton;
}
void MainWindow::resizeEvent(QResizeEvent *){
this->Ui_PresenceBase->setGeometry(0,0,this->width(),50);
this->Ui_HeadWidget->setGeometry(this->width()-50,0,50,50);
this->Ui_GroupScrollArea->setGeometry(0,50,this->width(),this->height()-100);
this->Ui_GroupSelect->resize(this->width()-10,this->Ui_GroupSelect->height());
this->Ui_SubscribedButton->setGeometry(10,this->Ui_GroupScrollArea->y()+this->Ui_GroupScrollArea->height()+5,140,30);
this->Ui_UnsubscribedButton->setGeometry(this->Ui_SubscribedButton->x()+145,this->Ui_GroupScrollArea->y()+this->Ui_GroupScrollArea->height()+5,140,30);
}
void MainWindow::closeEvent(QCloseEvent *){
this->Ui_GroupSelect->clearSelect();
}
void MainWindow::SLOT_LoginWinCancelButtonClicked(){
exit(0);
}
void MainWindow::SLOT_SubscribedButtonClicked(bool){
this->SubscribeDialog->show();
}
void MainWindow::SLOT_UnsubscribedButtonClicked(bool){
LinkcSubscribedItem* tmpItem = this->Ui_GroupSelect->getCurrentSelectedSubscribedItem();
if(tmpItem == nullptr){
QMessageBox::warning(this,tr("Warning"),tr("You have not selected any item"));
return;
}
if(this->core->update_roster(tmpItem->getId(),nullptr,nullptr,UNSUBSCRIBE) == false){
QMessageBox::warning(this,tr("Warning"),tr("Failed to unsubscribe"));
return;
}
this->refreshSubscribedList();
}
void MainWindow::SLOT_LoginWinSignInButtonClicked(){
char *host = new char[32];
char *username = new char[32];
char *password = new char[32];
int port;
memset(host,0,32);
memset(username,0,32);
memset(password,0,32);
strncpy(host,this->LoginW->GetDomain().toUtf8().data(),this->LoginW->GetDomain().length());
strncpy(username,this->LoginW->GetUsername().toUtf8().data(),this->LoginW->GetUsername().length());
strncpy(password,this->LoginW->GetPassword().toUtf8().data(),this->LoginW->GetPassword().length());
port = this->LoginW->GetPort();
if(!this->core->connect_to_server(host,port,nullptr,2)){
QMessageBox::warning(this,tr("Warning"),tr("Cannot connect to remote"),QMessageBox::Ok);
return;
}
if(!this->core->plain_password_auth(this->core->analyse_full_id(this->core->make_up_full_id(username,host,nullptr)),password)){
QMessageBox::warning(this,tr("Warning"),tr("Cannot authenticate [Worning username or password]"),QMessageBox::Ok);
return;
}
this->show();
this->LoginW->hide();
this->core->write_log("Auth successfully");
if(this->refreshSubscribedList() == false){
this->core->write_log("Failed to refresh list");
}
if(this->refreshePresence() == false){
this->core->write_log("Failed to refresh presence");
}
char *buf = new char[512];
char *tmpBuf = new char[512];
char *tmpBuf2;
rapidjson::Document d;
while(1){
memset(buf,0,512);
memset(tmpBuf,0,512);
if(this->core->gurgle_recv(buf,512,0,"message",1,1)<=0)
break;
d.Parse(buf);
if(d.IsNull())
break;
memset(buf,0,512);
tmpBuf2 = new char[512];
memset(tmpBuf2,0,512);
strncpy(tmpBuf2,d["params"]["message"].GetString(),d["params"]["message"].GetStringLength());
strncpy(tmpBuf,d["params"]["from"].GetString(),d["params"]["from"].GetStringLength());
this->MessageList->insert(tmpBuf2,d["id"].GetInt(),tmpBuf);
}
this->MsgReceiver->start();
}
bool MainWindow::refreshSubscribedList(){
int count = 0;
gurgle_subscription_t *list = nullptr;
this->Ui_GroupSelect->clearSelect();
list = this->core->query_roster(count);
if(list == nullptr)
return false;
LinkcGroupItem *item = new LinkcGroupItem();
item->setCore(this->core);
item->setParent(this->Ui_GroupSelect);
int i;
for(i=0;i<count;i++){
if(strcmp(list[i].presence.id,"") == 0){
continue;
}
item->InsertSubscribedItem(new LinkcSubscribedItem(item,&list[i]));
}
this->Ui_GroupSelect->insertGroup(item);
item->show();
return true;
}
bool MainWindow::refreshePresence(){
gurgle_presence_t *self_presence = this->core->query_presence();
if(self_presence == nullptr){
return false;
}
QString Name;
if(strcmp(self_presence->last_name,"") != 0){
Name.append(self_presence->last_name);
Name.append(" ");
}
if(strcmp(self_presence->first_name,"") != 0){
Name.append(self_presence->first_name);
}
if(Name == ""){
Name = self_presence->id;
}
this->Ui_Name->setContent(Name,true);
if(strcmp(self_presence->mood,"")!=0)
this->Ui_Mood->setContent(self_presence->mood,true);
return true;
}
void MainWindow::SLOT_PresenceNameUpdated(QString Name){
if(Name.length() > 32){
QMessageBox::warning(this,tr("Warning"),tr("Too long for name"));
}
gurgle_presence_t *t = new gurgle_presence_t;
memset(t,0,sizeof(gurgle_presence_t));
strncpy(t->last_name,Name.toUtf8().data(),Name.length());
if(this->core->publish_self_presence_update(t) == false){
this->core->write_log("Failed to publish presence");
QMessageBox::warning(this,tr("Warning"),tr("Failed to publish presences"));
return;
}
}
void MainWindow::SLOT_PresenceMoodUpdated(QString Mood){
if(Mood.length() > 512){
QMessageBox::warning(this,tr("Warning"),tr("Too long for Mood"));
}
gurgle_presence_t *t = new gurgle_presence_t;
memset(t,0,sizeof(gurgle_presence_t));
strncpy(t->mood,Mood.toUtf8().data(),Mood.length());
if(this->core->publish_self_presence_update(t) == false){
this->core->write_log("Failed to publish presence");
QMessageBox::warning(this,tr("Warning"),tr("Failed to publish presences"));
return;
}
}
void MainWindow::SLOT_ItemDoubleClicked(LinkcGroupItem *, LinkcSubscribedItem *item){
if(item->ChatDialog != nullptr){
item->ChatDialog->show();
item->ChatDialog->setFocus();
return;
}
item->ChatDialog = new LinkcChatDialog(NULL,this->core,&(item->getInfo()->presence));
char *Message = nullptr;
while(1){
Message = this->MessageList->get_data(0,item->getInfo()->presence.id);
if(Message == nullptr)
break;
item->ChatDialog->setMessage(Message);
this->MessageList->remove(0,item->getInfo()->presence.id);
}
Message = nullptr;
item->ChatDialog->show();
}
void MainWindow::SLOT_RefreshSubscribeList(){
if(this->refreshSubscribedList() == false)
QMessageBox::warning(this,tr("Warning"),tr("Failed to refresh subscribed list"));
}
void MainWindow::SLOT_MessageReceived(QString User, QString Msg,int id){
LinkcSubscribedItem *tmpItem = this->Ui_GroupSelect->findItem(User);
if(tmpItem){
if(tmpItem->ChatDialog){
tmpItem->ChatDialog->setMessage(Msg);
this->MsgReceiver->messageSaveDone();
return;
}
}
int len = Msg.length();
int len2 = User.length();
char *buf = new char[len+1];
char *buf_usr = new char[len2+1];
memset(buf,0,len+1);
memset(buf_usr,0,len2+1);
memcpy(buf,Msg.toUtf8().data(),len);
memcpy(buf_usr,User.toUtf8().data(),User.length());
buf[len] = 0;
buf_usr[len2] = 0;
this->MessageList->insert(buf,id,buf_usr);
this->MsgReceiver->messageSaveDone();
}
MessageReceiver::MessageReceiver(QObject *parent, gurgle *_core){
this->setParent(parent);
if(_core != nullptr)
this->core = _core;
else
this->core = nullptr;
this->recvBuf = new char[1024];
this->flag = true;
}
MessageReceiver::~MessageReceiver(){
delete this->recvBuf;
}
void MessageReceiver::run(){
if(this->core == nullptr)
return;
int recved = 0;
this->flag = true;
rapidjson::Document d;
QString Id,Message;
while(1){
while(!this->flag); // wait MainThread to save message
recved = this->core->gurgle_recv(recvBuf,1024,0,"message",5,10);
if(!(recved>=0)){
if(this->core->is_connected() == false)
break;
continue;
}
d.Parse(recvBuf);
if(d.IsNull())
continue;
if(d["params"].HasMember("from"))
if(d["params"]["from"].IsString())
Id = d["params"]["from"].GetString();
if(d["params"].HasMember("message"))
if(d["params"]["message"].IsString())
Message = d["params"]["message"].GetString();
if(Message!="" && Id!=""){
this->flag = false;
emit this->messageReceived(Id,Message,d["id"].GetInt());
}
}
}
void MessageReceiver::messageSaveDone(){
this->flag = true;
}
| Trickness/LinkC-qt | LinkC-Qt-Cpp/MainWindow.cpp | C++ | gpl-2.0 | 12,662 | [
30522,
1001,
2421,
1000,
2364,
11101,
5004,
1012,
1044,
1000,
2364,
11101,
5004,
1024,
1024,
2364,
11101,
5004,
1006,
1053,
9148,
24291,
1008,
6687,
1007,
1024,
1053,
9148,
24291,
1006,
6687,
1007,
1063,
2023,
1011,
1028,
4563,
1027,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
VERSION=0.1
SCM=$(shell if test -d .svn; then echo svn; elif test -d .git; then echo git; fi)
DATE=$(shell date +%Y%m%d%H%M)
BUILD=build
INITVM_ARCH=$(shell bash -c '. common_functions ; build_host_arch; echo $$BUILD_INITVM_ARCH')
ifeq ($(SCM),svn)
SVNVER=_SVN$(shell LANG=C svnversion .)
endif
prefix=/usr
bindir=$(prefix)/bin
datadir=$(prefix)/share
libdir=$(prefix)/lib
pkglibdir=$(libdir)/$(BUILD)
mandir=$(datadir)/man
man1dir=$(mandir)/man1
sysconfdir=/etc
DESTDIR=
all:
.PHONY: test test-debtransform doc
test:
PERL5LIB=. prove -v
test-debtransform:
# debtransform test suite
cd test-debtransform && ./run.sh
install:
install -m755 -d \
$(DESTDIR)$(pkglibdir)/configs \
$(DESTDIR)$(pkglibdir)/baselibs_configs \
$(DESTDIR)$(pkglibdir)/Build \
$(DESTDIR)$(pkglibdir)/PBuild \
$(DESTDIR)$(pkglibdir)/emulator \
$(DESTDIR)$(bindir) \
$(DESTDIR)$(man1dir)
install -m755 \
build \
pbuild \
vc \
createdirdeps \
order \
expanddeps \
computeblocklists \
extractbuild \
getbinaryid \
getbuildids \
killchroot \
queryconfig \
common_functions \
init_buildsystem \
substitutedeps \
debtransform \
debtransformbz2 \
debtransformxz \
debtransformzip \
mkbaselibs \
mkdrpms \
listinstalled \
call-flatpak-builder \
createzyppdeps \
createarchdeps \
createdebdeps \
createrepomddeps \
createyastdeps \
changelog2spec \
spec2changelog \
download \
runservices \
spec_add_patch \
spectool \
signdummy \
unpackarchive \
unrpm \
telnet_login_wrapper \
startdockerd \
dummyhttpserver \
patchdockerfile \
obs-docker-support \
create_container_package_list \
call-podman \
queryobs \
writemodulemd \
download_assets \
export_debian_orig_from_git \
$(DESTDIR)$(pkglibdir)
install -m644 \
qemu-reg \
lxc.conf \
build-validate-params \
openstack-console \
$(DESTDIR)$(pkglibdir)
install -m755 emulator/emulator.sh $(DESTDIR)$(pkglibdir)/emulator/
install -m644 Build/*.pm $(DESTDIR)$(pkglibdir)/Build
install -m644 PBuild/*.pm $(DESTDIR)$(pkglibdir)/PBuild
install -m644 build-vm build-vm-* $(DESTDIR)$(pkglibdir)
install -m644 build-recipe build-recipe-* $(DESTDIR)$(pkglibdir)
install -m644 build-pkg build-pkg-* $(DESTDIR)$(pkglibdir)
install -m644 *.pm $(DESTDIR)$(pkglibdir)
install -m644 configs/* $(DESTDIR)$(pkglibdir)/configs
install -m644 baselibs_configs/* $(DESTDIR)$(pkglibdir)/baselibs_configs
install -m644 build.1 $(DESTDIR)$(man1dir)
install -m644 pbuild.1 $(DESTDIR)$(man1dir)
install -m644 buildvc.1 $(DESTDIR)$(man1dir)
install -m644 unrpm.1 $(DESTDIR)$(man1dir)
ln -sf $(pkglibdir)/build $(DESTDIR)$(bindir)/build
ln -sf $(pkglibdir)/pbuild $(DESTDIR)$(bindir)/pbuild
ln -sf $(pkglibdir)/vc $(DESTDIR)$(bindir)/buildvc
ln -sf $(pkglibdir)/unrpm $(DESTDIR)$(bindir)/unrpm
ln -s baselibs_configs/baselibs_global.conf $(DESTDIR)$(pkglibdir)/baselibs_global.conf
ln -s baselibs_configs/baselibs_global-deb.conf $(DESTDIR)$(pkglibdir)/baselibs_global-deb.conf
# Allow initvm to be packaged seperately from the rest of build. This
# is useful because it is distributed as a static binary package (e.g.
# build-initvm-static) whereas the build scripts package is noarch.
initvm: initvm.c
$(CC) -o $@.$(INITVM_ARCH) -static $(CFLAGS) initvm.c
initvm-all: initvm
initvm-build: initvm
initvm-install: initvm
install -m755 -d $(DESTDIR)$(pkglibdir)
install -m755 initvm.$(INITVM_ARCH) $(DESTDIR)$(pkglibdir)/initvm.$(INITVM_ARCH)
dist:
ifeq ($(SCM),svn)
rm -rf $(BUILD)-$(VERSION)$(SVNVER)
svn export . $(BUILD)-$(VERSION)$(SVNVER)
tar --force-local -cjf $(BUILD)-$(VERSION)$(SVNVER).tar.bz2 $(BUILD)-$(VERSION)$(SVNVER)
rm -rf $(BUILD)-$(VERSION)$(SVNVER)
else
ifeq ($(SCM),git)
git archive --prefix=$(BUILD)-$(VERSION)_git$(DATE)/ HEAD| bzip2 > $(BUILD)-$(VERSION)_git$(DATE).tar.bz2
endif
endif
| andreas-schwab/obs-build | Makefile | Makefile | gpl-2.0 | 4,048 | [
30522,
2544,
1027,
1014,
1012,
1015,
8040,
2213,
1027,
30524,
3058,
1027,
1002,
1006,
5806,
3058,
1009,
1003,
1061,
1003,
1049,
1003,
1040,
1003,
1044,
1003,
1049,
1007,
3857,
1027,
3857,
1999,
4183,
2615,
2213,
1035,
7905,
1027,
1002,
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... |
/**
@file
Host-key wrapper.
@if license
Copyright (C) 2010, 2013 Alexander Lamaison <awl03@doc.ic.ac.uk>
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
In addition, as a special exception, the the copyright holders give you
permission to combine this program with free software programs or the
OpenSSL project's "OpenSSL" library (or with modified versions of it,
with unchanged license). You may copy and distribute such a system
following the terms of the GNU GPL for this program and the licenses
of the other code concerned. The GNU General Public License gives
permission to release a modified version without this exception; this
exception also makes it possible to release a modified version which
carries forward this exception.
@endif
*/
#ifndef SSH_HOST_KEY_HPP
#define SSH_HOST_KEY_HPP
#include <ssh/detail/session_state.hpp>
#include <boost/foreach.hpp> // BOOST_FOREACH
#include <boost/shared_ptr.hpp> // shared_ptr
#include <boost/throw_exception.hpp> // BOOST_THROW_EXCEPTION
#include <sstream> // ostringstream
#include <stdexcept> // invalid_argument
#include <string>
#include <utility> // pair
#include <vector>
#include <libssh2.h>
namespace ssh
{
namespace detail
{
/**
* Thin wrapper around libssh2_session_hostkey.
*/
inline std::pair<std::string, int> hostkey(session_state& session)
{
// Session owns the string.
// Lock until we finish copying the key string from the session. I
// don't know if other calls to the session are currently able to
// change it, but they might one day.
// Locking it for the duration makes it thread-safe either way.
detail::session_state::scoped_lock lock = session.aquire_lock();
size_t len = 0;
int type = LIBSSH2_HOSTKEY_TYPE_UNKNOWN;
const char* key =
libssh2_session_hostkey(session.session_ptr(), &len, &type);
if (key)
return std::make_pair(std::string(key, len), type);
else
return std::make_pair(std::string(), type);
}
/**
* Thin wrapper around libssh2_hostkey_hash.
*
* @param T Type of collection to return. Sensible examples
* include std::string or std::vector<unsigned char>.
* @param session libssh2 session pointer
* @param hash_type Hash method being requested.
*/
template <typename T>
inline T hostkey_hash(session_state& session, int hash_type)
{
// Session owns the data.
// Lock until we finish copying the key hash bytes from the session. I
// don't know if other calls to the session are currently able to
// change it, but they might one day.
// Locking it for the duration makes it thread-safe either way.
detail::session_state::scoped_lock lock = session.aquire_lock();
const T::value_type* hash_bytes = reinterpret_cast<const T::value_type*>(
::libssh2_hostkey_hash(session.session_ptr(), hash_type));
size_t len = 0;
if (hash_type == LIBSSH2_HOSTKEY_HASH_MD5)
len = 16;
else if (hash_type == LIBSSH2_HOSTKEY_HASH_SHA1)
len = 20;
else
BOOST_THROW_EXCEPTION(std::invalid_argument("Unknown hash type"));
if (hash_bytes)
return T(hash_bytes, hash_bytes + len);
else
return T();
}
/**
* Thin wrapper around libssh2_session_methods.
*/
inline std::string method(session_state& session, int method_type)
{
// Session owns the string.
// Lock until we finish copying the string from the session. I
// don't know if other calls to the session are currently able to
// change it, but they might one day.
// Locking it for the duration makes it thread-safe either way.
detail::session_state::scoped_lock lock = session.aquire_lock();
const char* key_type =
libssh2_session_methods(session.session_ptr(), method_type);
if (key_type)
return std::string(key_type);
else
return std::string();
}
}
/**
* Possible types of host-key algorithm.
*/
struct hostkey_type
{
enum enum_t
{
unknown,
rsa1,
ssh_rsa,
ssh_dss
};
};
namespace detail
{
/**
* Convert the returned key-type from libssh2_session_hostkey into a value from
* the hostkey_type enum.
*/
inline hostkey_type::enum_t type_to_hostkey_type(int type)
{
switch (type)
{
case LIBSSH2_HOSTKEY_TYPE_RSA:
return hostkey_type::ssh_rsa;
case LIBSSH2_HOSTKEY_TYPE_DSS:
return hostkey_type::ssh_dss;
default:
return hostkey_type::unknown;
}
}
}
/**
* Class representing the session's current negotiated host-key.
*
* As well as the raw key itself, this class provides MD5 and SHA1 hashes and
* key metadata.
*/
class host_key
{
public:
explicit host_key(detail::session_state& session)
: // We pull everything out of the session here and store it to avoid
// instances of this class depending on the lifetime of the session
m_key(detail::hostkey(session)),
m_algorithm_name(detail::method(session, LIBSSH2_METHOD_HOSTKEY)),
m_md5_hash(detail::hostkey_hash<std::vector<unsigned char>>(
session, LIBSSH2_HOSTKEY_HASH_MD5)),
m_sha1_hash(detail::hostkey_hash<std::vector<unsigned char>>(
session, LIBSSH2_HOSTKEY_HASH_SHA1))
{
}
/**
* Host-key either raw or base-64 encoded.
*
* @see is_base64()
*/
std::string key() const
{
return m_key.first;
}
/**
* Is the key returned by key() base64-encoded (printable)?
*/
bool is_base64() const
{
return false;
}
/**
* Type of the key algorithm e.g., ssh-dss.
*/
hostkey_type::enum_t algorithm() const
{
return detail::type_to_hostkey_type(m_key.second);
}
/**
* Printable name of the method negotiated for the key algorithm.
*/
std::string algorithm_name() const
{
return m_algorithm_name;
}
/**
* Hostkey sent by the server to identify itself, hashed with the MD5
* algorithm.
*
* @returns Hash as binary data; it is not directly printable
* (@see hexify()).
*/
std::vector<unsigned char> md5_hash() const
{
return m_md5_hash;
}
/**
* Hostkey sent by the server to identify itself, hashed with the SHA1
* algorithm.
*
* @returns Hash as binary data; it is not directly printable
* (@see hexify()).
*/
std::vector<unsigned char> sha1_hash() const
{
return m_sha1_hash;
}
private:
std::pair<std::string, int> m_key;
std::string m_algorithm_name;
std::vector<unsigned char> m_md5_hash;
std::vector<unsigned char> m_sha1_hash;
};
/**
* Turn a collection of bytes into a printable hexidecimal string.
*
* @param bytes Collection of bytes.
* @param nibble_sep String to place between each pair of hexidecimal
* characters.
* @param uppercase Whether to use uppercase or lowercase hexidecimal.
*/
template <typename T>
std::string hexify(const T& bytes, const std::string& nibble_sep = ":",
bool uppercase = false)
{
std::ostringstream hex_hash;
if (uppercase)
hex_hash << std::uppercase;
else
hex_hash << std::nouppercase;
hex_hash << std::hex << std::setfill('0');
BOOST_FOREACH (unsigned char b, bytes)
{
if (!hex_hash.str().empty())
hex_hash << nibble_sep;
unsigned int i = b;
hex_hash << std::setw(2) << i;
}
return hex_hash.str();
}
} // namespace ssh
#endif
| alamaison/swish | ssh/host_key.hpp | C++ | gpl-2.0 | 8,313 | [
30522,
1013,
1008,
1008,
1030,
5371,
3677,
1011,
3145,
10236,
4842,
1012,
1030,
2065,
6105,
9385,
1006,
1039,
1007,
2230,
1010,
2286,
3656,
18832,
10929,
1026,
22091,
2140,
2692,
2509,
1030,
9986,
1012,
24582,
1012,
9353,
1012,
2866,
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... |
#ifndef BITMAP_H
#define BITMAP_H
#include <allegro5/allegro.h>
#include <memory>
#include "renderlist.h"
// This class does double duty as a renderable, and a wrapper for allegro bitmap.
class Bitmap;
using BitmapPtr = std::shared_ptr<Bitmap>;
class Bitmap : public Renderable
{
ALLEGRO_BITMAP* bitmap;
float x, y;
float scale;
public:
Bitmap() : bitmap(nullptr), x(0), y(0), scale(1.0f)
{}
Bitmap( ALLEGRO_BITMAP* _bitmap, int _x = 0 , int _y = 0 ) : bitmap(_bitmap), x(_x), y(_y), scale(1.0f)
{}
~Bitmap();
void render();
void create( int w, int h, int flags = 0 );
bool loadFromFile( const std::string& filename, int flags = 0 );
bool saveToFile( const std::string& filename );
BitmapPtr getSubBitmap( int _x, int _y, int _w, int _h );
void setBitmap( ALLEGRO_BITMAP* nb );
void setBitmap( BitmapPtr& nb );
void blit( const BitmapPtr& other, float x, float y, float scale );
float getX() { return x; }
float getY() { return y; }
float getScale() { return scale; }
void setX( int _x ) { x = _x; }
void setY( int _y ) { y = _y; }
int getWidth() { return al_get_bitmap_width( bitmap ); }
int getHeight() { return al_get_bitmap_height( bitmap ); }
void setScale( float _scale ) { scale = _scale; }
};
#endif // BITMAP_H
| merlinblack/oyunum | src/bitmap.h | C | mit | 1,343 | [
30522,
1001,
2065,
13629,
2546,
2978,
2863,
2361,
1035,
1044,
1001,
9375,
2978,
2863,
2361,
1035,
1044,
1001,
2421,
1026,
25319,
2629,
1013,
25319,
1012,
1044,
1028,
1001,
2421,
1026,
3638,
1028,
1001,
2421,
1000,
17552,
9863,
1012,
1044,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\EntityManager\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
/**
* Class AfterEntitySave
*/
class AfterEntitySave implements ObserverInterface
{
/**
* Apply model save operation
*
* @param Observer $observer
* @throws \Magento\Framework\Validator\Exception
* @return void
*/
public function execute(Observer $observer)
{
$entity = $observer->getEvent()->getEntity();
if ($entity instanceof AbstractModel) {
if (method_exists($entity->getResource(), 'loadAllAttributes')) {
$entity->getResource()->loadAllAttributes();
}
$entity->getResource()->afterSave($entity);
$entity->afterSave();
$entity->getResource()->addCommitCallback([$entity, 'afterCommitCallback']);
if ($entity->getResource() instanceof AbstractDb) {
$entity->getResource()->unserializeFields($entity);
}
$entity->setHasDataChanges(false);
}
}
}
| j-froehlich/magento2_wk | vendor/magento/framework/EntityManager/Observer/AfterEntitySave.php | PHP | mit | 1,305 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
9385,
1075,
2286,
1011,
2418,
17454,
13663,
1010,
4297,
1012,
2035,
2916,
9235,
1012,
1008,
2156,
24731,
1012,
19067,
2102,
2005,
6105,
4751,
1012,
1008,
1013,
3415,
15327,
17454,
13663,
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... |
#
# 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.
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
from heat.engine.resources.openstack.neutron import neutron
from heat.engine import support
class Net(neutron.NeutronResource):
PROPERTIES = (
NAME, VALUE_SPECS, ADMIN_STATE_UP, TENANT_ID, SHARED,
DHCP_AGENT_IDS, PORT_SECURITY_ENABLED,
) = (
'name', 'value_specs', 'admin_state_up', 'tenant_id', 'shared',
'dhcp_agent_ids', 'port_security_enabled',
)
ATTRIBUTES = (
STATUS, NAME_ATTR, SUBNETS, ADMIN_STATE_UP_ATTR, TENANT_ID_ATTR,
PORT_SECURITY_ENABLED_ATTR, MTU_ATTR,
) = (
"status", "name", "subnets", "admin_state_up", "tenant_id",
"port_security_enabled", "mtu",
)
properties_schema = {
NAME: properties.Schema(
properties.Schema.STRING,
_('A string specifying a symbolic name for the network, which is '
'not required to be unique.'),
update_allowed=True
),
VALUE_SPECS: properties.Schema(
properties.Schema.MAP,
_('Extra parameters to include in the "network" object in the '
'creation request. Parameters are often specific to installed '
'hardware or extensions.'),
default={},
update_allowed=True
),
ADMIN_STATE_UP: properties.Schema(
properties.Schema.BOOLEAN,
_('A boolean value specifying the administrative status of the '
'network.'),
default=True,
update_allowed=True
),
TENANT_ID: properties.Schema(
properties.Schema.STRING,
_('The ID of the tenant which will own the network. Only '
'administrative users can set the tenant identifier; this '
'cannot be changed using authorization policies.')
),
SHARED: properties.Schema(
properties.Schema.BOOLEAN,
_('Whether this network should be shared across all tenants. '
'Note that the default policy setting restricts usage of this '
'attribute to administrative users only.'),
default=False,
update_allowed=True
),
DHCP_AGENT_IDS: properties.Schema(
properties.Schema.LIST,
_('The IDs of the DHCP agent to schedule the network. Note that '
'the default policy setting in Neutron restricts usage of this '
'property to administrative users only.'),
update_allowed=True
),
PORT_SECURITY_ENABLED: properties.Schema(
properties.Schema.BOOLEAN,
_('Flag to enable/disable port security on the network. It '
'provides the default value for the attribute of the ports '
'created on this network'),
update_allowed=True,
support_status=support.SupportStatus(version='5.0.0')
),
}
attributes_schema = {
STATUS: attributes.Schema(
_("The status of the network."),
type=attributes.Schema.STRING
),
NAME_ATTR: attributes.Schema(
_("The name of the network."),
type=attributes.Schema.STRING
),
SUBNETS: attributes.Schema(
_("Subnets of this network."),
type=attributes.Schema.LIST
),
ADMIN_STATE_UP_ATTR: attributes.Schema(
_("The administrative status of the network."),
type=attributes.Schema.STRING
),
TENANT_ID_ATTR: attributes.Schema(
_("The tenant owning this network."),
type=attributes.Schema.STRING
),
PORT_SECURITY_ENABLED_ATTR: attributes.Schema(
_("Port security enabled of the network."),
support_status=support.SupportStatus(version='5.0.0'),
type=attributes.Schema.BOOLEAN
),
MTU_ATTR: attributes.Schema(
_("The maximum transmission unit size(in bytes) for the network."),
support_status=support.SupportStatus(version='5.0.0'),
type=attributes.Schema.INTEGER
),
}
def handle_create(self):
props = self.prepare_properties(
self.properties,
self.physical_resource_name())
dhcp_agent_ids = props.pop(self.DHCP_AGENT_IDS, None)
net = self.neutron().create_network({'network': props})['network']
self.resource_id_set(net['id'])
if dhcp_agent_ids:
self._replace_dhcp_agents(dhcp_agent_ids)
def _show_resource(self):
return self.neutron().show_network(
self.resource_id)['network']
def check_create_complete(self, *args):
attributes = self._show_resource()
return self.is_built(attributes)
def handle_delete(self):
client = self.neutron()
try:
client.delete_network(self.resource_id)
except Exception as ex:
self.client_plugin().ignore_not_found(ex)
else:
return True
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
props = self.prepare_update_properties(json_snippet)
dhcp_agent_ids = props.pop(self.DHCP_AGENT_IDS, None)
if self.DHCP_AGENT_IDS in prop_diff:
if dhcp_agent_ids is not None:
self._replace_dhcp_agents(dhcp_agent_ids)
del prop_diff[self.DHCP_AGENT_IDS]
if len(prop_diff) > 0:
self.neutron().update_network(
self.resource_id, {'network': props})
def check_update_complete(self, *args):
attributes = self._show_resource()
return self.is_built(attributes)
def _replace_dhcp_agents(self, dhcp_agent_ids):
ret = self.neutron().list_dhcp_agent_hosting_networks(
self.resource_id)
old = set([agent['id'] for agent in ret['agents']])
new = set(dhcp_agent_ids)
for dhcp_agent_id in new - old:
try:
self.neutron().add_network_to_dhcp_agent(
dhcp_agent_id, {'network_id': self.resource_id})
except Exception as ex:
# if 409 is happened, the agent is already associated.
if not self.client_plugin().is_conflict(ex):
raise
for dhcp_agent_id in old - new:
try:
self.neutron().remove_network_from_dhcp_agent(
dhcp_agent_id, self.resource_id)
except Exception as ex:
# assume 2 patterns about status_code following:
# 404: the network or agent is already gone
# 409: the network isn't scheduled by the dhcp_agent
if not (self.client_plugin().is_conflict(ex) or
self.client_plugin().is_not_found(ex)):
raise
def resource_mapping():
return {
'OS::Neutron::Net': Net,
}
| miguelgrinberg/heat | heat/engine/resources/openstack/neutron/net.py | Python | apache-2.0 | 7,583 | [
30522,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
1001,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
2017,
2089,
6855,
1001,
1037,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 System.Threading.Tasks;
using Elasticsearch.Net;
namespace Nest
{
public partial class ElasticClient
{
/// <inheritdoc />
public ISearchResponse<T> MoreLikeThis<T>(Func<MoreLikeThisDescriptor<T>, MoreLikeThisDescriptor<T>> mltSelector)
where T : class
{
return this.Dispatcher.Dispatch<MoreLikeThisDescriptor<T>, MoreLikeThisRequestParameters, SearchResponse<T>>(
mltSelector,
(p, d) =>
{
IMoreLikeThisRequest r = d;
CopySearchRequestParameters(d);
return this.RawDispatch.MltDispatch<SearchResponse<T>>(p, r.Search);
}
);
}
/// <inheritdoc />
public ISearchResponse<T> MoreLikeThis<T>(IMoreLikeThisRequest moreLikeThisRequest)
where T : class
{
return this.Dispatcher.Dispatch<IMoreLikeThisRequest, MoreLikeThisRequestParameters, SearchResponse<T>>(
moreLikeThisRequest,
(p, d) =>
{
CopySearchRequestParameters(d);
return this.RawDispatch.MltDispatch<SearchResponse<T>>(p, d.Search);
}
);
}
/// <inheritdoc />
public Task<ISearchResponse<T>> MoreLikeThisAsync<T>(Func<MoreLikeThisDescriptor<T>, MoreLikeThisDescriptor<T>> mltSelector)
where T : class
{
return this.Dispatcher.DispatchAsync<MoreLikeThisDescriptor<T>, MoreLikeThisRequestParameters, SearchResponse<T>, ISearchResponse<T>>(
mltSelector,
(p, d) =>
{
IMoreLikeThisRequest r = d;
CopySearchRequestParameters(d);
return this.RawDispatch.MltDispatchAsync<SearchResponse<T>>(p, r.Search);
}
);
}
/// <inheritdoc />
public Task<ISearchResponse<T>> MoreLikeThisAsync<T>(IMoreLikeThisRequest moreLikeThisRequest)
where T : class
{
return this.Dispatcher.DispatchAsync<IMoreLikeThisRequest, MoreLikeThisRequestParameters, SearchResponse<T>, ISearchResponse<T>>(
moreLikeThisRequest,
(p, d) =>
{
CopySearchRequestParameters(d);
return this.RawDispatch.MltDispatchAsync<SearchResponse<T>>(p, d.Search);
}
);
}
private static void CopySearchRequestParameters(IMoreLikeThisRequest request)
{
if (request.Search == null) return;
request.RequestParameters.CopyQueryStringValuesFrom(request.Search.QueryString);
}
}
} | joehmchan/elasticsearch-net | src/Nest/ElasticClient-MoreLikeThis.cs | C# | apache-2.0 | 2,228 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
21274,
17310,
11140,
1012,
5658,
1025,
3415,
15327,
9089,
1063,
2270,
7704,
2465,
21274,
20464,
11638,
1063,
1013,
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... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>summernote</title>
<!-- include jquery -->
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- include libraries BS3 -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<!-- include summernote -->
<link rel="stylesheet" href="../dist/summernote.css">
<script type="text/javascript" src="../dist/summernote.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.summernote').summernote({
height: 200,
tabsize: 2,
styleWithSpan: false
});
});
</script>
</head>
<body>
<textarea class="summernote"><p>Seasons <b>coming up</b></p></textarea>
</body>
</html>
| aoliverio/builder | webroot/bower_components/summernote/examples/nativestyle.html | HTML | mit | 1,009 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
418... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//copy codes from d3.js, add 4 functions: tickAttr, tickTextAttr, minorTickAttr and domainAttr;
//axis() changes, need a raphael paper object param, return raphael set object.
//examples in ../examples/axis/ to know the usage.
//a basic part for other data visualization format
/*global d3*/
/*!
* Axis兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Axis', function (require) {
/**
* function from d3, get scaleRange of an ordinal scale
* @param {Array} domain ordinal scale's range
*/
function d3_scaleExtent(domain) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [start, stop] : [stop, start];
}
/**
* function from d3, get scaleRange of a scale
*/
function d3_scaleRange(scale) {
return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
}
/**
* function from d3, get subticks
* @param scale, scale
* @param ticks, major ticks of scale
* @param m, number of subdivide
*/
function d3_svg_axisSubdivide(scale, ticks, m) {
var subticks = [];
if (m && ticks.length > 1) {
var extent = d3_scaleExtent(scale.domain()),
i = -1,
n = ticks.length,
d = (ticks[1] - ticks[0]) / ++m,
j,
v;
while (++i < n) {
for (j = m; --j > 0;) {
if ((v = +ticks[i] - j * d) >= extent[0]) {
subticks.push(v);
}
}
}
for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1];) {
subticks.push(v);
}
}
return subticks;
}
var Axis = function () {
var scale = d3.scale.linear(),
orient = "bottom",
tickMajorSize = 6,
tickMinorSize = 6,
tickEndSize = 6,
tickPadding = 3,
tickArguments_ = [10],
tickFormat_,
tickSubdivide = 0,
tickAttr_ = {},
tickTextAttr_ = {},
minorTickAttr_ = {},
domainAttr_ = {};
/**
* @param paper: raphael's paper object.
* @return axisSet: raphael's set object.
*/
function axis(paper) {
// Ticks for quantitative scale, or domain values for ordinal scale.
var ticks = scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain(),
tickFormat = tickFormat_ === undefined ?
(scale.tickFormat ?
scale.tickFormat.apply(scale, tickArguments_)
: String)
: tickFormat_;
var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide);
var range = d3_scaleRange(scale);
var axisSet = paper.set();
switch (orient) {
case "bottom":
subticks.forEach(function (d, i, arr) {
var tickX = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickX + "," + tickMinorSize + "V0")
.attr(minorTickAttr_));
});
ticks.forEach(function (d, i, arr) {
var tickX = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickX + "," + tickMajorSize + "V0")
.attr(tickAttr_));
axisSet.push(paper
.text(tickX, Math.max(tickMajorSize, 0) + tickPadding + 2,
typeof tickFormat === "function" ? tickFormat(d) : tickFormat)
.attr({"text-anchor": "middle"})
.attr(tickTextAttr_));
});
axisSet.push(paper
.path("M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize)
.attr(domainAttr_));
break;
case "top":
subticks.forEach(function (d, i, arr) {
var tickX = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickX + "," + -tickMinorSize + "V0")
.attr(minorTickAttr_));
});
ticks.forEach(function (d, i, arr) {
var tickX = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickX + "," + -tickMajorSize + "V0")
.attr(tickAttr_));
axisSet.push(paper
.text(tickX, -(Math.max(tickMajorSize, 0) + tickPadding + 2),
typeof tickFormat === "function" ? tickFormat(d) : tickFormat)
.attr({"text-anchor": "middle"})
.attr(tickTextAttr_));
});
axisSet.push(paper
.path("M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize)
.attr(domainAttr_));
break;
case "left":
subticks.forEach(function (d, i, arr) {
var tickY = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + -tickMinorSize + "," + tickY + "H0")
.attr(minorTickAttr_));
});
ticks.forEach(function (d, i, arr) {
var tickY = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + -tickMajorSize + "," + tickY + "H0")
.attr(tickAttr_));
axisSet.push(paper
.text(-(Math.max(tickMajorSize, 0) + tickPadding), tickY,
typeof tickFormat === "function" ? tickFormat(d) : tickFormat)
.attr({"text-anchor": "end"})
.attr(tickTextAttr_));
});
axisSet.push(paper
.path("M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize)
.attr(domainAttr_));
break;
case "right":
subticks.forEach(function (d, i, arr) {
var tickY = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickMinorSize + "," + tickY + "H0")
.attr(minorTickAttr_));
});
ticks.forEach(function (d, i, arr) {
var tickY = scale.ticks ? scale(d) : scale(d) + scale.rangeBand() / 2;
axisSet.push(paper
.path("M" + tickMajorSize + "," + tickY + "H0")
.attr(tickAttr_));
axisSet.push(paper
.text(Math.max(tickMajorSize, 0) + tickPadding, tickY,
typeof tickFormat === "function" ? tickFormat(d) : tickFormat)
.attr({"text-anchor": "start"})
.attr(tickTextAttr_));
});
axisSet.push(paper
.path("M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize)
.attr(domainAttr_));
break;
}
return axisSet;
}
/**
* get or set axis' scale.
*/
axis.scale = function (x) {
if (!arguments.length) {
return scale;
}
scale = x;
return axis;
};
/**
* get or set axis' orinet: "bottom", "top", "left", "right", default orient is bottom.
*/
axis.orient = function (x) {
if (!arguments.length) {
return orient;
}
orient = x;
return axis;
};
/**
* get or set axis' ticks number.
*/
axis.ticks = function () {
if (!arguments.length) {
return tickArguments_;
}
tickArguments_ = arguments;
return axis;
};
/**
* get or set axis' ticks format function, it's a function change format style.
* from one string format to another string format.
*/
axis.tickFormat = function (x) {
if (!arguments.length) {
return tickFormat_;
}
tickFormat_ = x;
return axis;
};
/**
* get or set axis' tick size(length of tick line, unit: px).
* @param arguments.length === 0, get axis' major tick size.
* @param arguments.length === 1, set axis' all tick sizes as x.
* @param arguments.length === 2, get axis' major tick size as x, minor and end size as y.
* @param arguments.length === 3, get axis' major tick size as x, minor size as y, end size as z.
*/
axis.tickSize = function (x, y, z) {
if (!arguments.length) {
return tickMajorSize;
}
var n = arguments.length - 1;
tickMajorSize = +x;
tickMinorSize = n > 1 ? +y : tickMajorSize;
tickEndSize = n > 0 ? +arguments[n] : tickMajorSize;
return axis;
};
/**
* get or set axis' tick padding(the distance between tick text and axis).
* @param x is a number, unit is px;
*/
axis.tickPadding = function (x) {
if (!arguments.length) {
return tickPadding;
}
tickPadding = +x;
return axis;
};
/**
* get or set axis' sub tick divide number(divide number between two major ticks).
*/
axis.tickSubdivide = function (x) {
if (!arguments.length) {
return tickSubdivide;
}
tickSubdivide = +x;
return axis;
};
/**
* get or set axis' tick attribute(Raphael format).
*/
axis.tickAttr = function (x) {
if (!arguments.length) {
return tickAttr_;
}
tickAttr_ = x;
return axis;
};
/**
* get or set axis' tick text attribute(Raphael format).
*/
axis.tickTextAttr = function (x) {
if (!arguments.length) {
return tickTextAttr_;
}
tickTextAttr_ = x;
return axis;
};
/**
* get or set axis' minor tick attribute(Raphael format).
*/
axis.minorTickAttr = function (x) {
if (!arguments.length) {
return minorTickAttr_;
}
minorTickAttr_ = x;
return axis;
};
/**
* get or set axis' domain(axis line) attribute(Raphael format).
*/
axis.domainAttr = function (x) {
if (!arguments.length) {
return domainAttr_;
}
domainAttr_ = x;
return axis;
};
return axis;
};
return Axis;
});
/*global Raphael, d3, $, define, _ */
/*!
* Stream的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('StreamAxis', function (require) {
var DataV = require('DataV');
DataV.Axis = require('Axis');
var Axis = DataV.extend(DataV.Chart, {
initialize: function (container) {
this.node = $(container);
/**
* 时间纬度
*/
this.dimension.x = {
type: "string",
required: true,
index: 0
};
}
});
Axis.prototype.setSource = function (source, map) {
map = this.map(map);
this.grouped = _.groupBy(source, map.x);
this.axis = _.keys(this.grouped);
this.range = [0, this.axis.length - 1];
};
Axis.prototype.init = function () {
var conf = this.defaults;
this.paper = new Raphael(this.node[0], conf.legendBesidesWidth, conf.axisHeight);
this.node.css({
"margin-top": "0px",
"border-top": "1px solid #ddd",
"height": conf.axisHeight + "px"
});
};
Axis.prototype.render = function () {
this.init();
this.clear();
//all date strings' format are same, string length are same
var conf = this.defaults,
that = this;
var getPopPath = function (El) {
//down pop
var x = 0,
y = 0,
size = 4,
cw = 23,
bb = {height: 8};
if (El) {
bb = El.getBBox();
bb.height *= 0.6;
cw = bb.width / 2 - size;
}
return [
'M', x, y,
'l', size, size, cw, 0,
'a', size, size, 0, 0, 1, size, size,
'l', 0, bb.height,
'a', size, size, 0, 0, 1, -size, size,
'l', -(size * 2 + cw * 2), 0,
'a', size, size, 0, 0, 1, -size, -size,
'l', 0, -bb.height,
'a', size, size, 0, 0, 1, size, -size,
'l', cw, 0,
'z'
].join(',');
};
var left = conf.percentageWidth,
right = conf.legendBesidesWidth - conf.percentageWidth;
var tempWord = this.paper.text(0, 0, this.axis[0]);
var tickNumber = Math.floor((right - left) / tempWord.getBBox().width / 2) + 1;
tempWord.remove();
this.dateScale = d3.scale.linear()
.domain([0, this.axis.length - 1])
.range([left, right]);
DataV.Axis().scale(this.dateScale)
.ticks(tickNumber)
.tickSize(6, 3, 3)
.tickAttr({"stroke": "none"})
.minorTickAttr({"stroke": "none"})
.domainAttr({"stroke": "none"})
.tickFormat(function (d) {
return that.axis[d] || "";
})(this.paper);
this.axisPopText = this.paper.text(0, 11, this.axis[0])
.attr({
"text-anchor": "middle",
"fill": "#fff",
"transform": "t" + left + ",0"
}).hide();
this.axisPopBubble = this.paper.path(getPopPath(this.axisPopText))
.attr({
"fill": "#000",
"transform": "t" + (-10000) + ",0"
}).toBack()
.hide();
};
Axis.prototype.hideTab = function () {
this.axisPopText.hide();
this.axisPopBubble.hide();
};
Axis.prototype.showTab = function () {
this.axisPopText.show();
this.axisPopBubble.show();
};
Axis.prototype.refreshTab = function (index) {
var conf = this.defaults;
var x = conf.chartWidth * index / (this.axis.length - 1);
var transX = x + this.defaults.percentageWidth;
this.axisPopText.attr({
"text": this.axis[index + this.range[0]]
}).transform("t" + transX + ",0");
this.axisPopBubble.transform("t" + transX + ",0");
};
Axis.prototype.clear = function () {
this.paper.clear();
};
return Axis;
});
/*global Raphael, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Legend', function (require) {
var DataV = require('DataV');
var Legend = DataV.extend(DataV.Chart, {
initialize: function (container) {
this.legendIndent = 20;
this.node = $(container);
/**
* 类型纬度
*/
this.dimension.type = {
type: "string",
required: true,
index: 1
};
/**
* 时间纬度
*/
this.dimension.x = {
type: "string",
required: true,
index: 0
};
/**
* 值纬度
*/
this.dimension.value = {
type: "number",
required: true,
index: 2
};
this.defaults.highlightStyle = {"backgroundColor": "#dddddd"};
this.defaults.lowlightStyle = {"backgroundColor": "white"};
this.formatLabel = function (text) {
return text;
};
this.init();
}
});
Legend.prototype.init = function () {
var conf = this.defaults;
this.legend = $("<div></div>");
this.legend.css({
"overflow": "hidden",
"padding": "10px 0 10px 0",
"width": conf.leftLegendWidth - this.legendIndent + "px"
});
this.node.append(this.legend);
this.initEvents();
};
Legend.prototype.setSource = function (source, map) {
map = this.map(map);
var groupedByType = _.groupBy(source, map.type);
var sorted = _.sortBy(groupedByType, function (group) {
return -DataV.sum(group, map.value);
});
//this.list = _.keys();
this.list = sorted.map(function (d) { return d[0][map.type]; });
};
Legend.prototype.initEvents = function () {
var that = this;
that.on('hoverIn', function (index) {
that.highlight(index);
}).on('hoverOut', function (index) {
that.lowlight(index);
}).on('level_changed', function (start, end, needMore) {
that.render(start, end, needMore);
});
};
Legend.prototype.render = function (level) {
var conf = this.defaults;
conf.level = level || 0;
var that = this;
this.clear();
this.legends = [];
var colorFunc = conf.colorFunc,
hoverIn = function (e) {
var index = e.data.index;
that.fire('hoverIn', index);
this.highlight(index);
},
hoverOut = function (e) {
var index = e.data.index;
that.fire('hoverOut', index);
this.lowlight(index);
};
var ul = $("<ul></ul>").css({
"margin": "0 0 0 10px",
"paddingLeft": 0
});
var selected;
if (!conf.more) {
selected = this.list.slice(0);
} else {
selected = DataV.more(this.list, conf.level, conf.max, function () {
return conf.moreLabel;
});
}
var formatLabel = conf.formatLabel || this.formatLabel;
for (var i = 0, l = selected.length; i < l; i++) {
var color = colorFunc(i);
var li = $('<li style="color: ' + color + '"><span style="color: black" title="' + selected[i] + '">' + formatLabel(selected[i]) + '</span></li>');
li.mouseenter({"index": i}, $.proxy(hoverIn, this)).mouseleave({"index": i}, $.proxy(hoverOut, this));
ul.append(li);
this.legends.push(li);
}
ul.find("li").css({
"list-style-type": "square",
"list-style-position": "inside",
"white-space": "nowrap",
"padding-left": 5
});
this.legend.append(ul);
};
Legend.prototype.highlight = function (index) {
if (typeof index !== 'undefined') {
this.legends[index].css(this.defaults.highlightStyle);
}
};
Legend.prototype.lowlight = function (index) {
if (typeof index !== 'undefined') {
this.legends[index].css(this.defaults.lowlightStyle);
}
};
Legend.prototype.clear = function () {
this.legend.empty();
};
var TopLegend = DataV.extend(DataV.Widget, {
initialize: function (container) {
this.node = $(container);
this.defaults.r0 = 5;
this.defaults.r1 = 7;
}
});
TopLegend.prototype.init = function () {
var conf = this.owner.defaults;
this.legend = $("<div></div>").css({
"width": conf.width,
"backgroundColor": "#f4f4f4"
});
this.node.append(this.legend);
};
TopLegend.prototype.render = function () {
this.init();
var that = this;
var owner = this.owner,
conf = owner.defaults;
var r0 = this.defaults.r0;
this.legends = [];
this.paper = new Raphael(this.legend[0], conf.width, 50);
var paper = this.paper;
var m = [10, 20, 10, 20],
left = m[3],
top = m[0],
lineHeight = 25,
legendInterval = 10,
lineWidth = conf.width,
circleW = 18,
colorFunc = owner.getColor();
var hoverIn = function () {
var index = this.data("index");
that.owner.fire('hoverIn', index);
that.highlight(index);
};
var hoverOut = function () {
var index = this.data("index");
that.owner.fire('hoverOut', index);
that.lowlight(index);
};
that.on('hoverIn', function (index) {
that.highlight(index);
}).on('hoverOut', function (index) {
that.lowlight(index);
});
var colorArray = owner.displayData.allInfos.map(function (item, index) {
return colorFunc(index);
});
for (var i = 0, l = owner.displayData.allInfos.length; i < l; i++) {
var text = paper.text(0, 0, owner.getDisplayRowInfo(i).rowName).attr({
"font-size": conf.fontSize,
"text-anchor": "start",
"font-family": "微软雅黑"
});
var box = text.getBBox();
if (left + circleW + box.width >= lineWidth - m[1]) {
//new line
left = m[3];
top += lineHeight;
}
var color = colorArray[owner.displayData.rowIndex[i].slicedData];
var circle = paper.circle(left + circleW / 2, top + lineHeight / 2, r0)
.attr({
"stroke": "none",
"fill": color
})
.data("index", i)
.hover(hoverIn, hoverOut);
text.transform("t" + (left + circleW) + "," + (top + lineHeight / 2));
paper.rect(left + circleW, top, box.width, lineHeight).attr({
"stroke": "none",
"fill": "#000",
"opacity": 0
})
.data("index", i)
.hover(hoverIn, hoverOut);
that.legends.push({"text": text, "circle": circle});
left += legendInterval + circleW + box.width;
}
paper.setSize(lineWidth, top + lineHeight + m[2]);
};
TopLegend.prototype.highlight = function (index) {
this.legends[index].circle.animate({"r": this.defaults.r1, "opacity": 0.5}, 300);
};
TopLegend.prototype.lowlight = function (index) {
this.legends[index].circle.animate({"r": this.defaults.r0, "opacity": 1}, 300);
};
return {
Legend: Legend,
TopLegend: TopLegend
};
});
/*global Raphael, d3, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Navi', function (require) {
var DataV = require('DataV');
var Navi = DataV.extend(DataV.Chart, {
initialize: function (container) {
this.node = $(container);
}
});
Navi.prototype.init = function () {
this.naviBackWidth = 80;
var conf = this.defaults;
this.node.css({
"borderTop": "1px solid #ddd",
"borderBottom": "1px solid #ddd",
"padding": "5px 10px 10px 10px",
"fontSize": conf.fontSize + 1,
"fontFamily": "宋体"
});
this.naviTrace = $("<div></div>").css({
"width": conf.legendBesidesWidth - this.naviBackWidth - 50,
"margin-top": "5px"
});
this.naviBack = $("<div></div>");
this.naviBack.html("返回上层").css({
"width": this.naviBackWidth + "px",
"float": "right",
"background-color": "#f4f4f4",
"padding-top": "4px",
"padding-bottom": "4px",
"border": "1px solid #ddd",
"border-radius": "2px",
"cursor": "pointer",
"text-align": "center",
"visibility": "hidden"
});
this.node.append(this.naviBack).append(this.naviTrace);
var that = this;
this.naviTrace.on("click", ".navi", function (e) {
that.owner.fire('changeLevelTo', e.target.data('level'));
});
this.naviBack.on("back", function () {
that.owner.fire('changeLevel');
});
};
Navi.prototype.render = function () {
this.init();
var level = this.defaults.level;
this.clear();
for (var i = 0; i <= level; i++) {
this.naviTrace.append($("<span> > </span>"));
var span = $("<span></span>").data("level", i).html("第" + (i + 1) + "层");
this.naviTrace.append(span);
if (i !== level) {
span.css({
"cursor": "pointer",
"color": "#1E90FF"
}).addClass("navi");
}
}
this.naviBack.css('visibility', level > 0 ? "visible" : "hidden");
};
Navi.prototype.clear = function () {
this.naviTrace.empty();
};
return Navi;
});
/*global Raphael, d3, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Tip', function (require) {
var DataV = require('DataV');
//floatTag
var Tip = DataV.extend(DataV.Chart, {
initialize: function (container) {
this.container = container;
this.node = DataV.FloatTag()(this.container);
/**
* 类型纬度
*/
this.dimension.type = {
type: "string",
required: true,
index: 1
};
/**
* 时间纬度
*/
this.dimension.x = {
type: "string",
required: true,
index: 0
};
/**
* 值纬度
*/
this.dimension.value = {
type: "number",
required: true,
index: 2
};
},
getContent: function (obj) {
return obj[this.mapping.x];
}
});
Tip.prototype.setSource = function (source, map) {
var that = this;
this.map(map);
this.rawData = source;
this.groupedByX = _.groupBy(source, this.mapping.x);
this.groupedByType = _.groupBy(source, this.mapping.type);
var sorted = _.sortBy(this.groupedByType, function (group) {
return -DataV.sum(group, that.mapping.value);
});
this.sorted = sorted;
_.each(sorted, function (list, index) {
that.groupedByType[list[0][that.mapping.type]].finalRank = index + 1;
});
this.axis = _.keys(this.groupedByX);
};
Tip.prototype.render = function () {
this.hidden();
this.node.css(this.defaults.tipStyle);
};
Tip.prototype.setContent = function (rowIndex, columnIndex) {
var that = this;
var conf = this.defaults;
var getContent = conf.getContent || this.getContent;
var column = this.groupedByX[this.axis[columnIndex]];
var values = this.sorted;//_.values(this.groupedByType);
var types;
if (!conf.more) {
types = values;
} else {
types = DataV.more(values, conf.level, conf.max, function (remains) {
var row = [];
for (var i = 0; i < that.axis.length; i++) {
var col = {};
col[that.mapping.type] = conf.moreLabel;
col[that.mapping.x] = that.axis[i];
col[that.mapping.value] = NaN;// DataV.sum(_.pluck(remains, i), that.mapping.value);
col.rate = DataV.sum(_.pluck(remains, i), "rate");
row.push(col);
}
return row;
});
}
var row = types[rowIndex];
var obj = row[columnIndex];
var index = _.indexOf(_.map(column, function (item) {
return item[that.mapping.value];
}).sort(function (a, b) {
return a > b ? -1 : 1;
}), obj[that.mapping.value]);
obj.rank = index === -1 ? NaN : index + 1;
var html = getContent.call(this, obj);
this.node.html(html);
};
return Tip;
});
/*global Raphael, d3, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Percentage', function (require) {
var DataV = require('DataV');
var Percentage = DataV.extend(DataV.Chart, {
initialize: function (container) {
this.node = $(container);
this.limit = 20;
this.from = 0;
this.to = 0;
/**
* 类型纬度
*/
this.dimension.type = {
type: "string",
required: true,
index: 1
};
/**
* 值纬度
*/
this.dimension.value = {
type: "number",
required: true,
index: 2
};
}
});
Percentage.prototype.init = function () {
var conf = this.defaults;
this.paper = new Raphael(this.node[0], conf.percentageWidth, conf.chartHeight);
this.node.css({
"width": conf.percentageWidth,
"height": conf.chartHeight,
"float": "left",
"margin-bottom": "0px",
"border-bottom": "0px",
"padding-bottom": "0px"
});
};
Percentage.prototype.setSource = function (source, map) {
map = this.map(map);
this.grouped = _.groupBy(source, map.type);
this.types = _.keys(this.grouped);
if (this.types.length > this.limit) {
this.to = this.limit;
}
};
Percentage.prototype.render = function () {
this.init();
var conf = this.defaults;
var y = conf.fontSize * 2 / 3;
if (!this.rect) {//init
this.rect = this.paper.rect(0, 0, conf.percentageWidth, conf.chartHeight)
.attr({
"fill": "#f4f4f4",
"stroke": "#aaa",
"stroke-width": 0.5
});
this.text = this.paper.text(conf.percentageWidth / 2, y, Math.round(100) + "%")
.attr({"text-anchor": "middle"});
}
// this.rect.animate({"y": (1 - maxY) * conf.chartHeight, "height": maxY * conf.chartHeight}, 750);
// this.text.attr({
// "text": Math.round(maxY * 100) + "%"
// }).animate({"y": y}, 300);
};
return Percentage;
});
/*global Raphael, d3, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('HoverLine', function (require) {
var DataV = require('DataV');
var HoverLine = DataV.extend(DataV.Chart, {
initialize: function () {
}
});
HoverLine.prototype.render = function () {
this.clear();
var paper = this.owner.paper;
var conf = this.defaults;
this.indicatorLine = paper.path("M0 0V" + conf.chartHeight).attr({
stroke: "none",
"stroke-width": 1,
"stroke-dasharray": "- "
});
this.highlightLine = paper.path("M0 0V" + conf.chartHeight).attr({
stroke: "none",
"stroke-width": 2
});
};
HoverLine.prototype.hidden = function () {
this.indicatorLine.attr({"stroke": "none"});
this.highlightLine.attr({"stroke": "none"});
};
HoverLine.prototype.show = function () {
this.indicatorLine.attr({"stroke": "#000"});
this.highlightLine.attr({"stroke": "white"});
};
HoverLine.prototype.refresh = function (columnIndex, rowIndex) {
//refresh lines' position
var owner = this.owner;
var pathSource = owner.pathSource;
var lineX = this.defaults.chartWidth * columnIndex / (owner.columnCount - 1);
var pathSourceCell = pathSource[pathSource.length - 1][columnIndex];
this.indicatorLine.attr({
path: "M" + lineX + " " + (pathSourceCell.y0 - pathSourceCell.y) + "V" + pathSource[0][columnIndex].y0
});
if (typeof rowIndex !== 'undefined') {
pathSourceCell = pathSource[rowIndex][columnIndex];
this.highlightLine.attr({
path: "M" + lineX + " " + (pathSourceCell.y0 - pathSourceCell.y) + "V" + pathSourceCell.y0
});
if (rowIndex === 0) {
this.highlightLine.attr({"cursor": "pointer"});
} else {
this.highlightLine.attr({"cursor": "auto"});
}
}
};
HoverLine.prototype.clear = function () {
this.indicatorLine && this.indicatorLine.remove();
this.highlightLine && this.highlightLine.remove();
};
return HoverLine;
});
/*global Raphael, d3, $, define, _ */
/*!
* PathLabel的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('PathLabel', function (require) {
var DataV = require('DataV');
//pathLabel
var PathLabel = DataV.extend(DataV.Chart, {
initialize: function () {
/**
* 类型纬度
*/
this.dimension.type = {
type: "string",
required: true,
index: 1
};
/**
* 时间纬度
*/
this.dimension.x = {
type: "string",
required: true,
index: 0
};
/**
* 值纬度
*/
this.dimension.value = {
type: "number",
required: true,
index: 2
};
}
});
PathLabel.prototype.render = function () {
this.clear();
var that = this;
var owner = this.owner;
var paths = owner.paths;
var conf = this.defaults;
var pathSource = owner.pathSource;
var labels = [];
var getLabelLocation = function (locArray, el) {
var x = 0,
y = 0,
i;
var ratioMargin = 0.15;
var index = 0;
var max = 0;
var box = el.getBBox();
var xInterval;
var minTop, maxBottom;
var showLabel = true;
var loc;
var height;
xInterval = Math.ceil(box.width / (locArray[1].x - locArray[0].x) / 2);
if (xInterval === 0) {
xInterval = 1;
}
locArray.forEach(function (d, i, array) {
var m = Math.max(ratioMargin * array.length, xInterval);
if (i >= m && i <= array.length - m) {
if (d.y > max) {
minTop = d.y0 - d.y;
maxBottom = d.y0;
max = d.y;
index = i;
}
}
});
for (i = index - xInterval; i <= index + xInterval; i++) {
if (i < 0 || i >= locArray.length) {
height = 0;
showLabel = false;
break;
}
loc = locArray[i];
//top's y is small
if (loc.y0 - loc.y > minTop) {
minTop = loc.y0 - loc.y;
}
if (loc.y0 < maxBottom) {
maxBottom = loc.y0;
}
}
if (showLabel && maxBottom - minTop >= box.height * 0.8) {
x = locArray[index].x;
y = (minTop + maxBottom) / 2;
} else {
showLabel = false;
}
return {
x: x,
y: y,
showLabel: showLabel
};
};
var getPathLabel = this.defaults.getPathLabel || this.getPathLabel;
var selected;
//var values = _.values(this.groupedByType);
var values = _.values(this.sorted);
if (!conf.more) {
selected = values.slice(0);
} else {
selected = DataV.more(values, conf.level, conf.max, function (remains) {
var obj = {};
obj.type = conf.moreLabel;
obj.rank = remains[0].rank;
obj.sum = DataV.sum(remains, "sum");
return obj;
});
}
for (var i = 0, l = paths.length; i < l; i++) {
var path = paths[i];
var row = selected[i];
var obj = {
type: row.type,
rank: row.rank,
sum: row.sum,
total: this.total
};
var text = getPathLabel.call(this, obj);
var label = owner.paper.text(0, 0, text).attr({
"textAnchor": "middle",
"fill": "white",
"fontSize": conf.fontSize,
"fontFamily": "微软雅黑"
});
label.labelLoc = getLabelLocation(pathSource[i], label);
if (label.labelLoc.showLabel) {
label.attr({
"x": label.labelLoc.x,
"y": label.labelLoc.y
});
} else {
label.attr({"opacity": 0});
}
path.attr({"cursor": "auto"});
label.attr({"cursor": "auto"});
labels.push(label);
}
this.labels = labels;
};
/**
* 生成标签的默认方法,可以通过`setOption({getPathLable: function});`覆盖。
* Properties:
* - `type`, 条带类型
* - `rank`, 条带排名
* - `sum`, 当前条带总值
* - `total`, 所有条带总值
* @param {Object} obj 当前条带的对象
*/
PathLabel.prototype.getPathLabel = function (obj) {
return obj.type + " " + "排名: 第" + obj.rank;
};
PathLabel.prototype.hidden = function () {
this.labels.forEach(function (d) {
d.hide();
});
};
PathLabel.prototype.show = function () {
this.labels.forEach(function (d) {
if (d.labelLoc.showLabel) {
d.show();
}
});
};
PathLabel.prototype.clear = function () {
if (this.labels) {
this.labels.forEach(function (d) {
d.remove();
});
}
};
PathLabel.prototype.setSource = function (source, map) {
var that = this;
this.map(map);
this.groupedByType = _.groupBy(source, this.mapping.type);
var sorted = _.sortBy(this.groupedByType, function (group, type) {
var sum = DataV.sum(group, that.mapping.value);
that.groupedByType[type].sum = sum;
that.groupedByType[type].type = type;
return -sum;
});
this.sorted = sorted;
this.types = _.keys(this.groupedByType);
_.each(sorted, function (list, index) {
that.groupedByType[list[0][that.mapping.type]].rank = index + 1;
});
this.total = DataV.sum(_.map(that.groupedByType, function (group) {
return group.sum;
}));
};
return PathLabel;
});
/*global Raphael, d3, $, define, _ */
/*!
* StreamLegend的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Cover', function (require) {
var DataV = require('DataV');
//cover
var Cover = DataV.extend(DataV.Chart, {
initialize: function (container) {
var conf = this.defaults;
this.node = $(container);
this.node.css({
"position": "absolute",
"left": 0,
"top": 0,
"width": conf.chartWidth,
"height": conf.chartHeight,
"zIndex": 100,
"visibility": "hidden"
}).bind("mousemove", $.proxy(function (e) {
this.mouse = {x: e.pageX, y: e.pageY};
e.stopPropagation();
}, this)).bind("mouseleave", $.proxy(function () {
this.mouse = undefined;
}, this));
}
});
return Cover;
});
/*global Raphael, d3, $, define, _ */
/*!
* Stream的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('Stream', function (require) {
var DataV = require('DataV');
var HoverLine = require('HoverLine');
var PathLabel = require('PathLabel');
//streamChart
var Stream = DataV.extend(DataV.Chart, {
initialize: function (node, options) {
this.node = this.checkContainer(node);
/**
* 类型纬度
*/
this.dimension.type = {
type: "string",
required: true,
index: 1
};
/**
* 时间纬度
*/
this.dimension.x = {
type: "string",
required: true,
index: 0
};
/**
* 值纬度
*/
this.dimension.value = {
type: "number",
required: true,
index: 2
};
this.defaults.width = 500;
this.defaults.height = 300;
this.defaults.offset = "expand";//zero, expand, silhou-ette, wiggle;
this.defaults.order = "default";//default, reverse, inside-out //in this Stream application, it will always be default, the real order is adjusted in Stream's data-process.
this.defaults.animateDuration = 750;
this.defaults.animateOrder = undefined;
this.paths = undefined;
this.source = undefined;
this.layoutData = undefined;
this.pathSource = undefined;
this.setOptions(options);
this.createPaper();
}
});
Stream.prototype.createPaper = function () {
var conf = this.defaults;
this.paper = new Raphael(this.node, conf.width, conf.height);
};
Stream.prototype.setSource = function (source, map) {
this.map(map);
this.rawData = source;
this.rawMap = map;
var that = this;
// 按类型分组
var grouped = _.groupBy(source, this.mapping.type);
this.rowCount = _.keys(grouped).length;
this.columnCount = _.keys(_.groupBy(source, this.mapping.x)).length;
// 组内按横轴排序
_.forEach(grouped, function (group, type) {
grouped[type] = _.sortBy(group, that.mapping.x);
});
this.sorted = _.sortBy(grouped, function (group) {
return 0 - DataV.sum(group, that.mapping.value);
});
this.remaped = this.remapSource();
this.layoutData = this.getLayoutData();
};
Stream.prototype.remapSource = function () {
var sorted = this.sorted;
var remap = [];
for (var j = 0; j < this.columnCount; j++) {
var plucked = _.pluck(sorted, j);
var sum = DataV.sum(plucked, this.mapping.value);
for (var i = 0; i < this.rowCount; i++) {
remap[i] = remap[i] || [];
remap[i][j] = {};
remap[i][j].x = j;
var rate = sorted[i][j][this.mapping.value] / sum;
remap[i][j].y = rate;
sorted[i][j].rate = rate;
}
}
return remap;
};
/*!
* 获取等级数据
*/
Stream.prototype.getLayoutData = function () {
var conf = this.defaults;
var remaped = this.remaped;
var that = this;
if (!conf.more) {
return remaped;
} else {
return DataV.more(remaped, conf.level, conf.max, function (remains) {
var obj = [];
for (var i = 0; i < that.columnCount; i++) {
obj.push({
x: i,
y: DataV.sum(_.pluck(remains, i), 'y')
});
}
return obj;
});
}
};
Stream.prototype.layout = function () {
var conf = this.defaults;
d3.layout.stack().offset(conf.offset).order(conf.order)(this.layoutData);
};
Stream.prototype.generateChartElements = function () {
var conf = this.defaults;
var paper = this.paper,
paths = [];
var area = this.generateArea();
var colorFunc = this.getColor();
// set div's background instread;
paper.rect(0, 0, conf.chartWidth, conf.chartHeight).attr({
"stroke": "none",
"fill": "#e0e0e0"
});
for (var i = 0, l = this.layoutData.length; i < l; i++) {
var areaString = area(this.pathSource[i]);
var color = colorFunc(i);
var path = paper.path(areaString).attr({
fill: color,
stroke: color,
"stroke-width": 1
});
paths[i] = path;
}
this.paths = paths;
};
Stream.prototype.render = function (animate) {
if (animate !== "animate") {
this.clear();
this.layout();
this.generateChartElements();
} else {
this.layout();
this.animate();
}
//hoverLine
this.hoverLine = this.own(new HoverLine());
this.hoverLine.render();//lines should be to front, so at last
//pathLabel
if (this.defaults.pathLabel) {
this.pathLabel = this.own(new PathLabel());
this.pathLabel.setSource(this.rawData, this.rawMap);
this.pathLabel.render();
}
this.createInteractive();
};
Stream.prototype.animate = function () {
var time = 0,
area,
colorFunc,
color,
i, l,
_area,
paths = [],
order,
anim,
count = this.paths.length;
var that = this;
var animateCallback = function () {
count -= 1;
if (count > 0) {
return;
}
that.animateCallback();
};
if (typeof this.defaults.animateDuration !== 'undefined') {
time = this.defaults.animateDuration;
}
// if paths have not been created
if (typeof this.paths === 'undefined') {
this.generateChartElements();
}
area = this.generateArea();
colorFunc = this.getColor();
if (typeof this.defaults.animateOrder !== 'undefined') {
order = this.defaults.animateOrder;
} else {
order = d3.range(this.pathSource.length);
}
for (i = 0, l = this.pathSource.length; i < l; i++) {
_area = area(this.pathSource[i]);
paths.push(_area);
}
for (i = 0, l = this.pathSource.length; i < l; i++) {
color = colorFunc(i);
anim = Raphael.animation({"path": paths[i]}, time, animateCallback);
this.paths[order[i]].animate(anim);
}
};
Stream.prototype.animateCallback = function () {
var newOrderPaths = [];
var that = this;
if (typeof this.defaults.animateOrder !== 'undefined') {
this.defaults.animateOrder.forEach(function (d, i) {
newOrderPaths[i] = that.paths[d];
});
this.paths = newOrderPaths;
}
};
Stream.prototype.clear = function () {
this.paper.clear();
};
Stream.prototype.getColor = function (colorJson) {
var colorMatrix = DataV.getColor();
var color;
var colorStyle = colorJson || {};
var colorMode = colorStyle.mode || 'default';
var i, l;
switch (colorMode) {
case "gradient":
l = this.source.length;
// 最大为 colorMatrix.length - 1
var colorL = Math.min(Math.round(l / 5), colorMatrix.length - 1);
var testColor = [colorMatrix[0][0], colorMatrix[colorL][0]];
var test1 = DataV.gradientColor(testColor, "special");
var testColorMatrix = [];
var testColorMatrix1 = [];
for (i = 0; i < l; i++) {
testColorMatrix.push([test1(i / (l - 1)), test1(i / (l - 1))]);
}
for (i = l - 1; i >= 0; i--) {
testColorMatrix1.push(testColorMatrix[i]);
}
colorMatrix = testColorMatrix;
break;
case "random":
case "default":
break;
}
var ratio = colorStyle.ratio || 0;
ratio = Math.max(ratio, 0);
ratio = Math.min(ratio, 1);
var colorArray = colorMatrix.map(function () {
return d3.interpolateRgb.apply(null, [colorMatrix[i][0], colorMatrix[i][1]])(ratio);
});
color = d3.scale.ordinal().range(colorArray);
return color;
};
/*
*/
Stream.prototype.getColor = function () {
var count = this.layoutData.length;
var color = this.defaults.gradientColor || ["#8be62f", "#1F4FD8"];
var gradientColor = DataV.gradientColor(color, "special");
var percent = 1 / count;
var gotColors = [];
for (var i = 0; i < count; i++) {
gotColors.push(gradientColor(i * percent));
}
var midderNum = Math.floor(count / 2);
return function (num) {
return num % 2 === 0 ? gotColors[midderNum + num / 2] : gotColors[midderNum - (num + 1) / 2];
};
};
Stream.prototype.getMaxY = function () {
return d3.max(this.layoutData, function (d) {
return d3.max(d, function (d) {
return d.y0 + d.y;
});
});
};
Stream.prototype.mapPathSource = function () {
var conf = this.defaults,
maxX = this.layoutData[0].length - 1,
maxY = this.getMaxY(),
width = conf.chartWidth,
height = conf.chartHeight;
this.pathSource = [];
for (var i = 0, l = this.layoutData.length; i < l; i++) {
this.pathSource[i] = [];
for (var j = 0, l2 = this.layoutData[0].length; j < l2; j++) {
var s = this.layoutData[i][j];
var ps = this.pathSource[i][j] = {};
ps.x = s.x * width / maxX;
ps.y0 = height - s.y0 * height / maxY;
ps.y = s.y * height / maxY;
}
}
};
Stream.prototype.generateArea = function () {
this.mapPathSource();
var area = d3.svg.area().x(function (d) {
return d.x;
}).y0(function (d) {
return d.y0;
}).y1(function (d) {
return d.y0 - d.y;
});
return area;
};
Stream.prototype.highlight = function (index) {
if (typeof index !== 'undefined') {
this.paths[index].attr({"opacity": 0.5, "stroke-width": 0});
}
};
Stream.prototype.lowlight = function (index) {
if (typeof index !== 'undefined') {
this.paths[index].attr({"opacity": 1, "stroke-width": 1});
}
};
Stream.prototype.createInteractive = function () {
$(this.paper.canvas).unbind();//prevent event rebind.
//refactor stream chart's animate function, especially change the callback
var stream = this;
this.animateCallback = function () {
var newOrderPaths = [];
var that = this;
if (typeof this.defaults.animateOrder !== 'undefined') {
this.defaults.animateOrder.forEach(function (d, i) {
newOrderPaths[i] = that.paths[d];
});
this.paths = newOrderPaths;
}
stream.cover.hidden();
if (typeof stream.cover.mouse !== 'undefined') {
stream.hoverLine.show();
stream.floatTag.show();
var mouse = stream.cover.mouse;
$(stream.paper.canvas).trigger("mousemove", [mouse.x, mouse.y]);
$(stream.floatTag).trigger("mousemove", [mouse.x, mouse.y]);
stream.cover.mouse = undefined;
}
stream.pathLabel.show();
};
//chart mouseenter
var mouseenter = function () {
stream.hoverLine.show();
stream.fire('enter');
};
//chart mouseleave
var mouseleave = function () {
stream.hoverLine.hidden();
//recover prepath;
if (typeof stream.preIndex !== 'undefined') {
stream.lowlight(stream.preIndex);
}
stream.fire('leave', stream.preIndex);
stream.preIndex = undefined;
};
//chart click
var click = function () {};
//chart mousemove
var mousemove = function (e, pageX, pageY) {
var offset = $(this).parent().offset();
var x = (e.pageX || pageX) - offset.left,
y = (e.pageY || pageY) - offset.top;
var pathSource = stream.pathSource,
rowIndex;
var columnIndex = Math.floor((x / (stream.defaults.chartWidth / (stream.columnCount - 1) / 2) + 1) / 2);
//get path and pathIndex
for (var i = 0, l = pathSource.length; i < l; i++) {
if (y >= pathSource[i][columnIndex].y0 - pathSource[i][columnIndex].y && y <= pathSource[i][columnIndex].y0) {
rowIndex = i;
break;
}
}
//recover prepath;
if (typeof stream.preIndex !== 'undefined') {
stream.lowlight(stream.preIndex);
}
stream.highlight(rowIndex);
stream.fire('move', stream.preIndex, rowIndex, columnIndex);
//set indicator and highlight line new position
stream.hoverLine.refresh(columnIndex, rowIndex);
//customevent;
if (stream.defaults.customEventHandle.mousemove) {
stream.defaults.customEventHandle.mousemove.call(stream,
{"timeIndex": columnIndex, "rowIndex": rowIndex});
}
//change new path;
stream.preIndex = rowIndex;
};
$(this.paper.canvas).bind("mouseenter", mouseenter)
.bind("mouseleave", mouseleave)
.bind("click", click)
.bind("mousemove", mousemove);
};
return Stream;
});
/*global $, define */
/*!
* Stream的兼容定义
*/
;(function (name, definition) {
if (typeof define === 'function') { // Module
define(definition);
} else { // Assign to common namespaces or simply the global object (window)
this[name] = definition(function (id) { return this[id];});
}
})('StreamComponent', function (require) {
var DataV = require('DataV');
var Legend = require('Legend');
var Navi = require('Navi');
var Percentage = require('Percentage');
var Axis = require('StreamAxis');
var Tip = require('Tip');
var Stream = require('Stream');
var Cover = require('Cover');
/*
* constructor
* @param node the dom node or dom node Id
* options options json object for determin stream style.
* @example
* create stream in a dom node with id "chart", width is 500; height is 600px;
* "chart", {"width": 500, "height": 600}
*/
var StreamComponent = DataV.extend(DataV.Chart, {
initialize: function (node, options) {
this.type = "Stream";
this.node = this.checkContainer(node);
this.defaults = {};
// Properties
this.defaults.offset = "zero";//zero, expand, silhou-ette, wiggle;(d3 stack offset)
this.defaults.order = "default";//default, reverse, descending, ascending, inside-out(d3 stack order, sort by index of maximum value, then use balanced weighting.), inside-out-reverse(inside-out like, sort by index of maximum value, not descending but ascending);
this.defaults.normalized = false;//false, true; //ratio data or not;
//this.defaults.rowDataOrder = "default"; //default, descending, ascending(according to digitdata row sum value);
this.defaults.columnNameUsed = "auto";
this.defaults.rowNameUsed = "auto";
this.defaults.pathLabel = true;
this.defaults.fontSize = 12;
this.defaults.colorCount = 20;
//this.defaults.axisTickNumber = 8; // axis ticks number
this.defaults.indexMargin = 3; // if dates.length < indexMargin * 2 + 1, do not show label
this.timeRange = [];
// paper
this.defaults.width = 800;
this.defaults.height = 560;//if only width has value and autoHeight is true, then height will be width * heightWidthRatio.
this.defaults.autoHeight = true;
this.defaults.heightWidthRatio = 0.6;
this.defaults.legendPosition = "top";//"top", "left"
this.defaults.topLegendHeight = 50;
this.defaults.leftLegendWidth = 150;
this.defaults.showLegend = true;
this.defaults.legendBesidesWidth = undefined;
this.defaults.legendBesidesHeight = undefined;
this.defaults.more = false;
this.defaults.moreLabel = "more";
this.defaults.max = 20;
this.defaults.level = 0;
this.defaults.chartWidth = undefined;//depends on width, do not recommend to change
this.defaults.chartHeight = undefined;// depends on height, do not recommend to change
this.defaults.naviHeight = 20;//do not recommend to change
this.defaults.showNavi = undefined;//ture if moreConfig.more == true, else false;
this.defaults.axisHeight = 30;//do not recommend to change
this.defaults.showAxis = true;
this.defaults.showPercentage = undefined;//true if moreConfig.more == true, else false;
this.defaults.percentageWidth = 40;
this.defaults.customEventHandle = {"mousemove": null};
this.defaults.tipStyle = {};
this.setOptions(options);
}
});
StreamComponent.prototype.init = function () {
var that = this;
var getBack = function () {
var naviCallBack = function () {
that.cover.hidden();
if (typeof that.cover.mouse !== 'undefined') {
that.hoverLine.show();
that.tip.show();
$(that.paper.canvas).trigger("mousemove",[that.cover.mouse.x, that.cover.mouse.y]);
that.cover.mouse = undefined;
}
that.pathLabel.show();
};
that.cover.show();
that.cover.mouse = undefined;
that.processData("slicedData");
that.render("renderComponents");
//hidden
that.hoverLine.hidden();
that.tip.hidden();
that.pathLabel.hidden();
that.paths.forEach(function (d) {
d.attr({transform: "s1,0.001,0,0"});
d.animate({transform: "t0,0"}, 750, "linear", naviCallBack);
});
};
that.on('changeLevelTo', function (level) {
that.defaults.level = level;
getBack(that.defaults.moreConfig.level);
});
that.on('back', function () {
that.defaults.level = that.defaults.level - 1;
getBack(that.defaults.level);
});
that.legend.on('hoverIn', function (index) {
that.stream.highlight(index);
}).on('hoverOut', function (index) {
that.stream.lowlight(index);
});
that.stream.on('enter', function () {
that.axis.showTab();
that.tip.show();
}).on('leave', function (index) {
that.axis.hideTab();
that.tip.hidden();
if (index !== undefined) {
that.legend.lowlight(index);
}
}).on('move', function (pre, rowIndex, columnIndex) {
if (pre !== undefined) {
that.legend.lowlight(pre);
}
if (typeof rowIndex === "undefined" || typeof columnIndex === "undefined") {
return;
}
that.legend.highlight(rowIndex);
that.tip.setContent(rowIndex, columnIndex);
//axis pop bubble
that.axis.refreshTab(columnIndex);
}).on('level_changed', function (start, end, needMore) {
that.legend.fire('level_changed', start, end, needMore);
});
};
StreamComponent.prototype.setSource = function (source, map) {
this.source = source;
this.map = map;
};
StreamComponent.prototype.layout = function () {
var conf = this.defaults;
if (!conf.showLegend) {
conf.legendBesidesWidth = conf.width;
conf.legendBesidesHeight = conf.height;
} else {
if (conf.legendPosition === "left") {
conf.legendBesidesWidth = conf.width - conf.leftLegendWidth;
conf.legendBesidesHeight = conf.height;
} else {
conf.legendBesidesWidth = conf.width;
conf.legendBesidesHeight = conf.height - conf.topLegendHeight;
}
}
conf.chartWidth = conf.legendBesidesWidth - 2 * conf.percentageWidth;
conf.chartHeight = conf.legendBesidesHeight - (conf.showNavi ? conf.naviHeight : 0) - (conf.showAxis ? conf.axisHeight : 0);
var node = $(this.node).css({
position: "relative",
width: conf.width
});
// 创建DOM节点
this.streamBox = $("<div></div>").addClass("stream");
this.legendBox = $("<div></div>").addClass("legend");
this.axisBox = $("<div></div>").addClass("axis");
this.naviBox = $("<div></div>").addClass("navi");
this.percentageBox = $("<div></div>").addClass("percentage");
this.container = $("<div></div>").addClass("container");
this.rightBox = $("<div></div>").addClass("right");
// cover can block stream paper when animating to prevent some default mouse event
this.coverBox = $("<div></div>").addClass("cover");
// 插入DOM
this.streamBox.append(this.coverBox);
this.container.append(this.percentageBox).append(this.streamBox);
this.rightBox.append(this.naviBox).append(this.container).append(this.axisBox);
node.append(this.legendBox).append(this.rightBox);
// 设置各个节点大小
this.streamBox.css({
"position": "relative",
"float": "left",
"width": conf.chartWidth,
"height": conf.chartHeight
});
this.percentageBox.css({
});
this.container.css({
"height": conf.chartHeight
});
this.rightBox.css({
"float": "right",
"width": conf.legendBesidesWidth
});
this.legendBox.css({
"width": conf.leftLegendWidth - 4,
"float": "left",
"overflowX": "hidden"
});
};
StreamComponent.prototype.draw = function () {
var conf = this.defaults;
//chart and paper
this.stream = this.own(new Stream(this.streamBox, {"width": conf.chartWidth, "height": conf.chartHeight}));
this.stream.setSource(this.source, this.map);
this.stream.render();
this.legend = this.own(new Legend.Legend(this.legendBox));
this.legend.setOptions({
"colorFunc": this.stream.getColor()
});
this.legend.setSource(this.source, this.map);
this.legend.render();
this.percentage = this.own(new Percentage(this.percentageBox));
this.percentage.setSource(this.source, this.map);
this.percentage.render();
this.axis = this.own(new Axis(this.axisBox));
this.axis.setSource(this.source, this.map);
this.axis.render();
this.navi = this.own(new Navi(this.naviBox));
this.navi.render();
// cover can block stream paper when animating to prevent some default mouse event
this.cover = this.own(new Cover(this.coverBox));
//floatTag
this.tip = this.own(new Tip(this.streamBox));
this.tip.setSource(this.source, this.map);
this.tip.render();
};
StreamComponent.prototype.render = function () {
this.layout();
this.draw();
this.init();
};
StreamComponent.prototype.setCustomEvent = function (eventName, callback) {
this.defaults.customEventHandle[eventName] = callback;
};
/*!
* 导出StreamComponent
*/
return StreamComponent;
});
| TBEDP/datavjs | build/stream_component.js | JavaScript | mit | 61,243 | [
30522,
1013,
1013,
6100,
9537,
2013,
1040,
2509,
1012,
1046,
2015,
1010,
5587,
1018,
4972,
1024,
16356,
19321,
2099,
1010,
16356,
18209,
19321,
2099,
1010,
3576,
26348,
19321,
2099,
1998,
5884,
19321,
2099,
1025,
1013,
1013,
8123,
1006,
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... |
java_import 'org.apollo.game.action.DistancedAction'
# A distanced action which opens a door.
class OpenDoorAction < DistancedAction
include DoorConstants
attr_reader :door
def initialize(mob, door)
super(0, true, mob, door.position, DOOR_SIZE)
@door = door
end
def executeAction
mob.turn_to(@door.position)
DoorUtil.toggle(@door)
stop
end
def equals(other)
get_class == other.get_class && @door == other.door
end
end
# MessageListener for opening and closing doors.
on :message, :first_object_action do |player, message|
if DoorUtil.door?(message.id)
door = DoorUtil.get_door_object(message.position, message.id)
player.start_action(OpenDoorAction.new(player, door)) unless door.nil?
end
end
| garyttierney/apollo | data/plugins/navigation/door/door.rb | Ruby | isc | 753 | [
30522,
9262,
1035,
12324,
1005,
8917,
1012,
9348,
1012,
2208,
1012,
2895,
1012,
3292,
2850,
7542,
1005,
1001,
1037,
3292,
2094,
2895,
2029,
7480,
1037,
2341,
1012,
2465,
2330,
23835,
18908,
3258,
1026,
3292,
2850,
7542,
2421,
2341,
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... |
/*
* Hello Minecraft! Launcher
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
*
* 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 <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.mod.server;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.GameBuilder;
import org.jackhuang.hmcl.game.DefaultGameRepository;
import org.jackhuang.hmcl.mod.ModpackConfiguration;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.util.gson.JsonUtils;
import org.jackhuang.hmcl.util.io.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ServerModpackRemoteInstallTask extends Task<Void> {
private final String name;
private final DefaultDependencyManager dependency;
private final DefaultGameRepository repository;
private final List<Task<?>> dependencies = new ArrayList<>(1);
private final List<Task<?>> dependents = new ArrayList<>(1);
private final ServerModpackManifest manifest;
public ServerModpackRemoteInstallTask(DefaultDependencyManager dependencyManager, ServerModpackManifest manifest, String name) {
this.name = name;
this.dependency = dependencyManager;
this.repository = dependencyManager.getGameRepository();
this.manifest = manifest;
File json = repository.getModpackConfiguration(name);
if (repository.hasVersion(name) && !json.exists())
throw new IllegalArgumentException("Version " + name + " already exists.");
GameBuilder builder = dependencyManager.gameBuilder().name(name);
for (ServerModpackManifest.Addon addon : manifest.getAddons()) {
builder.version(addon.getId(), addon.getVersion());
}
dependents.add(builder.buildAsync());
onDone().register(event -> {
if (event.isFailed())
repository.removeVersionFromDisk(name);
});
ModpackConfiguration<ServerModpackManifest> config = null;
try {
if (json.exists()) {
config = JsonUtils.GSON.fromJson(FileUtils.readText(json), new TypeToken<ModpackConfiguration<ServerModpackManifest>>() {
}.getType());
if (!MODPACK_TYPE.equals(config.getType()))
throw new IllegalArgumentException("Version " + name + " is not a Server modpack. Cannot update this version.");
}
} catch (JsonParseException | IOException ignore) {
}
}
@Override
public List<Task<?>> getDependents() {
return dependents;
}
@Override
public List<Task<?>> getDependencies() {
return dependencies;
}
@Override
public void execute() throws Exception {
dependencies.add(new ServerModpackCompletionTask(dependency, name, new ModpackConfiguration<>(manifest, MODPACK_TYPE, manifest.getName(), manifest.getVersion(), Collections.emptyList())));
}
public static final String MODPACK_TYPE = "Server";
}
| huanghongxun/HMCL | HMCLCore/src/main/java/org/jackhuang/hmcl/mod/server/ServerModpackRemoteInstallTask.java | Java | gpl-3.0 | 3,748 | [
30522,
1013,
1008,
1008,
7592,
3067,
10419,
999,
22742,
1008,
9385,
1006,
1039,
1007,
12609,
15469,
10513,
20552,
1026,
15469,
19991,
2595,
4609,
28332,
2620,
1030,
14010,
1012,
4012,
1028,
1998,
16884,
1008,
1008,
2023,
2565,
2003,
2489,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.inspector.objectinspector.view;
import com.general.view.jtreetable.TableTreeNode;
import com.inspector.objectinspector.presenter.ObjectInspectorPresenterInterface;
public interface ObjectInspectorViewInterface {
public void setController(ObjectInspectorPresenterInterface objectInspectorPresenter);
public void clearTable();
public TableTreeNode getRoot();
public void refreshTable();
public ObjectInspectorView getView() ;
}
| DiegoArranzGarcia/JavaTracer | JavaTracer/src/com/inspector/objectinspector/view/ObjectInspectorViewInterface.java | Java | gpl-2.0 | 450 | [
30522,
7427,
4012,
1012,
7742,
1012,
4874,
7076,
5051,
16761,
1012,
3193,
1025,
12324,
4012,
1012,
2236,
1012,
3193,
1012,
1046,
13334,
10880,
1012,
13855,
28029,
10244,
1025,
12324,
4012,
1012,
7742,
1012,
4874,
7076,
5051,
16761,
1012,
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... |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GTimeZone</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions">
<link rel="next" href="glib-GDateTime.html" title="GDateTime">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Date-and-Time-Functions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-GDateTime.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-GTimeZone.synopsis" class="shortcut">Top</a>
|
<a href="#glib-GTimeZone.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-GTimeZone"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-GTimeZone.top_of_page"></a>GTimeZone</span></h2>
<p>GTimeZone — a structure representing a time zone</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-GTimeZone.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <glib.h>
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone">GTimeZone</a>;
<span class="returnvalue">void</span> <a class="link" href="glib-GTimeZone.html#g-time-zone-unref" title="g_time_zone_unref ()">g_time_zone_unref</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>);
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * <a class="link" href="glib-GTimeZone.html#g-time-zone-ref" title="g_time_zone_ref ()">g_time_zone_ref</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>);
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * <a class="link" href="glib-GTimeZone.html#g-time-zone-new" title="g_time_zone_new ()">g_time_zone_new</a> (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *identifier</code></em>);
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * <a class="link" href="glib-GTimeZone.html#g-time-zone-new-local" title="g_time_zone_new_local ()">g_time_zone_new_local</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * <a class="link" href="glib-GTimeZone.html#g-time-zone-new-utc" title="g_time_zone_new_utc ()">g_time_zone_new_utc</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
enum <a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType">GTimeType</a>;
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> <a class="link" href="glib-GTimeZone.html#g-time-zone-find-interval" title="g_time_zone_find_interval ()">g_time_zone_find_interval</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> type</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> time_</code></em>);
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> <a class="link" href="glib-GTimeZone.html#g-time-zone-adjust-time" title="g_time_zone_adjust_time ()">g_time_zone_adjust_time</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> type</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> *time_</code></em>);
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="glib-GTimeZone.html#g-time-zone-get-abbreviation" title="g_time_zone_get_abbreviation ()">g_time_zone_get_abbreviation</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);
<a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a> <a class="link" href="glib-GTimeZone.html#g-time-zone-get-offset" title="g_time_zone_get_offset ()">g_time_zone_get_offset</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="glib-GTimeZone.html#g-time-zone-is-dst" title="g_time_zone_is_dst ()">g_time_zone_is_dst</a> (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="glib-GTimeZone.description"></a><h2>Description</h2>
<p>
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> is a structure that represents a time zone, at no
particular point in time. It is refcounted and immutable.
</p>
<p>
A time zone contains a number of intervals. Each interval has
an abbreviation to describe it, an offet to UTC and a flag indicating
if the daylight savings time is in effect during that interval. A
time zone always has at least one interval -- interval 0.
</p>
<p>
Every UTC time is contained within exactly one interval, but a given
local time may be contained within zero, one or two intervals (due to
incontinuities associated with daylight savings time).
</p>
<p>
An interval may refer to a specific period of time (eg: the duration
of daylight savings time during 2010) or it may refer to many periods
of time that share the same properties (eg: all periods of daylight
savings time). It is also possible (usually for political reasons)
that some properties (like the abbreviation) change between intervals
without other properties changing.
</p>
<p>
<a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> is available since GLib 2.26.
</p>
</div>
<div class="refsect1">
<a name="glib-GTimeZone.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GTimeZone"></a><h3>GTimeZone</h3>
<pre class="programlisting">typedef struct _GTimeZone GTimeZone;</pre>
<p>
<a class="link" href="glib-GDateTime.html#GDateTime" title="GDateTime"><span class="type">GDateTime</span></a> is an opaque structure whose members cannot be accessed
directly.
</p>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-unref"></a><h3>g_time_zone_unref ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> g_time_zone_unref (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>);</pre>
<p>
Decreases the reference count on <em class="parameter"><code>tz</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-ref"></a><h3>g_time_zone_ref ()</h3>
<pre class="programlisting"><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * g_time_zone_ref (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>);</pre>
<p>
Increases the reference count on <em class="parameter"><code>tz</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new reference to <em class="parameter"><code>tz</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-new"></a><h3>g_time_zone_new ()</h3>
<pre class="programlisting"><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * g_time_zone_new (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *identifier</code></em>);</pre>
<p>
Creates a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> corresponding to <em class="parameter"><code>identifier</code></em>.
</p>
<p>
<em class="parameter"><code>identifier</code></em> can either be an RFC3339/ISO 8601 time offset or
something that would pass as a valid value for the
<code class="varname">TZ</code> environment variable (including <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>).
</p>
<p>
Valid RFC3339 time offsets are <code class="literal">"Z"</code> (for UTC) or
<code class="literal">"±hh:mm"</code>. ISO 8601 additionally specifies
<code class="literal">"±hhmm"</code> and <code class="literal">"±hh"</code>.
</p>
<p>
The <code class="varname">TZ</code> environment variable typically corresponds
to the name of a file in the zoneinfo database, but there are many
other possibilities. Note that those other possibilities are not
currently implemented, but are planned.
</p>
<p>
<a class="link" href="glib-GTimeZone.html#g-time-zone-new-local" title="g_time_zone_new_local ()"><code class="function">g_time_zone_new_local()</code></a> calls this function with the value of the
<code class="varname">TZ</code> environment variable. This function itself is
independent of the value of <code class="varname">TZ</code>, but if <em class="parameter"><code>identifier</code></em>
is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> then <code class="filename">/etc/localtime</code> will be consulted
to discover the correct timezone.
</p>
<p>
See <a class="ulink" href="http://tools.ietf.org/html/rfc3339#section-5.6" target="_top">RFC3339
§5.6</a> for a precise definition of valid RFC3339 time offsets
(the <code class="varname">time-offset</code> expansion) and ISO 8601 for the
full list of valid time offsets. See <a class="ulink" href="http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html" target="_top">The
GNU C Library manual</a> for an explanation of the possible
values of the <code class="varname">TZ</code> environment variable.
</p>
<p>
You should release the return value by calling <a class="link" href="glib-GTimeZone.html#g-time-zone-unref" title="g_time_zone_unref ()"><code class="function">g_time_zone_unref()</code></a>
when you are done with it.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>identifier</code></em> :</span></p></td>
<td>a timezone identifier. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the requested timezone</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-new-local"></a><h3>g_time_zone_new_local ()</h3>
<pre class="programlisting"><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * g_time_zone_new_local (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Creates a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> corresponding to local time. The local time
zone may change between invocations to this function; for example,
if the system administrator changes it.
</p>
<p>
This is equivalent to calling <a class="link" href="glib-GTimeZone.html#g-time-zone-new" title="g_time_zone_new ()"><code class="function">g_time_zone_new()</code></a> with the value of the
<code class="varname">TZ</code> environment variable (including the possibility
of <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>).
</p>
<p>
You should release the return value by calling <a class="link" href="glib-GTimeZone.html#g-time-zone-unref" title="g_time_zone_unref ()"><code class="function">g_time_zone_unref()</code></a>
when you are done with it.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the local timezone</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-new-utc"></a><h3>g_time_zone_new_utc ()</h3>
<pre class="programlisting"><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="returnvalue">GTimeZone</span></a> * g_time_zone_new_utc (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Creates a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> corresponding to UTC.
</p>
<p>
This is equivalent to calling <a class="link" href="glib-GTimeZone.html#g-time-zone-new" title="g_time_zone_new ()"><code class="function">g_time_zone_new()</code></a> with a value like
"Z", "UTC", "+00", etc.
</p>
<p>
You should release the return value by calling <a class="link" href="glib-GTimeZone.html#g-time-zone-unref" title="g_time_zone_unref ()"><code class="function">g_time_zone_unref()</code></a>
when you are done with it.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the universal timezone</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="GTimeType"></a><h3>enum GTimeType</h3>
<pre class="programlisting">typedef enum {
G_TIME_TYPE_STANDARD,
G_TIME_TYPE_DAYLIGHT,
G_TIME_TYPE_UNIVERSAL
} GTimeType;
</pre>
<p>
Disambiguates a given time in two ways.
</p>
<p>
First, specifies if the given time is in universal or local time.
</p>
<p>
Second, if the time is in local time, specifies if it is local
standard time or local daylight time. This is important for the case
where the same local time occurs twice (during daylight savings time
transitions, for example).
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><a name="G-TIME-TYPE-STANDARD:CAPS"></a><span class="term"><code class="literal">G_TIME_TYPE_STANDARD</code></span></p></td>
<td>the time is in local standard time
</td>
</tr>
<tr>
<td><p><a name="G-TIME-TYPE-DAYLIGHT:CAPS"></a><span class="term"><code class="literal">G_TIME_TYPE_DAYLIGHT</code></span></p></td>
<td>the time is in local daylight time
</td>
</tr>
<tr>
<td><p><a name="G-TIME-TYPE-UNIVERSAL:CAPS"></a><span class="term"><code class="literal">G_TIME_TYPE_UNIVERSAL</code></span></p></td>
<td>the time is in UTC
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-find-interval"></a><h3>g_time_zone_find_interval ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> g_time_zone_find_interval (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> type</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> time_</code></em>);</pre>
<p>
Finds an the interval within <em class="parameter"><code>tz</code></em> that corresponds to the given <em class="parameter"><code>time_</code></em>.
The meaning of <em class="parameter"><code>time_</code></em> depends on <em class="parameter"><code>type</code></em>.
</p>
<p>
If <em class="parameter"><code>type</code></em> is <a class="link" href="glib-GTimeZone.html#G-TIME-TYPE-UNIVERSAL:CAPS"><code class="literal">G_TIME_TYPE_UNIVERSAL</code></a> then this function will always
succeed (since universal time is monotonic and continuous).
</p>
<p>
Otherwise <em class="parameter"><code>time_</code></em> is treated is local time. The distinction between
<a class="link" href="glib-GTimeZone.html#G-TIME-TYPE-STANDARD:CAPS"><code class="literal">G_TIME_TYPE_STANDARD</code></a> and <a class="link" href="glib-GTimeZone.html#G-TIME-TYPE-DAYLIGHT:CAPS"><code class="literal">G_TIME_TYPE_DAYLIGHT</code></a> is ignored except in
the case that the given <em class="parameter"><code>time_</code></em> is ambiguous. In Toronto, for example,
01:30 on November 7th 2010 occurred twice (once inside of daylight
savings time and the next, an hour later, outside of daylight savings
time). In this case, the different value of <em class="parameter"><code>type</code></em> would result in a
different interval being returned.
</p>
<p>
It is still possible for this function to fail. In Toronto, for
example, 02:00 on March 14th 2010 does not exist (due to the leap
forward to begin daylight savings time). -1 is returned in that
case.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the <a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> of <em class="parameter"><code>time_</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>time_</code></em> :</span></p></td>
<td>a number of seconds since January 1, 1970</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the interval containing <em class="parameter"><code>time_</code></em>, or -1 in case of failure</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-adjust-time"></a><h3>g_time_zone_adjust_time ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> g_time_zone_adjust_time (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> type</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> *time_</code></em>);</pre>
<p>
Finds an interval within <em class="parameter"><code>tz</code></em> that corresponds to the given <em class="parameter"><code>time_</code></em>,
possibly adjusting <em class="parameter"><code>time_</code></em> if required to fit into an interval.
The meaning of <em class="parameter"><code>time_</code></em> depends on <em class="parameter"><code>type</code></em>.
</p>
<p>
This function is similar to <a class="link" href="glib-GTimeZone.html#g-time-zone-find-interval" title="g_time_zone_find_interval ()"><code class="function">g_time_zone_find_interval()</code></a>, with the
difference that it always succeeds (by making the adjustments
described below).
</p>
<p>
In any of the cases where <a class="link" href="glib-GTimeZone.html#g-time-zone-find-interval" title="g_time_zone_find_interval ()"><code class="function">g_time_zone_find_interval()</code></a> succeeds then
this function returns the same value, without modifying <em class="parameter"><code>time_</code></em>.
</p>
<p>
This function may, however, modify <em class="parameter"><code>time_</code></em> in order to deal with
non-existent times. If the non-existent local <em class="parameter"><code>time_</code></em> of 02:30 were
requested on March 14th 2010 in Toronto then this function would
adjust <em class="parameter"><code>time_</code></em> to be 03:00 and return the interval containing the
adjusted time.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
<td>the <a class="link" href="glib-GTimeZone.html#GTimeType" title="enum GTimeType"><span class="type">GTimeType</span></a> of <em class="parameter"><code>time_</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>time_</code></em> :</span></p></td>
<td>a pointer to a number of seconds since January 1, 1970</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the interval containing <em class="parameter"><code>time_</code></em>, never -1</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-get-abbreviation"></a><h3>g_time_zone_get_abbreviation ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * g_time_zone_get_abbreviation (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);</pre>
<p>
Determines the time zone abbreviation to be used during a particular
<em class="parameter"><code>interval</code></em> of time in the time zone <em class="parameter"><code>tz</code></em>.
</p>
<p>
For example, in Toronto this is currently "EST" during the winter
months and "EDT" during the summer months when daylight savings time
is in effect.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>an interval within the timezone</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the time zone abbreviation, which belongs to <em class="parameter"><code>tz</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-get-offset"></a><h3>g_time_zone_get_offset ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="returnvalue">gint32</span></a> g_time_zone_get_offset (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);</pre>
<p>
Determines the offset to UTC in effect during a particular <em class="parameter"><code>interval</code></em>
of time in the time zone <em class="parameter"><code>tz</code></em>.
</p>
<p>
The offset is the number of seconds that you add to UTC time to
arrive at local time for <em class="parameter"><code>tz</code></em> (ie: negative numbers for time zones
west of GMT, positive numbers for east).
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>an interval within the timezone</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the number of seconds that should be added to UTC to get the
local time in <em class="parameter"><code>tz</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
<hr>
<div class="refsect2">
<a name="g-time-zone-is-dst"></a><h3>g_time_zone_is_dst ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> g_time_zone_is_dst (<em class="parameter"><code><a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a> *tz</code></em>,
<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> interval</code></em>);</pre>
<p>
Determines if daylight savings time is in effect during a particular
<em class="parameter"><code>interval</code></em> of time in the time zone <em class="parameter"><code>tz</code></em>.
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>tz</code></em> :</span></p></td>
<td>a <a class="link" href="glib-GTimeZone.html#GTimeZone" title="GTimeZone"><span class="type">GTimeZone</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>an interval within the timezone</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if daylight savings time is in effect</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.26</p>
</div>
</div>
<div class="refsect1">
<a name="glib-GTimeZone.see-also"></a><h2>See Also</h2>
<a class="link" href="glib-GDateTime.html#GDateTime" title="GDateTime"><span class="type">GDateTime</span></a>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html> | jonnyniv/boost_converter | host/gui/GTK+/share/gtk-doc/html/glib/glib-GTimeZone.html | HTML | apache-2.0 | 31,659 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/** Get all roles */
$authManager = Yii::$app->authManager;
?>
<div class="user-assignment-form">
<?php $form = ActiveForm::begin(); ?>
<?= Html::activeHiddenInput($formModel, 'userId')?>
<label class="control-label"><?=$formModel->attributeLabels()['roles']?></label>
<input type="hidden" name="AssignmentForm[roles]" value="">
<table class="table table-striped table-bordered detail-view">
<thead>
<tr>
<th style="width:1px"></th>
<th style="width:150px">Name</th>
<th>Description</th>
</tr>
<tbody>
<?php foreach ($authManager->getRoles() as $role): ?>
<tr>
<?php
$checked = true;
if($formModel->roles==null||!is_array($formModel->roles)||count($formModel->roles)==0){
$checked = false;
}else if(!in_array($role->name, $formModel->roles) ){
$checked = false;
}
?>
<td><input <?= $checked? "checked":"" ?> type="checkbox" name="AssignmentForm[roles][]" value="<?= $role->name?>"></td>
<td><?= $role->name ?></td>
<td><?= $role->description ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!Yii::$app->request->isAjax) { ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('rbac', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php } ?>
<?php ActiveForm::end(); ?>
</div>
| bara-artur/mailtousacom | modules/user/views/admin/assignment.php | PHP | bsd-3-clause | 1,440 | [
30522,
1026,
1029,
25718,
2224,
12316,
2072,
1032,
2393,
2545,
1032,
16129,
1025,
2224,
12316,
2072,
1032,
15536,
28682,
1032,
3161,
14192,
1025,
1013,
1008,
1008,
2131,
2035,
4395,
1008,
1013,
1002,
8740,
2705,
24805,
4590,
1027,
12316,
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
namespace PJM\AppBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use PJM\AppBundle\Entity\Event\Invitation;
class LoadInvitationData extends BaseFixture implements OrderedFixtureInterface
{
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$users = array('ancien', 'ancienne', 'p3', 'conscrit');
$events = array('Nuit des Fignos', 'Bap\'s des 215', 'Apéro Phy\'sbook');
foreach ($events as $event) {
foreach ($users as $user) {
$this->loadInvitation(
$manager,
$event,
$user
);
}
}
$manager->flush();
}
private function loadInvitation(ObjectManager $manager, $event, $invite)
{
$invitation = new Invitation();
$invitation->setEvent($this->getEvenement($event));
$invitation->setInvite($this->getUser($invite));
$presence = rand(0, 3) ? rand(0, 1) : null;
$invitation->setEstPresent($presence);
$manager->persist($invitation);
}
/**
* {@inheritdoc}
*/
public function getOrder()
{
return 4;
}
}
| Minishlink/physbook | src/PJM/AppBundle/DataFixtures/ORM/LoadInvitationData.php | PHP | gpl-3.0 | 1,289 | [
30522,
1026,
1029,
25718,
3415,
15327,
1052,
24703,
1032,
10439,
27265,
2571,
1032,
2951,
8873,
18413,
14900,
1032,
2030,
2213,
1025,
2224,
8998,
1032,
2691,
1032,
2951,
8873,
18413,
14900,
1032,
3641,
8873,
18413,
5397,
18447,
2121,
12172,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*
* kernel/sched/debug.c
*
* Print the CFS rbtree
*
* Copyright(C) 2007, Red Hat, Inc., Ingo Molnar
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/kallsyms.h>
#include <linux/utsname.h>
#include "sched.h"
static DEFINE_SPINLOCK(sched_debug_lock);
/*
* This allows printing both to /proc/sched_debug and
* to the console
*/
#define SEQ_printf(m, x...) \
do { \
if (m) \
seq_printf(m, x); \
else \
printk(x); \
} while (0)
/*
* Ease the printing of nsec fields:
*/
static long long nsec_high(unsigned long long nsec)
{
if ((long long)nsec < 0) {
nsec = -nsec;
do_div(nsec, 1000000);
return -nsec;
}
do_div(nsec, 1000000);
return nsec;
}
static unsigned long nsec_low(unsigned long long nsec)
{
if ((long long)nsec < 0)
nsec = -nsec;
return do_div(nsec, 1000000);
}
#define SPLIT_NS(x) nsec_high(x), nsec_low(x)
#ifdef CONFIG_FAIR_GROUP_SCHED
static void print_cfs_group_stats(struct seq_file *m, int cpu, struct task_group *tg)
{
struct sched_entity *se = tg->se[cpu];
#define P(F) \
SEQ_printf(m, " .%-30s: %lld\n", #F, (long long)F)
#define PN(F) \
SEQ_printf(m, " .%-30s: %lld.%06ld\n", #F, SPLIT_NS((long long)F))
if (!se) {
struct sched_avg *avg = &cpu_rq(cpu)->avg;
P(avg->runnable_avg_sum);
P(avg->runnable_avg_period);
return;
}
PN(se->exec_start);
PN(se->vruntime);
PN(se->sum_exec_runtime);
#ifdef CONFIG_SCHEDSTATS
PN(se->statistics.wait_start);
PN(se->statistics.sleep_start);
PN(se->statistics.block_start);
PN(se->statistics.sleep_max);
PN(se->statistics.block_max);
PN(se->statistics.exec_max);
PN(se->statistics.slice_max);
PN(se->statistics.wait_max);
PN(se->statistics.wait_sum);
P(se->statistics.wait_count);
#endif
P(se->load.weight);
#ifdef CONFIG_SMP
P(se->avg.runnable_avg_sum);
P(se->avg.runnable_avg_period);
P(se->avg.usage_avg_sum);
P(se->avg.load_avg_contrib);
P(se->avg.decay_count);
#endif
#undef PN
#undef P
}
#endif
#ifdef CONFIG_CGROUP_SCHED
static char group_path[PATH_MAX];
static char *task_group_path(struct task_group *tg)
{
if (autogroup_path(tg, group_path, PATH_MAX))
return group_path;
cgroup_path(tg->css.cgroup, group_path, PATH_MAX);
return group_path;
}
#endif
static void
print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
{
if (rq->curr == p)
SEQ_printf(m, "R");
else
SEQ_printf(m, " ");
SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
p->comm, p->pid,
SPLIT_NS(p->se.vruntime),
(long long)(p->nvcsw + p->nivcsw),
p->prio);
#ifdef CONFIG_SCHEDSTATS
SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld",
SPLIT_NS(p->se.vruntime),
SPLIT_NS(p->se.sum_exec_runtime),
SPLIT_NS(p->se.statistics.sum_sleep_runtime));
#else
SEQ_printf(m, "%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld",
0LL, 0LL, 0LL, 0L, 0LL, 0L, 0LL, 0L);
#endif
#ifdef CONFIG_CGROUP_SCHED
SEQ_printf(m, " %s", task_group_path(task_group(p)));
#endif
SEQ_printf(m, "\n");
}
static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
{
struct task_struct *g, *p;
unsigned long flags;
SEQ_printf(m,
"\nrunnable tasks:\n"
" task PID tree-key switches prio"
" exec-runtime sum-exec sum-sleep\n"
"------------------------------------------------------"
"----------------------------------------------------\n");
read_lock_irqsave(&tasklist_lock, flags);
do_each_thread(g, p) {
if (!p->on_rq || task_cpu(p) != rq_cpu)
continue;
print_task(m, rq, p);
} while_each_thread(g, p);
read_unlock_irqrestore(&tasklist_lock, flags);
}
void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
spread, rq0_min_vruntime, spread0;
struct rq *rq = cpu_rq(cpu);
struct sched_entity *last;
unsigned long flags;
#ifdef CONFIG_FAIR_GROUP_SCHED
SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg));
#else
SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu);
#endif
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock",
SPLIT_NS(cfs_rq->exec_clock));
#if defined(CONFIG_SEC_DEBUG_TRYLOCK_RQLOCK_AND_SKIP)
if (!raw_spin_trylock_irqsave(&rq->lock, flags))
return;
#else
raw_spin_lock_irqsave(&rq->lock, flags);
#endif
if (cfs_rq->rb_leftmost)
MIN_vruntime = (__pick_first_entity(cfs_rq))->vruntime;
last = __pick_last_entity(cfs_rq);
if (last)
max_vruntime = last->vruntime;
min_vruntime = cfs_rq->min_vruntime;
rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
raw_spin_unlock_irqrestore(&rq->lock, flags);
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
SPLIT_NS(MIN_vruntime));
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "min_vruntime",
SPLIT_NS(min_vruntime));
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "max_vruntime",
SPLIT_NS(max_vruntime));
spread = max_vruntime - MIN_vruntime;
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread",
SPLIT_NS(spread));
spread0 = min_vruntime - rq0_min_vruntime;
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "spread0",
SPLIT_NS(spread0));
SEQ_printf(m, " .%-30s: %d\n", "nr_spread_over",
cfs_rq->nr_spread_over);
SEQ_printf(m, " .%-30s: %d\n", "nr_running", cfs_rq->nr_running);
SEQ_printf(m, " .%-30s: %ld\n", "load", cfs_rq->load.weight);
#ifdef CONFIG_FAIR_GROUP_SCHED
#ifdef CONFIG_SMP
SEQ_printf(m, " .%-30s: %ld\n", "runnable_load_avg",
cfs_rq->runnable_load_avg);
SEQ_printf(m, " .%-30s: %ld\n", "blocked_load_avg",
cfs_rq->blocked_load_avg);
SEQ_printf(m, " .%-30s: %lld\n", "tg_load_avg",
(unsigned long long)atomic64_read(&cfs_rq->tg->load_avg));
SEQ_printf(m, " .%-30s: %lld\n", "tg_load_contrib",
cfs_rq->tg_load_contrib);
SEQ_printf(m, " .%-30s: %d\n", "tg_runnable_contrib",
cfs_rq->tg_runnable_contrib);
SEQ_printf(m, " .%-30s: %d\n", "tg->runnable_avg",
atomic_read(&cfs_rq->tg->runnable_avg));
SEQ_printf(m, " .%-30s: %d\n", "tg->usage_avg",
atomic_read(&cfs_rq->tg->usage_avg));
#endif
#ifdef CONFIG_CFS_BANDWIDTH
SEQ_printf(m, " .%-30s: %d\n", "tg->cfs_bandwidth.timer_active",
cfs_rq->tg->cfs_bandwidth.timer_active);
SEQ_printf(m, " .%-30s: %d\n", "throttled",
cfs_rq->throttled);
SEQ_printf(m, " .%-30s: %d\n", "throttle_count",
cfs_rq->throttle_count);
#endif
print_cfs_group_stats(m, cpu, cfs_rq->tg);
#endif
}
void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)
{
#ifdef CONFIG_RT_GROUP_SCHED
SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg));
#else
SEQ_printf(m, "\nrt_rq[%d]:\n", cpu);
#endif
#define P(x) \
SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rt_rq->x))
#define PN(x) \
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rt_rq->x))
P(rt_nr_running);
P(rt_throttled);
PN(rt_time);
PN(rt_runtime);
#undef PN
#undef P
}
extern __read_mostly int sched_clock_running;
static void print_cpu(struct seq_file *m, int cpu)
{
struct rq *rq = cpu_rq(cpu);
unsigned long flags;
#ifdef CONFIG_X86
{
unsigned int freq = cpu_khz ? : 1;
SEQ_printf(m, "cpu#%d, %u.%03u MHz\n",
cpu, freq / 1000, (freq % 1000));
}
#else
SEQ_printf(m, "cpu#%d\n", cpu);
#endif
#define P(x) \
do { \
if (sizeof(rq->x) == 4) \
SEQ_printf(m, " .%-30s: %ld\n", #x, (long)(rq->x)); \
else \
SEQ_printf(m, " .%-30s: %Ld\n", #x, (long long)(rq->x));\
} while (0)
#define PN(x) \
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", #x, SPLIT_NS(rq->x))
P(nr_running);
SEQ_printf(m, " .%-30s: %d.%03d \n", "ave_nr_running",
rq->ave_nr_running / FIXED_1,
((rq->ave_nr_running % FIXED_1) * 1000) / FIXED_1);
SEQ_printf(m, " .%-30s: %lu\n", "load",
rq->load.weight);
P(nr_switches);
P(nr_load_updates);
P(nr_uninterruptible);
PN(next_balance);
P(curr->pid);
PN(clock);
P(cpu_load[0]);
P(cpu_load[1]);
P(cpu_load[2]);
P(cpu_load[3]);
P(cpu_load[4]);
#undef P
#undef PN
#ifdef CONFIG_SCHEDSTATS
#define P(n) SEQ_printf(m, " .%-30s: %d\n", #n, rq->n);
#define P64(n) SEQ_printf(m, " .%-30s: %Ld\n", #n, rq->n);
P(yld_count);
P(yield_sleep_count);
P(sched_count);
P(sched_goidle);
#ifdef CONFIG_SMP
P64(avg_idle);
#endif
P(ttwu_count);
P(ttwu_local);
#undef P
#undef P64
#endif
spin_lock_irqsave(&sched_debug_lock, flags);
print_cfs_stats(m, cpu);
print_rt_stats(m, cpu);
rcu_read_lock();
print_rq(m, rq, cpu);
rcu_read_unlock();
spin_unlock_irqrestore(&sched_debug_lock, flags);
SEQ_printf(m, "\n");
}
static const char *sched_tunable_scaling_names[] = {
"none",
"logaritmic",
"linear"
};
static void sched_debug_header(struct seq_file *m)
{
u64 ktime, sched_clk, cpu_clk;
unsigned long flags;
local_irq_save(flags);
ktime = ktime_to_ns(ktime_get());
sched_clk = sched_clock();
cpu_clk = local_clock();
local_irq_restore(flags);
SEQ_printf(m, "Sched Debug Version: v0.10, %s %.*s\n",
init_utsname()->release,
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version);
#define P(x) \
SEQ_printf(m, "%-40s: %Ld\n", #x, (long long)(x))
#define PN(x) \
SEQ_printf(m, "%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
PN(ktime);
PN(sched_clk);
PN(cpu_clk);
P(jiffies);
#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
P(sched_clock_stable);
#endif
#undef PN
#undef P
SEQ_printf(m, "\n");
SEQ_printf(m, "sysctl_sched\n");
#define P(x) \
SEQ_printf(m, " .%-40s: %Ld\n", #x, (long long)(x))
#define PN(x) \
SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
PN(sysctl_sched_latency);
PN(sysctl_sched_min_granularity);
PN(sysctl_sched_wakeup_granularity);
P(sysctl_sched_child_runs_first);
P(sysctl_sched_features);
#undef PN
#undef P
SEQ_printf(m, " .%-40s: %d (%s)\n",
"sysctl_sched_tunable_scaling",
sysctl_sched_tunable_scaling,
sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
SEQ_printf(m, "\n");
}
static int sched_debug_show(struct seq_file *m, void *v)
{
int cpu = (unsigned long)(v - 2);
if (cpu != -1)
print_cpu(m, cpu);
else
sched_debug_header(m);
return 0;
}
void sysrq_sched_debug_show(void)
{
int cpu;
sched_debug_header(NULL);
for_each_online_cpu(cpu)
print_cpu(NULL, cpu);
}
/*
* This itererator needs some explanation.
* It returns 1 for the header position.
* This means 2 is cpu 0.
* In a hotplugged system some cpus, including cpu 0, may be missing so we have
* to use cpumask_* to iterate over the cpus.
*/
static void *sched_debug_start(struct seq_file *file, loff_t *offset)
{
unsigned long n = *offset;
if (n == 0)
return (void *) 1;
n--;
if (n > 0)
n = cpumask_next(n - 1, cpu_online_mask);
else
n = cpumask_first(cpu_online_mask);
*offset = n + 1;
if (n < nr_cpu_ids)
return (void *)(unsigned long)(n + 2);
return NULL;
}
static void *sched_debug_next(struct seq_file *file, void *data, loff_t *offset)
{
(*offset)++;
return sched_debug_start(file, offset);
}
static void sched_debug_stop(struct seq_file *file, void *data)
{
}
static const struct seq_operations sched_debug_sops = {
.start = sched_debug_start,
.next = sched_debug_next,
.stop = sched_debug_stop,
.show = sched_debug_show,
};
static int sched_debug_release(struct inode *inode, struct file *file)
{
seq_release(inode, file);
return 0;
}
static int sched_debug_open(struct inode *inode, struct file *filp)
{
int ret = 0;
ret = seq_open(filp, &sched_debug_sops);
return ret;
}
static const struct file_operations sched_debug_fops = {
.open = sched_debug_open,
.read = seq_read,
.llseek = seq_lseek,
.release = sched_debug_release,
};
static int __init init_sched_debug_procfs(void)
{
struct proc_dir_entry *pe;
pe = proc_create("sched_debug", 0444, NULL, &sched_debug_fops);
if (!pe)
return -ENOMEM;
return 0;
}
__initcall(init_sched_debug_procfs);
void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
{
unsigned long nr_switches;
SEQ_printf(m, "%s (%d, #threads: %d)\n", p->comm, p->pid,
get_nr_threads(p));
SEQ_printf(m,
"---------------------------------------------------------\n");
#define __P(F) \
SEQ_printf(m, "%-35s:%21Ld\n", #F, (long long)F)
#define P(F) \
SEQ_printf(m, "%-35s:%21Ld\n", #F, (long long)p->F)
#define __PN(F) \
SEQ_printf(m, "%-35s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)F))
#define PN(F) \
SEQ_printf(m, "%-35s:%14Ld.%06ld\n", #F, SPLIT_NS((long long)p->F))
PN(se.exec_start);
PN(se.vruntime);
PN(se.sum_exec_runtime);
nr_switches = p->nvcsw + p->nivcsw;
#ifdef CONFIG_SCHEDSTATS
PN(se.statistics.wait_start);
PN(se.statistics.sleep_start);
PN(se.statistics.block_start);
PN(se.statistics.sleep_max);
PN(se.statistics.block_max);
PN(se.statistics.exec_max);
PN(se.statistics.slice_max);
PN(se.statistics.wait_max);
PN(se.statistics.wait_sum);
P(se.statistics.wait_count);
PN(se.statistics.iowait_sum);
P(se.statistics.iowait_count);
P(se.nr_migrations);
P(se.statistics.nr_migrations_cold);
P(se.statistics.nr_failed_migrations_affine);
P(se.statistics.nr_failed_migrations_running);
P(se.statistics.nr_failed_migrations_hot);
P(se.statistics.nr_forced_migrations);
P(se.statistics.nr_wakeups);
P(se.statistics.nr_wakeups_sync);
P(se.statistics.nr_wakeups_migrate);
P(se.statistics.nr_wakeups_local);
P(se.statistics.nr_wakeups_remote);
P(se.statistics.nr_wakeups_affine);
P(se.statistics.nr_wakeups_affine_attempts);
P(se.statistics.nr_wakeups_passive);
P(se.statistics.nr_wakeups_idle);
{
u64 avg_atom, avg_per_cpu;
avg_atom = p->se.sum_exec_runtime;
if (nr_switches)
avg_atom = div64_ul(avg_atom, nr_switches);
else
avg_atom = -1LL;
avg_per_cpu = p->se.sum_exec_runtime;
if (p->se.nr_migrations) {
avg_per_cpu = div64_u64(avg_per_cpu,
p->se.nr_migrations);
} else {
avg_per_cpu = -1LL;
}
__PN(avg_atom);
__PN(avg_per_cpu);
}
#endif
__P(nr_switches);
SEQ_printf(m, "%-35s:%21Ld\n",
"nr_voluntary_switches", (long long)p->nvcsw);
SEQ_printf(m, "%-35s:%21Ld\n",
"nr_involuntary_switches", (long long)p->nivcsw);
P(se.load.weight);
#if defined(CONFIG_SMP) && defined(CONFIG_FAIR_GROUP_SCHED)
P(se.avg.runnable_avg_sum);
P(se.avg.runnable_avg_period);
P(se.avg.load_avg_contrib);
P(se.avg.decay_count);
#endif
P(policy);
P(prio);
#undef PN
#undef __PN
#undef P
#undef __P
{
unsigned int this_cpu = raw_smp_processor_id();
u64 t0, t1;
t0 = cpu_clock(this_cpu);
t1 = cpu_clock(this_cpu);
SEQ_printf(m, "%-35s:%21Ld\n",
"clock-delta", (long long)(t1-t0));
}
}
void proc_sched_set_task(struct task_struct *p)
{
#ifdef CONFIG_SCHEDSTATS
memset(&p->se.statistics, 0, sizeof(p->se.statistics));
#endif
}
| halaszk/Perseus-halaszk-universal5433 | kernel/sched/debug.c | C | gpl-2.0 | 14,685 | [
30522,
1013,
1008,
1008,
16293,
1013,
8040,
9072,
1013,
2139,
8569,
2290,
1012,
1039,
1008,
1008,
6140,
1996,
12935,
2015,
21144,
13334,
1008,
1008,
9385,
1006,
1039,
1007,
2289,
1010,
2417,
6045,
1010,
4297,
1012,
1010,
13749,
2080,
9587,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/*************************************************************************************
*filename: rudp_ccc.h
*
*to do: RUDP·¢ËÍÂëÂÊ¿ØÖÆÆ÷£¬ÊµÏÖ´ø¿íÆÀ¹À¡¢·¢ËÍ´°¿Ú¾ö²ß¡¢RTT¼ÆËãµÈ
*Create on: 2013-04
*Author: zerok
*check list:
*************************************************************************************/
#ifndef __RUDP_CCC_H_
#define __RUDP_CCC_H_
#include "base_typedef.h"
#include "base_namespace.h"
#include "rudp_packet.h"
BASE_NAMESPACE_BEGIN_DECL
//CCCÏÞËÙ¿ØÖÆÆ÷
class RUDPCCCObject
{
public:
RUDPCCCObject();
virtual ~RUDPCCCObject();
void init(uint64_t last_ack_id);
void reset();
void on_ack(uint64_t ack_seq);
void on_loss(uint64_t base_seq, const LossIDArray& loss_ids);
void on_timer(uint64_t now_ts);
public:
uint32_t get_send_window_size() const {return snd_cwnd_;};
void set_max_segment_size(uint16_t mss);
void set_rtt(uint32_t keep_live_rtt);
uint32_t get_rtt() const { return (uint32_t)(rtt_ * rtt_scale_); };
uint32_t get_rtt_var() const { return (uint32_t)(rtt_var_ * rtt_scale_); };
void add_resend();
void add_recv(uint32_t count);
protected:
void set_max_cwnd(uint32_t rtt);
private:
//µ±Ç°·¢ËÍ´°¿Ú
uint32_t snd_cwnd_;
uint32_t rtt_;
uint32_t rtt_var_;
double rtt_scale_;
uint64_t last_ack_id_;
uint64_t prev_on_ts_;
bool slow_start_;
bool loss_flag_;
//µÚÒ»´ÎÉèÖÃRTT
bool rtt_first_;
uint32_t resend_count_;
uint32_t recv_count_;
uint16_t max_cwnd_;
uint16_t min_cwnd_;
uint16_t limit_cwnd_;
uint32_t print_count_;
};
BASE_NAMESPACE_END_DECL
#endif
/************************************************************************************/
| yuanrongxi/revolver | common/rudp/rudp_ccc.h | C | mpl-2.0 | 1,692 | [
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... |
-----------------------------------------------------------------------------------
--Do not modify this file, instead use an alter proc to over-write the procedure.--
--Make sure you follow the same expected interface of parameters, and resultsets.--
-----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM [dbo].[sysobjects] WHERE ID=object_id(N'[Auth].[UserRole_Exists]') AND OBJECTPROPERTY(id, N'IsProcedure')=1) DROP PROC [Auth].[UserRole_Exists]
GO--
CREATE PROCEDURE [Auth].[UserRole_Exists]
@UserRoleId int
AS --Generated--
BEGIN
SET NOCOUNT ON;
IF EXISTS(
SELECT * FROM [Auth].[UserRole]
WHERE [UserRoleId] = @UserRoleId
) BEGIN
SELECT CAST(1 as bit) as [Exists]
END ELSE BEGIN
SELECT CAST(0 as bit) as [Exists]
END
END
| SPDEVGUY/VotingInfoWebsite | VotingInfo/Database/SQL/Alter/06-Procs/00-Generated/Auth/UserRole/[Auth].[UserRole_Exists].sql | SQL | mit | 799 | [
30522,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
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... |
#pragma once
#include "Emu/Cell/PPUOpcodes.h"
#include "Emu/SysCalls/SysCalls.h"
#include "rpcs3/Ini.h"
#include "Emu/SysCalls/Modules.h"
#include "Emu/Memory/Memory.h"
#include "Emu/SysCalls/lv2/sys_time.h"
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#define _rotl64(x,r) (((u64)(x) << (r)) | ((u64)(x) >> (64 - (r))))
#endif
#include <fenv.h>
extern u64 rotate_mask[64][64]; // defined in PPUThread.cpp, static didn't work correctly in GCC 4.9 for some reason
inline void InitRotateMask()
{
static bool inited = false;
if(inited) return;
for(u32 mb=0; mb<64; mb++) for(u32 me=0; me<64; me++)
{
const u64 mask = ((u64)-1 >> mb) ^ ((me >= 63) ? 0 : (u64)-1 >> (me + 1));
rotate_mask[mb][me] = mb > me ? ~mask : mask;
}
inited = true;
}
inline u8 rotl8(const u8 x, const u8 n) { return (x << n) | (x >> (8 - n)); }
inline u8 rotr8(const u8 x, const u8 n) { return (x >> n) | (x << (8 - n)); }
inline u16 rotl16(const u16 x, const u8 n) { return (x << n) | (x >> (16 - n)); }
inline u16 rotr16(const u16 x, const u8 n) { return (x >> n) | (x << (16 - n)); }
/*
u32 rotl32(const u32 x, const u8 n) { return (x << n) | (x >> (32 - n)); }
u32 rotr32(const u32 x, const u8 n) { return (x >> n) | (x << (32 - n)); }
u64 rotl64(const u64 x, const u8 n) { return (x << n) | (x >> (64 - n)); }
u64 rotr64(const u64 x, const u8 n) { return (x >> n) | (x << (64 - n)); }
*/
#define rotl32(x, n) _rotl64((u64)(u32)x | ((u64)(u32)x << 32), n)
#define rotr32(x, n) _rotr64((u64)(u32)x | ((u64)(u32)x << 32), n)
#define rotl64 _rotl64
#define rotr64 _rotr64
static double SilenceNaN(double x)
{
u64 bits = (u64&)x;
bits |= 0x0008000000000000ULL;
return (double&)bits;
}
static float SilenceNaN(float x)
{
return static_cast<float>(SilenceNaN(static_cast<double>(x)));
}
static void SetHostRoundingMode(u32 rn)
{
switch (rn)
{
case FPSCR_RN_NEAR:
fesetround(FE_TONEAREST);
break;
case FPSCR_RN_ZERO:
fesetround(FE_TOWARDZERO);
break;
case FPSCR_RN_PINF:
fesetround(FE_UPWARD);
break;
case FPSCR_RN_MINF:
fesetround(FE_DOWNWARD);
break;
}
}
namespace ppu_recompiler_llvm {
class Compiler;
}
class PPUInterpreter : public PPUOpcodes
{
#ifdef PPU_LLVM_RECOMPILER
friend class ppu_recompiler_llvm::Compiler;
#endif
private:
PPUThread& CPU;
public:
PPUInterpreter(PPUThread& cpu) : CPU(cpu)
{
}
private:
void CheckHostFPExceptions()
{
CPU.SetFPSCR_FI(fetestexcept(FE_INEXACT) != 0);
if (fetestexcept(FE_UNDERFLOW)) CPU.SetFPSCRException(FPSCR_UX);
if (fetestexcept(FE_OVERFLOW)) CPU.SetFPSCRException(FPSCR_OX);
}
void NULL_OP()
{
throw "Null operation";
}
void NOP()
{
//__asm nop
}
float CheckVSCR_NJ(const float v) const
{
if(!CPU.VSCR.NJ) return v;
const int fpc = _fpclass(v);
#ifdef __GNUG__
if(fpc == FP_SUBNORMAL)
return std::signbit(v) ? -0.0f : 0.0f;
#else
if(fpc & _FPCLASS_ND) return -0.0f;
if(fpc & _FPCLASS_PD) return 0.0f;
#endif
return v;
}
bool CheckCondition(u32 bo, u32 bi)
{
const u8 bo0 = (bo & 0x10) ? 1 : 0;
const u8 bo1 = (bo & 0x08) ? 1 : 0;
const u8 bo2 = (bo & 0x04) ? 1 : 0;
const u8 bo3 = (bo & 0x02) ? 1 : 0;
if(!bo2) --CPU.CTR;
const u8 ctr_ok = bo2 | ((CPU.CTR != 0) ^ bo3);
const u8 cond_ok = bo0 | (CPU.IsCR(bi) ^ (~bo1 & 0x1));
return ctr_ok && cond_ok;
}
u64 ReadSPR(u32 spr)
{
const u32 n = (spr >> 5) | ((spr & 0x1f) << 5);
switch (n)
{
case 0x001: return CPU.XER.XER;
case 0x008: return CPU.LR;
case 0x009: return CPU.CTR;
case 0x100: return CPU.VRSAVE;
case 0x103: return CPU.SPRG[3];
case 0x10C: CPU.TB = get_time(); return CPU.TB;
case 0x10D: CPU.TB = get_time(); return CPU.TB >> 32;
case 0x110:
case 0x111:
case 0x112:
case 0x113:
case 0x114:
case 0x115:
case 0x116:
case 0x117: return CPU.SPRG[n - 0x110];
}
throw fmt::Format("ReadSPR(0x%x) error: unknown SPR (0x%x)", spr, n);
}
void WriteSPR(u32 spr, u64 value)
{
const u32 n = (spr >> 5) | ((spr & 0x1f) << 5);
switch (n)
{
case 0x001: CPU.XER.XER = value; return;
case 0x008: CPU.LR = value; return;
case 0x009: CPU.CTR = value; return;
case 0x100: CPU.VRSAVE = (u32)value; return;
case 0x103: throw fmt::Format("WriteSPR(0x103, 0x%llx): Write to read-only SPR", value);
case 0x10C: throw fmt::Format("WriteSPR(0x10C, 0x%llx): Write to time-based SPR", value);
case 0x10D: throw fmt::Format("WriteSPR(0x10D, 0x%llx): Write to time-based SPR", value);
case 0x110:
case 0x111:
case 0x112:
case 0x113:
case 0x114:
case 0x115:
case 0x116:
case 0x117: CPU.SPRG[n - 0x110] = value; return;
}
throw fmt::Format("WriteSPR(0x%x, 0x%llx) error: unknown SPR (0x%x)", spr, value, n);
}
void TDI(u32 to, u32 ra, s32 simm16)
{
s64 a = CPU.GPR[ra];
if( (a < (s64)simm16 && (to & 0x10)) ||
(a > (s64)simm16 && (to & 0x8)) ||
(a == (s64)simm16 && (to & 0x4)) ||
((u64)a < (u64)simm16 && (to & 0x2)) ||
((u64)a > (u64)simm16 && (to & 0x1)) )
{
throw fmt::Format("Trap! (tdi 0x%x, r%d, 0x%x)", to, ra, simm16);
}
}
void TWI(u32 to, u32 ra, s32 simm16)
{
s32 a = (s32)CPU.GPR[ra];
if( (a < simm16 && (to & 0x10)) ||
(a > simm16 && (to & 0x8)) ||
(a == simm16 && (to & 0x4)) ||
((u32)a < (u32)simm16 && (to & 0x2)) ||
((u32)a > (u32)simm16 && (to & 0x1)) )
{
throw fmt::Format("Trap! (twi 0x%x, r%d, 0x%x)", to, ra, simm16);
}
}
void MFVSCR(u32 vd) //nf
{
CPU.VPR[vd].clear();
CPU.VPR[vd]._u32[0] = CPU.VSCR.VSCR;
}
void MTVSCR(u32 vb)
{
CPU.VSCR.VSCR = CPU.VPR[vb]._u32[0];
CPU.VSCR.X = CPU.VSCR.Y = 0;
}
void VADDCUW(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = ~CPU.VPR[va]._u32[w] < CPU.VPR[vb]._u32[w];
}
}
void VADDFP(u32 vd, u32 va, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (std::isinf(a) && std::isinf(b) && a != b)
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(a + b);
}
}
void VADDSBS(u32 vd, u32 va, u32 vb) //nf
{
for(u32 b=0; b<16; ++b)
{
s16 result = (s16)CPU.VPR[va]._s8[b] + (s16)CPU.VPR[vb]._s8[b];
if (result > 0x7f)
{
CPU.VPR[vd]._s8[b] = 0x7f;
CPU.VSCR.SAT = 1;
}
else if (result < -0x80)
{
CPU.VPR[vd]._s8[b] = -0x80;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s8[b] = (s8)result;
}
}
void VADDSHS(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
s32 result = (s32)CPU.VPR[va]._s16[h] + (s32)CPU.VPR[vb]._s16[h];
if (result > 0x7fff)
{
CPU.VPR[vd]._s16[h] = 0x7fff;
CPU.VSCR.SAT = 1;
}
else if (result < -0x8000)
{
CPU.VPR[vd]._s16[h] = -0x8000;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s16[h] = result;
}
}
void VADDSWS(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
s64 result = (s64)CPU.VPR[va]._s32[w] + (s64)CPU.VPR[vb]._s32[w];
if (result > 0x7fffffff)
{
CPU.VPR[vd]._s32[w] = 0x7fffffff;
CPU.VSCR.SAT = 1;
}
else if (result < (s32)0x80000000)
{
CPU.VPR[vd]._s32[w] = 0x80000000;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = (s32)result;
}
}
void VADDUBM(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = CPU.VPR[va]._u8[b] + CPU.VPR[vb]._u8[b];
}
}
void VADDUBS(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
u16 result = (u16)CPU.VPR[va]._u8[b] + (u16)CPU.VPR[vb]._u8[b];
if (result > 0xff)
{
CPU.VPR[vd]._u8[b] = 0xff;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VADDUHM(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = CPU.VPR[va]._u16[h] + CPU.VPR[vb]._u16[h];
}
}
void VADDUHS(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
u32 result = (u32)CPU.VPR[va]._u16[h] + (u32)CPU.VPR[vb]._u16[h];
if (result > 0xffff)
{
CPU.VPR[vd]._u16[h] = 0xffff;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u16[h] = result;
}
}
void VADDUWM(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] + CPU.VPR[vb]._u32[w];
}
}
void VADDUWS(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
u64 result = (u64)CPU.VPR[va]._u32[w] + (u64)CPU.VPR[vb]._u32[w];
if (result > 0xffffffff)
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u32[w] = (u32)result;
}
}
void VAND(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] & CPU.VPR[vb]._u32[w];
}
}
void VANDC(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] & (~CPU.VPR[vb]._u32[w]);
}
}
void VAVGSB(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._s8[b] = (CPU.VPR[va]._s8[b] + CPU.VPR[vb]._s8[b] + 1) >> 1;
}
}
void VAVGSH(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = (CPU.VPR[va]._s16[h] + CPU.VPR[vb]._s16[h] + 1) >> 1;
}
}
void VAVGSW(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = ((s64)CPU.VPR[va]._s32[w] + (s64)CPU.VPR[vb]._s32[w] + 1) >> 1;
}
}
void VAVGUB(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
CPU.VPR[vd]._u8[b] = (CPU.VPR[va]._u8[b] + CPU.VPR[vb]._u8[b] + 1) >> 1;
}
void VAVGUH(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = (CPU.VPR[va]._u16[h] + CPU.VPR[vb]._u16[h] + 1) >> 1;
}
}
void VAVGUW(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = ((u64)CPU.VPR[va]._u32[w] + (u64)CPU.VPR[vb]._u32[w] + 1) >> 1;
}
}
void VCFSX(u32 vd, u32 uimm5, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
u32 scale = 1 << uimm5;
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._f[w] = ((float)CPU.VPR[vb]._s32[w]) / scale;
}
}
void VCFUX(u32 vd, u32 uimm5, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
u32 scale = 1 << uimm5;
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._f[w] = ((float)CPU.VPR[vb]._u32[w]) / scale;
}
}
void VCMPBFP(u32 vd, u32 va, u32 vb, bool rc)
{
bool allInBounds = true;
for (uint w = 0; w < 4; w++)
{
u32 mask = 1<<31 | 1<<30;
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (a <= b) mask &= ~(1 << 31);
if (a >= -b) mask &= ~(1 << 30);
CPU.VPR[vd]._u32[w] = mask;
if (mask)
allInBounds = false;
}
if (rc)
{
// Bit n°2 of CR6
CPU.SetCR(6, 0);
CPU.SetCRBit(6, 0x2, allInBounds);
}
}
void VCMPBFP(u32 vd, u32 va, u32 vb) {VCMPBFP(vd, va, vb, false);}
void VCMPBFP_(u32 vd, u32 va, u32 vb) {VCMPBFP(vd, va, vb, true);}
void VCMPEQFP(u32 vd, u32 va, u32 vb, bool rc)
{
int all_equal = 0x8;
int none_equal = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._f[w] == CPU.VPR[vb]._f[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_equal = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_equal = 0;
}
}
if (rc) CPU.CR.cr6 = all_equal | none_equal;
}
void VCMPEQFP(u32 vd, u32 va, u32 vb) {VCMPEQFP(vd, va, vb, false);}
void VCMPEQFP_(u32 vd, u32 va, u32 vb) {VCMPEQFP(vd, va, vb, true);}
void VCMPEQUB(u32 vd, u32 va, u32 vb, bool rc)
{
int all_equal = 0x8;
int none_equal = 0x2;
for (uint b = 0; b < 16; b++)
{
if (CPU.VPR[va]._u8[b] == CPU.VPR[vb]._u8[b])
{
CPU.VPR[vd]._u8[b] = 0xff;
none_equal = 0;
}
else
{
CPU.VPR[vd]._u8[b] = 0;
all_equal = 0;
}
}
if (rc) CPU.CR.cr6 = all_equal | none_equal;
}
void VCMPEQUB(u32 vd, u32 va, u32 vb) {VCMPEQUB(vd, va, vb, false);}
void VCMPEQUB_(u32 vd, u32 va, u32 vb) {VCMPEQUB(vd, va, vb, true);}
void VCMPEQUH(u32 vd, u32 va, u32 vb, bool rc) //nf
{
int all_equal = 0x8;
int none_equal = 0x2;
for (uint h = 0; h < 8; h++)
{
if (CPU.VPR[va]._u16[h] == CPU.VPR[vb]._u16[h])
{
CPU.VPR[vd]._u16[h] = 0xffff;
none_equal = 0;
}
else
{
CPU.VPR[vd]._u16[h] = 0;
all_equal = 0;
}
}
if (rc) CPU.CR.cr6 = all_equal | none_equal;
}
void VCMPEQUH(u32 vd, u32 va, u32 vb) {VCMPEQUH(vd, va, vb, false);}
void VCMPEQUH_(u32 vd, u32 va, u32 vb) {VCMPEQUH(vd, va, vb, true);}
void VCMPEQUW(u32 vd, u32 va, u32 vb, bool rc)
{
int all_equal = 0x8;
int none_equal = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._u32[w] == CPU.VPR[vb]._u32[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_equal = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_equal = 0;
}
}
if (rc) CPU.CR.cr6 = all_equal | none_equal;
}
void VCMPEQUW(u32 vd, u32 va, u32 vb) {VCMPEQUW(vd, va, vb, false);}
void VCMPEQUW_(u32 vd, u32 va, u32 vb) {VCMPEQUW(vd, va, vb, true);}
void VCMPGEFP(u32 vd, u32 va, u32 vb, bool rc)
{
int all_ge = 0x8;
int none_ge = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._f[w] >= CPU.VPR[vb]._f[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_ge = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_ge = 0;
}
}
if (rc) CPU.CR.cr6 = all_ge | none_ge;
}
void VCMPGEFP(u32 vd, u32 va, u32 vb) {VCMPGEFP(vd, va, vb, false);}
void VCMPGEFP_(u32 vd, u32 va, u32 vb) {VCMPGEFP(vd, va, vb, true);}
void VCMPGTFP(u32 vd, u32 va, u32 vb, bool rc)
{
int all_ge = 0x8;
int none_ge = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._f[w] > CPU.VPR[vb]._f[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_ge = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_ge = 0;
}
}
if (rc) CPU.CR.cr6 = all_ge | none_ge;
}
void VCMPGTFP(u32 vd, u32 va, u32 vb) {VCMPGTFP(vd, va, vb, false);}
void VCMPGTFP_(u32 vd, u32 va, u32 vb) {VCMPGTFP(vd, va, vb, true);}
void VCMPGTSB(u32 vd, u32 va, u32 vb, bool rc) //nf
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint b = 0; b < 16; b++)
{
if (CPU.VPR[va]._s8[b] > CPU.VPR[vb]._s8[b])
{
CPU.VPR[vd]._u8[b] = 0xff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u8[b] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTSB(u32 vd, u32 va, u32 vb) {VCMPGTSB(vd, va, vb, false);}
void VCMPGTSB_(u32 vd, u32 va, u32 vb) {VCMPGTSB(vd, va, vb, true);}
void VCMPGTSH(u32 vd, u32 va, u32 vb, bool rc)
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint h = 0; h < 8; h++)
{
if (CPU.VPR[va]._s16[h] > CPU.VPR[vb]._s16[h])
{
CPU.VPR[vd]._u16[h] = 0xffff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u16[h] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTSH(u32 vd, u32 va, u32 vb) {VCMPGTSH(vd, va, vb, false);}
void VCMPGTSH_(u32 vd, u32 va, u32 vb) {VCMPGTSH(vd, va, vb, true);}
void VCMPGTSW(u32 vd, u32 va, u32 vb, bool rc)
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._s32[w] > CPU.VPR[vb]._s32[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTSW(u32 vd, u32 va, u32 vb) {VCMPGTSW(vd, va, vb, false);}
void VCMPGTSW_(u32 vd, u32 va, u32 vb) {VCMPGTSW(vd, va, vb, true);}
void VCMPGTUB(u32 vd, u32 va, u32 vb, bool rc)
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint b = 0; b < 16; b++)
{
if (CPU.VPR[va]._u8[b] > CPU.VPR[vb]._u8[b])
{
CPU.VPR[vd]._u8[b] = 0xff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u8[b] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTUB(u32 vd, u32 va, u32 vb) {VCMPGTUB(vd, va, vb, false);}
void VCMPGTUB_(u32 vd, u32 va, u32 vb) {VCMPGTUB(vd, va, vb, true);}
void VCMPGTUH(u32 vd, u32 va, u32 vb, bool rc)
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint h = 0; h < 8; h++)
{
if (CPU.VPR[va]._u16[h] > CPU.VPR[vb]._u16[h])
{
CPU.VPR[vd]._u16[h] = 0xffff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u16[h] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTUH(u32 vd, u32 va, u32 vb) {VCMPGTUH(vd, va, vb, false);}
void VCMPGTUH_(u32 vd, u32 va, u32 vb) {VCMPGTUH(vd, va, vb, true);}
void VCMPGTUW(u32 vd, u32 va, u32 vb, bool rc)
{
int all_gt = 0x8;
int none_gt = 0x2;
for (uint w = 0; w < 4; w++)
{
if (CPU.VPR[va]._u32[w] > CPU.VPR[vb]._u32[w])
{
CPU.VPR[vd]._u32[w] = 0xffffffff;
none_gt = 0;
}
else
{
CPU.VPR[vd]._u32[w] = 0;
all_gt = 0;
}
}
if (rc) CPU.CR.cr6 = all_gt | none_gt;
}
void VCMPGTUW(u32 vd, u32 va, u32 vb) {VCMPGTUW(vd, va, vb, false);}
void VCMPGTUW_(u32 vd, u32 va, u32 vb) {VCMPGTUW(vd, va, vb, true);}
void VCTSXS(u32 vd, u32 uimm5, u32 vb)
{
u32 nScale = 1 << uimm5;
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
{
CPU.VPR[vd]._s32[w] = 0;
}
else
{
double result = (double)b * nScale;
if (result > 0x7fffffff)
{
CPU.VPR[vd]._s32[w] = (int)0x7fffffff;
CPU.VSCR.SAT = 1;
}
else if (result < -pow(2, 31))
{
CPU.VPR[vd]._s32[w] = (int)0x80000000;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = (int)trunc(result);
}
}
}
void VCTUXS(u32 vd, u32 uimm5, u32 vb)
{
u32 nScale = 1 << uimm5;
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
{
CPU.VPR[vd]._s32[w] = 0;
}
else
{
double result = (double)b * nScale;
if (result > 0xffffffffu)
{
CPU.VPR[vd]._u32[w] = 0xffffffffu;
CPU.VSCR.SAT = 1;
}
else if (result < 0)
{
CPU.VPR[vd]._u32[w] = 0;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u32[w] = (u32)trunc(result);
}
}
}
void VEXPTEFP(u32 vd, u32 vb)
{
// vd = 2^x
// ISA : Note that the value placed into the element of vD may vary between implementations
// and between different executions on the same implementation.
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(powf(2.0f, b));
}
}
void VLOGEFP(u32 vd, u32 vb)
{
// ISA : Note that the value placed into the element of vD may vary between implementations
// and between different executions on the same implementation.
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = log2f(b); // Can never be denormal.
}
}
void VMADDFP(u32 vd, u32 va, u32 vc, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
const float c = CheckVSCR_NJ(CPU.VPR[vc]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (std::isnan(c))
CPU.VPR[vd]._f[w] = SilenceNaN(c);
else if ((std::isinf(a) && c == 0) || (a == 0 && std::isinf(c)))
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
{
const float result = fmaf(a, c, b);
if (std::isnan(result))
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(result);
}
}
}
void VMAXFP(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (a > b)
CPU.VPR[vd]._f[w] = a;
else if (b > a)
CPU.VPR[vd]._f[w] = b;
else if (CPU.VPR[vb]._u32[w] == 0x80000000)
CPU.VPR[vd]._f[w] = a; // max(+0,-0) = +0
else
CPU.VPR[vd]._f[w] = b;
}
}
void VMAXSB(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
CPU.VPR[vd]._s8[b] = std::max(CPU.VPR[va]._s8[b], CPU.VPR[vb]._s8[b]);
}
void VMAXSH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = std::max(CPU.VPR[va]._s16[h], CPU.VPR[vb]._s16[h]);
}
}
void VMAXSW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = std::max(CPU.VPR[va]._s32[w], CPU.VPR[vb]._s32[w]);
}
}
void VMAXUB(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
CPU.VPR[vd]._u8[b] = std::max(CPU.VPR[va]._u8[b], CPU.VPR[vb]._u8[b]);
}
void VMAXUH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = std::max(CPU.VPR[va]._u16[h], CPU.VPR[vb]._u16[h]);
}
}
void VMAXUW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = std::max(CPU.VPR[va]._u32[w], CPU.VPR[vb]._u32[w]);
}
}
void VMHADDSHS(u32 vd, u32 va, u32 vb, u32 vc)
{
for (uint h = 0; h < 8; h++)
{
s32 result = (s32)CPU.VPR[va]._s16[h] * (s32)CPU.VPR[vb]._s16[h];
result = (result >> 15) + (s32)CPU.VPR[vc]._s16[h];
if (result > INT16_MAX)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT16_MIN)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s16[h] = (s16)result;
}
}
void VMHRADDSHS(u32 vd, u32 va, u32 vb, u32 vc)
{
for (uint h = 0; h < 8; h++)
{
s32 result = ((s32)CPU.VPR[va]._s16[h] * (s32)CPU.VPR[vb]._s16[h]) + 0x4000;
result = (result >> 15) + (s32)CPU.VPR[vc]._s16[h];
if (result > INT16_MAX)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT16_MIN)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s16[h] = (s16)result;
}
}
void VMINFP(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (a < b)
CPU.VPR[vd]._f[w] = a;
else if (b < a)
CPU.VPR[vd]._f[w] = b;
else if (CPU.VPR[vb]._u32[w] == 0x00000000)
CPU.VPR[vd]._f[w] = a; // min(-0,+0) = -0
else
CPU.VPR[vd]._f[w] = b;
}
}
void VMINSB(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._s8[b] = std::min(CPU.VPR[va]._s8[b], CPU.VPR[vb]._s8[b]);
}
}
void VMINSH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = std::min(CPU.VPR[va]._s16[h], CPU.VPR[vb]._s16[h]);
}
}
void VMINSW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = std::min(CPU.VPR[va]._s32[w], CPU.VPR[vb]._s32[w]);
}
}
void VMINUB(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = std::min(CPU.VPR[va]._u8[b], CPU.VPR[vb]._u8[b]);
}
}
void VMINUH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = std::min(CPU.VPR[va]._u16[h], CPU.VPR[vb]._u16[h]);
}
}
void VMINUW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = std::min(CPU.VPR[va]._u32[w], CPU.VPR[vb]._u32[w]);
}
}
void VMLADDUHM(u32 vd, u32 va, u32 vb, u32 vc)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = CPU.VPR[va]._u16[h] * CPU.VPR[vb]._u16[h] + CPU.VPR[vc]._u16[h];
}
}
void VMRGHB(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u8[15 - h*2] = VA._u8[15 - h];
CPU.VPR[vd]._u8[15 - h*2 - 1] = VB._u8[15 - h];
}
}
void VMRGHH(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u16[7 - w*2] = VA._u16[7 - w];
CPU.VPR[vd]._u16[7 - w*2 - 1] = VB._u16[7 - w];
}
}
void VMRGHW(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint d = 0; d < 2; d++)
{
CPU.VPR[vd]._u32[3 - d*2] = VA._u32[3 - d];
CPU.VPR[vd]._u32[3 - d*2 - 1] = VB._u32[3 - d];
}
}
void VMRGLB(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u8[15 - h*2] = VA._u8[7 - h];
CPU.VPR[vd]._u8[15 - h*2 - 1] = VB._u8[7 - h];
}
}
void VMRGLH(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u16[7 - w*2] = VA._u16[3 - w];
CPU.VPR[vd]._u16[7 - w*2 - 1] = VB._u16[3 - w];
}
}
void VMRGLW(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint d = 0; d < 2; d++)
{
CPU.VPR[vd]._u32[3 - d*2] = VA._u32[1 - d];
CPU.VPR[vd]._u32[3 - d*2 - 1] = VB._u32[1 - d];
}
}
void VMSUMMBM(u32 vd, u32 va, u32 vb, u32 vc) //nf
{
for (uint w = 0; w < 4; w++)
{
s32 result = 0;
for (uint b = 0; b < 4; b++)
{
result += CPU.VPR[va]._s8[w*4 + b] * CPU.VPR[vb]._u8[w*4 + b];
}
result += CPU.VPR[vc]._s32[w];
CPU.VPR[vd]._s32[w] = result;
}
}
void VMSUMSHM(u32 vd, u32 va, u32 vb, u32 vc) //nf
{
for (uint w = 0; w < 4; w++)
{
s32 result = 0;
for (uint h = 0; h < 2; h++)
{
result += CPU.VPR[va]._s16[w*2 + h] * CPU.VPR[vb]._s16[w*2 + h];
}
result += CPU.VPR[vc]._s32[w];
CPU.VPR[vd]._s32[w] = result;
}
}
void VMSUMSHS(u32 vd, u32 va, u32 vb, u32 vc) //nf
{
for (uint w = 0; w < 4; w++)
{
s64 result = 0;
s32 saturated = 0;
for (uint h = 0; h < 2; h++)
{
result += CPU.VPR[va]._s16[w*2 + h] * CPU.VPR[vb]._s16[w*2 + h];
}
result += CPU.VPR[vc]._s32[w];
if (result > 0x7fffffff)
{
saturated = 0x7fffffff;
CPU.VSCR.SAT = 1;
}
else if (result < (s64)(s32)0x80000000)
{
saturated = 0x80000000;
CPU.VSCR.SAT = 1;
}
else
saturated = (s32)result;
CPU.VPR[vd]._s32[w] = saturated;
}
}
void VMSUMUBM(u32 vd, u32 va, u32 vb, u32 vc)
{
for (uint w = 0; w < 4; w++)
{
u32 result = 0;
for (uint b = 0; b < 4; b++)
{
result += (u32)CPU.VPR[va]._u8[w*4 + b] * (u32)CPU.VPR[vb]._u8[w*4 + b];
}
result += CPU.VPR[vc]._u32[w];
CPU.VPR[vd]._u32[w] = result;
}
}
void VMSUMUHM(u32 vd, u32 va, u32 vb, u32 vc) //nf
{
for (uint w = 0; w < 4; w++)
{
u32 result = 0;
for (uint h = 0; h < 2; h++)
{
result += (u32)CPU.VPR[va]._u16[w*2 + h] * (u32)CPU.VPR[vb]._u16[w*2 + h];
}
result += CPU.VPR[vc]._u32[w];
CPU.VPR[vd]._u32[w] = result;
}
}
void VMSUMUHS(u32 vd, u32 va, u32 vb, u32 vc) //nf
{
for (uint w = 0; w < 4; w++)
{
u64 result = 0;
u32 saturated = 0;
for (uint h = 0; h < 2; h++)
{
result += (u64)CPU.VPR[va]._u16[w*2 + h] * (u64)CPU.VPR[vb]._u16[w*2 + h];
}
result += CPU.VPR[vc]._u32[w];
if (result > 0xffffffffu)
{
saturated = 0xffffffff;
CPU.VSCR.SAT = 1;
}
else
saturated = (u32)result;
CPU.VPR[vd]._u32[w] = saturated;
}
}
void VMULESB(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = (s16)CPU.VPR[va]._s8[h*2+1] * (s16)CPU.VPR[vb]._s8[h*2+1];
}
}
void VMULESH(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = (s32)CPU.VPR[va]._s16[w*2+1] * (s32)CPU.VPR[vb]._s16[w*2+1];
}
}
void VMULEUB(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = (u16)CPU.VPR[va]._u8[h*2+1] * (u16)CPU.VPR[vb]._u8[h*2+1];
}
}
void VMULEUH(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = (u32)CPU.VPR[va]._u16[w*2+1] * (u32)CPU.VPR[vb]._u16[w*2+1];
}
}
void VMULOSB(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = (s16)CPU.VPR[va]._s8[h*2] * (s16)CPU.VPR[vb]._s8[h*2];
}
}
void VMULOSH(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = (s32)CPU.VPR[va]._s16[w*2] * (s32)CPU.VPR[vb]._s16[w*2];
}
}
void VMULOUB(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = (u16)CPU.VPR[va]._u8[h*2] * (u16)CPU.VPR[vb]._u8[h*2];
}
}
void VMULOUH(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = (u32)CPU.VPR[va]._u16[w*2] * (u32)CPU.VPR[vb]._u16[w*2];
}
}
void VNMSUBFP(u32 vd, u32 va, u32 vc, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
const float c = CheckVSCR_NJ(CPU.VPR[vc]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (std::isnan(c))
CPU.VPR[vd]._f[w] = SilenceNaN(c);
else if ((std::isinf(a) && c == 0) || (a == 0 && std::isinf(c)))
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
{
const float result = -fmaf(a, c, -b);
if (std::isnan(result))
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(result);
}
}
}
void VNOR(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = ~(CPU.VPR[va]._u32[w] | CPU.VPR[vb]._u32[w]);
}
}
void VOR(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] | CPU.VPR[vb]._u32[w];
}
}
void VPERM(u32 vd, u32 va, u32 vb, u32 vc)
{
u8 tmpSRC[32];
memcpy(tmpSRC, CPU.VPR[vb]._u8, 16);
memcpy(tmpSRC + 16, CPU.VPR[va]._u8, 16);
for (uint b = 0; b < 16; b++)
{
u8 index = CPU.VPR[vc]._u8[b] & 0x1f;
CPU.VPR[vd]._u8[b] = tmpSRC[0x1f - index];
}
}
void VPKPX(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 4; h++)
{
u16 bb7 = VB._u8[15 - (h*4 + 0)] & 0x1;
u16 bb8 = VB._u8[15 - (h*4 + 1)] >> 3;
u16 bb16 = VB._u8[15 - (h*4 + 2)] >> 3;
u16 bb24 = VB._u8[15 - (h*4 + 3)] >> 3;
u16 ab7 = VA._u8[15 - (h*4 + 0)] & 0x1;
u16 ab8 = VA._u8[15 - (h*4 + 1)] >> 3;
u16 ab16 = VA._u8[15 - (h*4 + 2)] >> 3;
u16 ab24 = VA._u8[15 - (h*4 + 3)] >> 3;
CPU.VPR[vd]._u16[3 - h] = (bb7 << 15) | (bb8 << 10) | (bb16 << 5) | bb24;
CPU.VPR[vd]._u16[4 + (3 - h)] = (ab7 << 15) | (ab8 << 10) | (ab16 << 5) | ab24;
}
}
void VPKSHSS(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint b = 0; b < 8; b++)
{
s16 result = VA._s16[b];
if (result > INT8_MAX)
{
result = INT8_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT8_MIN)
{
result = INT8_MIN;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s8[b+8] = (s8)result;
result = VB._s16[b];
if (result > INT8_MAX)
{
result = INT8_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT8_MIN)
{
result = INT8_MIN;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s8[b] = (s8)result;
}
}
void VPKSHUS(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint b = 0; b < 8; b++)
{
s16 result = VA._s16[b];
if (result > UINT8_MAX)
{
result = UINT8_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < 0)
{
result = 0;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b+8] = (u8)result;
result = VB._s16[b];
if (result > UINT8_MAX)
{
result = UINT8_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < 0)
{
result = 0;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VPKSWSS(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 4; h++)
{
s32 result = VA._s32[h];
if (result > INT16_MAX)
{
result = INT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT16_MIN)
{
result = INT16_MIN;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s16[h+4] = result;
result = VB._s32[h];
if (result > INT16_MAX)
{
result = INT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < INT16_MIN)
{
result = INT16_MIN;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._s16[h] = result;
}
}
void VPKSWUS(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 4; h++)
{
s32 result = VA._s32[h];
if (result > UINT16_MAX)
{
result = UINT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < 0)
{
result = 0;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u16[h+4] = result;
result = VB._s32[h];
if (result > UINT16_MAX)
{
result = UINT16_MAX;
CPU.VSCR.SAT = 1;
}
else if (result < 0)
{
result = 0;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u16[h] = result;
}
}
void VPKUHUM(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint b = 0; b < 8; b++)
{
CPU.VPR[vd]._u8[b+8] = VA._u8[b*2];
CPU.VPR[vd]._u8[b ] = VB._u8[b*2];
}
}
void VPKUHUS(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint b = 0; b < 8; b++)
{
u16 result = VA._u16[b];
if (result > UINT8_MAX)
{
result = UINT8_MAX;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b+8] = (u8)result;
result = VB._u16[b];
if (result > UINT8_MAX)
{
result = UINT8_MAX;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VPKUWUM(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 4; h++)
{
CPU.VPR[vd]._u16[h+4] = VA._u16[h*2];
CPU.VPR[vd]._u16[h ] = VB._u16[h*2];
}
}
void VPKUWUS(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 4; h++)
{
u32 result = VA._u32[h];
if (result > UINT16_MAX)
{
result = UINT16_MAX;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u16[h+4] = result;
result = VB._u32[h];
if (result > UINT16_MAX)
{
result = UINT16_MAX;
CPU.VSCR.SAT = 1;
}
CPU.VPR[vd]._u16[h] = result;
}
}
void VREFP(u32 vd, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(1.0f / b);
}
}
void VRFIM(u32 vd, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = floorf(CPU.VPR[vb]._f[w]);
}
}
void VRFIN(u32 vd, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
{
SetHostRoundingMode(FPSCR_RN_NEAR);
CPU.VPR[vd]._f[w] = nearbyintf(CPU.VPR[vb]._f[w]);
}
}
}
void VRFIP(u32 vd, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = ceilf(CPU.VPR[vb]._f[w]);
}
}
void VRFIZ(u32 vd, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else
CPU.VPR[vd]._f[w] = truncf(CPU.VPR[vb]._f[w]);
}
}
void VRLB(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
{
int nRot = CPU.VPR[vb]._u8[b] & 0x7;
CPU.VPR[vd]._u8[b] = (CPU.VPR[va]._u8[b] << nRot) | (CPU.VPR[va]._u8[b] >> (8 - nRot));
}
}
void VRLH(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = rotl16(CPU.VPR[va]._u16[h], CPU.VPR[vb]._u8[h*2] & 0xf);
}
}
void VRLW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = (u32)rotl32(CPU.VPR[va]._u32[w], CPU.VPR[vb]._u8[w*4] & 0x1f);
}
}
void VRSQRTEFP(u32 vd, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
//TODO: accurate div
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (b < 0)
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
CPU.VPR[vd]._f[w] = 1.0f / sqrtf(b); // Can never be denormal.
}
}
void VSEL(u32 vd, u32 va, u32 vb, u32 vc)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = (CPU.VPR[vb]._u8[b] & CPU.VPR[vc]._u8[b]) | (CPU.VPR[va]._u8[b] & (~CPU.VPR[vc]._u8[b]));
}
}
void VSL(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u8 sh = CPU.VPR[vb]._u8[0] & 0x7;
CPU.VPR[vd]._u8[0] = VA._u8[0] << sh;
for (uint b = 1; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = (VA._u8[b] << sh) | (VA._u8[b-1] >> (8 - sh));
}
}
void VSLB(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = CPU.VPR[va]._u8[b] << (CPU.VPR[vb]._u8[b] & 0x7);
}
}
void VSLDOI(u32 vd, u32 va, u32 vb, u32 sh)
{
u8 tmpSRC[32];
memcpy(tmpSRC, CPU.VPR[vb]._u8, 16);
memcpy(tmpSRC + 16, CPU.VPR[va]._u8, 16);
for(uint b=0; b<16; b++)
{
CPU.VPR[vd]._u8[15 - b] = tmpSRC[31 - (b + sh)];
}
}
void VSLH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = CPU.VPR[va]._u16[h] << (CPU.VPR[vb]._u16[h] & 0xf);
}
}
void VSLO(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u8 nShift = (CPU.VPR[vb]._u8[0] >> 3) & 0xf;
CPU.VPR[vd].clear();
for (u8 b = 0; b < 16 - nShift; b++)
{
CPU.VPR[vd]._u8[15 - b] = VA._u8[15 - (b + nShift)];
}
}
void VSLW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] << (CPU.VPR[vb]._u32[w] & 0x1f);
}
}
void VSPLTB(u32 vd, u32 uimm5, u32 vb)
{
u8 byte = CPU.VPR[vb]._u8[15 - uimm5];
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = byte;
}
}
void VSPLTH(u32 vd, u32 uimm5, u32 vb)
{
assert(uimm5 < 8);
u16 hword = CPU.VPR[vb]._u16[7 - uimm5];
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = hword;
}
}
void VSPLTISB(u32 vd, s32 simm5)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = simm5;
}
}
void VSPLTISH(u32 vd, s32 simm5)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = (s16)simm5;
}
}
void VSPLTISW(u32 vd, s32 simm5)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = (s32)simm5;
}
}
void VSPLTW(u32 vd, u32 uimm5, u32 vb)
{
assert(uimm5 < 4);
u32 word = CPU.VPR[vb]._u32[3 - uimm5];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = word;
}
}
void VSR(u32 vd, u32 va, u32 vb) //nf
{
u128 VA = CPU.VPR[va];
u8 sh = CPU.VPR[vb]._u8[0] & 0x7;
CPU.VPR[vd]._u8[15] = VA._u8[15] >> sh;
for (uint b = 14; ~b; b--)
{
CPU.VPR[vd]._u8[b] = (VA._u8[b] >> sh) | (VA._u8[b+1] << (8 - sh));
}
}
void VSRAB(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._s8[b] = CPU.VPR[va]._s8[b] >> (CPU.VPR[vb]._u8[b] & 0x7);
}
}
void VSRAH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = CPU.VPR[va]._s16[h] >> (CPU.VPR[vb]._u16[h] & 0xf);
}
}
void VSRAW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = CPU.VPR[va]._s32[w] >> (CPU.VPR[vb]._u32[w] & 0x1f);
}
}
void VSRB(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = CPU.VPR[va]._u8[b] >> (CPU.VPR[vb]._u8[b] & 0x7);
}
}
void VSRH(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = CPU.VPR[va]._u16[h] >> (CPU.VPR[vb]._u16[h] & 0xf);
}
}
void VSRO(u32 vd, u32 va, u32 vb)
{
u128 VA = CPU.VPR[va];
u8 nShift = (CPU.VPR[vb]._u8[0] >> 3) & 0xf;
CPU.VPR[vd].clear();
for (u8 b = 0; b < 16 - nShift; b++)
{
CPU.VPR[vd]._u8[b] = VA._u8[b + nShift];
}
}
void VSRW(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] >> (CPU.VPR[vb]._u32[w] & 0x1f);
}
}
void VSUBCUW(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] < CPU.VPR[vb]._u32[w] ? 0 : 1;
}
}
void VSUBFP(u32 vd, u32 va, u32 vb)
{
SetHostRoundingMode(FPSCR_RN_NEAR);
for (uint w = 0; w < 4; w++)
{
const float a = CheckVSCR_NJ(CPU.VPR[va]._f[w]);
const float b = CheckVSCR_NJ(CPU.VPR[vb]._f[w]);
if (std::isnan(a))
CPU.VPR[vd]._f[w] = SilenceNaN(a);
else if (std::isnan(b))
CPU.VPR[vd]._f[w] = SilenceNaN(b);
else if (std::isinf(a) && std::isinf(b) && a == b)
CPU.VPR[vd]._f[w] = (float)FPR_NAN;
else
CPU.VPR[vd]._f[w] = CheckVSCR_NJ(a - b);
}
}
void VSUBSBS(u32 vd, u32 va, u32 vb) //nf
{
for (uint b = 0; b < 16; b++)
{
s16 result = (s16)CPU.VPR[va]._s8[b] - (s16)CPU.VPR[vb]._s8[b];
if (result < INT8_MIN)
{
CPU.VPR[vd]._s8[b] = INT8_MIN;
CPU.VSCR.SAT = 1;
}
else if (result > INT8_MAX)
{
CPU.VPR[vd]._s8[b] = INT8_MAX;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s8[b] = (s8)result;
}
}
void VSUBSHS(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
s32 result = (s32)CPU.VPR[va]._s16[h] - (s32)CPU.VPR[vb]._s16[h];
if (result < INT16_MIN)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MIN;
CPU.VSCR.SAT = 1;
}
else if (result > INT16_MAX)
{
CPU.VPR[vd]._s16[h] = (s16)INT16_MAX;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s16[h] = (s16)result;
}
}
void VSUBSWS(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
s64 result = (s64)CPU.VPR[va]._s32[w] - (s64)CPU.VPR[vb]._s32[w];
if (result < INT32_MIN)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MIN;
CPU.VSCR.SAT = 1;
}
else if (result > INT32_MAX)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MAX;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = (s32)result;
}
}
void VSUBUBM(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
CPU.VPR[vd]._u8[b] = (u8)((CPU.VPR[va]._u8[b] - CPU.VPR[vb]._u8[b]) & 0xff);
}
}
void VSUBUBS(u32 vd, u32 va, u32 vb)
{
for (uint b = 0; b < 16; b++)
{
s16 result = (s16)CPU.VPR[va]._u8[b] - (s16)CPU.VPR[vb]._u8[b];
if (result < 0)
{
CPU.VPR[vd]._u8[b] = 0;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u8[b] = (u8)result;
}
}
void VSUBUHM(u32 vd, u32 va, u32 vb)
{
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._u16[h] = CPU.VPR[va]._u16[h] - CPU.VPR[vb]._u16[h];
}
}
void VSUBUHS(u32 vd, u32 va, u32 vb) //nf
{
for (uint h = 0; h < 8; h++)
{
s32 result = (s32)CPU.VPR[va]._u16[h] - (s32)CPU.VPR[vb]._u16[h];
if (result < 0)
{
CPU.VPR[vd]._u16[h] = 0;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u16[h] = (u16)result;
}
}
void VSUBUWM(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._u32[w] = CPU.VPR[va]._u32[w] - CPU.VPR[vb]._u32[w];
}
}
void VSUBUWS(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
s64 result = (s64)CPU.VPR[va]._u32[w] - (s64)CPU.VPR[vb]._u32[w];
if (result < 0)
{
CPU.VPR[vd]._u32[w] = 0;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u32[w] = (u32)result;
}
}
void VSUMSWS(u32 vd, u32 va, u32 vb)
{
s64 sum = CPU.VPR[vb]._s32[0];
for (uint w = 0; w < 4; w++)
{
sum += CPU.VPR[va]._s32[w];
}
CPU.VPR[vd].clear();
if (sum > INT32_MAX)
{
CPU.VPR[vd]._s32[0] = (s32)INT32_MAX;
CPU.VSCR.SAT = 1;
}
else if (sum < INT32_MIN)
{
CPU.VPR[vd]._s32[0] = (s32)INT32_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[0] = (s32)sum;
}
void VSUM2SWS(u32 vd, u32 va, u32 vb)
{
for (uint n = 0; n < 2; n++)
{
s64 sum = (s64)CPU.VPR[va]._s32[n*2] + CPU.VPR[va]._s32[n*2 + 1] + CPU.VPR[vb]._s32[n*2];
if (sum > INT32_MAX)
{
CPU.VPR[vd]._s32[n*2] = (s32)INT32_MAX;
CPU.VSCR.SAT = 1;
}
else if (sum < INT32_MIN)
{
CPU.VPR[vd]._s32[n*2] = (s32)INT32_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[n*2] = (s32)sum;
}
CPU.VPR[vd]._s32[1] = 0;
CPU.VPR[vd]._s32[3] = 0;
}
void VSUM4SBS(u32 vd, u32 va, u32 vb) //nf
{
for (uint w = 0; w < 4; w++)
{
s64 sum = CPU.VPR[vb]._s32[w];
for (uint b = 0; b < 4; b++)
{
sum += CPU.VPR[va]._s8[w*4 + b];
}
if (sum > INT32_MAX)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MAX;
CPU.VSCR.SAT = 1;
}
else if (sum < INT32_MIN)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = (s32)sum;
}
}
void VSUM4SHS(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
s64 sum = CPU.VPR[vb]._s32[w];
for (uint h = 0; h < 2; h++)
{
sum += CPU.VPR[va]._s16[w*2 + h];
}
if (sum > INT32_MAX)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MAX;
CPU.VSCR.SAT = 1;
}
else if (sum < INT32_MIN)
{
CPU.VPR[vd]._s32[w] = (s32)INT32_MIN;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._s32[w] = (s32)sum;
}
}
void VSUM4UBS(u32 vd, u32 va, u32 vb)
{
for (uint w = 0; w < 4; w++)
{
u64 sum = CPU.VPR[vb]._u32[w];
for (uint b = 0; b < 4; b++)
{
sum += CPU.VPR[va]._u8[w*4 + b];
}
if (sum > UINT32_MAX)
{
CPU.VPR[vd]._u32[w] = (u32)UINT32_MAX;
CPU.VSCR.SAT = 1;
}
else
CPU.VPR[vd]._u32[w] = (u32)sum;
}
}
void VUPKHPX(u32 vd, u32 vb)
{
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s8[w*4 + 3] = VB._s8[8 + w*2 + 1] >> 7; // signed shift sign extends
CPU.VPR[vd]._u8[w*4 + 2] = (VB._u8[8 + w*2 + 1] >> 2) & 0x1f;
CPU.VPR[vd]._u8[w*4 + 1] = ((VB._u8[8 + w*2 + 1] & 0x3) << 3) | ((VB._u8[8 + w*2 + 0] >> 5) & 0x7);
CPU.VPR[vd]._u8[w*4 + 0] = VB._u8[8 + w*2 + 0] & 0x1f;
}
}
void VUPKHSB(u32 vd, u32 vb)
{
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = VB._s8[8 + h];
}
}
void VUPKHSH(u32 vd, u32 vb)
{
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = VB._s16[4 + w];
}
}
void VUPKLPX(u32 vd, u32 vb)
{
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s8[w*4 + 3] = VB._s8[w*2 + 1] >> 7; // signed shift sign extends
CPU.VPR[vd]._u8[w*4 + 2] = (VB._u8[w*2 + 1] >> 2) & 0x1f;
CPU.VPR[vd]._u8[w*4 + 1] = ((VB._u8[w*2 + 1] & 0x3) << 3) | ((VB._u8[w*2 + 0] >> 5) & 0x7);
CPU.VPR[vd]._u8[w*4 + 0] = VB._u8[w*2 + 0] & 0x1f;
}
}
void VUPKLSB(u32 vd, u32 vb) //nf
{
u128 VB = CPU.VPR[vb];
for (uint h = 0; h < 8; h++)
{
CPU.VPR[vd]._s16[h] = VB._s8[h];
}
}
void VUPKLSH(u32 vd, u32 vb)
{
u128 VB = CPU.VPR[vb];
for (uint w = 0; w < 4; w++)
{
CPU.VPR[vd]._s32[w] = VB._s16[w];
}
}
void VXOR(u32 vd, u32 va, u32 vb)
{
CPU.VPR[vd]._u32[0] = CPU.VPR[va]._u32[0] ^ CPU.VPR[vb]._u32[0];
CPU.VPR[vd]._u32[1] = CPU.VPR[va]._u32[1] ^ CPU.VPR[vb]._u32[1];
CPU.VPR[vd]._u32[2] = CPU.VPR[va]._u32[2] ^ CPU.VPR[vb]._u32[2];
CPU.VPR[vd]._u32[3] = CPU.VPR[va]._u32[3] ^ CPU.VPR[vb]._u32[3];
}
void MULLI(u32 rd, u32 ra, s32 simm16)
{
CPU.GPR[rd] = (s64)CPU.GPR[ra] * simm16;
}
void SUBFIC(u32 rd, u32 ra, s32 simm16)
{
const u64 RA = CPU.GPR[ra];
const u64 IMM = (s64)simm16;
CPU.GPR[rd] = ~RA + IMM + 1;
CPU.XER.CA = CPU.IsCarry(~RA, IMM, 1);
}
void CMPLI(u32 crfd, u32 l, u32 ra, u32 uimm16)
{
CPU.UpdateCRnU(l, crfd, CPU.GPR[ra], uimm16);
}
void CMPI(u32 crfd, u32 l, u32 ra, s32 simm16)
{
CPU.UpdateCRnS(l, crfd, CPU.GPR[ra], simm16);
}
void ADDIC(u32 rd, u32 ra, s32 simm16)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = RA + simm16;
CPU.XER.CA = CPU.IsCarry(RA, simm16);
}
void ADDIC_(u32 rd, u32 ra, s32 simm16)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = RA + simm16;
CPU.XER.CA = CPU.IsCarry(RA, simm16);
CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void ADDI(u32 rd, u32 ra, s32 simm16)
{
CPU.GPR[rd] = ra ? ((s64)CPU.GPR[ra] + simm16) : simm16;
}
void ADDIS(u32 rd, u32 ra, s32 simm16)
{
CPU.GPR[rd] = ra ? ((s64)CPU.GPR[ra] + (simm16 << 16)) : (simm16 << 16);
}
void BC(u32 bo, u32 bi, s32 bd, u32 aa, u32 lk)
{
if (CheckCondition(bo, bi))
{
const u32 nextLR = CPU.PC + 4;
CPU.SetBranch(branchTarget((aa ? 0 : CPU.PC), bd), lk);
if(lk) CPU.LR = nextLR;
}
}
void HACK(u32 index)
{
execute_ppu_func_by_index(CPU, index);
}
void SC(u32 lev)
{
switch (lev)
{
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
case 0x1: throw "SC(): HyperCall LV1";
case 0x3: CPU.FastStop(); break;
default: throw fmt::Format("SC(): unknown level (0x%x)", lev);
}
}
void B(s32 ll, u32 aa, u32 lk)
{
const u32 nextLR = CPU.PC + 4;
CPU.SetBranch(branchTarget(aa ? 0 : CPU.PC, ll), lk);
if(lk) CPU.LR = nextLR;
}
void MCRF(u32 crfd, u32 crfs)
{
CPU.SetCR(crfd, CPU.GetCR(crfs));
}
void BCLR(u32 bo, u32 bi, u32 bh, u32 lk)
{
if (CheckCondition(bo, bi))
{
const u32 nextLR = CPU.PC + 4;
CPU.SetBranch(branchTarget(0, (u32)CPU.LR), true);
if(lk) CPU.LR = nextLR;
}
}
void CRNOR(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = 1 ^ (CPU.IsCR(crba) | CPU.IsCR(crbb));
CPU.SetCRBit2(crbd, v & 0x1);
}
void CRANDC(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = CPU.IsCR(crba) & (1 ^ CPU.IsCR(crbb));
CPU.SetCRBit2(crbd, v & 0x1);
}
void ISYNC()
{
_mm_mfence();
}
void CRXOR(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = CPU.IsCR(crba) ^ CPU.IsCR(crbb);
CPU.SetCRBit2(crbd, v & 0x1);
}
void CRNAND(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = 1 ^ (CPU.IsCR(crba) & CPU.IsCR(crbb));
CPU.SetCRBit2(crbd, v & 0x1);
}
void CRAND(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = CPU.IsCR(crba) & CPU.IsCR(crbb);
CPU.SetCRBit2(crbd, v & 0x1);
}
void CREQV(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = 1 ^ (CPU.IsCR(crba) ^ CPU.IsCR(crbb));
CPU.SetCRBit2(crbd, v & 0x1);
}
void CRORC(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = CPU.IsCR(crba) | (1 ^ CPU.IsCR(crbb));
CPU.SetCRBit2(crbd, v & 0x1);
}
void CROR(u32 crbd, u32 crba, u32 crbb)
{
const u8 v = CPU.IsCR(crba) | CPU.IsCR(crbb);
CPU.SetCRBit2(crbd, v & 0x1);
}
void BCCTR(u32 bo, u32 bi, u32 bh, u32 lk)
{
if(bo & 0x10 || CPU.IsCR(bi) == ((bo & 0x8) != 0))
{
const u32 nextLR = CPU.PC + 4;
CPU.SetBranch(branchTarget(0, (u32)CPU.CTR), true);
if(lk) CPU.LR = nextLR;
}
}
void RLWIMI(u32 ra, u32 rs, u32 sh, u32 mb, u32 me, bool rc)
{
const u64 mask = rotate_mask[32 + mb][32 + me];
CPU.GPR[ra] = (CPU.GPR[ra] & ~mask) | (rotl32(CPU.GPR[rs], sh) & mask);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLWINM(u32 ra, u32 rs, u32 sh, u32 mb, u32 me, bool rc)
{
CPU.GPR[ra] = rotl32(CPU.GPR[rs], sh) & rotate_mask[32 + mb][32 + me];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLWNM(u32 ra, u32 rs, u32 rb, u32 mb, u32 me, bool rc)
{
CPU.GPR[ra] = rotl32(CPU.GPR[rs], CPU.GPR[rb] & 0x1f) & rotate_mask[32 + mb][32 + me];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ORI(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] | uimm16;
}
void ORIS(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] | ((u64)uimm16 << 16);
}
void XORI(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] ^ uimm16;
}
void XORIS(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] ^ ((u64)uimm16 << 16);
}
void ANDI_(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] & uimm16;
CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ANDIS_(u32 ra, u32 rs, u32 uimm16)
{
CPU.GPR[ra] = CPU.GPR[rs] & ((u64)uimm16 << 16);
CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLDICL(u32 ra, u32 rs, u32 sh, u32 mb, bool rc)
{
CPU.GPR[ra] = rotl64(CPU.GPR[rs], sh) & rotate_mask[mb][63];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLDICR(u32 ra, u32 rs, u32 sh, u32 me, bool rc)
{
CPU.GPR[ra] = rotl64(CPU.GPR[rs], sh) & rotate_mask[0][me];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLDIC(u32 ra, u32 rs, u32 sh, u32 mb, bool rc)
{
CPU.GPR[ra] = rotl64(CPU.GPR[rs], sh) & rotate_mask[mb][63-sh];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLDIMI(u32 ra, u32 rs, u32 sh, u32 mb, bool rc)
{
const u64 mask = rotate_mask[mb][63-sh];
CPU.GPR[ra] = (CPU.GPR[ra] & ~mask) | (rotl64(CPU.GPR[rs], sh) & mask);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void RLDC_LR(u32 ra, u32 rs, u32 rb, u32 m_eb, bool is_r, bool rc)
{
if (is_r) // rldcr
{
RLDICR(ra, rs, (u32)(CPU.GPR[rb] & 0x3F), m_eb, rc);
}
else // rldcl
{
RLDICL(ra, rs, (u32)(CPU.GPR[rb] & 0x3F), m_eb, rc);
}
}
void CMP(u32 crfd, u32 l, u32 ra, u32 rb)
{
CPU.UpdateCRnS(l, crfd, CPU.GPR[ra], CPU.GPR[rb]);
}
void TW(u32 to, u32 ra, u32 rb)
{
s32 a = (s32)CPU.GPR[ra];
s32 b = (s32)CPU.GPR[rb];
if( (a < b && (to & 0x10)) ||
(a > b && (to & 0x8)) ||
(a == b && (to & 0x4)) ||
((u32)a < (u32)b && (to & 0x2)) ||
((u32)a > (u32)b && (to & 0x1)) )
{
throw fmt::Format("Trap! (tw 0x%x, r%d, r%d)", to, ra, rb);
}
}
void LVSL(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
static const u64 lvsl_values[0x10][2] =
{
{0x08090A0B0C0D0E0F, 0x0001020304050607},
{0x090A0B0C0D0E0F10, 0x0102030405060708},
{0x0A0B0C0D0E0F1011, 0x0203040506070809},
{0x0B0C0D0E0F101112, 0x030405060708090A},
{0x0C0D0E0F10111213, 0x0405060708090A0B},
{0x0D0E0F1011121314, 0x05060708090A0B0C},
{0x0E0F101112131415, 0x060708090A0B0C0D},
{0x0F10111213141516, 0x0708090A0B0C0D0E},
{0x1011121314151617, 0x08090A0B0C0D0E0F},
{0x1112131415161718, 0x090A0B0C0D0E0F10},
{0x1213141516171819, 0x0A0B0C0D0E0F1011},
{0x131415161718191A, 0x0B0C0D0E0F101112},
{0x1415161718191A1B, 0x0C0D0E0F10111213},
{0x15161718191A1B1C, 0x0D0E0F1011121314},
{0x161718191A1B1C1D, 0x0E0F101112131415},
{0x1718191A1B1C1D1E, 0x0F10111213141516},
};
CPU.VPR[vd]._u64[0] = lvsl_values[addr & 0xf][0];
CPU.VPR[vd]._u64[1] = lvsl_values[addr & 0xf][1];
}
void LVEBX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.VPR[vd]._u8[15 - (addr & 0xf)] = vm::read8(vm::cast(addr));
// check LVEWX comments
}
void SUBFC(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
CPU.GPR[rd] = ~RA + RB + 1;
CPU.XER.CA = CPU.IsCarry(~RA, RB, 1);
if(oe) CPU.SetOV((~RA>>63 == RB>>63) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MULHDU(u32 rd, u32 ra, u32 rb, bool rc)
{
CPU.GPR[rd] = __umulh(CPU.GPR[ra], CPU.GPR[rb]);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void ADDC(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
CPU.GPR[rd] = RA + RB;
CPU.XER.CA = CPU.IsCarry(RA, RB);
if(oe) CPU.SetOV((RA>>63 == RB>>63) && (RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MULHWU(u32 rd, u32 ra, u32 rb, bool rc)
{
u32 a = (u32)CPU.GPR[ra];
u32 b = (u32)CPU.GPR[rb];
CPU.GPR[rd] = ((u64)a * (u64)b) >> 32;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MFOCRF(u32 a, u32 rd, u32 crm)
{
CPU.GPR[rd] = CPU.CR.CR;
}
void LWARX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
be_t<u32> value;
vm::reservation_acquire(&value, vm::cast(addr), sizeof(value));
CPU.GPR[rd] = value;
}
void LDX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::read64(vm::cast(addr));
}
void LWZX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::read32(vm::cast(addr));
}
void SLW(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x1f;
u32 r = (u32)rotl32((u32)CPU.GPR[rs], n);
u32 m = ((u32)CPU.GPR[rb] & 0x20) ? 0 : (u32)rotate_mask[32][63 - n];
CPU.GPR[ra] = r & m;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void CNTLZW(u32 ra, u32 rs, bool rc)
{
u32 i;
for(i=0; i < 32; i++)
{
if(CPU.GPR[rs] & (1ULL << (31 - i))) break;
}
CPU.GPR[ra] = i;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void SLD(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x3f;
u64 r = rotl64(CPU.GPR[rs], n);
u64 m = (CPU.GPR[rb] & 0x40) ? 0 : rotate_mask[0][63 - n];
CPU.GPR[ra] = r & m;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void AND(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = CPU.GPR[rs] & CPU.GPR[rb];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void CMPL(u32 crfd, u32 l, u32 ra, u32 rb)
{
CPU.UpdateCRnU(l, crfd, CPU.GPR[ra], CPU.GPR[rb]);
}
void LVSR(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
static const u64 lvsr_values[0x10][2] =
{
{0x18191A1B1C1D1E1F, 0x1011121314151617},
{0x1718191A1B1C1D1E, 0x0F10111213141516},
{0x161718191A1B1C1D, 0x0E0F101112131415},
{0x15161718191A1B1C, 0x0D0E0F1011121314},
{0x1415161718191A1B, 0x0C0D0E0F10111213},
{0x131415161718191A, 0x0B0C0D0E0F101112},
{0x1213141516171819, 0x0A0B0C0D0E0F1011},
{0x1112131415161718, 0x090A0B0C0D0E0F10},
{0x1011121314151617, 0x08090A0B0C0D0E0F},
{0x0F10111213141516, 0x0708090A0B0C0D0E},
{0x0E0F101112131415, 0x060708090A0B0C0D},
{0x0D0E0F1011121314, 0x05060708090A0B0C},
{0x0C0D0E0F10111213, 0x0405060708090A0B},
{0x0B0C0D0E0F101112, 0x030405060708090A},
{0x0A0B0C0D0E0F1011, 0x0203040506070809},
{0x090A0B0C0D0E0F10, 0x0102030405060708},
};
CPU.VPR[vd]._u64[0] = lvsr_values[addr & 0xf][0];
CPU.VPR[vd]._u64[1] = lvsr_values[addr & 0xf][1];
}
void LVEHX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~1ULL;
CPU.VPR[vd]._u16[7 - ((addr >> 1) & 0x7)] = vm::read16(vm::cast(addr));
// check LVEWX comments
}
void SUBF(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
CPU.GPR[rd] = RB - RA;
if(oe) CPU.SetOV((~RA>>63 == RB>>63) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void LDUX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
CPU.GPR[rd] = vm::read64(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void DCBST(u32 ra, u32 rb)
{
}
void LWZUX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
CPU.GPR[rd] = vm::read32(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void CNTLZD(u32 ra, u32 rs, bool rc)
{
u32 i;
for(i=0; i < 64; i++)
{
if(CPU.GPR[rs] & (1ULL << (63 - i))) break;
}
CPU.GPR[ra] = i;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ANDC(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = CPU.GPR[rs] & ~CPU.GPR[rb];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void TD(u32 to, u32 ra, u32 rb)
{
throw "TD()";
}
void LVEWX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~3ULL;
CPU.VPR[vd]._u32[3 - ((addr >> 2) & 0x3)] = vm::read32(vm::cast(addr));
// It's not very good idea to implement it using read128(),
// because it can theoretically read RawSPU 32-bit MMIO register (read128() will fail)
//CPU.VPR[vd] = vm::read128((ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfULL);
}
void MULHD(u32 rd, u32 ra, u32 rb, bool rc)
{
CPU.GPR[rd] = __mulh(CPU.GPR[ra], CPU.GPR[rb]);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MULHW(u32 rd, u32 ra, u32 rb, bool rc)
{
s32 a = (s32)CPU.GPR[ra];
s32 b = (s32)CPU.GPR[rb];
CPU.GPR[rd] = ((s64)a * (s64)b) >> 32;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void LDARX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
be_t<u64> value;
vm::reservation_acquire(&value, vm::cast(addr), sizeof(value));
CPU.GPR[rd] = value;
}
void DCBF(u32 ra, u32 rb)
{
}
void LBZX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::read8(vm::cast(addr));
}
void LVX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull;
CPU.VPR[vd] = vm::read128(vm::cast(addr));
}
void NEG(u32 rd, u32 ra, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = 0 - RA;
if(oe) CPU.SetOV((~RA>>63 == 0) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void LBZUX(u32 rd, u32 ra, u32 rb)
{
//if(ra == 0 || ra == rd) throw "Bad instruction [LBZUX]";
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
CPU.GPR[rd] = vm::read8(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void NOR(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = ~(CPU.GPR[rs] | CPU.GPR[rb]);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void STVEBX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u8 eb = addr & 0xf;
vm::write8(vm::cast(addr), CPU.VPR[vs]._u8[15 - eb]);
}
void SUBFE(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
CPU.GPR[rd] = ~RA + RB + CPU.XER.CA;
CPU.XER.CA = CPU.IsCarry(~RA, RB, CPU.XER.CA);
if(oe) CPU.SetOV((~RA>>63 == RB>>63) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void ADDE(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
if (CPU.XER.CA)
{
if (RA == ~0ULL) //-1
{
CPU.GPR[rd] = RB;
CPU.XER.CA = 1;
}
else
{
CPU.GPR[rd] = RA + 1 + RB;
CPU.XER.CA = CPU.IsCarry(RA + 1, RB);
}
}
else
{
CPU.GPR[rd] = RA + RB;
CPU.XER.CA = CPU.IsCarry(RA, RB);
}
if(oe) CPU.SetOV((RA>>63 == RB>>63) && (RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MTOCRF(u32 l, u32 crm, u32 rs)
{
if(l)
{
u32 n = 0, count = 0;
for(u32 i=0; i<8; ++i)
{
if(crm & (1 << i))
{
n = i;
count++;
}
}
if(count == 1)
{
//CR[4*n : 4*n+3] = RS[32+4*n : 32+4*n+3];
CPU.SetCR(7 - n, (CPU.GPR[rs] >> (4*n)) & 0xf);
}
else
CPU.CR.CR = 0;
}
else
{
for(u32 i=0; i<8; ++i)
{
if(crm & (1 << i))
{
CPU.SetCR(7 - i, (CPU.GPR[rs] >> (i * 4)) & 0xf);
}
}
}
}
void STDX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::write64(vm::cast(addr), CPU.GPR[rs]);
}
void STWCX_(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const be_t<u32> value = be_t<u32>::make((u32)CPU.GPR[rs]);
CPU.SetCR_EQ(0, vm::reservation_update(vm::cast(addr), &value, sizeof(value)));
}
void STWX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::write32(vm::cast(addr), (u32)CPU.GPR[rs]);
}
void STVEHX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~1ULL;
const u8 eb = (addr & 0xf) >> 1;
vm::write16(vm::cast(addr), CPU.VPR[vs]._u16[7 - eb]);
}
void STDUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
vm::write64(vm::cast(addr), CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void STWUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
vm::write32(vm::cast(addr), (u32)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void STVEWX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~3ULL;
const u8 eb = (addr & 0xf) >> 2;
vm::write32(vm::cast(addr), CPU.VPR[vs]._u32[3 - eb]);
}
void SUBFZE(u32 rd, u32 ra, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = ~RA + CPU.XER.CA;
CPU.XER.CA = CPU.IsCarry(~RA, CPU.XER.CA);
if(oe) CPU.SetOV((~RA>>63 == 0) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void ADDZE(u32 rd, u32 ra, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = RA + CPU.XER.CA;
CPU.XER.CA = CPU.IsCarry(RA, CPU.XER.CA);
if(oe) CPU.SetOV((RA>>63 == 0) && (RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void STDCX_(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const be_t<u64> value = be_t<u64>::make(CPU.GPR[rs]);
CPU.SetCR_EQ(0, vm::reservation_update(vm::cast(addr), &value, sizeof(value)));
}
void STBX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::write8(vm::cast(addr), (u8)CPU.GPR[rs]);
}
void STVX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull;
vm::write128(vm::cast(addr), CPU.VPR[vs]);
}
void MULLD(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const s64 RA = CPU.GPR[ra];
const s64 RB = CPU.GPR[rb];
CPU.GPR[rd] = (s64)(RA * RB);
if(oe)
{
const s64 high = __mulh(RA, RB);
CPU.SetOV(high != s64(CPU.GPR[rd]) >> 63);
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void SUBFME(u32 rd, u32 ra, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
CPU.GPR[rd] = ~RA + CPU.XER.CA + ~0ULL;
CPU.XER.CA = CPU.IsCarry(~RA, CPU.XER.CA, ~0ULL);
if(oe) CPU.SetOV((~RA>>63 == 1) && (~RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void ADDME(u32 rd, u32 ra, u32 oe, bool rc)
{
const s64 RA = CPU.GPR[ra];
CPU.GPR[rd] = RA + CPU.XER.CA - 1;
CPU.XER.CA |= RA != 0;
if(oe) CPU.SetOV((u64(RA)>>63 == 1) && (u64(RA)>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MULLW(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
CPU.GPR[rd] = (s64)((s64)(s32)CPU.GPR[ra] * (s64)(s32)CPU.GPR[rb]);
if(oe) CPU.SetOV(s64(CPU.GPR[rd]) < s64(-1)<<31 || s64(CPU.GPR[rd]) >= s64(1)<<31);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void DCBTST(u32 ra, u32 rb, u32 th)
{
}
void STBUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
vm::write8(vm::cast(addr), (u8)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void ADD(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
CPU.GPR[rd] = RA + RB;
if(oe) CPU.SetOV((RA>>63 == RB>>63) && (RA>>63 != CPU.GPR[rd]>>63));
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void DCBT(u32 ra, u32 rb, u32 th)
{
}
void LHZX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::read16(vm::cast(addr));
}
void EQV(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = ~(CPU.GPR[rs] ^ CPU.GPR[rb]);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ECIWX(u32 rd, u32 ra, u32 rb)
{
throw __FUNCTION__;
}
void LHZUX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::read16(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void XOR(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = CPU.GPR[rs] ^ CPU.GPR[rb];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void MFSPR(u32 rd, u32 spr)
{
CPU.GPR[rd] = ReadSPR(spr);
}
void LWAX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = (s64)(s32)vm::read32(vm::cast(addr));
}
void DST(u32 ra, u32 rb, u32 strm, u32 t)
{
}
void LHAX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = (s64)(s16)vm::read16(vm::cast(addr));
}
void LVXL(u32 vd, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull;
CPU.VPR[vd] = vm::read128(vm::cast(addr));
}
void MFTB(u32 rd, u32 spr)
{
const u32 n = (spr >> 5) | ((spr & 0x1f) << 5);
CPU.TB = get_time();
switch(n)
{
case 0x10C: CPU.GPR[rd] = CPU.TB; break;
case 0x10D: CPU.GPR[rd] = CPU.TB >> 32; break;
default: throw fmt::Format("mftb r%d, %d", rd, spr);
}
}
void LWAUX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = (s64)(s32)vm::read32(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void DSTST(u32 ra, u32 rb, u32 strm, u32 t)
{
}
void LHAUX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = (s64)(s16)vm::read16(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void STHX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::write16(vm::cast(addr), (u16)CPU.GPR[rs]);
}
void ORC(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = CPU.GPR[rs] | ~CPU.GPR[rb];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ECOWX(u32 rs, u32 ra, u32 rb)
{
throw __FUNCTION__;
}
void STHUX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
vm::write16(vm::cast(addr), (u16)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void OR(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = CPU.GPR[rs] | CPU.GPR[rb];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void DIVDU(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u64 RA = CPU.GPR[ra];
const u64 RB = CPU.GPR[rb];
if(RB == 0)
{
if(oe) CPU.SetOV(true);
CPU.GPR[rd] = 0;
}
else
{
if(oe) CPU.SetOV(false);
CPU.GPR[rd] = RA / RB;
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void DIVWU(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const u32 RA = (u32)CPU.GPR[ra];
const u32 RB = (u32)CPU.GPR[rb];
if(RB == 0)
{
if(oe) CPU.SetOV(true);
CPU.GPR[rd] = 0;
}
else
{
if(oe) CPU.SetOV(false);
CPU.GPR[rd] = RA / RB;
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void MTSPR(u32 spr, u32 rs)
{
WriteSPR(spr, CPU.GPR[rs]);
}
void DCBI(u32 ra, u32 rb)
{
}
void NAND(u32 ra, u32 rs, u32 rb, bool rc)
{
CPU.GPR[ra] = ~(CPU.GPR[rs] & CPU.GPR[rb]);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void STVXL(u32 vs, u32 ra, u32 rb)
{
const u64 addr = (ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb]) & ~0xfull;
vm::write128(vm::cast(addr), CPU.VPR[vs]);
}
void DIVD(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const s64 RA = CPU.GPR[ra];
const s64 RB = CPU.GPR[rb];
if (RB == 0 || ((u64)RA == (1ULL << 63) && RB == -1))
{
if(oe) CPU.SetOV(true);
CPU.GPR[rd] = /*(((u64)RA & (1ULL << 63)) && RB == 0) ? -1 :*/ 0;
}
else
{
if(oe) CPU.SetOV(false);
CPU.GPR[rd] = RA / RB;
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void DIVW(u32 rd, u32 ra, u32 rb, u32 oe, bool rc)
{
const s32 RA = (s32)CPU.GPR[ra];
const s32 RB = (s32)CPU.GPR[rb];
if (RB == 0 || ((u32)RA == (1 << 31) && RB == -1))
{
if(oe) CPU.SetOV(true);
CPU.GPR[rd] = /*(((u32)RA & (1 << 31)) && RB == 0) ? -1 :*/ 0;
}
else
{
if(oe) CPU.SetOV(false);
CPU.GPR[rd] = (u32)(RA / RB);
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[rd]);
}
void LVLX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u32 eb = addr & 0xf;
CPU.VPR[vd].clear();
for (u32 i = 0; i < 16u - eb; ++i) CPU.VPR[vd]._u8[15 - i] = vm::read8(vm::cast(addr + i));
}
void LDBRX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::get_ref<u64>(vm::cast(addr));
}
void LSWX(u32 rd, u32 ra, u32 rb)
{
u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
u32 count = CPU.XER.XER & 0x7F;
for (; count >= 4; count -= 4, addr += 4, rd = (rd+1) & 31)
{
CPU.GPR[rd] = vm::get_ref<be_t<u32>>(vm::cast(addr));
}
if (count)
{
u32 value = 0;
for (u32 byte = 0; byte < count; byte++)
{
u32 byte_value = vm::get_ref<u8>(vm::cast(addr+byte));
value |= byte_value << ((3^byte)*8);
}
CPU.GPR[rd] = value;
}
}
void LWBRX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::get_ref<u32>(vm::cast(addr));
}
void LFSX(u32 frd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
float val = vm::get_ref<be_t<float>>(vm::cast(addr)).value();
if (!FPRdouble::IsNaN(val))
{
CPU.FPR[frd] = val;
}
else
{
u64 bits = (u32&)val;
(u64&)CPU.FPR[frd] = (bits & 0x80000000) << 32 | 7ULL << 60 | (bits & 0x7fffffff) << 29;
}
}
void SRW(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x1f;
u32 r = (u32)rotl32((u32)CPU.GPR[rs], 64 - n);
u32 m = ((u32)CPU.GPR[rb] & 0x20) ? 0 : (u32)rotate_mask[32 + n][63];
CPU.GPR[ra] = r & m;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void SRD(u32 ra, u32 rs, u32 rb, bool rc)
{
u32 n = CPU.GPR[rb] & 0x3f;
u64 r = rotl64(CPU.GPR[rs], 64 - n);
u64 m = (CPU.GPR[rb] & 0x40) ? 0 : rotate_mask[n][63];
CPU.GPR[ra] = r & m;
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void LVRX(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u8 eb = addr & 0xf;
CPU.VPR[vd].clear();
for (u32 i = 16 - eb; i < 16; ++i) CPU.VPR[vd]._u8[15 - i] = vm::read8(vm::cast(addr + i - 16));
}
void LSWI(u32 rd, u32 ra, u32 nb)
{
u64 addr = ra ? CPU.GPR[ra] : 0;
u64 N = nb ? nb : 32;
u8 reg = rd;
while (N > 0)
{
if (N > 3)
{
CPU.GPR[reg] = vm::read32(vm::cast(addr));
addr += 4;
N -= 4;
}
else
{
u32 buf = 0;
u32 i = 3;
while (N > 0)
{
N = N - 1;
buf |= vm::read8(vm::cast(addr)) << (i * 8);
addr++;
i--;
}
CPU.GPR[reg] = buf;
}
reg = (reg + 1) % 32;
}
}
void LFSUX(u32 frd, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
float val = vm::get_ref<be_t<float>>(vm::cast(addr)).value();
if (!FPRdouble::IsNaN(val))
{
CPU.FPR[frd] = val;
}
else
{
u64 bits = (u32&)val;
(u64&)CPU.FPR[frd] = (bits & 0x80000000) << 32 | 7ULL << 60 | (bits & 0x7fffffff) << 29;
}
CPU.GPR[ra] = addr;
}
void SYNC(u32 l)
{
_mm_mfence();
}
void LFDX(u32 frd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.FPR[frd] = vm::get_ref<be_t<double>>(vm::cast(addr)).value();
}
void LFDUX(u32 frd, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
CPU.FPR[frd] = vm::get_ref<be_t<double>>(vm::cast(addr)).value();
CPU.GPR[ra] = addr;
}
void STVLX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u32 eb = addr & 0xf;
for (u32 i = 0; i < 16u - eb; ++i) vm::write8(vm::cast(addr + i), CPU.VPR[vs]._u8[15 - i]);
}
void STDBRX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::get_ref<u64>(vm::cast(addr)) = CPU.GPR[rs];
}
void STSWX(u32 rs, u32 ra, u32 rb)
{
u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
u32 count = CPU.XER.XER & 0x7F;
for (; count >= 4; count -= 4, addr += 4, rs = (rs+1) & 31)
{
vm::write32(vm::cast(addr), (u32)CPU.GPR[rs]);
}
if (count)
{
u32 value = (u32)CPU.GPR[rs];
for (u32 byte = 0; byte < count; byte++)
{
u32 byte_value = (u8)(value >> ((3^byte)*8));
vm::write8(vm::cast(addr+byte), byte_value);
}
}
}
void STWBRX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::get_ref<u32>(vm::cast(addr)) = (u32)CPU.GPR[rs];
}
void STFSX(u32 frs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
double val = CPU.FPR[frs];
if (!FPRdouble::IsNaN(val))
{
vm::get_ref<be_t<float>>(vm::cast(addr)) = (float)val;
}
else
{
u64 bits = (u64&)val;
u32 bits32 = (bits>>32 & 0x80000000) | (bits>>29 & 0x7fffffff);
vm::get_ref<be_t<u32>>(vm::cast(addr)) = bits32;
}
}
void STVRX(u32 vs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u8 eb = addr & 0xf;
for (u32 i = 16 - eb; i < 16; ++i) vm::write8(vm::cast(addr + i - 16), CPU.VPR[vs]._u8[15 - i]);
}
void STFSUX(u32 frs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
double val = CPU.FPR[frs];
if (!FPRdouble::IsNaN(val))
{
vm::get_ref<be_t<float>>(vm::cast(addr)) = (float)val;
}
else
{
u64 bits = (u64&)val;
u32 bits32 = (bits>>32 & 0x80000000) | (bits>>29 & 0x7fffffff);
vm::get_ref<be_t<u32>>(vm::cast(addr)) = bits32;
}
CPU.GPR[ra] = addr;
}
void STSWI(u32 rd, u32 ra, u32 nb)
{
u64 addr = ra ? CPU.GPR[ra] : 0;
u64 N = nb ? nb : 32;
u8 reg = rd;
while (N > 0)
{
if (N > 3)
{
vm::write32(vm::cast(addr), (u32)CPU.GPR[reg]);
addr += 4;
N -= 4;
}
else
{
u32 buf = (u32)CPU.GPR[reg];
while (N > 0)
{
N = N - 1;
vm::write8(vm::cast(addr), (0xFF000000 & buf) >> 24);
buf <<= 8;
addr++;
}
}
reg = (reg + 1) % 32;
}
}
void STFDX(u32 frs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::get_ref<be_t<double>>(vm::cast(addr)) = CPU.FPR[frs];
}
void STFDUX(u32 frs, u32 ra, u32 rb)
{
const u64 addr = CPU.GPR[ra] + CPU.GPR[rb];
vm::get_ref<be_t<double>>(vm::cast(addr)) = CPU.FPR[frs];
CPU.GPR[ra] = addr;
}
void LVLXL(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u32 eb = addr & 0xf;
CPU.VPR[vd].clear();
for (u32 i = 0; i < 16u - eb; ++i) CPU.VPR[vd]._u8[15 - i] = vm::read8(vm::cast(addr + i));
}
void LHBRX(u32 rd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
CPU.GPR[rd] = vm::get_ref<u16>(vm::cast(addr));
}
void SRAW(u32 ra, u32 rs, u32 rb, bool rc)
{
s32 RS = (s32)CPU.GPR[rs];
u8 shift = CPU.GPR[rb] & 63;
if (shift > 31)
{
CPU.GPR[ra] = 0 - (RS < 0);
CPU.XER.CA = (RS < 0);
}
else
{
CPU.GPR[ra] = RS >> shift;
CPU.XER.CA = (RS < 0) & ((CPU.GPR[ra] << shift) != RS);
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void SRAD(u32 ra, u32 rs, u32 rb, bool rc)
{
s64 RS = CPU.GPR[rs];
u8 shift = CPU.GPR[rb] & 127;
if (shift > 63)
{
CPU.GPR[ra] = 0 - (RS < 0);
CPU.XER.CA = (RS < 0);
}
else
{
CPU.GPR[ra] = RS >> shift;
CPU.XER.CA = (RS < 0) & ((CPU.GPR[ra] << shift) != RS);
}
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void LVRXL(u32 vd, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u8 eb = addr & 0xf;
CPU.VPR[vd].clear();
for (u32 i = 16 - eb; i < 16; ++i) CPU.VPR[vd]._u8[15 - i] = vm::read8(vm::cast(addr + i - 16));
}
void DSS(u32 strm, u32 a)
{
}
void SRAWI(u32 ra, u32 rs, u32 sh, bool rc)
{
s32 RS = (u32)CPU.GPR[rs];
CPU.GPR[ra] = RS >> sh;
CPU.XER.CA = (RS < 0) & ((u32)(CPU.GPR[ra] << sh) != RS);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void SRADI1(u32 ra, u32 rs, u32 sh, bool rc)
{
s64 RS = CPU.GPR[rs];
CPU.GPR[ra] = RS >> sh;
CPU.XER.CA = (RS < 0) & ((CPU.GPR[ra] << sh) != RS);
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void SRADI2(u32 ra, u32 rs, u32 sh, bool rc)
{
SRADI1(ra, rs, sh, rc);
}
void EIEIO()
{
_mm_mfence();
}
void STVLXL(u32 vs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u32 eb = addr & 0xf;
for (u32 i = 0; i < 16u - eb; ++i) vm::write8(vm::cast(addr + i), CPU.VPR[vs]._u8[15 - i]);
}
void STHBRX(u32 rs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::get_ref<u16>(vm::cast(addr)) = (u16)CPU.GPR[rs];
}
void EXTSH(u32 ra, u32 rs, bool rc)
{
CPU.GPR[ra] = (s64)(s16)CPU.GPR[rs];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void STVRXL(u32 vs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
const u8 eb = addr & 0xf;
for (u32 i = 16 - eb; i < 16; ++i) vm::write8(vm::cast(addr + i - 16), CPU.VPR[vs]._u8[15 - i]);
}
void EXTSB(u32 ra, u32 rs, bool rc)
{
CPU.GPR[ra] = (s64)(s8)CPU.GPR[rs];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void STFIWX(u32 frs, u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
vm::write32(vm::cast(addr), (u32&)CPU.FPR[frs]);
}
void EXTSW(u32 ra, u32 rs, bool rc)
{
CPU.GPR[ra] = (s64)(s32)CPU.GPR[rs];
if(rc) CPU.UpdateCR0<s64>(CPU.GPR[ra]);
}
void ICBI(u32 ra, u32 rs)
{
// Clear jit for the specified block? Nothing to do in the interpreter.
}
void DCBZ(u32 ra, u32 rb)
{
const u64 addr = ra ? CPU.GPR[ra] + CPU.GPR[rb] : CPU.GPR[rb];
memset(vm::get_ptr<u8>(vm::cast(addr) & ~127), 0, 128);
}
void LWZ(u32 rd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
CPU.GPR[rd] = vm::read32(vm::cast(addr));
}
void LWZU(u32 rd, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
CPU.GPR[rd] = vm::read32(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void LBZ(u32 rd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
CPU.GPR[rd] = vm::read8(vm::cast(addr));
}
void LBZU(u32 rd, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
CPU.GPR[rd] = vm::read8(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void STW(u32 rs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
vm::write32(vm::cast(addr), (u32)CPU.GPR[rs]);
}
void STWU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
vm::write32(vm::cast(addr), (u32)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void STB(u32 rs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
vm::write8(vm::cast(addr), (u8)CPU.GPR[rs]);
}
void STBU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
vm::write8(vm::cast(addr), (u8)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void LHZ(u32 rd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
CPU.GPR[rd] = vm::read16(vm::cast(addr));
}
void LHZU(u32 rd, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
CPU.GPR[rd] = vm::read16(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void LHA(u32 rd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
CPU.GPR[rd] = (s64)(s16)vm::read16(vm::cast(addr));
}
void LHAU(u32 rd, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
CPU.GPR[rd] = (s64)(s16)vm::read16(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void STH(u32 rs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
vm::write16(vm::cast(addr), (u16)CPU.GPR[rs]);
}
void STHU(u32 rs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
vm::write16(vm::cast(addr), (u16)CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void LMW(u32 rd, u32 ra, s32 d)
{
u64 addr = ra ? CPU.GPR[ra] + d : d;
for(u32 i=rd; i<32; ++i, addr += 4)
{
CPU.GPR[i] = vm::read32(vm::cast(addr));
}
}
void STMW(u32 rs, u32 ra, s32 d)
{
u64 addr = ra ? CPU.GPR[ra] + d : d;
for(u32 i=rs; i<32; ++i, addr += 4)
{
vm::write32(vm::cast(addr), (u32)CPU.GPR[i]);
}
}
void LFS(u32 frd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
float val = vm::get_ref<be_t<float>>(vm::cast(addr)).value();
if (!FPRdouble::IsNaN(val))
{
CPU.FPR[frd] = val;
}
else
{
u64 bits = (u32&)val;
(u64&)CPU.FPR[frd] = (bits & 0x80000000) << 32 | 7ULL << 60 | (bits & 0x7fffffff) << 29;
}
}
void LFSU(u32 frd, u32 ra, s32 ds)
{
const u64 addr = CPU.GPR[ra] + ds;
float val = vm::get_ref<be_t<float>>(vm::cast(addr)).value();
if (!FPRdouble::IsNaN(val))
{
CPU.FPR[frd] = val;
}
else
{
u64 bits = (u32&)val;
(u64&)CPU.FPR[frd] = (bits & 0x80000000) << 32 | 7ULL << 60 | (bits & 0x7fffffff) << 29;
}
CPU.GPR[ra] = addr;
}
void LFD(u32 frd, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
CPU.FPR[frd] = vm::get_ref<be_t<double>>(vm::cast(addr)).value();
}
void LFDU(u32 frd, u32 ra, s32 ds)
{
const u64 addr = CPU.GPR[ra] + ds;
CPU.FPR[frd] = vm::get_ref<be_t<double>>(vm::cast(addr)).value();
CPU.GPR[ra] = addr;
}
void STFS(u32 frs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
double val = CPU.FPR[frs];
if (!FPRdouble::IsNaN(val))
{
vm::get_ref<be_t<float>>(vm::cast(addr)) = (float)val;
}
else
{
u64 bits = (u64&)val;
u32 bits32 = (bits>>32 & 0x80000000) | (bits>>29 & 0x7fffffff);
vm::get_ref<be_t<u32>>(vm::cast(addr)) = bits32;
}
}
void STFSU(u32 frs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
double val = CPU.FPR[frs];
if (!FPRdouble::IsNaN(val))
{
vm::get_ref<be_t<float>>(vm::cast(addr)) = (float)val;
}
else
{
u64 bits = (u64&)val;
u32 bits32 = (bits>>32 & 0x80000000) | (bits>>29 & 0x7fffffff);
vm::get_ref<be_t<u32>>(vm::cast(addr)) = bits32;
}
CPU.GPR[ra] = addr;
}
void STFD(u32 frs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
vm::get_ref<be_t<double>>(vm::cast(addr)) = CPU.FPR[frs];
}
void STFDU(u32 frs, u32 ra, s32 d)
{
const u64 addr = CPU.GPR[ra] + d;
vm::get_ref<be_t<double>>(vm::cast(addr)) = CPU.FPR[frs];
CPU.GPR[ra] = addr;
}
void LD(u32 rd, u32 ra, s32 ds)
{
const u64 addr = ra ? CPU.GPR[ra] + ds : ds;
CPU.GPR[rd] = vm::read64(vm::cast(addr));
}
void LDU(u32 rd, u32 ra, s32 ds)
{
const u64 addr = CPU.GPR[ra] + ds;
CPU.GPR[rd] = vm::read64(vm::cast(addr));
CPU.GPR[ra] = addr;
}
void LWA(u32 rd, u32 ra, s32 ds)
{
const u64 addr = ra ? CPU.GPR[ra] + ds : ds;
CPU.GPR[rd] = (s64)(s32)vm::read32(vm::cast(addr));
}
void FDIVS(u32 frd, u32 fra, u32 frb, bool rc) {FDIV(frd, fra, frb, rc, true);}
void FSUBS(u32 frd, u32 fra, u32 frb, bool rc) {FSUB(frd, fra, frb, rc, true);}
void FADDS(u32 frd, u32 fra, u32 frb, bool rc) {FADD(frd, fra, frb, rc, true);}
void FSQRTS(u32 frd, u32 frb, bool rc) {FSQRT(frd, frb, rc, true);}
void FRES(u32 frd, u32 frb, bool rc)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(b == 0.0)
{
CPU.SetFPSCRException(FPSCR_ZX);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if (CPU.FPSCR.ZE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = 1.0 / b;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
CPU.FPR[frd] = static_cast<float>(1.0 / b);
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FMULS(u32 frd, u32 fra, u32 frc, bool rc) {FMUL(frd, fra, frc, rc, true);}
void FMADDS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, false, false, true);}
void FMSUBS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, false, true, true);}
void FNMSUBS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, true, true, true);}
void FNMADDS(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, true, false, true);}
void STD(u32 rs, u32 ra, s32 d)
{
const u64 addr = ra ? CPU.GPR[ra] + d : d;
vm::write64(vm::cast(addr), CPU.GPR[rs]);
}
void STDU(u32 rs, u32 ra, s32 ds)
{
const u64 addr = CPU.GPR[ra] + ds;
vm::write64(vm::cast(addr), CPU.GPR[rs]);
CPU.GPR[ra] = addr;
}
void MTFSB1(u32 crbd, bool rc)
{
u32 mask = 1 << (31 - crbd);
if ((crbd >= 3 && crbd <= 6) && !(CPU.FPSCR.FPSCR & mask)) mask |= 1 << 31; //FPSCR.FX
if ((crbd == 29) && !CPU.FPSCR.NI) LOG_WARNING(PPU, "Non-IEEE mode enabled");
CPU.SetFPSCR(CPU.FPSCR.FPSCR | mask);
if(rc) CPU.UpdateCR1();
}
void MCRFS(u32 crbd, u32 crbs)
{
CPU.SetCR(crbd, (CPU.FPSCR.FPSCR >> ((7 - crbs) * 4)) & 0xf);
const u32 exceptions_mask = 0x9FF80700;
CPU.SetFPSCR(CPU.FPSCR.FPSCR & ~(exceptions_mask & 0xf << ((7 - crbs) * 4)));
}
void MTFSB0(u32 crbd, bool rc)
{
u32 mask = 1 << (31 - crbd);
if ((crbd == 29) && !CPU.FPSCR.NI) LOG_WARNING(PPU, "Non-IEEE mode disabled");
CPU.SetFPSCR(CPU.FPSCR.FPSCR & ~mask);
if(rc) CPU.UpdateCR1();
}
void MTFSFI(u32 crfd, u32 i, bool rc)
{
u32 mask = 0xF0000000 >> (crfd * 4);
u32 val = (i & 0xF) << ((7 - crfd) * 4);
const u32 oldNI = CPU.FPSCR.NI;
CPU.SetFPSCR((CPU.FPSCR.FPSCR & ~mask) | val);
if (CPU.FPSCR.NI != oldNI)
{
if (oldNI)
LOG_WARNING(PPU, "Non-IEEE mode disabled");
else
LOG_WARNING(PPU, "Non-IEEE mode enabled");
}
if(rc) CPU.UpdateCR1();
}
void MFFS(u32 frd, bool rc)
{
(u64&)CPU.FPR[frd] = CPU.FPSCR.FPSCR;
if(rc) CPU.UpdateCR1();
}
void MTFSF(u32 flm, u32 frb, bool rc)
{
u32 mask = 0;
for(u32 i=0; i<8; ++i)
{
if(flm & (1 << i)) mask |= 0xf << (i * 4);
}
mask &= ~0x60000000;
const u32 oldNI = CPU.FPSCR.NI;
CPU.SetFPSCR((CPU.FPSCR.FPSCR & ~mask) | ((u32&)CPU.FPR[frb] & mask));
if (CPU.FPSCR.NI != oldNI)
{
if (oldNI)
LOG_WARNING(PPU, "Non-IEEE mode disabled");
else
LOG_WARNING(PPU, "Non-IEEE mode enabled");
}
if(rc) CPU.UpdateCR1();
}
void FCMPU(u32 crfd, u32 fra, u32 frb)
{
int cmp_res = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb]);
if(cmp_res == CR_SO)
{
if(FPRdouble::IsSNaN(CPU.FPR[fra]) || FPRdouble::IsSNaN(CPU.FPR[frb]))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
}
}
CPU.FPSCR.FPRF = cmp_res;
CPU.SetCR(crfd, cmp_res);
}
void FRSP(u32 frd, u32 frb, bool rc)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double b = CPU.FPR[frb];
if (FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if (CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
double b0 = b;
if(CPU.FPSCR.NI)
{
if (((u64&)b0 & DOUBLE_EXP) < 0x3800000000000000ULL) (u64&)b0 &= DOUBLE_SIGN;
}
feclearexcept(FE_ALL_EXCEPT);
const double r = static_cast<float>(b0);
if (FPRdouble::IsNaN(r))
{
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
}
else
{
CPU.FPSCR.FR = fabs(r) > fabs(b);
CheckHostFPExceptions();
}
u32 type = PPCdouble(r).GetType();
if (type == FPR_PN && r < ldexp(1.0, -126)) type = FPR_PD;
else if (type == FPR_NN && r > ldexp(-1.0, -126)) type = FPR_ND;
CPU.FPSCR.FPRF = type;
CPU.FPR[frd] = r;
if(rc) CPU.UpdateCR1();
}
void FCTIW(u32 frd, u32 frb, bool rc) {FCTIW(frd, frb, rc, false);}
void FCTIW(u32 frd, u32 frb, bool rc, bool truncate)
{
const double b = CPU.FPR[frb];
u32 r;
if (FPRdouble::IsNaN(b) || b < -(double)0x80000000)
{
CPU.SetFPSCRException(FPSCR_VXCVI);
if(FPRdouble::IsSNaN(b)) CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FI = 0;
CPU.FPSCR.FR = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
r = 0x80000000;
}
else if(b > (double)0x7fffffff)
{
CPU.SetFPSCRException(FPSCR_VXCVI);
CPU.FPSCR.FI = 0;
CPU.FPSCR.FR = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
r = 0x7fffffff;
}
else
{
s32 i = 0;
const u32 rn = truncate ? FPSCR_RN_ZERO : CPU.FPSCR.RN;
switch(rn)
{
case FPSCR_RN_NEAR:
SetHostRoundingMode(FPSCR_RN_NEAR);
i = (s32)nearbyint(b);
break;
case FPSCR_RN_ZERO:
i = (s32)b;
break;
case FPSCR_RN_PINF:
i = (s32)ceil(b);
break;
case FPSCR_RN_MINF:
i = (s32)floor(b);
break;
}
r = (u32)i;
double di = i;
if (di == b)
{
CPU.SetFPSCR_FI(0);
CPU.FPSCR.FR = 0;
}
else
{
CPU.SetFPSCR_FI(1);
CPU.FPSCR.FR = fabs(di) > fabs(b);
}
}
(u64&)CPU.FPR[frd] = r;
if(rc) CPU.UpdateCR1();
}
void FCTIWZ(u32 frd, u32 frb, bool rc) {FCTIW(frd, frb, rc, true);}
void FDIV(u32 frd, u32 fra, u32 frb, bool rc) {FDIV(frd, fra, frb, rc, false);}
void FDIV(u32 frd, u32 fra, u32 frb, bool rc, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double a = CPU.FPR[fra];
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(a) || FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(a))
{
CPU.FPR[frd] = SilenceNaN(a);
}
else if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(a == 0.0 && b == 0.0)
{
CPU.SetFPSCRException(FPSCR_VXZDZ);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else if(FPRdouble::IsINF(a) && FPRdouble::IsINF(b))
{
CPU.SetFPSCRException(FPSCR_VXIDI);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
if(b == 0.0)
{
CPU.SetFPSCRException(FPSCR_ZX);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if (CPU.FPSCR.ZE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
feclearexcept(FE_ALL_EXCEPT);
const double res = a / b;
if(single) CPU.FPR[frd] = (float)res;
else CPU.FPR[frd] = res;
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FSUB(u32 frd, u32 fra, u32 frb, bool rc) {FSUB(frd, fra, frb, rc, false);}
void FSUB(u32 frd, u32 fra, u32 frb, bool rc, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double a = CPU.FPR[fra];
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(a) || FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(a))
{
CPU.FPR[frd] = SilenceNaN(a);
}
else if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(FPRdouble::IsINF(a) && FPRdouble::IsINF(b) && a == b)
{
CPU.SetFPSCRException(FPSCR_VXISI);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
const double res = a - b;
if(single) CPU.FPR[frd] = (float)res;
else CPU.FPR[frd] = res;
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FADD(u32 frd, u32 fra, u32 frb, bool rc) {FADD(frd, fra, frb, rc, false);}
void FADD(u32 frd, u32 fra, u32 frb, bool rc, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double a = CPU.FPR[fra];
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(a) || FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(a))
{
CPU.FPR[frd] = SilenceNaN(a);
}
else if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(FPRdouble::IsINF(a) && FPRdouble::IsINF(b) && a != b)
{
CPU.SetFPSCRException(FPSCR_VXISI);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
const double res = a + b;
if(single) CPU.FPR[frd] = (float)res;
else CPU.FPR[frd] = res;
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FSQRT(u32 frd, u32 frb, bool rc) {FSQRT(frd, frb, rc, false);}
void FSQRT(u32 frd, u32 frb, bool rc, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(b < 0.0)
{
CPU.SetFPSCRException(FPSCR_VXSQRT);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
const double res = sqrt(b);
if(single) CPU.FPR[frd] = (float)res;
else CPU.FPR[frd] = res;
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FSEL(u32 frd, u32 fra, u32 frc, u32 frb, bool rc)
{
CPU.FPR[frd] = CPU.FPR[fra] >= 0.0 ? CPU.FPR[frc] : CPU.FPR[frb];
if(rc) CPU.UpdateCR1();
}
void FMUL(u32 frd, u32 fra, u32 frc, bool rc) {FMUL(frd, fra, frc, rc, false);}
void FMUL(u32 frd, u32 fra, u32 frc, bool rc, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double a = CPU.FPR[fra];
const double c = CPU.FPR[frc];
if(FPRdouble::IsSNaN(a) || FPRdouble::IsSNaN(c))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(a))
{
CPU.FPR[frd] = SilenceNaN(a);
}
else if(FPRdouble::IsNaN(c))
{
CPU.FPR[frd] = SilenceNaN(c);
}
else if((FPRdouble::IsINF(a) && c == 0.0) || (a == 0.0 && FPRdouble::IsINF(c)))
{
CPU.SetFPSCRException(FPSCR_VXIMZ);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
const double res = a * c;
if(single) CPU.FPR[frd] = (float)res;
else CPU.FPR[frd] = res;
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FRSQRTE(u32 frd, u32 frb, bool rc)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double b = CPU.FPR[frb];
if(FPRdouble::IsSNaN(b))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(b < 0.0)
{
CPU.SetFPSCRException(FPSCR_VXSQRT);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else if(b == 0.0)
{
CPU.SetFPSCRException(FPSCR_ZX);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if (CPU.FPSCR.ZE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = 1.0 / b;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
CPU.FPR[frd] = 1.0 / sqrt(b);
CheckHostFPExceptions();
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FMSUB(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, false, true, false);}
void FMADD(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, false, false, false);}
void FMADD(u32 frd, u32 fra, u32 frc, u32 frb, bool rc, bool neg, bool sub, bool single)
{
SetHostRoundingMode(CPU.FPSCR.RN);
const double a = CPU.FPR[fra];
const double b = CPU.FPR[frb];
const double c = CPU.FPR[frc];
if(FPRdouble::IsSNaN(a) || FPRdouble::IsSNaN(b) || FPRdouble::IsSNaN(c))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
}
if(FPRdouble::IsNaN(a))
{
CPU.FPR[frd] = SilenceNaN(a);
}
else if(FPRdouble::IsNaN(b))
{
CPU.FPR[frd] = SilenceNaN(b);
}
else if(FPRdouble::IsNaN(c))
{
CPU.FPR[frd] = SilenceNaN(c);
}
else if((FPRdouble::IsINF(a) && c == 0.0) || (a == 0.0 && FPRdouble::IsINF(c)))
{
CPU.SetFPSCRException(FPSCR_VXIMZ);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
const double res = fma(a, c, sub ? -b : b);
if(FPRdouble::IsNaN(res))
{
CPU.SetFPSCRException(FPSCR_VXISI);
CPU.FPSCR.FR = 0;
CPU.FPSCR.FI = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
CPU.FPR[frd] = FPR_NAN;
}
else
{
feclearexcept(FE_ALL_EXCEPT);
if(single) CPU.FPR[frd] = (float)(neg ? -res : res);
else CPU.FPR[frd] = (neg ? -res : res);
CheckHostFPExceptions();
}
}
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void FNMSUB(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, true, true, false);}
void FNMADD(u32 frd, u32 fra, u32 frc, u32 frb, bool rc) {FMADD(frd, fra, frc, frb, rc, true, false, false);}
void FCMPO(u32 crfd, u32 fra, u32 frb)
{
int cmp_res = FPRdouble::Cmp(CPU.FPR[fra], CPU.FPR[frb]);
if(cmp_res == CR_SO)
{
if(FPRdouble::IsSNaN(CPU.FPR[fra]) || FPRdouble::IsSNaN(CPU.FPR[frb]))
{
CPU.SetFPSCRException(FPSCR_VXSNAN);
if(!CPU.FPSCR.VE) CPU.SetFPSCRException(FPSCR_VXVC);
}
else
{
CPU.SetFPSCRException(FPSCR_VXVC);
}
CPU.FPSCR.FX = 1;
}
CPU.FPSCR.FPRF = cmp_res;
CPU.SetCR(crfd, cmp_res);
}
void FNEG(u32 frd, u32 frb, bool rc)
{
CPU.FPR[frd] = -CPU.FPR[frb];
if(rc) CPU.UpdateCR1();
}
void FMR(u32 frd, u32 frb, bool rc)
{
CPU.FPR[frd] = CPU.FPR[frb];
if(rc) CPU.UpdateCR1();
}
void FNABS(u32 frd, u32 frb, bool rc)
{
CPU.FPR[frd] = -fabs(CPU.FPR[frb]);
if(rc) CPU.UpdateCR1();
}
void FABS(u32 frd, u32 frb, bool rc)
{
CPU.FPR[frd] = fabs(CPU.FPR[frb]);
if(rc) CPU.UpdateCR1();
}
void FCTID(u32 frd, u32 frb, bool rc) {FCTID(frd, frb, rc, false);}
void FCTID(u32 frd, u32 frb, bool rc, bool truncate)
{
const double b = CPU.FPR[frb];
u64 r;
if (FPRdouble::IsNaN(b) || b < -(double)0x8000000000000000)
{
CPU.SetFPSCRException(FPSCR_VXCVI);
if(FPRdouble::IsSNaN(b)) CPU.SetFPSCRException(FPSCR_VXSNAN);
CPU.FPSCR.FI = 0;
CPU.FPSCR.FR = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
r = 0x8000000000000000;
}
else if(b >= (double)0x8000000000000000)
{
CPU.SetFPSCRException(FPSCR_VXCVI);
CPU.FPSCR.FI = 0;
CPU.FPSCR.FR = 0;
if(CPU.FPSCR.VE)
{
if(rc) CPU.UpdateCR1();
return;
}
r = 0x7fffffffffffffff;
}
else
{
s64 i = 0;
const u32 rn = truncate ? FPSCR_RN_ZERO : CPU.FPSCR.RN;
switch(rn)
{
case FPSCR_RN_NEAR:
SetHostRoundingMode(FPSCR_RN_NEAR);
i = (s64)nearbyint(b);
break;
case FPSCR_RN_ZERO:
i = (s64)b;
break;
case FPSCR_RN_PINF:
i = (s64)ceil(b);
break;
case FPSCR_RN_MINF:
i = (s64)floor(b);
break;
}
r = (u64)i;
double di = (double)i;
if (di == b)
{
CPU.SetFPSCR_FI(0);
CPU.FPSCR.FR = 0;
}
else
{
CPU.SetFPSCR_FI(1);
CPU.FPSCR.FR = fabs(di) > fabs(b);
}
}
(u64&)CPU.FPR[frd] = r;
if(rc) CPU.UpdateCR1();
}
void FCTIDZ(u32 frd, u32 frb, bool rc) {FCTID(frd, frb, rc, true);}
void FCFID(u32 frd, u32 frb, bool rc)
{
s64 bi = (s64&)CPU.FPR[frb];
double bf = (double)bi;
s64 bfi = (s64)bf;
if(bi == bfi)
{
CPU.SetFPSCR_FI(0);
CPU.FPSCR.FR = 0;
}
else
{
CPU.SetFPSCR_FI(1);
CPU.FPSCR.FR = abs(bfi) > abs(bi);
}
CPU.FPR[frd] = bf;
CPU.FPSCR.FPRF = CPU.FPR[frd].GetType();
if(rc) CPU.UpdateCR1();
}
void UNK(const u32 code, const u32 opcode, const u32 gcode)
{
throw fmt::Format("Unknown/Illegal opcode! (0x%08x : 0x%x : 0x%x)", code, opcode, gcode);
}
};
| Syphurith/rpcs3 | rpcs3/Emu/Cell/PPUInterpreter.h | C | gpl-2.0 | 103,091 | [
30522,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1000,
7861,
2226,
1013,
3526,
1013,
4903,
19098,
15042,
19847,
1012,
1044,
1000,
1001,
2421,
1000,
7861,
2226,
1013,
25353,
15782,
12718,
1013,
25353,
15782,
12718,
1012,
1044,
1000,
1001,
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... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, division
import random
import string
import timeit
import os
import zipfile
import datrie
def words100k():
zip_name = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'words100k.txt.zip'
)
zf = zipfile.ZipFile(zip_name)
txt = zf.open(zf.namelist()[0]).read().decode('utf8')
return txt.splitlines()
def random_words(num):
russian = 'абвгдеёжзиклмнопрстуфхцчъыьэюя'
alphabet = russian + string.ascii_letters
return [
"".join([random.choice(alphabet) for x in range(random.randint(1,15))])
for y in range(num)
]
def truncated_words(words):
return [word[:3] for word in words]
def prefixes1k(words, prefix_len):
words = [w for w in words if len(w) >= prefix_len]
every_nth = int(len(words)/1000)
_words = [w[:prefix_len] for w in words[::every_nth]]
return _words[:1000]
WORDS100k = words100k()
MIXED_WORDS100k = truncated_words(WORDS100k)
NON_WORDS100k = random_words(100000)
PREFIXES_3_1k = prefixes1k(WORDS100k, 3)
PREFIXES_5_1k = prefixes1k(WORDS100k, 5)
PREFIXES_8_1k = prefixes1k(WORDS100k, 8)
PREFIXES_15_1k = prefixes1k(WORDS100k, 15)
def _alphabet(words):
chars = set()
for word in words:
for ch in word:
chars.add(ch)
return "".join(sorted(list(chars)))
ALPHABET = _alphabet(WORDS100k)
def bench(name, timer, descr='M ops/sec', op_count=0.1, repeats=3, runs=5):
times = []
for x in range(runs):
times.append(timer.timeit(repeats))
def op_time(time):
return op_count*repeats / time
print("%55s: %0.3f%s" % (
name,
op_time(min(times)),
descr,
))
def create_trie():
words = words100k()
trie = datrie.Trie(ALPHABET)
for word in words:
trie[word] = 1
return trie
def benchmark():
print('\n====== Benchmarks (100k unique unicode words) =======\n')
tests = [
('__getitem__ (hits)', "for word in words: data[word]", 'M ops/sec', 0.1, 3),
('__contains__ (hits)', "for word in words: word in data", 'M ops/sec', 0.1, 3),
('__contains__ (misses)', "for word in NON_WORDS100k: word in data", 'M ops/sec', 0.1, 3),
('__len__', 'len(data)', ' ops/sec', 1, 1),
('__setitem__ (updates)', 'for word in words: data[word]=1', 'M ops/sec', 0.1, 3),
('__setitem__ (inserts, random)', 'for word in NON_WORDS_10k: data[word]=1', 'M ops/sec',0.01, 3),
('__setitem__ (inserts, sorted)', 'for word in words: empty_data[word]=1', 'M ops/sec', 0.1, 3),
('setdefault (updates)', 'for word in words: data.setdefault(word, 1)', 'M ops/sec', 0.1, 3),
('setdefault (inserts)', 'for word in NON_WORDS_10k: data.setdefault(word, 1)', 'M ops/sec', 0.01, 3),
('values()', 'list(data.values())', ' ops/sec', 1, 1),
('keys()', 'list(data.keys())', ' ops/sec', 1, 1),
('items()', 'list(data.items())', ' ops/sec', 1, 1),
]
common_setup = """
from __main__ import create_trie, WORDS100k, NON_WORDS100k, MIXED_WORDS100k, datrie
from __main__ import PREFIXES_3_1k, PREFIXES_5_1k, PREFIXES_8_1k, PREFIXES_15_1k
from __main__ import ALPHABET
words = WORDS100k
NON_WORDS_10k = NON_WORDS100k[:10000]
NON_WORDS_1k = ['ыва', 'xyz', 'соы', 'Axx', 'avы']*200
"""
dict_setup = common_setup + 'data = dict((word, 1) for word in words); empty_data=dict()'
trie_setup = common_setup + 'data = create_trie(); empty_data = datrie.Trie(ALPHABET)'
for test_name, test, descr, op_count, repeats in tests:
t_dict = timeit.Timer(test, dict_setup)
t_trie = timeit.Timer(test, trie_setup)
bench('dict '+test_name, t_dict, descr, op_count, repeats)
bench('trie '+test_name, t_trie, descr, op_count, repeats)
# trie-specific benchmarks
bench(
'trie.iter_prefix_values (hits)',
timeit.Timer(
"for word in words:\n"
" for it in data.iter_prefix_values(word):\n"
" pass",
trie_setup
),
)
bench(
'trie.prefix_values (hits)',
timeit.Timer(
"for word in words: data.prefix_values(word)",
trie_setup
)
)
bench(
'trie.prefix_values loop (hits)',
timeit.Timer(
"for word in words:\n"
" for it in data.prefix_values(word):pass",
trie_setup
)
)
bench(
'trie.iter_prefix_items (hits)',
timeit.Timer(
"for word in words:\n"
" for it in data.iter_prefix_items(word):\n"
" pass",
trie_setup
),
)
bench(
'trie.prefix_items (hits)',
timeit.Timer(
"for word in words: data.prefix_items(word)",
trie_setup
)
)
bench(
'trie.prefix_items loop (hits)',
timeit.Timer(
"for word in words:\n"
" for it in data.prefix_items(word):pass",
trie_setup
)
)
bench(
'trie.iter_prefixes (hits)',
timeit.Timer(
"for word in words:\n"
" for it in data.iter_prefixes(word): pass",
trie_setup
)
)
bench(
'trie.iter_prefixes (misses)',
timeit.Timer(
"for word in NON_WORDS100k:\n"
" for it in data.iter_prefixes(word): pass",
trie_setup
)
)
bench(
'trie.iter_prefixes (mixed)',
timeit.Timer(
"for word in MIXED_WORDS100k:\n"
" for it in data.iter_prefixes(word): pass",
trie_setup
)
)
bench(
'trie.has_keys_with_prefix (hits)',
timeit.Timer(
"for word in words: data.has_keys_with_prefix(word)",
trie_setup
)
)
bench(
'trie.has_keys_with_prefix (misses)',
timeit.Timer(
"for word in NON_WORDS100k: data.has_keys_with_prefix(word)",
trie_setup
)
)
for meth in ('longest_prefix', 'longest_prefix_item', 'longest_prefix_value'):
bench(
'trie.%s (hits)' % meth,
timeit.Timer(
"for word in words: data.%s(word)" % meth,
trie_setup
)
)
bench(
'trie.%s (misses)' % meth,
timeit.Timer(
"for word in NON_WORDS100k: data.%s(word, default=None)" % meth,
trie_setup
)
)
bench(
'trie.%s (mixed)' % meth,
timeit.Timer(
"for word in MIXED_WORDS100k: data.%s(word, default=None)" % meth,
trie_setup
)
)
prefix_data = [
('xxx', 'avg_len(res)==415', 'PREFIXES_3_1k'),
('xxxxx', 'avg_len(res)==17', 'PREFIXES_5_1k'),
('xxxxxxxx', 'avg_len(res)==3', 'PREFIXES_8_1k'),
('xxxxx..xx', 'avg_len(res)==1.4', 'PREFIXES_15_1k'),
('xxx', 'NON_EXISTING', 'NON_WORDS_1k'),
]
for xxx, avg, data in prefix_data:
for meth in ('items', 'keys', 'values'):
bench(
'trie.%s(prefix="%s"), %s' % (meth, xxx, avg),
timeit.Timer(
"for word in %s: data.%s(word)" % (data, meth),
trie_setup
),
'K ops/sec',
op_count=1,
)
def profiling():
print('\n====== Profiling =======\n')
def profile_yep():
import yep
trie = create_trie()
#WORDS = words100k()
yep.start(b'output.prof')
for x in range(100):
trie.keys()
# for x in range(1000):
# for word in WORDS:
# trie[word]
yep.stop()
def profile_cprofile():
import pstats
import cProfile
trie = create_trie()
WORDS = words100k()
def check_trie(trie, words):
value = 0
for word in words:
value += trie[word]
if value != len(words):
raise Exception()
# def check_prefixes(trie, words):
# for word in words:
# trie.keys(word)
# cProfile.runctx("check_prefixes(trie, NON_WORDS_1k)", globals(), locals(), "Profile.prof")
cProfile.runctx("check_trie(trie, WORDS)", globals(), locals(), "Profile.prof")
s = pstats.Stats("Profile.prof")
s.strip_dirs().sort_stats("time").print_stats(20)
#profile_cprofile()
profile_yep()
#def memory():
# gc.collect()
# _memory = lambda: _get_memory(os.getpid())
# initial_memory = _memory()
# trie = create_trie()
# gc.collect()
# trie_memory = _memory()
#
# del trie
# gc.collect()
# alphabet, words = words100k()
# words_dict = dict((word, 1) for word in words)
# del alphabet
# del words
# gc.collect()
#
# dict_memory = _memory()
# print('initial: %s, trie: +%s, dict: +%s' % (
# initial_memory,
# trie_memory-initial_memory,
# dict_memory-initial_memory,
# ))
if __name__ == '__main__':
benchmark()
#profiling()
#memory()
print('\n~~~~~~~~~~~~~~\n') | hexforge/pulp_db | experiments/tries/comparison/datrie/bench/speed.py | Python | apache-2.0 | 9,330 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
7619,
1035,
12324,
1010,
27260,
1035,
18204,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 frontend\modules\patient\controllers;
use common\components\AppController;
use common\components\MyHelper;
/**
* Description of PrintController
*
* @author utehn
*/
class PrintController extends AppController {
public function beforeAction($action) {
if ($action->id == 'index') {
$this->enableCsrfValidation = false;
}
return parent::beforeAction($action);
}
public function actionIndex($pid){
$this->layout = 'main';
$this->permitRole([1,2]);
return $this->render('index',[
'pid'=>$pid
]);
}
}
| sirensoft/smartcare | frontend/modules/patient/controllers/PrintController.php | PHP | bsd-3-clause | 678 | [
30522,
1026,
1029,
25718,
3415,
15327,
2392,
10497,
1032,
14184,
1032,
5776,
1032,
21257,
1025,
2224,
2691,
1032,
6177,
1032,
10439,
8663,
13181,
10820,
1025,
2224,
2691,
1032,
6177,
1032,
2026,
16001,
4842,
1025,
1013,
1008,
1008,
1008,
64... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
from contextlib import contextmanager
from _pytest.python import FixtureRequest
import mock
from mock import Mock
import pyramid.testing
from webob.multidict import MultiDict
import pyramid_swagger
import pyramid_swagger.tween
import pytest
import simplejson
from pyramid.config import Configurator
from pyramid.interfaces import IRoutesMapper
from pyramid.registry import Registry
from pyramid.response import Response
from pyramid.urldispatch import RoutesMapper
from webtest import AppError
from .request_test import test_app
from pyramid_swagger.exceptions import ResponseValidationError
from pyramid_swagger.ingest import compile_swagger_schema
from pyramid_swagger.ingest import get_resource_listing
from pyramid_swagger.tween import validation_tween_factory
class CustomResponseValidationException(Exception):
pass
class EnhancedDummyRequest(pyramid.testing.DummyRequest):
"""
pyramid.testing.DummyRequest doesn't support MultiDicts like the real
pyramid.request.Request so this is the next best thing.
"""
def __init__(self, **kw):
super(EnhancedDummyRequest, self).__init__(**kw)
self.GET = MultiDict(self.GET)
# Make sure content_type attr exists is not passed in via **kw
self.content_type = getattr(self, 'content_type', None)
@contextmanager
def validation_context(request, response=None):
try:
yield
except Exception:
raise CustomResponseValidationException
validation_ctx_path = 'tests.acceptance.response_test.validation_context'
def get_registry(settings):
registry = Registry('testing')
config = Configurator(registry=registry)
if getattr(registry, 'settings', None) is None:
config._set_settings(settings)
registry.registerUtility(RoutesMapper(), IRoutesMapper)
config.commit()
return registry
def get_swagger_schema(schema_dir='tests/sample_schemas/good_app/'):
return compile_swagger_schema(
schema_dir,
get_resource_listing(schema_dir, False)
)
def _validate_against_tween(request, response=None, **overrides):
"""
Acceptance testing helper for testing the validation tween with Swagger 1.2
responses.
:param request: pytest fixture
:param response: standard fixture by default
"""
def handler(request):
return response or Response()
settings = dict({
'pyramid_swagger.swagger_versions': ['1.2'],
'pyramid_swagger.enable_swagger_spec_validation': False,
'pyramid_swagger.schema_directory': 'tests/sample_schemas/good_app/'},
**overrides
)
settings['pyramid_swagger.schema12'] = get_swagger_schema()
settings['pyramid_swagger.schema20'] = None
registry = get_registry(settings)
# Let's make request validation a no-op so we can focus our tests.
with mock.patch.object(pyramid_swagger.tween, 'validate_request'):
validation_tween_factory(handler, registry)(request)
def test_response_validation_enabled_by_default():
request = EnhancedDummyRequest(
method='GET',
path='/sample/path_arg1/resource',
params={'required_arg': 'test'},
matchdict={'path_arg': 'path_arg1'},
)
# Omit the logging_info key from the response. If response validation
# occurs, we'll fail it.
response = Response(
body=simplejson.dumps({'raw_response': 'foo'}),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
with pytest.raises(ResponseValidationError) as excinfo:
_validate_against_tween(request, response=response)
assert "'logging_info' is a required property" in str(excinfo.value)
def test_500_when_response_is_missing_required_field():
request = EnhancedDummyRequest(
method='GET',
path='/sample/path_arg1/resource',
params={'required_arg': 'test'},
matchdict={'path_arg': 'path_arg1'},
)
# Omit the logging_info key from the response.
response = Response(
body=simplejson.dumps({'raw_response': 'foo'}),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
with pytest.raises(ResponseValidationError) as excinfo:
_validate_against_tween(request, response=response)
assert "'logging_info' is a required property" in str(excinfo.value)
def test_200_when_response_is_void_with_none_response():
request = EnhancedDummyRequest(
method='GET',
path='/sample/nonstring/{int_arg}/{float_arg}/{boolean_arg}',
params={'required_arg': 'test'},
matchdict={'int_arg': '1', 'float_arg': '2.0', 'boolean_arg': 'true'},
)
response = Response(
body=simplejson.dumps(None),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
_validate_against_tween(request, response=response)
def test_200_when_response_is_void_with_empty_response():
request = EnhancedDummyRequest(
method='GET',
path='/sample/nonstring/{int_arg}/{float_arg}/{boolean_arg}',
params={'required_arg': 'test'},
matchdict={'int_arg': '1', 'float_arg': '2.0', 'boolean_arg': 'true'},
)
response = Response(body='{}')
_validate_against_tween(request, response=response)
def test_500_when_response_arg_is_wrong_type():
request = EnhancedDummyRequest(
method='GET',
path='/sample/path_arg1/resource',
params={'required_arg': 'test'},
matchdict={'path_arg': 'path_arg1'},
)
response = Response(
body=simplejson.dumps({
'raw_response': 1.0,
'logging_info': {'foo': 'bar'}
}),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
with pytest.raises(ResponseValidationError) as excinfo:
_validate_against_tween(request, response=response)
assert "1.0 is not of type 'string'" in str(excinfo.value)
def test_500_for_bad_validated_array_response():
request = EnhancedDummyRequest(
method='GET',
path='/sample_array_response',
)
response = Response(
body=simplejson.dumps([{"enum_value": "bad_enum_value"}]),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
with pytest.raises(ResponseValidationError) as excinfo:
_validate_against_tween(request, response=response)
assert "is not one of ['good_enum_value']" in str(excinfo.value)
def test_200_for_good_validated_array_response():
request = EnhancedDummyRequest(
method='GET',
path='/sample_array_response',
)
response = Response(
body=simplejson.dumps([{"enum_value": "good_enum_value"}]),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
_validate_against_tween(request, response=response)
def test_200_for_normal_response_validation():
app = test_app(
request=Mock(spec=FixtureRequest, param=['1.2']),
**{'pyramid_swagger.enable_response_validation': True}
)
response = app.post_json('/sample', {'foo': 'test', 'bar': 'test'})
assert response.status_code == 200
def test_200_skip_validation_for_excluded_path():
# FIXME(#64): This test is broken and doesn't check anything.
app = test_app(
request=Mock(spec=FixtureRequest, param=['1.2']),
**{'pyramid_swagger.exclude_paths': [r'^/sample/?']}
)
response = app.get(
'/sample/path_arg1/resource',
params={'required_arg': 'test'}
)
assert response.status_code == 200
def test_app_error_if_path_not_in_spec_and_path_validation_disabled():
"""If path missing and validation is disabled we want to let something else
handle the error. TestApp throws an AppError, but Pyramid would throw a
HTTPNotFound exception.
"""
with pytest.raises(AppError):
app = test_app(
request=Mock(spec=FixtureRequest, param=['1.2']),
**{'pyramid_swagger.enable_path_validation': False}
)
assert app.get('/this/path/doesnt/exist')
def test_response_validation_context():
request = EnhancedDummyRequest(
method='GET',
path='/sample/path_arg1/resource',
params={'required_arg': 'test'},
matchdict={'path_arg': 'path_arg1'},
)
# Omit the logging_info key from the response.
response = Response(
body=simplejson.dumps({'raw_response': 'foo'}),
headers={'Content-Type': 'application/json; charset=UTF-8'},
)
with pytest.raises(CustomResponseValidationException):
_validate_against_tween(
request,
response=response,
**{'pyramid_swagger.validation_context_path': validation_ctx_path}
)
| prat0318/pyramid_swagger | tests/acceptance/response_test.py | Python | bsd-3-clause | 8,642 | [
30522,
2013,
6123,
29521,
12324,
6123,
24805,
4590,
2013,
1035,
1052,
17250,
3367,
1012,
18750,
12324,
15083,
2890,
30524,
1012,
5604,
2013,
4773,
16429,
1012,
4800,
29201,
12324,
4800,
29201,
12324,
11918,
1035,
25430,
27609,
12324,
11918,
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... |
# Parmularia novomexicana B. de Lesd. SPECIES
#### Status
ACCEPTED
#### According to
Index Fungorum
#### Published in
null
#### Original name
Parmularia novomexicana B. de Lesd.
### Remarks
null | mdoering/backbone | life/Fungi/Ascomycota/Dothideomycetes/Hysteriales/Parmulariaceae/Parmularia/Parmularia novomexicana/README.md | Markdown | apache-2.0 | 199 | [
30522,
1001,
11968,
12274,
8017,
2401,
24576,
4168,
9048,
28621,
1038,
1012,
2139,
4649,
2094,
1012,
2427,
1001,
1001,
1001,
1001,
3570,
3970,
1001,
1001,
1001,
1001,
2429,
2000,
5950,
4569,
20255,
2819,
1001,
1001,
1001,
1001,
2405,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.