<commit_before>//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author:  Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
//------------------------------------------------------------------------------

#include "cling/Utils/AST.h"

#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/Lookup.h"

using namespace clang;

namespace cling {
namespace utils {
  Expr* Synthesize::CStyleCastPtrExpr(Sema* S, QualType Ty, uint64_t Ptr) {
    ASTContext& Ctx = S->getASTContext();
    if (!Ty->isPointerType())
      Ty = Ctx.getPointerType(Ty);
    TypeSourceInfo* TSI = Ctx.CreateTypeSourceInfo(Ty);
    const llvm::APInt Addr(8 * sizeof(void *), Ptr);

    Expr* Result = IntegerLiteral::Create(Ctx, Addr, Ctx.UnsignedLongTy,
                                          SourceLocation());
    Result = S->BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(),
                                         Result).take();
    assert(Result && "Cannot create CStyleCastPtrExpr");
    return Result;

  }

  QualType Transform::GetPartiallyDesugaredType(const ASTContext& Ctx,
                                                QualType QT,
                              const llvm::SmallSet<const Type*, 4>& TypesToSkip){
    // If there are no constains - use the standard desugaring.
    if (!TypesToSkip.size())
      return QT.getDesugaredType(Ctx);

    while(isa<TypedefType>(QT.getTypePtr())) {
      if (!TypesToSkip.count(QT.getTypePtr()))
        QT = QT.getSingleStepDesugaredType(Ctx);
      else
        return QT;
    }

    // In case of template specializations iterate over the arguments and
    // desugar them as well.
    if(const TemplateSpecializationType* TST
       = dyn_cast<const TemplateSpecializationType>(QT.getTypePtr())) {

      bool mightHaveChanged = false;
      llvm::SmallVector<TemplateArgument, 4> desArgs;
      for(TemplateSpecializationType::iterator I = TST->begin(), E = TST->end();
          I != E; ++I) {
        QualType SubTy = I->getAsType();

        if (SubTy.isNull())
          continue;

        // Check if the type needs more desugaring and recurse.
        if (isa<TypedefType>(SubTy) || isa<TemplateSpecializationType>(SubTy)) {
          mightHaveChanged = true;
          desArgs.push_back(TemplateArgument(GetPartiallyDesugaredType(Ctx,
                                                                       SubTy,
                                                                  TypesToSkip)));
         else
            desArgs.push_back(*I);
      }

      // If desugaring happened allocate new type in the AST.
      if (mightHaveChanged) {
        QualType Result
          = Ctx.getTemplateSpecializationType(TST->getTemplateName(),
                                              desArgs.data(),
                                              desArgs.size(),
                                              TST->getCanonicalTypeInternal());
        return Result;
      }
    }
    return QT;
  }

  NamespaceDecl* Lookup::Namespace(Sema* S, const char* Name,
                                   DeclContext* Within) {
    DeclarationName DName = &S->Context.Idents.get(Name);
    LookupResult R(*S, DName, SourceLocation(),
                   Sema::LookupNestedNameSpecifierName);
    if (!Within)
      S->LookupName(R, S->TUScope);
    else
      S->LookupQualifiedName(R, Within);

    if (R.empty())
      return 0;

    R.resolveKind();

    return dyn_cast<NamespaceDecl>(R.getFoundDecl());
  }

  NamedDecl* Lookup::Named(Sema* S, const char* Name, DeclContext* Within) {
    DeclarationName DName = &S->Context.Idents.get(Name);

    LookupResult R(*S, DName, SourceLocation(), Sema::LookupOrdinaryName,
                   Sema::ForRedeclaration);
    if (!Within)
      S->LookupName(R, S->TUScope);
    else
      S->LookupQualifiedName(R, Within);

    if (R.empty())
      return 0;

    R.resolveKind();

    return R.getFoundDecl();

  }
} // end namespace utils
} // end namespace cling
<commit_msg>Fix typo<commit_after>//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author:  Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
//------------------------------------------------------------------------------

#include "cling/Utils/AST.h"

#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclarationName.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/Lookup.h"

using namespace clang;

namespace cling {
namespace utils {
  Expr* Synthesize::CStyleCastPtrExpr(Sema* S, QualType Ty, uint64_t Ptr) {
    ASTContext& Ctx = S->getASTContext();
    if (!Ty->isPointerType())
      Ty = Ctx.getPointerType(Ty);
    TypeSourceInfo* TSI = Ctx.CreateTypeSourceInfo(Ty);
    const llvm::APInt Addr(8 * sizeof(void *), Ptr);

    Expr* Result = IntegerLiteral::Create(Ctx, Addr, Ctx.UnsignedLongTy,
                                          SourceLocation());
    Result = S->BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(),
                                         Result).take();
    assert(Result && "Cannot create CStyleCastPtrExpr");
    return Result;

  }

  QualType Transform::GetPartiallyDesugaredType(const ASTContext& Ctx,
                                                QualType QT,
                              const llvm::SmallSet<const Type*, 4>& TypesToSkip){
    // If there are no constains - use the standard desugaring.
    if (!TypesToSkip.size())
      return QT.getDesugaredType(Ctx);

    while(isa<TypedefType>(QT.getTypePtr())) {
      if (!TypesToSkip.count(QT.getTypePtr()))
        QT = QT.getSingleStepDesugaredType(Ctx);
      else
        return QT;
    }

    // In case of template specializations iterate over the arguments and
    // desugar them as well.
    if(const TemplateSpecializationType* TST
       = dyn_cast<const TemplateSpecializationType>(QT.getTypePtr())) {

      bool mightHaveChanged = false;
      llvm::SmallVector<TemplateArgument, 4> desArgs;
      for(TemplateSpecializationType::iterator I = TST->begin(), E = TST->end();
          I != E; ++I) {
        QualType SubTy = I->getAsType();

        if (SubTy.isNull())
          continue;

        // Check if the type needs more desugaring and recurse.
        if (isa<TypedefType>(SubTy) || isa<TemplateSpecializationType>(SubTy)) {
          mightHaveChanged = true;
          desArgs.push_back(TemplateArgument(GetPartiallyDesugaredType(Ctx,
                                                                       SubTy,
                                                                  TypesToSkip)));
         } else
            desArgs.push_back(*I);
      }

      // If desugaring happened allocate new type in the AST.
      if (mightHaveChanged) {
        QualType Result
          = Ctx.getTemplateSpecializationType(TST->getTemplateName(),
                                              desArgs.data(),
                                              desArgs.size(),
                                              TST->getCanonicalTypeInternal());
        return Result;
      }
    }
    return QT;
  }

  NamespaceDecl* Lookup::Namespace(Sema* S, const char* Name,
                                   DeclContext* Within) {
    DeclarationName DName = &S->Context.Idents.get(Name);
    LookupResult R(*S, DName, SourceLocation(),
                   Sema::LookupNestedNameSpecifierName);
    if (!Within)
      S->LookupName(R, S->TUScope);
    else
      S->LookupQualifiedName(R, Within);

    if (R.empty())
      return 0;

    R.resolveKind();

    return dyn_cast<NamespaceDecl>(R.getFoundDecl());
  }

  NamedDecl* Lookup::Named(Sema* S, const char* Name, DeclContext* Within) {
    DeclarationName DName = &S->Context.Idents.get(Name);

    LookupResult R(*S, DName, SourceLocation(), Sema::LookupOrdinaryName,
                   Sema::ForRedeclaration);
    if (!Within)
      S->LookupName(R, S->TUScope);
    else
      S->LookupQualifiedName(R, Within);

    if (R.empty())
      return 0;

    R.resolveKind();

    return R.getFoundDecl();

  }
} // end namespace utils
} // end namespace cling
<|endoftext|>


<commit_before>/**
* @version		GrPPI v0.3
* @copyright		Copyright (C) 2017 Universidad Carlos III de Madrid. All rights reserved.
* @license		GNU/GPL, see LICENSE.txt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You have received a copy of the GNU General Public License in LICENSE.txt
* also available in <http://www.gnu.org/licenses/gpl.html>.
*
* See COPYRIGHT.txt for copyright notices and details.
*/
#include <atomic>
#include <utility>
#include <experimental/optional>

#include <gtest/gtest.h>

#include "farm.h"
#include "pipeline.h"
#include "dyn/dynamic_execution.h"

#include "supported_executions.h"

using namespace std;
using namespace grppi;
template <typename T>
using optional = std::experimental::optional<T>;

template <typename T>
class farm_pipeline_test : public ::testing::Test {
public:
  T execution_;
  dynamic_execution dyn_execution_{execution_};

  // Variables
  std::atomic<int> output;

  // Vectors
  vector<int> v{};
  vector<int> v2{};
  vector<int> v3{};
  vector<int> w{};

  // entry counter
  int idx_in = 0;
  int idx_out = 0;

  // Invocation counter
  std::atomic<int> invocations_in{0};
  std::atomic<int> invocations_op{0};
  std::atomic<int> invocations_op2{0};
  std::atomic<int> invocations_sk{0};

  void setup_empty() {}

  template <typename E>
  void run_empty(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int>{
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x;
          },
          [this](int x) {
            invocations_op2++;
            return x;
          }
        )
      ),
      [](int x) {}
    );
  }

  void check_empty() {
    EXPECT_EQ(1, invocations_in); // Functor in was invoked once
    EXPECT_EQ(0, invocations_op); // Functor op was not invoked
    EXPECT_EQ(0, invocations_op2); // Functor op2 was not invoked
  }

  void setup_empty_sink() {}

  template <typename E>
  void run_empty_sink(const E & e) {
    grppi::pipeline (e,
      [this]() -> optional<int>{
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x;
          },
          [this](int x) {
            invocations_op2++;
            return x;
          }
        )
      ),
      [this](int x) {
        this->invocations_sk++;
      }
    );
  }

  void check_empty_sink() {
    EXPECT_EQ(1, invocations_in);
    EXPECT_EQ(0, invocations_op);
    EXPECT_EQ(0, invocations_op2);
    EXPECT_EQ(0, invocations_sk);
  }

  void setup_empty_ary() {}

  template <typename E>
  void run_empty_ary(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](tuple<int,int,int> x) {
            invocations_op++;
            return x;
          },
          [this](tuple<int,int,int> x) {
            invocations_op2++;
            return x;
          })
      ),
      [&](tuple<int,int,int> x){
        invocations_sk++;
      }
    );
  }

  void check_empty_ary() {
    EXPECT_EQ(1, invocations_in);
    EXPECT_EQ(0, invocations_op);
    EXPECT_EQ(0, invocations_op2);
    EXPECT_EQ(0, invocations_sk);
  }

  void setup_single_sink() {
    v = vector<int>{42};
    w = vector<int>{99};
  }

  template <typename E>
  void run_single_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int> {
        invocations_in++;
        if (idx_in < v.size() ) {
          idx_in++;
          return v[idx_in-1];
        }
        else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x*2;
          },
          [this](int x) {
            invocations_op2++;
            return x*2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        w[idx_out] = x;
        idx_out++;
      }
    );
  }

  void check_single_sink() {
    EXPECT_EQ(2, invocations_in); // Functor in was invoked once
    EXPECT_EQ(1, this->invocations_op); // one invocation of function op
    EXPECT_EQ(1, this->invocations_op2); // one invocation of function op
    EXPECT_EQ(1, this->invocations_sk); // one invocation of function sk
    EXPECT_EQ(168, this->w[0]);
  }

  void setup_single_ary_sink() {
    v = vector<int>{11};
    v2 = vector<int>{22};
    v3 = vector<int>{33};
    w = vector<int>{99};
  }

  template <typename E>
  void run_single_ary_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return make_tuple(v[idx_in-1], v2[idx_in-1], v3[idx_in-1]);
        }
        else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](tuple<int,int,int> x) {
            invocations_op++;
            return get<0>(x) + get<1>(x) + get<2>(x);;
          },
          [this](int x){
            invocations_op2++;
            return x*2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        w[idx_out] = x;
        idx_out++;
      });
  }

  void check_single_ary_sink() {
    EXPECT_EQ(2, invocations_in); // Functor in was invoked twice
    EXPECT_EQ(1, this->invocations_op); // one invocation of function op
    EXPECT_EQ(1, this->invocations_op2); // one invocation of function op
    EXPECT_EQ(1, this->invocations_sk); // one invocation of function sk
    EXPECT_EQ(132, this->w[0]);
  }

  void setup_multiple_sink() {
    v = vector<int>{1,2,3,4,5};
    output = 0;
  }

  template <typename E>
  void run_multiple_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return v[idx_in-1];
        } else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x * 2;
          },
          [this](int x) {
            invocations_op2++;
            return x * 2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        output +=x;
      }
    );
  }

  void check_multiple_sink() {
    EXPECT_EQ(6, this->invocations_in); // six invocations of function in
    EXPECT_EQ(5, this->invocations_op); // five invocations of function op
    EXPECT_EQ(5, this->invocations_op2); // five invocations of function sk
    EXPECT_EQ(5, this->invocations_sk); // five invocations of function sk
    EXPECT_EQ(60, this->output);
  }

  void setup_multiple_ary_sink() {
    v = vector<int>{1,2,3,4,5};
    v2 = vector<int>{2,4,6,8,10};
    v3 = vector<int>{10,10,10,10,10};
    output = 0;
  }

  template <typename E>
  void run_multiple_ary_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return make_tuple(v[idx_in-1], v2[idx_in-1], v3[idx_in-1]);
      }
      else return {};
    },
    grppi::farm(2,
      grppi::pipeline(
        [this](tuple<int,int,int> x) {
          invocations_op++;
          return get<0>(x) + get<1>(x) + get<2>(x);
        },
        [this](int x){
          invocations_op2++;
          return x*2;
        }
      )
    ),
    [this](int x) {
      invocations_sk++;
      output += x;
    });
  }

  void check_multiple_ary_sink() {
    EXPECT_EQ(6, this->invocations_in); // six invocations of function in
    EXPECT_EQ(5, this->invocations_op); // five invocations of function op
    EXPECT_EQ(5, this->invocations_op2); // five invocations of function op
    EXPECT_EQ(5, this->invocations_sk); // five invocations of function sk
    EXPECT_EQ(190, this->output);
  }

};

// Test for execution policies defined in supported_executions.h
TYPED_TEST_CASE(farm_pipeline_test, executions);

TYPED_TEST(farm_pipeline_test, static_empty)
{
  this->setup_empty();
  this->run_empty(this->execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, dyn_empty)
{
  this->setup_empty();
  this->run_empty(this->dyn_execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, static_empty_sink)
{
  this->setup_empty_sink();
  this->run_empty_sink(this->execution_);
  this->check_empty_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_empty_sink)
{
  this->setup_empty_sink();
  this->run_empty_sink(this->dyn_execution_);
  this->check_empty_sink();
}

TYPED_TEST(farm_pipeline_test, static_empty_ary)
{
  this->setup_empty();
  this->run_empty_ary(this->execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, dyn_empty_ary)
{
  this->setup_empty();
  this->run_empty_ary(this->dyn_execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, static_single_sink)
{
  this->setup_single_sink();
  this->run_single_sink(this->execution_);
  this->check_single_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_single_sink)
{
  this->setup_single_sink();
  this->run_single_sink(this->dyn_execution_);
  this->check_single_sink();
}

TYPED_TEST(farm_pipeline_test, static_single_ary_sink)
{
  this->setup_single_ary_sink();
  this->run_single_ary_sink(this->dyn_execution_);
  this->check_single_ary_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_single_ary_sink)
{
  this->setup_single_ary_sink();
  this->run_single_ary_sink(this->dyn_execution_);
  this->check_single_ary_sink();
}

TYPED_TEST(farm_pipeline_test, static_multiple_sink)
{
  this->setup_multiple_sink();
  this->run_multiple_sink(this->execution_);
  this->check_multiple_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_multiple_sink)
{
  this->setup_multiple_sink();
  this->run_multiple_sink(this->dyn_execution_);
  this->check_multiple_sink();
}

TYPED_TEST(farm_pipeline_test, static_multiple_ary_sink)
{
  this->setup_multiple_ary_sink();
  this->run_multiple_ary_sink(this->execution_);
  this->check_multiple_ary_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_multiple_ary_sink)
{
  this->setup_multiple_ary_sink();
  this->run_multiple_ary_sink(this->dyn_execution_);
  this->check_multiple_ary_sink();
}
<commit_msg>Unit test farm+pipeline with no ff execution until it is implemented<commit_after>/**
* @version		GrPPI v0.3
* @copyright		Copyright (C) 2017 Universidad Carlos III de Madrid. All rights reserved.
* @license		GNU/GPL, see LICENSE.txt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You have received a copy of the GNU General Public License in LICENSE.txt
* also available in <http://www.gnu.org/licenses/gpl.html>.
*
* See COPYRIGHT.txt for copyright notices and details.
*/
#include <atomic>
#include <utility>
#include <experimental/optional>

#include <gtest/gtest.h>

#include "farm.h"
#include "pipeline.h"
#include "dyn/dynamic_execution.h"

#include "supported_executions.h"

using namespace std;
using namespace grppi;
template <typename T>
using optional = std::experimental::optional<T>;

template <typename T>
class farm_pipeline_test : public ::testing::Test {
public:
  T execution_;
  dynamic_execution dyn_execution_{execution_};

  // Variables
  std::atomic<int> output;

  // Vectors
  vector<int> v{};
  vector<int> v2{};
  vector<int> v3{};
  vector<int> w{};

  // entry counter
  int idx_in = 0;
  int idx_out = 0;

  // Invocation counter
  std::atomic<int> invocations_in{0};
  std::atomic<int> invocations_op{0};
  std::atomic<int> invocations_op2{0};
  std::atomic<int> invocations_sk{0};

  void setup_empty() {}

  template <typename E>
  void run_empty(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int>{
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x;
          },
          [this](int x) {
            invocations_op2++;
            return x;
          }
        )
      ),
      [](int x) {}
    );
  }

  void check_empty() {
    EXPECT_EQ(1, invocations_in); // Functor in was invoked once
    EXPECT_EQ(0, invocations_op); // Functor op was not invoked
    EXPECT_EQ(0, invocations_op2); // Functor op2 was not invoked
  }

  void setup_empty_sink() {}

  template <typename E>
  void run_empty_sink(const E & e) {
    grppi::pipeline (e,
      [this]() -> optional<int>{
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x;
          },
          [this](int x) {
            invocations_op2++;
            return x;
          }
        )
      ),
      [this](int x) {
        this->invocations_sk++;
      }
    );
  }

  void check_empty_sink() {
    EXPECT_EQ(1, invocations_in);
    EXPECT_EQ(0, invocations_op);
    EXPECT_EQ(0, invocations_op2);
    EXPECT_EQ(0, invocations_sk);
  }

  void setup_empty_ary() {}

  template <typename E>
  void run_empty_ary(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](tuple<int,int,int> x) {
            invocations_op++;
            return x;
          },
          [this](tuple<int,int,int> x) {
            invocations_op2++;
            return x;
          })
      ),
      [&](tuple<int,int,int> x){
        invocations_sk++;
      }
    );
  }

  void check_empty_ary() {
    EXPECT_EQ(1, invocations_in);
    EXPECT_EQ(0, invocations_op);
    EXPECT_EQ(0, invocations_op2);
    EXPECT_EQ(0, invocations_sk);
  }

  void setup_single_sink() {
    v = vector<int>{42};
    w = vector<int>{99};
  }

  template <typename E>
  void run_single_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int> {
        invocations_in++;
        if (idx_in < v.size() ) {
          idx_in++;
          return v[idx_in-1];
        }
        else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x*2;
          },
          [this](int x) {
            invocations_op2++;
            return x*2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        w[idx_out] = x;
        idx_out++;
      }
    );
  }

  void check_single_sink() {
    EXPECT_EQ(2, invocations_in); // Functor in was invoked once
    EXPECT_EQ(1, this->invocations_op); // one invocation of function op
    EXPECT_EQ(1, this->invocations_op2); // one invocation of function op
    EXPECT_EQ(1, this->invocations_sk); // one invocation of function sk
    EXPECT_EQ(168, this->w[0]);
  }

  void setup_single_ary_sink() {
    v = vector<int>{11};
    v2 = vector<int>{22};
    v3 = vector<int>{33};
    w = vector<int>{99};
  }

  template <typename E>
  void run_single_ary_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return make_tuple(v[idx_in-1], v2[idx_in-1], v3[idx_in-1]);
        }
        else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](tuple<int,int,int> x) {
            invocations_op++;
            return get<0>(x) + get<1>(x) + get<2>(x);;
          },
          [this](int x){
            invocations_op2++;
            return x*2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        w[idx_out] = x;
        idx_out++;
      });
  }

  void check_single_ary_sink() {
    EXPECT_EQ(2, invocations_in); // Functor in was invoked twice
    EXPECT_EQ(1, this->invocations_op); // one invocation of function op
    EXPECT_EQ(1, this->invocations_op2); // one invocation of function op
    EXPECT_EQ(1, this->invocations_sk); // one invocation of function sk
    EXPECT_EQ(132, this->w[0]);
  }

  void setup_multiple_sink() {
    v = vector<int>{1,2,3,4,5};
    output = 0;
  }

  template <typename E>
  void run_multiple_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<int> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return v[idx_in-1];
        } else return {};
      },
      grppi::farm(2,
        grppi::pipeline(
          [this](int x) {
            invocations_op++;
            return x * 2;
          },
          [this](int x) {
            invocations_op2++;
            return x * 2;
          }
        )
      ),
      [this](int x) {
        invocations_sk++;
        output +=x;
      }
    );
  }

  void check_multiple_sink() {
    EXPECT_EQ(6, this->invocations_in); // six invocations of function in
    EXPECT_EQ(5, this->invocations_op); // five invocations of function op
    EXPECT_EQ(5, this->invocations_op2); // five invocations of function sk
    EXPECT_EQ(5, this->invocations_sk); // five invocations of function sk
    EXPECT_EQ(60, this->output);
  }

  void setup_multiple_ary_sink() {
    v = vector<int>{1,2,3,4,5};
    v2 = vector<int>{2,4,6,8,10};
    v3 = vector<int>{10,10,10,10,10};
    output = 0;
  }

  template <typename E>
  void run_multiple_ary_sink(const E & e) {
    grppi::pipeline(e,
      [this]() -> optional<tuple<int,int,int>> {
        invocations_in++;
        if (idx_in < v.size()) {
          idx_in++;
          return make_tuple(v[idx_in-1], v2[idx_in-1], v3[idx_in-1]);
      }
      else return {};
    },
    grppi::farm(2,
      grppi::pipeline(
        [this](tuple<int,int,int> x) {
          invocations_op++;
          return get<0>(x) + get<1>(x) + get<2>(x);
        },
        [this](int x){
          invocations_op2++;
          return x*2;
        }
      )
    ),
    [this](int x) {
      invocations_sk++;
      output += x;
    });
  }

  void check_multiple_ary_sink() {
    EXPECT_EQ(6, this->invocations_in); // six invocations of function in
    EXPECT_EQ(5, this->invocations_op); // five invocations of function op
    EXPECT_EQ(5, this->invocations_op2); // five invocations of function op
    EXPECT_EQ(5, this->invocations_sk); // five invocations of function sk
    EXPECT_EQ(190, this->output);
  }

};

// Test for execution policies defined in supported_executions.h
TYPED_TEST_CASE(farm_pipeline_test, executions_noff);

TYPED_TEST(farm_pipeline_test, static_empty)
{
  this->setup_empty();
  this->run_empty(this->execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, dyn_empty)
{
  this->setup_empty();
  this->run_empty(this->dyn_execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, static_empty_sink)
{
  this->setup_empty_sink();
  this->run_empty_sink(this->execution_);
  this->check_empty_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_empty_sink)
{
  this->setup_empty_sink();
  this->run_empty_sink(this->dyn_execution_);
  this->check_empty_sink();
}

TYPED_TEST(farm_pipeline_test, static_empty_ary)
{
  this->setup_empty();
  this->run_empty_ary(this->execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, dyn_empty_ary)
{
  this->setup_empty();
  this->run_empty_ary(this->dyn_execution_);
  this->check_empty();
}

TYPED_TEST(farm_pipeline_test, static_single_sink)
{
  this->setup_single_sink();
  this->run_single_sink(this->execution_);
  this->check_single_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_single_sink)
{
  this->setup_single_sink();
  this->run_single_sink(this->dyn_execution_);
  this->check_single_sink();
}

TYPED_TEST(farm_pipeline_test, static_single_ary_sink)
{
  this->setup_single_ary_sink();
  this->run_single_ary_sink(this->dyn_execution_);
  this->check_single_ary_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_single_ary_sink)
{
  this->setup_single_ary_sink();
  this->run_single_ary_sink(this->dyn_execution_);
  this->check_single_ary_sink();
}

TYPED_TEST(farm_pipeline_test, static_multiple_sink)
{
  this->setup_multiple_sink();
  this->run_multiple_sink(this->execution_);
  this->check_multiple_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_multiple_sink)
{
  this->setup_multiple_sink();
  this->run_multiple_sink(this->dyn_execution_);
  this->check_multiple_sink();
}

TYPED_TEST(farm_pipeline_test, static_multiple_ary_sink)
{
  this->setup_multiple_ary_sink();
  this->run_multiple_ary_sink(this->execution_);
  this->check_multiple_ary_sink();
}

TYPED_TEST(farm_pipeline_test, dyn_multiple_ary_sink)
{
  this->setup_multiple_ary_sink();
  this->run_multiple_ary_sink(this->dyn_execution_);
  this->check_multiple_ary_sink();
}
<|endoftext|>


<commit_before>#include <my-class.h>

/*! \namespace MyNamespace

\brief This is a small namespace thought for the examle.

This is a namespace. A small litte namespace. It doesn't need any detailed documentation,
because it's so small. But also, because nobody will every use it.

But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.

*/

/*! \class MyClass

\brief This is a small class thought for the examle.

This is a class. A small litte class. It doesn't need any detailed documentation,
because it's so small. But also, because nobody will every use it.

But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.

*/

namespace MyNamespace
{
  /*!
  \brief This is a small function thought for the examle.

  This is a function. A small litte function. It doesn't need any detailed documentation,
  because it's so small. But also, because nobody will every use it.

  But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.
  */
  int MyClass::myFunction(int x) const
  {
    return myVar - x + 42;
  }
}
<commit_msg>fixed example docu<commit_after>#include <my-class.h>

/*! \namespace MyNamespace

\brief This is a small namespace thought for the examle.

This is a namespace. A small litte namespace. It doesn't need any detailed documentation,
because it's so small. But also, because nobody will every use it.

But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.

*/

/*! \class MyNamespace::MyClass

\brief This is a small class thought for the examle.

This is a class. A small litte class. It doesn't need any detailed documentation,
because it's so small. But also, because nobody will every use it.

But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.

*/

namespace MyNamespace
{
  /*!
  \brief This is a small function thought for the examle.

  This is a function. A small litte function. It doesn't need any detailed documentation,
  because it's so small. But also, because nobody will every use it.

  But hey, don't be sad. That's, what an example is for. Just showcasing useful stuff.
  */
  int MyClass::myFunction(int x) const
  {
    return myVar - x + 42;
  }
}
<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"

#include <rtl/ustrbuf.hxx>
#include <tools/inetdef.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/bootstrap.hxx>
#include <unotools/docinfohelper.hxx>

using namespace ::com::sun::star;

namespace utl
{

::rtl::OUString DocInfoHelper::GetGeneratorString()
{
    rtl::OUStringBuffer aResult;

    // First product: branded name + version
    // version is <product_versions>_<product_extension>$<platform>
    utl::ConfigManager& rMgr = utl::ConfigManager::GetConfigManager();
    // plain product name
    rtl::OUString aValue;
    uno::Any aAny = rMgr.GetDirectConfigProperty(
                                        utl::ConfigManager::PRODUCTNAME);
    if ( (aAny >>= aValue) && aValue.getLength() )
    {
        aResult.append( aValue.replace( ' ', '_' ) );
        aResult.append( (sal_Unicode)'/' );

        aAny = rMgr.GetDirectConfigProperty(
                                    utl::ConfigManager::PRODUCTVERSION);
        if ( (aAny >>= aValue) && aValue.getLength() )
        {
            aResult.append( aValue.replace( ' ', '_' ) );

            aAny = rMgr.GetDirectConfigProperty(
                                    utl::ConfigManager::PRODUCTEXTENSION);
            if ( (aAny >>= aValue) && aValue.getLength() )
            {
                aResult.append( (sal_Unicode)'_' );
                aResult.append( aValue.replace( ' ', '_' ) );
            }
        }

        aResult.append( (sal_Unicode)'$' );
        aResult.append( ::rtl::OUString::createFromAscii(
                                TOOLS_INETDEF_OS ).replace( ' ', '_' ) );

        aResult.append( (sal_Unicode)' ' );
    }

    // second product: OpenOffice.org_project/<build_information>
    // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
    // and ':' replaced by '-'
    {
        aResult.appendAscii( "OpenOffice.org_project/" );
        ::rtl::OUString aDefault;
        ::rtl::OUString aBuildId( Bootstrap::getBuildIdData( aDefault ) );
        for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
        {
            sal_Unicode c = aBuildId[i];
            switch( c )
            {
            case '(':
            case '[':
                aResult.append( (sal_Unicode)'$' );
                break;
            case ')':
            case ']':
                break;
            case ':':
                aResult.append( (sal_Unicode)'-' );
                break;
            default:
                aResult.append( c );
                break;
            }
        }
    }

    return aResult.makeStringAndClear();
}

} // end of namespace utl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>Change ODF creator to LibreOffice<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_unotools.hxx"

#include <rtl/ustrbuf.hxx>
#include <tools/inetdef.hxx>
#include <unotools/configmgr.hxx>
#include <unotools/bootstrap.hxx>
#include <unotools/docinfohelper.hxx>

using namespace ::com::sun::star;

namespace utl
{

::rtl::OUString DocInfoHelper::GetGeneratorString()
{
    rtl::OUStringBuffer aResult;

    // First product: branded name + version
    // version is <product_versions>_<product_extension>$<platform>
    utl::ConfigManager& rMgr = utl::ConfigManager::GetConfigManager();
    // plain product name
    rtl::OUString aValue;
    uno::Any aAny = rMgr.GetDirectConfigProperty(
                                        utl::ConfigManager::PRODUCTNAME);
    if ( (aAny >>= aValue) && aValue.getLength() )
    {
        aResult.append( aValue.replace( ' ', '_' ) );
        aResult.append( (sal_Unicode)'/' );

        aAny = rMgr.GetDirectConfigProperty(
                                    utl::ConfigManager::PRODUCTVERSION);
        if ( (aAny >>= aValue) && aValue.getLength() )
        {
            aResult.append( aValue.replace( ' ', '_' ) );

            aAny = rMgr.GetDirectConfigProperty(
                                    utl::ConfigManager::PRODUCTEXTENSION);
            if ( (aAny >>= aValue) && aValue.getLength() )
            {
                aResult.append( (sal_Unicode)'_' );
                aResult.append( aValue.replace( ' ', '_' ) );
            }
        }

        aResult.append( (sal_Unicode)'$' );
        aResult.append( ::rtl::OUString::createFromAscii(
                                TOOLS_INETDEF_OS ).replace( ' ', '_' ) );

        aResult.append( (sal_Unicode)' ' );
    }

    // second product: LibreOffice_project/<build_information>
    // build_information has '(' and '[' encoded as '$', ')' and ']' ignored
    // and ':' replaced by '-'
    {
        aResult.appendAscii( "LibreOffice_project/" );
        ::rtl::OUString aDefault;
        ::rtl::OUString aBuildId( Bootstrap::getBuildIdData( aDefault ) );
        for( sal_Int32 i=0; i < aBuildId.getLength(); i++ )
        {
            sal_Unicode c = aBuildId[i];
            switch( c )
            {
            case '(':
            case '[':
                aResult.append( (sal_Unicode)'$' );
                break;
            case ')':
            case ']':
                break;
            case ':':
                aResult.append( (sal_Unicode)'-' );
                break;
            default:
                aResult.append( c );
                break;
            }
        }
    }

    return aResult.makeStringAndClear();
}

} // end of namespace utl

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>


<commit_before>#ifndef RBX_OBJECTS_HPP
#define RBX_OBJECTS_HPP

#include "vm.hpp"
#include "object.hpp"
#include "type_info.hpp"

#include <iostream>

#include "builtin/immediates.hpp" // TODO: remove me!

namespace rubinius {
  class Numeric : public Object {
  public:
    static const object_type type = NumericType;

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
    };
  };

  class Integer : public Numeric {
  public:
    static const object_type type = IntegerType;

    native_int n2i();

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
    };
  };
}

namespace rubinius {
  class NormalObject : public Object {
  public:
    const static size_t fields = 1;
    const static object_type type = ObjectType;

    OBJECT instance_variables;

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
      virtual void mark(OBJECT t, ObjectMark& mark);
    };
  };

  template <>
  static inline NormalObject* as<NormalObject>(OBJECT obj) {
    return (NormalObject*)obj;
  }
};

#endif
<commit_msg>Removed immediates from objects.hpp<commit_after>#ifndef RBX_OBJECTS_HPP
#define RBX_OBJECTS_HPP

#include "vm.hpp"
#include "object.hpp"
#include "type_info.hpp"

#include <iostream>

namespace rubinius {
  class Numeric : public Object {
  public:
    static const object_type type = NumericType;

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
    };
  };

  class Integer : public Numeric {
  public:
    static const object_type type = IntegerType;

    native_int n2i();

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
    };
  };
}

namespace rubinius {
  class NormalObject : public Object {
  public:
    const static size_t fields = 1;
    const static object_type type = ObjectType;

    OBJECT instance_variables;

    class Info : public TypeInfo {
    public:
      Info(object_type type) : TypeInfo(type) { }
      virtual void mark(OBJECT t, ObjectMark& mark);
    };
  };

  template <>
  static inline NormalObject* as<NormalObject>(OBJECT obj) {
    return (NormalObject*)obj;
  }
};

#endif
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: directview.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: jb $ $Date: 2002-03-28 08:14:40 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License") You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#include <stdio.h>
#include "directview.hxx"

#ifndef CONFIGMGR_VIEWBEHAVIORFACTORY_HXX_
#include "viewfactory.hxx"
#endif

#ifndef CONFIGMGR_SETNODEBEHAVIOR_HXX_
#include "setnodeimpl.hxx"
#endif
#ifndef CONFIGMGR_SETNODEACCESS_HXX
#include "setnodeaccess.hxx"
#endif

namespace configmgr
{
    namespace view
    {
//-----------------------------------------------------------------------------

void DirectViewStrategy::implMarkNondefault(SetNode const& _aSetNode)
{
    data::SetNodeAccess aSetAccess = _aSetNode.getAccess();

    OSL_ASSERT(aSetAccess.isValid());

    sharable::SetNode* pNode = this->getDataForUpdate(aSetAccess);

    OSL_ASSERT(pNode);

    pNode->info.markAsDefault(false);
}
//-----------------------------------------------------------------------------

bool DirectViewStrategy::doHasChanges(Node const& ) const
{
    return false;
}
//-----------------------------------------------------------------------------

void DirectViewStrategy::doMarkChanged(Node const& )
{
    // do nothing
}
//-----------------------------------------------------------------------------

node::Attributes DirectViewStrategy::doAdjustAttributes(node::Attributes const& _aAttributes) const
{
    node::Attributes aAttributes = _aAttributes;
    aAttributes.bFinalized |= !aAttributes.bWritable;
    aAttributes.bWritable = true;
    return aAttributes;
}
//-----------------------------------------------------------------------------

configuration::ValueMemberNode DirectViewStrategy::doGetValueMember(GroupNode const& _aNode, Name const& _aName, bool _bForUpdate) const
{
    return ViewStrategy::doGetValueMember(_aNode,_aName,_bForUpdate);
}
//-----------------------------------------------------------------------------
void DirectViewStrategy::doInsertElement(SetNode const& _aNode, Name const& _aName, SetNodeEntry const& _aNewEntry)
{
    // move to this memory segment
    // should already be direct (as any free-floating one)

    //implMakeElement(aNewEntry)
    SetNodeElement aNewElement = implMakeElement(_aNode, _aNewEntry );
 //   _aNewEntry.tree()->rebuild(this, _aNode.accessor());

    _aNode.get_impl()->insertElement(_aName, aNewElement);

    aNewElement->attachTo( _aNode.getAccess(), _aName );

    implMarkNondefault( _aNode );
}
//-----------------------------------------------------------------------------

void DirectViewStrategy::doRemoveElement(SetNode const& _aNode, Name const& _aName)
{
    SetNodeElement aOldElement = _aNode.get_impl()->removeElement(_aName);

    aOldElement->detachFrom( _aNode.getAccess(), _aName);

    implMarkNondefault( _aNode );
}
//-----------------------------------------------------------------------------

extern NodeFactory& getDirectAccessFactory();

NodeFactory& DirectViewStrategy::doGetNodeFactory()
{
    return getDirectAccessFactory();
}
//-----------------------------------------------------------------------------

ViewStrategyRef createDirectAccessStrategy(data::TreeSegment const & _aTreeSegment)
{
    return new DirectViewStrategy(_aTreeSegment);
}

//-----------------------------------------------------------------------------
    }
}
<commit_msg>INTEGRATION: CWS cfg01 (1.2.24); FILE MERGED 2003/03/13 15:25:50 jb 1.2.24.2: #107404# Further clean up of node::Attributes interface 2003/02/17 15:58:08 ssmith 1.2.24.1: #107404# refactoring code to support encapsulation<commit_after>/*************************************************************************
 *
 *  $RCSfile: directview.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: vg $ $Date: 2003-04-01 13:40:04 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License") You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#include <stdio.h>
#include "directview.hxx"

#ifndef CONFIGMGR_VIEWBEHAVIORFACTORY_HXX_
#include "viewfactory.hxx"
#endif

#ifndef CONFIGMGR_SETNODEBEHAVIOR_HXX_
#include "setnodeimpl.hxx"
#endif
#ifndef CONFIGMGR_SETNODEACCESS_HXX
#include "setnodeaccess.hxx"
#endif

namespace configmgr
{
    namespace view
    {
//-----------------------------------------------------------------------------

void DirectViewStrategy::implMarkNondefault(SetNode const& _aSetNode)
{
    data::SetNodeAccess aSetAccess = _aSetNode.getAccess();

    OSL_ASSERT(aSetAccess.isValid());

    sharable::SetNode* pNode = this->getDataForUpdate(aSetAccess);

    OSL_ASSERT(pNode);

    pNode->info.markAsDefault(false);
}
//-----------------------------------------------------------------------------

bool DirectViewStrategy::doHasChanges(Node const& ) const
{
    return false;
}
//-----------------------------------------------------------------------------

void DirectViewStrategy::doMarkChanged(Node const& )
{
    // do nothing
}
//-----------------------------------------------------------------------------

node::Attributes DirectViewStrategy::doAdjustAttributes(node::Attributes const& _aAttributes) const
{
    node::Attributes aAttributes = _aAttributes;

    if (aAttributes.isReadonly())
        aAttributes.setAccess(node::accessFinal);

    return aAttributes;
}
//-----------------------------------------------------------------------------

configuration::ValueMemberNode DirectViewStrategy::doGetValueMember(GroupNode const& _aNode, Name const& _aName, bool _bForUpdate) const
{
    return ViewStrategy::doGetValueMember(_aNode,_aName,_bForUpdate);
}
//-----------------------------------------------------------------------------
void DirectViewStrategy::doInsertElement(SetNode const& _aNode, Name const& _aName, SetNodeEntry const& _aNewEntry)
{
    // move to this memory segment
    // should already be direct (as any free-floating one)

    //implMakeElement(aNewEntry)
    SetNodeElement aNewElement = implMakeElement(_aNode, _aNewEntry );
 //   _aNewEntry.tree()->rebuild(this, _aNode.accessor());

    _aNode.get_impl()->insertElement(_aName, aNewElement);

    aNewElement->attachTo( _aNode.getAccess(), _aName );

    implMarkNondefault( _aNode );
}
//-----------------------------------------------------------------------------

void DirectViewStrategy::doRemoveElement(SetNode const& _aNode, Name const& _aName)
{
    SetNodeElement aOldElement = _aNode.get_impl()->removeElement(_aName);

    aOldElement->detachFrom( _aNode.getAccess(), _aName);

    implMarkNondefault( _aNode );
}
//-----------------------------------------------------------------------------

extern NodeFactory& getDirectAccessFactory();

NodeFactory& DirectViewStrategy::doGetNodeFactory()
{
    return getDirectAccessFactory();
}
//-----------------------------------------------------------------------------

ViewStrategyRef createDirectAccessStrategy(data::TreeSegment const & _aTreeSegment)
{
    return new DirectViewStrategy(_aTreeSegment);
}

//-----------------------------------------------------------------------------
    }
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: propertyids.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: oj $ $Date: 2000-10-24 15:13:05 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
#define _CONNECTIVITY_PROPERTYIDS_HXX_

// this define has to be set to split the names into different dll's or so's
// every dll has his own set of property names
#ifndef CONNECTIVITY_PROPERTY_NAME_SPACE
#pragma warning("CONNECTIVITY_PROPERTY_NAME_SPACE not set")
#endif

#ifndef _RTL_USTRING_
#include <rtl/ustring>
#endif

namespace connectivity
{
namespace dbtools
{
    extern const sal_Char* getPROPERTY_QUERYTIMEOUT();
    extern const sal_Char* getPROPERTY_MAXFIELDSIZE();
    extern const sal_Char* getPROPERTY_MAXROWS();
    extern const sal_Char* getPROPERTY_CURSORNAME();
    extern const sal_Char* getPROPERTY_RESULTSETCONCURRENCY();
    extern const sal_Char* getPROPERTY_RESULTSETTYPE();
    extern const sal_Char* getPROPERTY_FETCHDIRECTION();
    extern const sal_Char* getPROPERTY_FETCHSIZE();
    extern const sal_Char* getPROPERTY_ESCAPEPROCESSING();
    extern const sal_Char* getPROPERTY_USEBOOKMARKS();

    extern const sal_Char* getPROPERTY_NAME();
    extern const sal_Char* getPROPERTY_TYPE();
    extern const sal_Char* getPROPERTY_TYPENAME();
    extern const sal_Char* getPROPERTY_PRECISION();
    extern const sal_Char* getPROPERTY_SCALE();
    extern const sal_Char* getPROPERTY_ISNULLABLE();
    extern const sal_Char* getPROPERTY_ISAUTOINCREMENT();
    extern const sal_Char* getPROPERTY_ISROWVERSION();
    extern const sal_Char* getPROPERTY_DESCRIPTION();
    extern const sal_Char* getPROPERTY_DEFAULTVALUE();

    extern const sal_Char* getPROPERTY_REFERENCEDTABLE();
    extern const sal_Char* getPROPERTY_UPDATERULE();
    extern const sal_Char* getPROPERTY_DELETERULE();
    extern const sal_Char* getPROPERTY_CATALOG();
    extern const sal_Char* getPROPERTY_ISUNIQUE();
    extern const sal_Char* getPROPERTY_ISPRIMARYKEYINDEX();
    extern const sal_Char* getPROPERTY_ISCLUSTERED();
    extern const sal_Char* getPROPERTY_ISASCENDING();
    extern const sal_Char* getPROPERTY_SCHEMANAME();
    extern const sal_Char* getPROPERTY_CATALOGNAME();
    extern const sal_Char* getPROPERTY_COMMAND();
    extern const sal_Char* getPROPERTY_CHECKOPTION();
    extern const sal_Char* getPROPERTY_PASSWORD();
    extern const sal_Char* getPROPERTY_REFERENCEDCOLUMN();

    extern const sal_Char* getSTAT_INVALID_INDEX();

    extern const sal_Char* getPROPERTY_FUNCTION();
    extern const sal_Char* getPROPERTY_TABLENAME();
    extern const sal_Char* getPROPERTY_REALNAME();
    extern const sal_Char* getPROPERTY_DBASEPRECISIONCHANGED();
    extern const sal_Char* getPROPERTY_ISCURRENCY();

    extern const sal_Char* getPROPERTY_ISBOOKMARKABLE();
//  ====================================================
//  error messages
//  ====================================================
    extern const sal_Char* getERRORMSG_SEQUENCE();
    extern const sal_Char* getSQLSTATE_SEQUENCE();
}
}

namespace connectivity
{
    namespace CONNECTIVITY_PROPERTY_NAME_SPACE
    {
        typedef const sal_Char* (*PVFN)();

        struct UStringDescription
        {
            const sal_Char* pZeroTerminatedName;
            sal_Int32 nLength;

            UStringDescription(PVFN _fCharFkt);
            operator ::rtl::OUString() const { return ::rtl::OUString(pZeroTerminatedName,nLength,RTL_TEXTENCODING_ASCII_US); }
            ~UStringDescription();
        private:
            UStringDescription();
        };

#define DECLARE_CONSTASCII_USTRING(name,nsp)    \
    extern connectivity::nsp::UStringDescription name;

    DECLARE_CONSTASCII_USTRING(PROPERTY_CURSORNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHSIZE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_MAXROWS,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ESCAPEPROCESSING,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_NAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TYPE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TYPENAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_PRECISION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_SCALE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISNULLABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISROWVERSION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DESCRIPTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATERULE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DELETERULE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOG,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISUNIQUE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISCLUSTERED,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISASCENDING,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_SCHEMANAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOGNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_COMMAND,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_CHECKOPTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDCOLUMN,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_FUNCTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TABLENAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_REALNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DBASEPRECISIONCHANGED,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISCURRENCY,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    // error msg
    DECLARE_CONSTASCII_USTRING(STAT_INVALID_INDEX,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(ERRORMSG_SEQUENCE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(SQLSTATE_SEQUENCE,CONNECTIVITY_PROPERTY_NAME_SPACE);

    }
}

//------------------------------------------------------------------------------
#define DECL_PROP1IMPL(varname, type) \
pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::CONNECTIVITY_PROPERTY_NAME_SPACE::PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< type*>(NULL)),
//------------------------------------------------------------------------------
#define DECL_PROP0(varname, type)   \
    DECL_PROP1IMPL(varname, type) 0)
//------------------------------------------------------------------------------
#define DECL_BOOL_PROP1IMPL(varname) \
        pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::CONNECTIVITY_PROPERTY_NAME_SPACE::PROPERTY_##varname, PROPERTY_ID_##varname, ::getBooleanCppuType(),
//------------------------------------------------------------------------------
#define DECL_BOOL_PROP0(varname)    \
    DECL_BOOL_PROP1IMPL(varname) 0)

#define PROPERTY_ID_QUERYTIMEOUT                    1
#define PROPERTY_ID_MAXFIELDSIZE                    2
#define PROPERTY_ID_MAXROWS                         3
#define PROPERTY_ID_CURSORNAME                      4
#define PROPERTY_ID_RESULTSETCONCURRENCY            5
#define PROPERTY_ID_RESULTSETTYPE                   6
#define PROPERTY_ID_FETCHDIRECTION                  7
#define PROPERTY_ID_FETCHSIZE                       8
#define PROPERTY_ID_ESCAPEPROCESSING                9
#define PROPERTY_ID_USEBOOKMARKS                    10
// Column
#define PROPERTY_ID_NAME                            11
#define PROPERTY_ID_TYPE                            12
#define PROPERTY_ID_TYPENAME                        13
#define PROPERTY_ID_PRECISION                       14
#define PROPERTY_ID_SCALE                           15
#define PROPERTY_ID_ISNULLABLE                      16
#define PROPERTY_ID_ISAUTOINCREMENT                 17
#define PROPERTY_ID_ISROWVERSION                    18
#define PROPERTY_ID_DESCRIPTION                     19
#define PROPERTY_ID_DEFAULTVALUE                    20

#define PROPERTY_ID_REFERENCEDTABLE                 21
#define PROPERTY_ID_UPDATERULE                      22
#define PROPERTY_ID_DELETERULE                      23
#define PROPERTY_ID_CATALOG                         24
#define PROPERTY_ID_ISUNIQUE                        25
#define PROPERTY_ID_ISPRIMARYKEYINDEX               26
#define PROPERTY_ID_ISCLUSTERED                     27
#define PROPERTY_ID_ISASCENDING                     28
#define PROPERTY_ID_SCHEMANAME                      29
#define PROPERTY_ID_CATALOGNAME                     30

#define PROPERTY_ID_COMMAND                         31
#define PROPERTY_ID_CHECKOPTION                     32
#define PROPERTY_ID_PASSWORD                        33
#define PROPERTY_ID_REFERENCEDCOLUMN                34

#define PROPERTY_ID_FUNCTION                        35
#define PROPERTY_ID_TABLENAME                       36
#define PROPERTY_ID_REALNAME                        37
#define PROPERTY_ID_DBASEPRECISIONCHANGED           38
#define PROPERTY_ID_ISCURRENCY                      39
#define PROPERTY_ID_ISBOOKMARKABLE                  40

#endif // _CONNECTIVITY_PROPERTYIDS_HXX_

<commit_msg>#65293#: typo<commit_after>/*************************************************************************
 *
 *  $RCSfile: propertyids.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: hr $ $Date: 2000-10-31 11:04:19 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_
#define _CONNECTIVITY_PROPERTYIDS_HXX_

// this define has to be set to split the names into different dll's or so's
// every dll has his own set of property names
#ifndef CONNECTIVITY_PROPERTY_NAME_SPACE
#pragma warning("CONNECTIVITY_PROPERTY_NAME_SPACE not set")
#endif

#ifndef _RTL_USTRING_
#include <rtl/ustring>
#endif

namespace connectivity
{
namespace dbtools
{
    extern const sal_Char* getPROPERTY_QUERYTIMEOUT();
    extern const sal_Char* getPROPERTY_MAXFIELDSIZE();
    extern const sal_Char* getPROPERTY_MAXROWS();
    extern const sal_Char* getPROPERTY_CURSORNAME();
    extern const sal_Char* getPROPERTY_RESULTSETCONCURRENCY();
    extern const sal_Char* getPROPERTY_RESULTSETTYPE();
    extern const sal_Char* getPROPERTY_FETCHDIRECTION();
    extern const sal_Char* getPROPERTY_FETCHSIZE();
    extern const sal_Char* getPROPERTY_ESCAPEPROCESSING();
    extern const sal_Char* getPROPERTY_USEBOOKMARKS();

    extern const sal_Char* getPROPERTY_NAME();
    extern const sal_Char* getPROPERTY_TYPE();
    extern const sal_Char* getPROPERTY_TYPENAME();
    extern const sal_Char* getPROPERTY_PRECISION();
    extern const sal_Char* getPROPERTY_SCALE();
    extern const sal_Char* getPROPERTY_ISNULLABLE();
    extern const sal_Char* getPROPERTY_ISAUTOINCREMENT();
    extern const sal_Char* getPROPERTY_ISROWVERSION();
    extern const sal_Char* getPROPERTY_DESCRIPTION();
    extern const sal_Char* getPROPERTY_DEFAULTVALUE();

    extern const sal_Char* getPROPERTY_REFERENCEDTABLE();
    extern const sal_Char* getPROPERTY_UPDATERULE();
    extern const sal_Char* getPROPERTY_DELETERULE();
    extern const sal_Char* getPROPERTY_CATALOG();
    extern const sal_Char* getPROPERTY_ISUNIQUE();
    extern const sal_Char* getPROPERTY_ISPRIMARYKEYINDEX();
    extern const sal_Char* getPROPERTY_ISCLUSTERED();
    extern const sal_Char* getPROPERTY_ISASCENDING();
    extern const sal_Char* getPROPERTY_SCHEMANAME();
    extern const sal_Char* getPROPERTY_CATALOGNAME();
    extern const sal_Char* getPROPERTY_COMMAND();
    extern const sal_Char* getPROPERTY_CHECKOPTION();
    extern const sal_Char* getPROPERTY_PASSWORD();
    extern const sal_Char* getPROPERTY_REFERENCEDCOLUMN();

    extern const sal_Char* getSTAT_INVALID_INDEX();

    extern const sal_Char* getPROPERTY_FUNCTION();
    extern const sal_Char* getPROPERTY_TABLENAME();
    extern const sal_Char* getPROPERTY_REALNAME();
    extern const sal_Char* getPROPERTY_DBASEPRECISIONCHANGED();
    extern const sal_Char* getPROPERTY_ISCURRENCY();

    extern const sal_Char* getPROPERTY_ISBOOKMARKABLE();
//  ====================================================
//  error messages
//  ====================================================
    extern const sal_Char* getERRORMSG_SEQUENCE();
    extern const sal_Char* getSQLSTATE_SEQUENCE();
}
}

namespace connectivity
{
    namespace CONNECTIVITY_PROPERTY_NAME_SPACE
    {
        typedef const sal_Char* (*PVFN)();

        struct UStringDescription
        {
            const sal_Char* pZeroTerminatedName;
            sal_Int32 nLength;

            UStringDescription(PVFN _fCharFkt);
            operator ::rtl::OUString() const { return ::rtl::OUString(pZeroTerminatedName,nLength,RTL_TEXTENCODING_ASCII_US); }
            ~UStringDescription();
        private:
            UStringDescription();
        };

#define DECLARE_CONSTASCII_USTRING(name,nsp)    \
    extern connectivity::nsp::UStringDescription name;

    DECLARE_CONSTASCII_USTRING(PROPERTY_CURSORNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETCONCURRENCY,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_RESULTSETTYPE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHDIRECTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_FETCHSIZE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_QUERYTIMEOUT,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_MAXFIELDSIZE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_MAXROWS,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ESCAPEPROCESSING,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_USEBOOKMARKS,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_NAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TYPE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TYPENAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_PRECISION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_SCALE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISNULLABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISAUTOINCREMENT,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISROWVERSION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DESCRIPTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DEFAULTVALUE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDTABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_UPDATERULE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DELETERULE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOG,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISUNIQUE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISPRIMARYKEYINDEX,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISCLUSTERED,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISASCENDING,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_SCHEMANAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_CATALOGNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_COMMAND,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_CHECKOPTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_PASSWORD,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_REFERENCEDCOLUMN,CONNECTIVITY_PROPERTY_NAME_SPACE)

    DECLARE_CONSTASCII_USTRING(PROPERTY_FUNCTION,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_TABLENAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_REALNAME,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_DBASEPRECISIONCHANGED,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISCURRENCY,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(PROPERTY_ISBOOKMARKABLE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    // error msg
    DECLARE_CONSTASCII_USTRING(STAT_INVALID_INDEX,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(ERRORMSG_SEQUENCE,CONNECTIVITY_PROPERTY_NAME_SPACE)
    DECLARE_CONSTASCII_USTRING(SQLSTATE_SEQUENCE,CONNECTIVITY_PROPERTY_NAME_SPACE)

    }
}

//------------------------------------------------------------------------------
#define DECL_PROP1IMPL(varname, type) \
pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::CONNECTIVITY_PROPERTY_NAME_SPACE::PROPERTY_##varname, PROPERTY_ID_##varname, ::getCppuType(reinterpret_cast< type*>(NULL)),
//------------------------------------------------------------------------------
#define DECL_PROP0(varname, type)   \
    DECL_PROP1IMPL(varname, type) 0)
//------------------------------------------------------------------------------
#define DECL_BOOL_PROP1IMPL(varname) \
        pProperties[nPos++] = ::com::sun::star::beans::Property(connectivity::CONNECTIVITY_PROPERTY_NAME_SPACE::PROPERTY_##varname, PROPERTY_ID_##varname, ::getBooleanCppuType(),
//------------------------------------------------------------------------------
#define DECL_BOOL_PROP0(varname)    \
    DECL_BOOL_PROP1IMPL(varname) 0)

#define PROPERTY_ID_QUERYTIMEOUT                    1
#define PROPERTY_ID_MAXFIELDSIZE                    2
#define PROPERTY_ID_MAXROWS                         3
#define PROPERTY_ID_CURSORNAME                      4
#define PROPERTY_ID_RESULTSETCONCURRENCY            5
#define PROPERTY_ID_RESULTSETTYPE                   6
#define PROPERTY_ID_FETCHDIRECTION                  7
#define PROPERTY_ID_FETCHSIZE                       8
#define PROPERTY_ID_ESCAPEPROCESSING                9
#define PROPERTY_ID_USEBOOKMARKS                    10
// Column
#define PROPERTY_ID_NAME                            11
#define PROPERTY_ID_TYPE                            12
#define PROPERTY_ID_TYPENAME                        13
#define PROPERTY_ID_PRECISION                       14
#define PROPERTY_ID_SCALE                           15
#define PROPERTY_ID_ISNULLABLE                      16
#define PROPERTY_ID_ISAUTOINCREMENT                 17
#define PROPERTY_ID_ISROWVERSION                    18
#define PROPERTY_ID_DESCRIPTION                     19
#define PROPERTY_ID_DEFAULTVALUE                    20

#define PROPERTY_ID_REFERENCEDTABLE                 21
#define PROPERTY_ID_UPDATERULE                      22
#define PROPERTY_ID_DELETERULE                      23
#define PROPERTY_ID_CATALOG                         24
#define PROPERTY_ID_ISUNIQUE                        25
#define PROPERTY_ID_ISPRIMARYKEYINDEX               26
#define PROPERTY_ID_ISCLUSTERED                     27
#define PROPERTY_ID_ISASCENDING                     28
#define PROPERTY_ID_SCHEMANAME                      29
#define PROPERTY_ID_CATALOGNAME                     30

#define PROPERTY_ID_COMMAND                         31
#define PROPERTY_ID_CHECKOPTION                     32
#define PROPERTY_ID_PASSWORD                        33
#define PROPERTY_ID_REFERENCEDCOLUMN                34

#define PROPERTY_ID_FUNCTION                        35
#define PROPERTY_ID_TABLENAME                       36
#define PROPERTY_ID_REALNAME                        37
#define PROPERTY_ID_DBASEPRECISIONCHANGED           38
#define PROPERTY_ID_ISCURRENCY                      39
#define PROPERTY_ID_ISBOOKMARKABLE                  40

#endif // _CONNECTIVITY_PROPERTYIDS_HXX_

<|endoftext|>


<commit_before>#ifndef SAVE_STATE_H
# define SAVE_STATE_H
# pragma once

struct statebuf
{
  void* sp;
  void* bp;
  void* label;
};

#if defined(__GNUC__)
static inline bool __attribute__((always_inline)) savestate(
  statebuf& ssb) noexcept
{
  bool r;

#if defined(i386) || defined(__i386) || defined(__i386__)
  asm volatile (
    "movl %%esp, %0\n\t" // store sp
    "movl %%ebp, %1\n\t" // store bp
    "movl $1f, %2\n\t" // store label
    "movb $0, %3\n\t" // return false
    "jmp 2f\n\t"
    "1:"
    "movb $1, %3\n\t" // return true
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "memory"
  );
#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
  asm volatile (
    "movq %%rsp, %0\n\t" // store sp
    "movq %%rbp, %1\n\t" // store bp
    "movq $1f, %2\n\t" // store label
    "movb $0, %3\n\t" // return false
    "jmp 2f\n\t"
    "1:"
    "movb $1, %3\n\t" // return true
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "memory"
  );
#elif defined(__aarch64__)
  asm volatile (
    "mov x7, sp\n\t"
    "str x7, %0\n\t" // store sp
    "str fp, %1\n\t" // store fp
    "ldr x7, =1f\n\t" // load label into x3
    "str x7, %2\n\t" // store x3 into label
    "mov %3, #0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, #1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "x7", "memory"
  );
#elif defined(__arm__) && defined(__ARM_ARCH_7__)
  asm volatile (
    "str sp, %0\n\t" // store sp
    "str r7, %1\n\t" // store fp
    "ldr r3, =1f\n\t" // load label into r3
    "str r3, %2\n\t" // store r3 into label
    "mov %3, $0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, $1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "r3", "memory"
  );
#elif defined(__arm__)
  asm volatile (
    "str sp, %0\n\t" // store sp
    "str fp, %1\n\t" // store fp
    "ldr r3, =1f\n\t" // load label into r3
    "str r3, %2\n\t" // store r3 into label
    "mov %3, $0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, $1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "r3", "memory"
  );
#endif

  return r;
}
#elif defined(_MSC_VER)
__forceinline bool savestate(statebuf& ssb) noexcept
{
  bool r;

  __asm {
    mov ebx, ssb
    mov [ebx]ssb.sp, esp
    mov [ebx]ssb.bp, ebp
    mov [ebx]ssb.label, offset _1f
    mov r, 0x0
    jmp _2f
    _1f:
    mov r, 0x1
    _2f:
  }

  return r;
}
#else
# error "unsupported compiler"
#endif

#if defined(__GNUC__)
#if defined(i386) || defined(__i386) || defined(__i386__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "movl %0, %%esp\n\t"                         \
    "movl %1, %%ebp\n\t"                         \
    "jmp *%2"                                    \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "movq %0, %%rsp\n\t"                         \
    "movq %1, %%rbp\n\t"                         \
    "jmp *%2"                                    \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__aarch64__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "mov sp, %0\n\t"                             \
    "mov fp, %1\n\t"                            \
    "ret %2"                                     \
    :                                            \
    : "r" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__arm__) && defined(__ARM_ARCH_7__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "ldr sp, %0\n\t"                             \
    "mov r7, %1\n\t"                             \
    "mov pc, %2"                                 \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__arm__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "ldr sp, %0\n\t"                             \
    "mov fp, %1\n\t"                             \
    "mov pc, %2"                                 \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#else
# error "unsupported architecture"
#endif
#elif defined(_MSC_VER)
#define restorestate(SSB)   \
  __asm mov ebx, this       \
  __asm add ebx, [SSB]      \
  __asm mov esp, [ebx]SSB.sp\
  __asm mov ebp, [ebx]SSB.bp\
  __asm jmp [ebx]SSB.label
#else
# error "unsupported compiler"
#endif

#endif // SAVE_STATE_H
<commit_msg>some fixes<commit_after>#ifndef SAVE_STATE_H
# define SAVE_STATE_H
# pragma once

struct statebuf
{
  void* sp;
  void* bp;
  void* label;
};

#if defined(__GNUC__)
static inline bool __attribute__((always_inline)) savestate(
  statebuf& ssb) noexcept
{
  bool r;

#if defined(i386) || defined(__i386) || defined(__i386__)
  asm volatile (
    "movl %%esp, %0\n\t" // store sp
    "movl %%ebp, %1\n\t" // store bp
    "movl $1f, %2\n\t" // store label
    "movb $0, %3\n\t" // return false
    "jmp 2f\n\t"
    "1:"
    "movb $1, %3\n\t" // return true
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "memory"
  );
#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
  asm volatile (
    "movq %%rsp, %0\n\t" // store sp
    "movq %%rbp, %1\n\t" // store bp
    "movq $1f, %2\n\t" // store label
    "movb $0, %3\n\t" // return false
    "jmp 2f\n\t"
    "1:"
    "movb $1, %3\n\t" // return true
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "memory"
  );
#elif defined(__aarch64__)
  asm volatile (
    "mov x7, sp\n\t"
    "str x7, %0\n\t" // store sp
    "str fp, %1\n\t" // store fp
    "ldr x7, =1f\n\t" // load label into x3
    "str x7, %2\n\t" // store x3 into label
    "mov %3, #0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, #1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "x7", "memory"
  );
#elif defined(__arm__) && defined(__ARM_ARCH_7__)
  asm volatile (
    "str sp, %0\n\t" // store sp
    "str r7, %1\n\t" // store fp
    "ldr r3, =1f\n\t" // load label into r3
    "str r3, %2\n\t" // store r3 into label
    "mov %3, $0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, $1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "r3", "memory"
  );
#elif defined(__arm__)
  asm volatile (
    "str sp, %0\n\t" // store sp
    "str fp, %1\n\t" // store fp
    "ldr r3, =1f\n\t" // load label into r3
    "str r3, %2\n\t" // store r3 into label
    "mov %3, $0\n\t" // store 0 into result
    "b 2f\n\t"
    "1:"
    "mov %3, $1\n\t" // store 1 into result
    "2:"
    : "=m" (ssb.sp), "=m" (ssb.bp), "=m" (ssb.label), "=r" (r)
    :
    : "r3", "memory"
  );
#endif

  return r;
}
#elif defined(_MSC_VER)
__forceinline bool savestate(statebuf& ssb) noexcept
{
  bool r;

  __asm {
    mov ebx, ssb
    mov [ebx]ssb.sp, esp
    mov [ebx]ssb.bp, ebp
    mov [ebx]ssb.label, offset _1f
    mov r, 0x0
    jmp _2f
    _1f:
    mov r, 0x1
    _2f:
  }

  return r;
}
#else
# error "unsupported compiler"
#endif

#if defined(__GNUC__)
#if defined(i386) || defined(__i386) || defined(__i386__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "movl %0, %%esp\n\t"                         \
    "movl %1, %%ebp\n\t"                         \
    "jmp *%2"                                    \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "movq %0, %%rsp\n\t"                         \
    "movq %1, %%rbp\n\t"                         \
    "jmp *%2"                                    \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__aarch64__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "mov sp, %0\n\t"                             \
    "mov fp, %1\n\t"                             \
    "ret %2"                                     \
    :                                            \
    : "r" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__arm__) && defined(__ARM_ARCH_7__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "ldr sp, %0\n\t"                             \
    "mov r7, %1\n\t"                             \
    "mov pc, %2"                                 \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#elif defined(__arm__)
#define restorestate(SSB)                        \
  asm volatile (                                 \
    "ldr sp, %0\n\t"                             \
    "mov fp, %1\n\t"                             \
    "mov pc, %2"                                 \
    :                                            \
    : "m" (SSB.sp), "r" (SSB.bp), "r" (SSB.label)\
  );
#else
# error "unsupported architecture"
#endif
#elif defined(_MSC_VER)
#define restorestate(SSB)   \
  __asm mov ebx, this       \
  __asm add ebx, [SSB]      \
  __asm mov esp, [ebx]SSB.sp\
  __asm mov ebp, [ebx]SSB.bp\
  __asm jmp [ebx]SSB.label
#else
# error "unsupported compiler"
#endif

#endif // SAVE_STATE_H
<|endoftext|>