text:
<!DOCTYPE html>

    <title>Etap pakowania - Rubinius</title>
    <meta content='text/html;charset=utf-8' http-equiv='content-type'>
    <meta content='pl' http-equiv='content-language'>
    <meta content='Rubinius is an implementation of the Ruby programming language. The Rubinius bytecode virtual machine is written in C++. The bytecode compiler is written in pure Ruby. The vast majority of the core library is also written in Ruby, with some supporting primitives that interact with the VM directly.' name='description'>
    <meta content='Less Than Three. <3. http://less.thanthree.com' name='author'>
    <link href='/' rel='home'>
    <link href='/' rel='start'>
    <link href='/doc/pl/bytecode-compiler/encoder' rel='prev' title='Etap kodowania'>
    <link href='/doc/pl/bytecode-compiler/writer' rel='next' title='Etap zapisu'>

    <link href="/stylesheets/blueprint/screen.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/blueprint/print.css" media="print" rel="stylesheet" type="text/css" />

    <link href="/stylesheets/pygments.css" media="screen" rel="stylesheet" type="text/css" />

Home

Blog

Documentation

Projects

Roadmap

Releases

          1.2.3

  Język:

de

en

es

fr

ja

pl

pt-br

ru

        Wstecz:
        Etap kodowania

        Do góry:
        Spis treści

        Dalej:
        Etap zapisu

Etap pakowania

Po tym jak Generator został odpowiednio zakodowany podczas etapu
kodowania, Rubinius pakuje bajtkod jako CompiledMethod tworząc nową
instancję klasy CompiledMethod i ustawiając na niej kilka atrybutów.

Te atrubuty są dostępne na każdej instancji klasy CompiledMethod. Aby
otrzymać instancję CompiledMethod z metody Rubiego wywołaj na niej
executable.

iseq: Krotka (ang. Tuple) zawierająca sekwencję instrukcji

literals: Krotka zawierająca literały używane w metodzie.
Rubinius używa literałów wewnętrznie do wartości takich jak String,
literały używane są przez instrukcje push_literal oraz set_literal.

lines: Tablica (ang. Array) zawierająca wskaźnik do pierwszej
instrukcji dla każdej linii reprezentowanej przez bajtkod.

required_args: liczba argumentów wymaganych przez metodę

total_args: całkowita liczba argumentów, zawierająca również argumenty
opcjonalne

splat: pozycja argumentu splat, jeśli taki istnieje

local_count: ilość zmiennych lokalnych włączając w to argumenty

local_names: Krotka zawierająca listę wszystkich zmiennych
*lokalnych w kolejności: argumenty wymagane, opcjonalne, splat oraz
*argumenty blokowe.

file: nazwa pliku, która jest używana przy śledzeniu stosu oraz
przy innych informacjach do debuggowania

name: nazwa metody

primitive: nazwa podstawowego elementu (ang. primitive) powiązanego z tą metodą
jeśli taki istnieje

metadata: jeśli generator został utworzony dla bloku, metadata
będzie zawierać element for_block o wartości true. Atrubutu
metadata można używać do przechowywania innych danych dotyczących metody.

Etap pakowania zamienia również wszystkie pomniejsze generatory
(np. generatory dla bloków czy metod) na skompilowane metody
(CompiledMethod). Te pomniejsze skompilowane metody są dostępne w
krotce literals w nadrzędnej skompilowanej metodzie.

Gdy Generator skończył pakowanie siebie jako CompiledMethod, wywołuje
etap zapisywania, przekazując CompiledMethod na wejście.

Pliki

kernel/bootstrap/compiled_method.rb: podstawowa implementacja
CompiledMethod, głównie złożona z odwoływań do elementów
podstawowych (primitives)

kernel/common/compiled_method.rb: bardziej rozbudowana implementacja
CompiledMethod, połączenie elementów podstawowych oraz metod
napisanych w Ruby

vm/builtin/compiledmethod.cpp: implementacja elementów
podstawowych w C++

lib/compiler/generator.rb: Implementacja metody package, która
wypełnia obiekt CompiledMethod informacjami pochodzącymi z Generatora.

Dostosowanie pakowania

Ogólnie rzecz biorąc, metoda package została zaprojektowana aby
wypełnić obiekt CompiledMethod serią zmiennych. Możesz jednak użyć
etapu pakowania aby wypełnić inny obiekt posiadający ten sam interfejs
tymi danymi.

        Wstecz:
        Etap kodowania

        Do góry:
        Spis treści

        Dalej:
        Etap zapisu

Please enable JavaScript to view the comments powered by Disqus.

Follow Rubinius on Twitter

Fork Rubinius on github

An Engine Yard project

              Site design by
              Less Than Three


text:
package com.fincatto.documentofiscal.cte300.classes.enviolote.consulta;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Namespace;
import org.simpleframework.xml.Root;

import com.fincatto.documentofiscal.DFBase;
import com.fincatto.documentofiscal.cte300.classes.nota.assinatura.CTeSignature;

/**
 * @author Caio
 * @info Conjunto de CT-es processados, só existe nos casos em que o lote consultado se encontra processado
 */

@Root(name = "protCTe")
@Namespace(reference = "http://www.portalfiscal.inf.br/cte")
public class CTeProtocolo extends DFBase {
    private static final long serialVersionUID = 4634629801463718104L;

    @Element(name = "infProt", required = false)
    private CTeProtocoloInfo info;

    @Element(name = "Signature", required = false)
    private CTeSignature signature;

    @Attribute(name = "versao", required = true)
    private String versao;

    public CTeProtocolo() {
        this.info = null;
        this.signature = null;
        this.versao = null;
    }

    public CTeProtocoloInfo getInfo() {
        return this.info;
    }

    /**
     * Dados do protocolo de status
     */
    public void setInfo(final CTeProtocoloInfo info) {
        this.info = info;
    }

    public CTeSignature getSignature() {
        return this.signature;
    }

    /**
     *
     * */
    public void setSignature(final CTeSignature signature) {
        this.signature = signature;
    }

    public String getVersao() {
        return this.versao;
    }

    /**
     *
     * */
    public void setVersao(final String versao) {
        this.versao = versao;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.thanple.gs.app.task.msg;

/**
 * auto created by CreateProtocol
 * 2017-06-02 14:51:04
 * */

public class SRequestTaskStatus extends
       com.thanple.gs.common.nio.manager.Protocol
               <com.thanple.gs.common.nio.protocol._SRequestTaskStatus.SRequestTaskStatus>{

    public SRequestTaskStatus(
           com.thanple.gs.common.nio.protocol._SRequestTaskStatus.SRequestTaskStatus msg){
        super(msg);
    }

    @Override
    public void process(io.netty.channel.ChannelHandlerContext ctx) {

    }
}


text:
(function () {
  const commando = require('discord.js-commando')
  const gamesList = require('../../room-games/list')
  module.exports = class RoomGameListCommand extends commando.Command {
    constructor (client) {
      super(client, {
        name: 'gameslist',
        aliases: ['gl'],
        group: 'games',
        memberName: 'gameslist',
        description: 'Lists the room games available to play'
      })
    }

    async run (msg, args) {
      let message = 'Available games are: '
      for (var i = 0; i < gamesList.length; i++) {
        const game = gamesList[i]
        message += `${game}`
        if (i < gamesList.length - 1) {
          message += ', '
        }
      }

      msg.reply(message)
    }
  }
})()


text:
package net.gumbix.hl7dsl

import build.BuildMessage
import DSL._
import helper.{Tel, Address, Name, Code}
import net.gumbix.hl7dsl.helper.ImplicitDef._
import junit.framework.TestCase
import org.hl7.types.CE
import java.util.ArrayList
import org.hl7.types.impl.{SETjuSetAdapter, CEimpl}
import org.hl7.types.enums.TelecommunicationAddressUse._
import org.hl7.types.enums.ActStatus._
import org.hl7.types.enums.ActRelationshipType._
import tools.nsc.io.Path
import java.io.{FileWriter, File}

/**
 * This demo is used to have a reference CDA.
 * TODO confidentialityCode: codeSystem is not displayed
 * TODO birthPlace is not marshalled
 * @author Markus Gumbel (m.gumbel@hs-mannheim.de)
 */
class VHitGDemo extends TestCase {
  def testPOCD_EX000001() {
    val clinicalDocument = new DocumentDSL {
      typeId = ("POCD_HD000040", "2.16.840.1.113883.1.3")
      id = ("1.2.276.0.76.3645.239", "6014161089")
      title = "Arztbrief auf der Basis von CDA Release 2"
      effectiveTime = "20050829"
      code = new Code {
        code = "11488-4"
        codeSystem = "2.16.840.1.113883.6.1"
        displayName = "Consultation note"
      }
      confidentialityCode = ("N", "2.16.840.1.113883.5.25")
      languageCode = ("de-DE", "1.22.333.4444")

      participation("recordTarget") = new ParticipationDSL {
        role("patientRole") = new PatientDSL {
          id = List(
            ("6245", "2.16.840.1.113883.3.933"),
            ("1543627549", "1.2.276.0.76.4.1")
            )
          player("patient") = new PersonDSL {
            name = new Name {
              given = "Paul"
              family = "Pappel"
            }
            administrativeGenderCode = ("M", "2.16.840.1.113883.5.1")
            birthTime = "19551217"
            scopedRole("birthplace") = new RoleDSL {
              player("place") = new PlaceDSL {
                addr = new Address {
                  city = "Sassnitz"
                }
              }
            }
          }
          addr = new Address {
            streetAddressLine = "Riedemannweg 59"
            postalCode = "13627"
            city = "Berlin"
          }
          telecom = new Tel {
            number = ("tel:030.456.345345", HomeAddressUse)
          }
          scoper("providerOrganziation") = new OrganizationDSL {
            addr = new Address {
              streetName = "Krankenhausstraße"
              postalCode = "51371"
              city = "Leverkusen"
            }
          }
        }
      }
      participation("author") = new ParticipationDSL {
        time = "20050829"
        role("assignedAuthor") = new RoleDSL {
          id = ("2.16.840.1.113883.3.67.933", "ied8984938")
          player("assignedPerson") = new PersonDSL {
            name = new Name {
              prefix = "Dr. med."
              given = "Theo"
              family = "Phyllin"
            }
          }
          scoper("representedOrganization") = new OrganizationDSL {
            name = new Name() {
              orgName = "Praxis Dr. med. Phyllin"
            }
            telecom = new Tel {
              number = ("tel:0214.2127070", WorkPlaceAddressUse)
            }
            addr = new Address {
              streetName = "Krankenhausstraße"
              postalCode = "51371"
              city = "Leverkusen"
            }
          }
        }
      }

      participation("custodian") = new ParticipationDSL {
        role("assignedCustodian") = new RoleDSL {
          scoper("representedCustodianOrganization") = new OrganizationDSL {
            id = ("1.2.276.0.58", "M345")
            name = new Name() {
              orgName = "Praxis Dr. med. Phyllin"
            }
            telecom = new Tel {
              number = ("tel:0214.2127070", WorkPlaceAddressUse)
            }
            addr = new Address {
              streetName = "Krankenhausstraße"
              houseNumber = "59"
              postalCode = "51371"
              city = "Leverkusen"
            }
          }
        }
      }

      participation("informationRecipient") = new ParticipationDSL {
        role("intendedRecipient") = new RoleDSL {
          player("informationRecipient") = new PersonDSL {
            name = new Name {
              prefix = "Dr. med."
              given = "Kai"
              family = "Heitmann"
            }
          }
          scoper("receivedOrganization") = new OrganizationDSL {
            name = new Name() {
              orgName = "Gemeinschaftspraxis Dr. Heitmann"
            }
            telecom = new Tel {
              number = ("fax:02473.54637.2938", WorkPlaceAddressUse)
            }
            addr = new Address {
              streetAddressLine = "Mühlenweg 1a"
              postalCode = "52152"
              city = "Simmerath"
            }
          }
        }
      }

      outboundRelationship("relatedDocument") = new ActRelationshipDSL {
        typeCode = IsAppendage // "APND"
        target("parentDocument") = new DocumentDSL {
          id = ("1.2.276.0.58", "463957847")
        }
      }

      outboundRelationship("authorization") = new ActRelationshipDSL {
        target("consent") = new ActDSL {
          id = ("1.2.276.0.76.3645.239", "cs856727-298784")
          code = ("1.2.276.0.76.5.310", "3-00d")
          statusCode = Completed
        }
      }

      outboundRelationship("component") = new ActRelationshipDSL {
        target("structuredBody") = new ActDSL {
          outboundRelationship("component") = new ActRelationshipDSL {
            target("section") = new ActDSL {
              code = new Code {
                code = "10164-2"
                codeSystem = "2.16.840.1.113883.6.1"
                codeSystemName = "LOINC"
                // translation = TODO
              }
              title = "29.08.2005: Anamnese"
              text = """Sei Jahren wiederholt
              <content styleCode="Bold">chronische Bronchitiden</content>
              besonders bei kalter Luft. Bei Anstrengung expiratorische
              Atemnot. Kontakt mit Haustieren."""
            }
          }
        }
      }
    }
    val msg = BuildMessage.toXML(clinicalDocument, "POCD_HD000040")
    println(msg)
    val fw = new FileWriter("VHitG01-Scala.xml")
    fw.write(msg)
    fw.close()
  }
}


text:
#include <irtkNormalizedGradientFieldSimilarity.h>

// =============================================================================
// Construction/Destruction
// =============================================================================

// -----------------------------------------------------------------------------
irtkNormalizedGradientFieldSimilarity
::irtkNormalizedGradientFieldSimilarity(const char *name, double weight)
:
  irtkGradientFieldSimilarity(name, weight),
  _TargetNoise(1.0),
  _SourceNoise(1.0),
  _TargetNormalization (100.0),
  _SourceNormalization (100.0)
{
}

// -----------------------------------------------------------------------------
irtkNormalizedGradientFieldSimilarity::irtkNormalizedGradientFieldSimilarity(const irtkNormalizedGradientFieldSimilarity &other)
:
  irtkGradientFieldSimilarity(other),
  _TargetNoise(other._TargetNoise),
  _SourceNoise(other._SourceNoise),
  _TargetNormalization (other._TargetNormalization),
  _SourceNormalization (other._SourceNormalization)
{
}

// -----------------------------------------------------------------------------
irtkNormalizedGradientFieldSimilarity::~irtkNormalizedGradientFieldSimilarity()
{
}

// =============================================================================
// Parameters
// =============================================================================

// -----------------------------------------------------------------------------
bool irtkNormalizedGradientFieldSimilarity::Set(const char *name, const char *value)
{
  if (strcmp(name, "Target noise") == 0) {
    return FromString(value, _TargetNoise) && _TargetNoise > 0;
  } else if (strcmp(name, "Source noise") == 0) {
    return FromString(value, _SourceNoise) && _SourceNoise > 0;
  }
  return irtkGradientFieldSimilarity::Set(name, value);
}

// -----------------------------------------------------------------------------
irtkParameterList irtkNormalizedGradientFieldSimilarity::Parameter() const
{
  irtkParameterList params = irtkGradientFieldSimilarity::Parameter();
  Insert(params, "Target noise", ToString(_TargetNoise));
  Insert(params, "Source noise", ToString(_SourceNoise));
  return params;
}

// =============================================================================
// Evaluation
// =============================================================================

// -----------------------------------------------------------------------------
double irtkNormalizedGradientFieldSimilarity::NormalizationFactor(irtkRegisteredImage *image, double noise) const
{
  double norm = .0;
  int    n    = 0;

  VoxelType *dx = image->GetPointerToVoxels(0, 0, 0, 1);
  VoxelType *dy = image->GetPointerToVoxels(0, 0, 0, 2);
  VoxelType *dz = image->GetPointerToVoxels(0, 0, 0, 3);

  for (int idx = 0; idx < NumberOfVoxels(); ++idx, ++dx, ++dy, ++dz) {
    if (IsForeground(idx)) {
      norm += sqrt((*dx) * (*dx) + (*dy) * (*dy) + (*dz) * (*dz));
      ++n;
    }
  }

  return ((n > 0) ? (norm * noise / n) : .0);
}

// -----------------------------------------------------------------------------
void irtkNormalizedGradientFieldSimilarity::Update(bool hessian)
{
  const bool initial_update = _InitialUpdate;
  irtkGradientFieldSimilarity::Update(hessian); // sets _InitialUpdate = false
  if (initial_update || _Target->Transformation()) {
    _TargetNormalization = NormalizationFactor(_Target, _TargetNoise);
    if (_TargetNormalization == 0) {
      cerr << "irtkNormalizedGradientFieldSimilarity::Update: Target image has no structure!" << endl;
      exit(1);
    }
  }
  if (initial_update || _Source->Transformation()) {
    _SourceNormalization = NormalizationFactor(_Source, _SourceNoise);
    if (_SourceNormalization == 0) {
      cerr << "irtkNormalizedGradientFieldSimilarity::Update: Source image has no structure!" << endl;
      exit(1);
    }
  }
}


text:
package org.jkiss.dbeaver.registry;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.DBeaverActivator;
import org.jkiss.dbeaver.model.app.DBPRegistryListener;
import org.jkiss.dbeaver.model.connection.DBPConnectionType;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.SAXListener;
import org.jkiss.utils.xml.SAXReader;
import org.jkiss.utils.xml.XMLBuilder;
import org.jkiss.utils.xml.XMLException;
import org.xml.sax.Attributes;

import java.io.*;
import java.net.URL;
import java.util.*;

public class DataSourceProviderRegistry
{
    private static final Log log = Log.getLog(DataSourceProviderRegistry.class);

    private static DataSourceProviderRegistry instance = null;

    public synchronized static DataSourceProviderRegistry getInstance()
    {
        if (instance == null) {
            instance = new DataSourceProviderRegistry();
            instance.loadExtensions(Platform.getExtensionRegistry());
        }
        return instance;
    }

    private final List<DataSourceProviderDescriptor> dataSourceProviders = new ArrayList<>();
    private final List<DBPRegistryListener> registryListeners = new ArrayList<>();
    private final Map<String, DBPConnectionType> connectionTypes = new LinkedHashMap<>();
    private final Map<String, ExternalResourceDescriptor> resourceContributions = new HashMap<>();

    private DataSourceProviderRegistry()
    {
    }

    public void loadExtensions(IExtensionRegistry registry)
    {
        // Load datasource providers from external plugins
        {
            IConfigurationElement[] extElements = registry.getConfigurationElementsFor(DataSourceProviderDescriptor.EXTENSION_ID);
            for (IConfigurationElement ext : extElements) {
                DataSourceProviderDescriptor provider = new DataSourceProviderDescriptor(this, ext);
                dataSourceProviders.add(provider);
            }
            Collections.sort(dataSourceProviders, new Comparator<DataSourceProviderDescriptor>() {
                @Override
                public int compare(DataSourceProviderDescriptor o1, DataSourceProviderDescriptor o2)
                {
                    if (o1.isDriversManagable() && !o2.isDriversManagable()) {
                        return 1;
                    }
                    if (o2.isDriversManagable() && !o1.isDriversManagable()) {
                        return -1;
                    }
                    return o1.getName().compareToIgnoreCase(o2.getName());
                }
            });
        }

        // Load drivers
        File driversConfig = DBeaverActivator.getConfigurationFile(RegistryConstants.DRIVERS_FILE_NAME);
        if (driversConfig.exists()) {
            loadDrivers(driversConfig);
        }

        // Resolve all driver replacements
        {
            List<DriverDescriptor> allDrivers = new ArrayList<>();
            for (DataSourceProviderDescriptor provider : dataSourceProviders) {
                allDrivers.addAll(provider.getDrivers());
            }
            for (DriverDescriptor driver1 : allDrivers) {
                for (DriverDescriptor driver2 : allDrivers) {
                    if (driver1 != driver2 && driver1.replaces(driver2)) {
                        driver2.setReplacedBy(driver1);
                    }
                }
            }
        }

        // Load connection types
        {
            for (DBPConnectionType ct : DBPConnectionType.SYSTEM_TYPES) {
                connectionTypes.put(ct.getId(), ct);
            }
            File ctConfig = DBeaverActivator.getConfigurationFile(RegistryConstants.CONNECTION_TYPES_FILE_NAME);
            if (ctConfig.exists()) {
                loadConnectionTypes(ctConfig);
            }
        }

        // Load external resources information
        {
            IConfigurationElement[] extElements = registry.getConfigurationElementsFor(ExternalResourceDescriptor.EXTENSION_ID);
            for (IConfigurationElement ext : extElements) {
                ExternalResourceDescriptor resource = new ExternalResourceDescriptor(ext);
                resourceContributions.put(resource.getName(), resource);
            }
        }

    }

    public void dispose()
    {
        synchronized (registryListeners) {
            if (!registryListeners.isEmpty()) {
                log.warn("Some datasource registry listeners are still registered: " + registryListeners);
            }
            registryListeners.clear();
        }
        for (DataSourceProviderDescriptor providerDescriptor : this.dataSourceProviders) {
            providerDescriptor.dispose();
        }
        this.dataSourceProviders.clear();
        this.resourceContributions.clear();
    }

    @Nullable
    public DataSourceProviderDescriptor getDataSourceProvider(String id)
    {
        for (DataSourceProviderDescriptor provider : dataSourceProviders) {
            if (provider.getId().equals(id)) {
                return provider;
            }
        }
        return null;
    }

    public List<DataSourceProviderDescriptor> getDataSourceProviders()
    {
        return dataSourceProviders;
    }

    @Nullable
    public DriverDescriptor findDriver(@NotNull String driverName) {
        // Try to find by ID
        for (DataSourceProviderDescriptor pd : dataSourceProviders) {
            DriverDescriptor driver = pd.getDriver(driverName);
            if (driver != null) {
                return driver;
            }
        }
        // Try to find by name
        for (DataSourceProviderDescriptor pd : dataSourceProviders) {
            for (DriverDescriptor driver : pd.getDrivers()) {
                if (driver.getName().equalsIgnoreCase(driverName)) {
                    return driver;
                }
            }
        }
        return null;
    }

    private void loadDrivers(File driversConfig)
    {
        if (driversConfig.exists()) {
            try {
                try (InputStream is = new FileInputStream(driversConfig)) {
                    new SAXReader(is).parse(new DriverDescriptor.DriversParser());
                } catch (XMLException ex) {
                    log.warn("Drivers config parse error", ex);
                }
            } catch (Exception ex) {
                log.warn("Error loading drivers from " + driversConfig.getPath(), ex);
            }
        }
    }

    public void saveDrivers()
    {
        File driversConfig = DBeaverActivator.getConfigurationFile(RegistryConstants.DRIVERS_FILE_NAME);
        try {
            OutputStream os = new FileOutputStream(driversConfig);
            XMLBuilder xml = new XMLBuilder(os, GeneralUtils.UTF8_ENCODING);
            xml.setButify(true);
            xml.startElement(RegistryConstants.TAG_DRIVERS);
            for (DataSourceProviderDescriptor provider : this.dataSourceProviders) {
                xml.startElement(RegistryConstants.TAG_PROVIDER);
                xml.addAttribute(RegistryConstants.ATTR_ID, provider.getId());
                for (DriverDescriptor driver : provider.getDrivers()) {
                    if (driver.isModified()) {
                        driver.serialize(xml, false);
                    }
                }
                xml.endElement();
            }
            xml.endElement();
            xml.flush();
            os.close();
        }
        catch (Exception ex) {
            log.warn("Error saving drivers", ex);
        }
    }

    private void loadConnectionTypes(File configFile)
    {
        try {
            try (InputStream is = new FileInputStream(configFile)) {
                new SAXReader(is).parse(new ConnectionTypeParser());
            } catch (XMLException ex) {
                log.warn("Can't load connection types config from " + configFile.getPath(), ex);
            }
        }
        catch (Exception ex) {
            log.warn("Error parsing connection types", ex);
        }
    }

    public Collection<DBPConnectionType> getConnectionTypes()
    {
        return connectionTypes.values();
    }

    public DBPConnectionType getConnectionType(String id, DBPConnectionType defaultType)
    {
        DBPConnectionType connectionType = connectionTypes.get(id);
        return connectionType == null ? defaultType : connectionType;
    }

    public void addConnectionType(DBPConnectionType connectionType)
    {
        if (this.connectionTypes.containsKey(connectionType.getId())) {
            log.warn("Duplicate connection type id: " + connectionType.getId());
            return;
        }
        this.connectionTypes.put(connectionType.getId(), connectionType);
    }

    public void removeConnectionType(DBPConnectionType connectionType)
    {
        if (!this.connectionTypes.containsKey(connectionType.getId())) {
            log.warn("Connection type doesn't exist: " + connectionType.getId());
            return;
        }
        this.connectionTypes.remove(connectionType.getId());
    }

    public void saveConnectionTypes()
    {
        File ctConfig = DBeaverActivator.getConfigurationFile(RegistryConstants.CONNECTION_TYPES_FILE_NAME);
        try {
            OutputStream os = new FileOutputStream(ctConfig);
            XMLBuilder xml = new XMLBuilder(os, GeneralUtils.UTF8_ENCODING);
            xml.setButify(true);
            xml.startElement(RegistryConstants.TAG_TYPES);
            for (DBPConnectionType connectionType : connectionTypes.values()) {
                xml.startElement(RegistryConstants.TAG_TYPE);
                xml.addAttribute(RegistryConstants.ATTR_ID, connectionType.getId());
                xml.addAttribute(RegistryConstants.ATTR_NAME, CommonUtils.toString(connectionType.getName()));
                xml.addAttribute(RegistryConstants.ATTR_COLOR, connectionType.getColor());
                xml.addAttribute(RegistryConstants.ATTR_DESCRIPTION, CommonUtils.toString(connectionType.getDescription()));
                xml.addAttribute(RegistryConstants.ATTR_AUTOCOMMIT, connectionType.isAutocommit());
                xml.addAttribute(RegistryConstants.ATTR_CONFIRM_EXECUTE, connectionType.isConfirmExecute());
                xml.endElement();
            }
            xml.endElement();
            xml.flush();
            os.close();
        }
        catch (Exception ex) {
            log.warn("Error saving drivers", ex);
        }
    }

    /**
     * Searches for resource within external resources provided by plugins
     * @param resourcePath path
     * @return URL or null if specified resource not found
     */
    @Nullable
    public URL findResourceURL(String resourcePath)
    {
        ExternalResourceDescriptor descriptor = resourceContributions.get(resourcePath);
        return descriptor == null ? null : descriptor.getURL();
    }

    public void addDataSourceRegistryListener(DBPRegistryListener listener)
    {
        synchronized (registryListeners) {
            registryListeners.add(listener);
        }
    }

    public void removeDataSourceRegistryListener(DBPRegistryListener listener)
    {
        synchronized (registryListeners) {
            registryListeners.remove(listener);
        }
    }

    void fireRegistryChange(DataSourceRegistry registry, boolean load)
    {
        synchronized (registryListeners) {
            for (DBPRegistryListener listener : registryListeners) {
                if (load) {
                    listener.handleRegistryLoad(registry);
                } else {
                    listener.handleRegistryUnload(registry);
                }
            }
        }
    }

    class ConnectionTypeParser implements SAXListener
    {
        @Override
        public void saxStartElement(SAXReader reader, String namespaceURI, String localName, Attributes atts)
            throws XMLException
        {
            if (localName.equals(RegistryConstants.TAG_TYPE)) {
                DBPConnectionType connectionType = new DBPConnectionType(
                    atts.getValue(RegistryConstants.ATTR_ID),
                    atts.getValue(RegistryConstants.ATTR_NAME),
                    atts.getValue(RegistryConstants.ATTR_COLOR),
                    atts.getValue(RegistryConstants.ATTR_DESCRIPTION),
                    CommonUtils.getBoolean(atts.getValue(RegistryConstants.ATTR_AUTOCOMMIT)),
                    CommonUtils.getBoolean(atts.getValue(RegistryConstants.ATTR_CONFIRM_EXECUTE)));
                connectionTypes.put(connectionType.getId(), connectionType);
            }
        }

        @Override
        public void saxText(SAXReader reader, String data) {}

        @Override
        public void saxEndElement(SAXReader reader, String namespaceURI, String localName) {}
    }

}


text:
<Alloy>
	<TabGroup id='tgMain'>
		<Tab id='tabMain'>
			<Window class="container" id="winHome" tabBarHidden="true" navBarHidden="true">
				<View>
					<ImageView></ImageView>
					<Button onClick="btnBeginSr1_onClick" title="BEGIN NEW SR1 FORM" />
					<Button onClick="btnHistory_onClick" id='btnHistory' title="HISTORY" />
				</View>
			</Window>
		</Tab>
	</TabGroup>
</Alloy>


text:
/* AVISO: implementação não testada */
/* TODO reescrever fifo para fazer uso da estrutura de listas definida em linked_list.h */

#ifndef UTIL_FIFO_H
#define UTIL_FIFO_H

#include <stdlib.h>

typedef struct UTIL_FIFO fifo_t;

fifo_t *fifo_create(size_t nmemb, size_t memb_size);
fifo_t *fifo_destroy(fifo_t *fifo);
size_t fifo_size(fifo_t *fifo);
int fifo_append(fifo_t *fifo, const void *data);
int fifo_get(fifo_t *fifo, void *dest);

#endif //UTIL_FIFO_H


text:
// <copyright file="Program.cs" company="Bit, LLC">
// Copyright (c) 2014 All Rights Reserved
// </copyright>
// <author>ock</author>
// <date></date>
// <summary></summary>

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

namespace WopiBasicEditor
{
    class Program
    {
        static void Main()
        {
            WopiServer s = new WopiServer(@"C:\\src\\");
            s.Start();

            Console.WriteLine("A simple wopi webserver. Press any key to quit.");
            Console.ReadKey();

            s.Stop();
        }
    }
}


text:
package commands;

import java.util.List;

import tree.CommandNode;
import application.Model;
import application.Turtle;

public class Equal extends CommandNode{

	public Equal(Model myModel) {
		super(myModel, Double.class, Double.class);
	}

	@Override
	public List<Object> function(Turtle myTurtle, List<Object> args) {
		boolean eq = (double)args.get(0) == (double)args.get(1);
		double eqNum = 0;
		if (eq) eqNum = 1;
		return putObjectInList(eqNum);
	}

}


text:
// __BEGIN_LICENSE__
//  Copyright (c) 2006-2013, United States Government as represented by the
//  Administrator of the National Aeronautics and Space Administration. All
//  rights reserved.
//
//  The NASA Vision Workbench is 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.
// __END_LICENSE__

/// \file PixelMask.h
///
/// Defines the useful pixel utility type that can wrap any existing
/// pixel type and add mask semantics.  Any operations with an
/// "invalid" pixel returns an invalid pixel as a result.
///
#ifndef __VW_IMAGE_PIXELMASK_H__
#define __VW_IMAGE_PIXELMASK_H__

#include <ostream>

#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/static_assert.hpp>

#include <vw/Image/PixelMath.h>
#include <vw/Image/PixelTypeInfo.h>

namespace vw {

  // *******************************************************************
  // The PixelMask wrapper pixel type.
  // *******************************************************************

  /// A generic wrapper for any of the above pixel types that adds an
  /// additional "valid" bit to the pixel.  Math operations that
  /// include invalide pixels will produce resulting pixels that are
  /// themselves invalid.
  template <class ChildT>
  struct PixelMask : public PixelMathBase< PixelMask<ChildT> >
  {
    typedef typename CompoundChannelType<ChildT>::type channel_type;

  private:
    ChildT m_child;
    channel_type m_valid;

  public:

    // Default constructor (zero value).  Pixel is not valid by
    // default.
    PixelMask() {
      m_child = ChildT();
      m_valid = ChannelRange<channel_type>::min();
    }

    /// Conversion from other PixelMask<> types.
    template <class T>
    PixelMask( PixelMask<T> other ) {
      // We let the child's built-in conversions do their work here.
      // This will fail if there is no conversion defined from
      // OtherT to ChildT.
      m_child = ChildT(other.child());

      if (other.valid())
        m_valid = ChannelRange<channel_type>::max();
      else
        m_valid = ChannelRange<channel_type>::min();
    }

    /// implicit construction from the raw channel value, or from the
    /// child pixel type value.  Values constructed in this manner
    /// are considered valid.
    template <class T>
    PixelMask( T const& pix) {
      m_child = ChildT(pix);
      m_valid = ChannelRange<channel_type>::max();
    }

    /// Constructs a pixel with the given channel values (use only when child has 2 channels)
    PixelMask( channel_type const& a0, channel_type const& a1 ) {
      m_child[0]=a0; m_child[1]=a1; m_valid = ChannelRange<channel_type>::max();
    }

    /// Constructs a pixel with the given channel values (use only when child has 3 channels)
    PixelMask( channel_type const& a0, channel_type const& a1, channel_type const& a2 ) {
      m_child[0]=a0; m_child[1]=a1; m_child[2]=a2; m_valid = ChannelRange<channel_type>::max();
    }

    /// Constructs a pixel with the given channel values (use only when child has 4 channels)
    PixelMask( channel_type const& a0, channel_type const& a1, channel_type const& a2, channel_type const& a3 ) {
      m_child[0]=a0; m_child[1]=a1; m_child[2]=a2; m_child[3]=a3; m_valid = ChannelRange<channel_type>::max();
    }

    /// Returns the value from the valid channel
    channel_type valid() const { return m_valid; }

    /// Invalidates this pixel, setting its valid bit to zero.
    void invalidate() { m_valid = ChannelRange<channel_type>::min(); }

    /// Validates this pixel, setting its valid bit to 1;
    void validate() { m_valid = ChannelRange<channel_type>::max(); }

    /// Switching valid to what it was not previously
    void toggle() {
      if ( m_valid )
        m_valid = ChannelRange<channel_type>::min();
      else
        m_valid = ChannelRange<channel_type>::max();
    }

    /// Returns the child pixel type
    ChildT & child() { return m_child; }
    ChildT const& child() const { return m_child; }

    /// Automatic down-cast to the raw channel value in numeric
    /// contexts.  This should only work for pixels that contain one
    /// data channel (plus the mask channel).  We add a
    /// BOOST_STATIC_ASSERT here to make sure that this is the case.
    operator channel_type() const {
       BOOST_STATIC_ASSERT(CompoundNumChannels<ChildT>::value == 1);
       return compound_select_channel<channel_type const&>(m_child,0);
    }

    /// Channel indexing operator.
    inline channel_type& operator[](size_t i) {
      if (i == CompoundNumChannels<ChildT>::value)
        return m_valid;
      else
        return compound_select_channel<channel_type&>(m_child,i);
     }
    /// Channel indexing operator (const overload).
    inline channel_type const& operator[](size_t i) const {
      if (i == CompoundNumChannels<ChildT>::value)
        return m_valid;
      else
        return compound_select_channel<channel_type const&>(m_child,i);
    }
    /// Channel indexing operator.
    inline channel_type& operator()(size_t i) {
      if (i == CompoundNumChannels<ChildT>::value)
        return valid;
      else
        return compound_select_channel<channel_type&>(m_child,i);
    }
    /// Channel indexing operator (const overload).
    inline channel_type const& operator()(size_t i) const {
      if (i == CompoundNumChannels<ChildT>::value)
        return valid;
      else
        return compound_select_channel<channel_type const&>(m_child,i);
    }
  };

  // *******************************************************************
  // Generic Mask Manipulation Methods
  // *******************************************************************

  // Overload for the pixel transparency traits class.
  template <class ChildT>
  bool is_transparent(PixelMask<ChildT> const& pixel) { return !pixel.valid(); }

  // Overload for the pixel transparency traits class.
  template <class ChildT>
  bool is_opaque(PixelMask<ChildT> const& pixel) { return pixel.valid(); }

  // A pixel validity checker.
  template <class PixelT>
  bool is_valid(PixelT const& /* pixel */) { return true; }

  // Overload for the pixel transparency traits class.
  template <class ChildT>
  bool is_valid(PixelMask<ChildT> const& pixel) { return pixel.valid(); }

  // Generic method for "validating" pixel (setting the mask bit).
  // This is a no-op by default, but it actually calls px.validate()
  // for PixelMask<> types.
  template <class PixelT>
  inline void validate(PixelT & /* pixel */ ) { return; }

  template <class ChildPixelT>
  inline void validate(PixelMask<ChildPixelT> &pixel) { pixel.validate(); }

  // Generic method for "invalidating" pixel (removing the mask bit).
  // This is a no-op by default, but it actually calls px.validate()
  // for PixelMask<> types.
  template <class PixelT>
  inline void invalidate(PixelT& /*pixel*/) { return; }

  template <class ChildPixelT>
  inline void invalidate(PixelMask<ChildPixelT> &pixel) { pixel.invalidate(); }

  // Generic method for "toggling" a pixel (not'ing the mask bit).
  // This is a no-op by default, but it actually calls px.validate()
  // for PixelMask<> types.
  template <class PixelT>
  inline void toggle(PixelT &/*pixel*/) { return; }

  template <class ChildPixelT>
  inline void toggle(PixelMask<ChildPixelT> &pixel) { pixel.toggle(); }

  // Remove mask
  template <class PixelT>
  inline PixelT& remove_mask(PixelT& pixel) { return pixel; }

  template <class PixelT>
  inline const PixelT& remove_mask(const PixelT& pixel) { return pixel; }

  template <class PixelT>
  inline PixelT& remove_mask(PixelMask<PixelT>& pixel) { return pixel.child(); }

  template <class PixelT>
  inline const PixelT& remove_mask(const PixelMask<PixelT>& pixel) { return pixel.child(); }

  /// Print a PixelMask to a debugging stream.
  template <class ChildT>
  std::ostream& operator<<( std::ostream& os, PixelMask<ChildT> const& pix ) {
    return os << "PixelMask( " << pix.child() << " : " << _numeric(pix.valid()) << " )";
  }

  // *******************************************************************
  // Type Traits
  // *******************************************************************

  template <class T>
  struct CompoundChannelType<PixelMask<T> > {
    typedef typename CompoundChannelType<T>::type type;
  };
  template <class T>
  struct CompoundNumChannels<PixelMask<T> > {
    static const size_t value = CompoundNumChannels<T>::value + 1;
  };
  template <class OldT, class NewChT>
  struct CompoundChannelCast<PixelMask<OldT>, NewChT> {
    typedef PixelMask<typename CompoundChannelCast<OldT,NewChT>::type> type;
  };
  template <class OldT, class NewChT>
  struct CompoundChannelCast<PixelMask<OldT>, const NewChT> {
    typedef const PixelMask<typename CompoundChannelCast<OldT,NewChT>::type> type;
  };
  template <class T> struct IsMasked : public boost::false_type::type {};
  template <class T> struct IsMasked<PixelMask<T> > : public boost::true_type::type {};

  // Computes the mean value of a compound PixelMask<> type.  Not
  // especially efficient.
  template <class T>
  typename boost::enable_if< IsScalarOrCompound<T>, double >::type
  inline mean_channel_value( PixelMask<T> const& arg ) {
    typedef typename CompoundChannelType<T>::type channel_type;
    if (arg.valid()) {
      size_t num_channels = CompoundNumChannels<T>::value;
      double accum = 0;
      for( size_t i=0; i<num_channels-1; ++i )
        accum += compound_select_channel<channel_type const&>( arg, i );
      return accum / num_channels;
    } else {
      return 0;
    }
  }

  // These are handy for determining what the masked type is for a
  // given pixel type.
  template <class PixelT>
  struct MaskedPixelType { typedef PixelMask<PixelT> type; };

  // Most importantly, we want to make sure that we only wrap each
  // pixel in one layer of PixelMask<>.
  template <class ChildT>
  struct MaskedPixelType<PixelMask<ChildT> > { typedef PixelMask<ChildT> type; };

  // These are handy for determining what the masked type is for a
  // given pixel type.
  template <class PixelT>
  struct UnmaskedPixelType { typedef PixelT type; };

  // Most importantly, we want to make sure that we only wrap each
  // pixel in one layer of PixelMask<>.
  template <class ChildT>
  struct UnmaskedPixelType<PixelMask<ChildT> > { typedef ChildT type; };

  // *******************************************************************
  // Binary elementwise compound type functor.
  // *******************************************************************

  template <class FuncT, class ChildPixel1T, class ChildPixel2T>
  class BinaryCompoundFunctor<FuncT, PixelMask<ChildPixel1T>, PixelMask<ChildPixel2T> > {
    FuncT func;

    // The general multi-channel case
    template <bool CompoundB, size_t ChannelsN, class ResultT, class Arg1T, class Arg2T>
    struct Helper {
      static inline ResultT construct( FuncT const& func, Arg1T const& arg1, Arg2T const& arg2 ) {
        ResultT result;
        for( size_t i=0; i<ChannelsN-1; ++i ) result[i] = func(arg1[i],arg2[i]);
        if (arg1.valid() && arg2.valid())
          result.validate();
        return result;
      }
    };

    // Specialization for one-channel + 1 "valid pixel" channel
    template <class ResultT, class Arg1T, class Arg2T>
    struct Helper<true,2,ResultT,Arg1T,Arg2T> {
      static inline ResultT construct( FuncT const& func, Arg1T const& arg1, Arg2T const& arg2 ) {
        ResultT result( func(arg1[0],arg2[0]) );
        if (!arg1.valid() || !arg2.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for two-channel + 1 valid pixel channel types
    template <class ResultT, class Arg1T, class Arg2T>
    struct Helper<true,3,ResultT,Arg1T,Arg2T> {
      static inline ResultT construct( FuncT const& func, Arg1T const& arg1, Arg2T const& arg2 ) {
        ResultT result( func(arg1[0],arg2[0]), func(arg1[1],arg2[1]) );
        if (!arg1.valid() || !arg2.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for three-channel + 1 valid pixel channel types
    template <class ResultT, class Arg1T, class Arg2T>
    struct Helper<true,4,ResultT,Arg1T,Arg2T> {
      static inline ResultT construct( FuncT const& func, Arg1T const& arg1, Arg2T const& arg2 ) {
        ResultT result( func(arg1[0],arg2[0]), func(arg1[1],arg2[1]), func(arg1[2],arg2[2]) );
        if (!arg1.valid() || !arg2.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for four-channel + 1 valid pixel channel types
    template <class ResultT, class Arg1T, class Arg2T>
    struct Helper<true,5,ResultT,Arg1T,Arg2T> {
      static inline ResultT construct( FuncT const& func, Arg1T const& arg1, Arg2T const& arg2 ) {
        ResultT result( func(arg1[0],arg2[0]), func(arg1[1],arg2[1]), func(arg1[2],arg2[2]), func(arg1[3],arg2[3]) );
        if (!arg1.valid() || !arg2.valid())
          result.invalidate();
        return result;
      }
    };

  public:
    BinaryCompoundFunctor() : func() {}
    BinaryCompoundFunctor( FuncT const& func ) : func(func) {}

    template <class ArgsT> struct result {};

    template <class F, class Arg1T, class Arg2T>
    struct result<F(Arg1T,Arg2T)> {
      typedef typename CompoundChannelType<Arg1T>::type arg1_type;
      typedef typename CompoundChannelType<Arg2T>::type arg2_type;
      typedef typename boost::result_of<FuncT(arg1_type,arg2_type)>::type result_type;
      typedef typename CompoundChannelCast<Arg1T,result_type>::type type;
    };

    template <class Arg1T, class Arg2T>
    typename result<BinaryCompoundFunctor(Arg1T,Arg2T)>::type
    inline operator()( Arg1T const& arg1, Arg2T const& arg2 ) const {
      typedef typename result<BinaryCompoundFunctor(Arg1T,Arg2T)>::type result_type;
      return Helper<IsCompound<result_type>::value,CompoundNumChannels<result_type>::value,result_type,Arg1T,Arg2T>::construct(func,arg1,arg2);
    }
  };

  // *******************************************************************
  // Binary in-place elementwise compound type functor.
  // *******************************************************************

  template <class FuncT, class ChildPixel1T, class ChildPixel2T>
  class BinaryInPlaceCompoundFunctor<FuncT, PixelMask<ChildPixel1T>, PixelMask<ChildPixel2T> > {
    FuncT func;

    // The general multi-channel case
    template <bool CompoundB, size_t ChannelsN, class Arg1T, class Arg2T>
    struct Helper {
      static inline Arg1T& apply( FuncT const& func, Arg1T& arg1, Arg2T const& arg2 ) {
        for( size_t i=0; i<ChannelsN-1; ++i ) func(arg1[i],arg2[i]);
        if (!arg2.valid())
          arg1.invalidate();
        return arg1;
      }
    };

    // Specialization for one-channel types + 1 "valid pixel" channel
    template <class Arg1T, class Arg2T>
    struct Helper<true,2,Arg1T,Arg2T> {
      static inline Arg1T& apply( FuncT const& func, Arg1T& arg1, Arg2T const& arg2 ) {
        func(arg1[0],arg2[0]);
        if (!arg2.valid())
          arg1.invalidate();
        return arg1;
      }
    };

    // Specialization for two-channel types + 1 "valid pixel" channel
    template <class Arg1T, class Arg2T>
    struct Helper<true,3,Arg1T,Arg2T> {
      static inline Arg1T& apply( FuncT const& func, Arg1T& arg1, Arg2T const& arg2 ) {
        func(arg1[0],arg2[0]);
        func(arg1[1],arg2[1]);
        if (!arg2.valid())
          arg1.invalidate();
        return arg1;
      }
    };

    // Specialization for three-channel types + 1 "valid pixel" channel
    template <class Arg1T, class Arg2T>
    struct Helper<true,4,Arg1T,Arg2T> {
      static inline Arg1T& apply( FuncT const& func, Arg1T& arg1, Arg2T const& arg2 ) {
        func(arg1[0],arg2[0]);
        func(arg1[1],arg2[1]);
        func(arg1[2],arg2[2]);
        if (!arg2.valid())
          arg1.invalidate();
        return arg1;
      }
    };

    // Specialization for four-channel types + 1 "valid pixel" channel
    template <class Arg1T, class Arg2T>
    struct Helper<true,5,Arg1T,Arg2T> {
      static inline Arg1T& apply( FuncT const& func, Arg1T& arg1, Arg2T const& arg2 ) {
        func(arg1[0],arg2[0]);
        func(arg1[1],arg2[1]);
        func(arg1[2],arg2[2]);
        func(arg1[3],arg2[3]);
        if (!arg2.valid())
          arg1.invalidate();
        return arg1;
      }
    };

  public:
    BinaryInPlaceCompoundFunctor() : func() {}
    BinaryInPlaceCompoundFunctor( FuncT const& func ) : func(func) {}

    template <class ArgsT> struct result {};

    template <class F, class Arg1T, class Arg2T>
    struct result<F(Arg1T,Arg2T)> {
      typedef Arg1T& type;
    };

    template <class Arg1T, class Arg2T>
    typename result<BinaryInPlaceCompoundFunctor(Arg1T,Arg2T)>::type
    inline operator()( Arg1T& arg1, Arg2T const& arg2 ) const {
      return Helper<IsCompound<Arg1T>::value,CompoundNumChannels<Arg1T>::value,Arg1T,Arg2T>::apply(func,arg1,arg2);
    }
  };

  // *******************************************************************
  // Unary elementwise compound type functor.
  // *******************************************************************

  template <class FuncT, class ChildPixelT>
  class UnaryCompoundFunctor<FuncT, PixelMask<ChildPixelT> > {
    FuncT func;

    // The general multi-channel case
    template <bool CompoundB, size_t ChannelsN, class ResultT, class ArgT>
    struct Helper {
      static inline ResultT construct( FuncT const& func, ArgT const& arg ) {
        ResultT result;
        for( size_t i=0; i<ChannelsN-1; ++i ) result[i] = func(arg[i]);
        if (arg.valid())
          result.validate();
        return result;
      }
    };

    // Specialization for one-channel + 1 "valid pixel" channel
    template <class ResultT, class ArgT>
    struct Helper<true,2,ResultT,ArgT> {
      static inline ResultT construct( FuncT const& func, ArgT const& arg ) {
        ResultT result( func(arg[0]) );
        if (!arg.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for two-channel + 1 valid pixel channel types
    template <class ResultT, class ArgT>
    struct Helper<true,3,ResultT,ArgT> {
      static inline ResultT construct( FuncT const& func, ArgT const& arg ) {
        ResultT result( func(arg[0]), func(arg[1]) );
        if (!arg.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for three-channel + 1 valid pixel channel types
    template <class ResultT, class ArgT>
    struct Helper<true,4,ResultT,ArgT> {
      static inline ResultT construct( FuncT const& func, ArgT const& arg ) {
        ResultT result( func(arg[0]), func(arg[1]), func(arg[2]) );
        if (!arg.valid())
          result.invalidate();
        return result;
      }
    };

    // Specialization for four-channel + 1 valid pixel channel types
    template <class ResultT, class ArgT>
    struct Helper<true,5,ResultT,ArgT> {
      static inline ResultT construct( FuncT const& func, ArgT const& arg ) {
        ResultT result( func(arg[0]), func(arg[1]), func(arg[2]), func(arg[3]) );
        if (!arg.valid())
          result.invalidate();
        return result;
      }
    };

  public:
    UnaryCompoundFunctor() : func() {}
    UnaryCompoundFunctor( FuncT const& func ) : func(func) {}

    template <class ArgsT> struct result {};

    template <class F, class ArgT>
    struct result<F(ArgT)> {
      typedef typename CompoundChannelType<ArgT>::type arg_type;
      typedef typename boost::result_of<FuncT(arg_type)>::type result_type;
      typedef typename CompoundChannelCast<ArgT,result_type>::type type;
    };

    template <class ArgT>
    typename result<UnaryCompoundFunctor(ArgT)>::type
    inline operator()( ArgT const& arg ) const {
      typedef typename result<UnaryCompoundFunctor(ArgT)>::type result_type;
      return Helper<IsCompound<result_type>::value,CompoundNumChannels<result_type>::value,result_type,ArgT>::construct(func,arg);
    }
  };

  // *******************************************************************
  // Unary in-place elementwise compound type functor.
  // *******************************************************************

  template <class FuncT, class ChildPixelT>
  class UnaryInPlaceCompoundFunctor<FuncT, PixelMask<ChildPixelT> > {
    FuncT func;
    typedef typename boost::add_reference<FuncT>::type func_ref;

    // The general multi-channel case
    template <bool CompoundB, size_t ChannelsN, class ArgT>
    struct Helper {
      static inline ArgT& apply( func_ref func, ArgT& arg ) {
        for( size_t i=0; i<ChannelsN-1; ++i ) func(arg[i]);
        return arg;
      }
    };

    // Specialization for one-channel types + 1 "valid pixel" channel
    template <class ArgT>
    struct Helper<true,2,ArgT> {
      static inline ArgT& apply( func_ref func, ArgT& arg ) {
        func(arg[0]);
        return arg;
      }
    };

    // Specialization for two-channel types + 1 "valid pixel" channel
    template <class ArgT>
    struct Helper<true,3,ArgT> {
      static inline ArgT& apply( func_ref func, ArgT& arg ) {
        func(arg[0]);
        func(arg[1]);
        return arg;
      }
    };

    // Specialization for three-channel types + 1 "valid pixel" channel
    template <class ArgT>
    struct Helper<true,4,ArgT> {
      static inline ArgT& apply( func_ref func, ArgT& arg ) {
        func(arg[0]);
        func(arg[1]);
        func(arg[2]);
        return arg;
      }
    };

    // Specialization for four-channel types + 1 "valid pixel" channel
    template <class ArgT>
    struct Helper<true,5,ArgT> {
      static inline ArgT& apply( func_ref func, ArgT& arg ) {
        func(arg[0]);
        func(arg[1]);
        func(arg[2]);
        func(arg[3]);
        return arg;
      }
    };

  public:
    UnaryInPlaceCompoundFunctor() : func() {}
    UnaryInPlaceCompoundFunctor( func_ref func ) : func(func) {}

    template <class ArgsT> struct result {};

    /// FIXME: This seems not to respect the constness of ArgT?  Weird?
    template <class F, class ArgT>
    struct result<F(ArgT)> {
      typedef ArgT& type;
    };

    template <class ArgT>
    inline ArgT& operator()( ArgT& arg ) const {
      return Helper<IsCompound<ArgT>::value,CompoundNumChannels<ArgT>::value,ArgT>::apply(func,arg);
    }

    template <class ArgT>
    inline const ArgT& operator()( const ArgT& arg ) const {
      return Helper<IsCompound<ArgT>::value,CompoundNumChannels<ArgT>::value,const ArgT>::apply(func,arg);
    }
  };

  // ******************************************************************
  // Special Quotient Safe Functors for Pixel Mask types
  struct ArgArgMaskedSafeQuotientFunctor : BinaryReturnTemplateType<QuotientType> {
    template <class Arg1T, class Arg2T>
    inline typename QuotientType<PixelMask<Arg1T>, PixelMask<Arg2T> >::type
    operator()( PixelMask<Arg1T> const& arg1, PixelMask<Arg2T> const& arg2 ) const {
      if ( arg2.child() == Arg2T() ) {
        if ( is_valid(arg1) && is_valid(arg2) )
          return typename QuotientType<PixelMask<Arg1T>,PixelMask<Arg2T> >::type(0); // Valid
        else
          return typename QuotientType<PixelMask<Arg1T>,PixelMask<Arg2T> >::type();
      }
      else return ( arg1 / arg2 );
    }
  };

  template <class ValT>
  struct ValArgMaskedSafeQuotientFunctor : UnaryReturnBinaryTemplateBind1st<QuotientType,ValT> {
  private:
    const ValT m_val;
  public:
    ValArgMaskedSafeQuotientFunctor( ValT const& val ) : m_val(val) {}

    template <class ArgT>
    inline typename QuotientType<ValT, PixelMask<ArgT> >::type
    operator()( PixelMask<ArgT> const& arg ) const {
      if ( arg.child()==ArgT() ) {
        if ( is_valid(arg) && is_valid(m_val) )
          return typename QuotientType<ValT,PixelMask<ArgT> >::type(0);
        else
          return typename QuotientType<ValT,PixelMask<ArgT> >::type();
      }
      else return (m_val / arg);
    }
  };

  struct ArgArgInPlaceMaskedSafeQuotientFunctor : BinaryReturn1stType {
    template <class Arg1T, class Arg2T>
    inline PixelMask<Arg1T>& operator()( PixelMask<Arg1T>& arg1,
                                         PixelMask<Arg2T> const& arg2 ) const {
      if ( arg2.child()==Arg2T() ) {
        if ( is_valid(arg1) && is_valid(arg2) )
          return arg1=PixelMask<Arg1T>(0);
        else
          return arg1=PixelMask<Arg1T>();
      } else
        return arg1=(PixelMask<Arg1T>)(arg1/arg2);
    }
  };

  // *******************************************************************
  // The Pixel Math specialization for math against PixelMask<Scalar>
  //
  // Yet this should specifically not do PixelMask<scalar> against
  // PixelMask<scalar> as that becomes an ambiguous call against the
  // normal math operators.
  // *******************************************************************
#define VW_PIXEL_MASK_MATH_BINARY_PS_FUNCTION(func,ftor)                                \
  template <class PixelT, class ScalarT>                                                \
    typename boost::enable_if< boost::mpl::and_<boost::mpl::and_<IsScalar<ScalarT>, IsMasked<PixelT> >, \
                               boost::mpl::not_<boost::is_same<PixelT,PixelMask<ScalarT> > > >, \
                               typename CompoundResult<ftor<ScalarT>,PixelT>::type >::type \
  inline func( PixelMathBase<PixelT> const& pixel, PixelMask<ScalarT> masked_scalar ) { \
    if (!masked_scalar.valid()) {                                                       \
      PixelT px = pixel.impl();                                                         \
      px.invalidate();                                                                  \
      return compound_apply(ftor<ScalarT>(masked_scalar.child()), px );                 \
    } else {                                                                            \
      return compound_apply(ftor<ScalarT>(masked_scalar.child()), pixel.impl() );       \
    }                                                                                \
  }

#define VW_PIXEL_MASK_MATH_BINARY_SP_FUNCTION(func,ftor)                                \
  template <class PixelT, class ScalarT>                                                \
    typename boost::enable_if< boost::mpl::and_<boost::mpl::and_<IsScalar<ScalarT>, IsMasked<PixelT> >, \
                               boost::mpl::not_<boost::is_same<PixelT,PixelMask<ScalarT> > > >, \
                               typename CompoundResult<ftor<ScalarT>,PixelT>::type >::type \
  inline func( PixelMask<ScalarT> masked_scalar, PixelMathBase<PixelT> const& pixel ) { \
    if (!masked_scalar.valid()) {                                                       \
      PixelT px = pixel.impl();                                                         \
      px.invalidate();                                                                  \
      return compound_apply(ftor<ScalarT>(masked_scalar.child()), px );                 \
    } else {                                                                            \
      return compound_apply(ftor<ScalarT>(masked_scalar.child()), pixel.impl() );       \
    }                                                                                \
  }

#define VW_PIXEL_MASK_MATH_BINARY_IS_FUNCTION(func,ftor)                                 \
  template <class PixelT, class ScalarT>                                                 \
    typename boost::enable_if< boost::mpl::and_<IsScalar<ScalarT>, IsMasked<PixelT> >, PixelT&>::type \
  inline func( PixelMathBase<PixelT>& pixel, PixelMask<ScalarT> masked_scalar ) {        \
    if (!masked_scalar.valid())                                                          \
      pixel.impl().invalidate();                                                         \
    return compound_apply_in_place(ftor<ScalarT>(masked_scalar.child()), pixel.impl() ); \
  }

  VW_PIXEL_MASK_MATH_BINARY_PS_FUNCTION(operator +, vw::ArgValSumFunctor)
  VW_PIXEL_MASK_MATH_BINARY_SP_FUNCTION(operator +, vw::ValArgSumFunctor)
  VW_PIXEL_MASK_MATH_BINARY_IS_FUNCTION(operator +=, vw::ArgValInPlaceSumFunctor)
  VW_PIXEL_MASK_MATH_BINARY_PS_FUNCTION(operator -, vw::ArgValDifferenceFunctor)
  VW_PIXEL_MASK_MATH_BINARY_SP_FUNCTION(operator -, vw::ValArgDifferenceFunctor)
  VW_PIXEL_MASK_MATH_BINARY_IS_FUNCTION(operator -=, vw::ArgValInPlaceDifferenceFunctor)
  VW_PIXEL_MASK_MATH_BINARY_PS_FUNCTION(operator *, vw::ArgValProductFunctor)
  VW_PIXEL_MASK_MATH_BINARY_SP_FUNCTION(operator *, vw::ValArgProductFunctor)
  VW_PIXEL_MASK_MATH_BINARY_IS_FUNCTION(operator *=, vw::ArgValInPlaceProductFunctor)
  VW_PIXEL_MASK_MATH_BINARY_PS_FUNCTION(operator /, vw::ArgValQuotientFunctor)
  VW_PIXEL_MASK_MATH_BINARY_SP_FUNCTION(operator /, vw::ValArgQuotientFunctor)
  VW_PIXEL_MASK_MATH_BINARY_IS_FUNCTION(operator /=, vw::ArgValInPlaceQuotientFunctor)

} // namespace vw

#endif // __VW_IMAGE_PIXELMASK_H__


text:
name: Question
about: Ask a question
title: ''
labels: question
assignees: ''

---

IMPORTANT!
If possible, please ask on the Discord here: https://discord.gg/6g47knp
Questions on the Discord are usually answered more quickly, and are easier to manage than Github issues.

If you are unable or unwilling to use Discord, then delete this line and the above, and ask away.


text:
package org.efaps.ui.wicket.components.dashboard;

import org.efaps.api.background.IExecutionBridge;
import org.efaps.api.background.IJob;
import org.efaps.ui.wicket.background.ExecutionBridge;
import org.efaps.ui.wicket.models.EsjpInvoker;
import org.efaps.util.EFapsBaseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * The Class DashboardJob.
 *
 * @author The eFaps Team
 */
public class DashboardJob
    implements IJob
{
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /**
     * Logging instance used in this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(DashboardJob.class);

    /** The esjp invoker. */
    private final EsjpInvoker esjpInvoker;

    /**
     * Instantiates a new dashboard job.
     *
     * @param _esjpInvoker the _esjp invoker
     */
    public DashboardJob(final EsjpInvoker _esjpInvoker)
    {
        this.esjpInvoker = _esjpInvoker;
    }

    @Override
    public void execute(final IExecutionBridge _bridge)
    {
        try {
            final String content = this.esjpInvoker.getHtmlSnipplet().toString();
            ((ExecutionBridge) _bridge).setContent(content);
            ((ExecutionBridge) _bridge).setProgress(100);
        } catch (final EFapsBaseException e) {
            LOG.error("Execute", e);
        }
    }
}


text:
@implementation BBTemplaterTagParam

+ (NSString *)tagName {
	return @"param";
}

- (NSString *)name {
	NSString *name = self.attributes[@"name"];
#if DEBUG
	if (!name) {
		NSLog(@"[BBTemplaterTagParam][ERROR]: missing attribute 'name'");
	}
#endif
	return name;
}

- (NSString *)value {
	NSString *value = super.value;
#if DEBUG
	if (!value) {
		NSLog(@"[BBTemplaterTagParam][ERROR]: missing attribute 'value'");
	}
#endif
	return value;
}

- (BOOL)includeHidden {
	BOOL include = NO;
	if (self.attributes[@"include"] && [self.attributes[@"include"] isEqualToString:@"hidden"]) {
		include = YES;
	}
	return include;
}

@end


text:
((app) => {
    'use strict'
    app.component("home", {
        templateUrl: 'js/components/home/home.html',
        controller: ['UserService', 'PageService', 'InstagramService', 'FacebookService','$state', 'ngMeta', 'SlackService', function(UserService, PageService, InstagramService, FacebookService, $state, ngMeta, SlackService) {
            angular.extend(this, {
                editMode: false,
                cancel(){
                  this.editMode = false
                  $state.go('app.home', {}, { reload: true })
                },
                save() {
                    PageService.save(angular.copy(this.page)).then(()=>{
                      toastr.success(`${this.page.name} saved`)
                      this.editMode = false;
                    }).catch((err)=>{
                      toastr.error(`${err.data}`)
                    })
                },
                $onInit() {
                    UserService.getCurrent().then((user) => {
                        this.user = user
                    }).catch((err) => {})

                    PageService.get('home').then((res) => {
                      this.page = res.data;
                      if (this.page.content){
                        this.page.content = JSON.parse(this.page.content);
                    }
                    }).catch((err) =>{
                      console.log(err);
                    })
                    FacebookService.getFeeds(9).then((res) => {
                        this.posts_a = [];
                        this.posts_b = [];
                        this.posts_c = [];
                        res.data.data.forEach((el, index)=> {
                            FacebookService.getInfos(el.id).then((res) => {
                                if (index <= 2) {
                                    this.posts_a.push(res.data);
                                } else if (index <= 5) {
                                    this.posts_b.push(res.data);
                                } else {
                                    this.posts_c.push(res.data);
                                }
                            });
                        });
                    });

                    InstagramService.fetchPhotos().then((res)=> {
                        this.instagram = [];
                        res.data.data.forEach((el, index) => {
                            this.instagram.push(el);
                        });

                    });

                    // SlackService.postMessage('$general', 'helloworld')
                    ngMeta.setTitle('Vibesharing | Travel for People and culture by bike on Budget');
                    ngMeta.setTag('author', 'Hadrien Buret');
                    ngMeta.setTag('description', 'Vibesharing is a travel blog where you will find articles, maps and other tips on how to travel in Asia and South-Korea by bike on a budget.');
                    ngMeta.setTag('type', 'website');
                    ngMeta.setTag('image', 'https://s3.eu-central-1.amazonaws.com/vibesharing-static/vibesharing_home_page_meta.png');
                    ngMeta.setTag('url', 'http://korea.vibesharing.com/#!');
                }
            });
        }]
    });
})(angular.module('app.home'))