<commit_before>#ifndef VIENNAGRID_CONFIG_GENERIC_CONFIG_HPP
#define VIENNAGRID_CONFIG_GENERIC_CONFIG_HPP

/* =======================================================================
   Copyright (c) 2011-2012, Institute for Microelectronics,
                            Institute for Analysis and Scientific Computing,
                            TU Wien.

                            -----------------
                     ViennaGrid - The Vienna Grid Library
                            -----------------

   Authors:      Karl Rupp                           rupp@iue.tuwien.ac.at
                 Josef Weinbub                    weinbub@iue.tuwien.ac.at

   (A list of additional contributors can be found in the PDF manual)

   License:      MIT (X11), see file LICENSE in the base directory
======================================================================= */

#include "viennagrid/topology/simplex.hpp"

/** @file config/simplex.hpp
    @brief Provides default configuration classes for simplex domains
*/

namespace viennagrid
{
    namespace result_of
    {
        //
        // Meta Functions for creating a default config
        //

        template<typename element_tag, typename boundary_cell_tag>
        struct storage_layout_config
        {

            typedef typename viennameta::typemap::result_of::insert<
                typename storage_layout_config<element_tag, typename boundary_cell_tag::facet_tag>::type,
                viennameta::static_pair<
                    boundary_cell_tag,
                    viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::full_handling_tag >
                >
            >::type type;
        };

        template<typename element_tag>
        struct storage_layout_config<element_tag, viennagrid::vertex_tag>
        {
            //typedef viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag > type;
            typedef typename viennameta::make_typemap<
                viennagrid::vertex_tag,
                viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag >
            >::type type;
        };

        template<typename element_tag>
        struct storage_layout_config<element_tag, viennameta::null_type>
        {
            //typedef viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag > type;
            typedef viennameta::null_type type;
        };

        template<typename element_tag, typename boundary_cell_tag>
        struct default_container_tag
        {
            typedef viennagrid::storage::hidden_key_map_tag< viennagrid::storage::element_key_tag<int> > type;
        };

        template<typename element_tag>
        struct default_container_tag<element_tag, element_tag>
        {
            typedef viennagrid::storage::std_deque_tag type;
        };

        template<typename element_tag>
        struct default_container_tag<element_tag, viennagrid::vertex_tag>
        {
            typedef viennagrid::storage::std_deque_tag type;
        };

        template<typename element_tag, typename boundary_cell_tag, typename hook_tag>
        struct default_element_config
        {
            typedef typename viennameta::make_typemap<

                viennagrid::element_id_type_tag,
                int,

                viennagrid::element_container_tag,
                viennagrid::storage::hooked_container_tag<
                    //viennagrid::storage::std_deque_tag,
                    typename default_container_tag<element_tag, boundary_cell_tag>::type,
                    hook_tag
                >,

                viennagrid::element_boundary_storage_layout_tag,
                typename storage_layout_config<element_tag, typename boundary_cell_tag::facet_tag>::type

            >::type type;
        };

        template<typename element_tag, typename boundary_cell_tag, typename hook_tag>
        struct default_config_helper
        {
            typedef typename viennameta::typemap::result_of::insert<
                typename default_config_helper<element_tag, typename boundary_cell_tag::facet_tag, hook_tag>::type,
                viennameta::static_pair<
                    boundary_cell_tag,
                    typename default_element_config<element_tag, boundary_cell_tag, hook_tag>::type
                >
            >::type type;
        };

        template<typename element_tag, typename hook_tag>
        struct default_config_helper<element_tag, viennagrid::vertex_tag, hook_tag>
        {
            typedef typename viennameta::make_typemap<
                viennagrid::vertex_tag,
                typename default_element_config<element_tag, viennagrid::vertex_tag, hook_tag>::type
            >::type type;
        };

        template<typename element_tag, typename hook_tag>
        struct default_config
        {
            typedef typename default_config_helper<element_tag, element_tag, hook_tag>::type type;
        };
    }
}

#endif
<commit_msg>new boundary handling tags<commit_after>#ifndef VIENNAGRID_CONFIG_GENERIC_CONFIG_HPP
#define VIENNAGRID_CONFIG_GENERIC_CONFIG_HPP

/* =======================================================================
   Copyright (c) 2011-2012, Institute for Microelectronics,
                            Institute for Analysis and Scientific Computing,
                            TU Wien.

                            -----------------
                     ViennaGrid - The Vienna Grid Library
                            -----------------

   Authors:      Karl Rupp                           rupp@iue.tuwien.ac.at
                 Josef Weinbub                    weinbub@iue.tuwien.ac.at

   (A list of additional contributors can be found in the PDF manual)

   License:      MIT (X11), see file LICENSE in the base directory
======================================================================= */

#include "viennagrid/topology/simplex.hpp"

/** @file config/simplex.hpp
    @brief Provides default configuration classes for simplex domains
*/

namespace viennagrid
{
    namespace result_of
    {
        //
        // Meta Functions for creating a default config
        //

        template<typename element_tag, typename boundary_cell_tag>
        struct storage_layout_config
        {

            typedef typename viennameta::typemap::result_of::insert<
                typename storage_layout_config<element_tag, typename boundary_cell_tag::facet_tag>::type,
                viennameta::static_pair<
                    boundary_cell_tag,
                    viennagrid::full_handling_tag
                    //viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::full_handling_tag >
                >
            >::type type;
        };

        template<typename element_tag>
        struct storage_layout_config<element_tag, viennagrid::vertex_tag>
        {
            //typedef viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag > type;
            typedef typename viennameta::make_typemap<
                viennagrid::vertex_tag,
                viennagrid::no_orientation_handling_tag
                //viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag >
            >::type type;
        };

        template<typename element_tag>
        struct storage_layout_config<element_tag, viennameta::null_type>
        {
            //typedef viennameta::static_pair< viennagrid::full_handling_tag, viennagrid::no_handling_tag > type;
            typedef viennameta::null_type type;
        };

        template<typename element_tag, typename boundary_cell_tag>
        struct default_container_tag
        {
            typedef viennagrid::storage::hidden_key_map_tag< viennagrid::storage::element_key_tag<int> > type;
        };

        template<typename element_tag>
        struct default_container_tag<element_tag, element_tag>
        {
            typedef viennagrid::storage::std_deque_tag type;
        };

        template<typename element_tag>
        struct default_container_tag<element_tag, viennagrid::vertex_tag>
        {
            typedef viennagrid::storage::std_deque_tag type;
        };

        template<typename element_tag, typename boundary_cell_tag, typename hook_tag>
        struct default_element_config
        {
            typedef typename viennameta::make_typemap<

                viennagrid::element_id_type_tag,
                int,

                viennagrid::element_container_tag,
                viennagrid::storage::hooked_container_tag<
                    //viennagrid::storage::std_deque_tag,
                    typename default_container_tag<element_tag, boundary_cell_tag>::type,
                    hook_tag
                >,

                viennagrid::element_boundary_storage_layout_tag,
                typename storage_layout_config<element_tag, typename boundary_cell_tag::facet_tag>::type

            >::type type;
        };

        template<typename element_tag, typename boundary_cell_tag, typename hook_tag>
        struct default_config_helper
        {
            typedef typename viennameta::typemap::result_of::insert<
                typename default_config_helper<element_tag, typename boundary_cell_tag::facet_tag, hook_tag>::type,
                viennameta::static_pair<
                    boundary_cell_tag,
                    typename default_element_config<element_tag, boundary_cell_tag, hook_tag>::type
                >
            >::type type;
        };

        template<typename element_tag, typename hook_tag>
        struct default_config_helper<element_tag, viennagrid::vertex_tag, hook_tag>
        {
            typedef typename viennameta::make_typemap<
                viennagrid::vertex_tag,
                typename default_element_config<element_tag, viennagrid::vertex_tag, hook_tag>::type
            >::type type;
        };

        template<typename element_tag, typename hook_tag>
        struct default_config
        {
            typedef typename default_config_helper<element_tag, element_tag, hook_tag>::type type;
        };
    }
}

#endif
<|endoftext|>


<commit_before>//===-- PowerPCTargetMachine.cpp - Define TargetMachine for PowerPC -------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Top-level implementation for the PowerPC target.
//
//===----------------------------------------------------------------------===//

#include "PowerPC.h"
#include "PowerPCTargetMachine.h"
#include "PowerPCFrameInfo.h"
#include "PPC32TargetMachine.h"
#include "PPC32JITInfo.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/CommandLine.h"
#include <iostream>
using namespace llvm;

namespace {
  const char *PPC32ID = "PowerPC/32bit";

  static cl::opt<bool> DisablePPCDAGDAG("disable-ppc-dag-isel", cl::Hidden,
                             cl::desc("Disable DAG-to-DAG isel for PPC"));

  // Register the targets
  RegisterTarget<PPC32TargetMachine>
  X("ppc32", "  PowerPC 32-bit");
}

PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
                                           IntrinsicLowering *IL,
                                           const Module &M,
                                           const std::string &FS,
                                           const TargetData &TD,
                                           const PowerPCFrameInfo &TFI)
: TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M, FS) {
  if (TargetDefault == PPCTarget) {
    if (Subtarget.isAIX()) PPCTarget = TargetAIX;
    if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
  }
}

unsigned PPC32TargetMachine::getJITMatchQuality() {
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
  return 10;
#else
  return 0;
#endif
}

/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
                                               std::ostream &Out,
                                                CodeGenFileType FileType) {
  if (FileType != TargetMachine::AssemblyFile) return true;

  // Run loop strength reduction before anything else.
  PM.add(createLoopStrengthReducePass());
  PM.add(createCFGSimplificationPass());

  // FIXME: Implement efficient support for garbage collection intrinsics.
  PM.add(createLowerGCPass());

  // FIXME: Implement the invoke/unwind instructions!
  PM.add(createLowerInvokePass());

  // FIXME: Implement the switch instruction in the instruction selector!
  PM.add(createLowerSwitchPass());

  // Make sure that no unreachable blocks are instruction selected.
  PM.add(createUnreachableBlockEliminationPass());

  // Install an instruction selector.
  if (!DisablePPCDAGDAG)
    PM.add(createPPC32ISelDag(*this));
  else
    PM.add(createPPC32ISelPattern(*this));

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));

  PM.add(createRegisterAllocator());

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));

  PM.add(createPrologEpilogCodeInserter());

  // Must run branch selection immediately preceding the asm printer
  PM.add(createPPCBranchSelectionPass());

  // Decide which asm printer to use.  If the user has not specified one on
  // the command line, choose whichever one matches the default (current host).
  switch (PPCTarget) {
  case TargetAIX:
    PM.add(createAIXAsmPrinter(Out, *this));
    break;
  case TargetDefault:
  case TargetDarwin:
    PM.add(createDarwinAsmPrinter(Out, *this));
    break;
  }

  PM.add(createMachineCodeDeleter());
  return false;
}

void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
  // The JIT does not support or need PIC.
  PICEnabled = false;

  // Run loop strength reduction before anything else.
  PM.add(createLoopStrengthReducePass());
  PM.add(createCFGSimplificationPass());

  // FIXME: Implement efficient support for garbage collection intrinsics.
  PM.add(createLowerGCPass());

  // FIXME: Implement the invoke/unwind instructions!
  PM.add(createLowerInvokePass());

  // FIXME: Implement the switch instruction in the instruction selector!
  PM.add(createLowerSwitchPass());

  // Make sure that no unreachable blocks are instruction selected.
  PM.add(createUnreachableBlockEliminationPass());

  // Install an instruction selector.
  PM.add(createPPC32ISelPattern(TM));

  PM.add(createRegisterAllocator());
  PM.add(createPrologEpilogCodeInserter());

  // Must run branch selection immediately preceding the asm printer
  PM.add(createPPCBranchSelectionPass());

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));
}

/// PowerPCTargetMachine ctor - Create an ILP32 architecture model
///
PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL,
                                       const std::string &FS)
  : PowerPCTargetMachine(PPC32ID, IL, M, FS,
                         TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1),
                         PowerPCFrameInfo(*this, false)), JITInfo(*this) {}

unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
  // We strongly match "powerpc-*".
  std::string TT = M.getTargetTriple();
  if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
    return 20;

  if (M.getEndianness()  == Module::BigEndian &&
      M.getPointerSize() == Module::Pointer32)
    return 10;                                   // Weak match
  else if (M.getEndianness() != Module::AnyEndianness ||
           M.getPointerSize() != Module::AnyPointerSize)
    return 0;                                    // Match for some other target

  return getJITMatchQuality()/2;
}
<commit_msg>Move the post-lsr simplify cfg pass after lowereh, so it can clean up after eh lowering as well.<commit_after>//===-- PowerPCTargetMachine.cpp - Define TargetMachine for PowerPC -------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Top-level implementation for the PowerPC target.
//
//===----------------------------------------------------------------------===//

#include "PowerPC.h"
#include "PowerPCTargetMachine.h"
#include "PowerPCFrameInfo.h"
#include "PPC32TargetMachine.h"
#include "PPC32JITInfo.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/CommandLine.h"
#include <iostream>
using namespace llvm;

namespace {
  const char *PPC32ID = "PowerPC/32bit";

  static cl::opt<bool> DisablePPCDAGDAG("disable-ppc-dag-isel", cl::Hidden,
                             cl::desc("Disable DAG-to-DAG isel for PPC"));

  // Register the targets
  RegisterTarget<PPC32TargetMachine>
  X("ppc32", "  PowerPC 32-bit");
}

PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
                                           IntrinsicLowering *IL,
                                           const Module &M,
                                           const std::string &FS,
                                           const TargetData &TD,
                                           const PowerPCFrameInfo &TFI)
: TargetMachine(name, IL, TD), FrameInfo(TFI), Subtarget(M, FS) {
  if (TargetDefault == PPCTarget) {
    if (Subtarget.isAIX()) PPCTarget = TargetAIX;
    if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
  }
}

unsigned PPC32TargetMachine::getJITMatchQuality() {
#if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
  return 10;
#else
  return 0;
#endif
}

/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
                                               std::ostream &Out,
                                                CodeGenFileType FileType) {
  if (FileType != TargetMachine::AssemblyFile) return true;

  // Run loop strength reduction before anything else.
  PM.add(createLoopStrengthReducePass());

  // FIXME: Implement efficient support for garbage collection intrinsics.
  PM.add(createLowerGCPass());

  // FIXME: Implement the invoke/unwind instructions!
  PM.add(createLowerInvokePass());

  // Clean up after other passes, e.g. merging critical edges.
  PM.add(createCFGSimplificationPass());

  // FIXME: Implement the switch instruction in the instruction selector!
  PM.add(createLowerSwitchPass());

  // Make sure that no unreachable blocks are instruction selected.
  PM.add(createUnreachableBlockEliminationPass());

  // Install an instruction selector.
  if (!DisablePPCDAGDAG)
    PM.add(createPPC32ISelDag(*this));
  else
    PM.add(createPPC32ISelPattern(*this));

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));

  PM.add(createRegisterAllocator());

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));

  PM.add(createPrologEpilogCodeInserter());

  // Must run branch selection immediately preceding the asm printer
  PM.add(createPPCBranchSelectionPass());

  // Decide which asm printer to use.  If the user has not specified one on
  // the command line, choose whichever one matches the default (current host).
  switch (PPCTarget) {
  case TargetAIX:
    PM.add(createAIXAsmPrinter(Out, *this));
    break;
  case TargetDefault:
  case TargetDarwin:
    PM.add(createDarwinAsmPrinter(Out, *this));
    break;
  }

  PM.add(createMachineCodeDeleter());
  return false;
}

void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
  // The JIT does not support or need PIC.
  PICEnabled = false;

  // Run loop strength reduction before anything else.
  PM.add(createLoopStrengthReducePass());

  // FIXME: Implement efficient support for garbage collection intrinsics.
  PM.add(createLowerGCPass());

  // FIXME: Implement the invoke/unwind instructions!
  PM.add(createLowerInvokePass());

  // Clean up after other passes, e.g. merging critical edges.
  PM.add(createCFGSimplificationPass());

  // FIXME: Implement the switch instruction in the instruction selector!
  PM.add(createLowerSwitchPass());

  // Make sure that no unreachable blocks are instruction selected.
  PM.add(createUnreachableBlockEliminationPass());

  // Install an instruction selector.
  PM.add(createPPC32ISelPattern(TM));

  PM.add(createRegisterAllocator());
  PM.add(createPrologEpilogCodeInserter());

  // Must run branch selection immediately preceding the asm printer
  PM.add(createPPCBranchSelectionPass());

  if (PrintMachineCode)
    PM.add(createMachineFunctionPrinterPass(&std::cerr));
}

/// PowerPCTargetMachine ctor - Create an ILP32 architecture model
///
PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL,
                                       const std::string &FS)
  : PowerPCTargetMachine(PPC32ID, IL, M, FS,
                         TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1),
                         PowerPCFrameInfo(*this, false)), JITInfo(*this) {}

unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
  // We strongly match "powerpc-*".
  std::string TT = M.getTargetTriple();
  if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
    return 20;

  if (M.getEndianness()  == Module::BigEndian &&
      M.getPointerSize() == Module::Pointer32)
    return 10;                                   // Weak match
  else if (M.getEndianness() != Module::AnyEndianness ||
           M.getPointerSize() != Module::AnyPointerSize)
    return 0;                                    // Match for some other target

  return getJITMatchQuality()/2;
}
<|endoftext|>


<commit_before>//===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//

#include "XCoreTargetAsmInfo.h"
#include "XCoreTargetMachine.h"
#include "XCore.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Target/TargetMachineRegistry.h"
using namespace llvm;

namespace {
  // Register the target.
  RegisterTarget<XCoreTargetMachine> X("xcore", "  XCore");
}

const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
  return new XCoreTargetAsmInfo(*this);
}

/// XCoreTargetMachine ctor - Create an ILP32 architecture model
///
XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
  : Subtarget(*this, M, FS),
    DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
               "i16:16:32-i32:32:32-i64:32:32"),
    InstrInfo(),
    FrameInfo(*this),
    TLInfo(*this) {
}

unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
  std::string TT = M.getTargetTriple();
  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
    return 20;

  // Otherwise we don't match.
  return 0;
}

bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
  PM.add(createXCoreISelDag(*this));
  return false;
}

bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
                                            raw_ostream &Out) {
  // Output assembly language.
  PM.add(createXCoreCodePrinterPass(Out, *this));
  return false;
}
<commit_msg>[XCore] Remove whitespace in the description used when registering XCoreTargetMachine.<commit_after>//===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//

#include "XCoreTargetAsmInfo.h"
#include "XCoreTargetMachine.h"
#include "XCore.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Target/TargetMachineRegistry.h"
using namespace llvm;

namespace {
  // Register the target.
  RegisterTarget<XCoreTargetMachine> X("xcore", "XCore");
}

const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
  return new XCoreTargetAsmInfo(*this);
}

/// XCoreTargetMachine ctor - Create an ILP32 architecture model
///
XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
  : Subtarget(*this, M, FS),
    DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
               "i16:16:32-i32:32:32-i64:32:32"),
    InstrInfo(),
    FrameInfo(*this),
    TLInfo(*this) {
}

unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
  std::string TT = M.getTargetTriple();
  if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
    return 20;

  // Otherwise we don't match.
  return 0;
}

bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM, bool Fast) {
  PM.add(createXCoreISelDag(*this));
  return false;
}

bool XCoreTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast,
                                            raw_ostream &Out) {
  // Output assembly language.
  PM.add(createXCoreCodePrinterPass(Out, *this));
  return false;
}
<|endoftext|>


<commit_before>// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "application_runner.h"

#include <zircon/types.h>

#include <sstream>
#include <utility>

#include "flutter/lib/ui/text/font_collection.h"
#include "fuchsia_font_manager.h"
#include "lib/icu_data/cpp/icu_data.h"
#include "third_party/skia/include/core/SkGraphics.h"

namespace flutter {

static void SetProcessName(const std::string& process_name) {
  zx::process::self().set_property(ZX_PROP_NAME, process_name.c_str(),
                                   process_name.size());
}

static void SetThreadName(const std::string& thread_name) {
  zx::thread::self().set_property(ZX_PROP_NAME, thread_name.c_str(),
                                  thread_name.size());
}

static void SetProcessName(const std::string& label, size_t app_count) {
  // Format: "flutter.<label_truncated_to_fit>+<app_count>"
  //         "flutter" in case of error.

  const std::string prefix = "flutter.";
  const std::string suffix =
      app_count == 0 ? "" : "+" + std::to_string(app_count);

  if ((prefix.size() + suffix.size()) > ZX_MAX_NAME_LEN) {
    SetProcessName("flutter");
    return;
  }

  auto truncated_label =
      label.substr(0, ZX_MAX_NAME_LEN - 1 - (prefix.size() + suffix.size()));

  SetProcessName(prefix + truncated_label + suffix);
}

ApplicationRunner::ApplicationRunner(fxl::Closure on_termination_callback)
    : on_termination_callback_(std::move(on_termination_callback)),
      host_context_(component::ApplicationContext::CreateFromStartupInfo()) {
  SkGraphics::Init();

  SetupICU();

  SetupGlobalFonts();

  SetProcessName("application_runner", 0);

  SetThreadName("io.flutter.application_runner");

  host_context_->outgoing_services()->AddService<component::ApplicationRunner>(
      std::bind(&ApplicationRunner::RegisterApplication, this,
                std::placeholders::_1));

  active_applications_bindings_.set_empty_set_handler(
      [this]() { FireTerminationCallbackIfNecessary(); });
}

ApplicationRunner::~ApplicationRunner() {
  host_context_->outgoing_services()
      ->RemoveService<component::ApplicationRunner>();
}

void ApplicationRunner::RegisterApplication(
    fidl::InterfaceRequest<component::ApplicationRunner> request) {
  active_applications_bindings_.AddBinding(this, std::move(request));
}

void ApplicationRunner::StartApplication(
    component::ApplicationPackage package,
    component::ApplicationStartupInfo startup_info,
    fidl::InterfaceRequest<component::ApplicationController> controller) {
  auto thread_application_pair =
      Application::Create(*this,                    // delegate
                          std::move(package),       // application pacakge
                          std::move(startup_info),  // startup info
                          std::move(controller)     // controller request
      );

  // Update the process label so that "ps" will will list the last appication
  // started by the runner plus the count of applications hosted by this runner.
  SetProcessName(thread_application_pair.second->GetDebugLabel(),
                 active_applications_.size());

  active_applications_[thread_application_pair.second.get()] =
      std::move(thread_application_pair);
}

void ApplicationRunner::OnApplicationTerminate(const Application* application) {
  active_applications_.erase(application);
  FireTerminationCallbackIfNecessary();
}

void ApplicationRunner::SetupICU() {
  if (!icu_data::Initialize(host_context_.get())) {
    FXL_LOG(ERROR) << "Could not initialize ICU data.";
  }
}

void ApplicationRunner::SetupGlobalFonts() {
  // Fuchsia does not have per application (shell) fonts. Instead, all fonts
  // must be obtained from the font provider.
  auto process_font_collection =
      blink::FontCollection::ForProcess().GetFontCollection();

  // Connect to the system font provider.
  fonts::FontProviderSyncPtr sync_font_provider;
  host_context_->ConnectToEnvironmentService(sync_font_provider.NewRequest());

  // Set the default font manager.
  process_font_collection->SetDefaultFontManager(
      sk_make_sp<txt::FuchsiaFontManager>(std::move(sync_font_provider)));
}

void ApplicationRunner::FireTerminationCallbackIfNecessary() {
  // We have no reason to exist if:
  // 1: No previously launched applications are running.
  // 2: No bindings exist that may require launching more applications.
  if (on_termination_callback_ && active_applications_.size() == 0 &&
      active_applications_bindings_.size() == 0) {
    on_termination_callback_();
  }
}

}  // namespace flutter
<commit_msg>Make thread names more descriptive. (#5196)<commit_after>// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "application_runner.h"

#include <zircon/types.h>

#include <sstream>
#include <utility>

#include "flutter/lib/ui/text/font_collection.h"
#include "fuchsia_font_manager.h"
#include "lib/icu_data/cpp/icu_data.h"
#include "third_party/flutter/runtime/dart_vm.h"
#include "third_party/skia/include/core/SkGraphics.h"

namespace flutter {

static void SetProcessName() {
  std::stringstream stream;
  stream << "io.flutter.runner.";
  if (blink::DartVM::IsRunningPrecompiledCode()) {
    stream << "aot";
  } else {
    stream << "jit";
  }
  const auto name = stream.str();
  zx::process::self().set_property(ZX_PROP_NAME, name.c_str(), name.size());
}

static void SetThreadName(const std::string& thread_name) {
  zx::thread::self().set_property(ZX_PROP_NAME, thread_name.c_str(),
                                  thread_name.size());
}

ApplicationRunner::ApplicationRunner(fxl::Closure on_termination_callback)
    : on_termination_callback_(std::move(on_termination_callback)),
      host_context_(component::ApplicationContext::CreateFromStartupInfo()) {
  SkGraphics::Init();

  SetupICU();

  SetupGlobalFonts();

  SetProcessName();

  SetThreadName("io.flutter.runner.main");

  host_context_->outgoing_services()->AddService<component::ApplicationRunner>(
      std::bind(&ApplicationRunner::RegisterApplication, this,
                std::placeholders::_1));

  active_applications_bindings_.set_empty_set_handler(
      [this]() { FireTerminationCallbackIfNecessary(); });
}

ApplicationRunner::~ApplicationRunner() {
  host_context_->outgoing_services()
      ->RemoveService<component::ApplicationRunner>();
}

void ApplicationRunner::RegisterApplication(
    fidl::InterfaceRequest<component::ApplicationRunner> request) {
  active_applications_bindings_.AddBinding(this, std::move(request));
}

void ApplicationRunner::StartApplication(
    component::ApplicationPackage package,
    component::ApplicationStartupInfo startup_info,
    fidl::InterfaceRequest<component::ApplicationController> controller) {
  auto thread_application_pair =
      Application::Create(*this,                    // delegate
                          std::move(package),       // application pacakge
                          std::move(startup_info),  // startup info
                          std::move(controller)     // controller request
      );

  active_applications_[thread_application_pair.second.get()] =
      std::move(thread_application_pair);
}

void ApplicationRunner::OnApplicationTerminate(const Application* application) {
  active_applications_.erase(application);
  FireTerminationCallbackIfNecessary();
}

void ApplicationRunner::SetupICU() {
  if (!icu_data::Initialize(host_context_.get())) {
    FXL_LOG(ERROR) << "Could not initialize ICU data.";
  }
}

void ApplicationRunner::SetupGlobalFonts() {
  // Fuchsia does not have per application (shell) fonts. Instead, all fonts
  // must be obtained from the font provider.
  auto process_font_collection =
      blink::FontCollection::ForProcess().GetFontCollection();

  // Connect to the system font provider.
  fonts::FontProviderSyncPtr sync_font_provider;
  host_context_->ConnectToEnvironmentService(sync_font_provider.NewRequest());

  // Set the default font manager.
  process_font_collection->SetDefaultFontManager(
      sk_make_sp<txt::FuchsiaFontManager>(std::move(sync_font_provider)));
}

void ApplicationRunner::FireTerminationCallbackIfNecessary() {
  // We have no reason to exist if:
  // 1: No previously launched applications are running.
  // 2: No bindings exist that may require launching more applications.
  if (on_termination_callback_ && active_applications_.size() == 0 &&
      active_applications_bindings_.size() == 0) {
    on_termination_callback_();
  }
}

}  // namespace flutter
<|endoftext|>


<commit_before>#line 2 "togo/core/utility/tags.hpp"
/**
@copyright MIT license; see @ref index or the accompanying LICENSE file.

@file
@brief Variation/placeholder tags.
@ingroup lib_core_utility
*/

#pragma once

#include <togo/core/config.hpp>

namespace togo {

/**
	@addtogroup lib_core_utility
	@{
*/

/** @name Variation/placeholder tags */ /// @{

/// Null value tag.
enum class null_tag {};

/// Null reference tag.
enum class null_ref_tag {};

/// NUL-terminated string tag.
enum class cstr_tag {};

/// Boolean value tag.
enum class bool_tag {};

/// @}

/** @} */ // end of doc-group lib_core_utility

} // namespace togo
<commit_msg>lib/core/utility/tags: added no_init_tag.<commit_after>#line 2 "togo/core/utility/tags.hpp"
/**
@copyright MIT license; see @ref index or the accompanying LICENSE file.

@file
@brief Variation/placeholder tags.
@ingroup lib_core_utility
*/

#pragma once

#include <togo/core/config.hpp>

namespace togo {

/**
	@addtogroup lib_core_utility
	@{
*/

/** @name Variation/placeholder tags */ /// @{

/// No-initialize constructor tag.
enum class no_init_tag {};

/// Null value tag.
enum class null_tag {};

/// Null reference tag.
enum class null_ref_tag {};

/// NUL-terminated string tag.
enum class cstr_tag {};

/// Boolean value tag.
enum class bool_tag {};

/// @}

/** @} */ // end of doc-group lib_core_utility

} // namespace togo
<|endoftext|>


<commit_before>#pragma once
#include <cstring>
#include <string>
#include <xxhash.h>
#include "darkfeed/types/symbol.hpp"
#include "crc32c.h"

namespace darkfeed
{

/// @brief Computes a hash of a symbol using the XXHash32 algorithm with offset
/// @param s the symbol
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_sym_32(const Symbol &s)
{
    //get hash of root symbol
    std::uint32_t base_hash = XXH32(s.root, std::strlen(s.root), 0);
    //stride by type and series
    base_hash += (std::uint32_t) IssueType::MAX * s.series + (std::uint32_t) s.issue_type;
    return base_hash;
}

/// @brief Struct used to check for equality between symbols in a dense hash table
struct eqsym {
    bool operator()(const Symbol &a, const Symbol &b) const
    {
        return a == b;
    }
};

/// @brief Struct used to check for equality between exchanges
struct eqexg {
    bool operator()(const Exchange &a, const Exchange &b) const
    {
        return a.mic == b.mic;
    }
};

/// @brief Computes the hash of a std::string using the XXHash32 algorithm
/// @param s the string
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_str_32(const std::string &s)
{
    const char *str = s.c_str();
    return XXH32(str, s.length(), 0);
}

/// @brief Computes the ahsh of a C-string using the XXHash32 algorithm
/// @param s the string
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_c_str_32(const char *s)
{ return XXH32(s, std::strlen(s), 0); }

/// @brief Struct used to check for equality between std::string objects in a dense hash table
struct eqstr {
    bool operator()(const std::string &a, const std::string &b) const
    {
        return b == a;
    }
};

/// @brief Struct used to check for equality between C-strings in a dense hash table
struct eq_c_str {
    bool operator()(const char *a, const char *b) const
    { return !std::strcmp(a, b); }
};

/// @brief Struct used to hash symbols for a dense hash table
struct XXSymHasher32 {
    inline std::uint32_t operator()(const Symbol &s) const
    { return xxhash_sym_32(s); }
};

/// @brief Struct used to hash exchanges for reporting/listing exchange keyed hash tables
struct XXExchangeHasher32 {
    inline std::uint32_t operator()(const Exchange &e) const
    {
        return static_cast<std::uint32_t>(e.mic);
    }
};

/// @brief Struct used to hash std::string objects for a dense hash table
struct XXStrHasher32 {
    inline std::uint32_t operator()(const std::string &s) const
    { return xxhash_str_32(s); }
};

/// @brief Struct used to hash C-strings for a dense hash table
struct XXCStrHasher32 {
    inline std::uint32_t operator()(const char *s) const
    { return xxhash_c_str_32(s); }
};

/// @brief Computes the CRC32C checksum using slicing-by-8 method or SSE 4.2 CRC32C instruction if HAS_SSE_4_2 defined at compile time
/// @param crc Carryover checksum
/// @param s The buffer to hash
/// @param len The length of the buffer in bytes
/// @return The checksum as an unsigned 32 bit integer
std::uint32_t crc32c(std::uint32_t crc, const void *buf, std::size_t len);

/// @brief Struct used to hash strings using CRC32C
struct CRC32CStrHasher {
    inline std::uint32_t operator()(const std::string &s)
    {
        return CRC32C_FINISH(crc32c(CRC32C_INIT, s.c_str(), s.size()));
    }
};

/// @brief Struct used to hash C-strings using CRC32C
struct CRC32CCStrHasher {
    inline std::uint32_t operator()(const char *s)
    {
        std::size_t len = std::strlen(s);
        return CRC32C_FINISH(crc32c(CRC32C_INIT, s, len));
    }
};
}

<commit_msg>[cpp] Add test for hardware accelerated (SSE4.3) CRC32C symbol hasher<commit_after>#pragma once
#include <cstring>
#include <string>
#include <xxhash.h>
#include "darkfeed/types/symbol.hpp"
#include "crc32c.h"

namespace darkfeed
{

/// @brief Computes a hash of a symbol using the XXHash32 algorithm with offset
/// @param s the symbol
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_sym_32(const Symbol &s)
{
    //get hash of root symbol
    std::uint32_t base_hash = XXH32(s.root, std::strlen(s.root), 0);
    //stride by type and series
    base_hash += (std::uint32_t) IssueType::MAX * s.series + (std::uint32_t) s.issue_type;
    return base_hash;
}

/// @brief Struct used to check for equality between symbols in a dense hash table
struct eqsym {
    bool operator()(const Symbol &a, const Symbol &b) const
    {
        return a == b;
    }
};

/// @brief Struct used to check for equality between exchanges
struct eqexg {
    bool operator()(const Exchange &a, const Exchange &b) const
    {
        return a.mic == b.mic;
    }
};

/// @brief Computes the hash of a std::string using the XXHash32 algorithm
/// @param s the string
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_str_32(const std::string &s)
{
    const char *str = s.c_str();
    return XXH32(str, s.length(), 0);
}

/// @brief Computes the ahsh of a C-string using the XXHash32 algorithm
/// @param s the string
/// @return the hash as a std::uint32_t
inline std::uint32_t xxhash_c_str_32(const char *s)
{ return XXH32(s, std::strlen(s), 0); }

/// @brief Struct used to check for equality between std::string objects in a dense hash table
struct eqstr {
    bool operator()(const std::string &a, const std::string &b) const
    {
        return b == a;
    }
};

/// @brief Struct used to check for equality between C-strings in a dense hash table
struct eq_c_str {
    bool operator()(const char *a, const char *b) const
    { return !std::strcmp(a, b); }
};

/// @brief Struct used to hash symbols for a dense hash table
struct XXSymHasher32 {
    inline std::uint32_t operator()(const Symbol &s) const
    { return xxhash_sym_32(s); }
};

/// @brief Struct used to hash exchanges for reporting/listing exchange keyed hash tables
struct XXExchangeHasher32 {
    inline std::uint32_t operator()(const Exchange &e) const
    {
        return static_cast<std::uint32_t>(e.mic);
    }
};

/// @brief Struct used to hash std::string objects for a dense hash table
struct XXStrHasher32 {
    inline std::uint32_t operator()(const std::string &s) const
    { return xxhash_str_32(s); }
};

/// @brief Struct used to hash C-strings for a dense hash table
struct XXCStrHasher32 {
    inline std::uint32_t operator()(const char *s) const
    { return xxhash_c_str_32(s); }
};

/// @brief Computes the CRC32C checksum using slicing-by-8 method or SSE 4.2 CRC32C instruction if HAS_SSE_4_2 defined at compile time
/// @param crc Carryover checksum
/// @param s The buffer to hash
/// @param len The length of the buffer in bytes
/// @return The checksum as an unsigned 32 bit integer
std::uint32_t crc32c(std::uint32_t crc, const void *buf, std::size_t len);

/// @brief Struct used to hash strings using CRC32C
struct CRC32CStrHasher {
    inline std::uint32_t operator()(const std::string &s)
    {
        return CRC32C_FINISH(crc32c(CRC32C_INIT, s.c_str(), s.size()));
    }
};

/// @brief Struct used to hash C-strings using CRC32C
struct CRC32CCStrHasher {
    inline std::uint32_t operator()(const char *s)
    {
        std::size_t len = std::strlen(s);
        return CRC32C_FINISH(crc32c(CRC32C_INIT, s, len));
    }
};

/// @brief Struct used to hash Symbols using CRC32C
struct CRC32CSymHasher {
    inline std::uint32_t operator()(const Symbol &s)
    {
        std::size_t len = std::strlen(s.root);
        auto post_root = crc32c(CRC32C_INIT, s.root, len);
        char modifiers[3] = {s.series, (char) s.listing_exg.mic, (char) s.issue_type};
        return CRC32C_FINISH(crc32c(post_root, modifiers, 3));
    }
};

/// @brief Struct used as a std::hash wrapper for identity hash
struct IdentityHasher {
    inline std::uint32_t operator()(const std::uint64_t x)
    {
        return (std::uint32_t) x;
    }
};
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: factory.hxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: rt $ $Date: 2006-12-01 17:17:59 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _CPPUHELPER_FACTORY_HXX_
#define _CPPUHELPER_FACTORY_HXX_

#ifndef _RTL_STRING_HXX_
#include <rtl/ustring.hxx>
#endif

#ifndef _UNO_DISPATCHER_H_
#include <uno/dispatcher.h>
#endif

#ifndef _RTL_UNLOAD_H_
#include <rtl/unload.h>
#endif

#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>

//##################################################################################################

#define COMPONENT_GETENV            "component_getImplementationEnvironment"
#define COMPONENT_GETDESCRIPTION    "component_getDescription"
#define COMPONENT_WRITEINFO         "component_writeInfo"
#define COMPONENT_GETFACTORY        "component_getFactory"

typedef struct _uno_Environment uno_Environment;

/** Function pointer declaration.
    Function determines the environment of the component implementation, i.e. which compiler
    compiled it. If the environment is NOT session specific (needs no additional context),
    then this function should return the environment type name and leave ppEnv (to 0).

    @paramppEnvTypeName environment type name; string must be constant
    @param ppEnv function returns its environment if the environment is session specific,
                 i.e. has special context
*/
typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
    const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );

/** Function pointer declaration.
    Function retrieves a component description.

    @return an XML formatted string containing a short component description
*/
typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);

/** Function pointer declaration.
    Function writes component registry info, at least writing the supported service names.

    @param pServiceManager
    a service manager (the type is an XMultiServiceFactory that can be used
    by the environment returned by component_getImplementationEnvironment)
    @param pRegistryKey a registry key
    (the type is XRegistryKey that can be used by the environment
    returned by component_getImplementationEnvironment)
    @return true if everything went fine
*/
typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
    void * pServiceManager, void * pRegistryKey );

/** Function pointer declaration.
    Retrieves a factory to create component instances.

   @param pImplName
   desired implementation name
   @param pServiceManager
   a service manager (the type is XMultiServiceFactory that can be used by the environment
   returned by component_getImplementationEnvironment)
   @param pRegistryKey
   a registry key (the type is XRegistryKey that can be used by the environment
   returned by component_getImplementationEnvironment)
   @return acquired component factory
   (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
   environment returned by component_getImplementationEnvironment)
*/
typedef void * (SAL_CALL * component_getFactoryFunc)(
    const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );

//##################################################################################################

namespace cppu
{

/** Function pointer declaration.
    Function creates component instance passing the component context to be used.

    @param xContext component context to be used
    @return component instance
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
    SAL_CALL * ComponentFactoryFunc)(
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext )
    SAL_THROW( (::com::sun::star::uno::Exception) );

/** Creates a single component factory supporting the XSingleComponentFactory interface.

    @param fptr function pointer for instanciating the object
    @param rImplementationName implementation name of service
    @param rServiceNames supported services
    @param pModCount for future extension (library unloading concept).
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createSingleComponentFactory(
    ComponentFactoryFunc fptr,
    ::rtl::OUString const & rImplementationName,
    ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
    rtl_ModuleCount * pModCount = 0 )
    SAL_THROW( () );

/** Deprecated.  The type of the instanciate function used as argument of the create*Fcatory functions.

    @see createSingleFactory
    @see createOneInstanceFactory
    @deprecated
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager );

/** Deprecated.  Creates a single service factory.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createOneInstanceFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createSingleFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a factory wrapping another one.
    This means the methods of the interfaces XServiceProvider, XServiceInfo and
    XSingleServiceFactory are forwarded.
    @attention
    The XComponent interface is not supported!

    @param rServiceManager      the service manager used by the implementation.
    @param xSingleServiceFactory    the wrapped service factory.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createFactoryProxy(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createOneInstanceFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once
    based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleRegistryFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

}

#endif
<commit_msg>INTEGRATION: CWS bunoexttm (1.10.4); FILE MERGED 2007/01/30 14:16:39 kr 1.10.4.1: joined UTF2 -  COMPONENT_GETENVEXT<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: factory.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: kz $ $Date: 2007-05-09 13:24:47 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _CPPUHELPER_FACTORY_HXX_
#define _CPPUHELPER_FACTORY_HXX_

#ifndef _RTL_STRING_HXX_
#include <rtl/ustring.hxx>
#endif

#ifndef _UNO_DISPATCHER_H_
#include <uno/dispatcher.h>
#endif

#ifndef _RTL_UNLOAD_H_
#include <rtl/unload.h>
#endif

#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>

//##################################################################################################

#define COMPONENT_GETENV            "component_getImplementationEnvironment"
#define COMPONENT_GETENVEXT         "component_getImplementationEnvironmentExt"
#define COMPONENT_GETDESCRIPTION    "component_getDescription"
#define COMPONENT_WRITEINFO         "component_writeInfo"
#define COMPONENT_GETFACTORY        "component_getFactory"

typedef struct _uno_Environment uno_Environment;

/** Function pointer declaration.
    Function determines the environment of the component implementation, i.e. which compiler
    compiled it. If the environment is NOT session specific (needs no additional context),
    then this function should return the environment type name and leave ppEnv (to 0).

    @paramppEnvTypeName environment type name; string must be constant
    @param ppEnv function returns its environment if the environment is session specific,
                 i.e. has special context
*/
typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)(
    const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv );

/** Function pointer declaration.
    Function determines the environment of the component implementation, i.e. the compiler.
    If the environment is NOT session specific (needs no additional context),
    then this function should return the environment type name and leave ppEnv (to 0).

    @param ppEnvTypeName environment type name; string must be a constant
    @param ppEnv         function returns an environment if the environment is session specific,
                         i.e. has special context
    @param pImplName
*/
typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)(
    sal_Char        const ** ppEnvTypeName,
    uno_Environment       ** ppEnv,
    sal_Char        const  * pImplName,
    uno_Environment        * pTargetEnv
);

/** Function pointer declaration.
    Function retrieves a component description.

    @return an XML formatted string containing a short component description
*/
typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void);

/** Function pointer declaration.
    Function writes component registry info, at least writing the supported service names.

    @param pServiceManager
    a service manager (the type is an XMultiServiceFactory that can be used
    by the environment returned by component_getImplementationEnvironment)
    @param pRegistryKey a registry key
    (the type is XRegistryKey that can be used by the environment
    returned by component_getImplementationEnvironment)
    @return true if everything went fine
*/
typedef sal_Bool (SAL_CALL * component_writeInfoFunc)(
    void * pServiceManager, void * pRegistryKey );

/** Function pointer declaration.
    Retrieves a factory to create component instances.

   @param pImplName
   desired implementation name
   @param pServiceManager
   a service manager (the type is XMultiServiceFactory that can be used by the environment
   returned by component_getImplementationEnvironment)
   @param pRegistryKey
   a registry key (the type is XRegistryKey that can be used by the environment
   returned by component_getImplementationEnvironment)
   @return acquired component factory
   (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the
   environment returned by component_getImplementationEnvironment)
*/
typedef void * (SAL_CALL * component_getFactoryFunc)(
    const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );

//##################################################################################################

namespace cppu
{

/** Function pointer declaration.
    Function creates component instance passing the component context to be used.

    @param xContext component context to be used
    @return component instance
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
    SAL_CALL * ComponentFactoryFunc)(
        ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext )
    SAL_THROW( (::com::sun::star::uno::Exception) );

/** Creates a single component factory supporting the XSingleComponentFactory interface.

    @param fptr function pointer for instanciating the object
    @param rImplementationName implementation name of service
    @param rServiceNames supported services
    @param pModCount for future extension (library unloading concept).
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createSingleComponentFactory(
    ComponentFactoryFunc fptr,
    ::rtl::OUString const & rImplementationName,
    ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames,
    rtl_ModuleCount * pModCount = 0 )
    SAL_THROW( () );

/** Deprecated.  The type of the instanciate function used as argument of the create*Fcatory functions.

    @see createSingleFactory
    @see createOneInstanceFactory
    @deprecated
*/
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager );

/** Deprecated.  Creates a single service factory.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createOneInstanceFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createSingleFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a factory wrapping another one.
    This means the methods of the interfaces XServiceProvider, XServiceInfo and
    XSingleServiceFactory are forwarded.
    @attention
    The XComponent interface is not supported!

    @param rServiceManager      the service manager used by the implementation.
    @param xSingleServiceFactory    the wrapped service factory.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createFactoryProxy(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param ComponentInstantiation the function pointer to create an object.
    @param rServiceNames            the service supported by the implementation.
    @param pModCount             for future extension (library unloading concept).
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL
createOneInstanceFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    ComponentInstantiation pCreateFunction,
    const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames,
    rtl_ModuleCount * pModCount = 0  )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rImplementationName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

/** Deprecated.  Creates a single service factory which holds the instance created only once
    based on a registry.

    @param rServiceManager      the service manager used by the implementation.
    @param rImplementationName  the implementation name. An empty string is possible.
    @param rImplementationKey   the registry key of the implementation section.
    @return a factory that support the interfaces XServiceProvider, XServiceInfo
    XSingleServiceFactory and XComponent.

    @see createSingleRegistryFactory
    @deprecated
*/
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory(
    const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager,
    const ::rtl::OUString & rComponentName,
    const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey )
    SAL_THROW( () );

}

#endif
<|endoftext|>


<commit_before><commit_msg>Properly identify malformed (too short) chunks in mpeg4 files.<commit_after><|endoftext|>


<commit_before><commit_msg>slots slide on node borders except for ends<commit_after><|endoftext|>


<commit_before><commit_msg>Fixed clang unused error<commit_after><|endoftext|>


<commit_before><commit_msg>Run integration filter from state estimator node<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: XTempFile.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 09:50:11 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _XTEMPFILE_HXX
#define _XTEMPFILE_HXX

#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSTREAM_HPP_
#include <com/sun/star/io/XStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
#include <com/sun/star/io/XTruncate.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
#include <com/sun/star/lang/XTypeProvider.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _CPPUHELPER_WEAK_HXX_
#include <cppuhelper/weak.hxx>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

class SvStream;
namespace utl { class TempFile; }

class XTempFile : public com::sun::star::lang::XTypeProvider,
                  public com::sun::star::io::XInputStream,
                  public com::sun::star::io::XOutputStream,
                  public com::sun::star::io::XSeekable,
                  public com::sun::star::io::XStream,
                  public com::sun::star::io::XTruncate,
                  public com::sun::star::beans::XPropertySetInfo,
                  public com::sun::star::beans::XPropertySet,
                  public ::com::sun::star::lang::XServiceInfo,
                  public cppu::OWeakObject
{
protected:
    ::utl::TempFile*    mpTempFile;
    ::osl::Mutex        maMutex;
    SvStream*           mpStream;
    sal_Bool            mbRemoveFile;
    sal_Bool            mbInClosed;
    sal_Bool            mbOutClosed;

    // intended to hold the current position in disconnected state
    sal_Int64           mnCachedPos;
    sal_Bool            mbHasCachedPos;

    void checkError () const;
    void checkConnected ();

    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > GetProps();

public:
    XTempFile ();
    virtual ~XTempFile ();

    // XInterface
    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
        throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL acquire(  )
        throw ();
    virtual void SAL_CALL release(  )
        throw ();

    // XTypeProvider
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
        throw ( ::com::sun::star::uno::RuntimeException );
    virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId()
        throw ( ::com::sun::star::uno::RuntimeException );

    // XInputStream
    virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL available(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL closeInput(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    // XOutputStream
    virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL flush(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL closeOutput(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    // XSeekable
    virtual void SAL_CALL seek( sal_Int64 location )
        throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int64 SAL_CALL getPosition(  )
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int64 SAL_CALL getLength(  )
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);

    // XStream
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  )
        throw (::com::sun::star::uno::RuntimeException);

    // XTruncate
    virtual void SAL_CALL truncate()
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);

    // XPropertySetInfo
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);

    // XPropertySet
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    static ::rtl::OUString getImplementationName_Static ();
    static ::com::sun::star::uno::Sequence < ::rtl::OUString > getSupportedServiceNames_Static();
    static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory_Static( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName()
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
        throw (::com::sun::star::uno::RuntimeException);

};
#endif
<commit_msg>INTEGRATION: CWS warnings01 (1.8.16); FILE MERGED 2006/01/27 12:39:19 sb 1.8.16.2: #i53898# Made code warning-free. 2005/12/21 11:32:04 fs 1.8.16.1: #i55991# warning-free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: XTempFile.hxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-19 14:09:23 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _XTEMPFILE_HXX
#define _XTEMPFILE_HXX

#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSTREAM_HPP_
#include <com/sun/star/io/XStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
#include <com/sun/star/io/XTruncate.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE8_HXX_
#include <cppuhelper/implbase8.hxx>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

class SvStream;
namespace utl { class TempFile; }

class XTempFile : public ::cppu::WeakImplHelper8<   com::sun::star::io::XInputStream
                                                  , ::com::sun::star::io::XOutputStream
                                                  , ::com::sun::star::io::XSeekable
                                                  , ::com::sun::star::io::XStream
                                                  , ::com::sun::star::io::XTruncate
                                                  , ::com::sun::star::beans::XPropertySetInfo
                                                  , ::com::sun::star::beans::XPropertySet
                                                  , ::com::sun::star::lang::XServiceInfo
                                                  >
{
protected:
    ::utl::TempFile*    mpTempFile;
    ::osl::Mutex        maMutex;
    SvStream*           mpStream;
    sal_Bool            mbRemoveFile;
    sal_Bool            mbInClosed;
    sal_Bool            mbOutClosed;

    // intended to hold the current position in disconnected state
    sal_Int64           mnCachedPos;
    sal_Bool            mbHasCachedPos;

    void checkError () const;
    void checkConnected ();

    ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > GetProps();

public:
    XTempFile ();
    virtual ~XTempFile ();

    // XInputStream
    virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int32 SAL_CALL available(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL closeInput(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    // XOutputStream
    virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL flush(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL closeOutput(  )
        throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    // XSeekable
    virtual void SAL_CALL seek( sal_Int64 location )
        throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int64 SAL_CALL getPosition(  )
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
    virtual sal_Int64 SAL_CALL getLength(  )
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);

    // XStream
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  )
        throw (::com::sun::star::uno::RuntimeException);

    // XTruncate
    virtual void SAL_CALL truncate()
        throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);

    // XPropertySetInfo
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(  ) throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);

    // XPropertySet
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
        throw (::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener )
        throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    static ::rtl::OUString getImplementationName_Static ();
    static ::com::sun::star::uno::Sequence < ::rtl::OUString > getSupportedServiceNames_Static();
    static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleServiceFactory > createServiceFactory_Static( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory );

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName()
        throw (::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
        throw (::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
        throw (::com::sun::star::uno::RuntimeException);

};
#endif
<|endoftext|>


<commit_before><commit_msg>Minor fixes to tooltips.<commit_after><|endoftext|>


<commit_before>#include <string.h>
#include <string>

#include "SentenceExtractor.h"

using namespace std;

SentenceExtractor::SentenceExtractor(ExtractorOptions opts)
{
  this->opts = opts;
}

SentenceExtractor::~SentenceExtractor()
{
}

char SentenceExtractor::last_written_char()
{
  return output[output.size()-1];
}

bool SentenceExtractor::is_last_written_char(const char* chars)
{
  if(output.empty())
    return false;
  const int n = strlen(chars);
  const char last = last_written_char();
  for(int i = 0; i < n; i++) {
    if(last == chars[i])
      return true;
  }
  return false;
}

bool SentenceExtractor::is_ws(char ch)
{
  return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}

char SentenceExtractor::peek() {
  return input[pos+1];
}

char SentenceExtractor::peek(size_t n) {
  size_t i = 0;
  while(input[pos + i] != '\0' && ++i < n);
  return i == n ? input[pos+i] : '\0';
}

void SentenceExtractor::newline(int count)
{
  if(output.size() == 0)
    return;

  for(int i = output.size()-1; i >= 0 && output[i] == '\n'; i--, count--);

  while(count-- > 0) {
    output += '\n';
  }
}

bool SentenceExtractor::out_ends_with(const char* suffix)
{
  return output.find(suffix, output.size()-strlen(suffix)) != string::npos;
}

string SentenceExtractor::extract(const char* input)
{
  this->input = input;
  this->pos = 0;
  this->output.clear();
  // Reserve 2MB for output. Most wikipedia articles will fit without resizing.
  this->output.reserve(2*1024*1024);

  while(input[pos] != '\0') {
    const char ch = input[pos];
    switch(ch) {
    case '\n':
      if(peek() == '\n' && opts.separateParagraphs) {
        newline(2);
        pos++;
      }
      break;

    case '.':
      output += ch;
      if(is_ws(peek()) &&
         !out_ends_with("e.g.") &&
         !out_ends_with("i.e.")) {
        if(peek(3) == '.') { // One letter "sentence": most likely an abbreviation
          output += input[pos+1];
          output += input[pos+2];
          output += input[pos+3];
          pos += 3;
        }
        else {
          if(peek()=='"' || peek()=='\'') {
            output += input[++pos];
          }

          newline(1);
        }
      }
      break;

    case '?':
    case '!':
      output += ch;
      newline(1);
      break;

    case ' ':
    case '\t':
      if(pos == 0 || !is_last_written_char(" \t\r\n"))
        output += ch;
      break;

    default:
      output += ch;
      break;
    }

    pos++;
  }

  // make sure we have to newlines at the end: this is so that we
  // can concatenate outputs from multiple articles and have their
  // paragraphs clearly separated.
  newline(2);

  return this->output;
}
<commit_msg>do not produce reduntant spaces in the sentence extractor<commit_after>#include <string.h>
#include <string>

#include "SentenceExtractor.h"

using namespace std;

SentenceExtractor::SentenceExtractor(ExtractorOptions opts)
{
  this->opts = opts;
}

SentenceExtractor::~SentenceExtractor()
{
}

char SentenceExtractor::last_written_char()
{
  return output[output.size()-1];
}

bool SentenceExtractor::is_last_written_char(const char* chars)
{
  if(output.empty())
    return false;
  const int n = strlen(chars);
  const char last = last_written_char();
  for(int i = 0; i < n; i++) {
    if(last == chars[i])
      return true;
  }
  return false;
}

bool SentenceExtractor::is_ws(char ch)
{
  return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r';
}

char SentenceExtractor::peek() {
  return input[pos+1];
}

char SentenceExtractor::peek(size_t n) {
  size_t i = 0;
  while(input[pos + i] != '\0' && ++i < n);
  return i == n ? input[pos+i] : '\0';
}

void SentenceExtractor::newline(int count)
{
  if(output.size() == 0)
    return;

  for(int i = output.size()-1; i >= 0 && output[i] == '\n'; i--, count--);

  while(count-- > 0) {
    output += '\n';
  }
}

bool SentenceExtractor::out_ends_with(const char* suffix)
{
  return output.find(suffix, output.size()-strlen(suffix)) != string::npos;
}

string SentenceExtractor::extract(const char* input)
{
  this->input = input;
  this->pos = 0;
  this->output.clear();
  // Reserve 2MB for output. Most wikipedia articles will fit without resizing.
  this->output.reserve(2*1024*1024);

  while(input[pos] != '\0') {
    const char ch = input[pos];
    switch(ch) {
    case '\n':
      if(peek() == '\n' && opts.separateParagraphs) {
        newline(2);
        pos++;
      }
      else if(!is_last_written_char(" \t")) {
        output += ' ';
      }
      break;

    case '.':
      output += ch;
      if(is_ws(peek()) &&
         !out_ends_with("e.g.") &&
         !out_ends_with("i.e.")) {
        if(peek(3) == '.') { // One letter "sentence": most likely an abbreviation
          output += input[pos+1];
          output += input[pos+2];
          output += input[pos+3];
          pos += 3;
        }
        else {
          if(peek()=='"' || peek()=='\'') {
            output += input[++pos];
          }

          newline(1);
        }
      }
      break;

    case '?':
    case '!':
      output += ch;
      newline(1);
      break;

    case ' ':
    case '\t':
      if(pos == 0 || !is_last_written_char(" \t\r\n"))
        output += ch;
      break;

    default:
      output += ch;
      break;
    }

    pos++;
  }

  // make sure we have to newlines at the end: this is so that we
  // can concatenate outputs from multiple articles and have their
  // paragraphs clearly separated.
  newline(2);

  return this->output;
}
<|endoftext|>