answer stringlengths 15 1.25M |
|---|
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function () {
var node = document.createElement('div');
assert_true('append' in node);
var append = 'mine';
var getAttribute = 'mine';
with (node) {
assert_true(append === 'mine');
assert_false(getAttribute === 'mine');
}
assert_true('Symbol' in window);
var unscopables = Object.getPrototypeOf(node)[Symbol.unscopables];
assert_true(unscopables.append);
}, 'ChildNode.append() unscopable');
function test_append(node, nodeName) {
test(function() {
var parent = node.cloneNode();
parent.append();
assert_array_equals(parent.childNodes, []);
}, nodeName + '.append() without any argument, on a parent having no child.');
test(function() {
var parent = node.cloneNode();
parent.append(null);
assert_equals(parent.childNodes[0].textContent, 'null');
}, nodeName + '.append() with null as an argument, on a parent having no child.');
test(function() {
var parent = node.cloneNode();
parent.append(undefined);
assert_equals(parent.childNodes[0].textContent, 'undefined');
}, nodeName + '.append() with undefined as an argument, on a parent having no child.');
test(function() {
var parent = node.cloneNode();
parent.append('text');
assert_equals(parent.childNodes[0].textContent, 'text');
}, nodeName + '.append() with only text as an argument, on a parent having no child.');
test(function() {
var parent = node.cloneNode();
var x = document.createElement('x');
parent.append(x);
assert_array_equals(parent.childNodes, [x]);
}, nodeName + '.append() with only one element as an argument, on a parent having no child.');
test(function() {
var parent = node.cloneNode();
var child = document.createElement('test');
parent.appendChild(child);
parent.append(null);
assert_equals(parent.childNodes[0], child);
assert_equals(parent.childNodes[1].textContent, 'null');
}, nodeName + '.append() with null as an argument, on a parent having a child.');
test(function() {
var parent = node.cloneNode();
var x = document.createElement('x');
var child = document.createElement('test');
parent.appendChild(x);
parent.appendChild(child);
parent.append(child, x);
assert_array_equals(parent.childNodes, [child, x]);
}, nodeName + '.append() with all children as arguments, on a parent having two children.');
test(function() {
var parent = node.cloneNode();
var x = document.createElement('x');
var child = document.createElement('test');
parent.appendChild(child);
parent.append(x, 'text');
assert_equals(parent.childNodes[0], child);
assert_equals(parent.childNodes[1], x);
assert_equals(parent.childNodes[2].textContent, 'text');
}, nodeName + '.append() with one element and text as argument, on a parent having a child.');
test(function() {
var parent = node.cloneNode();
var doc2 = document.implementation.createDocument("http:
assert_throws_dom('<API key>', () => { parent.append(doc2, "foo") });
assert_equals(parent.firstChild, null);
}, nodeName + '.append() with a Document as an argument should throw.');
}
test_append(document.createElement('div'), 'Element');
test_append(document.<API key>(), 'DocumentFrgment');
</script>
</html> |
#include "services/device/public/cpp/bluetooth/<API key>.h"
namespace mojo {
// static
bool StructTraits<
device::mojom::<API key>,
std::array<uint8_t, 6>>::Read(device::mojom::<API key> data,
std::array<uint8_t, 6>* out_address) {
ArrayDataView<uint8_t> address;
data.GetAddressDataView(&address);
if (address.is_null())
return false;
// The size is validated by the generated validation code.
DCHECK_EQ(6u, address.size());
std::copy_n(address.data(), 6, std::begin(*out_address));
return true;
}
} // namespace mojo |
#include "content/browser/renderer_host/input/<API key>.h"
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "content/browser/renderer_host/input/synthetic_gesture.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/input/<API key>.h"
#include "content/browser/renderer_host/<API key>.h"
#include "content/common/input/<API key>.h"
#include "content/common/input/<API key>.h"
#include "content/common/input/<API key>.h"
#include "content/common/input/<API key>.h"
#include "content/public/test/<API key>.h"
#include "content/public/test/<API key>.h"
#include "content/test/<API key>.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/geometry/vector2d_f.h"
using blink::WebInputEvent;
using blink::WebMouseEvent;
using blink::WebMouseWheelEvent;
using blink::WebTouchEvent;
using blink::WebTouchPoint;
namespace content {
namespace {
const int kFlushInputRateInMs = 16;
const int <API key> = 43;
const float kTouchSlopInDips = 7.0f;
const float <API key> = 27.5f;
const int <API key> = 16;
enum TouchGestureType { TOUCH_SCROLL, TOUCH_DRAG };
class <API key> : public SyntheticGesture {
public:
<API key>(bool* finished, int num_steps)
: finished_(finished),
num_steps_(num_steps),
step_count_(0) {
*finished_ = false;
}
~<API key>() override {}
Result ForwardInputEvents(const base::TimeTicks& timestamp,
<API key>* target) override {
step_count_++;
if (step_count_ == num_steps_) {
*finished_ = true;
return SyntheticGesture::GESTURE_FINISHED;
} else if (step_count_ > num_steps_) {
*finished_ = true;
// Return arbitrary failure.
return SyntheticGesture::<API key>;
}
return SyntheticGesture::GESTURE_RUNNING;
}
protected:
bool* finished_;
int num_steps_;
int step_count_;
};
class <API key> : public <API key> {
public:
<API key>()
: flush_requested_(false),
<API key>(<API key>) {}
~<API key>() override {}
// <API key>:
void <API key>(const WebInputEvent& event) override {}
void SetNeedsFlush() override { flush_requested_ = true; }
<API key>::GestureSourceType
<API key>() const override {
return <API key>::TOUCH_INPUT;
}
base::TimeDelta <API key>() const override {
return base::TimeDelta::FromMilliseconds(<API key>);
}
void <API key>(int time_ms) {
<API key> = time_ms;
}
float GetTouchSlopInDips() const override { return kTouchSlopInDips; }
float <API key>() const override {
return <API key>;
}
bool flush_requested() const { return flush_requested_; }
void ClearFlushRequest() { flush_requested_ = false; }
private:
bool flush_requested_;
int <API key>;
};
class <API key> : public <API key> {
public:
<API key>() : <API key>(0) {}
~<API key>() override {}
gfx::Vector2dF <API key>() const {
return <API key>;
}
float <API key>() const {
return <API key>;
}
protected:
gfx::Vector2dF <API key>;
float <API key>;
};
class <API key> : public <API key> {
public:
<API key>() {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_EQ(event.type, WebInputEvent::MouseWheel);
const WebMouseWheelEvent& mouse_wheel_event =
static_cast<const WebMouseWheelEvent&>(event);
gfx::Vector2dF delta(mouse_wheel_event.deltaX, mouse_wheel_event.deltaY);
<API key> += delta;
<API key> += delta.Length();
}
};
class MockMoveTouchTarget : public <API key> {
public:
MockMoveTouchTarget() : started_(false) {}
~MockMoveTouchTarget() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
ASSERT_EQ(touch_event.touchesLength, 1U);
if (!started_) {
ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
start_.SetPoint(touch_event.touches[0].position.x,
touch_event.touches[0].position.y);
last_touch_point_ = gfx::PointF(start_);
started_ = true;
} else {
ASSERT_NE(touch_event.type, WebInputEvent::TouchStart);
ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel);
gfx::PointF touch_point(touch_event.touches[0].position.x,
touch_event.touches[0].position.y);
gfx::Vector2dF delta = touch_point - last_touch_point_;
<API key> += delta.Length();
if (touch_event.type == WebInputEvent::TouchEnd)
<API key> = touch_point - gfx::PointF(start_);
last_touch_point_ = touch_point;
}
}
protected:
gfx::Point start_;
gfx::PointF last_touch_point_;
bool started_;
};
class MockDragMouseTarget : public <API key> {
public:
MockDragMouseTarget() : started_(false) {}
~MockDragMouseTarget() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
if (!started_) {
EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft);
EXPECT_EQ(mouse_event.clickCount, 1);
EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown);
start_.SetPoint(mouse_event.x, mouse_event.y);
last_mouse_point_ = start_;
started_ = true;
} else {
EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft);
ASSERT_NE(mouse_event.type, WebInputEvent::MouseDown);
gfx::PointF mouse_point(mouse_event.x, mouse_event.y);
gfx::Vector2dF delta = mouse_point - last_mouse_point_;
<API key> += delta.Length();
if (mouse_event.type == WebInputEvent::MouseUp)
<API key> = mouse_point - start_;
last_mouse_point_ = mouse_point;
}
}
private:
bool started_;
gfx::PointF start_, last_mouse_point_;
};
class <API key>
: public <API key> {
public:
enum ZoomDirection {
<API key>,
ZOOM_IN,
ZOOM_OUT
};
<API key>()
: <API key>(0),
<API key>(0),
zoom_direction_(<API key>),
started_(false) {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
ASSERT_EQ(touch_event.touchesLength, 2U);
if (!started_) {
ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart);
start_0_ = gfx::PointF(touch_event.touches[0].position);
start_1_ = gfx::PointF(touch_event.touches[1].position);
<API key> = (start_0_ - start_1_).Length();
<API key> = <API key>;
EXPECT_GE(<API key>, <API key>());
started_ = true;
} else {
ASSERT_NE(touch_event.type, WebInputEvent::TouchStart);
ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel);
gfx::PointF current_0 = gfx::PointF(touch_event.touches[0].position);
gfx::PointF current_1 = gfx::PointF(touch_event.touches[1].position);
float pointer_distance = (current_0 - current_1).Length();
if (<API key> != pointer_distance) {
if (zoom_direction_ == <API key>)
zoom_direction_ =
<API key>(<API key>, pointer_distance);
else
EXPECT_EQ(
zoom_direction_,
<API key>(<API key>, pointer_distance));
}
<API key> = pointer_distance;
}
}
<API key>::GestureSourceType
<API key>() const override {
return <API key>::TOUCH_INPUT;
}
ZoomDirection zoom_direction() const { return zoom_direction_; }
float ComputeScaleFactor() const {
switch (zoom_direction_) {
case ZOOM_IN:
return <API key> /
(<API key> + 2 * GetTouchSlopInDips());
case ZOOM_OUT:
return <API key> /
(<API key> - 2 * GetTouchSlopInDips());
case <API key>:
return 1.0f;
default:
NOTREACHED();
return 0.0f;
}
}
private:
ZoomDirection <API key>(float <API key>,
float <API key>) {
DCHECK_NE(<API key>, <API key>);
return <API key> < <API key> ? ZOOM_IN
: ZOOM_OUT;
}
float <API key>;
float <API key>;
ZoomDirection zoom_direction_;
gfx::PointF start_0_;
gfx::PointF start_1_;
bool started_;
};
class <API key>
: public <API key> {
public:
enum ZoomDirection { <API key>, ZOOM_IN, ZOOM_OUT };
<API key>()
: zoom_direction_(<API key>),
started_(false),
ended_(false),
scale_factor_(1.0f) {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
EXPECT_TRUE(WebInputEvent::isGestureEventType(event.type));
const blink::WebGestureEvent& gesture_event =
static_cast<const blink::WebGestureEvent&>(event);
if (gesture_event.type == WebInputEvent::GesturePinchBegin) {
EXPECT_FALSE(started_);
EXPECT_FALSE(ended_);
started_ = true;
} else if (gesture_event.type == WebInputEvent::GesturePinchEnd) {
EXPECT_TRUE(started_);
EXPECT_FALSE(ended_);
ended_ = true;
} else {
EXPECT_EQ(WebInputEvent::GesturePinchUpdate, gesture_event.type);
EXPECT_TRUE(started_);
EXPECT_FALSE(ended_);
const float scale = gesture_event.data.pinchUpdate.scale;
if (scale != 1.0f) {
if (zoom_direction_ == <API key>) {
zoom_direction_ = scale > 1.0f ? ZOOM_IN : ZOOM_OUT;
} else if (zoom_direction_ == ZOOM_IN) {
EXPECT_GT(scale, 1.0f);
} else {
EXPECT_EQ(ZOOM_OUT, zoom_direction_);
EXPECT_LT(scale, 1.0f);
}
scale_factor_ *= scale;
}
}
}
<API key>::GestureSourceType
<API key>() const override {
return <API key>::MOUSE_INPUT;
}
ZoomDirection zoom_direction() const { return zoom_direction_; }
float scale_factor() const { return scale_factor_; }
private:
ZoomDirection zoom_direction_;
bool started_;
bool ended_;
float scale_factor_;
};
class <API key> : public <API key> {
public:
<API key>() : state_(NOT_STARTED) {}
~<API key>() override {}
bool GestureFinished() const { return state_ == FINISHED; }
gfx::PointF position() const { return position_; }
base::TimeDelta GetDuration() const { return stop_time_ - start_time_; }
protected:
enum GestureState {
NOT_STARTED,
STARTED,
FINISHED
};
gfx::PointF position_;
base::TimeDelta start_time_;
base::TimeDelta stop_time_;
GestureState state_;
};
class <API key> : public <API key> {
public:
<API key>() {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
ASSERT_EQ(touch_event.touchesLength, 1U);
switch (state_) {
case NOT_STARTED:
EXPECT_EQ(touch_event.type, WebInputEvent::TouchStart);
position_ = gfx::PointF(touch_event.touches[0].position);
start_time_ = base::TimeDelta::FromMilliseconds(
static_cast<int64_t>(touch_event.timeStampSeconds * 1000));
state_ = STARTED;
break;
case STARTED:
EXPECT_EQ(touch_event.type, WebInputEvent::TouchEnd);
EXPECT_EQ(position_, gfx::PointF(touch_event.touches[0].position));
stop_time_ = base::TimeDelta::FromMilliseconds(
static_cast<int64_t>(touch_event.timeStampSeconds * 1000));
state_ = FINISHED;
break;
case FINISHED:
EXPECT_FALSE(true);
break;
}
}
};
class <API key> : public <API key> {
public:
<API key>() {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
switch (state_) {
case NOT_STARTED:
EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown);
EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft);
EXPECT_EQ(mouse_event.clickCount, 1);
position_ = gfx::PointF(mouse_event.x, mouse_event.y);
start_time_ = base::TimeDelta::FromMilliseconds(
static_cast<int64_t>(mouse_event.timeStampSeconds * 1000));
state_ = STARTED;
break;
case STARTED:
EXPECT_EQ(mouse_event.type, WebInputEvent::MouseUp);
EXPECT_EQ(mouse_event.button, WebMouseEvent::ButtonLeft);
EXPECT_EQ(mouse_event.clickCount, 1);
EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y));
stop_time_ = base::TimeDelta::FromMilliseconds(
static_cast<int64_t>(mouse_event.timeStampSeconds * 1000));
state_ = FINISHED;
break;
case FINISHED:
EXPECT_FALSE(true);
break;
}
}
};
class <API key> : public <API key> {
public:
<API key>() {}
~<API key>() override {}
gfx::PointF positions(int index) const { return positions_[index]; }
int indexes(int index) const { return indexes_[index]; }
WebTouchPoint::State states(int index) { return states_[index]; }
unsigned touch_length() const { return touch_length_; }
WebInputEvent::Type type() const { return type_; }
protected:
gfx::PointF positions_[<API key>];
unsigned touch_length_;
int indexes_[<API key>];
WebTouchPoint::State states_[<API key>];
WebInputEvent::Type type_;
};
class <API key>
: public <API key> {
public:
<API key>() {}
~<API key>() override {}
void <API key>(const WebInputEvent& event) override {
ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type));
const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
type_ = touch_event.type;
for (size_t i = 0; i < touch_event.touchesLength; ++i) {
indexes_[i] = touch_event.touches[i].id;
positions_[i] = gfx::PointF(touch_event.touches[i].position);
states_[i] = touch_event.touches[i].state;
}
touch_length_ = touch_event.touchesLength;
}
};
class <API key> {
public:
<API key>() {}
~<API key>() {}
protected:
template<typename MockGestureTarget>
void <API key>() {
target_ = new MockGestureTarget();
controller_.reset(new <API key>(
scoped_ptr<<API key>>(target_)));
}
void <API key>(scoped_ptr<SyntheticGesture> gesture) {
controller_-><API key>(
std::move(gesture),
base::Bind(
&<API key>::<API key>,
base::Unretained(this)));
}
void <API key>() {
while (target_->flush_requested()) {
while (target_->flush_requested()) {
target_->ClearFlushRequest();
time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
controller_->Flush(time_);
}
controller_->OnDidFlushInput();
}
}
void <API key>(SyntheticGesture::Result result) {
DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING);
if (result == SyntheticGesture::GESTURE_FINISHED)
num_success_++;
else
num_failure_++;
}
base::TimeDelta GetTotalTime() const { return time_ - start_time_; }
<API key>* target_;
scoped_ptr<<API key>> controller_;
base::TimeTicks start_time_;
base::TimeTicks time_;
int num_success_;
int num_failure_;
};
class <API key>
: public <API key>,
public testing::Test {
protected:
void SetUp() override {
start_time_ = base::TimeTicks::Now();
time_ = start_time_;
num_success_ = 0;
num_failure_ = 0;
}
void TearDown() override {
controller_.reset();
target_ = nullptr;
time_ = base::TimeTicks();
}
};
class <API key>
: public <API key>,
public testing::TestWithParam<bool> {
protected:
void SetUp() override {
start_time_ = base::TimeTicks::Now();
time_ = start_time_;
num_success_ = 0;
num_failure_ = 0;
}
void TearDown() override {
controller_.reset();
target_ = nullptr;
time_ = base::TimeTicks();
}
};
TEST_F(<API key>, SingleGesture) {
<API key><<API key>>();
bool finished = false;
scoped_ptr<<API key>> gesture(
new <API key>(&finished, 3));
<API key>(std::move(gesture));
<API key>();
EXPECT_TRUE(finished);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
}
TEST_F(<API key>, GestureFailed) {
<API key><<API key>>();
bool finished = false;
scoped_ptr<<API key>> gesture(
new <API key>(&finished, 0));
<API key>(std::move(gesture));
<API key>();
EXPECT_TRUE(finished);
EXPECT_EQ(1, num_failure_);
EXPECT_EQ(0, num_success_);
}
TEST_F(<API key>, SuccessiveGestures) {
<API key><<API key>>();
bool finished_1 = false;
scoped_ptr<<API key>> gesture_1(
new <API key>(&finished_1, 2));
bool finished_2 = false;
scoped_ptr<<API key>> gesture_2(
new <API key>(&finished_2, 4));
// Queue first gesture and wait for it to finish
<API key>(std::move(gesture_1));
<API key>();
EXPECT_TRUE(finished_1);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
// Queue second gesture.
<API key>(std::move(gesture_2));
<API key>();
EXPECT_TRUE(finished_2);
EXPECT_EQ(2, num_success_);
EXPECT_EQ(0, num_failure_);
}
TEST_F(<API key>, TwoGesturesInFlight) {
<API key><<API key>>();
bool finished_1 = false;
scoped_ptr<<API key>> gesture_1(
new <API key>(&finished_1, 2));
bool finished_2 = false;
scoped_ptr<<API key>> gesture_2(
new <API key>(&finished_2, 4));
<API key>(std::move(gesture_1));
<API key>(std::move(gesture_2));
<API key>();
EXPECT_TRUE(finished_1);
EXPECT_TRUE(finished_2);
EXPECT_EQ(2, num_success_);
EXPECT_EQ(0, num_failure_);
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
bool finished_1, finished_2;
scoped_ptr<<API key>> gesture_1(
new <API key>(&finished_1, 2));
scoped_ptr<<API key>> gesture_2(
new <API key>(&finished_2, 4));
<API key>(std::move(gesture_1));
<API key>(std::move(gesture_2));
while (target_->flush_requested()) {
target_->ClearFlushRequest();
time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
controller_->Flush(time_);
}
EXPECT_EQ(0, num_success_);
controller_->OnDidFlushInput();
EXPECT_EQ(1, num_success_);
while (target_->flush_requested()) {
target_->ClearFlushRequest();
time_ += base::TimeDelta::FromMilliseconds(kFlushInputRateInMs);
controller_->Flush(time_);
}
EXPECT_EQ(1, num_success_);
controller_->OnDidFlushInput();
EXPECT_EQ(2, num_success_);
}
gfx::Vector2d <API key>(const gfx::Vector2dF& vector,
<API key>* target) {
const int kTouchSlop = target->GetTouchSlopInDips();
int x = vector.x();
if (x > 0)
x += kTouchSlop;
else if (x < 0)
x -= kTouchSlop;
int y = vector.y();
if (y > 0)
y += kTouchSlop;
else if (y < 0)
y -= kTouchSlop;
return gfx::Vector2d(x, y);
}
TEST_P(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
if (GetParam() == TOUCH_DRAG) {
params.add_slop = false;
}
params.start_point.SetPoint(89, 32);
params.distances.push_back(gfx::Vector2d(0, 123));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
if (GetParam() == TOUCH_SCROLL) {
EXPECT_EQ(<API key>(params.distances[0], target_),
scroll_target-><API key>());
} else {
EXPECT_EQ(params.distances[0], scroll_target-><API key>());
}
}
TEST_P(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
if (GetParam() == TOUCH_DRAG) {
params.add_slop = false;
}
params.start_point.SetPoint(12, -23);
params.distances.push_back(gfx::Vector2d(-234, 0));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
if (GetParam() == TOUCH_SCROLL) {
EXPECT_EQ(<API key>(params.distances[0], target_),
scroll_target-><API key>());
} else {
EXPECT_EQ(params.distances[0], scroll_target-><API key>());
}
}
void <API key>(float scroll_distance,
int target_distance,
<API key>* target) {
if (target_distance > 0) {
EXPECT_LE(target_distance, scroll_distance);
EXPECT_LE(scroll_distance, target_distance + target->GetTouchSlopInDips());
} else {
EXPECT_GE(target_distance, scroll_distance);
EXPECT_GE(scroll_distance, target_distance - target->GetTouchSlopInDips());
}
}
void <API key>(
const gfx::Vector2dF& scroll_distance,
const gfx::Vector2dF& target_distance,
<API key>* target) {
<API key>(scroll_distance.x(), target_distance.x(), target);
<API key>(scroll_distance.y(), target_distance.y(), target);
}
TEST_F(<API key>, <API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
params.start_point.SetPoint(0, 7);
params.distances.push_back(gfx::Vector2d(413, -83));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
<API key>(
scroll_target-><API key>(), params.distances[0], target_);
}
TEST_F(<API key>, <API key>) {
<API key><MockMoveTouchTarget>();
// Create a smooth scroll with a short distance and set the pointer assumed
// stopped time high, so that the stopping should dominate the time the
// gesture is active.
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
params.start_point.SetPoint(-98, -23);
params.distances.push_back(gfx::Vector2d(21, -12));
params.prevent_fling = true;
target_-><API key>(543);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
<API key>(
scroll_target-><API key>(), params.distances[0], target_);
EXPECT_GE(GetTotalTime(), target_-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><MockMoveTouchTarget>();
// Create a smooth scroll with a short distance and set the pointer assumed
// stopped time high. Disable 'prevent_fling' and check that the gesture
// finishes without waiting before it stops.
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
params.start_point.SetPoint(-89, 78);
params.distances.push_back(gfx::Vector2d(-43, 19));
params.prevent_fling = false;
target_-><API key>(543);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
<API key>(
scroll_target-><API key>(), params.distances[0], target_);
EXPECT_LE(GetTotalTime(), target_-><API key>());
}
TEST_P(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
if (GetParam() == TOUCH_DRAG) {
params.add_slop = false;
}
params.start_point.SetPoint(-32, 43);
params.distances.push_back(gfx::Vector2d(0, 0));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.input_type = <API key>::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(432, 89);
params.distances.push_back(gfx::Vector2d(0, -234));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.distances[0], scroll_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.input_type = <API key>::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(90, 12);
params.distances.push_back(gfx::Vector2d(345, 0));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.distances[0], scroll_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.input_type = <API key>::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(90, 12);
params.distances.push_back(gfx::Vector2d(-194, 303));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.distances[0], scroll_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.input_type = <API key>::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(90, 12);
params.distances.push_back(gfx::Vector2d(-129, 212));
params.distances.push_back(gfx::Vector2d(8, -9));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.distances[0] + params.distances[1],
scroll_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.input_type = <API key>::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(90, 12);
params.distances.push_back(gfx::Vector2d(-129, 0));
params.distances.push_back(gfx::Vector2d(79, 0));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
// This check only works for horizontal or vertical scrolls because of
// floating point precision issues with diagonal scrolls.
EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(),
scroll_target-><API key>());
EXPECT_EQ(params.distances[0] + params.distances[1],
scroll_target-><API key>());
}
void <API key>(float scroll_distance,
int target_distance,
<API key>* target) {
if (target_distance > 0) {
EXPECT_GE(scroll_distance, target_distance - target->GetTouchSlopInDips());
EXPECT_LE(scroll_distance, target_distance + target->GetTouchSlopInDips());
} else {
EXPECT_LE(scroll_distance, target_distance + target->GetTouchSlopInDips());
EXPECT_GE(scroll_distance, target_distance - target->GetTouchSlopInDips());
}
}
void <API key>(
const gfx::Vector2dF& scroll_distance,
const gfx::Vector2dF& target_distance,
<API key>* target) {
<API key>(scroll_distance.x(), target_distance.x(), target);
<API key>(scroll_distance.y(), target_distance.y(), target);
}
TEST_F(<API key>, <API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
params.start_point.SetPoint(8, -13);
params.distances.push_back(gfx::Vector2d(234, 133));
params.distances.push_back(gfx::Vector2d(-9, 78));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
<API key>(
scroll_target-><API key>(),
params.distances[0] + params.distances[1],
target_);
}
TEST_P(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.input_type = <API key>::TOUCH_INPUT;
if (GetParam() == TOUCH_DRAG) {
params.add_slop = false;
}
params.start_point.SetPoint(234, -13);
params.distances.push_back(gfx::Vector2d(0, 133));
params.distances.push_back(gfx::Vector2d(0, 78));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* scroll_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
if (GetParam() == TOUCH_SCROLL) {
EXPECT_FLOAT_EQ(params.distances[0].Length() +
params.distances[1].Length() +
target_->GetTouchSlopInDips(),
scroll_target-><API key>());
EXPECT_EQ(<API key>(params.distances[0] + params.distances[1],
target_),
scroll_target-><API key>());
} else {
EXPECT_FLOAT_EQ(params.distances[0].Length() + params.distances[1].Length(),
scroll_target-><API key>());
EXPECT_EQ(params.distances[0] + params.distances[1],
scroll_target-><API key>());
}
}
<API key>(Single,
<API key>,
testing::Values(TOUCH_SCROLL, TOUCH_DRAG));
TEST_F(<API key>, <API key>) {
<API key><MockDragMouseTarget>();
<API key> params;
params.input_type = <API key>::MOUSE_DRAG_INPUT;
params.start_point.SetPoint(0, 7);
params.distances.push_back(gfx::Vector2d(413, -83));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* drag_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(drag_target-><API key>(), params.distances[0]);
}
TEST_F(<API key>, <API key>) {
<API key><MockDragMouseTarget>();
<API key> params;
params.input_type = <API key>::MOUSE_DRAG_INPUT;
params.start_point.SetPoint(-32, 43);
params.distances.push_back(gfx::Vector2d(0, 0));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* drag_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(gfx::Vector2dF(0, 0), drag_target-><API key>());
}
TEST_F(<API key>, <API key>) {
<API key><MockDragMouseTarget>();
<API key> params;
params.input_type = <API key>::MOUSE_DRAG_INPUT;
params.start_point.SetPoint(8, -13);
params.distances.push_back(gfx::Vector2d(234, 133));
params.distances.push_back(gfx::Vector2d(-9, 78));
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* drag_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(drag_target-><API key>(),
params.distances[0] + params.distances[1]);
}
TEST_F(<API key>,
<API key>) {
<API key><MockDragMouseTarget>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.distances.push_back(gfx::Vector2d(234, 133));
params.speed_in_pixels_s = 800;
scoped_ptr<<API key>> gesture(
new <API key>(params));
const base::TimeTicks timestamp;
gesture->ForwardInputEvents(timestamp, target_);
}
TEST_F(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.start_point.SetPoint(89, 32);
params.distances.push_back(gfx::Vector2d(0, 123));
params.speed_in_pixels_s = 800;
scoped_ptr<<API key>> gesture(
new <API key>(params));
const base::TimeTicks timestamp;
gesture->ForwardInputEvents(timestamp, target_);
}
TEST_F(<API key>,
<API key>) {
<API key><MockMoveTouchTarget>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
scoped_ptr<<API key>> gesture(
new <API key>(params));
const base::TimeTicks timestamp;
gesture->ForwardInputEvents(timestamp, target_);
}
TEST_F(<API key>,
<API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.anchor.SetPoint(432, 89);
params.distances.push_back(gfx::Vector2d(0, -234));
params.speed_in_pixels_s = 800;
scoped_ptr<<API key>> gesture(
new <API key>(params));
const base::TimeTicks timestamp;
gesture->ForwardInputEvents(timestamp, target_);
}
TEST_F(<API key>,
<API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::ZOOM_IN);
EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
}
TEST_F(<API key>,
<API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.scale_factor = 0.4f;
params.anchor.SetPoint(-12, 93);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::ZOOM_OUT);
EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
}
TEST_F(<API key>,
<API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.scale_factor = 1.0f;
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::<API key>);
EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::ZOOM_IN);
EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.scale_factor = 0.4f;
params.anchor.SetPoint(-12, 93);
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::ZOOM_OUT);
EXPECT_FLOAT_EQ(params.scale_factor, pinch_target->scale_factor());
}
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.scale_factor = 1.0f;
scoped_ptr<<API key>> gesture(
new <API key>(params));
<API key>(std::move(gesture));
<API key>();
<API key>* pinch_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pinch_target->zoom_direction(),
<API key>::<API key>);
EXPECT_EQ(params.scale_factor, pinch_target->scale_factor());
}
// Ensure that if <API key> is instantiated with TOUCH_INPUT it
// correctly creates a touchscreen gesture.
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(new <API key>(params));
<API key>(std::move(gesture));
<API key>();
// Gesture target will fail expectations if the wrong underlying
// SyntheticPinch*Gesture was instantiated.
}
// Ensure that if <API key> is instantiated with MOUSE_INPUT it
// correctly creates a touchpad gesture.
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(new <API key>(params));
<API key>(std::move(gesture));
<API key>();
// Gesture target will fail expectations if the wrong underlying
// SyntheticPinch*Gesture was instantiated.
}
// Ensure that if <API key> is instantiated with DEFAULT_INPUT it
// correctly creates a touchscreen gesture for a touchscreen controller.
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::DEFAULT_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(new <API key>(params));
<API key>(std::move(gesture));
<API key>();
// Gesture target will fail expectations if the wrong underlying
// SyntheticPinch*Gesture was instantiated.
}
// Ensure that if <API key> is instantiated with DEFAULT_INPUT it
// correctly creates a touchpad gesture for a touchpad controller.
TEST_F(<API key>, <API key>) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::DEFAULT_INPUT;
params.scale_factor = 2.3f;
params.anchor.SetPoint(54, 89);
scoped_ptr<<API key>> gesture(new <API key>(params));
<API key>(std::move(gesture));
<API key>();
// Gesture target will fail expectations if the wrong underlying
// SyntheticPinch*Gesture was instantiated.
}
TEST_F(<API key>, TapGestureTouch) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::TOUCH_INPUT;
params.duration_ms = 123;
params.position.SetPoint(87, -124);
scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
<API key>(std::move(gesture));
<API key>();
<API key>* tap_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_TRUE(tap_target->GestureFinished());
EXPECT_EQ(tap_target->position(), params.position);
EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
EXPECT_GE(GetTotalTime(),
base::TimeDelta::FromMilliseconds(params.duration_ms));
}
TEST_F(<API key>, TapGestureMouse) {
<API key><<API key>>();
<API key> params;
params.gesture_source_type = <API key>::MOUSE_INPUT;
params.duration_ms = 79;
params.position.SetPoint(98, 123);
scoped_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
<API key>(std::move(gesture));
<API key>();
<API key>* tap_target =
static_cast<<API key>*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_TRUE(tap_target->GestureFinished());
EXPECT_EQ(tap_target->position(), params.position);
EXPECT_EQ(tap_target->GetDuration().InMilliseconds(), params.duration_ms);
EXPECT_GE(GetTotalTime(),
base::TimeDelta::FromMilliseconds(params.duration_ms));
}
TEST_F(<API key>, PointerTouchAction) {
<API key><<API key>>();
<API key> synthetic_pointer;
gfx::PointF position(54, 89);
scoped_ptr<<API key>> gesture(new <API key>(
<API key>::TOUCH_INPUT, SyntheticGesture::PRESS,
&synthetic_pointer, position));
<API key>(std::move(gesture));
<API key>();
<API key>* <API key> =
static_cast<<API key>*>(target_);
EXPECT_EQ(<API key>->type(), WebInputEvent::TouchStart);
EXPECT_EQ(<API key>->positions(0), position);
EXPECT_EQ(<API key>->states(0), WebTouchPoint::StatePressed);
ASSERT_EQ(<API key>->touch_length(), 1U);
position.SetPoint(79, 132);
gesture.reset(new <API key>(<API key>::TOUCH_INPUT,
SyntheticGesture::PRESS,
&synthetic_pointer, position));
<API key>(std::move(gesture));
<API key>();
<API key> =
static_cast<<API key>*>(target_);
EXPECT_EQ(<API key>->type(), WebInputEvent::TouchStart);
EXPECT_EQ(<API key>->indexes(1), 1);
EXPECT_EQ(<API key>->positions(1), position);
EXPECT_EQ(<API key>->states(1), WebTouchPoint::StatePressed);
ASSERT_EQ(<API key>->touch_length(), 2U);
int index = 1;
position.SetPoint(133, 156);
gesture.reset(new <API key>(
<API key>::TOUCH_INPUT, SyntheticGesture::MOVE,
&synthetic_pointer, position, index));
<API key>(std::move(gesture));
<API key>();
<API key> =
static_cast<<API key>*>(target_);
EXPECT_EQ(<API key>->type(), WebInputEvent::TouchMove);
EXPECT_EQ(<API key>->positions(1), position);
EXPECT_EQ(<API key>->states(1), WebTouchPoint::StateMoved);
ASSERT_EQ(<API key>->touch_length(), 2U);
gesture.reset(new <API key>(
<API key>::TOUCH_INPUT, SyntheticGesture::RELEASE,
&synthetic_pointer, position, index));
<API key>(std::move(gesture));
<API key>();
<API key> =
static_cast<<API key>*>(target_);
EXPECT_EQ(<API key>->type(), WebInputEvent::TouchEnd);
EXPECT_EQ(<API key>->states(1), WebTouchPoint::StateReleased);
}
} // namespace
} // namespace content |
// flow-typed signature: <API key>
// @flow
declare module 'styled-components' {
declare type Interpolation = ((executionContext: Object) => string) | string | number;
declare type NameGenerator = (hash: number) => string
declare type StyledComponent = (
strings: Array<string>,
interpolations: Array<Interpolation>
) => ReactClass<*>;
declare type Theme = {[key: string]: mixed};
declare type ThemeProviderProps = {
theme: ((outerTheme: Theme) => void) | Theme
};
declare type Component =
| React$Component<*, *, *>
| (props: *) => React$Element<*>;
declare class ThemeProvider extends React$Component {
props: ThemeProviderProps;
}
declare module.exports: {
injectGlobal: (strings: Array<string>, ...interpolations: Array<Interpolation>) => void,
css: (strings: Array<string>, ...interpolations: Array<Interpolation>) => Array<Interpolation>,
keyframes: (strings: Array<string>, ...interpolations: Array<Interpolation>) => string,
withTheme: (component: Component) => React$Component<*, ThemeProviderProps, *>,
ThemeProvider: typeof ThemeProvider,
(baseComponent: Component): StyledComponent,
a: StyledComponent,
abbr: StyledComponent,
address: StyledComponent,
area: StyledComponent,
article: StyledComponent,
aside: StyledComponent,
audio: StyledComponent,
b: StyledComponent,
base: StyledComponent,
bdi: StyledComponent,
bdo: StyledComponent,
big: StyledComponent,
blockquote: StyledComponent,
body: StyledComponent,
br: StyledComponent,
button: StyledComponent,
canvas: StyledComponent,
caption: StyledComponent,
cite: StyledComponent,
code: StyledComponent,
col: StyledComponent,
colgroup: StyledComponent,
data: StyledComponent,
datalist: StyledComponent,
dd: StyledComponent,
del: StyledComponent,
details: StyledComponent,
dfn: StyledComponent,
dialog: StyledComponent,
div: StyledComponent,
dl: StyledComponent,
dt: StyledComponent,
em: StyledComponent,
embed: StyledComponent,
fieldset: StyledComponent,
figcaption: StyledComponent,
figure: StyledComponent,
footer: StyledComponent,
form: StyledComponent,
h1: StyledComponent,
h2: StyledComponent,
h3: StyledComponent,
h4: StyledComponent,
h5: StyledComponent,
h6: StyledComponent,
head: StyledComponent,
header: StyledComponent,
hgroup: StyledComponent,
hr: StyledComponent,
html: StyledComponent,
i: StyledComponent,
iframe: StyledComponent,
img: StyledComponent,
input: StyledComponent,
ins: StyledComponent,
kbd: StyledComponent,
keygen: StyledComponent,
label: StyledComponent,
legend: StyledComponent,
li: StyledComponent,
link: StyledComponent,
main: StyledComponent,
map: StyledComponent,
mark: StyledComponent,
menu: StyledComponent,
menuitem: StyledComponent,
meta: StyledComponent,
meter: StyledComponent,
nav: StyledComponent,
noscript: StyledComponent,
object: StyledComponent,
ol: StyledComponent,
optgroup: StyledComponent,
option: StyledComponent,
output: StyledComponent,
p: StyledComponent,
param: StyledComponent,
picture: StyledComponent,
pre: StyledComponent,
progress: StyledComponent,
q: StyledComponent,
rp: StyledComponent,
rt: StyledComponent,
ruby: StyledComponent,
s: StyledComponent,
samp: StyledComponent,
script: StyledComponent,
section: StyledComponent,
select: StyledComponent,
small: StyledComponent,
source: StyledComponent,
span: StyledComponent,
strong: StyledComponent,
style: StyledComponent,
sub: StyledComponent,
summary: StyledComponent,
sup: StyledComponent,
table: StyledComponent,
tbody: StyledComponent,
td: StyledComponent,
textarea: StyledComponent,
tfoot: StyledComponent,
th: StyledComponent,
thead: StyledComponent,
time: StyledComponent,
title: StyledComponent,
tr: StyledComponent,
track: StyledComponent,
u: StyledComponent,
ul: StyledComponent,
var: StyledComponent,
video: StyledComponent,
wbr: StyledComponent,
// SVG
circle: StyledComponent,
clipPath: StyledComponent,
defs: StyledComponent,
ellipse: StyledComponent,
g: StyledComponent,
image: StyledComponent,
line: StyledComponent,
linearGradient: StyledComponent,
mask: StyledComponent,
path: StyledComponent,
pattern: StyledComponent,
polygon: StyledComponent,
polyline: StyledComponent,
radialGradient: StyledComponent,
rect: StyledComponent,
stop: StyledComponent,
svg: StyledComponent,
text: StyledComponent,
tspan: StyledComponent,
};
} |
<?php
namespace CrEOF\Spatial\ORM\Query\AST\Functions\PostgreSql;
use CrEOF\Spatial\ORM\Query\AST\Functions\<API key>;
class STAzimuth extends <API key>
{
protected $platforms = array('postgresql');
protected $functionName = 'ST_Azimuth';
protected $minGeomExpr = 2;
protected $maxGeomExpr = 2;
} |
// This file was generated by counterfeiter
package appfilesfakes
import (
"sync"
"code.cloudfoundry.org/cli/cf/api/appfiles"
)
type <API key> struct {
ListFilesStub func(appGUID string, instance int, path string) (files string, apiErr error)
listFilesMutex sync.RWMutex
<API key> []struct {
appGUID string
instance int
path string
}
listFilesReturns struct {
result1 string
result2 error
}
}
func (fake *<API key>) ListFiles(appGUID string, instance int, path string) (files string, apiErr error) {
fake.listFilesMutex.Lock()
fake.<API key> = append(fake.<API key>, struct {
appGUID string
instance int
path string
}{appGUID, instance, path})
fake.listFilesMutex.Unlock()
if fake.ListFilesStub != nil {
return fake.ListFilesStub(appGUID, instance, path)
} else {
return fake.listFilesReturns.result1, fake.listFilesReturns.result2
}
}
func (fake *<API key>) ListFilesCallCount() int {
fake.listFilesMutex.RLock()
defer fake.listFilesMutex.RUnlock()
return len(fake.<API key>)
}
func (fake *<API key>) <API key>(i int) (string, int, string) {
fake.listFilesMutex.RLock()
defer fake.listFilesMutex.RUnlock()
return fake.<API key>[i].appGUID, fake.<API key>[i].instance, fake.<API key>[i].path
}
func (fake *<API key>) ListFilesReturns(result1 string, result2 error) {
fake.ListFilesStub = nil
fake.listFilesReturns = struct {
result1 string
result2 error
}{result1, result2}
}
var _ appfiles.Repository = new(<API key>) |
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by mktables from the Unicode
# database, Version 6.1.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by core Perl only. The format and even the
# name or existence of this file are subject to change without notice. Don't
# use it directly.
return <<'END';
F900 FAFF
END |
<?php
namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use PDO;
require_once __DIR__ . '/../../TestInit.php';
class DataAccessTest extends \Doctrine\Tests\<API key>
{
static private $generated = false;
public function setUp()
{
parent::setUp();
if (self::$generated === false) {
/* @var $sm \Doctrine\DBAL\Schema\<API key> */
$table = new \Doctrine\DBAL\Schema\Table("fetch_table");
$table->addColumn('test_int', 'integer');
$table->addColumn('test_string', 'string');
$table->addColumn('test_datetime', 'datetime', array('notnull' => false));
$table->setPrimaryKey(array('test_int'));
$sm = $this->_conn->getSchemaManager();
$sm->createTable($table);
$this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10'));
self::$generated = true;
}
}
public function <API key>()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindValue(1, 1);
$stmt->bindValue(2, 'foo');
$stmt->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
}
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
}
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$rows[0] = <API key>($rows[0], \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
}
/**
* @group DBAL-228
*/
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_BOTH);
$rows[0] = <API key>($rows[0], \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]);
}
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$column = $stmt->fetchColumn();
$this->assertEquals(1, $column);
}
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = array();
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
foreach ($stmt as $row) {
$rows[] = <API key>($row, \CASE_LOWER);
}
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
}
public function <API key>()
{
$table = 'fetch_table';
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ".
"WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr);
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
}
public function <API key>()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->execute(array($paramInt, $paramStr));
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$this->assertTrue($row !== false);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
}
public function testFetchAll()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$data = $this->_conn->fetchAll($sql, array(1, 'foo'));
$this->assertEquals(1, count($data));
$row = $data[0];
$this->assertEquals(2, count($row));
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this->assertEquals('foo', $row['test_string']);
}
/**
* @group DBAL-209
*/
public function <API key>()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$data = $this->_conn->fetchAll($sql, array(1, $datetime), array(PDO::PARAM_STR, Type::DATETIME));
$this->assertEquals(1, count($data));
$row = $data[0];
$this->assertEquals(2, count($row));
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this-><API key>($datetimeString, $row['test_datetime']);
}
/**
* @group DBAL-209
* @expectedException \Doctrine\DBAL\DBALException
*/
public function <API key>()
{
if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
$this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$data = $this->_conn->fetchAll($sql, array(1, $datetime));
}
public function testFetchBoth()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$row = $this->_conn->executeQuery($sql, array(1, 'foo'))->fetch(\PDO::FETCH_BOTH);
$this->assertTrue($row !== false);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this->assertEquals('foo', $row['test_string']);
$this->assertEquals(1, $row[0]);
$this->assertEquals('foo', $row[1]);
}
public function testFetchAssoc()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$row = $this->_conn->fetchAssoc($sql, array(1, 'foo'));
$this->assertTrue($row !== false);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this->assertEquals('foo', $row['test_string']);
}
public function <API key>()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchAssoc($sql, array(1, $datetime), array(PDO::PARAM_STR, Type::DATETIME));
$this->assertTrue($row !== false);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this-><API key>($datetimeString, $row['test_datetime']);
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function <API key>()
{
if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
$this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchAssoc($sql, array(1, $datetime));
}
public function testFetchArray()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$row = $this->_conn->fetchArray($sql, array(1, 'foo'));
$this->assertEquals(1, $row[0]);
$this->assertEquals('foo', $row[1]);
}
public function <API key>()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchArray($sql, array(1, $datetime), array(PDO::PARAM_STR, Type::DATETIME));
$this->assertTrue($row !== false);
$row = <API key>($row, \CASE_LOWER);
$this->assertEquals(1, $row[0]);
$this-><API key>($datetimeString, $row[1]);
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function <API key>()
{
if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
$this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchArray($sql, array(1, $datetime));
}
public function testFetchColumn()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0);
$this->assertEquals(1, $testInt);
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1);
$this->assertEquals('foo', $testString);
}
public function <API key>()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$column = $this->_conn->fetchColumn($sql, array(1, $datetime), 1, array(PDO::PARAM_STR, Type::DATETIME));
$this->assertTrue($column !== false);
$this-><API key>($datetimeString, $column);
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function <API key>()
{
if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
$this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$column = $this->_conn->fetchColumn($sql, array(1, $datetime), 1);
}
/**
* @group DDC-697
*/
public function <API key>()
{
$sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
$stmt = $this->_conn->executeQuery($sql,
array(1 => new \DateTime('2010-01-01 10:10:10')),
array(1 => Type::DATETIME)
);
$this->assertEquals(1, $stmt->fetchColumn());
}
/**
* @group DDC-697
*/
public function <API key>()
{
$datetime = new \DateTime('2010-02-02 20:20:20');
$sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
$affectedRows = $this->_conn->executeUpdate($sql,
array(1 => 50, 2 => 'foo', 3 => $datetime),
array(1 => PDO::PARAM_INT, 2 => PDO::PARAM_STR, 3 => Type::DATETIME)
);
$this->assertEquals(1, $affectedRows);
$this->assertEquals(1, $this->_conn->executeQuery(
'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?',
array(1 => $datetime),
array(1 => Type::DATETIME)
)->fetchColumn());
}
/**
* @group DDC-697
*/
public function <API key>()
{
$sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
$stmt = $this->_conn->prepare($sql);
$stmt->bindValue(1, new \DateTime('2010-01-01 10:10:10'), Type::DATETIME);
$stmt->execute();
$this->assertEquals(1, $stmt->fetchColumn());
}
/**
* @group DBAL-78
*/
public function <API key>()
{
for ($i = 100; $i < 110; $i++) {
$this->_conn->insert('fetch_table', array('test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10'));
}
$stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int IN (?)',
array(array(100, 101, 102, 103, 104)), array(Connection::PARAM_INT_ARRAY));
$data = $stmt->fetchAll(PDO::FETCH_NUM);
$this->assertEquals(5, count($data));
$this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
$stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_string IN (?)',
array(array('foo100', 'foo101', 'foo102', 'foo103', 'foo104')), array(Connection::PARAM_STR_ARRAY));
$data = $stmt->fetchAll(PDO::FETCH_NUM);
$this->assertEquals(5, count($data));
$this->assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
}
/**
* @dataProvider <API key>
*/
public function testTrimExpression($value, $position, $char, $expectedResult)
{
$sql = 'SELECT ' .
$this->_conn->getDatabasePlatform()->getTrimExpression($value, $position, $char) . ' AS trimmed ' .
'FROM fetch_table';
$row = $this->_conn->fetchAssoc($sql);
$row = <API key>($row, CASE_LOWER);
$this->assertEquals($expectedResult, $row['trimmed']);
}
public function <API key>()
{
return array(
array('test_string', AbstractPlatform::TRIM_UNSPECIFIED, false, 'foo'),
array('test_string', AbstractPlatform::TRIM_LEADING, false, 'foo'),
array('test_string', AbstractPlatform::TRIM_TRAILING, false, 'foo'),
array('test_string', AbstractPlatform::TRIM_BOTH, false, 'foo'),
array('test_string', AbstractPlatform::TRIM_UNSPECIFIED, "'f'", 'oo'),
array('test_string', AbstractPlatform::TRIM_UNSPECIFIED, "'o'", 'f'),
array('test_string', AbstractPlatform::TRIM_UNSPECIFIED, "'.'", 'foo'),
array('test_string', AbstractPlatform::TRIM_LEADING, "'f'", 'oo'),
array('test_string', AbstractPlatform::TRIM_LEADING, "'o'", 'foo'),
array('test_string', AbstractPlatform::TRIM_LEADING, "'.'", 'foo'),
array('test_string', AbstractPlatform::TRIM_TRAILING, "'f'", 'foo'),
array('test_string', AbstractPlatform::TRIM_TRAILING, "'o'", 'f'),
array('test_string', AbstractPlatform::TRIM_TRAILING, "'.'", 'foo'),
array('test_string', AbstractPlatform::TRIM_BOTH, "'f'", 'oo'),
array('test_string', AbstractPlatform::TRIM_BOTH, "'o'", 'f'),
array('test_string', AbstractPlatform::TRIM_BOTH, "'.'", 'foo'),
array("' foo '", AbstractPlatform::TRIM_UNSPECIFIED, false, 'foo'),
array("' foo '", AbstractPlatform::TRIM_LEADING, false, 'foo '),
array("' foo '", AbstractPlatform::TRIM_TRAILING, false, ' foo'),
array("' foo '", AbstractPlatform::TRIM_BOTH, false, 'foo'),
array("' foo '", AbstractPlatform::TRIM_UNSPECIFIED, "'f'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_UNSPECIFIED, "'o'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_UNSPECIFIED, "'.'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_UNSPECIFIED, "' '", 'foo'),
array("' foo '", AbstractPlatform::TRIM_LEADING, "'f'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_LEADING, "'o'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_LEADING, "'.'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_LEADING, "' '", 'foo '),
array("' foo '", AbstractPlatform::TRIM_TRAILING, "'f'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_TRAILING, "'o'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_TRAILING, "'.'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_TRAILING, "' '", ' foo'),
array("' foo '", AbstractPlatform::TRIM_BOTH, "'f'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_BOTH, "'o'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_BOTH, "'.'", ' foo '),
array("' foo '", AbstractPlatform::TRIM_BOTH, "' '", 'foo'),
);
}
/**
* @group DDC-1014
*/
public function testDateArithmetics()
{
$p = $this->_conn->getDatabasePlatform();
$sql = 'SELECT ';
$sql .= $p-><API key>('test_datetime', $p-><API key>()) .' AS diff, ';
$sql .= $p-><API key>('test_datetime', 1) .' AS add_seconds, ';
$sql .= $p-><API key>('test_datetime', 1) .' AS sub_seconds, ';
$sql .= $p-><API key>('test_datetime', 5) .' AS add_minutes, ';
$sql .= $p-><API key>('test_datetime', 5) .' AS sub_minutes, ';
$sql .= $p-><API key>('test_datetime', 3) .' AS add_hour, ';
$sql .= $p-><API key>('test_datetime', 3) .' AS sub_hour, ';
$sql .= $p-><API key>('test_datetime', 10) .' AS add_days, ';
$sql .= $p-><API key>('test_datetime', 10) .' AS sub_days, ';
$sql .= $p-><API key>('test_datetime', 1) .' AS add_weeks, ';
$sql .= $p-><API key>('test_datetime', 1) .' AS sub_weeks, ';
$sql .= $p-><API key>('test_datetime', 2) .' AS add_month, ';
$sql .= $p-><API key>('test_datetime', 2) .' AS sub_month, ';
$sql .= $p-><API key>('test_datetime', 3) .' AS add_quarters, ';
$sql .= $p-><API key>('test_datetime', 3) .' AS sub_quarters, ';
$sql .= $p-><API key>('test_datetime', 6) .' AS add_years, ';
$sql .= $p-><API key>('test_datetime', 6) .' AS sub_years ';
$sql .= 'FROM fetch_table';
$row = $this->_conn->fetchAssoc($sql);
$row = <API key>($row, CASE_LOWER);
$diff = floor( (strtotime('2010-01-01')-time()) / 3600 / 24);
$this->assertEquals($diff, (int)$row['diff'], "Date difference should be approx. ".$diff." days.", 1);
$this->assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])), "Adding second should end up on 2010-01-01 10:10:11");
$this->assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])), "Subtracting second should end up on 2010-01-01 10:10:09");
$this->assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])), "Adding minutes should end up on 2010-01-01 10:15:10");
$this->assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])), "Subtracting minutes should end up on 2010-01-01 10:05:10");
$this->assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])), "Adding date should end up on 2010-01-01 13:10");
$this->assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])), "Subtracting date should end up on 2010-01-01 07:10");
$this->assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), "Adding date should end up on 2010-01-11");
$this->assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), "Subtracting date should end up on 2009-12-22");
$this->assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])), "Adding week should end up on 2010-01-08");
$this->assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])), "Subtracting week should end up on 2009-12-25");
$this->assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), "Adding month should end up on 2010-03-01");
$this->assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), "Substracting month should end up on 2009-11-01");
$this->assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])), "Adding quarters should end up on 2010-04-01");
$this->assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])), "Substracting quarters should end up on 2009-10-01");
$this->assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])), "Adding years should end up on 2016-01-01");
$this->assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), "Substracting years should end up on 2004-01-01");
}
public function <API key>()
{
$platform = $this->_conn->getDatabasePlatform();
$sql = 'SELECT ';
$sql .= $platform->getLocateExpression('test_string', "'oo'") .' AS locate1, ';
$sql .= $platform->getLocateExpression('test_string', "'foo'") .' AS locate2, ';
$sql .= $platform->getLocateExpression('test_string', "'bar'") .' AS locate3, ';
$sql .= $platform->getLocateExpression('test_string', 'test_string') .' AS locate4, ';
$sql .= $platform->getLocateExpression("'foo'", 'test_string') .' AS locate5, ';
$sql .= $platform->getLocateExpression("'barfoobaz'", 'test_string') .' AS locate6, ';
$sql .= $platform->getLocateExpression("'bar'", 'test_string') .' AS locate7, ';
$sql .= $platform->getLocateExpression('test_string', "'oo'", 2) .' AS locate8, ';
$sql .= $platform->getLocateExpression('test_string', "'oo'", 3) .' AS locate9 ';
$sql .= 'FROM fetch_table';
$row = $this->_conn->fetchAssoc($sql);
$row = <API key>($row, CASE_LOWER);
$this->assertEquals(2, $row['locate1']);
$this->assertEquals(1, $row['locate2']);
$this->assertEquals(0, $row['locate3']);
$this->assertEquals(1, $row['locate4']);
$this->assertEquals(1, $row['locate5']);
$this->assertEquals(4, $row['locate6']);
$this->assertEquals(0, $row['locate7']);
$this->assertEquals(2, $row['locate8']);
$this->assertEquals(0, $row['locate9']);
}
public function <API key>()
{
$sql = "SELECT * FROM fetch_table WHERE test_string = " . $this->_conn->quote("bar' OR '1'='1");
$rows = $this->_conn->fetchAll($sql);
$this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible");
}
/**
* @group DDC-1213
*/
public function <API key>()
{
$this->_conn->executeQuery('DELETE FROM fetch_table')->execute();
$platform = $this->_conn->getDatabasePlatform();
$bitmap = array();
for ($i = 2; $i < 9; $i = $i + 2) {
$bitmap[$i] = array(
'bit_or' => ($i | 2),
'bit_and' => ($i & 2)
);
$this->_conn->insert('fetch_table', array(
'test_int' => $i,
'test_string' => json_encode($bitmap[$i]),
'test_datetime' => '2010-01-01 10:10:10'
));
}
$sql[] = 'SELECT ';
$sql[] = 'test_int, ';
$sql[] = 'test_string, ';
$sql[] = $platform-><API key>('test_int', 2) . ' AS bit_or, ';
$sql[] = $platform-><API key>('test_int', 2) . ' AS bit_and ';
$sql[] = 'FROM fetch_table';
$stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql));
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$this->assertEquals(4, count($data));
$this->assertEquals(count($bitmap), count($data));
foreach ($data as $row) {
$row = <API key>($row, CASE_LOWER);
$this->assertArrayHasKey('test_int', $row);
$id = $row['test_int'];
$this->assertArrayHasKey($id, $bitmap);
$this->assertArrayHasKey($id, $bitmap);
$this->assertArrayHasKey('bit_or', $row);
$this->assertArrayHasKey('bit_and', $row);
$this->assertEquals($row['bit_or'], $bitmap[$id]['bit_or']);
$this->assertEquals($row['bit_and'], $bitmap[$id]['bit_and']);
}
}
public function <API key>()
{
$stmt = $this->_conn->query("SELECT * FROM fetch_table");
$stmt->setFetchMode(\PDO::FETCH_NUM);
$row = array_keys($stmt->fetch());
$this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result.");
}
/**
* @group DBAL-196
*/
public function <API key>()
{
$this->skipOci8AndMysqli();
$this->setupFixture();
$sql = "SELECT test_int, test_string, test_datetime FROM fetch_table";
$stmt = $this->_conn->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(
\PDO::FETCH_CLASS,
__NAMESPACE__.'\\MyFetchClass'
);
$this->assertEquals(1, count($results));
$this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
$this->assertEquals(1, $results[0]->test_int);
$this->assertEquals('foo', $results[0]->test_string);
$this-><API key>('2010-01-01 10:10:10', $results[0]->test_datetime);
}
/**
* @group DBAL-241
*/
public function <API key>()
{
$sql = "DELETE FROM fetch_table";
$this->_conn->executeUpdate($sql);
$this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo'));
$this->_conn->insert('fetch_table', array('test_int' => 10, 'test_string' => 'foo'));
$sql = "SELECT test_int FROM fetch_table";
$rows = $this->_conn->query($sql)->fetchAll(\PDO::FETCH_COLUMN);
$this->assertEquals(array(1, 10), $rows);
}
/**
* @group DBAL-214
*/
public function <API key>()
{
$this->skipOci8AndMysqli();
$this->setupFixture();
$sql = "SELECT * FROM fetch_table";
$stmt = $this->_conn->query($sql);
$stmt->setFetchMode(\PDO::FETCH_CLASS, __NAMESPACE__ . '\\MyFetchClass');
$results = $stmt->fetchAll();
$this->assertEquals(1, count($results));
$this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
$this->assertEquals(1, $results[0]->test_int);
$this->assertEquals('foo', $results[0]->test_string);
$this-><API key>('2010-01-01 10:10:10', $results[0]->test_datetime);
}
/**
* @group DBAL-214
*/
public function <API key>()
{
$this->skipOci8AndMysqli();
$this->setupFixture();
$sql = "SELECT * FROM fetch_table";
$stmt = $this->_conn->query($sql);
$stmt->setFetchMode(\PDO::FETCH_CLASS, __NAMESPACE__ . '\\MyFetchClass');
$results = array();
while ($row = $stmt->fetch()) {
$results[] = $row;
}
$this->assertEquals(1, count($results));
$this->assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
$this->assertEquals(1, $results[0]->test_int);
$this->assertEquals('foo', $results[0]->test_string);
$this-><API key>('2010-01-01 10:10:10', $results[0]->test_datetime);
}
/**
* @group DBAL-257
*/
public function <API key>()
{
$this->_conn->executeQuery('DELETE FROM fetch_table')->execute();
$this->assertFalse($this->_conn->fetchColumn('SELECT test_int FROM fetch_table'));
$this->assertFalse($this->_conn->query('SELECT test_int FROM fetch_table')->fetchColumn());
}
/**
* @group DBAL-339
*/
public function <API key>()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->executeQuery($sql, array(1, "foo"));
$stmt->setFetchMode(\PDO::FETCH_NUM);
while ($row = $stmt->fetch()) {
$this->assertTrue(isset($row[0]));
$this->assertTrue(isset($row[1]));
}
}
/**
* @group DBAL-435
*/
public function testEmptyParameters()
{
$sql = "SELECT * FROM fetch_table WHERE test_int IN (?)";
$stmt = $this->_conn->executeQuery($sql, array(array()), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY));
$rows = $stmt->fetchAll();
$this->assertEquals(array(), $rows);
}
/**
* @group DBAL-1028
*/
public function <API key>()
{
$this->_conn->executeUpdate(
'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)',
array(1, 'foo')
);
$this->assertNull(
$this->_conn->fetchColumn('SELECT test_datetime FROM fetch_table WHERE test_int = ?', array(1))
);
}
/**
* @group DBAL-1028
*/
public function <API key>()
{
if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') {
$this->markTestSkipped(
'Test does not work for pdo_sqlsrv driver as it throws a fatal error for a non-existing column index.'
);
}
$this->assertNull(
$this->_conn->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', array(1), 1)
);
}
/**
* @group DBAL-1028
*/
public function <API key>()
{
$this->assertFalse(
$this->_conn->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', array(-1))
);
}
private function setupFixture()
{
$this->_conn->executeQuery('DELETE FROM fetch_table')->execute();
$this->_conn->insert('fetch_table', array(
'test_int' => 1,
'test_string' => 'foo',
'test_datetime' => '2010-01-01 10:10:10'
));
}
private function skipOci8AndMysqli()
{
if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] == "oci8") {
$this->markTestSkipped("Not supported by OCI8");
}
if ('mysqli' == $this->_conn->getDriver()->getName()) {
$this->markTestSkipped('Mysqli driver dont support this feature.');
}
}
}
class MyFetchClass
{
public $test_int, $test_string, $test_datetime;
} |
var buster = typeof window !== 'undefined' ? window.buster : require('buster');
var assert = buster.assert;
var fail = buster.referee.fail;
var when = require('../when');
var CorePromise = when.Promise;
var resolved = when.resolve;
var rejected = when.reject;
var sentinel = { value: 'sentinel' };
var other = { value: 'other' };
buster.testCase('when.all', {
'should resolve empty input': function(done) {
return when.all([]).then(
function(result) {
assert.equals(result, []);
},
fail
).ensure(done);
},
'should resolve values array': function(done) {
var input = [1, 2, 3];
when.all(input).then(
function(results) {
assert.equals(results, input);
},
fail
).ensure(done);
},
'should resolve promises array': function(done) {
var input = [resolved(1), resolved(2), resolved(3)];
when.all(input).then(
function(results) {
assert.equals(results, [1, 2, 3]);
},
fail
).ensure(done);
},
'should resolve sparse array input': function(done) {
var input = [, 1, , 1, 1 ];
when.all(input).then(
function(results) {
assert.equals(results, input);
},
fail
).ensure(done);
},
'should reject if any input promise rejects': function(done) {
var input = [resolved(1), rejected(2), resolved(3)];
when.all(input).then(
fail,
function(failed) {
assert.equals(failed, 2);
}
).ensure(done);
},
'should accept a promise for an array': function(done) {
var expected, input;
expected = [1, 2, 3];
input = resolved(expected);
when.all(input).then(
function(results) {
assert.equals(results, expected);
},
fail
).ensure(done);
},
'should resolve to empty array when input promise does not resolve to array': function(done) {
when.all(resolved(1)).then(
function(result) {
assert.equals(result, []);
},
fail
).ensure(done);
},
'should report only 1 unhandled rejection': {
'when array contains > 1 rejection': function(done) {
/*global setTimeout*/
var origOnUnhandled = CorePromise.<API key>;
CorePromise.<API key> = function() {
fail(new Error('should not report unhandled rejection'));
};
when.all([rejected(sentinel), resolved(123), rejected(other)])
['catch'](function(e) {
assert.same(e, sentinel);
setTimeout(function() {
CorePromise.<API key> = origOnUnhandled;
done();
}, 100);
});
},
'when array contains same rejection multiple times': function(done) {
/*global setTimeout*/
var origOnUnhandled = CorePromise.<API key>;
CorePromise.<API key> = function() {
fail(new Error('should not report unhandled rejection'));
};
var r = rejected(sentinel);
when.all([r, r.then()])
['catch'](function(e) {
assert.same(e, sentinel);
setTimeout(function() {
CorePromise.<API key> = origOnUnhandled;
done();
}, 100);
});
}
}
}); |
module TestGrouping
using Base.Test
using DataFrames
df = DataFrame(a=rep(1:4, 2), b=rep(2:-1:1, 4), c=randn(8))
#df[6, :a] = NA
#df[7, :b] = NA
cols = [:a, :b]
f(df) = DataFrame(cmax = maximum(df[:c]))
sdf = sort(df, cols=cols)
bdf = by(df, cols, f)
@test bdf[cols] == unique(sdf[cols])
byf = by(df, :a, df -> DataFrame(bsum = sum(df[:b])))
@test all(T -> T <: AbstractVector, map(typeof, colwise([sum], df)))
@test all(T -> T <: AbstractVector, map(typeof, colwise(sum, df)))
gd = groupby(df, cols)
ga = map(f, gd)
@test bdf == combine(ga)
g(df) = DataFrame(cmax1 = df[:cmax] + 1)
h(df) = g(f(df))
@test combine(map(h, gd)) == combine(map(g, ga))
end |
define(
['aloha/core', 'jquery', 'aloha/command', 'aloha/selection', 'util/dom', 'aloha/<API key>', 'aloha/console'],
function(Aloha, jQuery, command, selection, dom, <API key>, console) {
"use strict";
// Exported commands
command.register( 'inserthtml', {
action: function(value, range) {
var
$editable = jQuery(dom.getEditingHostOf(range.startContainer)),
cac = range.<API key>,
i,
selectedRange,
domNodes = [];
/**
* Paste the given object into the current selection.
* If inserting fails (because the object is not allowed to be inserted), unwrap the contents and try with that.
* @param object object to be pasted
*/
function pasteElement(object) {
var $object = jQuery(object),
contents;
// try to insert the element into the DOM with limit the editable host
// this fails when an element is not allowed to be inserted
if (!dom.insertIntoDOM($object, range, $editable, false)) {
// if that is not possible, we unwrap the content and insert every child element
contents = $object.contents();
// when a block level element was unwrapped, we at least insert a break
if (dom.isBlockLevelElement(object) || dom.isListElement(object)) {
pasteElement(jQuery('<br/>').get(0));
}
// and now all children (starting from the back)
for ( i = contents.length - 1; i >= 0; --i) {
pasteElement(contents[i]);
}
}
};
// apply content handler to cleanup inserted data
// just use all registerd content handler or specity Aloha.defaults.contentHandler.insertHtml manually?
// Aloha.settings.contentHandler.insertHtml = Aloha.defaults.contentHandler.insertHtml;
value = <API key>.handleContent( value, { contenthandler: Aloha.settings.contentHandler.insertHtml } );
// allowed values are string or jQuery objects
// add value to a container div
if ( typeof value === 'string' ){
value = jQuery( '<div>' + value + '</div>' );
} else if ( value instanceof jQuery ) {
value = jQuery( '<div>' ).append(value);
} else {
throw "INVALID_VALUE_ERR";
}
// get contents of container div
domNodes = value.contents();
// check if range starts an ends in same editable host
// if ( !(dom.inSameEditingHost(range.startContainer, range.endContainer)) ) {
// throw "INVALID_RANGE_ERR";
// delete currently selected contents
dom.removeRange(range);
for ( i = domNodes.length - 1; i >= 0; --i) {
// insert the elements
pasteElement(domNodes[i]);
}
// Call collapse() on the context object's Selection,
// with last child's parent as the first argument and one plus its index as the second.
if (domNodes.length > 0) {
range = dom.setCursorAfter(domNodes.get(domNodes.length - 1));
} else {
// if nothing was pasted, just reselect the old range
range.select();
}
dom.doCleanup({merge:true, removeempty: true}, range, cac);
//In some cases selecting the range does not work properly
//e.g. when pasting from word in an h2 after the first character in IE
//in these cases we should fail gracefully.
//TODO check why the selection is failing
try {
range.select();
} catch (e) {
console.warn('Error:',e);
}
}
});
}); |
class AdminsController < <API key>
include AdminsHelper
before_filter :<API key>
def index
end
def populate
render json: <API key>
end
def edit
@user = Admin.find_by_id(params[:id])
end
def new
@user = Admin.new
end
def update
@user = Admin.find(params[:id])
# update_attributes supplied by ActiveRecords
if @user.update_attributes(user_params).nil?
flash[:error] = I18n.t('admins.update.error')
render :edit
else
flash[:success] = I18n.t('admins.update.success',
user_name: @user.user_name)
redirect_to action: 'index'
end
end
# Create a new Admin
def create
# Default attributes: role = TA or role = STUDENT
# params[:user] is a hash of values passed to the controller
# by the HTML form with the help of ActiveView::Helper::
@user = Admin.new(user_params)
# Return unless the save is successful; save inherted from
# active records--creates a new record if the model is new, otherwise
# updates the existing record
if @user.save
flash[:success] = I18n.t('admins.create.success',
user_name: @user.user_name)
redirect_to action: 'index'
else
flash[:error] = I18n.t('admins.create.error')
render 'new'
end
end
private
def user_params
params.require(:user).permit(:user_name, :first_name, :last_name)
end
end |
<?php
return [
'photoalbum' => 'Photo albums',
'numbers_of_items' =>'Number of items',
'description' => 'Description',
]; |
#ifndef <API key>
#define <API key>
#define GPIO_INIT(_port, _gpio, _init) \
{ \
.gpio = TEGRA_GPIO(_port, _gpio), \
.init = TEGRA_GPIO_INIT_##_init, \
}
static const struct tegra_gpio_config <API key>[] = {
/* port, pin, init_val */
GPIO_INIT(G, 0, IN),
GPIO_INIT(G, 1, IN),
GPIO_INIT(G, 2, IN),
GPIO_INIT(G, 3, IN),
GPIO_INIT(G, 4, IN),
GPIO_INIT(H, 2, OUT0),
GPIO_INIT(H, 4, IN),
GPIO_INIT(H, 7, IN),
GPIO_INIT(I, 0, OUT0),
GPIO_INIT(I, 1, IN),
GPIO_INIT(I, 6, IN),
GPIO_INIT(J, 0, IN),
GPIO_INIT(K, 1, OUT0),
GPIO_INIT(K, 2, IN),
GPIO_INIT(K, 4, OUT0),
GPIO_INIT(K, 6, OUT0),
GPIO_INIT(N, 7, IN),
GPIO_INIT(O, 1, IN),
GPIO_INIT(O, 4, IN),
GPIO_INIT(P, 2, OUT0),
GPIO_INIT(Q, 0, IN),
GPIO_INIT(Q, 3, IN),
GPIO_INIT(Q, 5, IN),
GPIO_INIT(R, 0, OUT0),
GPIO_INIT(R, 2, OUT0),
GPIO_INIT(R, 4, IN),
GPIO_INIT(R, 7, IN),
GPIO_INIT(S, 7, IN),
GPIO_INIT(T, 0, OUT0),
GPIO_INIT(T, 1, IN),
GPIO_INIT(U, 0, IN),
GPIO_INIT(U, 1, IN),
GPIO_INIT(U, 2, IN),
GPIO_INIT(U, 3, IN),
GPIO_INIT(U, 4, IN),
GPIO_INIT(U, 5, IN),
GPIO_INIT(U, 6, IN),
GPIO_INIT(V, 0, IN),
GPIO_INIT(V, 1, IN),
GPIO_INIT(X, 1, IN),
GPIO_INIT(X, 4, IN),
GPIO_INIT(X, 7, OUT0),
GPIO_INIT(BB, 3, OUT0),
GPIO_INIT(BB, 5, OUT0),
GPIO_INIT(BB, 6, OUT0),
GPIO_INIT(BB, 7, OUT0),
GPIO_INIT(CC, 1, IN),
GPIO_INIT(CC, 2, IN),
GPIO_INIT(EE, 2, OUT1),
};
#define PINCFG(_pingrp, _mux, _pull, _tri, _io, _od, _rcv_sel) \
{ \
.pingrp = PMUX_PINGRP_##_pingrp, \
.func = PMUX_FUNC_##_mux, \
.pull = PMUX_PULL_##_pull, \
.tristate = PMUX_TRI_##_tri, \
.io = PMUX_PIN_
.od = PMUX_PIN_OD_
.rcv_sel = PMUX_PIN_RCV_SEL_##_rcv_sel, \
.lock = <API key>, \
.ioreset = <API key>, \
}
static const struct pmux_pingrp_config jetson_tk1_pingrps[] = {
/* pingrp, mux, pull, tri, e_input, od, rcv_sel */
PINCFG(CLK_32K_OUT_PA0, SOC, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(UART3_CTS_N_PA1, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP2_FS_PA2, I2S1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP2_SCLK_PA3, I2S1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP2_DIN_PA4, I2S1, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(DAP2_DOUT_PA5, I2S1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_CLK_PA6, SDMMC3, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_CMD_PA7, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PB0, UARTD, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PB1, UARTD, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_DAT3_PB4, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_DAT2_PB5, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_DAT1_PB6, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_DAT0_PB7, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(UART3_RTS_N_PC0, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(UART2_TXD_PC2, IRDA, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(UART2_RXD_PC3, IRDA, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(GEN1_I2C_SCL_PC4, I2C1, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(GEN1_I2C_SDA_PC5, I2C1, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(PC7, RSVD1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PG0, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PG1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PG2, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PG3, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PG4, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PG5, SPI4, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PG6, SPI4, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PG7, SPI4, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PH0, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH1, PWM1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH2, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH3, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH4, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PH5, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH6, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PH7, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PI0, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PI1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PI2, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PI3, SPI4, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PI4, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PI5, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PI6, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PI7, RSVD1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PJ0, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PJ2, RSVD1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(UART2_CTS_N_PJ5, UARTB, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(UART2_RTS_N_PJ6, UARTB, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PJ7, UARTD, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PK0, RSVD1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PK1, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PK2, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PK3, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PK4, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SPDIF_OUT_PK5, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SPDIF_IN_PK6, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PK7, UARTD, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP1_FS_PN0, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP1_DIN_PN1, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP1_DOUT_PN2, SATA, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP1_SCLK_PN3, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(USB_VBUS_EN0_PN4, USB, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(USB_VBUS_EN1_PN5, USB, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(HDMI_INT_PN7, DEFAULT, DOWN, TRISTATE, INPUT, DEFAULT, NORMAL),
PINCFG(ULPI_DATA7_PO0, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA0_PO1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA1_PO2, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA2_PO3, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA3_PO4, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA4_PO5, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA5_PO6, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DATA6_PO7, ULPI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP3_FS_PP0, I2S2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP3_DIN_PP1, I2S2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP3_DOUT_PP2, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP3_SCLK_PP3, RSVD3, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP4_FS_PP4, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP4_DIN_PP5, RSVD3, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP4_DOUT_PP6, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP4_SCLK_PP7, RSVD3, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL0_PQ0, DEFAULT, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL1_PQ1, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL2_PQ2, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL3_PQ3, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL4_PQ4, SDMMC3, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL5_PQ5, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL6_PQ6, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_COL7_PQ7, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW0_PR0, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW1_PR1, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW2_PR2, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW3_PR3, KBC, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW4_PR4, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW5_PR5, RSVD3, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW6_PR6, DISPLAYA_ALT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW7_PR7, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW8_PS0, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW9_PS1, UARTA, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW10_PS2, UARTA, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW11_PS3, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW12_PS4, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW13_PS5, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW14_PS6, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW15_PS7, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW16_PT0, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(KB_ROW17_PT1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(GEN2_I2C_SCL_PT5, I2C2, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(GEN2_I2C_SDA_PT6, I2C2, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(SDMMC4_CMD_PT7, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU0, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU1, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU2, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU3, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU4, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU5, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PU6, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PV0, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PV1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC3_CD_N_PV2, SDMMC3, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_WP_N_PV3, SDMMC1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DDC_SCL_PV4, I2C4, NORMAL, NORMAL, INPUT, DEFAULT, NORMAL),
PINCFG(DDC_SDA_PV5, I2C4, NORMAL, NORMAL, INPUT, DEFAULT, NORMAL),
PINCFG(GPIO_W2_AUD_PW2, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_W3_AUD_PW3, SPI6, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP_MCLK1_PW4, EXTPERIPH1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(CLK2_OUT_PW5, EXTPERIPH2, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(UART3_TXD_PW6, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(UART3_RXD_PW7, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DVFS_PWM_PX0, CLDVFS, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X1_AUD_PX1, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(DVFS_CLK_PX2, CLDVFS, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X3_AUD_PX3, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X4_AUD_PX4, DEFAULT, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X5_AUD_PX5, RSVD4, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X6_AUD_PX6, GMI, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(GPIO_X7_AUD_PX7, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_CLK_PY0, SPI1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_DIR_PY1, SPI1, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_NXT_PY2, SPI1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(ULPI_STP_PY3, SPI1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_DAT3_PY4, SDMMC1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_DAT2_PY5, SDMMC1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_DAT1_PY6, SDMMC1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_DAT0_PY7, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_CLK_PZ0, RSVD3, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC1_CMD_PZ1, SDMMC1, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PWR_I2C_SCL_PZ6, I2CPWR, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(PWR_I2C_SDA_PZ7, I2CPWR, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(SDMMC4_DAT0_PAA0, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT1_PAA1, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT2_PAA2, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT3_PAA3, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT4_PAA4, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT5_PAA5, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT6_PAA6, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_DAT7_PAA7, SDMMC4, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PBB0, VIMCLK2_ALT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(CAM_I2C_SCL_PBB1, I2C3, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(CAM_I2C_SDA_PBB2, I2C3, NORMAL, NORMAL, INPUT, ENABLE, DEFAULT),
PINCFG(PBB3, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PBB4, VGP4, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PBB5, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PBB6, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PBB7, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(CAM_MCLK_PCC0, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PCC1, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(PCC2, DEFAULT, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(SDMMC4_CLK_PCC4, SDMMC4, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(CLK2_REQ_PCC5, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PEX_L0_RST_N_PDD1, PE0, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(<API key>, PE0, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PEX_WAKE_N_PDD3, PE, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(PEX_L1_RST_N_PDD5, PE1, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(<API key>, PE1, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(CLK3_OUT_PEE0, EXTPERIPH3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(CLK3_REQ_PEE1, RSVD2, DOWN, TRISTATE, OUTPUT, DEFAULT, DEFAULT),
PINCFG(DAP_MCLK1_REQ_PEE2, DEFAULT, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(HDMI_CEC_PEE3, CEC, NORMAL, NORMAL, INPUT, DISABLE, DEFAULT),
PINCFG(<API key>, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(<API key>, SDMMC3, UP, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(DP_HPD_PFF0, DP, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(USB_VBUS_EN2_PFF1, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(PFF2, RSVD2, DOWN, TRISTATE, OUTPUT, DISABLE, DEFAULT),
PINCFG(CORE_PWR_REQ, PWRON, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(CPU_PWR_REQ, CPU, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT),
PINCFG(PWR_INT_N, PMI, UP, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(RESET_OUT_N, RESET_OUT_N, NORMAL, NORMAL, INPUT, DEFAULT, DEFAULT),
PINCFG(CLK_32K_IN, CLK, NORMAL, TRISTATE, INPUT, DEFAULT, DEFAULT),
PINCFG(JTAG_RTCK, RTCK, UP, NORMAL, OUTPUT, DEFAULT, DEFAULT),
};
#define DRVCFG(_drvgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, _hsm) \
{ \
.drvgrp = PMUX_DRVGRP_##_drvgrp, \
.slwf = _slwf, \
.slwr = _slwr, \
.drvup = _drvup, \
.drvdn = _drvdn, \
.lpmd = PMUX_LPMD_##_lpmd, \
.schmt = PMUX_SCHMT_##_schmt, \
.hsm = PMUX_HSM_##_hsm, \
}
static const struct pmux_drvgrp_config jetson_tk1_drvgrps[] = {
};
#define MIPIPADCTRLCFG(_grp, _mux) \
{ \
.grp = <API key>##_grp, \
.func = PMUX_FUNC_##_mux, \
}
static const struct <API key> <API key>[] = {
/* grp, mux */
MIPIPADCTRLCFG(DSI_B, DSI_B),
};
#endif /* <API key> */ |
using System;
using System.Drawing;
using System.Windows.Forms;
namespace LiveSplit.UI
{
public static class InputBox
{
public static DialogResult Show(string title, string promptText, ref string value)
{
return Show(null, title, promptText, ref value);
}
public static DialogResult Show(IWin32Window owner, string title, string promptText, ref string value)
{
using (Form form = new Form())
{
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] {label, textBox, buttonOk, buttonCancel});
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = owner != null ? form.ShowDialog(owner) : form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
}
public static DialogResult Show(string title, string promptText, string promptText2, ref string value, ref string value2)
{
return Show(null, title, promptText, promptText2, ref value, ref value2);
}
public static DialogResult Show(IWin32Window owner, string title, string promptText, string promptText2, ref string value, ref string value2)
{
using (Form form = new Form())
{
Label label = new Label();
Label label2 = new Label();
TextBox textBox = new TextBox();
TextBox textBox2 = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
label2.Text = promptText2;
textBox.Text = value;
textBox2.Text = value2;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
label2.SetBounds(9, 66, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
textBox2.SetBounds(12, 82, 372, 20);
buttonOk.SetBounds(228, 118, 75, 23);
buttonCancel.SetBounds(309, 118, 75, 23);
label.AutoSize = true;
label2.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
textBox2.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 153);
form.Controls.AddRange(new Control[] {label, label2, textBox, textBox2, buttonOk, buttonCancel});
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = owner != null ? form.ShowDialog(owner) : form.ShowDialog();
value = textBox.Text;
value2 = textBox2.Text;
return dialogResult;
}
}
}
} |
namespace Microsoft.Test.OData.TDD.Tests.Roundtripping.VerboseJson
{
using System;
using System.Collections;
using System.IO;
using System.Text;
using FluentAssertions;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Library;
using Microsoft.OData.Core;
using Microsoft.OData.Core.VerboseJson;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class <API key>
{
[TestMethod()]
public void <API key>()
{
var values = new byte[][]
{
new byte[0],
new byte[] { 0 },
new byte[] { 42, Byte.MinValue, Byte.MaxValue },
};
this.<API key>(values, "Edm.Binary");
}
[TestMethod()]
public void <API key>()
{
var values = new bool[]
{
true,
false,
};
this.<API key>(values, "Edm.Boolean");
}
[TestMethod()]
public void <API key>()
{
var values = new byte[]
{
0,
42,
Byte.MaxValue,
Byte.MinValue,
};
this.<API key>(values, "Edm.Byte");
}
[TestMethod()]
public void <API key>()
{
var values = new DateTime[]
{
new DateTime(2012, 4, 13, 2, 43, 10, 215),
// This fails to roundtrip in V1 - because the date time is read as UTC
// by design since the V1/V2 format stores everything as UTC and doesn't store kind information
// new DateTime(2013, 5, 14, 3, 44, 11, DateTimeKind.Local),
new DateTime(2014, 6, 15, 4, 45, 12, DateTimeKind.Unspecified),
new DateTime(2015, 7, 16, 5, 46, 13, DateTimeKind.Utc),
DateTime.MinValue,
// This fails to roundtrip in V1 - the input has higher ticks precision than the output - by design.
// DateTime.MaxValue,
};
this.<API key>(values, "Edm.DateTime");
}
[TestMethod()]
public void <API key>()
{
var values = new DateTimeOffset[]
{
new DateTimeOffset(2012, 4, 13, 2, 43, 10, TimeSpan.Zero),
new DateTimeOffset(2012, 4, 13, 2, 43, 10, 215, TimeSpan.FromMinutes(840)),
new DateTimeOffset(2012, 4, 13, 2, 43, 10, 215, TimeSpan.FromMinutes(-840)),
new DateTimeOffset(2012, 4, 13, 2, 43, 10, 215, TimeSpan.FromMinutes(123)),
new DateTimeOffset(2012, 4, 13, 2, 43, 10, 215, TimeSpan.FromMinutes(-42)),
DateTimeOffset.MinValue,
// This fails to roundtrip in V1 - the input has higher ticks precision than the output - by design.
// DateTimeOffset.MaxValue,
};
this.<API key>(values, "Edm.DateTimeOffset");
}
[TestMethod()]
public void <API key>()
{
var values = new decimal[]
{
0,
1,
-1,
Decimal.MinValue,
Decimal.MaxValue,
10^-28,
10^28,
};
this.<API key>(values, "Edm.Decimal");
}
[TestMethod()]
public void <API key>()
{
var values = new double[]
{
0,
42,
42.42,
Double.MaxValue,
Double.MinValue,
Double.PositiveInfinity,
Double.NegativeInfinity,
Double.NaN,
-4.42330604244772E-305,
};
this.<API key>(values, "Edm.Double");
}
[TestMethod()]
public void <API key>()
{
var values = new Guid[]
{
new Guid(0, 0, 0, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }),
new Guid("<API key>"),
Guid.Empty,
};
this.<API key>(values, "Edm.Guid");
}
[TestMethod()]
public void <API key>()
{
var values = new Int16[]
{
0,
42,
-43,
Int16.MaxValue,
Int16.MinValue,
};
this.<API key>(values, "Edm.Int16");
}
[TestMethod()]
public void <API key>()
{
var values = new Int32[]
{
0,
42,
-43,
Int32.MaxValue,
Int32.MinValue,
};
this.<API key>(values, "Edm.Int32");
}
[TestMethod()]
public void <API key>()
{
var values = new Int64[]
{
0,
42,
-43,
Int64.MaxValue,
Int64.MinValue,
};
this.<API key>(values, "Edm.Int64");
}
[TestMethod()]
public void <API key>()
{
var values = new SByte[]
{
0,
42,
-43,
SByte.MaxValue,
SByte.MinValue,
};
this.<API key>(values, "Edm.SByte");
}
[TestMethod()]
public void <API key>()
{
var values = new string[]
{
string.Empty,
" ",
"testvalue",
"TestValue",
"\r\n\t",
"\"",
"\'",
};
this.<API key>(values, "Edm.String");
}
[TestMethod()]
public void <API key>()
{
var values = new Single[]
{
0,
42,
(float)-43.43,
Single.MaxValue,
Single.MinValue,
Single.PositiveInfinity,
Single.NegativeInfinity,
Single.NaN,
};
this.<API key>(values, "Edm.Single");
}
[TestMethod()]
public void <API key>()
{
var values = new TimeSpan[]
{
new TimeSpan(1, 2, 3, 4, 5),
TimeSpan.Zero,
TimeSpan.MinValue,
TimeSpan.MaxValue,
};
this.<API key>(values, "Edm.Duration");
}
private void <API key>(IEnumerable clrValues, string edmTypeName)
{
foreach (ODataVersion version in Enum.GetValues(typeof(ODataVersion)))
{
foreach (object clrValue in clrValues)
{
this.<API key>(clrValue, edmTypeName, version, string.Format("Verbose JSON roundtrip value {0} of type {1} in version {2}.", clrValue, edmTypeName, version));
}
}
}
private void <API key>(object clrValue, string edmTypeName, ODataVersion version, string description)
{
IEdmModel model = new EdmModel();
<API key> typeReference = new <API key>((IEdmPrimitiveType)model.FindType(edmTypeName), true);
MemoryStream stream = new MemoryStream();
using (<API key> outputContext = new <API key>(
ODataFormat.VerboseJson,
new NonDisposingStream(stream),
Encoding.UTF8,
new <API key>() { Version = version },
/*writingResponse*/ true,
/*synchronous*/ true,
model,
/*urlResolver*/ null))
{
<API key> serializer = new <API key>(outputContext);
serializer.WritePrimitiveValue(
clrValue,
/*collectionValidator*/ null,
typeReference);
}
stream.Position = 0;
object actualValue;
using (<API key> inputContext = new <API key>(
ODataFormat.VerboseJson,
stream,
Encoding.UTF8,
new <API key>(),
version,
/*readingResponse*/ true,
/*synchronous*/ true,
model,
/*urlResolver*/ null))
{
<API key> deserializer = new <API key>(inputContext);
deserializer.JsonReader.Read();
actualValue = deserializer.ReadNonEntityValue(
typeReference,
/*<API key>*/ null,
/*collectionValidator*/ null,
/*validateNullValue*/ true,
/*propertyName*/ null);
}
if (clrValue is byte[])
{
((byte[])actualValue).Should().Equal((byte[])clrValue, description);
}
else
{
actualValue.Should().Be(clrValue, description);
}
}
}
} |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="robots" content="index, follow, all" />
<title>Thelia\Model\Base\Lang | </title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css">
</head>
<body id="class">
<div class="header">
<ul>
<li><a href="../../../classes.html">Classes</a></li>
<li><a href="../../../namespaces.html">Namespaces</a></li>
<li><a href="../../../interfaces.html">Interfaces</a></li>
<li><a href="../../../traits.html">Traits</a></li>
<li><a href="../../../doc-index.html">Index</a></li>
</ul>
<div id="title"></div>
<div class="type">Class</div>
<h1><a href="../../../Thelia/Model/Base.html">Thelia\Model\Base</a>\Lang</h1>
</div>
<div class="content">
<p>abstract class
<strong>Lang</strong> implements
<abbr title="Propel\Runtime\ActiveRecord\<API key>"><API key></abbr></p>
<h2>Constants</h2>
<table>
<tr>
<td>TABLE_MAP</td>
<td class="last">
<p><em>TableMap class name</em></p>
<p>
</p>
</td>
</tr>
</table>
<h2>Methods</h2>
<table>
<tr>
<td class="type">
</td>
<td class="last">
<a href="
<p>Initializes internal state of Thelia\Model\Base\Lang object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_isModified">isModified</a>()
<p>Returns whether the object has been modified.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#<API key>">isColumnModified</a>(string $col)
<p>Has specified column been modified?</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
array
</td>
<td class="last">
<a href="#<API key>">getModifiedColumns</a>()
<p>Get the columns that have been modified in this object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_isNew">isNew</a>()
<p>Returns whether the object has ever been saved.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_setNew">setNew</a>(boolean $b)
<p>Setter for the isNew attribute.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_isDeleted">isDeleted</a>()
<p>Whether this object has been deleted.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_setDeleted">setDeleted</a>(boolean $b)
<p>Specify whether this object has been deleted.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#<API key>">resetModified</a>(string $col = null)
<p>Sets the modified state for the object to be false.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_equals">equals</a>(mixed $obj)
<p>Compares this with another <code>Lang</code> instance.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_hashCode">hashCode</a>()
<p>If the primary key is not null, return the hashcode of the primary key.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
array
</td>
<td class="last">
<a href="#<API key>">getVirtualColumns</a>()
<p>Get the associative array of the virtual columns in this object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#<API key>">hasVirtualColumn</a>(string $name)
<p>Checks the existence of a virtual column in this object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
mixed
</td>
<td class="last">
<a href="#<API key>">getVirtualColumn</a>(string $name)
<p>Get the value of a virtual column in this object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>">setVirtualColumn</a>(string $name, mixed $value)
<p>Set the value of a virtual column in this object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_importFrom">importFrom</a>(mixed $parser, string $data)
<p>Populate the current object from a string, using a given parser format <code> $book = new Book(); $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); </code></p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_exportTo">exportTo</a>(mixed $parser, boolean $<API key> = true)
<p>Export the current object properties to a string, using a given parser format <code> $book = BookQuery::create()->findPk(9012); echo $book->exportTo('JSON'); => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); </code></p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="
<p>Clean up internal collections prior to serializing Avoids recursive loops that turn into segmentation faults when serializing</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_getId">getId</a>()
<p>Get the [id] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_getTitle">getTitle</a>()
<p>Get the [title] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_getCode">getCode</a>()
<p>Get the [code] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_getLocale">getLocale</a>()
<p>Get the [locale] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_getUrl">getUrl</a>()
<p>Get the [url] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#<API key>">getDateFormat</a>()
<p>Get the [date_format] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#<API key>">getTimeFormat</a>()
<p>Get the [time_format] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#<API key>">getDatetimeFormat</a>()
<p>Get the [datetime_format] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#<API key>">getDecimalSeparator</a>()
<p>Get the [decimal_separator] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#<API key>"><API key></a>()
<p>Get the [thousands_separator] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="#method_getDecimals">getDecimals</a>()
<p>Get the [decimals] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_getByDefault">getByDefault</a>()
<p>Get the [by_default] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_getPosition">getPosition</a>()
<p>Get the [position] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
mixed
</td>
<td class="last">
<a href="#method_getCreatedAt">getCreatedAt</a>(string $format = NULL)
<p>Get the [optionally formatted] temporal [created_at] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
mixed
</td>
<td class="last">
<a href="#method_getUpdatedAt">getUpdatedAt</a>(string $format = NULL)
<p>Get the [optionally formatted] temporal [updated_at] column value.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setId">setId</a>(int $v)
<p>Set the value of [id] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setTitle">setTitle</a>(string $v)
<p>Set the value of [title] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setCode">setCode</a>(string $v)
<p>Set the value of [code] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setLocale">setLocale</a>(string $v)
<p>Set the value of [locale] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setUrl">setUrl</a>(string $v)
<p>Set the value of [url] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>">setDateFormat</a>(string $v)
<p>Set the value of [date_format] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>">setTimeFormat</a>(string $v)
<p>Set the value of [time_format] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>">setDatetimeFormat</a>(string $v)
<p>Set the value of [datetime_format] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>">setDecimalSeparator</a>(string $v)
<p>Set the value of [decimal_separator] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>"><API key></a>(string $v)
<p>Set the value of [thousands_separator] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setDecimals">setDecimals</a>(string $v)
<p>Set the value of [decimals] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setByDefault">setByDefault</a>(int $v)
<p>Set the value of [by_default] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setPosition">setPosition</a>(int $v)
<p>Set the value of [position] column.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setCreatedAt">setCreatedAt</a>(mixed $v)
<p>Sets the value of [created_at] column to a normalized version of the date/time value specified.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setUpdatedAt">setUpdatedAt</a>(mixed $v)
<p>Sets the value of [updated_at] column to a normalized version of the date/time value specified.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#<API key>"><API key></a>()
<p>Indicates whether the columns in this object are only set to default values.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_hydrate">hydrate</a>(array $row, int $startcol, boolean $rehydrate = false, string $indexType = TableMap::TYPE_NUM)
<p>Hydrates (populates) the object variables with values from the database resultset.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#<API key>">ensureConsistency</a>()
<p>Checks and repairs the internal consistency of the object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_reload">reload</a>(boolean $deep = false, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Reloads this object from datastore based on primary key and (optionally) resets all associated objects.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_delete">delete</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Removes this object from datastore and sets delete attribute.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_save">save</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Persists this object to the database.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
mixed
</td>
<td class="last">
<a href="#method_getByName">getByName</a>(string $name, string $type = TableMap::TYPE_PHPNAME)
<p>Retrieves a field from the object by name passed in as a string.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
mixed
</td>
<td class="last">
<a href="#<API key>">getByPosition</a>(int $pos)
<p>Retrieves a field from the object by Position as specified in the xml schema.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
array
</td>
<td class="last">
<a href="#method_toArray">toArray</a>(string $keyType = TableMap::TYPE_PHPNAME, boolean $<API key> = true, array $<API key> = array(), boolean $<API key> = false)
<p>Exports the object as an array.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_setByName">setByName</a>(string $name, mixed $value, string $type = TableMap::TYPE_PHPNAME)
<p>Sets a field from the object by name passed in as a string.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#<API key>">setByPosition</a>(int $pos, mixed $value)
<p>Sets a field from the object by Position as specified in the xml schema.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_fromArray">fromArray</a>(array $arr, string $keyType = TableMap::TYPE_PHPNAME)
<p>Populates the object using an array.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr>
</td>
<td class="last">
<a href="#<API key>">buildCriteria</a>()
<p>Build a Criteria object containing the values of all modified columns in this object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr>
</td>
<td class="last">
<a href="#<API key>">buildPkeyCriteria</a>()
<p>Builds a Criteria object containing the primary key for this object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#<API key>">getPrimaryKey</a>()
<p>Returns the primary key for this object (row).</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#<API key>">setPrimaryKey</a>(int $key)
<p>Generic method to set the primary key (id column).</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#<API key>">isPrimaryKeyNull</a>()
<p>Returns true if the primary key for this object is null.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_copyInto">copyInto</a>(object $copyObj, boolean $deepCopy = false, boolean $makeNew = true)
<p>Sets contents of passed object to values from current object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_copy">copy</a>(boolean $deepCopy = false)
<p>Makes a copy of this object that will be inserted as a new row in table when saved.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_initRelation">initRelation</a>(string $relationName)
<p>Initializes a collection based on the name of a relation.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_clearOrders">clearOrders</a>()
<p>Clears out the collOrders collection</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#<API key>">resetPartialOrders</a>($v = true)
<p>Reset is the collOrders collection loaded partially.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
void
</td>
<td class="last">
<a href="#method_initOrders">initOrders</a>(boolean $overrideExisting = true)
<p>Initializes the collOrders collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#method_getOrders">getOrders</a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Gets an array of ChildOrder objects which contain a foreign key that references this object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_setOrders">setOrders</a>(<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr> $orders, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Sets a collection of Order objects related by a one-to-many relationship to the current object.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
int
</td>
<td class="last">
<a href="#method_countOrders">countOrders</a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, boolean $distinct = false, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Returns the number of related Order objects.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_addOrder">addOrder</a>(<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a> $l)
<p>Method called to associate a ChildOrder object to this object through the ChildOrder foreign key attribute.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#method_removeOrder">removeOrder</a>(<a href="../../../Thelia/Model/Base/Order.html"><abbr title="Thelia\Model\Base\Order">Order</abbr></a> $order)
<p>
</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
</td>
<td class="last">
<a href="#<API key>"><API key></a>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_clear">clear</a>()
<p>Clears the current object and sets all attributes to their default values</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#<API key>">clearAllReferences</a>(boolean $deep = false)
<p>Resets all references to other model objects or collections of model objects.</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
string
</td>
<td class="last">
<a href="
<p>Return the string representation of this object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
<a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
</td>
<td class="last">
<a href="#<API key>"><API key></a>()
<p>Mark the current object so that the update date doesn't get updated during next save</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_preSave">preSave</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run before persisting the object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_postSave">postSave</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run after persisting the object</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_preInsert">preInsert</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run before inserting to database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_postInsert">postInsert</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run after inserting to database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_preUpdate">preUpdate</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run before updating the object in database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_postUpdate">postUpdate</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run after updating the object in database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
boolean
</td>
<td class="last">
<a href="#method_preDelete">preDelete</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run before deleting the object in database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
</td>
<td class="last">
<a href="#method_postDelete">postDelete</a>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)
<p>Code to be run after deleting the object in database</p>
</td>
<td></td>
</tr>
<tr>
<td class="type">
array|string
</td>
<td class="last">
<a href="
<p>Derived method to catches calls to undefined methods.</p>
</td>
<td></td>
</tr>
</table>
<h2>Details</h2>
<h3 id="method___construct">
<div class="location">at line 173</div>
<code> public
<strong>__construct</strong>()</code>
</h3>
<div class="details">
<p>Initializes internal state of Thelia\Model\Base\Lang object.</p>
<p>
</p>
<div class="tags">
</div>
</div>
<h3 id="method_isModified">
<div class="location">at line 182</div>
<code> public boolean
<strong>isModified</strong>()</code>
</h3>
<div class="details">
<p>Returns whether the object has been modified.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>True if the object has been modified.</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 193</div>
<code> public boolean
<strong>isColumnModified</strong>(string $col)</code>
</h3>
<div class="details">
<p>Has specified column been modified?</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$col</td>
<td>column fully qualified name (TableMap::TYPE<em>COLNAME), e.g. Book::AUTHOR</em>ID</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>True if $col has been modified.</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 202</div>
<code> public array
<strong>getModifiedColumns</strong>()</code>
</h3>
<div class="details">
<p>Get the columns that have been modified in this object.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>array</td>
<td>A unique list of the modified column names for this object.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_isNew">
<div class="location">at line 214</div>
<code> public boolean
<strong>isNew</strong>()</code>
</h3>
<div class="details">
<p>Returns whether the object has ever been saved.</p>
<p>This will
be false, if the object was retrieved from storage or was created
and then saved.</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>true, if the object has never been persisted.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setNew">
<div class="location">at line 225</div>
<code> public
<strong>setNew</strong>(boolean $b)</code>
</h3>
<div class="details">
<p>Setter for the isNew attribute.</p>
<p>This method will be called
by Propel-generated children and objects.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$b</td>
<td>the state of the object.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_isDeleted">
<div class="location">at line 234</div>
<code> public boolean
<strong>isDeleted</strong>()</code>
</h3>
<div class="details">
<p>Whether this object has been deleted.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>The deleted state of this object.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setDeleted">
<div class="location">at line 244</div>
<code> public void
<strong>setDeleted</strong>(boolean $b)</code>
</h3>
<div class="details">
<p>Specify whether this object has been deleted.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$b</td>
<td>The deleted state of this object.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 254</div>
<code> public void
<strong>resetModified</strong>(string $col = null)</code>
</h3>
<div class="details">
<p>Sets the modified state for the object to be false.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$col</td>
<td>If supplied, only the specified column is reset.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_equals">
<div class="location">at line 273</div>
<code> public boolean
<strong>equals</strong>(mixed $obj)</code>
</h3>
<div class="details">
<p>Compares this with another <code>Lang</code> instance.</p>
<p>If
<code>obj</code> is an instance of <code>Lang</code>, delegates to
<code>equals(Lang)</code>. Otherwise, returns <code>false</code>.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>mixed</td>
<td>$obj</td>
<td>The object to compare to.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>Whether equal to the object specified.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_hashCode">
<div class="location">at line 298</div>
<code> public int
<strong>hashCode</strong>()</code>
</h3>
<div class="details">
<p>If the primary key is not null, return the hashcode of the primary key.</p>
<p>Otherwise, return the hash code of the object.</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>Hashcode</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 312</div>
<code> public array
<strong>getVirtualColumns</strong>()</code>
</h3>
<div class="details">
<p>Get the associative array of the virtual columns in this object</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>array</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 323</div>
<code> public boolean
<strong>hasVirtualColumn</strong>(string $name)</code>
</h3>
<div class="details">
<p>Checks the existence of a virtual column in this object</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>The virtual column name</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 336</div>
<code> public mixed
<strong>getVirtualColumn</strong>(string $name)</code>
</h3>
<div class="details">
<p>Get the value of a virtual column in this object</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>The virtual column name</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>mixed</td>
<td>
</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 353</div>
<code> public <a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a>
<strong>setVirtualColumn</strong>(string $name, mixed $value)</code>
</h3>
<div class="details">
<p>Set the value of a virtual column in this object</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>The virtual column name</td>
</tr>
<tr>
<td>mixed</td>
<td>$value</td>
<td>The value to give to the virtual column</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a></td>
<td>The current object, for fluid interface</td>
</tr>
</table>
</div>
</div>
<h3 id="method_importFrom">
<div class="location">at line 385</div>
<code> public <a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a>
<strong>importFrom</strong>(mixed $parser, string $data)</code>
</h3>
<div class="details">
<p>Populate the current object from a string, using a given parser format <code> $book = new Book(); $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); </code></p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>mixed</td>
<td>$parser</td>
<td>A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')</td>
</tr>
<tr>
<td>string</td>
<td>$data</td>
<td>The source data to import from</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Base/Lang.html"><abbr title="Thelia\Model\Base\Lang">Lang</abbr></a></td>
<td>The current object, for fluid interface</td>
</tr>
</table>
</div>
</div>
<h3 id="method_exportTo">
<div class="location">at line 408</div>
<code> public string
<strong>exportTo</strong>(mixed $parser, boolean $<API key> = true)</code>
</h3>
<div class="details">
<p>Export the current object properties to a string, using a given parser format <code> $book = BookQuery::create()->findPk(9012); echo $book->exportTo('JSON'); => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); </code></p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>mixed</td>
<td>$parser</td>
<td>A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')</td>
</tr>
<tr>
<td>boolean</td>
<td>$<API key></td>
<td>(optional) Whether to include lazy load(ed) columns. Defaults to TRUE.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>The exported data</td>
</tr>
</table>
</div>
</div>
<h3 id="method___sleep">
<div class="location">at line 421</div>
<code> public
<strong>__sleep</strong>()</code>
</h3>
<div class="details">
<p>Clean up internal collections prior to serializing Avoids recursive loops that turn into segmentation faults when serializing</p>
<p>
</p>
<div class="tags">
</div>
</div>
<h3 id="method_getId">
<div class="location">at line 433</div>
<code> public int
<strong>getId</strong>()</code>
</h3>
<div class="details">
<p>Get the [id] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getTitle">
<div class="location">at line 444</div>
<code> public string
<strong>getTitle</strong>()</code>
</h3>
<div class="details">
<p>Get the [title] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getCode">
<div class="location">at line 455</div>
<code> public string
<strong>getCode</strong>()</code>
</h3>
<div class="details">
<p>Get the [code] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getLocale">
<div class="location">at line 466</div>
<code> public string
<strong>getLocale</strong>()</code>
</h3>
<div class="details">
<p>Get the [locale] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getUrl">
<div class="location">at line 477</div>
<code> public string
<strong>getUrl</strong>()</code>
</h3>
<div class="details">
<p>Get the [url] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 488</div>
<code> public string
<strong>getDateFormat</strong>()</code>
</h3>
<div class="details">
<p>Get the [date_format] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 499</div>
<code> public string
<strong>getTimeFormat</strong>()</code>
</h3>
<div class="details">
<p>Get the [time_format] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 510</div>
<code> public string
<strong>getDatetimeFormat</strong>()</code>
</h3>
<div class="details">
<p>Get the [datetime_format] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 521</div>
<code> public string
<strong>getDecimalSeparator</strong>()</code>
</h3>
<div class="details">
<p>Get the [decimal_separator] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 532</div>
<code> public string
<strong><API key></strong>()</code>
</h3>
<div class="details">
<p>Get the [thousands_separator] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getDecimals">
<div class="location">at line 543</div>
<code> public string
<strong>getDecimals</strong>()</code>
</h3>
<div class="details">
<p>Get the [decimals] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getByDefault">
<div class="location">at line 554</div>
<code> public int
<strong>getByDefault</strong>()</code>
</h3>
<div class="details">
<p>Get the [by_default] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getPosition">
<div class="location">at line 565</div>
<code> public int
<strong>getPosition</strong>()</code>
</h3>
<div class="details">
<p>Get the [position] column value.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getCreatedAt">
<div class="location">at line 582</div>
<code> public mixed
<strong>getCreatedAt</strong>(string $format = NULL)</code>
</h3>
<div class="details">
<p>Get the [optionally formatted] temporal [created_at] column value.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$format</td>
<td>The date/time format string (either date()-style or strftime()-style). If format is NULL, then the raw \DateTime object will be returned.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>mixed</td>
<td>Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td><ul>
<li>if unable to parse/validate the date/time value.</li>
</ul>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getUpdatedAt">
<div class="location">at line 602</div>
<code> public mixed
<strong>getUpdatedAt</strong>(string $format = NULL)</code>
</h3>
<div class="details">
<p>Get the [optionally formatted] temporal [updated_at] column value.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$format</td>
<td>The date/time format string (either date()-style or strftime()-style). If format is NULL, then the raw \DateTime object will be returned.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>mixed</td>
<td>Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td><ul>
<li>if unable to parse/validate the date/time value.</li>
</ul>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setId">
<div class="location">at line 617</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setId</strong>(int $v)</code>
</h3>
<div class="details">
<p>Set the value of [id] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setTitle">
<div class="location">at line 638</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setTitle</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [title] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setCode">
<div class="location">at line 659</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setCode</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [code] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setLocale">
<div class="location">at line 680</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setLocale</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [locale] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setUrl">
<div class="location">at line 701</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setUrl</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [url] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 722</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setDateFormat</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [date_format] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 743</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setTimeFormat</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [time_format] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 764</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setDatetimeFormat</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [datetime_format] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 785</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setDecimalSeparator</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [decimal_separator] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 806</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong><API key></strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [thousands_separator] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setDecimals">
<div class="location">at line 827</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setDecimals</strong>(string $v)</code>
</h3>
<div class="details">
<p>Set the value of [decimals] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setByDefault">
<div class="location">at line 848</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setByDefault</strong>(int $v)</code>
</h3>
<div class="details">
<p>Set the value of [by_default] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setPosition">
<div class="location">at line 869</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setPosition</strong>(int $v)</code>
</h3>
<div class="details">
<p>Set the value of [position] column.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$v</td>
<td>new value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setCreatedAt">
<div class="location">at line 891</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setCreatedAt</strong>(mixed $v)</code>
</h3>
<div class="details">
<p>Sets the value of [created_at] column to a normalized version of the date/time value specified.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>mixed</td>
<td>$v</td>
<td>string, integer (timestamp), or \DateTime value. Empty strings are treated as NULL.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setUpdatedAt">
<div class="location">at line 912</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setUpdatedAt</strong>(mixed $v)</code>
</h3>
<div class="details">
<p>Sets the value of [updated_at] column to a normalized version of the date/time value specified.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>mixed</td>
<td>$v</td>
<td>string, integer (timestamp), or \DateTime value. Empty strings are treated as NULL.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 934</div>
<code> public boolean
<strong><API key></strong>()</code>
</h3>
<div class="details">
<p>Indicates whether the columns in this object are only set to default values.</p>
<p>This method can be used in conjunction with isModified() to indicate whether an object is both
modified <em>and</em> has some values set which are non-default.</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>Whether the columns in this object are only been set with default values.</td>
</tr>
</table>
</div>
</div>
<h3 id="method_hydrate">
<div class="location">at line 958</div>
<code> public int
<strong>hydrate</strong>(array $row, int $startcol, boolean $rehydrate = false, string $indexType = TableMap::TYPE_NUM)</code>
</h3>
<div class="details">
<p>Hydrates (populates) the object variables with values from the database resultset.</p>
<p>An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>array</td>
<td>$row</td>
<td>The row returned by DataFetcher->fetch().</td>
</tr>
<tr>
<td>int</td>
<td>$startcol</td>
<td>0-based offset column which indicates which restultset column to start with.</td>
</tr>
<tr>
<td>boolean</td>
<td>$rehydrate</td>
<td>Whether this object is being re-hydrated from the database.</td>
</tr>
<tr>
<td>string</td>
<td>$indexType</td>
<td>The index type of $row. Mostly DataFetcher->getIndexType(). One of the class type constants TableMap::TYPE<em>PHPNAME, TableMap::TYPE</em>STUDLYPHPNAME TableMap::TYPE<em>COLNAME, TableMap::TYPE</em>FIELDNAME, TableMap::TYPE_NUM.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>next starting column</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td><ul>
<li>Any caught Exception will be rewrapped as a PropelException.</li>
</ul>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1041</div>
<code> public
<strong>ensureConsistency</strong>()</code>
</h3>
<div class="details">
<p>Checks and repairs the internal consistency of the object.</p>
<p>This method is executed after an <API key> object is re-hydrated
from the database. It exists to check any foreign keys to make sure that
the objects related to the current object are correct based on foreign key.</p>
<p>You can override this method in the stub class, but you should always invoke
the base method from the overridden method (i.e. parent::ensureConsistency()),
in case your model changes.</p>
<div class="tags">
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_reload">
<div class="location">at line 1055</div>
<code> public void
<strong>reload</strong>(boolean $deep = false, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Reloads this object from datastore based on primary key and (optionally) resets all associated objects.</p>
<p>This will only work if the object has been saved and has a valid primary key set.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$deep</td>
<td>(optional) Whether to also de-associated any related objects.</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>(optional) The ConnectionInterface connection to use.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td><ul>
<li>if this object is deleted, unsaved or doesn't have pk match in db</li>
</ul>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_delete">
<div class="location">at line 1096</div>
<code> public void
<strong>delete</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Removes this object from datastore and sets delete attribute.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
<h4>See also</h4>
<table>
<tr>
<td>Lang::setDeleted()</td>
<td></td>
</tr>
<tr>
<td>Lang::isDeleted()</td>
<td></td>
</tr>
</table>
</div>
</div>
<h3 id="method_save">
<div class="location">at line 1138</div>
<code> public int
<strong>save</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Persists this object to the database.</p>
<p>If the object is new, it inserts it; otherwise an update is performed.
All modified related objects will also be persisted in the doSave()
method. This method wraps all precipitate database operations in a
single transaction.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>The number of rows affected by this insert/update and any referring fk objects' save() operations.</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
<h4>See also</h4>
<table>
<tr>
<td>doSave()</td>
<td></td>
</tr>
</table>
</div>
</div>
<h3 id="method_getByName">
<div class="location">at line 1405</div>
<code> public mixed
<strong>getByName</strong>(string $name, string $type = TableMap::TYPE_PHPNAME)</code>
</h3>
<div class="details">
<p>Retrieves a field from the object by name passed in as a string.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>name</td>
</tr>
<tr>
<td>string</td>
<td>$type</td>
<td>The type of fieldname the $name is of: one of the class type constants TableMap::TYPE<em>PHPNAME, TableMap::TYPE</em>STUDLYPHPNAME TableMap::TYPE<em>COLNAME, TableMap::TYPE</em>FIELDNAME, TableMap::TYPE<em>NUM. Defaults to TableMap::TYPE</em>PHPNAME.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>mixed</td>
<td>Value of field.</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1420</div>
<code> public mixed
<strong>getByPosition</strong>(int $pos)</code>
</h3>
<div class="details">
<p>Retrieves a field from the object by Position as specified in the xml schema.</p>
<p>Zero-based.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$pos</td>
<td>position in xml schema</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>mixed</td>
<td>Value of field at $pos</td>
</tr>
</table>
</div>
</div>
<h3 id="method_toArray">
<div class="location">at line 1489</div>
<code> public array
<strong>toArray</strong>(string $keyType = TableMap::TYPE_PHPNAME, boolean $<API key> = true, array $<API key> = array(), boolean $<API key> = false)</code>
</h3>
<div class="details">
<p>Exports the object as an array.</p>
<p>You can specify the key type of the array by passing one of the class
type constants.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$keyType</td>
<td>(optional) One of the class type constants TableMap::TYPE<em>PHPNAME, TableMap::TYPE</em>STUDLYPHPNAME, TableMap::TYPE<em>COLNAME, TableMap::TYPE</em>FIELDNAME, TableMap::TYPE<em>NUM. Defaults to TableMap::TYPE</em>PHPNAME.</td>
</tr>
<tr>
<td>boolean</td>
<td>$<API key></td>
<td>(optional) Whether to include lazy loaded columns. Defaults to TRUE.</td>
</tr>
<tr>
<td>array</td>
<td>$<API key></td>
<td>List of objects to skip to avoid recursion</td>
</tr>
<tr>
<td>boolean</td>
<td>$<API key></td>
<td>(optional) Whether to include hydrated related objects. Default to FALSE.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>array</td>
<td>an associative array containing the field names (as keys) and field values</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setByName">
<div class="location">at line 1538</div>
<code> public void
<strong>setByName</strong>(string $name, mixed $value, string $type = TableMap::TYPE_PHPNAME)</code>
</h3>
<div class="details">
<p>Sets a field from the object by name passed in as a string.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>
</td>
</tr>
<tr>
<td>mixed</td>
<td>$value</td>
<td>field value</td>
</tr>
<tr>
<td>string</td>
<td>$type</td>
<td>The type of fieldname the $name is of: one of the class type constants TableMap::TYPE<em>PHPNAME, TableMap::TYPE</em>STUDLYPHPNAME TableMap::TYPE<em>COLNAME, TableMap::TYPE</em>FIELDNAME, TableMap::TYPE<em>NUM. Defaults to TableMap::TYPE</em>PHPNAME.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1553</div>
<code> public void
<strong>setByPosition</strong>(int $pos, mixed $value)</code>
</h3>
<div class="details">
<p>Sets a field from the object by Position as specified in the xml schema.</p>
<p>Zero-based.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$pos</td>
<td>position in xml schema</td>
</tr>
<tr>
<td>mixed</td>
<td>$value</td>
<td>field value</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_fromArray">
<div class="location">at line 1621</div>
<code> public void
<strong>fromArray</strong>(array $arr, string $keyType = TableMap::TYPE_PHPNAME)</code>
</h3>
<div class="details">
<p>Populates the object using an array.</p>
<p>This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.</p>
<p>You can specify the key type of the array by additionally passing one
of the class type constants TableMap::TYPE<em>PHPNAME, TableMap::TYPE</em>STUDLYPHPNAME,
TableMap::TYPE<em>COLNAME, TableMap::TYPE</em>FIELDNAME, TableMap::TYPE<em>NUM.
The default key type is the column's TableMap::TYPE</em>PHPNAME.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>array</td>
<td>$arr</td>
<td>An array to populate the object from.</td>
</tr>
<tr>
<td>string</td>
<td>$keyType</td>
<td>The type of keys the array uses.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1647</div>
<code> public <abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr>
<strong>buildCriteria</strong>()</code>
</h3>
<div class="details">
<p>Build a Criteria object containing the values of all modified columns in this object.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>The Criteria object containing all modified values.</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1678</div>
<code> public <abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr>
<strong>buildPkeyCriteria</strong>()</code>
</h3>
<div class="details">
<p>Builds a Criteria object containing the primary key for this object.</p>
<p>Unlike buildCriteria() this method includes the primary key values regardless
of whether or not they have been modified.</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>The Criteria object containing value(s) for primary key(s).</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1690</div>
<code> public int
<strong>getPrimaryKey</strong>()</code>
</h3>
<div class="details">
<p>Returns the primary key for this object (row).</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1701</div>
<code> public void
<strong>setPrimaryKey</strong>(int $key)</code>
</h3>
<div class="details">
<p>Generic method to set the primary key (id column).</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>int</td>
<td>$key</td>
<td>Primary key.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1710</div>
<code> public boolean
<strong>isPrimaryKeyNull</strong>()</code>
</h3>
<div class="details">
<p>Returns true if the primary key for this object is null.</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_copyInto">
<div class="location">at line 1727</div>
<code> public
<strong>copyInto</strong>(object $copyObj, boolean $deepCopy = false, boolean $makeNew = true)</code>
</h3>
<div class="details">
<p>Sets contents of passed object to values from current object.</p>
<p>If desired, this method can also make copies of all associated (fkey referrers)
objects.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>object</td>
<td>$copyObj</td>
<td>An object of \Thelia\Model\Lang (or compatible) type.</td>
</tr>
<tr>
<td>boolean</td>
<td>$deepCopy</td>
<td>Whether to also copy all rows that refer (by fkey) to the current row.</td>
</tr>
<tr>
<td>boolean</td>
<td>$makeNew</td>
<td>Whether to reset autoincrement PKs and make the object new.</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_copy">
<div class="location">at line 1775</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>copy</strong>(boolean $deepCopy = false)</code>
</h3>
<div class="details">
<p>Makes a copy of this object that will be inserted as a new row in table when saved.</p>
<p>It creates a new object filling in the simple attributes, but skipping any primary
keys that are defined for the table.</p>
<p>If desired, this method can also make copies of all associated (fkey referrers)
objects.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$deepCopy</td>
<td>Whether to also copy all rows that refer (by fkey) to the current row.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>Clone of current object.</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_initRelation">
<div class="location">at line 1794</div>
<code> public void
<strong>initRelation</strong>(string $relationName)</code>
</h3>
<div class="details">
<p>Initializes a collection based on the name of a relation.</p>
<p>Avoids crafting an 'init[$relationName]s' method name
that wouldn't work when <API key> is used.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$relationName</td>
<td>The name of the relation to initialize</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_clearOrders">
<div class="location">at line 1810</div>
<code> public void
<strong>clearOrders</strong>()</code>
</h3>
<div class="details">
<p>Clears out the collOrders collection</p>
<p>This does not modify the database; however, it will remove any associated objects, causing
them to be refetched by subsequent calls to accessor method.</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
<h4>See also</h4>
<table>
<tr>
<td>addOrders()</td>
<td></td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 1818</div>
<code> public
<strong>resetPartialOrders</strong>($v = true)</code>
</h3>
<div class="details">
<p>Reset is the collOrders collection loaded partially.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td></td>
<td>$v</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_initOrders">
<div class="location">at line 1835</div>
<code> public void
<strong>initOrders</strong>(boolean $overrideExisting = true)</code>
</h3>
<div class="details">
<p>Initializes the collOrders collection.</p>
<p>By default this just sets the collOrders collection to an empty array (like clearcollOrders());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$overrideExisting</td>
<td>If set to true, the method call initializes the collection even if it is not empty</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>void</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_getOrders">
<div class="location">at line 1858</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong>getOrders</strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Gets an array of ChildOrder objects which contain a foreign key that references this object.</p>
<p>If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildLang is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_setOrders">
<div class="location">at line 1914</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>setOrders</strong>(<abbr title="Propel\Runtime\Collection\Collection">Collection</abbr> $orders, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Sets a collection of Order objects related by a one-to-many relationship to the current object.</p>
<p>It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr></td>
<td>$orders</td>
<td>A Propel collection.</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>Optional connection object</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_countOrders">
<div class="location">at line 1945</div>
<code> public int
<strong>countOrders</strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, boolean $distinct = false, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Returns the number of related Order objects.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>
</td>
</tr>
<tr>
<td>boolean</td>
<td>$distinct</td>
<td>
</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>int</td>
<td>Count of related Order objects.</td>
</tr>
</table>
<h4>Exceptions</h4>
<table>
<tr>
<td><abbr title="PropelException">PropelException</abbr></td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_addOrder">
<div class="location">at line 1977</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>addOrder</strong>(<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a> $l)</code>
</h3>
<div class="details">
<p>Method called to associate a ChildOrder object to this object through the ChildOrder foreign key attribute.</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a></td>
<td>$l</td>
<td>ChildOrder</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_removeOrder">
<div class="location">at line 2004</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong>removeOrder</strong>(<a href="../../../Thelia/Model/Base/Order.html"><abbr title="Thelia\Model\Base\Order">Order</abbr></a> $order)</code>
</h3>
<div class="details">
<p>
</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Base/Order.html"><abbr title="Thelia\Model\Base\Order">Order</abbr></a></td>
<td>$order</td>
<td>The order object to remove.</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2036</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2061</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2086</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2111</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2136</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2161</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2186</div>
<code> public <abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]
<strong><API key></strong>(<abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr> $criteria = null, <abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null, string $joinBehavior = Criteria::LEFT_JOIN)</code>
</h3>
<div class="details">
<p>If this collection has already been initialized with an identical criteria, it returns the collection.</p>
<p>Otherwise if this Lang is new, it will return
an empty collection; or if this Lang has previously
been saved, it will retrieve related Orders from storage.</p>
<p>This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in Lang.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\ActiveQuery\Criteria">Criteria</abbr></td>
<td>$criteria</td>
<td>optional Criteria object to narrow the query</td>
</tr>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>optional connection object</td>
</tr>
<tr>
<td>string</td>
<td>$joinBehavior</td>
<td>optional join type to use (defaults to Criteria::LEFT_JOIN)</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Collection\Collection">Collection</abbr>|<a href="../../../Thelia/Model/Order.html"><abbr title="Thelia\Model\Order">Order</abbr></a>[]</td>
<td>List of ChildOrder objects</td>
</tr>
</table>
</div>
</div>
<h3 id="method_clear">
<div class="location">at line 2197</div>
<code> public
<strong>clear</strong>()</code>
</h3>
<div class="details">
<p>Clears the current object and sets all attributes to their default values</p>
<p>
</p>
<div class="tags">
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2230</div>
<code> public
<strong>clearAllReferences</strong>(boolean $deep = false)</code>
</h3>
<div class="details">
<p>Resets all references to other model objects or collections of model objects.</p>
<p>This method is a user-space workaround for PHP's inability to garbage collect
objects with circular references (even in PHP 5.3). This is currently necessary
when using Propel in certain daemon or large-volume/high-memory operations.</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>boolean</td>
<td>$deep</td>
<td>Whether to also clear the references on all referrer objects.</td>
</tr>
</table>
</div>
</div>
<h3 id="method___toString">
<div class="location">at line 2251</div>
<code> public string
<strong>__toString</strong>()</code>
</h3>
<div class="details">
<p>Return the string representation of this object</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td>string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="<API key>">
<div class="location">at line 2263</div>
<code> public <a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a>
<strong><API key></strong>()</code>
</h3>
<div class="details">
<p>Mark the current object so that the update date doesn't get updated during next save</p>
<p>
</p>
<div class="tags">
<h4>Return Value</h4>
<table>
<tr>
<td><a href="../../../Thelia/Model/Lang.html"><abbr title="Thelia\Model\Lang">Lang</abbr></a></td>
<td>The current object (for fluent API support)</td>
</tr>
</table>
</div>
</div>
<h3 id="method_preSave">
<div class="location">at line 2275</div>
<code> public boolean
<strong>preSave</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run before persisting the object</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_postSave">
<div class="location">at line 2284</div>
<code> public
<strong>postSave</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run after persisting the object</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_preInsert">
<div class="location">at line 2294</div>
<code> public boolean
<strong>preInsert</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run before inserting to database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_postInsert">
<div class="location">at line 2303</div>
<code> public
<strong>postInsert</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run after inserting to database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_preUpdate">
<div class="location">at line 2313</div>
<code> public boolean
<strong>preUpdate</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run before updating the object in database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_postUpdate">
<div class="location">at line 2322</div>
<code> public
<strong>postUpdate</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run after updating the object in database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_preDelete">
<div class="location">at line 2332</div>
<code> public boolean
<strong>preDelete</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run before deleting the object in database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>boolean</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method_postDelete">
<div class="location">at line 2341</div>
<code> public
<strong>postDelete</strong>(<abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr> $con = null)</code>
</h3>
<div class="details">
<p>Code to be run after deleting the object in database</p>
<p>
</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td><abbr title="Propel\Runtime\Connection\ConnectionInterface">ConnectionInterface</abbr></td>
<td>$con</td>
<td>
</td>
</tr>
</table>
</div>
</div>
<h3 id="method___call">
<div class="location">at line 2358</div>
<code> public array|string
<strong>__call</strong>(string $name, mixed $params)</code>
</h3>
<div class="details">
<p>Derived method to catches calls to undefined methods.</p>
<p>Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
Allows to define default __call() behavior if you overwrite __call()</p>
<div class="tags">
<h4>Parameters</h4>
<table>
<tr>
<td>string</td>
<td>$name</td>
<td>
</td>
</tr>
<tr>
<td>mixed</td>
<td>$params</td>
<td>
</td>
</tr>
</table>
<h4>Return Value</h4>
<table>
<tr>
<td>array|string</td>
<td>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated by <a href="http://sami.sensiolabs.org/" target="_top">Sami, the API Documentation Generator</a>.
</div>
</body>
</html> |
// By: The Aaron, Arcane Scriptomancer
var BounceTokens = BounceTokens || (function(){
'use strict';
var version = '0.1.0',
lastUpdate = 1473882811,
schemaVersion = 0.1,
bounceInterval = false,
stepRate = 200,
<API key> = 20,
<API key> = 1000,
ch = function (c) {
var entities = {
'<' : 'lt',
'>' : 'gt',
"'" : '
'@' : '
'{' : '#123',
'|' : '#124',
'}' : '#125',
'[' : '
']' : '
'"' : 'quot',
'-' : 'mdash',
' ' : 'nbsp'
};
if(_.has(entities,c) ){
return ('&'+entities[c]+';');
}
return '';
},
showHelp = function() {
sendChat('',
'/w gm '+
'<div style="border: 1px solid black; background-color: white; padding: 3px 3px;">'+
'<div style="font-weight: bold; border-bottom: 1px solid black;font-size: 130%;">'+
'BounceTokens v'+version+
'<div style="clear: both"></div>'+
'</div>'+
'<div style="padding-left:10px;margin-bottom:3px;">'+
'<p>Allows the GM to toggle bouncing of selected tokens</p>'+
'</div>'+
'<b>Commands</b>'+
'<div style="padding-left:10px;"><b><span style="font-family: serif;">!bounce-start '+ch('[')+'Seconds Per Cycle'+ch(']')+'</span></b>'+
'<div style="padding-left: 10px;padding-right:20px">'+
'Starts a selected token bouncing, optionally with a speed.'+
'<ul>'+
'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'+
'<b><span style="font-family: serif;">Seconds Per Cycle</span></b> '+ch('-')+' Specifies the number of seconds for the token to make a full bounce. <b>Default: '+<API key> +'</b></li>'+
'</li> '+
'</ul>'+
'</div>'+
'</div>'+
'<div style="padding-left:10px;"><b><span style="font-family: serif;">!bounce-stop</span></b>'+
'<div style="padding-left: 10px;padding-right:20px">'+
'Stops the selected tokens from bouncing.'+
'</div>'+
'</div>'+
'</div>'
);
},
handleInput = function(msg) {
var args,
secondsPerCycle;
if ( "api" !== msg.type || !playerIsGM(msg.playerid) ) {
return;
}
args = msg.content.split(/\s+/);
switch(args[0]) {
case '!bounce-start':
if(!( msg.selected && msg.selected.length > 0 ) ) {
showHelp();
return;
}
secondsPerCycle = Math.abs(args[1] || <API key>);
_.chain(msg.selected)
.map(function (o) {
return getObj(o._type,o._id);
})
.filter(function(o){
return 'token' === o.get('subtype');
})
.each(function(o){
state.BounceTokens.bouncers[o.id]={
id: o.id,
top: o.get('top'),
page: o.get('pageid'),
rate: (secondsPerCycle*<API key>)
};
})
;
break;
case '!bounce-stop':
if(!( msg.selected && msg.selected.length > 0 ) ) {
showHelp();
return;
}
_.chain(msg.selected)
.map(function (o) {
return getObj(o._type,o._id);
})
.filter(function(o){
return 'token' === o.get('subtype');
})
.each(function(o){
o.set('top',state.BounceTokens.bouncers[o.id].top);
delete state.BounceTokens.bouncers[o.id];
})
;
break;
}
},
animateBounce = function() {
var pages = _.union([Campaign().get('playerpageid')], _.values(Campaign().get('playerspecificpages')));
_.chain(state.BounceTokens.bouncers)
.filter(function(o){
return _.contains(pages,o.page);
})
.each(function(sdata){
var s = getObj('graphic',sdata.id);
if(!s) {
delete state.BounceTokens.bouncers[sdata.id];
} else {
s.set({
top: state.BounceTokens.bouncers[sdata.id].top - (s.get('height')*0.25)*Math.sin(( (Date.now()%sdata.rate)/sdata.rate )*Math.PI)
});
}
});
},
handleTokenDelete = function(obj) {
var found = _.findWhere(state.BounceTokens.bouncers, {id: obj.id});
if(found) {
delete state.BounceTokens.bouncers[obj.id];
}
},
handleTokenChange = function(obj) {
var found = _.findWhere(state.BounceTokens.bouncers, {id: obj.id});
if(found) {
state.BounceTokens.bouncers[obj.id].top= obj.get('top');
}
},
checkInstall = function() {
log('-=> BounceTokens v'+version+' <=- ['+(new Date(lastUpdate*1000))+']');
if( ! _.has(state,'BounceTokens') || state.BounceTokens.version !== schemaVersion) {
log(' > Updating Schema to v'+schemaVersion+' <');
state.BounceTokens = {
version: schemaVersion,
bouncers: {}
};
}
bounceInterval = setInterval(animateBounce,stepRate);
},
<API key> = function() {
on('chat:message', handleInput);
on('destroy:graphic', handleTokenDelete);
on('change:graphic', handleTokenChange);
};
return {
CheckInstall: checkInstall,
<API key>: <API key>
};
}());
on("ready",function(){
'use strict';
BounceTokens.CheckInstall();
BounceTokens.<API key>();
}); |
2014-05-04
#objective-c
* [qvacua/vimr](https:
* [nealyoung/NYSegmentedControl](https://github.com/nealyoung/NYSegmentedControl): Animated, customizable replacement for UISegmentedControl
* [brunophilipe/Cakebrew](https://github.com/brunophilipe/Cakebrew): Manage your Homebrew formulas with style using Cakebrew. It is a fork of Homebrew-GUI by vincentsaluzzo.
* [poetmountain/PMTween](https://github.com/poetmountain/PMTween): An elegant and flexible tweening library for iOS.
* [uzysjung/<API key>](https://github.com/uzysjung/<API key>): Add PullToRefresh using animated GIF to any scrollView with just simple code
* [BoltsFramework/Bolts-iOS](https://github.com/BoltsFramework/Bolts-iOS): Bolts is a collection of low-level libraries designed to make developing mobile apps easier.
* [antiraum/THPinViewController](https://github.com/antiraum/THPinViewController): iOS 7 Style PIN Screen for iPhone and iPad
* [facebook/Shimmer](https://github.com/facebook/Shimmer): An easy way to add a simple shimmering effect to any view in an iOS app, which is particularly useful as an unobtrusive loading indicator.
* [facebook/Tweaks](https://github.com/facebook/Tweaks): Easily adjust parameters for iOS apps in development.
* [mxcl/PromiseKit](https://github.com/mxcl/PromiseKit): A delightful Promises implementation for iOS
* [michalkonturek/GraphKit](https://github.com/michalkonturek/GraphKit): A lightweight library of animated graphs for iOS.
* [AFNetworking/AFNetworking](https://github.com/AFNetworking/AFNetworking): A delightful iOS and OS X networking framework
* [orta/ARAnalytics](https://github.com/orta/ARAnalytics): Simplify your iOS analytics
* [jamztang/<API key>](https://github.com/jamztang/<API key>): UICollectionView replacement of UITableView. Do even more like Parallax Header, Sticky Section Header. Made for iOS 7.
* [matthewcheok/POP-MCAnimate](https://github.com/matthewcheok/POP-MCAnimate): Concise syntax for the Pop animation framework.
* [dhennessy/PAPreferences](https://github.com/dhennessy/PAPreferences): Using @dynamic to access NSUserDefaults.
* [andreamazz/AMWaveTransition](https://github.com/andreamazz/AMWaveTransition): Custom transition between viewcontrollers holding tableviews
* [lostinthepines/TutorialKit](https://github.com/lostinthepines/TutorialKit): TutorialKit
* [ReactiveCocoa/ReactiveCocoa](https://github.com/ReactiveCocoa/ReactiveCocoa): A framework for composing and transforming streams of values
* [xhacker/TEAChart](https://github.com/xhacker/TEAChart): Simple and intuitive iOS chart library. Contribution graph, clock chart, and bar chart.
* [fastred/AHKActionSheet](https://github.com/fastred/AHKActionSheet): An alternative to the UIActionSheet inspired by the Spotify app.
* [romaonthego/RESideMenu](https://github.com/romaonthego/RESideMenu): iOS 7 style side menu with parallax effect.
* [smyrgl/RESTEasy](https://github.com/smyrgl/RESTEasy): A dead simple RESTful server that runs INSIDE your iOS/OSX app.
* [deivuh/<API key>](https://github.com/deivuh/<API key>): A Digital Ocean droplets manager for OSX
* [xhzengAIB/MessageDisplayKit](https://github.com/xhzengAIB/MessageDisplayKit): A messages UI for iPhone and iPad. You can send texts, voice messages, images, videos, and emotions, etc. It's similar to the Wechat app.
* [zachlatta/postman](https://github.com/zachlatta/postman): Command-line utility for batch-sending email.
* [dotcloud/docker](https://github.com/dotcloud/docker): Docker - the open-source application container engine
* [soundcloud/roshi](https://github.com/soundcloud/roshi): Roshi is a large-scale CRDT set implementation for timestamped events.
* [mailgun/vulcand](https://github.com/mailgun/vulcand): HTTP proxy that uses Etcd as a configuration backend.
* [go-martini/martini](https://github.com/go-martini/martini): Classy web framework for Go
* [inconshreveable/ngrok](https://github.com/inconshreveable/ngrok): Introspected tunnels to localhost
* [tsuru/tsuru](https://github.com/tsuru/tsuru): Open source Platform as a Service.
* [sjwhitworth/golearn](https://github.com/sjwhitworth/golearn): Machine Learning for Go
* [limetext/lime](https://github.com/limetext/lime): Experimental Sublime Text clone
* [zenazn/goji](https://github.com/zenazn/goji): Goji is a minimalistic web framework for Golang inspired by Sinatra that's high in antioxidants
* [streadway/handy](https://github.com/streadway/handy): net/http handler filters
* [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata): A small utility which generates Go code from any file. Useful for embedding binary data in a Go program.
* [bitly/nsq](https://github.com/bitly/nsq): A realtime distributed messaging platform
* [gogits/gogs](https://github.com/gogits/gogs): Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language.
* [go-validator/validator](https://github.com/go-validator/validator): Package validator implements struct field validations
* [apg/wipes](https://github.com/apg/wipes): Pipe text to a WebSocket server
* [astaxie/<API key>](https://github.com/astaxie/<API key>): A golang ebook intro how to build a web with golang
* [hashicorp/consul](https://github.com/hashicorp/consul): Consul is a tool for service discovery, monitoring and configuration.
* [go-xorm/xorm](https://github.com/go-xorm/xorm): A Simple and Powerful ORM for Go.
* [influxdb/influxdb](https://github.com/influxdb/influxdb): Scalable datastore for metrics, events, and real-time analytics
* [revel/revel](https://github.com/revel/revel): A high productivity, full-stack web framework for the Go language.
* [astaxie/beego](https://github.com/astaxie/beego): beego is an open-source, high-performance web framework for the Go programming language.
* [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql): Go-MySQL-Driver is a lightweight and fast MySQL-Driver for Go's (golang) database/sql package
* [hybridgroup/gobot](https://github.com/hybridgroup/gobot): A Go framework/set of libraries for robotics and physical computing
* [garyburd/redigo](https://github.com/garyburd/redigo): Go client for Redis
#javascript
* [julianshapiro/velocity](https://github.com/julianshapiro/velocity): Accelerated JavaScript animation.
* [GitbookIO/gitbook](https://github.com/GitbookIO/gitbook): Command line utility for generating books and exercises using GitHub/Git and Markdown
* [jansmolders86/mediacenterjs](https://github.com/jansmolders86/mediacenterjs): A HTML/CSS/Javascipt (NodeJs) based Mediacenter
* [angular/angular.js](https://github.com/angular/angular.js): HTML enhanced for web apps
* [jdan/isomer](https://github.com/jdan/isomer): Simple isometric graphics library for HTML5 canvas
* [ruanyf/es6tutorial](https://github.com/ruanyf/es6tutorial): ECMAScript 6JavaScriptECMAScript 6
* [masayuki0812/c3](https://github.com/masayuki0812/c3): A D3-based reusable chart library
* [popcorn-official/popcorn-app](https://github.com/popcorn-official/popcorn-app): Allow easily streaming from torrents, without any particular knowledge.
* [n3-charts/line-chart](https://github.com/n3-charts/line-chart): Awesome charts for AngularJS.
* [brianreavis/selectize.js](https://github.com/brianreavis/selectize.js): Selectize is the hybrid of a textbox and <select> box. It's jQuery based and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.
* [joyent/node](https://github.com/joyent/node): evented I/O for v8 javascript
* [kolodny/webwork](https://github.com/kolodny/webwork): Execute Web Workers without external files
* [meteor/meteor](https://github.com/meteor/meteor): Meteor, an ultra-simple, database-everywhere, data-on-the-wire, pure-Javascript web framework.
* [facebook/react](https://github.com/facebook/react): React is a JavaScript library for building user interfaces. It's declarative, efficient, and extremely flexible. What's more, it works with the libraries and frameworks that you already know.
* [adobe/brackets](https://github.com/adobe/brackets): An open source code editor for the web, written in JavaScript, HTML and CSS.
* [cheeriojs/cheerio](https://github.com/cheeriojs/cheerio): Fast, flexible, and lean implementation of core jQuery designed specifically for the server.
* [visionmedia/express](https://github.com/visionmedia/express): Sinatra inspired web development framework for node.js -- insanely fast, flexible, and simple
* [moment/moment](https://github.com/moment/moment): Parse, validate, manipulate, and display dates in javascript.
* [conveyal/transitive.js](https://github.com/conveyal/transitive.js): Transit data visualization
* [TryGhost/Ghost](https://github.com/TryGhost/Ghost): Just a blogging platform
* [kenwheeler/slick](https://github.com/kenwheeler/slick): the last carousel you'll ever need
* [petkaantonov/bluebird](https://github.com/petkaantonov/bluebird): Bluebird is a full featured promise library with unmatched performance.
* [linnovate/mean](https://github.com/linnovate/mean): MEAN (Mongo, Express, Angular, Node) - A Simple, Scalable and Easy starting point for full stack javascript web development - utilizing many of the best practices we've found on the way
* [photonstorm/phaser](https://github.com/photonstorm/phaser): Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
* [bower/bower](https://github.com/bower/bower): A package manager for the web |
package lila
package object push extends PackageObject {
private[push] def logger = lila.log("push")
} |
#include <stdint.h>
#include "dl/api/arm/armOMX.h"
#include "dl/api/omxtypes.h"
#include "dl/sp/api/armSP.h"
#include "dl/sp/api/omxSP.h"
/**
* Function: omxSP_FFTInit_R_F32
*
* Description:
* Initialize the real forward-FFT specification information struct.
*
* Remarks:
* This function is used to initialize the specification structures
* for functions <<API key>> and
* <<API key>>. Memory for *pFFTSpec must be
* allocated prior to calling this function. The number of bytes
* required for *pFFTSpec can be determined using
* <FFTGetBufSize_R_F32>.
*
* Parameters:
* [in] order base-2 logarithm of the desired block length;
* valid in the range [1,12]. ([1,15] if
* BIG_FFT_TABLE is defined.)
* [out] pFFTFwdSpec pointer to the initialized specification structure.
*
* Return Value:
* Standard omxError result. See enumeration for possible result codes.
*
*/
OMXResult omxSP_FFTInit_R_F32(OMXFFTSpec_R_F32* pFFTSpec, OMX_INT order) {
OMX_INT i;
OMX_INT j;
OMX_FC32* pTwiddle;
OMX_FC32* pTwiddle1;
OMX_FC32* pTwiddle2;
OMX_FC32* pTwiddle3;
OMX_FC32* pTwiddle4;
OMX_F32* pBuf;
OMX_U16* pBitRev;
OMX_U32 pTmp;
OMX_INT Nby2;
OMX_INT N;
OMX_INT M;
OMX_INT diff;
OMX_INT step;
OMX_F32 x;
OMX_F32 y;
OMX_F32 xNeg;
ARMsFFTSpec_R_FC32* pFFTStruct = 0;
pFFTStruct = (ARMsFFTSpec_R_FC32 *) pFFTSpec;
/* Validate args */
if (!pFFTSpec || (order < 1) || (order > TWIDDLE_TABLE_ORDER))
return OMX_Sts_BadArgErr;
/* Do the initializations */
Nby2 = 1 << (order - 1);
N = Nby2 << 1;
/* optimized implementations don't use bitreversal */
pBitRev = NULL;
pTwiddle = (OMX_FC32 *) (sizeof(ARMsFFTSpec_R_SC32) + (OMX_S8*) pFFTSpec);
/* Align to 32 byte boundary */
pTmp = ((uintptr_t)pTwiddle) & 31;
if (pTmp)
pTwiddle = (OMX_FC32*) ((OMX_S8*)pTwiddle + (32 - pTmp));
pBuf = (OMX_F32*) (sizeof(OMX_FC32)*(5*N/8) + (OMX_S8*) pTwiddle);
/* Align to 32 byte boundary */
pTmp = ((uintptr_t)pBuf)&31; /* (uintptr_t)pBuf % 32 */
if (pTmp)
pBuf = (OMX_F32*) ((OMX_S8*)pBuf + (32 - pTmp));
/*
* Filling Twiddle factors :
*
* exp^(-j*2*PI*k/ (N/2) ) ; k=0,1,2,...,3/4(N/2)
*
* N/2 point complex FFT is used to compute N point real FFT The
* original twiddle table "<API key>" is of size
* (MaxSize/8 + 1) Rest of the values i.e., upto MaxSize are
* calculated using the symmetries of sin and cos The max size of
* the twiddle table needed is 3/4(N/2) for a radix-4 stage
*
* W = (-2 * PI) / N
* N = 1 << order
* W = -PI >> (order - 1)
*/
M = Nby2 >> 3;
diff = TWIDDLE_TABLE_ORDER - (order - 1);
/* step into the twiddle table for the current order */
step = 1 << diff;
x = <API key>[0];
y = <API key>[1];
xNeg = 1;
if ((order - 1) >= 3) {
/* i = 0 case */
pTwiddle[0].Re = x;
pTwiddle[0].Im = y;
pTwiddle[2*M].Re = -y;
pTwiddle[2*M].Im = xNeg;
pTwiddle[4*M].Re = xNeg;
pTwiddle[4*M].Im = y;
for (i = 1; i <= M; i++) {
j = i*step;
x = <API key>[2*j];
y = <API key>[2*j+1];
pTwiddle[i].Re = x;
pTwiddle[i].Im = y;
pTwiddle[2*M-i].Re = -y;
pTwiddle[2*M-i].Im = -x;
pTwiddle[2*M+i].Re = y;
pTwiddle[2*M+i].Im = -x;
pTwiddle[4*M-i].Re = -x;
pTwiddle[4*M-i].Im = y;
pTwiddle[4*M+i].Re = -x;
pTwiddle[4*M+i].Im = -y;
pTwiddle[6*M-i].Re = y;
pTwiddle[6*M-i].Im = x;
}
} else if ((order - 1) == 2) {
pTwiddle[0].Re = x;
pTwiddle[0].Im = y;
pTwiddle[1].Re = -y;
pTwiddle[1].Im = xNeg;
pTwiddle[2].Re = xNeg;
pTwiddle[2].Im = y;
} else if ((order-1) == 1) {
pTwiddle[0].Re = x;
pTwiddle[0].Im = y;
}
/*
* Now fill the last N/4 values : exp^(-j*2*PI*k/N) ;
* k=1,3,5,...,N/2-1 These are used for the final twiddle fix-up for
* converting complex to real FFT
*/
M = N >> 3;
diff = TWIDDLE_TABLE_ORDER - order;
step = 1 << diff;
pTwiddle1 = pTwiddle + 3*N/8;
pTwiddle4 = pTwiddle1 + (N/4 - 1);
pTwiddle3 = pTwiddle1 + N/8;
pTwiddle2 = pTwiddle1 + (N/8 - 1);
x = <API key>[0];
y = <API key>[1];
xNeg = 1;
if (order >=3) {
for (i = 1; i <= M; i += 2) {
j = i*step;
x = <API key>[2*j];
y = <API key>[2*j+1];
pTwiddle1[0].Re = x;
pTwiddle1[0].Im = y;
pTwiddle1 += 1;
pTwiddle2[0].Re = -y;
pTwiddle2[0].Im = -x;
pTwiddle2 -= 1;
pTwiddle3[0].Re = y;
pTwiddle3[0].Im = -x;
pTwiddle3 += 1;
pTwiddle4[0].Re = -x;
pTwiddle4[0].Im = y;
pTwiddle4 -= 1;
}
} else {
if (order == 2) {
pTwiddle1[0].Re = -y;
pTwiddle1[0].Im = xNeg;
}
}
/* Update the structure */
pFFTStruct->N = N;
pFFTStruct->pTwiddle = pTwiddle;
pFFTStruct->pBitRev = pBitRev;
pFFTStruct->pBuf = pBuf;
return OMX_Sts_NoErr;
} |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="robots" content="index, follow, all" />
<title>Thelia\Core\Event\TheliaEvents | </title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css">
</head>
<body id="class">
<div class="header">
<ul>
<li><a href="../../../classes.html">Classes</a></li>
<li><a href="../../../namespaces.html">Namespaces</a></li>
<li><a href="../../../interfaces.html">Interfaces</a></li>
<li><a href="../../../traits.html">Traits</a></li>
<li><a href="../../../doc-index.html">Index</a></li>
</ul>
<div id="title"></div>
<div class="type">Class</div>
<h1><a href="../../../Thelia/Core/Event.html">Thelia\Core\Event</a>\TheliaEvents</h1>
</div>
<div class="content">
<p> class
<strong>TheliaEvents</strong></p>
<div class="description">
<p>This class contains all Thelia events identifiers used by Thelia Core</p>
<p>
</p>
</div>
<h2>Constants</h2>
<table>
<tr>
<td>BOOT</td>
<td class="last">
<p><em>sent at the beginning</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent once the address creation form has been successfully validated, and before address insertion in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADDRESS_CREATE</td>
<td class="last">
<p><em>sent for address creation</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEADDRESS</td>
<td class="last">
<p><em>Sent just after a successful insert of a new address in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADDRESS_UPDATE</td>
<td class="last">
<p><em>sent for address modification</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEADDRESS</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADDRESS_DELETE</td>
<td class="last">
<p><em>sent on address removal</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEADDRESS</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADDRESS_DEFAULT</td>
<td class="last">
<p><em>sent when an address is tag as default</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADMIN_LOGOUT</td>
<td class="last">
<p><em>Sent before the logout of the administrator.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ADMIN_LOGIN</td>
<td class="last">
<p><em>Sent once the administrator is successfully logged in.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_POSTAGE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_ADD_COUNTRY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_REMOVE_COUNTRY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AREA_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEAREA</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CATEGORY_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CATEGORY_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CATEGORY_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CATEGORY_UPDATE_SEO</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONTENT_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATECONTENT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONTENT_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATECONTENT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONTENT_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETECONTENT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONTENT_UPDATE_SEO</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONTENT_ADD_FOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUNTRY_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATECOUNTRY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUNTRY_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATECOUNTRY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUNTRY_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETECOUNTRY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CUSTOMER_LOGOUT</td>
<td class="last">
<p><em>Sent before the logout of the customer.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CUSTOMER_LOGIN</td>
<td class="last">
<p><em>Sent once the customer is successfully logged in.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent once the customer creation form has been successfully validated, and before customer insertion in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent on customer account creation</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just after a successful insert of a new customer in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent on customer account update</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent once the customer change form has been successfully validated, and before customer update in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent on customer account update profile</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just after a successful update of a customer in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent just before customer removal</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent on customer removal</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent on customer address removal</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent just after customer removal</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LOST_PASSWORD</td>
<td class="last">
<p><em>sent when a customer need a new password</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FOLDER_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FOLDER_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FOLDER_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEFOLDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FOLDER_UPDATE_SEO</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PRODUCT_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEPRODUCT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PRODUCT_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEPRODUCT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PRODUCT_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEPRODUCT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PRODUCT_UPDATE_SEO</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PRODUCT_ADD_CONTENT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Restore a current cart in the session, either by reloading it from the database, or creating a new one</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_CREATE_NEW</td>
<td class="last">
<p><em>Create a new, empty cart in the session, and attach it to the current customer, if any.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_DUPLICATE</td>
<td class="last">
<p><em>sent when a new existing cat id duplicated.</em></p>
<p>This append when current customer is different from current cart</p>
</td>
</tr>
<tr>
<td>CART_ITEM_DUPLICATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CARTADDITEM</td>
<td class="last">
<p><em>sent when a new item is added to current cart</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent when a cart item is modify</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_ADDITEM</td>
<td class="last">
<p><em>sent for addArticle action</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_UPDATEITEM</td>
<td class="last">
<p><em>sent on modify article action</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_DELETEITEM</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CART_CLEAR</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Order linked event</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_SET_POSTAGE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_PAY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_BEFORE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_AFTER_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_CART_CLEAR</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_CREATE_MANUAL</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ORDER_UPDATE_STATUS</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_PROCESS</td>
<td class="last">
<p><em>Sent on image processing</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_PREPROCESSING</td>
<td class="last">
<p><em>Sent just after creating the image object from the image file</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just before saving the processed image object on disk</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>DOCUMENT_PROCESS</td>
<td class="last">
<p><em>Sent on document processing</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent on image cache clear request</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>DOCUMENT_SAVE</td>
<td class="last">
<p><em>Save given documents</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>DOCUMENT_UPDATE</td>
<td class="last">
<p><em>Save given documents</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>DOCUMENT_DELETE</td>
<td class="last">
<p><em>Delete given document</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_CLEAR_CACHE</td>
<td class="last">
<p><em>Sent on image cache clear request</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_SAVE</td>
<td class="last">
<p><em>Save given images</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_UPDATE</td>
<td class="last">
<p><em>Save given images</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMAGE_DELETE</td>
<td class="last">
<p><em>Delete given image</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUPON_CREATE</td>
<td class="last">
<p><em>Sent when creating a Coupon</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just before a successful insert of a new Coupon in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATE_COUPON</td>
<td class="last">
<p><em>Sent just after a successful insert of a new Coupon in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUPON_UPDATE</td>
<td class="last">
<p><em>Sent when editing a Coupon</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just before a successful update of a new Coupon in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATE_COUPON</td>
<td class="last">
<p><em>Sent just after a successful update of a new Coupon in the database.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUPON_CONSUME</td>
<td class="last">
<p><em>Sent when attempting to use a Coupon</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>COUPON_CLEAR_ALL</td>
<td class="last">
<p><em>Sent when all coupons in the current session should be cleared</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just before an attempt to use a Coupon</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just after an attempt to use a Coupon</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent when attempting to update Coupon Condition</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just before an attempt to update a Coupon Condition</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>Sent just after an attempt to update a Coupon Condition</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONFIG_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONFIG_SETVALUE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONFIG_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CONFIG_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETECONFIG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MESSAGE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MESSAGE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MESSAGE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEMESSAGE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEMESSAGE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEMESSAGE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CURRENCY_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CURRENCY_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CURRENCY_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PROFILE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PROFILE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>PROFILE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>API_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>API_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>API_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_RULE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_RULE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TAX_RULE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TEMPLATE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TEMPLATE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>TEMPLATE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEFEATURE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEFEATURE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEFEATURE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_AV_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_AV_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>ATTRIBUTE_AV_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_AV_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_AV_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FEATURE_AV_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent when system find a mailer transporter.</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent when Thelia try to generate a rewritten url</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>GENERATE_PDF</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent when a module is activated or deactivated</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent when module position is changed</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_CREATE</td>
<td class="last">
<p><em>module</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_INSTALL</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_PAY</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_HOOK_RENDER</td>
<td class="last">
<p><em>Hook</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_PROCESS_RENDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_HOOK_RENDER</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_TOGGLE_NATIVE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_CREATE_ALL</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>HOOK_DEACTIVATION</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_HOOK_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_HOOK_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>MODULE_HOOK_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>CACHE_CLEAR</td>
<td class="last">
<p><em>sent for clearing cache</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>sent for subscribing to the newsletter</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>NEWSLETTER_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LANG_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LANG_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LANG_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LANG_URL</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>LANG_TOGGLEDEFAULT</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETELANG</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BRAND_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BRAND_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BRAND_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BRAND_UPDATE_SEO</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATEBRAND</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>EXPORT_AFTER_ENCODE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>IMPORT_AFTER_DECODE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>SALE_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>SALE_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>SALE_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_CREATESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_CREATESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_DELETESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_DELETESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>BEFORE_UPDATESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>AFTER_UPDATESALE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>META_DATA_CREATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>META_DATA_UPDATE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>META_DATA_DELETE</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FORM_BEFORE_BUILD</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td>FORM_AFTER_BUILD</td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
<tr>
<td><API key></td>
<td class="last">
<p><em>
</em></p>
<p>
</p>
</td>
</tr>
</table>
</div>
<div id="footer">
Generated by <a href="http://sami.sensiolabs.org/" target="_top">Sami, the API Documentation Generator</a>.
</div>
</body>
</html> |
--TEST
Test rsort() function : usage variations - Hexadecimal vales
--FILE
<?php
/* Prototype : bool rsort(array &$array_arg [, int $sort_flags])
* Description: Sort an array in reverse order
* Source code: ext/standard/array.c
*/
/*
* Pass rsort() an array of hexadecimal values to test behaviour
*/
echo "*** Testing rsort() : variation ***\n";
// an array contains unsorted hexadecimal values
$unsorted_hex_array = array(0x1AB, 0xFFF, 0xF, 0xFF, 0x2AA, 0xBB, 0x1ab, 0xff, -0xFF, 0, -0x2aa);
echo "\n-- 'flag' value is defualt --\n";
$temp_array = $unsorted_hex_array;
var_dump(rsort($temp_array) );
var_dump($temp_array);
echo "\n-- 'flag' value is SORT_REGULAR --\n";
$temp_array = $unsorted_hex_array;
var_dump(rsort($temp_array, SORT_REGULAR) );
var_dump($temp_array);
echo "\n-- 'flag' value is SORT_NUMERIC --\n";
$temp_array = $unsorted_hex_array;
var_dump(rsort($temp_array, SORT_NUMERIC) );
var_dump($temp_array);
echo "Done";
?>
--EXPECTF
*** Testing rsort() : variation ***
-- 'flag' value is defualt --
bool(true)
array(11) {
[0]=>
int(4095)
[1]=>
int(682)
[2]=>
int(427)
[3]=>
int(427)
[4]=>
int(255)
[5]=>
int(255)
[6]=>
int(187)
[7]=>
int(15)
[8]=>
int(0)
[9]=>
int(-255)
[10]=>
int(-682)
}
-- 'flag' value is SORT_REGULAR --
bool(true)
array(11) {
[0]=>
int(4095)
[1]=>
int(682)
[2]=>
int(427)
[3]=>
int(427)
[4]=>
int(255)
[5]=>
int(255)
[6]=>
int(187)
[7]=>
int(15)
[8]=>
int(0)
[9]=>
int(-255)
[10]=>
int(-682)
}
-- 'flag' value is SORT_NUMERIC --
bool(true)
array(11) {
[0]=>
int(4095)
[1]=>
int(682)
[2]=>
int(427)
[3]=>
int(427)
[4]=>
int(255)
[5]=>
int(255)
[6]=>
int(187)
[7]=>
int(15)
[8]=>
int(0)
[9]=>
int(-255)
[10]=>
int(-682)
}
Done |
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "gpu/config/gpu_control_list.h"
#include "gpu/config/gpu_info.h"
#include "testing/gtest/include/gtest/gtest.h"
const char kOsVersion[] = "10.6.4";
const uint32 kIntelVendorId = 0x8086;
const uint32 kNvidiaVendorId = 0x10de;
const uint32 kAmdVendorId = 0x10de;
#define LONG_STRING_CONST(...) #__VA_ARGS__
#define EXPECT_EMPTY_SET(feature_set) EXPECT_EQ(0u, feature_set.size())
#define <API key>(feature_set, feature) \
EXPECT_TRUE(feature_set.size() == 1 && feature_set.count(feature) == 1)
namespace gpu {
enum TestFeatureType {
TEST_FEATURE_0 = 1,
TEST_FEATURE_1 = 1 << 2,
TEST_FEATURE_2 = 1 << 3,
};
class GpuControlListTest : public testing::Test {
public:
GpuControlListTest() { }
~GpuControlListTest() override {}
const GPUInfo& gpu_info() const {
return gpu_info_;
}
GpuControlList* Create() {
GpuControlList* rt = new GpuControlList();
rt->AddSupportedFeature("test_feature_0", TEST_FEATURE_0);
rt->AddSupportedFeature("test_feature_1", TEST_FEATURE_1);
rt->AddSupportedFeature("test_feature_2", TEST_FEATURE_2);
return rt;
}
protected:
void SetUp() override {
gpu_info_.gpu.vendor_id = kNvidiaVendorId;
gpu_info_.gpu.device_id = 0x0640;
gpu_info_.driver_vendor = "NVIDIA";
gpu_info_.driver_version = "1.6.18";
gpu_info_.driver_date = "7-14-2009";
gpu_info_.machine_model_name = "MacBookPro";
gpu_info_.<API key> = "7.1";
gpu_info_.gl_vendor = "NVIDIA Corporation";
gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
}
void TearDown() override {}
private:
GPUInfo gpu_info_;
};
TEST_F(GpuControlListTest, <API key>) {
scoped_ptr<GpuControlList> control_list(Create());
// Default control list settings: all feature are allowed.
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
EXPECT_EMPTY_SET(features);
}
TEST_F(GpuControlListTest, EmptyControlList) {
// Empty list: all features are allowed.
const std::string empty_list_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "2.5",
"entries": [
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(empty_list_json,
GpuControlList::kAllOs));
EXPECT_EQ("2.5", control_list->version());
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
EXPECT_EMPTY_SET(features);
}
TEST_F(GpuControlListTest, <API key>) {
// exact setting.
const std::string exact_list_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 5,
"os": {
"type": "macosx",
"version": {
"op": "=",
"value": "10.6.4"
}
},
"vendor_id": "0x10de",
"device_id": ["0x0640"],
"driver_version": {
"op": "=",
"value": "1.6.18"
},
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(exact_list_json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
// Invalid json input should not change the current control_list settings.
const std::string invalid_json = "invalid";
EXPECT_FALSE(control_list->LoadList(invalid_json, GpuControlList::kAllOs));
features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
std::vector<uint32> entries;
control_list->GetDecisionEntries(&entries, false);
ASSERT_EQ(1u, entries.size());
EXPECT_EQ(5u, entries[0]);
EXPECT_EQ(5u, control_list->max_entry_id());
}
TEST_F(GpuControlListTest, VendorOnAllOsEntry) {
// ControlList a vendor on all OS.
const std::string vendor_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"vendor_id": "0x10de",
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
// ControlList entries won't be filtered to the current OS only upon loading.
EXPECT_TRUE(control_list->LoadList(vendor_json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) || \
defined(OS_OPENBSD)
// ControlList entries will be filtered to the current OS only upon loading.
EXPECT_TRUE(control_list->LoadList(
vendor_json, GpuControlList::kCurrentOsOnly));
features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info());
<API key>(features, TEST_FEATURE_0);
#endif
}
TEST_F(GpuControlListTest, UnknownField) {
const std::string unknown_field_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"unknown_field": 0,
"features": [
"test_feature_1"
]
},
{
"id": 2,
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_FALSE(control_list->LoadList(
unknown_field_json, GpuControlList::kAllOs));
}
TEST_F(GpuControlListTest, <API key>) {
const std::string <API key> = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"unknown_field": 0,
"features": [
"test_feature_2"
]
},
{
"id": 2,
"exceptions": [
{
"unknown_field": 0
}
],
"features": [
"test_feature_1"
]
},
{
"id": 3,
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_FALSE(control_list->LoadList(
<API key>, GpuControlList::kAllOs));
}
TEST_F(GpuControlListTest, DisabledEntry) {
const std::string disabled_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"disabled": true,
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(disabled_json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info());
EXPECT_EMPTY_SET(features);
std::vector<uint32> flag_entries;
control_list->GetDecisionEntries(&flag_entries, false);
EXPECT_EQ(0u, flag_entries.size());
control_list->GetDecisionEntries(&flag_entries, true);
EXPECT_EQ(1u, flag_entries.size());
}
TEST_F(GpuControlListTest, NeedsMoreInfo) {
const std::string json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"vendor_id": "0x10de",
"driver_version": {
"op": "<",
"value": "12"
},
"features": [
"test_feature_0"
]
}
]
}
);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = kNvidiaVendorId;
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
EXPECT_TRUE(control_list->needs_more_info());
std::vector<uint32> decision_entries;
control_list->GetDecisionEntries(&decision_entries, false);
EXPECT_EQ(0u, decision_entries.size());
gpu_info.driver_version = "11";
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
EXPECT_FALSE(control_list->needs_more_info());
control_list->GetDecisionEntries(&decision_entries, false);
EXPECT_EQ(1u, decision_entries.size());
}
TEST_F(GpuControlListTest, <API key>) {
const std::string json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "linux"
},
"vendor_id": "0x8086",
"exceptions": [
{
"gl_renderer": ".*mesa.*"
}
],
"features": [
"test_feature_0"
]
}
]
}
);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = kIntelVendorId;
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
// The case this entry does not apply.
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsMacosx, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
EXPECT_FALSE(control_list->needs_more_info());
// The case this entry might apply, but need more info.
features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info);
// Ignore exceptions if main entry info matches
<API key>(features, TEST_FEATURE_0);
EXPECT_TRUE(control_list->needs_more_info());
// The case we have full info, and the exception applies (so the entry
// does not apply).
gpu_info.gl_renderer = "mesa";
features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
EXPECT_FALSE(control_list->needs_more_info());
// The case we have full info, and this entry applies.
gpu_info.gl_renderer = "my renderer";
features = control_list->MakeDecision(GpuControlList::kOsLinux, kOsVersion,
gpu_info);
<API key>(features, TEST_FEATURE_0);
EXPECT_FALSE(control_list->needs_more_info());
}
TEST_F(GpuControlListTest, IgnorableEntries) {
// If an entry will not change the control_list decisions, then it should not
// trigger the needs_more_info flag.
const std::string json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "linux"
},
"vendor_id": "0x8086",
"features": [
"test_feature_0"
]
},
{
"id": 2,
"os": {
"type": "linux"
},
"vendor_id": "0x8086",
"driver_version": {
"op": "<",
"value": "10.7"
},
"features": [
"test_feature_0"
]
}
]
}
);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = kIntelVendorId;
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
EXPECT_FALSE(control_list->needs_more_info());
}
TEST_F(GpuControlListTest, <API key>) {
const std::string json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "linux"
},
"vendor_id": "0x8086",
"exceptions": [
{
"device_id": ["0x2a06"],
"driver_version": {
"op": ">=",
"value": "8.1"
}
},
{
"device_id": ["0x2a02"],
"driver_version": {
"op": ">=",
"value": "9.1"
}
}
],
"features": [
"test_feature_0"
]
}
]
}
);
GPUInfo gpu_info;
gpu_info.gpu.vendor_id = kIntelVendorId;
gpu_info.gpu.device_id = 0x2a02;
gpu_info.driver_version = "9.1";
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
gpu_info.driver_version = "9.0";
features = control_list->MakeDecision(
GpuControlList::kOsLinux, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
}
TEST_F(GpuControlListTest, AMDSwitchable) {
GPUInfo gpu_info;
gpu_info.amd_switchable = true;
gpu_info.gpu.vendor_id = kAmdVendorId;
gpu_info.gpu.device_id = 0x6760;
GPUInfo::GPUDevice integrated_gpu;
integrated_gpu.vendor_id = kIntelVendorId;
integrated_gpu.device_id = 0x0116;
gpu_info.secondary_gpus.push_back(integrated_gpu);
{ // <API key> entry
const std::string json= LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"multi_gpu_style": "<API key>",
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
// Integrated GPU is active
gpu_info.gpu.active = false;
gpu_info.secondary_gpus[0].active = true;
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
// Discrete GPU is active
gpu_info.gpu.active = true;
gpu_info.secondary_gpus[0].active = false;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
}
{ // <API key> entry
const std::string json= LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"multi_gpu_style": "<API key>",
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
// Discrete GPU is active
gpu_info.gpu.active = true;
gpu_info.secondary_gpus[0].active = false;
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
// Integrated GPU is active
gpu_info.gpu.active = false;
gpu_info.secondary_gpus[0].active = true;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
// For non AMD switchable
gpu_info.amd_switchable = false;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
}
}
TEST_F(GpuControlListTest, <API key>) {
// exact setting.
const std::string exact_list_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"disabled_extensions": [
"test_extension2",
"test_extension1"
]
},
{
"id": 2,
"os": {
"type": "win"
},
"disabled_extensions": [
"test_extension3",
"test_extension2"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(exact_list_json, GpuControlList::kAllOs));
GPUInfo gpu_info;
control_list->MakeDecision(GpuControlList::kOsWin, kOsVersion, gpu_info);
std::vector<std::string> disabled_extensions =
control_list-><API key>();
ASSERT_EQ(3u, disabled_extensions.size());
ASSERT_STREQ("test_extension1", disabled_extensions[0].c_str());
ASSERT_STREQ("test_extension2", disabled_extensions[1].c_str());
ASSERT_STREQ("test_extension3", disabled_extensions[2].c_str());
}
TEST_F(GpuControlListTest, <API key>) {
const std::string exact_list_json = LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"in_process_gpu": true,
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(exact_list_json, GpuControlList::kAllOs));
GPUInfo gpu_info;
gpu_info.in_process_gpu = true;
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
<API key>(features, TEST_FEATURE_0);
gpu_info.in_process_gpu = false;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
}
} // namespace gpu |
(function (global) {
'use strict';
var slice = Array.prototype.slice,
localStorage = global.localStorage,
proto = {},
scrat = create(proto);
scrat.version = '0.3.5';
scrat.options = {
prefix: '__SCRAT__',
cache: false,
hash: '',
timeout: 15, // seconds
alias: {}, // key - name, value - id
deps: {}, // key - id, value - name/id
urlPattern: null, // '/path/to/resources/%s'
comboPattern: null, // '/path/to/combo-service/%s' or function (ids) { return url; }
combo: false,
maxUrlLength: 2000 // approximate value of combo url's max length (recommend 2000)
};
scrat.cache = {}; // key - id
scrat.traceback = null;
/**
* Mix obj to scrat.options
* @param {object} obj
*/
proto.config = function (obj) {
var options = scrat.options;
debug('scrat.config', obj);
each(obj, function (value, key) {
var data = options[key],
t = type(data);
if (t === 'object') {
each(value, function (v, k) {
data[k] = v;
});
} else {
if (t === 'array') value = data.concat(value);
options[key] = value;
}
});
// detect localStorage support and activate cache ability
try {
if (options.hash !== localStorage.getItem('__SCRAT_HASH__')) {
scrat.clean();
localStorage.setItem('__SCRAT_HASH__', options.hash);
}
options.cache = options.cache && !!options.hash;
} catch (e) {
options.cache = false;
}
// detect scrat=nocombo,nocache in location.search
if (/\bscrat=([\w,]+)\b/.test(location.search)) {
each(RegExp.$1.split(','), function (o) {
switch (o) {
case 'nocache':
scrat.clean();
options.cache = false;
break;
case 'nocombo':
options.combo = false;
break;
}
});
}
return options;
};
/**
* Require modules asynchronously with a callback
* @param {string|Array} names
* @param {function} onload
*/
proto.async = function (names, onload) {
if (type(names) === 'string') names = [names];
debug('scrat.async', 'require [' + names.join(', ') + ']');
var reactor = new scrat.Reactor(names, function () {
var args = [];
each(names, function (id) {
args.push(require(id));
});
if (onload) onload.apply(scrat, args);
debug('scrat.async', '[' + names.join(', ') + '] callback called');
});
reactor.run();
};
/**
* Define a JS module with a factory funciton
* @param {string} id
* @param {function} factory
*/
proto.define = function (id, factory) {
debug('scrat.define', '[' + id + ']');
var options = scrat.options,
res = scrat.cache[id];
if (res) {
res.factory = factory;
} else {
scrat.cache[id] = {
id: id,
loaded: true,
factory: factory
};
}
if (options.cache) {
localStorage.setItem(options.prefix + id, factory.toString());
}
};
/**
* Define a CSS module
* @param {string} id
* @param {string} css
* @param {boolean} [parsing=true]
*/
proto.defineCSS = function (id, css, parsing) {
debug('scrat.defineCSS', '[' + id + ']');
var options = scrat.options;
scrat.cache[id] = {
id: id,
loaded: true,
rawCSS: css
};
if (parsing !== false) requireCSS(id);
if (options.cache) localStorage.setItem(options.prefix + id, css);
};
/**
* Get a defined module
* @param {string} id
* @returns {object} module
*/
proto.get = function (id) {
/* jshint evil:true */
debug('scrat.get', '[' + id + ']');
var options = scrat.options,
type = fileType(id),
res = scrat.cache[id],
raw;
if (res) {
return res;
} else if (options.cache) {
raw = localStorage.getItem(options.prefix + id);
if (raw) {
if (type === 'js') {
global['eval'].call(global, 'define("' + id + '",' + raw + ')');
} else if (type === 'css') {
scrat.defineCSS(id, raw, false);
}
scrat.cache[id].loaded = false;
return scrat.cache[id];
}
}
return null;
};
/**
* Clean module cache in localStorage
*/
proto.clean = function () {
debug('scrat.clean');
try {
each(localStorage, function (_, key) {
if (~key.indexOf(scrat.options.prefix)) {
localStorage.removeItem(key);
}
});
localStorage.removeItem('__SCRAT_HASH__');
} catch (e) {}
};
/**
* Get alias from specified name recursively
* @param {string} name
* @param {string|function} [alias] - set alias
* @returns {string} name
*/
proto.alias = function (name, alias) {
var aliasMap = scrat.options.alias;
if (arguments.length > 1) {
aliasMap[name] = alias;
return scrat.alias(name);
}
while (aliasMap[name] && name !== aliasMap[name]) {
switch (type(aliasMap[name])) {
case 'function':
name = aliasMap[name](name);
break;
case 'string':
name = aliasMap[name];
break;
}
}
return name;
};
/**
* Load any types of resources from specified url
* @param {string} url
* @param {function|object} options
*/
proto.load = function (url, options) {
if (type(options) === 'function') options = {onload: options};
var t = options.type || fileType(url),
isScript = t === 'js',
isCss = t === 'css',
isOldWebKit = +navigator.userAgent
.replace(/.*AppleWebKit\/(\d+)\..*/, '$1') < 536,
head = document.head,
node = document.createElement(isScript ? 'script' : 'link'),
supportOnload = 'onload' in node,
tid = setTimeout(onerror, (options.timeout || 15) * 1000),
intId, intTimer;
if (isScript) {
node.type = 'text/javascript';
node.async = 'async';
node.src = url;
} else {
if (isCss) {
node.type = 'text/css';
node.rel = 'stylesheet';
}
node.href = url;
}
node.onload = node.onreadystatechange = function () {
if (node && (!node.readyState ||
/loaded|complete/.test(node.readyState))) {
clearTimeout(tid);
node.onload = node.onreadystatechange = null;
if (isScript && head && node.parentNode) head.removeChild(node);
if (options.onload) options.onload.call(scrat);
node = null;
}
};
node.onerror = function onerror() {
clearTimeout(tid);
clearInterval(intId);
throw new Error('Error loading url: ' + url);
};
debug('scrat.load', '[' + url + ']');
head.appendChild(node);
// trigger onload immediately after nonscript node insertion
if (isCss) {
if (isOldWebKit || !supportOnload) {
debug('scrat.load', 'check css\'s loading status for compatible');
intTimer = 0;
intId = setInterval(function () {
if ((intTimer += 20) > options.timeout || !node) {
clearTimeout(tid);
clearInterval(intId);
return;
}
if (node.sheet) {
clearTimeout(tid);
clearInterval(intId);
if (options.onload) options.onload.call(scrat);
node = null;
}
}, 20);
}
} else if (!isScript) {
if (options.onload) options.onload.call(scrat);
}
};
proto.Reactor = function (names, callback) {
this.length = 0;
this.depends = {};
this.depended = {};
this.push.apply(this, names);
this.callback = callback;
};
var rproto = scrat.Reactor.prototype;
rproto.push = function () {
var that = this,
args = slice.call(arguments);
function onload() {
if (--that.length === 0) that.callback();
}
each(args, function (arg) {
var id = scrat.alias(arg),
type = fileType(id),
res = scrat.get(id);
if (!res) {
res = scrat.cache[id] = {
id: id,
loaded: false,
onload: []
};
} else if (that.depended[id] || res.loaded) return;
that.depended[id] = 1;
that.push.apply(that, scrat.options.deps[id]);
if ((type === 'css' && !res.rawCSS && !res.parsed) ||
(type === 'js' && !res.factory && !res.exports)) {
(that.depends[type] || (that.depends[type] = [])).push(res);
++that.length;
res.onload.push(onload);
} else if (res.rawCSS) {
requireCSS(id);
}
});
};
function makeOnload(deps) {
deps = deps.slice();
return function () {
each(deps, function (res) {
res.loaded = true;
while (res.onload.length) {
var onload = res.onload.shift();
onload.call(res);
}
});
};
}
rproto.run = function () {
var that = this,
options = scrat.options,
combo = options.combo,
depends = this.depends;
if (this.length === 0) return this.callback();
debug('reactor.run', depends);
each(depends.unknown, function (res) {
scrat.load(that.genUrl(res.id), function () {
res.loaded = true;
});
});
debug('reactor.run', 'combo: ' + combo);
if (combo) {
each(['css', 'js'], function (type) {
var urlLength = 0,
ids = [],
deps = [];
each(depends[type], function (res, i) {
if (urlLength + res.id.length < options.maxUrlLength) {
urlLength += res.id.length;
ids.push(res.id);
deps.push(res);
} else {
scrat.load(that.genUrl(ids), makeOnload(deps));
urlLength = res.id.length;
ids = [res.id];
deps = [res];
}
if (i === depends[type].length - 1) {
scrat.load(that.genUrl(ids), makeOnload(deps));
}
});
});
} else {
each((depends.css || []).concat(depends.js || []), function (res) {
scrat.load(that.genUrl(res.id), function () {
res.loaded = true;
while (res.onload.length) {
var onload = res.onload.shift();
onload.call(res);
}
});
});
}
};
rproto.genUrl = function (ids) {
if (type(ids) === 'string') ids = [ids];
var options = scrat.options,
url = options.combo && options.comboPattern || options.urlPattern;
if (options.cache && fileType(ids[0]) === 'css') {
each(ids, function (id, i) {
ids[i] = id + '.js';
});
}
switch (type(url)) {
case 'string':
url = url.replace('%s', ids.join(','));
break;
case 'function':
url = url(ids);
break;
default:
url = ids.join(',');
}
return url + (~url.indexOf('?') ? '&' : '?') + options.hash;
};
/**
* Require another module in factory
* @param {string} name
* @returns {*} module.exports
*/
function require(name) {
var id = scrat.alias(name),
module = scrat.get(id);
if (fileType(id) !== 'js') return;
if (!module) throw new Error('failed to require "' + name + '"');
if (!module.exports) {
if (type(module.factory) !== 'function') {
throw new Error('failed to require "' + name + '"');
}
try {
module.factory.call(scrat, require, module.exports = {}, module);
} catch (e) {
e.id = id;
throw (scrat.traceback = e);
}
delete module.factory;
debug('require', '[' + id + '] factory called');
}
return module.exports;
}
// Mix scrat's prototype to require
each(proto, function (m, k) { require[k] = m; });
/**
* Parse CSS module
* @param {string} name
*/
function requireCSS(name) {
var id = scrat.alias(name),
module = scrat.get(id);
if (fileType(id) !== 'css') return;
if (!module) throw new Error('failed to require "' + name + '"');
if (!module.parsed) {
if (type(module.rawCSS) !== 'string') {
throw new Error('failed to require "' + name + '"');
}
var styleEl = document.createElement('style');
document.head.appendChild(styleEl);
styleEl.appendChild(document.createTextNode(module.rawCSS));
delete module.rawCSS;
module.parsed = true;
}
}
function type(obj) {
var t;
if (obj == null) {
t = String(obj);
} else {
t = Object.prototype.toString.call(obj).toLowerCase();
t = t.substring(8, t.length - 1);
}
return t;
}
function each(obj, iterator, context) {
if (typeof obj !== 'object') return;
var i, l, t = type(obj);
context = context || obj;
if (t === 'array' || t === 'arguments' || t === 'nodelist') {
for (i = 0, l = obj.length; i < l; i++) {
if (iterator.call(context, obj[i], i, obj) === false) return;
}
} else {
for (i in obj) {
if (obj.hasOwnProperty(i)) {
if (iterator.call(context, obj[i], i, obj) === false) return;
}
}
}
}
function create(proto) {
function Dummy() {}
Dummy.prototype = proto;
return new Dummy();
}
var TYPE_RE = /\.(js|css)(?=[?&,]|$)/i;
function fileType(str) {
var ext = 'js';
str.replace(TYPE_RE, function (m, $1) {
ext = $1;
});
if (ext !== 'js' && ext !== 'css') ext = 'unknown';
return ext;
}
var _modCache;
function debug() {
var flag = (global.localStorage || {}).debug,
args = slice.call(arguments),
style = 'color: #bada55',
mod = args.shift(),
re = new RegExp(mod.replace(/[.\/\\]/g, function (m) {
return '\\' + m;
}));
mod = '%c' + mod;
if (flag && flag === '*' || re.test(flag)) {
if (_modCache !== mod) {
console.groupEnd(_modCache, style);
console.group(_modCache = mod, style);
}
if (/string|number|boolean/.test(type(args[0]))) {
args[0] = '%c' + args[0];
args.splice(1, 0, style);
}
console.log.apply(console, args);
}
}
global.require = scrat;
global.define = scrat.define;
global.defineCSS = scrat.defineCSS;
if (global.module && global.module.exports) global.module.exports = scrat;
})(this); |
/*global define*/
define(function () {
'use strict';
/**
*
* @param {$scope} $scope
* @param {$state} $state
* @param {NgAdmin} Configuration
* @constructor
*/
var AppController = function ($scope, $state, Configuration) {
var application = Configuration();
this.$scope = $scope;
this.$state = $state;
this.$scope.isCollapsed = true;
this.menu = application.menu();
this.applicationName = application.title();
this.header = application.header();
$scope.$on('$destroy', this.destroy.bind(this));
};
AppController.prototype.displayHome = function () {
this.$state.go(this.$state.get('dashboard'));
};
AppController.prototype.destroy = function () {
this.$scope = undefined;
this.$state = undefined;
};
AppController.$inject = ['$scope', '$state', '<API key>'];
return AppController;
}); |
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
function <API key>($string)
{
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($string);
} else {
return strtoupper($string);
}
}
?> |
require 'yt/collections/base'
require 'yt/models/rating'
module Yt
module Collections
# @private
class Ratings < Base
private
def <API key>(data)
{rating: data['rating'], video_id: @parent.id, auth: @auth}
end
def list_params
super.tap do |params|
params[:path] = '/youtube/v3/videos/getRating'
params[:params] = {id: @parent.id}
end
end
end
end
end |
cc.v2fzero = function () {
return {x: 0, y: 0};
};
cc.v2f = function (x, y) {
return {x: x, y: y};
};
cc.v2fadd = function (v0, v1) {
return cc.v2f(v0.x + v1.x, v0.y + v1.y);
};
cc.v2fsub = function (v0, v1) {
return cc.v2f(v0.x - v1.x, v0.y - v1.y);
};
cc.v2fmult = function (v, s) {
return cc.v2f(v.x * s, v.y * s);
};
cc.v2fperp = function (p0) {
return cc.v2f(-p0.y, p0.x);
};
cc.v2fneg = function (p0) {
return cc.v2f(-p0.x, -p0.y);
};
cc.v2fdot = function (p0, p1) {
return p0.x * p1.x + p0.y * p1.y;
};
cc.v2fforangle = function (_a_) {
return cc.v2f(Math.cos(_a_), Math.sin(_a_));
};
cc.v2fnormalize = function (p) {
var r = cc.pNormalize(cc.p(p.x, p.y));
return cc.v2f(r.x, r.y);
};
cc.__v2f = function (v) {
return cc.v2f(v.x, v.y);
};
cc.__t = function (v) {
return {u: v.x, v: v.y};
};
/**
* <p>CCDrawNode <br/>
* Node that draws dots, segments and polygons. <br/>
* Faster than the "drawing primitives" since they it draws everything in one single batch.</p>
* @class
* @name cc.DrawNode
* @extends cc.Node
*/
cc.DrawNode = cc.Node.extend(/** @lends cc.DrawNode# */{
//TODO need refactor
_buffer:null,
_blendFunc:null,
_lineWidth: 1,
_drawColor: null,
/**
* Gets the blend func
* @returns {Object}
*/
getBlendFunc: function () {
return this._blendFunc;
},
/**
* Set the blend func
* @param blendFunc
* @param dst
*/
setBlendFunc: function (blendFunc, dst) {
if (dst === undefined) {
this._blendFunc.src = blendFunc.src;
this._blendFunc.dst = blendFunc.dst;
} else {
this._blendFunc.src = blendFunc;
this._blendFunc.dst = dst;
}
},
/**
* line width setter
* @param {Number} width
*/
setLineWidth: function (width) {
this._lineWidth = width;
},
/**
* line width getter
* @returns {Number}
*/
getLineWidth: function () {
return this._lineWidth;
},
/**
* draw color setter
* @param {cc.Color} color
*/
setDrawColor: function (color) {
var locDrawColor = this._drawColor;
locDrawColor.r = color.r;
locDrawColor.g = color.g;
locDrawColor.b = color.b;
locDrawColor.a = (color.a == null) ? 255 : color.a;
},
/**
* draw color getter
* @returns {cc.Color}
*/
getDrawColor: function () {
return cc.color(this._drawColor.r, this._drawColor.g, this._drawColor.b, this._drawColor.a);
}
});
/**
* Creates a DrawNode
* @deprecated since v3.0 please use new cc.DrawNode() instead.
* @return {cc.DrawNode}
*/
cc.DrawNode.create = function () {
return new cc.DrawNode();
};
cc.DrawNode.TYPE_DOT = 0;
cc.DrawNode.TYPE_SEGMENT = 1;
cc.DrawNode.TYPE_POLY = 2;
cc.game.addEventListener(cc.game.<API key>, function () {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
cc._DrawNodeElement = function (type, verts, fillColor, lineWidth, lineColor, lineCap, isClosePolygon, isFill, isStroke) {
var _t = this;
_t.type = type;
_t.verts = verts || null;
_t.fillColor = fillColor || null;
_t.lineWidth = lineWidth || 0;
_t.lineColor = lineColor || null;
_t.lineCap = lineCap || "butt";
_t.isClosePolygon = isClosePolygon || false;
_t.isFill = isFill || false;
_t.isStroke = isStroke || false;
};
cc.extend(cc.DrawNode.prototype, /** @lends cc.DrawNode# */{
_className:"DrawNodeCanvas",
/**
* <p>The cc.DrawNodeCanvas's constructor. <br/>
* This function will automatically be invoked when you create a node using new construction: "var node = new cc.DrawNodeCanvas()".<br/>
* Override it to extend its behavior, remember to call "this._super()" in the extended "ctor" function.</p>
*/
ctor: function () {
cc.Node.prototype.ctor.call(this);
var locCmd = this._renderCmd;
locCmd._buffer = this._buffer = [];
locCmd._drawColor = this._drawColor = cc.color(255, 255, 255, 255);
locCmd._blendFunc = this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
this.init();
},
/**
* draws a rectangle given the origin and destination point measured in points.
* @param {cc.Point} origin
* @param {cc.Point} destination
* @param {cc.Color} fillColor
* @param {Number} lineWidth
* @param {cc.Color} lineColor
*/
drawRect: function (origin, destination, fillColor, lineWidth, lineColor) {
lineWidth = (lineWidth == null) ? this._lineWidth : lineWidth;
lineColor = lineColor || this.getDrawColor();
if(lineColor.a == null)
lineColor.a = 255;
var vertices = [
origin,
cc.p(destination.x, origin.y),
destination,
cc.p(origin.x, destination.y)
];
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = vertices;
element.lineWidth = lineWidth;
element.lineColor = lineColor;
element.isClosePolygon = true;
element.isStroke = true;
element.lineCap = "butt";
element.fillColor = fillColor;
if (fillColor) {
if(fillColor.a == null)
fillColor.a = 255;
element.isFill = true;
}
this._buffer.push(element);
},
/**
* draws a circle given the center, radius and number of segments.
* @override
* @param {cc.Point} center center of circle
* @param {Number} radius
* @param {Number} angle angle in radians
* @param {Number} segments
* @param {Boolean} drawLineToCenter
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawCircle: function (center, radius, angle, segments, drawLineToCenter, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var coef = 2.0 * Math.PI / segments;
var vertices = [];
for (var i = 0; i <= segments; i++) {
var rads = i * coef;
var j = radius * Math.cos(rads + angle) + center.x;
var k = radius * Math.sin(rads + angle) + center.y;
vertices.push(cc.p(j, k));
}
if (drawLineToCenter) {
vertices.push(cc.p(center.x, center.y));
}
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = vertices;
element.lineWidth = lineWidth;
element.lineColor = color;
element.isClosePolygon = true;
element.isStroke = true;
this._buffer.push(element);
},
/**
* draws a quad bezier path
* @override
* @param {cc.Point} origin
* @param {cc.Point} control
* @param {cc.Point} destination
* @param {Number} segments
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawQuadBezier: function (origin, control, destination, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var vertices = [], t = 0.0;
for (var i = 0; i < segments; i++) {
var x = Math.pow(1 - t, 2) * origin.x + 2.0 * (1 - t) * t * control.x + t * t * destination.x;
var y = Math.pow(1 - t, 2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y;
vertices.push(cc.p(x, y));
t += 1.0 / segments;
}
vertices.push(cc.p(destination.x, destination.y));
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = vertices;
element.lineWidth = lineWidth;
element.lineColor = color;
element.isStroke = true;
element.lineCap = "round";
this._buffer.push(element);
},
/**
* draws a cubic bezier path
* @override
* @param {cc.Point} origin
* @param {cc.Point} control1
* @param {cc.Point} control2
* @param {cc.Point} destination
* @param {Number} segments
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawCubicBezier: function (origin, control1, control2, destination, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var vertices = [], t = 0;
for (var i = 0; i < segments; i++) {
var x = Math.pow(1 - t, 3) * origin.x + 3.0 * Math.pow(1 - t, 2) * t * control1.x + 3.0 * (1 - t) * t * t * control2.x + t * t * t * destination.x;
var y = Math.pow(1 - t, 3) * origin.y + 3.0 * Math.pow(1 - t, 2) * t * control1.y + 3.0 * (1 - t) * t * t * control2.y + t * t * t * destination.y;
vertices.push(cc.p(x, y));
t += 1.0 / segments;
}
vertices.push(cc.p(destination.x, destination.y));
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = vertices;
element.lineWidth = lineWidth;
element.lineColor = color;
element.isStroke = true;
element.lineCap = "round";
this._buffer.push(element);
},
/**
* draw a CatmullRom curve
* @override
* @param {Array} points
* @param {Number} segments
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawCatmullRom: function (points, segments, lineWidth, color) {
this.drawCardinalSpline(points, 0.5, segments, lineWidth, color);
},
/**
* draw a cardinal spline path
* @override
* @param {Array} config
* @param {Number} tension
* @param {Number} segments
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawCardinalSpline: function (config, tension, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if(color.a == null)
color.a = 255;
var vertices = [], p, lt, deltaT = 1.0 / config.length;
for (var i = 0; i < segments + 1; i++) {
var dt = i / segments;
// border
if (dt === 1) {
p = config.length - 1;
lt = 1;
} else {
p = 0 | (dt / deltaT);
lt = (dt - deltaT * p) / deltaT;
}
// Interpolate
var newPos = cc.cardinalSplineAt(
cc.getControlPointAt(config, p - 1),
cc.getControlPointAt(config, p - 0),
cc.getControlPointAt(config, p + 1),
cc.getControlPointAt(config, p + 2),
tension, lt);
vertices.push(newPos);
}
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = vertices;
element.lineWidth = lineWidth;
element.lineColor = color;
element.isStroke = true;
element.lineCap = "round";
this._buffer.push(element);
},
/**
* draw a dot at a position, with a given radius and color
* @param {cc.Point} pos
* @param {Number} radius
* @param {cc.Color} color
*/
drawDot: function (pos, radius, color) {
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);
element.verts = [pos];
element.lineWidth = radius;
element.fillColor = color;
this._buffer.push(element);
},
/**
* draws an array of points.
* @override
* @param {Array} points point of array
* @param {Number} radius
* @param {cc.Color} color
*/
drawDots: function(points, radius, color){
if(!points || points.length == 0)
return;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
for(var i = 0, len = points.length; i < len; i++)
this.drawDot(points[i], radius, color);
},
/**
* draw a segment with a radius and color
* @param {cc.Point} from
* @param {cc.Point} to
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawSegment: function (from, to, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = [from, to];
element.lineWidth = lineWidth * 2;
element.lineColor = color;
element.isStroke = true;
element.lineCap = "round";
this._buffer.push(element);
},
/**
* draw a polygon with a fill color and line color without copying the vertex list
* @param {Array} verts
* @param {cc.Color} fillColor
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawPoly_: function (verts, fillColor, lineWidth, color) {
lineWidth = (lineWidth == null ) ? this._lineWidth : lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var element = new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);
element.verts = verts;
element.fillColor = fillColor;
element.lineWidth = lineWidth;
element.lineColor = color;
element.isClosePolygon = true;
element.isStroke = true;
element.lineCap = "round";
if (fillColor)
element.isFill = true;
this._buffer.push(element);
},
/**
* draw a polygon with a fill color and line color, copying the vertex list
* @param {Array} verts
* @param {cc.Color} fillColor
* @param {Number} lineWidth
* @param {cc.Color} color
*/
drawPoly: function (verts, fillColor, lineWidth, color) {
var vertsCopy = [];
for (var i=0; i < verts.length; i++) {
vertsCopy.push(cc.p(verts[i].x, verts[i].y));
}
return this.drawPoly_(vertsCopy, fillColor, lineWidth, color);
},
/**
* Clear the geometry in the node's buffer.
*/
clear: function () {
this._buffer.length = 0;
},
_createRenderCmd: function(){
return new cc.DrawNode.CanvasRenderCmd(this);
}
});
}
else if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
cc.extend(cc.DrawNode.prototype, {
_bufferCapacity:0,
<API key>:null,
_trianglesWebBuffer:null,
_trianglesReader:null,
_dirty:false,
_className:"DrawNodeWebGL",
ctor:function () {
cc.Node.prototype.ctor.call(this);
this._buffer = [];
this._blendFunc = new cc.BlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA);
this._drawColor = cc.color(255,255,255,255);
this.init();
},
init:function () {
if (cc.Node.prototype.init.call(this)) {
this.shaderProgram = cc.shaderCache.programForKey(cc.<API key>);
this._ensureCapacity(64);
this._trianglesWebBuffer = cc._renderContext.createBuffer();
this._dirty = true;
return true;
}
return false;
},
drawRect: function (origin, destination, fillColor, lineWidth, lineColor) {
lineWidth = (lineWidth == null) ? this._lineWidth : lineWidth;
lineColor = lineColor || this.getDrawColor();
if (lineColor.a == null)
lineColor.a = 255;
var vertices = [origin, cc.p(destination.x, origin.y), destination, cc.p(origin.x, destination.y)];
if(fillColor == null)
this._drawSegments(vertices, lineWidth, lineColor, true);
else
this.drawPoly(vertices, fillColor, lineWidth, lineColor);
},
drawCircle: function (center, radius, angle, segments, drawLineToCenter, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var coef = 2.0 * Math.PI / segments, vertices = [], i, len;
for (i = 0; i <= segments; i++) {
var rads = i * coef;
var j = radius * Math.cos(rads + angle) + center.x;
var k = radius * Math.sin(rads + angle) + center.y;
vertices.push(cc.p(j, k));
}
if (drawLineToCenter)
vertices.push(cc.p(center.x, center.y));
lineWidth *= 0.5;
for (i = 0, len = vertices.length; i < len - 1; i++)
this.drawSegment(vertices[i], vertices[i + 1], lineWidth, color);
},
drawQuadBezier: function (origin, control, destination, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var vertices = [], t = 0.0;
for (var i = 0; i < segments; i++) {
var x = Math.pow(1 - t, 2) * origin.x + 2.0 * (1 - t) * t * control.x + t * t * destination.x;
var y = Math.pow(1 - t, 2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y;
vertices.push(cc.p(x, y));
t += 1.0 / segments;
}
vertices.push(cc.p(destination.x, destination.y));
this._drawSegments(vertices, lineWidth, color, false);
},
drawCubicBezier: function (origin, control1, control2, destination, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var vertices = [], t = 0;
for (var i = 0; i < segments; i++) {
var x = Math.pow(1 - t, 3) * origin.x + 3.0 * Math.pow(1 - t, 2) * t * control1.x + 3.0 * (1 - t) * t * t * control2.x + t * t * t * destination.x;
var y = Math.pow(1 - t, 3) * origin.y + 3.0 * Math.pow(1 - t, 2) * t * control1.y + 3.0 * (1 - t) * t * t * control2.y + t * t * t * destination.y;
vertices.push(cc.p(x, y));
t += 1.0 / segments;
}
vertices.push(cc.p(destination.x, destination.y));
this._drawSegments(vertices, lineWidth, color, false);
},
drawCatmullRom: function (points, segments, lineWidth, color) {
this.drawCardinalSpline(points, 0.5, segments, lineWidth, color);
},
drawCardinalSpline: function (config, tension, segments, lineWidth, color) {
lineWidth = lineWidth || this._lineWidth;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var vertices = [], p, lt, deltaT = 1.0 / config.length;
for (var i = 0; i < segments + 1; i++) {
var dt = i / segments;
// border
if (dt === 1) {
p = config.length - 1;
lt = 1;
} else {
p = 0 | (dt / deltaT);
lt = (dt - deltaT * p) / deltaT;
}
// Interpolate
var newPos = cc.cardinalSplineAt(
cc.getControlPointAt(config, p - 1),
cc.getControlPointAt(config, p - 0),
cc.getControlPointAt(config, p + 1),
cc.getControlPointAt(config, p + 2),
tension, lt);
vertices.push(newPos);
}
lineWidth *= 0.5;
for (var j = 0, len = vertices.length; j < len - 1; j++)
this.drawSegment(vertices[j], vertices[j + 1], lineWidth, color);
},
_render:function () {
var gl = cc._renderContext;
cc.<API key>(cc.<API key>);
gl.bindBuffer(gl.ARRAY_BUFFER, this._trianglesWebBuffer);
if (this._dirty) {
gl.bufferData(gl.ARRAY_BUFFER, this.<API key>, gl.STREAM_DRAW);
this._dirty = false;
}
var triangleSize = cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;
// vertex
gl.vertexAttribPointer(cc.<API key>, 2, gl.FLOAT, false, triangleSize, 0);
// color
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, triangleSize, 8);
// texcood
gl.vertexAttribPointer(cc.<API key>, 2, gl.FLOAT, false, triangleSize, 12);
gl.drawArrays(gl.TRIANGLES, 0, this._buffer.length * 3);
cc.incrementGLDraws(1);
//cc.checkGLErrorDebug();
},
_ensureCapacity:function(count){
var _t = this;
var locBuffer = _t._buffer;
if(locBuffer.length + count > _t._bufferCapacity){
var TriangleLength = cc.<API key>.BYTES_PER_ELEMENT;
_t._bufferCapacity += Math.max(_t._bufferCapacity, count);
//re alloc
if((locBuffer == null) || (locBuffer.length === 0)){
//init
_t._buffer = [];
_t.<API key> = new ArrayBuffer(TriangleLength * _t._bufferCapacity);
_t._trianglesReader = new Uint8Array(_t.<API key>);
} else {
var newTriangles = [];
var newArrayBuffer = new ArrayBuffer(TriangleLength * _t._bufferCapacity);
for(var i = 0; i < locBuffer.length;i++){
newTriangles[i] = new cc.<API key>(locBuffer[i].a,locBuffer[i].b,locBuffer[i].c,
newArrayBuffer, i * TriangleLength);
}
_t._trianglesReader = new Uint8Array(newArrayBuffer);
_t.<API key> = newArrayBuffer;
_t._buffer = newTriangles;
}
}
},
drawDot:function (pos, radius, color) {
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
var c4bColor = {r: 0 | color.r, g: 0 | color.g, b: 0 | color.b, a: 0 | color.a};
var a = {vertices: {x: pos.x - radius, y: pos.y - radius}, colors: c4bColor, texCoords: {u: -1.0, v: -1.0}};
var b = {vertices: {x: pos.x - radius, y: pos.y + radius}, colors: c4bColor, texCoords: {u: -1.0, v: 1.0}};
var c = {vertices: {x: pos.x + radius, y: pos.y + radius}, colors: c4bColor, texCoords: {u: 1.0, v: 1.0}};
var d = {vertices: {x: pos.x + radius, y: pos.y - radius}, colors: c4bColor, texCoords: {u: 1.0, v: -1.0}};
this._ensureCapacity(2*3);
this._buffer.push(new cc.<API key>(a, b, c, this.<API key>, this._buffer.length * cc.<API key>.BYTES_PER_ELEMENT));
this._buffer.push(new cc.<API key>(a, c, d, this.<API key>, this._buffer.length * cc.<API key>.BYTES_PER_ELEMENT));
this._dirty = true;
},
drawDots: function(points, radius,color) {
if(!points || points.length === 0)
return;
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
for(var i = 0, len = points.length; i < len; i++)
this.drawDot(points[i], radius, color);
},
drawSegment:function (from, to, radius, color) {
color = color || this.getDrawColor();
if (color.a == null)
color.a = 255;
radius = radius || (this._lineWidth * 0.5);
var vertexCount = 6*3;
this._ensureCapacity(vertexCount);
var c4bColor = {r: 0 | color.r, g: 0 | color.g, b: 0 | color.b, a: 0 | color.a};
var a = cc.__v2f(from), b = cc.__v2f(to);
var n = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(b, a))), t = cc.v2fperp(n);
var nw = cc.v2fmult(n, radius), tw = cc.v2fmult(t, radius);
var v0 = cc.v2fsub(b, cc.v2fadd(nw, tw));
var v1 = cc.v2fadd(b, cc.v2fsub(nw, tw));
var v2 = cc.v2fsub(b, nw);
var v3 = cc.v2fadd(b, nw);
var v4 = cc.v2fsub(a, nw);
var v5 = cc.v2fadd(a, nw);
var v6 = cc.v2fsub(a, cc.v2fsub(nw, tw));
var v7 = cc.v2fadd(a, cc.v2fadd(nw, tw));
var TriangleLength = cc.<API key>.BYTES_PER_ELEMENT, triangleBuffer = this.<API key>, locBuffer = this._buffer;
locBuffer.push(new cc.<API key>({vertices: v0, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(cc.v2fadd(n, t)))},
{vertices: v1, colors: c4bColor, texCoords: cc.__t(cc.v2fsub(n, t))}, {vertices: v2, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))},
triangleBuffer, locBuffer.length * TriangleLength));
locBuffer.push(new cc.<API key>({vertices: v3, colors: c4bColor, texCoords: cc.__t(n)},
{vertices: v1, colors: c4bColor, texCoords: cc.__t(cc.v2fsub(n, t))}, {vertices: v2, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))},
triangleBuffer, locBuffer.length * TriangleLength));
locBuffer.push(new cc.<API key>({vertices: v3, colors: c4bColor, texCoords: cc.__t(n)},
{vertices: v4, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))}, {vertices: v2, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))},
triangleBuffer, locBuffer.length * TriangleLength));
locBuffer.push(new cc.<API key>({vertices: v3, colors: c4bColor, texCoords: cc.__t(n)},
{vertices: v4, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))}, {vertices: v5, colors: c4bColor, texCoords: cc.__t(n)},
triangleBuffer, locBuffer.length * TriangleLength));
locBuffer.push(new cc.<API key>({vertices: v6, colors: c4bColor, texCoords: cc.__t(cc.v2fsub(t, n))},
{vertices: v4, colors: c4bColor, texCoords: cc.__t(cc.v2fneg(n))}, {vertices: v5, colors: c4bColor, texCoords: cc.__t(n)},
triangleBuffer, locBuffer.length * TriangleLength));
locBuffer.push(new cc.<API key>({vertices: v6, colors: c4bColor, texCoords: cc.__t(cc.v2fsub(t, n))},
{vertices: v7, colors: c4bColor, texCoords: cc.__t(cc.v2fadd(n, t))}, {vertices: v5, colors: c4bColor, texCoords: cc.__t(n)},
triangleBuffer, locBuffer.length * TriangleLength));
this._dirty = true;
},
drawPoly:function (verts, fillColor, borderWidth, borderColor) {
if(fillColor == null){
this._drawSegments(verts, borderWidth, borderColor, true);
return;
}
if (fillColor.a == null)
fillColor.a = 255;
if (borderColor.a == null)
borderColor.a = 255;
borderWidth = (borderWidth == null)? this._lineWidth : borderWidth;
borderWidth *= 0.5;
var c4bFillColor = {r: 0 | fillColor.r, g: 0 | fillColor.g, b: 0 | fillColor.b, a: 0 | fillColor.a};
var c4bBorderColor = {r: 0 | borderColor.r, g: 0 | borderColor.g, b: 0 | borderColor.b, a: 0 | borderColor.a};
var extrude = [], i, v0, v1, v2, count = verts.length;
for (i = 0; i < count; i++) {
v0 = cc.__v2f(verts[(i - 1 + count) % count]);
v1 = cc.__v2f(verts[i]);
v2 = cc.__v2f(verts[(i + 1) % count]);
var n1 = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(v1, v0)));
var n2 = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(v2, v1)));
var offset = cc.v2fmult(cc.v2fadd(n1, n2), 1.0 / (cc.v2fdot(n1, n2) + 1.0));
extrude[i] = {offset: offset, n: n2};
}
var outline = (borderWidth > 0.0), triangleCount = 3 * count - 2, vertexCount = 3 * triangleCount;
this._ensureCapacity(vertexCount);
var triangleBytesLen = cc.<API key>.BYTES_PER_ELEMENT, trianglesBuffer = this.<API key>;
var locBuffer = this._buffer;
var inset = (outline == false ? 0.5 : 0.0);
for (i = 0; i < count - 2; i++) {
v0 = cc.v2fsub(cc.__v2f(verts[0]), cc.v2fmult(extrude[0].offset, inset));
v1 = cc.v2fsub(cc.__v2f(verts[i + 1]), cc.v2fmult(extrude[i + 1].offset, inset));
v2 = cc.v2fsub(cc.__v2f(verts[i + 2]), cc.v2fmult(extrude[i + 2].offset, inset));
locBuffer.push(new cc.<API key>({vertices: v0, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())},
{vertices: v1, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())}, {vertices: v2, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())},
trianglesBuffer, locBuffer.length * triangleBytesLen));
}
for (i = 0; i < count; i++) {
var j = (i + 1) % count;
v0 = cc.__v2f(verts[i]);
v1 = cc.__v2f(verts[j]);
var n0 = extrude[i].n;
var offset0 = extrude[i].offset;
var offset1 = extrude[j].offset;
var inner0 = outline ? cc.v2fsub(v0, cc.v2fmult(offset0, borderWidth)) : cc.v2fsub(v0, cc.v2fmult(offset0, 0.5));
var inner1 = outline ? cc.v2fsub(v1, cc.v2fmult(offset1, borderWidth)) : cc.v2fsub(v1, cc.v2fmult(offset1, 0.5));
var outer0 = outline ? cc.v2fadd(v0, cc.v2fmult(offset0, borderWidth)) : cc.v2fadd(v0, cc.v2fmult(offset0, 0.5));
var outer1 = outline ? cc.v2fadd(v1, cc.v2fmult(offset1, borderWidth)) : cc.v2fadd(v1, cc.v2fmult(offset1, 0.5));
if (outline) {
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))},
{vertices: inner1, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))}, {vertices: outer1, colors: c4bBorderColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))},
{vertices: outer0, colors: c4bBorderColor, texCoords: cc.__t(n0)}, {vertices: outer1, colors: c4bBorderColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
} else {
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())},
{vertices: inner1, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())}, {vertices: outer1, colors: c4bFillColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bFillColor, texCoords: cc.__t(cc.v2fzero())},
{vertices: outer0, colors: c4bFillColor, texCoords: cc.__t(n0)}, {vertices: outer1, colors: c4bFillColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
}
}
extrude = null;
this._dirty = true;
},
_drawSegments: function(verts, borderWidth, borderColor, closePoly){
borderWidth = (borderWidth == null) ? this._lineWidth : borderWidth;
borderColor = borderColor || this._drawColor;
if(borderColor.a == null)
borderColor.a = 255;
borderWidth *= 0.5;
if (borderWidth <= 0)
return;
var c4bBorderColor = {r: 0 | borderColor.r, g: 0 | borderColor.g, b: 0 | borderColor.b, a: 0 | borderColor.a };
var extrude = [], i, v0, v1, v2, count = verts.length;
for (i = 0; i < count; i++) {
v0 = cc.__v2f(verts[(i - 1 + count) % count]);
v1 = cc.__v2f(verts[i]);
v2 = cc.__v2f(verts[(i + 1) % count]);
var n1 = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(v1, v0)));
var n2 = cc.v2fnormalize(cc.v2fperp(cc.v2fsub(v2, v1)));
var offset = cc.v2fmult(cc.v2fadd(n1, n2), 1.0 / (cc.v2fdot(n1, n2) + 1.0));
extrude[i] = {offset: offset, n: n2};
}
var triangleCount = 3 * count - 2, vertexCount = 3 * triangleCount;
this._ensureCapacity(vertexCount);
var triangleBytesLen = cc.<API key>.BYTES_PER_ELEMENT, trianglesBuffer = this.<API key>;
var locBuffer = this._buffer;
var len = closePoly ? count : count - 1;
for (i = 0; i < len; i++) {
var j = (i + 1) % count;
v0 = cc.__v2f(verts[i]);
v1 = cc.__v2f(verts[j]);
var n0 = extrude[i].n;
var offset0 = extrude[i].offset;
var offset1 = extrude[j].offset;
var inner0 = cc.v2fsub(v0, cc.v2fmult(offset0, borderWidth));
var inner1 = cc.v2fsub(v1, cc.v2fmult(offset1, borderWidth));
var outer0 = cc.v2fadd(v0, cc.v2fmult(offset0, borderWidth));
var outer1 = cc.v2fadd(v1, cc.v2fmult(offset1, borderWidth));
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))},
{vertices: inner1, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))}, {vertices: outer1, colors: c4bBorderColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
locBuffer.push(new cc.<API key>({vertices: inner0, colors: c4bBorderColor, texCoords: cc.__t(cc.v2fneg(n0))},
{vertices: outer0, colors: c4bBorderColor, texCoords: cc.__t(n0)}, {vertices: outer1, colors: c4bBorderColor, texCoords: cc.__t(n0)},
trianglesBuffer, locBuffer.length * triangleBytesLen));
}
extrude = null;
this._dirty = true;
},
clear:function () {
this._buffer.length = 0;
this._dirty = true;
},
_createRenderCmd: function () {
return new cc.DrawNode.WebGLRenderCmd(this);
}
});
}
}); |
""" Test functions for limits module.
"""
from numpy.testing import *
from numpy.core import finfo, iinfo
from numpy import half, single, double, longdouble
import numpy as np
class TestPythonFloat(TestCase):
def test_singleton(self):
ftype = finfo(float)
ftype2 = finfo(float)
assert_equal(id(ftype),id(ftype2))
class TestHalf(TestCase):
def test_singleton(self):
ftype = finfo(half)
ftype2 = finfo(half)
assert_equal(id(ftype),id(ftype2))
class TestSingle(TestCase):
def test_singleton(self):
ftype = finfo(single)
ftype2 = finfo(single)
assert_equal(id(ftype),id(ftype2))
class TestDouble(TestCase):
def test_singleton(self):
ftype = finfo(double)
ftype2 = finfo(double)
assert_equal(id(ftype),id(ftype2))
class TestLongdouble(TestCase):
def test_singleton(self,level=2):
ftype = finfo(longdouble)
ftype2 = finfo(longdouble)
assert_equal(id(ftype),id(ftype2))
class TestIinfo(TestCase):
def test_basic(self):
dts = zip(['i1', 'i2', 'i4', 'i8',
'u1', 'u2', 'u4', 'u8'],
[np.int8, np.int16, np.int32, np.int64,
np.uint8, np.uint16, np.uint32, np.uint64])
for dt1, dt2 in dts:
assert_equal(iinfo(dt1).min, iinfo(dt2).min)
assert_equal(iinfo(dt1).max, iinfo(dt2).max)
self.assertRaises(ValueError, iinfo, 'f4')
def test_unsigned_max(self):
types = np.sctypes['uint']
for T in types:
assert_equal(iinfo(T).max, T(-1))
class TestRepr(TestCase):
def test_iinfo_repr(self):
expected = "iinfo(min=-32768, max=32767, dtype=int16)"
assert_equal(repr(np.iinfo(np.int16)), expected)
def test_finfo_repr(self):
expected = "finfo(resolution=1e-06, min=-3.4028235e+38," + \
" max=3.4028235e+38, dtype=float32)"
# Python 2.5 float formatting on Windows adds an extra 0 to the
# exponent. So test for both. Once 2.5 compatibility is dropped, this
# can simply use `assert_equal(repr(np.finfo(np.float32)), expected)`.
expected_win25 = "finfo(resolution=1e-006, min=-3.4028235e+038," + \
" max=3.4028235e+038, dtype=float32)"
actual = repr(np.finfo(np.float32))
if not actual == expected:
if not actual == expected_win25:
msg = build_err_msg([actual, desired], verbose=True)
raise AssertionError(msg)
def test_instances():
iinfo(10)
finfo(3.0)
if __name__ == "__main__":
run_module_suite() |
<h1><code ng:non-bindable=""></code>
<div><span class="hint"></span>
</div>
</h1>
<div><div class="welcome-page"><h2 id="welcome-to-barney">Welcome to Barney!</h2>
<p>To use Barney library first of all you have to include <strong>main.min.js</strong> in your index.html file.
You can find this file in the <strong>dist</strong> folder of Barney.</p>
<p><strong>index.html</strong>:</p>
<pre class="prettyprint linenums">
//Include Barney script
<script type="text/javascript" src="./bower_components/barney/dist/main.min.js">
</pre>
<p>Once you have included Barney in to your index.html file remember that you have to import Barney module
as a dependency in your <strong>app.js</strong> file.</p>
<p><strong>app.js</strong>:
<pre class="prettyprint linenums">
angular
.module('yourAngularApp', [
,
'barney',
])
</pre>
<h2 id="barney-components">Barney Components:</h2>
<p>Here you can find a full list of the components of Barney: </p>
<ul>
<li><a href="#/version/analytics">analytics</a></li>
<li><a href="#/version/callbacky">callbacky</a></li>
<li><a href="#/version/config">config</a></li>
<li><a href="#/version/dict">dict</a></li>
<li><a href="#/version/history">history</a></li>
<li><a href="#/version/infinite">infinite</a></li>
<li><a href="#/version/logger">logger</a></li>
<li><a href="#/version/meta">meta</a></li>
<li><a href="#/version/newton">newton</a></li>
<li><a href="#/version/storage">storage</a></li>
<li><a href="#/version/utility">utility</a></li>
</ul>
</div></div> |
#ifndef <API key>
#define <API key>
class <API key>* <API key>(struct <API key>& options);
#endif //<API key> |
<?php
$base = array(
0x00 => 'ddwim', 'ddwib', 'ddwibs', 'ddwis', 'ddwiss', 'ddwing', 'ddwij', 'ddwic', 'ddwik', 'ddwit', 'ddwip', 'ddwih', 'ddyu', 'ddyug', 'ddyugg', 'ddyugs',
0x10 => 'ddyun', 'ddyunj', 'ddyunh', 'ddyud', 'ddyul', 'ddyulg', 'ddyulm', 'ddyulb', 'ddyuls', 'ddyult', 'ddyulp', 'ddyulh', 'ddyum', 'ddyub', 'ddyubs', 'ddyus',
0x20 => 'ddyuss', 'ddyung', 'ddyuj', 'ddyuc', 'ddyuk', 'ddyut', 'ddyup', 'ddyuh', 'ddeu', 'ddeug', 'ddeugg', 'ddeugs', 'ddeun', 'ddeunj', 'ddeunh', 'ddeud',
0x30 => 'ddeul', 'ddeulg', 'ddeulm', 'ddeulb', 'ddeuls', 'ddeult', 'ddeulp', 'ddeulh', 'ddeum', 'ddeub', 'ddeubs', 'ddeus', 'ddeuss', 'ddeung', 'ddeuj', 'ddeuc',
0x40 => 'ddeuk', 'ddeut', 'ddeup', 'ddeuh', 'ddyi', 'ddyig', 'ddyigg', 'ddyigs', 'ddyin', 'ddyinj', 'ddyinh', 'ddyid', 'ddyil', 'ddyilg', 'ddyilm', 'ddyilb',
0x50 => 'ddyils', 'ddyilt', 'ddyilp', 'ddyilh', 'ddyim', 'ddyib', 'ddyibs', 'ddyis', 'ddyiss', 'ddying', 'ddyij', 'ddyic', 'ddyik', 'ddyit', 'ddyip', 'ddyih',
0x60 => 'ddi', 'ddig', 'ddigg', 'ddigs', 'ddin', 'ddinj', 'ddinh', 'ddid', 'ddil', 'ddilg', 'ddilm', 'ddilb', 'ddils', 'ddilt', 'ddilp', 'ddilh',
0x70 => 'ddim', 'ddib', 'ddibs', 'ddis', 'ddiss', 'dding', 'ddij', 'ddic', 'ddik', 'ddit', 'ddip', 'ddih', 'ra', 'rag', 'ragg', 'rags',
0x80 => 'ran', 'ranj', 'ranh', 'rad', 'ral', 'ralg', 'ralm', 'ralb', 'rals', 'ralt', 'ralp', 'ralh', 'ram', 'rab', 'rabs', 'ras',
0x90 => 'rass', 'rang', 'raj', 'rac', 'rak', 'rat', 'rap', 'rah', 'rae', 'raeg', 'raegg', 'raegs', 'raen', 'raenj', 'raenh', 'raed',
0xA0 => 'rael', 'raelg', 'raelm', 'raelb', 'raels', 'raelt', 'raelp', 'raelh', 'raem', 'raeb', 'raebs', 'raes', 'raess', 'raeng', 'raej', 'raec',
0xB0 => 'raek', 'raet', 'raep', 'raeh', 'rya', 'ryag', 'ryagg', 'ryags', 'ryan', 'ryanj', 'ryanh', 'ryad', 'ryal', 'ryalg', 'ryalm', 'ryalb',
0xC0 => 'ryals', 'ryalt', 'ryalp', 'ryalh', 'ryam', 'ryab', 'ryabs', 'ryas', 'ryass', 'ryang', 'ryaj', 'ryac', 'ryak', 'ryat', 'ryap', 'ryah',
0xD0 => 'ryae', 'ryaeg', 'ryaegg', 'ryaegs', 'ryaen', 'ryaenj', 'ryaenh', 'ryaed', 'ryael', 'ryaelg', 'ryaelm', 'ryaelb', 'ryaels', 'ryaelt', 'ryaelp', 'ryaelh',
0xE0 => 'ryaem', 'ryaeb', 'ryaebs', 'ryaes', 'ryaess', 'ryaeng', 'ryaej', 'ryaec', 'ryaek', 'ryaet', 'ryaep', 'ryaeh', 'reo', 'reog', 'reogg', 'reogs',
0xF0 => 'reon', 'reonj', 'reonh', 'reod', 'reol', 'reolg', 'reolm', 'reolb', 'reols', 'reolt', 'reolp', 'reolh', 'reom', 'reob', 'reobs', 'reos',
); |
#include <stdlib.h>
#include <rtgui/dc.h>
#include <rtgui/dc_hw.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/container.h>
#include "demo_view.h"
#define RAND(x1, x2) ((rand() % (x2 - x1)) + x1)
#define _int_swap(x, y) do {x ^= y; y ^= x; x ^= y; } while(0)
static struct rtgui_container *container = RT_NULL;
static int running = 0;
static rt_tick_t ticks;
static long long area;
static rt_bool_t _benchmark_onshow(struct rtgui_object *obj, struct rtgui_event *ev)
{
rtgui_widget_focus(RTGUI_WIDGET(obj));
return RT_TRUE;
}
void _onidle(struct rtgui_object *object, rtgui_event_t *event)
{
rtgui_color_t color;
rtgui_rect_t rect, draw_rect;
struct rtgui_dc *dc;
// dc = rtgui_dc_hw_create(RTGUI_WIDGET(container));
dc = <API key>(RTGUI_WIDGET(container));
if (dc == RT_NULL)
return;
<API key>(RTGUI_CONTAINER(container), &rect);
draw_rect.x1 = RAND(rect.x1, rect.x2);
draw_rect.y1 = RAND(rect.y1, rect.y2);
draw_rect.x2 = RAND(rect.x1, rect.x2);
draw_rect.y2 = RAND(rect.y1, rect.y2);
if(draw_rect.x1 > draw_rect.x2) _int_swap(draw_rect.x1, draw_rect.x2);
if(draw_rect.y1 > draw_rect.y2) _int_swap(draw_rect.y1, draw_rect.y2);
area += rtgui_rect_width(draw_rect) * rtgui_rect_height(draw_rect);
color = RTGUI_RGB(rand() % 255, rand() % 255, rand() % 255);
<API key>(container) = color;
rtgui_dc_fill_rect(dc, &draw_rect);
<API key>(dc);
if(rt_tick_get()-ticks >= RT_TICK_PER_SECOND)
{
char buf[16];
sprintf(buf, "%.2f", (double)area/(800*480));
rt_kprintf("frames per second: %s fps\n", buf);
area = 0;
ticks = rt_tick_get();
}
}
void _draw_default(struct rtgui_object *object, rtgui_event_t *event)
{
struct rtgui_widget *widget = RTGUI_WIDGET(object);
struct rtgui_dc *dc;
rtgui_rect_t rect;
<API key>(object, event);
dc = <API key>(widget);
if (dc == RT_NULL)
return;
<API key>(RTGUI_CONTAINER(widget), &rect);
<API key>(widget) = default_background;
rtgui_dc_fill_rect(dc, &rect);
rtgui_dc_draw_text(dc, "°´ÈÎÒâ¼ü¿ªÊ¼/Í£Ö¹²âÊÔ...", &rect);
<API key>(dc);
}
rt_bool_t <API key>(struct rtgui_object *object, rtgui_event_t *event)
{
if (event->type == RTGUI_EVENT_PAINT)
{
_draw_default(object, event);
}
else if (event->type == RTGUI_EVENT_SHOW)
{
<API key>(object, event);
_benchmark_onshow(object, event);
}
else if (event->type == RTGUI_EVENT_KBD)
{
struct rtgui_event_kbd *kbd = (struct rtgui_event_kbd *)event;
if (kbd->key == RTGUIK_LEFT || kbd->key == RTGUIK_RIGHT)
return RT_FALSE;
if (RTGUI_KBD_IS_UP(kbd))
{
if (running)
{
/* stop */
<API key>(rtgui_app_self(), RT_NULL);
_draw_default(object, event);
}
else
{
/* run */
ticks = rt_tick_get();
area = 0;
<API key>(rtgui_app_self(), _onidle);
}
running = !running;
}
return RT_TRUE;
}
else
{
return <API key>(object, event);
}
return RT_FALSE;
}
rtgui_container_t *demo_view_benchmark(void)
{
srand(100);
container = demo_view("»æÍ¼²âÊÔ");
RTGUI_WIDGET(container)->flag |= <API key>;
<API key>(RTGUI_OBJECT(container), <API key>);
return container;
} |
<?php
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class EventgridQuery extends StatehistoryQuery
{
/**
* The columns additionally provided by this query
*
* @var array
*/
protected $additionalColumns = array(
'day' => 'DATE(FROM_UNIXTIME(sth.timestamp))',
'cnt_up' => "SUM(CASE WHEN sth.object_type = 'host' AND sth.state = 0 THEN 1 ELSE 0 END)",
'cnt_down_hard' => "SUM(CASE WHEN sth.object_type = 'host' AND sth.state = 1 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_down' => "SUM(CASE WHEN sth.object_type = 'host' AND sth.state = 1 THEN 1 ELSE 0 END)",
'<API key>' => "SUM(CASE WHEN sth.object_type = 'host' AND sth.state = 2 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_unreachable' => "SUM(CASE WHEN sth.object_type = 'host' AND sth.state = 2 THEN 1 ELSE 0 END)",
'cnt_unknown_hard' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 3 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_unknown' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 3 THEN 1 ELSE 0 END)",
'cnt_unknown_hard' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 3 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_critical' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 2 THEN 1 ELSE 0 END)",
'cnt_critical_hard' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 2 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_warning' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 1 THEN 1 ELSE 0 END)",
'cnt_warning_hard' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 1 AND sth.type = 'hard_state' THEN 1 ELSE 0 END)",
'cnt_ok' => "SUM(CASE WHEN sth.object_type = 'service' AND sth.state = 0 THEN 1 ELSE 0 END)"
);
/**
* {@inheritdoc}
*/
protected function joinBaseTables()
{
parent::joinBaseTables();
$this->requireVirtualTable('history');
$this->columnMap['statehistory'] += $this->additionalColumns;
$this->select->group(array('DATE(FROM_UNIXTIME(sth.timestamp))'));
}
/**
* {@inheritdoc}
*/
public function order($columnOrAlias, $dir = null)
{
if (array_key_exists($columnOrAlias, $this->additionalColumns)) {
$subQueries = $this->subQueries;
$this->subQueries = array();
parent::order($columnOrAlias, $dir);
$this->subQueries = $subQueries;
} else {
parent::order($columnOrAlias, $dir);
}
return $this;
}
} |
#ifndef FBDEV_H
#define FBDEV_H
#include "screen.h"
class FbDev : public Screen {
private:
friend class Screen;
static FbDev *initFbDev();
FbDev();
~FbDev();
virtual void setupOffset();
virtual void setupPalette(bool restore);
virtual const s8 *drvId();
};
#endif |
/*-
* Verify that the code within a method block doesn't exploit any
* security holes.
*/
/*
Exported function:
jboolean
VerifyClass(JNIEnv *env, jclass cb, char *message_buffer,
jint buffer_length)
jboolean
<API key>(JNIEnv *env, jclass cb, char *message_buffer,
jint buffer_length, jint major_version)
This file now only uses the standard JNI and the following VM functions
exported in jvm.h:
<API key>
JVM_IsInterface
JVM_GetClassNameUTF
<API key>
JVM_GetClassCPTypes
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
JVM_IsConstructorIx
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
<API key>
JVM_ReleaseUTF
<API key>
*/
#include <string.h>
#include <setjmp.h>
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include "jni.h"
#include "jni_util.h"
#include "jvm.h"
#include "classfile_constants.h"
#include "opcodes.in_out"
#ifdef _AIX
static int aix_dummy;
static void* aix_malloc(size_t len) {
if (len == 0) {
return &aix_dummy;
}
return malloc(len);
}
static void* aix_calloc(size_t n, size_t size) {
if (n == 0) {
return &aix_dummy;
}
return calloc(n, size);
}
static void aix_free(void* p) {
if (p == &aix_dummy) {
return;
}
free(p);
}
#undef malloc
#undef calloc
#undef free
#define malloc aix_malloc
#define calloc aix_calloc
#define free aix_free
#endif
#ifdef __APPLE__
/* use setjmp/longjmp versions that do not save/restore the signal mask */
#define setjmp _setjmp
#define longjmp _longjmp
#endif
#define <API key> 255
/* align byte code */
#ifndef ALIGN_UP
#define ALIGN_UP(n,align_grain) (((n) + ((align_grain) - 1)) & ~((align_grain)-1))
#endif /* ALIGN_UP */
#define UCALIGN(n) ((unsigned char *)ALIGN_UP((uintptr_t)(n),sizeof(int)))
#ifdef DEBUG
int verify_verbose = 0;
static struct context_type *GlobalContext;
#endif
enum {
ITEM_Bogus,
ITEM_Void, /* only as a function return value */
ITEM_Integer,
ITEM_Float,
ITEM_Double,
ITEM_Double_2, /* 2nd word of double in register */
ITEM_Long,
ITEM_Long_2, /* 2nd word of long in register */
ITEM_Array,
ITEM_Object, /* Extra info field gives name. */
ITEM_NewObject, /* Like object, but uninitialized. */
ITEM_InitObject, /* "this" is init method, before call
to super() */
ITEM_ReturnAddress, /* Extra info gives instr # of start pc */
/* The following four are only used within array types.
* Normally, we use ITEM_Integer, instead. */
ITEM_Byte,
ITEM_Short,
ITEM_Char,
ITEM_Boolean
};
#define UNKNOWN_STACK_SIZE -1
#define <API key> -1
#define <API key> -1
#undef MAX
#undef MIN
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define BITS_PER_INT (CHAR_BIT * sizeof(int)/sizeof(char))
#define SET_BIT(flags, i) (flags[(i)/BITS_PER_INT] |= \
((unsigned)1 << ((i) % BITS_PER_INT)))
#define IS_BIT_SET(flags, i) (flags[(i)/BITS_PER_INT] & \
((unsigned)1 << ((i) % BITS_PER_INT)))
typedef unsigned int fullinfo_type;
typedef unsigned int *bitvector;
#define GET_ITEM_TYPE(thing) ((thing) & 0x1F)
#define GET_INDIRECTION(thing) (((thing) & 0xFFFF) >> 5)
#define GET_EXTRA_INFO(thing) ((thing) >> 16)
#define <API key>(thing) ((thing) & ~(0xFFE0))
#define <API key>(thing) ((thing) & 0xFFFF)
#define MAKE_FULLINFO(type, indirect, extra) \
((type) + ((indirect) << 5) + ((extra) << 16))
#define MAKE_Object_ARRAY(indirect) \
(context->object_info + ((indirect) << 5))
#define NULL_FULLINFO MAKE_FULLINFO(ITEM_Object, 0, 0)
/* <API key> calls to <init> need to be treated special */
#define JVM_OPC_invokeinit 0x100
/* A hash mechanism used by the verifier.
* Maps class names to unique 16 bit integers.
*/
#define HASH_TABLE_SIZE 503
/* The buckets are managed as a 256 by 256 matrix. We allocate an entire
* row (256 buckets) at a time to minimize fragmentation. Rows are
* allocated on demand so that we don't waste too much space.
*/
#define MAX_HASH_ENTRIES 65536
#define HASH_ROW_SIZE 256
typedef struct hash_bucket_type {
char *name;
unsigned int hash;
jclass class;
unsigned short ID;
unsigned short next;
unsigned loadable:1; /* from context->class loader */
} hash_bucket_type;
typedef struct {
hash_bucket_type **buckets;
unsigned short *table;
int entries_used;
} hash_table_type;
#define GET_BUCKET(class_hash, ID)\
(class_hash->buckets[ID / HASH_ROW_SIZE] + ID % HASH_ROW_SIZE)
/*
* There are currently two types of resources that we need to keep
* track of (in addition to the CCalloc pool).
*/
enum {
VM_STRING_UTF, /* VM-allocated UTF strings */
VM_MALLOC_BLK /* malloc'ed blocks */
};
#define <API key> 49
#define <API key> 51
#define <API key> 51
#define <API key> 52
#define ALLOC_STACK_SIZE 16 /* big enough */
typedef struct alloc_stack_type {
void *ptr;
int kind;
struct alloc_stack_type *next;
} alloc_stack_type;
/* The context type encapsulates the current invocation of the byte
* code verifier.
*/
struct context_type {
JNIEnv *env; /* current JNIEnv */
/* buffers etc. */
char *message;
jint message_buf_len;
jboolean err_code;
alloc_stack_type *allocated_memory; /* all memory blocks that we have not
had a chance to free */
/* Store up to ALLOC_STACK_SIZE number of handles to allocated memory
blocks here, to save mallocs. */
alloc_stack_type alloc_stack[ALLOC_STACK_SIZE];
int alloc_stack_top;
/* these fields are per class */
jclass class; /* current class */
jint major_version;
jint nconstants;
unsigned char *constant_types;
hash_table_type class_hash;
fullinfo_type object_info; /* fullinfo for java/lang/Object */
fullinfo_type string_info; /* fullinfo for java/lang/String */
fullinfo_type throwable_info; /* fullinfo for java/lang/Throwable */
fullinfo_type cloneable_info; /* fullinfo for java/lang/Cloneable */
fullinfo_type serializable_info; /* fullinfo for java/io/Serializable */
fullinfo_type currentclass_info; /* fullinfo for context->class */
fullinfo_type superclass_info; /* fullinfo for superclass */
/* these fields are per method */
int method_index; /* current method */
unsigned short *exceptions; /* exceptions */
unsigned char *code; /* current code object */
jint code_length;
int *code_data; /* offset to instruction number */
struct <API key> *instruction_data; /* info about each */
struct handler_info_type *handler_info;
fullinfo_type *superclasses; /* null terminated superclasses */
int instruction_count; /* number of instructions */
fullinfo_type return_type; /* function return type */
fullinfo_type swap_table[4]; /* used for passing information */
int bitmask_size; /* words needed to hold bitmap of arguments */
/* these fields are per field */
int field_index;
/* Used by the space allocator */
struct CCpool *CCroot, *CCcurrent;
char *CCfree_ptr;
int CCfree_size;
/* Jump here on any error. */
jmp_buf jump_buffer;
#ifdef DEBUG
/* keep track of how many global refs are allocated. */
int n_globalrefs;
#endif
};
struct stack_info_type {
struct stack_item_type *stack;
int stack_size;
};
struct register_info_type {
int register_count; /* number of registers used */
fullinfo_type *registers;
int mask_count; /* number of masks in the following */
struct mask_type *masks;
};
struct mask_type {
int entry;
int *modifies;
};
typedef unsigned short flag_type;
struct <API key> {
int opcode; /* may turn into "canonical" opcode */
unsigned changed:1; /* has it changed */
unsigned protected:1; /* must accessor be a subclass of "this" */
union {
int i; /* operand to the opcode */
int *ip;
fullinfo_type fi;
} operand, operand2;
fullinfo_type p;
struct stack_info_type stack_info;
struct register_info_type register_info;
#define FLAG_REACHED 0x01 /* instruction reached */
#define <API key> 0x02 /* must call this.<init> or super.<init> */
#define FLAG_NO_RETURN 0x04 /* must throw out of method */
flag_type or_flags; /* true for at least one path to this inst */
#define FLAG_CONSTRUCTED 0x01 /* this.<init> or super.<init> called */
flag_type and_flags; /* true for all paths to this instruction */
};
struct handler_info_type {
int start, end, handler;
struct stack_info_type stack_info;
};
struct stack_item_type {
fullinfo_type item;
struct stack_item_type *next;
};
typedef struct context_type context_type;
typedef struct <API key> <API key>;
typedef struct stack_item_type stack_item_type;
typedef struct register_info_type register_info_type;
typedef struct stack_info_type stack_info_type;
typedef struct mask_type mask_type;
static void read_all_code(context_type *context, jclass cb, int num_methods,
int** code_lengths, unsigned char*** code);
static void verify_method(context_type *context, jclass cb, int index,
int code_length, unsigned char* code);
static void free_all_code(context_type* context, int num_methods,
unsigned char** code);
static void verify_field(context_type *context, jclass cb, int index);
static void <API key> (context_type *, unsigned int inumber, int offset);
static void set_protected(context_type *, unsigned int inumber, int key, int);
static jboolean is_superclass(context_type *, fullinfo_type);
static void <API key>(context_type *);
static int instruction_length(unsigned char *iptr, unsigned char *end);
static jboolean isLegalTarget(context_type *, int offset);
static void <API key>(context_type *, int, unsigned);
static void initialize_dataflow(context_type *);
static void run_dataflow(context_type *context);
static void <API key>(context_type *context, unsigned int inumber);
static void check_flags(context_type *context, unsigned int inumber);
static void pop_stack(context_type *, unsigned int inumber, stack_info_type *);
static void update_registers(context_type *, unsigned int inumber, register_info_type *);
static void update_flags(context_type *, unsigned int inumber,
flag_type *new_and_flags, flag_type *new_or_flags);
static void push_stack(context_type *, unsigned int inumber, stack_info_type *stack);
static void <API key>(context_type *, unsigned int inumber,
register_info_type *register_info,
stack_info_type *stack_info,
flag_type and_flags, flag_type or_flags);
static void <API key>(context_type *context,
unsigned int from_inumber,
unsigned int inumber,
register_info_type *register_info,
stack_info_type *stack_info,
flag_type and_flags, flag_type or_flags,
jboolean isException);
static void merge_stack(context_type *, unsigned int inumber,
unsigned int to_inumber, stack_info_type *);
static void merge_registers(context_type *, unsigned int inumber,
unsigned int to_inumber,
register_info_type *);
static void merge_flags(context_type *context, unsigned int from_inumber,
unsigned int to_inumber,
flag_type new_and_flags, flag_type new_or_flags);
static stack_item_type *copy_stack(context_type *, stack_item_type *);
static mask_type *copy_masks(context_type *, mask_type *masks, int mask_count);
static mask_type *add_to_masks(context_type *, mask_type *, int , int);
static fullinfo_type <API key>(fullinfo_type);
static fullinfo_type <API key>(context_type *context,
fullinfo_type a,
fullinfo_type b,
jboolean assignment);
static jboolean isAssignableTo(context_type *,
fullinfo_type a,
fullinfo_type b);
static jclass <API key>(context_type *, fullinfo_type);
#define NEW(type, count) \
((type *)CCalloc(context, (count)*(sizeof(type)), JNI_FALSE))
#define ZNEW(type, count) \
((type *)CCalloc(context, (count)*(sizeof(type)), JNI_TRUE))
static void CCinit(context_type *context);
static void CCreinit(context_type *context);
static void CCdestroy(context_type *context);
static void *CCalloc(context_type *context, int size, jboolean zero);
static fullinfo_type <API key>(context_type *, int, int);
static const char* <API key>(const char* signature);
static char <API key>(context_type *context,
const char **signature_p, fullinfo_type *info);
static void CCerror (context_type *, char *format, ...);
static void CFerror (context_type *, char *format, ...);
static void CCout_of_memory (context_type *);
/* Because we can longjmp any time, we need to be very careful about
* remembering what needs to be freed. */
static void check_and_push(context_type *context, const void *ptr, int kind);
static void pop_and_free(context_type *context);
static int <API key>(const char *method_signature);
#ifdef DEBUG
static void print_stack (context_type *, stack_info_type *stack_info);
static void print_registers(context_type *, register_info_type *register_info);
static void print_flags(context_type *, flag_type, flag_type);
static void <API key>(context_type *context, int index);
static void <API key>(context_type *context, int index);
#endif
/*
* Declare library specific JNI_Onload entry if static build
*/
<API key>
void <API key>(context_type *context)
{
hash_table_type *class_hash = &(context->class_hash);
class_hash->buckets = (hash_bucket_type **)
calloc(MAX_HASH_ENTRIES / HASH_ROW_SIZE, sizeof(hash_bucket_type *));
class_hash->table = (unsigned short *)
calloc(HASH_TABLE_SIZE, sizeof(unsigned short));
if (class_hash->buckets == 0 ||
class_hash->table == 0)
CCout_of_memory(context);
class_hash->entries_used = 0;
}
static void finalize_class_hash(context_type *context)
{
hash_table_type *class_hash = &(context->class_hash);
JNIEnv *env = context->env;
int i;
/* 4296677: bucket index starts from 1. */
for (i=1;i<=class_hash->entries_used;i++) {
hash_bucket_type *bucket = GET_BUCKET(class_hash, i);
assert(bucket != NULL);
free(bucket->name);
if (bucket->class) {
(*env)->DeleteGlobalRef(env, bucket->class);
#ifdef DEBUG
context->n_globalrefs
#endif
}
}
if (class_hash->buckets) {
for (i=0;i<MAX_HASH_ENTRIES / HASH_ROW_SIZE; i++) {
if (class_hash->buckets[i] == 0)
break;
free(class_hash->buckets[i]);
}
}
free(class_hash->buckets);
free(class_hash->table);
}
static hash_bucket_type *
new_bucket(context_type *context, unsigned short *pID)
{
hash_table_type *class_hash = &(context->class_hash);
int i = *pID = class_hash->entries_used + 1;
int row = i / HASH_ROW_SIZE;
if (i >= MAX_HASH_ENTRIES)
CCerror(context, "Exceeded verifier's limit of 65535 referred classes");
if (class_hash->buckets[row] == 0) {
class_hash->buckets[row] = (hash_bucket_type*)
calloc(HASH_ROW_SIZE, sizeof(hash_bucket_type));
if (class_hash->buckets[row] == 0)
CCout_of_memory(context);
}
class_hash->entries_used++; /* only increment when we are sure there
is no overflow. */
return GET_BUCKET(class_hash, i);
}
static unsigned int
class_hash_fun(const char *s)
{
int i;
unsigned raw_hash;
for (raw_hash = 0; (i = *s) != '\0'; ++s)
raw_hash = raw_hash * 37 + i;
return raw_hash;
}
/*
* Find a class using the defining loader of the current class
* and return a local reference to it.
*/
static jclass load_class_local(context_type *context,const char *classname)
{
jclass cb = <API key>(context->env, classname,
JNI_FALSE, context->class);
if (cb == 0)
CCerror(context, "Cannot find class %s", classname);
return cb;
}
/*
* Find a class using the defining loader of the current class
* and return a global reference to it.
*/
static jclass load_class_global(context_type *context, const char *classname)
{
JNIEnv *env = context->env;
jclass local, global;
local = load_class_local(context, classname);
global = (*env)->NewGlobalRef(env, local);
if (global == 0)
CCout_of_memory(context);
#ifdef DEBUG
context->n_globalrefs++;
#endif
(*env)->DeleteLocalRef(env, local);
return global;
}
/*
* Return a unique ID given a local class reference. The loadable
* flag is true if the defining class loader of context->class
* is known to be capable of loading the class.
*/
static unsigned short
class_to_ID(context_type *context, jclass cb, jboolean loadable)
{
JNIEnv *env = context->env;
hash_table_type *class_hash = &(context->class_hash);
unsigned int hash;
hash_bucket_type *bucket;
unsigned short *pID;
const char *name = JVM_GetClassNameUTF(env, cb);
check_and_push(context, name, VM_STRING_UTF);
hash = class_hash_fun(name);
pID = &(class_hash->table[hash % HASH_TABLE_SIZE]);
while (*pID) {
bucket = GET_BUCKET(class_hash, *pID);
if (bucket->hash == hash && strcmp(name, bucket->name) == 0) {
/*
* There is an unresolved entry with our name
* so we're forced to load it in case it matches us.
*/
if (bucket->class == 0) {
assert(bucket->loadable == JNI_TRUE);
bucket->class = load_class_global(context, name);
}
/*
* It's already in the table. Update the loadable
* state if it's known and then we're done.
*/
if ((*env)->IsSameObject(env, cb, bucket->class)) {
if (loadable && !bucket->loadable)
bucket->loadable = JNI_TRUE;
goto done;
}
}
pID = &bucket->next;
}
bucket = new_bucket(context, pID);
bucket->next = 0;
bucket->hash = hash;
bucket->name = malloc(strlen(name) + 1);
if (bucket->name == 0)
CCout_of_memory(context);
strcpy(bucket->name, name);
bucket->loadable = loadable;
bucket->class = (*env)->NewGlobalRef(env, cb);
if (bucket->class == 0)
CCout_of_memory(context);
#ifdef DEBUG
context->n_globalrefs++;
#endif
done:
pop_and_free(context);
return *pID;
}
/*
* Return a unique ID given a class name from the constant pool.
* All classes are lazily loaded from the defining loader of
* context->class.
*/
static unsigned short
class_name_to_ID(context_type *context, const char *name)
{
hash_table_type *class_hash = &(context->class_hash);
unsigned int hash = class_hash_fun(name);
hash_bucket_type *bucket;
unsigned short *pID;
jboolean force_load = JNI_FALSE;
pID = &(class_hash->table[hash % HASH_TABLE_SIZE]);
while (*pID) {
bucket = GET_BUCKET(class_hash, *pID);
if (bucket->hash == hash && strcmp(name, bucket->name) == 0) {
if (bucket->loadable)
goto done;
force_load = JNI_TRUE;
}
pID = &bucket->next;
}
if (force_load) {
/*
* We found at least one matching named entry for a class that
* was not known to be loadable through the defining class loader
* of context->class. We must load our named class and update
* the hash table in case one these entries matches our class.
*/
JNIEnv *env = context->env;
jclass cb = load_class_local(context, name);
unsigned short id = class_to_ID(context, cb, JNI_TRUE);
(*env)->DeleteLocalRef(env, cb);
return id;
}
bucket = new_bucket(context, pID);
bucket->next = 0;
bucket->class = 0;
bucket->loadable = JNI_TRUE; /* name-only IDs are implicitly loadable */
bucket->hash = hash;
bucket->name = malloc(strlen(name) + 1);
if (bucket->name == 0)
CCout_of_memory(context);
strcpy(bucket->name, name);
done:
return *pID;
}
static const char *
ID_to_class_name(context_type *context, unsigned short ID)
{
hash_table_type *class_hash = &(context->class_hash);
hash_bucket_type *bucket = GET_BUCKET(class_hash, ID);
return bucket->name;
}
static jclass
ID_to_class(context_type *context, unsigned short ID)
{
hash_table_type *class_hash = &(context->class_hash);
hash_bucket_type *bucket = GET_BUCKET(class_hash, ID);
if (bucket->class == 0) {
assert(bucket->loadable == JNI_TRUE);
bucket->class = load_class_global(context, bucket->name);
}
return bucket->class;
}
static fullinfo_type
<API key>(context_type *context, jclass cb)
{
return MAKE_FULLINFO(ITEM_Object, 0,
class_to_ID(context, cb, JNI_TRUE));
}
static fullinfo_type
make_class_info(context_type *context, jclass cb)
{
return MAKE_FULLINFO(ITEM_Object, 0,
class_to_ID(context, cb, JNI_FALSE));
}
static fullinfo_type
<API key>(context_type *context, const char *name)
{
return MAKE_FULLINFO(ITEM_Object, 0,
class_name_to_ID(context, name));
}
/* RETURNS
* 1: on success chosen to be consistent with previous VerifyClass
* 0: verify error
* 2: out of memory
* 3: class format error
*
* Called by verify_class. Verify the code of each of the methods
* in a class. Note that this function apparently can't be JNICALL,
* because if it is the dynamic linker doesn't appear to be able to
* find it on Win32.
*/
#define CC_OK 1
#define CC_VerifyError 0
#define CC_OutOfMemory 2
#define CC_ClassFormatError 3
JNIEXPORT jboolean
<API key>(JNIEnv *env, jclass cb, char *buffer, jint len,
jint major_version)
{
context_type context_structure;
context_type *context = &context_structure;
jboolean result = CC_OK;
int i;
int num_methods;
int* code_lengths;
unsigned char** code;
#ifdef DEBUG
GlobalContext = context;
#endif
memset(context, 0, sizeof(context_type));
context->message = buffer;
context->message_buf_len = len;
context->env = env;
context->class = cb;
/* Set invalid method/field index of the context, in case anyone
calls CCerror */
context->method_index = -1;
context->field_index = -1;
/* Don't call CCerror or anything that can call it above the setjmp! */
if (!setjmp(context->jump_buffer)) {
jclass super;
CCinit(context); /* initialize heap; may throw */
<API key>(context);
context->major_version = major_version;
context->nconstants = <API key>(env, cb);
context->constant_types = (unsigned char *)
malloc(sizeof(unsigned char) * context->nconstants + 1);
if (context->constant_types == 0)
CCout_of_memory(context);
JVM_GetClassCPTypes(env, cb, context->constant_types);
if (context->constant_types == 0)
CCout_of_memory(context);
context->object_info =
<API key>(context, "java/lang/Object");
context->string_info =
<API key>(context, "java/lang/String");
context->throwable_info =
<API key>(context, "java/lang/Throwable");
context->cloneable_info =
<API key>(context, "java/lang/Cloneable");
context->serializable_info =
<API key>(context, "java/io/Serializable");
context->currentclass_info = <API key>(context, cb);
super = (*env)->GetSuperclass(env, cb);
if (super != 0) {
fullinfo_type *gptr;
int i = 0;
context->superclass_info = <API key>(context, super);
while(super != 0) {
jclass tmp_cb = (*env)->GetSuperclass(env, super);
(*env)->DeleteLocalRef(env, super);
super = tmp_cb;
i++;
}
(*env)->DeleteLocalRef(env, super);
super = 0;
/* Can't go on context heap since it survives more than
one method */
context->superclasses = gptr =
malloc(sizeof(fullinfo_type)*(i + 1));
if (gptr == 0) {
CCout_of_memory(context);
}
super = (*env)->GetSuperclass(env, context->class);
while(super != 0) {
jclass tmp_cb;
*gptr++ = make_class_info(context, super);
tmp_cb = (*env)->GetSuperclass(env, super);
(*env)->DeleteLocalRef(env, super);
super = tmp_cb;
}
*gptr = 0;
} else {
context->superclass_info = 0;
}
(*env)->DeleteLocalRef(env, super);
/* Look at each method */
for (i = <API key>(env, cb); --i >= 0;)
verify_field(context, cb, i);
num_methods = <API key>(env, cb);
read_all_code(context, cb, num_methods, &code_lengths, &code);
for (i = num_methods - 1; i >= 0; --i)
verify_method(context, cb, i, code_lengths[i], code[i]);
free_all_code(context, num_methods, code);
result = CC_OK;
} else {
result = context->err_code;
}
/* Cleanup */
finalize_class_hash(context);
while(context->allocated_memory)
pop_and_free(context);
#ifdef DEBUG
GlobalContext = 0;
#endif
if (context->exceptions)
free(context->exceptions);
if (context->constant_types)
free(context->constant_types);
if (context->superclasses)
free(context->superclasses);
#ifdef DEBUG
/* Make sure all global refs created in the verifier are freed */
assert(context->n_globalrefs == 0);
#endif
CCdestroy(context); /* destroy heap */
return result;
}
#define <API key> 48
JNIEXPORT jboolean
VerifyClass(JNIEnv *env, jclass cb, char *buffer, jint len)
{
static int warned = 0;
if (!warned) {
jio_fprintf(stdout, "Warning! An old version of jvm is used. This is not supported.\n");
warned = 1;
}
return <API key>(env, cb, buffer, len,
<API key>);
}
static void
verify_field(context_type *context, jclass cb, int field_index)
{
JNIEnv *env = context->env;
int access_bits = <API key>(env, cb, field_index);
context->field_index = field_index;
if ( ((access_bits & JVM_ACC_PUBLIC) != 0) &&
((access_bits & (JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) != 0)) {
CCerror(context, "Inconsistent access bits.");
}
context->field_index = -1;
}
/**
* We read all of the class's methods' code because it is possible that
* the verification of one method could resulting in linking further
* down the stack (due to class loading), which could end up rewriting
* some of the bytecode of methods we haven't verified yet. Since we
* don't want to see the rewritten bytecode, cache all the code and
* operate only on that.
*/
static void
read_all_code(context_type* context, jclass cb, int num_methods,
int** lengths_addr, unsigned char*** code_addr)
{
int* lengths;
unsigned char** code;
int i;
lengths = malloc(sizeof(int) * num_methods);
check_and_push(context, lengths, VM_MALLOC_BLK);
code = malloc(sizeof(unsigned char*) * num_methods);
check_and_push(context, code, VM_MALLOC_BLK);
*(lengths_addr) = lengths;
*(code_addr) = code;
for (i = 0; i < num_methods; ++i) {
lengths[i] = <API key>(context->env, cb, i);
if (lengths[i] > 0) {
code[i] = malloc(sizeof(unsigned char) * (lengths[i] + 1));
check_and_push(context, code[i], VM_MALLOC_BLK);
<API key>(context->env, cb, i, code[i]);
} else {
code[i] = NULL;
}
}
}
static void
free_all_code(context_type* context, int num_methods, unsigned char** code)
{
int i;
for (i = 0; i < num_methods; ++i) {
if (code[i] != NULL) {
pop_and_free(context);
}
}
pop_and_free(context); /* code */
pop_and_free(context); /* lengths */
}
/* Verify the code of one method */
static void
verify_method(context_type *context, jclass cb, int method_index,
int code_length, unsigned char* code)
{
JNIEnv *env = context->env;
int access_bits = <API key>(env, cb, method_index);
int *code_data;
<API key> *idata = 0;
int instruction_count;
int i, offset;
unsigned int inumber;
jint nexceptions;
if ((access_bits & (JVM_ACC_NATIVE | JVM_ACC_ABSTRACT)) != 0) {
/* not much to do for abstract and native methods */
return;
}
context->code_length = code_length;
context->code = code;
/* CCerror can give method-specific info once this is set */
context->method_index = method_index;
CCreinit(context); /* initial heap */
code_data = NEW(int, code_length);
#ifdef DEBUG
if (verify_verbose) {
const char *classname = JVM_GetClassNameUTF(env, cb);
const char *methodname =
<API key>(env, cb, method_index);
const char *signature =
<API key>(env, cb, method_index);
jio_fprintf(stdout, "Looking at %s.%s%s\n",
(classname ? classname : ""),
(methodname ? methodname : ""),
(signature ? signature : ""));
JVM_ReleaseUTF(classname);
JVM_ReleaseUTF(methodname);
JVM_ReleaseUTF(signature);
}
#endif
if (((access_bits & JVM_ACC_PUBLIC) != 0) &&
((access_bits & (JVM_ACC_PRIVATE | JVM_ACC_PROTECTED)) != 0)) {
CCerror(context, "Inconsistent access bits.");
}
// If this method is an overpass method, which is generated by the VM,
// we trust the code and no check needs to be done.
if (<API key>(env, cb, method_index)) {
return;
}
/* Run through the code. Mark the start of each instruction, and give
* the instruction a number */
for (i = 0, offset = 0; offset < code_length; i++) {
int length = instruction_length(&code[offset], code + code_length);
int next_offset = offset + length;
if (length <= 0)
CCerror(context, "Illegal instruction found at offset %d", offset);
if (next_offset > code_length)
CCerror(context, "Code stops in the middle of instruction "
" starting at offset %d", offset);
code_data[offset] = i;
while (++offset < next_offset)
code_data[offset] = -1;
}
instruction_count = i; /* number of instructions in code */
/* Allocate a structure to hold info about each instruction. */
idata = NEW(<API key>, instruction_count);
/* Initialize the heap, and other info in the context structure. */
context->code = code;
context->instruction_data = idata;
context->code_data = code_data;
context->instruction_count = instruction_count;
context->handler_info =
NEW(struct handler_info_type,
<API key>(env, cb, method_index));
context->bitmask_size =
(<API key>(env, cb, method_index)
+ (BITS_PER_INT - 1))/BITS_PER_INT;
if (instruction_count == 0)
CCerror(context, "Empty code");
for (inumber = 0, offset = 0; offset < code_length; inumber++) {
int length = instruction_length(&code[offset], code + code_length);
<API key> *this_idata = &idata[inumber];
this_idata->opcode = code[offset];
this_idata->stack_info.stack = NULL;
this_idata->stack_info.stack_size = UNKNOWN_STACK_SIZE;
this_idata->register_info.register_count = <API key>;
this_idata->changed = JNI_FALSE; /* no need to look at it yet. */
this_idata->protected = JNI_FALSE; /* no need to look at it yet. */
this_idata->and_flags = (flag_type) -1; /* "bottom" and value */
this_idata->or_flags = 0; /* "bottom" or value*/
/* This also sets up this_data->operand. It also makes the
* xload_x and xstore_x instructions look like the generic form. */
<API key>(context, inumber, offset);
offset += length;
}
/* make sure exception table is reasonable. */
<API key>(context);
/* Set up first instruction, and start of exception handlers. */
initialize_dataflow(context);
/* Run data flow analysis on the instructions. */
run_dataflow(context);
/* verify checked exceptions, if any */
nexceptions = <API key>(env, cb, method_index);
context->exceptions = (unsigned short *)
malloc(sizeof(unsigned short) * nexceptions + 1);
if (context->exceptions == 0)
CCout_of_memory(context);
<API key>(env, cb, method_index,
context->exceptions);
for (i = 0; i < nexceptions; i++) {
/* Make sure the constant pool item is JVM_CONSTANT_Class */
<API key>(context, (int)context->exceptions[i],
1 << JVM_CONSTANT_Class);
}
free(context->exceptions);
context->exceptions = 0;
context->code = 0;
context->method_index = -1;
}
/* Look at a single instruction, and verify its operands. Also, for
* simplicity, move the operand into the ->operand field.
* Make sure that branches don't go into the middle of nowhere.
*/
static jint _ck_ntohl(jint n)
{
unsigned char *p = (unsigned char *)&n;
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
static void
<API key>(context_type *context, unsigned int inumber, int offset)
{
JNIEnv *env = context->env;
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int *code_data = context->code_data;
int mi = context->method_index;
unsigned char *code = context->code;
int opcode = this_idata->opcode;
int var;
/*
* Set the ip fields to 0 not the i fields because the ip fields
* are 64 bits on 64 bit architectures, the i field is only 32
*/
this_idata->operand.ip = 0;
this_idata->operand2.ip = 0;
switch (opcode) {
case JVM_OPC_jsr:
/* instruction of ret statement */
this_idata->operand2.i = <API key>;
/* FALLTHROUGH */
case JVM_OPC_ifeq: case JVM_OPC_ifne: case JVM_OPC_iflt:
case JVM_OPC_ifge: case JVM_OPC_ifgt: case JVM_OPC_ifle:
case JVM_OPC_ifnull: case JVM_OPC_ifnonnull:
case JVM_OPC_if_icmpeq: case JVM_OPC_if_icmpne: case JVM_OPC_if_icmplt:
case JVM_OPC_if_icmpge: case JVM_OPC_if_icmpgt: case JVM_OPC_if_icmple:
case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
case JVM_OPC_goto: {
/* Set the ->operand to be the instruction number of the target. */
int jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
int target = offset + jump;
if (!isLegalTarget(context, target))
CCerror(context, "Illegal target of jump or branch");
this_idata->operand.i = code_data[target];
break;
}
case JVM_OPC_jsr_w:
/* instruction of ret statement */
this_idata->operand2.i = <API key>;
/* FALLTHROUGH */
case JVM_OPC_goto_w: {
/* Set the ->operand to be the instruction number of the target. */
int jump = (((signed char)(code[offset+1])) << 24) +
(code[offset+2] << 16) + (code[offset+3] << 8) +
(code[offset + 4]);
int target = offset + jump;
if (!isLegalTarget(context, target))
CCerror(context, "Illegal target of jump or branch");
this_idata->operand.i = code_data[target];
break;
}
case JVM_OPC_tableswitch:
case <API key>: {
/* Set the ->operand to be a table of possible instruction targets. */
int *lpc = (int *) UCALIGN(code + offset + 1);
int *lptr;
int *saved_operand;
int keys;
int k, delta;
if (context->major_version < <API key>) {
/* 4639449, 4647081: Padding bytes must be zero. */
unsigned char* bptr = (unsigned char*) (code + offset + 1);
for (; bptr < (unsigned char*)lpc; bptr++) {
if (*bptr != 0) {
CCerror(context, "Non zero padding bytes in switch");
}
}
}
if (opcode == JVM_OPC_tableswitch) {
keys = _ck_ntohl(lpc[2]) - _ck_ntohl(lpc[1]) + 1;
delta = 1;
} else {
keys = _ck_ntohl(lpc[1]); /* number of pairs */
delta = 2;
/* Make sure that the tableswitch items are sorted */
for (k = keys - 1, lptr = &lpc[2]; --k >= 0; lptr += 2) {
int this_key = _ck_ntohl(lptr[0]); /* NB: ntohl may be unsigned */
int next_key = _ck_ntohl(lptr[2]);
if (this_key >= next_key) {
CCerror(context, "Unsorted lookup switch");
}
}
}
saved_operand = NEW(int, keys + 2);
if (!isLegalTarget(context, offset + _ck_ntohl(lpc[0])))
CCerror(context, "Illegal default target in switch");
saved_operand[keys + 1] = code_data[offset + _ck_ntohl(lpc[0])];
for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
int target = offset + _ck_ntohl(lptr[0]);
if (!isLegalTarget(context, target))
CCerror(context, "Illegal branch in tableswitch");
saved_operand[k + 1] = code_data[target];
}
saved_operand[0] = keys + 1; /* number of successors */
this_idata->operand.ip = saved_operand;
break;
}
case JVM_OPC_ldc: {
/* Make sure the constant pool item is the right type. */
int key = code[offset + 1];
int types = (1 << <API key>) | (1 << JVM_CONSTANT_Float) |
(1 << JVM_CONSTANT_String);
if (context->major_version >= <API key>) {
types |= 1 << JVM_CONSTANT_Class;
}
if (context->major_version >= <API key>) {
types |= (1 << <API key>) |
(1 << <API key>);
}
this_idata->operand.i = key;
<API key>(context, key, types);
break;
}
case JVM_OPC_ldc_w: {
/* Make sure the constant pool item is the right type. */
int key = (code[offset + 1] << 8) + code[offset + 2];
int types = (1 << <API key>) | (1 << JVM_CONSTANT_Float) |
(1 << JVM_CONSTANT_String);
if (context->major_version >= <API key>) {
types |= 1 << JVM_CONSTANT_Class;
}
if (context->major_version >= <API key>) {
types |= (1 << <API key>) |
(1 << <API key>);
}
this_idata->operand.i = key;
<API key>(context, key, types);
break;
}
case JVM_OPC_ldc2_w: {
/* Make sure the constant pool item is the right type. */
int key = (code[offset + 1] << 8) + code[offset + 2];
int types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long);
this_idata->operand.i = key;
<API key>(context, key, types);
break;
}
case JVM_OPC_getfield: case JVM_OPC_putfield:
case JVM_OPC_getstatic: case JVM_OPC_putstatic: {
/* Make sure the constant pool item is the right type. */
int key = (code[offset + 1] << 8) + code[offset + 2];
this_idata->operand.i = key;
<API key>(context, key, 1 << <API key>);
if (opcode == JVM_OPC_getfield || opcode == JVM_OPC_putfield)
set_protected(context, inumber, key, opcode);
break;
}
case <API key>:
case <API key>:
case <API key>:
case <API key>: {
/* Make sure the constant pool item is the right type. */
int key = (code[offset + 1] << 8) + code[offset + 2];
const char *methodname;
jclass cb = context->class;
fullinfo_type clazz_info;
int is_constructor, is_internal;
int kind;
switch (opcode ) {
case <API key>:
kind = ((context->major_version < <API key>)
? (1 << <API key>)
: ((1 << <API key>) | (1 << <API key>)));
break;
case <API key>:
kind = 1 << <API key>;
break;
default:
kind = 1 << <API key>;
}
/* Make sure the constant pool item is the right type. */
<API key>(context, key, kind);
methodname = <API key>(env, cb, key);
check_and_push(context, methodname, VM_STRING_UTF);
is_constructor = !strcmp(methodname, "<init>");
is_internal = methodname[0] == '<';
pop_and_free(context);
clazz_info = <API key>(context, key,
<API key>);
this_idata->operand.i = key;
this_idata->operand2.fi = clazz_info;
if (is_constructor) {
if (opcode != <API key>) {
CCerror(context,
"Must call initializers using invokespecial");
}
this_idata->opcode = JVM_OPC_invokeinit;
} else {
if (is_internal) {
CCerror(context, "Illegal call to internal method");
}
if (opcode == <API key>
&& clazz_info != context->currentclass_info
&& clazz_info != context->superclass_info) {
int not_found = 1;
jclass super = (*env)->GetSuperclass(env, context->class);
while(super != 0) {
jclass tmp_cb;
fullinfo_type new_info = make_class_info(context, super);
if (clazz_info == new_info) {
not_found = 0;
break;
}
tmp_cb = (*env)->GetSuperclass(env, super);
(*env)->DeleteLocalRef(env, super);
super = tmp_cb;
}
(*env)->DeleteLocalRef(env, super);
/* The optimizer may cause this to happen on local code */
if (not_found) {
CCerror(context, "Illegal use of nonvirtual function call");
}
}
}
if (opcode == <API key>) {
unsigned int args1;
unsigned int args2;
const char *signature =
<API key>(env, context->class, key);
check_and_push(context, signature, VM_STRING_UTF);
args1 = <API key>(signature) + 1;
args2 = code[offset + 3];
if (args1 != args2) {
CCerror(context,
"Inconsistent args_size for invokeinterface");
}
if (code[offset + 4] != 0) {
CCerror(context,
"Fourth operand byte of invokeinterface must be zero");
}
pop_and_free(context);
} else if (opcode == <API key>
|| opcode == <API key>)
set_protected(context, inumber, key, opcode);
break;
}
case <API key>:
CCerror(context,
"invokedynamic bytecode is not supported in this class file version");
case JVM_OPC_instanceof:
case JVM_OPC_checkcast:
case JVM_OPC_new:
case JVM_OPC_anewarray:
case <API key>: {
/* Make sure the constant pool item is a class */
int key = (code[offset + 1] << 8) + code[offset + 2];
fullinfo_type target;
<API key>(context, key, 1 << JVM_CONSTANT_Class);
target = <API key>(context, key, JVM_CONSTANT_Class);
if (GET_ITEM_TYPE(target) == ITEM_Bogus)
CCerror(context, "Illegal type");
switch(opcode) {
case JVM_OPC_anewarray:
if ((GET_INDIRECTION(target)) >= <API key>)
CCerror(context, "Array with too many dimensions");
this_idata->operand.fi = MAKE_FULLINFO(GET_ITEM_TYPE(target),
GET_INDIRECTION(target) + 1,
GET_EXTRA_INFO(target));
break;
case JVM_OPC_new:
if (<API key>(target) !=
MAKE_FULLINFO(ITEM_Object, 0, 0))
CCerror(context, "Illegal creation of multi-dimensional array");
/* operand gets set to the "unitialized object". operand2 gets
* set to what the value will be after it's initialized. */
this_idata->operand.fi = MAKE_FULLINFO(ITEM_NewObject, 0, inumber);
this_idata->operand2.fi = target;
break;
case <API key>:
this_idata->operand.fi = target;
this_idata->operand2.i = code[offset + 3];
if ( (this_idata->operand2.i > (int)GET_INDIRECTION(target))
|| (this_idata->operand2.i == 0))
CCerror(context, "Illegal dimension argument");
break;
default:
this_idata->operand.fi = target;
}
break;
}
case JVM_OPC_newarray: {
/* Cache the result of the JVM_OPC_newarray into the operand slot */
fullinfo_type full_info;
switch (code[offset + 1]) {
case JVM_T_INT:
full_info = MAKE_FULLINFO(ITEM_Integer, 1, 0); break;
case JVM_T_LONG:
full_info = MAKE_FULLINFO(ITEM_Long, 1, 0); break;
case JVM_T_FLOAT:
full_info = MAKE_FULLINFO(ITEM_Float, 1, 0); break;
case JVM_T_DOUBLE:
full_info = MAKE_FULLINFO(ITEM_Double, 1, 0); break;
case JVM_T_BOOLEAN:
full_info = MAKE_FULLINFO(ITEM_Boolean, 1, 0); break;
case JVM_T_BYTE:
full_info = MAKE_FULLINFO(ITEM_Byte, 1, 0); break;
case JVM_T_CHAR:
full_info = MAKE_FULLINFO(ITEM_Char, 1, 0); break;
case JVM_T_SHORT:
full_info = MAKE_FULLINFO(ITEM_Short, 1, 0); break;
default:
full_info = 0; /* Keep lint happy */
CCerror(context, "Bad type passed to newarray");
}
this_idata->operand.fi = full_info;
break;
}
/* Fudge iload_x, aload_x, etc to look like their generic cousin. */
case JVM_OPC_iload_0: case JVM_OPC_iload_1: case JVM_OPC_iload_2: case JVM_OPC_iload_3:
this_idata->opcode = JVM_OPC_iload;
var = opcode - JVM_OPC_iload_0;
goto <API key>;
case JVM_OPC_fload_0: case JVM_OPC_fload_1: case JVM_OPC_fload_2: case JVM_OPC_fload_3:
this_idata->opcode = JVM_OPC_fload;
var = opcode - JVM_OPC_fload_0;
goto <API key>;
case JVM_OPC_aload_0: case JVM_OPC_aload_1: case JVM_OPC_aload_2: case JVM_OPC_aload_3:
this_idata->opcode = JVM_OPC_aload;
var = opcode - JVM_OPC_aload_0;
goto <API key>;
case JVM_OPC_lload_0: case JVM_OPC_lload_1: case JVM_OPC_lload_2: case JVM_OPC_lload_3:
this_idata->opcode = JVM_OPC_lload;
var = opcode - JVM_OPC_lload_0;
goto <API key>;
case JVM_OPC_dload_0: case JVM_OPC_dload_1: case JVM_OPC_dload_2: case JVM_OPC_dload_3:
this_idata->opcode = JVM_OPC_dload;
var = opcode - JVM_OPC_dload_0;
goto <API key>;
case JVM_OPC_istore_0: case JVM_OPC_istore_1: case JVM_OPC_istore_2: case JVM_OPC_istore_3:
this_idata->opcode = JVM_OPC_istore;
var = opcode - JVM_OPC_istore_0;
goto <API key>;
case JVM_OPC_fstore_0: case JVM_OPC_fstore_1: case JVM_OPC_fstore_2: case JVM_OPC_fstore_3:
this_idata->opcode = JVM_OPC_fstore;
var = opcode - JVM_OPC_fstore_0;
goto <API key>;
case JVM_OPC_astore_0: case JVM_OPC_astore_1: case JVM_OPC_astore_2: case JVM_OPC_astore_3:
this_idata->opcode = JVM_OPC_astore;
var = opcode - JVM_OPC_astore_0;
goto <API key>;
case JVM_OPC_lstore_0: case JVM_OPC_lstore_1: case JVM_OPC_lstore_2: case JVM_OPC_lstore_3:
this_idata->opcode = JVM_OPC_lstore;
var = opcode - JVM_OPC_lstore_0;
goto <API key>;
case JVM_OPC_dstore_0: case JVM_OPC_dstore_1: case JVM_OPC_dstore_2: case JVM_OPC_dstore_3:
this_idata->opcode = JVM_OPC_dstore;
var = opcode - JVM_OPC_dstore_0;
goto <API key>;
case JVM_OPC_wide:
this_idata->opcode = code[offset + 1];
var = (code[offset + 2] << 8) + code[offset + 3];
switch(this_idata->opcode) {
case JVM_OPC_lload: case JVM_OPC_dload:
case JVM_OPC_lstore: case JVM_OPC_dstore:
goto <API key>;
default:
goto <API key>;
}
case JVM_OPC_iinc: /* the increment amount doesn't matter */
case JVM_OPC_ret:
case JVM_OPC_aload: case JVM_OPC_iload: case JVM_OPC_fload:
case JVM_OPC_astore: case JVM_OPC_istore: case JVM_OPC_fstore:
var = code[offset + 1];
<API key>:
this_idata->operand.i = var;
if (var >= <API key>(env, context->class, mi))
CCerror(context, "Illegal local variable number");
break;
case JVM_OPC_lload: case JVM_OPC_dload: case JVM_OPC_lstore: case JVM_OPC_dstore:
var = code[offset + 1];
<API key>:
this_idata->operand.i = var;
if ((var + 1) >= <API key>(env, context->class, mi))
CCerror(context, "Illegal local variable number");
break;
default:
if (opcode > JVM_OPC_MAX)
CCerror(context, "Quick instructions shouldn't appear yet.");
break;
} /* of switch */
}
static void
set_protected(context_type *context, unsigned int inumber, int key, int opcode)
{
JNIEnv *env = context->env;
fullinfo_type clazz_info;
if (opcode != <API key> && opcode != <API key>) {
clazz_info = <API key>(context, key,
<API key>);
} else {
clazz_info = <API key>(context, key,
<API key>);
}
if (is_superclass(context, clazz_info)) {
jclass calledClass =
<API key>(context, clazz_info);
int access;
/* 4734966: <API key>() or <API key>() only
searches the referenced field or method in calledClass. The following
while loop is added to search up the superclass chain to make this
symbolic resolution consistent with the field/method resolution
specified in VM spec 5.4.3. */
calledClass = (*env)->NewLocalRef(env, calledClass);
do {
jclass tmp_cb;
if (opcode != <API key> && opcode != <API key>) {
access = <API key>
(env, context->class, key, calledClass);
} else {
access = <API key>
(env, context->class, key, calledClass);
}
if (access != -1) {
break;
}
tmp_cb = (*env)->GetSuperclass(env, calledClass);
(*env)->DeleteLocalRef(env, calledClass);
calledClass = tmp_cb;
} while (calledClass != 0);
if (access == -1) {
/* field/method not found, detected at runtime. */
} else if (access & JVM_ACC_PROTECTED) {
if (!<API key>(env, calledClass, context->class))
context->instruction_data[inumber].protected = JNI_TRUE;
}
(*env)->DeleteLocalRef(env, calledClass);
}
}
static jboolean
is_superclass(context_type *context, fullinfo_type clazz_info) {
fullinfo_type *fptr = context->superclasses;
if (fptr == 0)
return JNI_FALSE;
for (; *fptr != 0; fptr++) {
if (*fptr == clazz_info)
return JNI_TRUE;
}
return JNI_FALSE;
}
static void
<API key>(context_type *context)
{
JNIEnv *env = context->env;
int mi = context->method_index;
struct handler_info_type *handler_info = context->handler_info;
int *code_data = context->code_data;
int code_length = context->code_length;
int max_stack_size = <API key>(env, context->class, mi);
int i = <API key>(env, context->class, mi);
if (max_stack_size < 1 && i > 0) {
// If the method contains exception handlers, it must have room
// on the expression stack for the exception that the VM could push
CCerror(context, "Stack size too large");
}
for (; --i >= 0; handler_info++) {
<API key> einfo;
stack_item_type *stack_item = NEW(stack_item_type, 1);
<API key>(env, context->class, mi,
i, &einfo);
if (!(einfo.start_pc < einfo.end_pc &&
einfo.start_pc >= 0 &&
isLegalTarget(context, einfo.start_pc) &&
(einfo.end_pc == code_length ||
isLegalTarget(context, einfo.end_pc)))) {
CFerror(context, "Illegal exception table range");
}
if (!((einfo.handler_pc > 0) &&
isLegalTarget(context, einfo.handler_pc))) {
CFerror(context, "Illegal exception table handler");
}
handler_info->start = code_data[einfo.start_pc];
/* einfo.end_pc may point to one byte beyond the end of bytecodes. */
handler_info->end = (einfo.end_pc == context->code_length) ?
context->instruction_count : code_data[einfo.end_pc];
handler_info->handler = code_data[einfo.handler_pc];
handler_info->stack_info.stack = stack_item;
handler_info->stack_info.stack_size = 1;
stack_item->next = NULL;
if (einfo.catchType != 0) {
const char *classname;
/* Constant pool entry type has been checked in format checker */
classname = <API key>(env,
context->class,
einfo.catchType);
check_and_push(context, classname, VM_STRING_UTF);
stack_item->item = <API key>(context, classname);
if (!isAssignableTo(context,
stack_item->item,
context->throwable_info))
CCerror(context, "catch_type not a subclass of Throwable");
pop_and_free(context);
} else {
stack_item->item = context->throwable_info;
}
}
}
/* Given a pointer to an instruction, return its length. Use the table
* opcode_length[] which is automatically built.
*/
static int instruction_length(unsigned char *iptr, unsigned char *end)
{
static unsigned char opcode_length[] = <API key>;
int instruction = *iptr;
switch (instruction) {
case JVM_OPC_tableswitch: {
int *lpc = (int *)UCALIGN(iptr + 1);
int index;
if (lpc + 2 >= (int *)end) {
return -1; /* do not read pass the end */
}
index = _ck_ntohl(lpc[2]) - _ck_ntohl(lpc[1]);
if ((index < 0) || (index > 65535)) {
return -1;
} else {
return (unsigned char *)(&lpc[index + 4]) - iptr;
}
}
case <API key>: {
int *lpc = (int *) UCALIGN(iptr + 1);
int npairs;
if (lpc + 1 >= (int *)end)
return -1; /* do not read pass the end */
npairs = _ck_ntohl(lpc[1]);
/* There can't be more than 64K labels because of the limit
* on per-method byte code length.
*/
if (npairs < 0 || npairs >= 65536)
return -1;
else
return (unsigned char *)(&lpc[2 * (npairs + 1)]) - iptr;
}
case JVM_OPC_wide:
if (iptr + 1 >= end)
return -1; /* do not read pass the end */
switch(iptr[1]) {
case JVM_OPC_ret:
case JVM_OPC_iload: case JVM_OPC_istore:
case JVM_OPC_fload: case JVM_OPC_fstore:
case JVM_OPC_aload: case JVM_OPC_astore:
case JVM_OPC_lload: case JVM_OPC_lstore:
case JVM_OPC_dload: case JVM_OPC_dstore:
return 4;
case JVM_OPC_iinc:
return 6;
default:
return -1;
}
default: {
if (instruction < 0 || instruction > JVM_OPC_MAX)
return -1;
/* A length of 0 indicates an error. */
if (opcode_length[instruction] <= 0)
return -1;
return opcode_length[instruction];
}
}
}
static jboolean
isLegalTarget(context_type *context, int offset)
{
int code_length = context->code_length;
int *code_data = context->code_data;
return (offset >= 0 && offset < code_length && code_data[offset] >= 0);
}
/* Make sure that an element of the constant pool really is of the indicated
* type.
*/
static void
<API key>(context_type *context, int index, unsigned mask)
{
int nconstants = context->nconstants;
unsigned char *type_table = context->constant_types;
unsigned type;
if ((index <= 0) || (index >= nconstants))
CCerror(context, "Illegal constant pool index");
type = type_table[index];
if ((mask & (1 << type)) == 0)
CCerror(context, "Illegal type in constant pool");
}
static void
initialize_dataflow(context_type *context)
{
JNIEnv *env = context->env;
<API key> *idata = context->instruction_data;
int mi = context->method_index;
jclass cb = context->class;
int args_size = <API key>(env, cb, mi);
fullinfo_type *reg_ptr;
fullinfo_type full_info;
const char *p;
const char *signature;
/* Initialize the function entry, since we know everything about it. */
idata[0].stack_info.stack_size = 0;
idata[0].stack_info.stack = NULL;
idata[0].register_info.register_count = args_size;
idata[0].register_info.registers = NEW(fullinfo_type, args_size);
idata[0].register_info.mask_count = 0;
idata[0].register_info.masks = NULL;
idata[0].and_flags = 0; /* nothing needed */
idata[0].or_flags = FLAG_REACHED; /* instruction reached */
reg_ptr = idata[0].register_info.registers;
if ((<API key>(env, cb, mi) & JVM_ACC_STATIC) == 0) {
/* A non static method. If this is an <init> method, the first
* argument is an uninitialized object. Otherwise it is an object of
* the given class type. java.lang.Object.<init> is special since
* we don't call its superclass <init> method.
*/
if (JVM_IsConstructorIx(env, cb, mi)
&& context->currentclass_info != context->object_info) {
*reg_ptr++ = MAKE_FULLINFO(ITEM_InitObject, 0, 0);
idata[0].or_flags |= <API key>;
} else {
*reg_ptr++ = context->currentclass_info;
}
}
signature = <API key>(env, cb, mi);
check_and_push(context, signature, VM_STRING_UTF);
/* Fill in each of the arguments into the registers. */
for (p = signature + 1; *p != <API key>; ) {
char fieldchar = <API key>(context, &p, &full_info);
switch (fieldchar) {
case 'D': case 'L':
*reg_ptr++ = full_info;
*reg_ptr++ = full_info + 1;
break;
default:
*reg_ptr++ = full_info;
break;
}
}
p++; /* skip over right parenthesis */
if (*p == 'V') {
context->return_type = MAKE_FULLINFO(ITEM_Void, 0, 0);
} else {
<API key>(context, &p, &full_info);
context->return_type = full_info;
}
pop_and_free(context);
/* Indicate that we need to look at the first instruction. */
idata[0].changed = JNI_TRUE;
}
/* Run the data flow analysis, as long as there are things to change. */
static void
run_dataflow(context_type *context) {
JNIEnv *env = context->env;
int mi = context->method_index;
jclass cb = context->class;
int max_stack_size = <API key>(env, cb, mi);
<API key> *idata = context->instruction_data;
unsigned int icount = context->instruction_count;
jboolean work_to_do = JNI_TRUE;
unsigned int inumber;
/* Run through the loop, until there is nothing left to do. */
while (work_to_do) {
work_to_do = JNI_FALSE;
for (inumber = 0; inumber < icount; inumber++) {
<API key> *this_idata = &idata[inumber];
if (this_idata->changed) {
register_info_type new_register_info;
stack_info_type new_stack_info;
flag_type new_and_flags, new_or_flags;
this_idata->changed = JNI_FALSE;
work_to_do = JNI_TRUE;
#ifdef DEBUG
if (verify_verbose) {
int opcode = this_idata->opcode;
jio_fprintf(stdout, "Instruction %d: ", inumber);
print_stack(context, &this_idata->stack_info);
print_registers(context, &this_idata->register_info);
print_flags(context,
this_idata->and_flags, this_idata->or_flags);
fflush(stdout);
}
#endif
/* Make sure the registers and flags are appropriate */
<API key>(context, inumber);
check_flags(context, inumber);
/* Make sure the stack can deal with this instruction */
pop_stack(context, inumber, &new_stack_info);
/* Update the registers and flags */
update_registers(context, inumber, &new_register_info);
update_flags(context, inumber, &new_and_flags, &new_or_flags);
/* Update the stack. */
push_stack(context, inumber, &new_stack_info);
if (new_stack_info.stack_size > max_stack_size)
CCerror(context, "Stack size too large");
#ifdef DEBUG
if (verify_verbose) {
jio_fprintf(stdout, " ");
print_stack(context, &new_stack_info);
print_registers(context, &new_register_info);
print_flags(context, new_and_flags, new_or_flags);
fflush(stdout);
}
#endif
/* Add the new stack and register information to any
* instructions that can follow this instruction. */
<API key>(context, inumber,
&new_register_info, &new_stack_info,
new_and_flags, new_or_flags);
}
}
}
}
/* Make sure that the registers contain a legitimate value for the given
* instruction.
*/
static void
<API key>(context_type *context, unsigned int inumber)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
int operand = this_idata->operand.i;
int register_count = this_idata->register_info.register_count;
fullinfo_type *registers = this_idata->register_info.registers;
jboolean double_word = JNI_FALSE; /* default value */
int type;
switch (opcode) {
default:
return;
case JVM_OPC_iload: case JVM_OPC_iinc:
type = ITEM_Integer; break;
case JVM_OPC_fload:
type = ITEM_Float; break;
case JVM_OPC_aload:
type = ITEM_Object; break;
case JVM_OPC_ret:
type = ITEM_ReturnAddress; break;
case JVM_OPC_lload:
type = ITEM_Long; double_word = JNI_TRUE; break;
case JVM_OPC_dload:
type = ITEM_Double; double_word = JNI_TRUE; break;
}
if (!double_word) {
fullinfo_type reg;
if (operand >= register_count) {
CCerror(context,
"Accessing value from uninitialized register %d", operand);
}
reg = registers[operand];
if (<API key>(reg) == (unsigned)MAKE_FULLINFO(type, 0, 0)) {
/* the register is obviously of the given type */
return;
} else if (GET_INDIRECTION(reg) > 0 && type == ITEM_Object) {
/* address type stuff be used on all arrays */
return;
} else if (GET_ITEM_TYPE(reg) == ITEM_ReturnAddress) {
CCerror(context, "Cannot load return address from register %d",
operand);
/* alternatively
(GET_ITEM_TYPE(reg) == ITEM_ReturnAddress)
&& (opcode == JVM_OPC_iload)
&& (type == ITEM_Object || type == ITEM_Integer)
but this never occurs
*/
} else if (reg == ITEM_InitObject && type == ITEM_Object) {
return;
} else if (<API key>(reg) ==
MAKE_FULLINFO(ITEM_NewObject, 0, 0) &&
type == ITEM_Object) {
return;
} else {
CCerror(context, "Register %d contains wrong type", operand);
}
} else {
if ((operand + 1) >= register_count) {
CCerror(context,
"Accessing value from uninitialized register pair %d/%d",
operand, operand+1);
} else {
if ((registers[operand] == (unsigned)MAKE_FULLINFO(type, 0, 0)) &&
(registers[operand + 1] == (unsigned)MAKE_FULLINFO(type + 1, 0, 0))) {
return;
} else {
CCerror(context, "Register pair %d/%d contains wrong type",
operand, operand+1);
}
}
}
}
/* Make sure the flags contain legitimate values for this instruction.
*/
static void
check_flags(context_type *context, unsigned int inumber)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
switch (opcode) {
case JVM_OPC_return:
/* We need a constructor, but we aren't guaranteed it's called */
if ((this_idata->or_flags & <API key>) &&
!(this_idata->and_flags & FLAG_CONSTRUCTED))
CCerror(context, "Constructor must call super() or this()");
/* fall through */
case JVM_OPC_ireturn: case JVM_OPC_lreturn:
case JVM_OPC_freturn: case JVM_OPC_dreturn: case JVM_OPC_areturn:
if (this_idata->or_flags & FLAG_NO_RETURN)
/* This method cannot exit normally */
CCerror(context, "Cannot return normally");
default:
break; /* nothing to do. */
}
}
/* Make sure that the top of the stack contains reasonable values for the
* given instruction. The post-pop values of the stack and its size are
* returned in *new_stack_info.
*/
static void
pop_stack(context_type *context, unsigned int inumber, stack_info_type *new_stack_info)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
stack_item_type *stack = this_idata->stack_info.stack;
int stack_size = this_idata->stack_info.stack_size;
char *stack_operands, *p;
char buffer[257]; /* for holding manufactured argument lists */
fullinfo_type <API key>[256]; /* save info popped off stack */
fullinfo_type *stack_extra_info = &<API key>[256];
fullinfo_type full_info; /* only used in case of invoke instructions */
fullinfo_type put_full_info; /* only used in case JVM_OPC_putstatic and JVM_OPC_putfield */
switch(opcode) {
default:
/* For most instructions, we just use a built-in table */
stack_operands = opcode_in_out[opcode][0];
break;
case JVM_OPC_putstatic: case JVM_OPC_putfield: {
/* The top thing on the stack depends on the signature of
* the object. */
int operand = this_idata->operand.i;
const char *signature =
<API key>(context->env,
context->class,
operand);
char *ip = buffer;
check_and_push(context, signature, VM_STRING_UTF);
#ifdef DEBUG
if (verify_verbose) {
<API key>(context, operand);
}
#endif
if (opcode == JVM_OPC_putfield)
*ip++ = 'A'; /* object for putfield */
*ip++ = <API key>(context, &signature, &put_full_info);
*ip = '\0';
stack_operands = buffer;
pop_and_free(context);
break;
}
case <API key>: case <API key>:
case JVM_OPC_invokeinit: /* invokespecial call to <init> */
case <API key>: case <API key>: {
/* The top stuff on the stack depends on the method signature */
int operand = this_idata->operand.i;
const char *signature =
<API key>(context->env,
context->class,
operand);
char *ip = buffer;
const char *p;
check_and_push(context, signature, VM_STRING_UTF);
#ifdef DEBUG
if (verify_verbose) {
<API key>(context, operand);
}
#endif
if (opcode != <API key>)
/* First, push the object */
*ip++ = (opcode == JVM_OPC_invokeinit ? '@' : 'A');
for (p = signature + 1; *p != <API key>; ) {
*ip++ = <API key>(context, &p, &full_info);
if (ip >= buffer + sizeof(buffer) - 1)
CCerror(context, "Signature %s has too many arguments",
signature);
}
*ip = 0;
stack_operands = buffer;
pop_and_free(context);
break;
}
case <API key>: {
/* Count can't be larger than 255. So can't overflow buffer */
int count = this_idata->operand2.i; /* number of ints on stack */
memset(buffer, 'I', count);
buffer[count] = '\0';
stack_operands = buffer;
break;
}
} /* of switch */
/* Run through the list of operands >>backwards<< */
for ( p = stack_operands + strlen(stack_operands);
p > stack_operands;
stack = stack->next) {
int type = *--p;
fullinfo_type top_type = stack ? stack->item : 0;
int size = (type == 'D' || type == 'L') ? 2 : 1;
*--stack_extra_info = top_type;
if (stack == NULL)
CCerror(context, "Unable to pop operand off an empty stack");
switch (type) {
case 'I':
if (top_type != MAKE_FULLINFO(ITEM_Integer, 0, 0))
CCerror(context, "Expecting to find integer on stack");
break;
case 'F':
if (top_type != MAKE_FULLINFO(ITEM_Float, 0, 0))
CCerror(context, "Expecting to find float on stack");
break;
case 'A': /* object or array */
if ( (GET_ITEM_TYPE(top_type) != ITEM_Object)
&& (GET_INDIRECTION(top_type) == 0)) {
/* The thing isn't an object or an array. Let's see if it's
* one of the special cases */
if ( (<API key>(top_type) ==
MAKE_FULLINFO(ITEM_ReturnAddress, 0, 0))
&& (opcode == JVM_OPC_astore))
break;
if ( (GET_ITEM_TYPE(top_type) == ITEM_NewObject
|| (GET_ITEM_TYPE(top_type) == ITEM_InitObject))
&& ((opcode == JVM_OPC_astore) || (opcode == JVM_OPC_aload)
|| (opcode == JVM_OPC_ifnull) || (opcode == JVM_OPC_ifnonnull)))
break;
/* The 2nd edition VM of the specification allows field
* initializations before the superclass initializer,
* if the field is defined within the current class.
*/
if ( (GET_ITEM_TYPE(top_type) == ITEM_InitObject)
&& (opcode == JVM_OPC_putfield)) {
int operand = this_idata->operand.i;
int access_bits = <API key>(context->env,
context->class,
operand,
context->class);
/* Note: This relies on the fact that
* <API key> retrieves only local fields,
* and does not respect inheritance.
*/
if (access_bits != -1) {
if ( <API key>(context, operand, <API key>) ==
context->currentclass_info ) {
top_type = context->currentclass_info;
*stack_extra_info = top_type;
break;
}
}
}
CCerror(context, "Expecting to find object/array on stack");
}
break;
case '@': { /* unitialized object, for call to <init> */
int item_type = GET_ITEM_TYPE(top_type);
if (item_type != ITEM_NewObject && item_type != ITEM_InitObject)
CCerror(context,
"Expecting to find unitialized object on stack");
break;
}
case 'O': /* object, not array */
if (<API key>(top_type) !=
MAKE_FULLINFO(ITEM_Object, 0, 0))
CCerror(context, "Expecting to find object on stack");
break;
case 'a': /* integer, object, or array */
if ( (top_type != MAKE_FULLINFO(ITEM_Integer, 0, 0))
&& (GET_ITEM_TYPE(top_type) != ITEM_Object)
&& (GET_INDIRECTION(top_type) == 0))
CCerror(context,
"Expecting to find object, array, or int on stack");
break;
case 'D': /* double */
if (top_type != MAKE_FULLINFO(ITEM_Double, 0, 0))
CCerror(context, "Expecting to find double on stack");
break;
case 'L': /* long */
if (top_type != MAKE_FULLINFO(ITEM_Long, 0, 0))
CCerror(context, "Expecting to find long on stack");
break;
case ']': /* array of some type */
if (top_type == NULL_FULLINFO) {
/* do nothing */
} else switch(p[-1]) {
case 'I': /* array of integers */
if (top_type != MAKE_FULLINFO(ITEM_Integer, 1, 0) &&
top_type != NULL_FULLINFO)
CCerror(context,
"Expecting to find array of ints on stack");
break;
case 'L': /* array of longs */
if (top_type != MAKE_FULLINFO(ITEM_Long, 1, 0))
CCerror(context,
"Expecting to find array of longs on stack");
break;
case 'F': /* array of floats */
if (top_type != MAKE_FULLINFO(ITEM_Float, 1, 0))
CCerror(context,
"Expecting to find array of floats on stack");
break;
case 'D': /* array of doubles */
if (top_type != MAKE_FULLINFO(ITEM_Double, 1, 0))
CCerror(context,
"Expecting to find array of doubles on stack");
break;
case 'A': { /* array of addresses (arrays or objects) */
int indirection = GET_INDIRECTION(top_type);
if ((indirection == 0) ||
((indirection == 1) &&
(GET_ITEM_TYPE(top_type) != ITEM_Object)))
CCerror(context,
"Expecting to find array of objects or arrays "
"on stack");
break;
}
case 'B': /* array of bytes or booleans */
if (top_type != MAKE_FULLINFO(ITEM_Byte, 1, 0) &&
top_type != MAKE_FULLINFO(ITEM_Boolean, 1, 0))
CCerror(context,
"Expecting to find array of bytes or Booleans on stack");
break;
case 'C': /* array of characters */
if (top_type != MAKE_FULLINFO(ITEM_Char, 1, 0))
CCerror(context,
"Expecting to find array of chars on stack");
break;
case 'S': /* array of shorts */
if (top_type != MAKE_FULLINFO(ITEM_Short, 1, 0))
CCerror(context,
"Expecting to find array of shorts on stack");
break;
case '?': /* any type of array is okay */
if (GET_INDIRECTION(top_type) == 0)
CCerror(context,
"Expecting to find array on stack");
break;
default:
CCerror(context, "Internal error
break;
}
p -= 2; /* skip over [ <char> */
break;
case '1': case '2': case '3': case '4': /* stack swapping */
if (top_type == MAKE_FULLINFO(ITEM_Double, 0, 0)
|| top_type == MAKE_FULLINFO(ITEM_Long, 0, 0)) {
if ((p > stack_operands) && (p[-1] == '+')) {
context->swap_table[type - '1'] = top_type + 1;
context->swap_table[p[-2] - '1'] = top_type;
size = 2;
p -= 2;
} else {
CCerror(context,
"Attempt to split long or double on the stack");
}
} else {
context->swap_table[type - '1'] = stack->item;
if ((p > stack_operands) && (p[-1] == '+'))
p--; /* ignore */
}
break;
case '+': /* these should have been caught. */
default:
CCerror(context, "Internal error
}
stack_size -= size;
}
/* For many of the opcodes that had an "A" in their field, we really
* need to go back and do a little bit more accurate testing. We can, of
* course, assume that the minimal type checking has already been done.
*/
switch (opcode) {
default: break;
case JVM_OPC_aastore: { /* array index object */
fullinfo_type array_type = stack_extra_info[0];
fullinfo_type object_type = stack_extra_info[2];
fullinfo_type target_type = <API key>(array_type);
if ((GET_ITEM_TYPE(object_type) != ITEM_Object)
&& (GET_INDIRECTION(object_type) == 0)) {
CCerror(context, "Expecting reference type on operand stack in aastore");
}
if ((GET_ITEM_TYPE(target_type) != ITEM_Object)
&& (GET_INDIRECTION(target_type) == 0)) {
CCerror(context, "Component type of the array must be reference type in aastore");
}
break;
}
case JVM_OPC_putfield:
case JVM_OPC_getfield:
case JVM_OPC_putstatic: {
int operand = this_idata->operand.i;
fullinfo_type stack_object = stack_extra_info[0];
if (opcode == JVM_OPC_putfield || opcode == JVM_OPC_getfield) {
if (!isAssignableTo
(context,
stack_object,
<API key>
(context, operand, <API key>))) {
CCerror(context,
"Incompatible type for getting or setting field");
}
if (this_idata->protected &&
!isAssignableTo(context, stack_object,
context->currentclass_info)) {
CCerror(context, "Bad access to protected data");
}
}
if (opcode == JVM_OPC_putfield || opcode == JVM_OPC_putstatic) {
int item = (opcode == JVM_OPC_putfield ? 1 : 0);
if (!isAssignableTo(context,
stack_extra_info[item], put_full_info)) {
CCerror(context, "Bad type in putfield/putstatic");
}
}
break;
}
case JVM_OPC_athrow:
if (!isAssignableTo(context, stack_extra_info[0],
context->throwable_info)) {
CCerror(context, "Can only throw Throwable objects");
}
break;
case JVM_OPC_aaload: { /* array index */
/* We need to pass the information to the stack updater */
fullinfo_type array_type = stack_extra_info[0];
context->swap_table[0] = <API key>(array_type);
break;
}
case <API key>: case <API key>:
case JVM_OPC_invokeinit:
case <API key>: case <API key>: {
int operand = this_idata->operand.i;
const char *signature =
<API key>(context->env,
context->class,
operand);
int item;
const char *p;
check_and_push(context, signature, VM_STRING_UTF);
if (opcode == <API key>) {
item = 0;
} else if (opcode == JVM_OPC_invokeinit) {
fullinfo_type init_type = this_idata->operand2.fi;
fullinfo_type object_type = stack_extra_info[0];
context->swap_table[0] = object_type; /* save value */
if (GET_ITEM_TYPE(stack_extra_info[0]) == ITEM_NewObject) {
/* We better be calling the appropriate init. Find the
* inumber of the "JVM_OPC_new" instruction", and figure
* out what the type really is.
*/
unsigned int new_inumber = GET_EXTRA_INFO(stack_extra_info[0]);
fullinfo_type target_type = idata[new_inumber].operand2.fi;
context->swap_table[1] = target_type;
if (target_type != init_type) {
CCerror(context, "Call to wrong initialization method");
}
if (this_idata->protected
&& !isAssignableTo(context, object_type,
context->currentclass_info)) {
CCerror(context, "Bad access to protected data");
}
} else {
/* We better be calling super() or this(). */
if (init_type != context->superclass_info &&
init_type != context->currentclass_info) {
CCerror(context, "Call to wrong initialization method");
}
context->swap_table[1] = context->currentclass_info;
}
item = 1;
} else {
fullinfo_type target_type = this_idata->operand2.fi;
fullinfo_type object_type = stack_extra_info[0];
if (!isAssignableTo(context, object_type, target_type)){
CCerror(context,
"Incompatible object argument for function call");
}
if (opcode == <API key>
&& !isAssignableTo(context, object_type,
context->currentclass_info)) {
/* Make sure object argument is assignment compatible to current class */
CCerror(context,
"Incompatible object argument for invokespecial");
}
if (this_idata->protected
&& !isAssignableTo(context, object_type,
context->currentclass_info)) {
/* This is ugly. Special dispensation. Arrays pretend to
implement public Object clone() even though they don't */
const char *utfName =
<API key>(context->env,
context->class,
this_idata->operand.i);
int is_clone = utfName && (strcmp(utfName, "clone") == 0);
JVM_ReleaseUTF(utfName);
if ((target_type == context->object_info) &&
(GET_INDIRECTION(object_type) > 0) &&
is_clone) {
} else {
CCerror(context, "Bad access to protected data");
}
}
item = 1;
}
for (p = signature + 1; *p != <API key>; item++)
if (<API key>(context, &p, &full_info) == 'A') {
if (!isAssignableTo(context,
stack_extra_info[item], full_info)) {
CCerror(context, "Incompatible argument to function");
}
}
pop_and_free(context);
break;
}
case JVM_OPC_return:
if (context->return_type != MAKE_FULLINFO(ITEM_Void, 0, 0))
CCerror(context, "Wrong return type in function");
break;
case JVM_OPC_ireturn: case JVM_OPC_lreturn: case JVM_OPC_freturn:
case JVM_OPC_dreturn: case JVM_OPC_areturn: {
fullinfo_type target_type = context->return_type;
fullinfo_type object_type = stack_extra_info[0];
if (!isAssignableTo(context, object_type, target_type)) {
CCerror(context, "Wrong return type in function");
}
break;
}
case JVM_OPC_new: {
/* Make sure that nothing on the stack already looks like what
* we want to create. I can't image how this could possibly happen
* but we should test for it anyway, since if it could happen, the
* result would be an unitialized object being able to masquerade
* as an initialized one.
*/
stack_item_type *item;
for (item = stack; item != NULL; item = item->next) {
if (item->item == this_idata->operand.fi) {
CCerror(context,
"Uninitialized object on stack at creating point");
}
}
/* Info for update_registers */
context->swap_table[0] = this_idata->operand.fi;
context->swap_table[1] = MAKE_FULLINFO(ITEM_Bogus, 0, 0);
break;
}
}
new_stack_info->stack = stack;
new_stack_info->stack_size = stack_size;
}
static void
update_registers(context_type *context, unsigned int inumber,
register_info_type *new_register_info)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
int operand = this_idata->operand.i;
int register_count = this_idata->register_info.register_count;
fullinfo_type *registers = this_idata->register_info.registers;
stack_item_type *stack = this_idata->stack_info.stack;
int mask_count = this_idata->register_info.mask_count;
mask_type *masks = this_idata->register_info.masks;
/* Use these as default new values. */
int new_register_count = register_count;
int new_mask_count = mask_count;
fullinfo_type *new_registers = registers;
mask_type *new_masks = masks;
enum { ACCESS_NONE, ACCESS_SINGLE, ACCESS_DOUBLE } access = ACCESS_NONE;
int i;
/* Remember, we've already verified the type at the top of the stack. */
switch (opcode) {
default: break;
case JVM_OPC_istore: case JVM_OPC_fstore: case JVM_OPC_astore:
access = ACCESS_SINGLE;
goto continue_store;
case JVM_OPC_lstore: case JVM_OPC_dstore:
access = ACCESS_DOUBLE;
goto continue_store;
continue_store: {
/* We have a modification to the registers. Copy them if needed. */
fullinfo_type stack_top_type = stack->item;
int max_operand = operand + ((access == ACCESS_DOUBLE) ? 1 : 0);
if ( max_operand < register_count
&& registers[operand] == stack_top_type
&& ((access == ACCESS_SINGLE) ||
(registers[operand + 1]== stack_top_type + 1)))
/* No changes have been made to the registers. */
break;
new_register_count = MAX(max_operand + 1, register_count);
new_registers = NEW(fullinfo_type, new_register_count);
for (i = 0; i < register_count; i++)
new_registers[i] = registers[i];
for (i = register_count; i < new_register_count; i++)
new_registers[i] = MAKE_FULLINFO(ITEM_Bogus, 0, 0);
new_registers[operand] = stack_top_type;
if (access == ACCESS_DOUBLE)
new_registers[operand + 1] = stack_top_type + 1;
break;
}
case JVM_OPC_iload: case JVM_OPC_fload: case JVM_OPC_aload:
case JVM_OPC_iinc: case JVM_OPC_ret:
access = ACCESS_SINGLE;
break;
case JVM_OPC_lload: case JVM_OPC_dload:
access = ACCESS_DOUBLE;
break;
case JVM_OPC_jsr: case JVM_OPC_jsr_w:
for (i = 0; i < new_mask_count; i++)
if (new_masks[i].entry == operand)
CCerror(context, "Recursive call to jsr entry");
new_masks = add_to_masks(context, masks, mask_count, operand);
new_mask_count++;
break;
case JVM_OPC_invokeinit:
case JVM_OPC_new: {
/* For invokeinit, an uninitialized object has been initialized.
* For new, all previous occurrences of an uninitialized object
* from the same instruction must be made bogus.
* We find all occurrences of swap_table[0] in the registers, and
* replace them with swap_table[1];
*/
fullinfo_type from = context->swap_table[0];
fullinfo_type to = context->swap_table[1];
int i;
for (i = 0; i < register_count; i++) {
if (new_registers[i] == from) {
/* Found a match */
break;
}
}
if (i < register_count) { /* We broke out loop for match */
/* We have to change registers, and possibly a mask */
jboolean copied_mask = JNI_FALSE;
int k;
new_registers = NEW(fullinfo_type, register_count);
memcpy(new_registers, registers,
register_count * sizeof(registers[0]));
for ( ; i < register_count; i++) {
if (new_registers[i] == from) {
new_registers[i] = to;
for (k = 0; k < new_mask_count; k++) {
if (!IS_BIT_SET(new_masks[k].modifies, i)) {
if (!copied_mask) {
new_masks = copy_masks(context, new_masks,
mask_count);
copied_mask = JNI_TRUE;
}
SET_BIT(new_masks[k].modifies, i);
}
}
}
}
}
break;
}
} /* of switch */
if ((access != ACCESS_NONE) && (new_mask_count > 0)) {
int i, j;
for (i = 0; i < new_mask_count; i++) {
int *mask = new_masks[i].modifies;
if ((!IS_BIT_SET(mask, operand)) ||
((access == ACCESS_DOUBLE) &&
!IS_BIT_SET(mask, operand + 1))) {
new_masks = copy_masks(context, new_masks, mask_count);
for (j = i; j < new_mask_count; j++) {
SET_BIT(new_masks[j].modifies, operand);
if (access == ACCESS_DOUBLE)
SET_BIT(new_masks[j].modifies, operand + 1);
}
break;
}
}
}
new_register_info->register_count = new_register_count;
new_register_info->registers = new_registers;
new_register_info->masks = new_masks;
new_register_info->mask_count = new_mask_count;
}
static void
update_flags(context_type *context, unsigned int inumber,
flag_type *new_and_flags, flag_type *new_or_flags)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
flag_type and_flags = this_idata->and_flags;
flag_type or_flags = this_idata->or_flags;
/* Set the "we've done a constructor" flag */
if (this_idata->opcode == JVM_OPC_invokeinit) {
fullinfo_type from = context->swap_table[0];
if (from == MAKE_FULLINFO(ITEM_InitObject, 0, 0))
and_flags |= FLAG_CONSTRUCTED;
}
*new_and_flags = and_flags;
*new_or_flags = or_flags;
}
static void
push_stack(context_type *context, unsigned int inumber, stack_info_type *new_stack_info)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
int operand = this_idata->operand.i;
int stack_size = new_stack_info->stack_size;
stack_item_type *stack = new_stack_info->stack;
char *stack_results;
fullinfo_type full_info = 0;
char buffer[5], *p; /* actually [2] is big enough */
/* We need to look at all those opcodes in which either we can't tell the
* value pushed onto the stack from the opcode, or in which the value
* pushed onto the stack is an object or array. For the latter, we need
* to make sure that full_info is set to the right value.
*/
switch(opcode) {
default:
stack_results = opcode_in_out[opcode][1];
break;
case JVM_OPC_ldc: case JVM_OPC_ldc_w: case JVM_OPC_ldc2_w: {
/* Look to constant pool to determine correct result. */
unsigned char *type_table = context->constant_types;
switch (type_table[operand]) {
case <API key>:
stack_results = "I"; break;
case JVM_CONSTANT_Float:
stack_results = "F"; break;
case JVM_CONSTANT_Double:
stack_results = "D"; break;
case JVM_CONSTANT_Long:
stack_results = "L"; break;
case JVM_CONSTANT_String:
stack_results = "A";
full_info = context->string_info;
break;
case JVM_CONSTANT_Class:
if (context->major_version < <API key>)
CCerror(context, "Internal error
stack_results = "A";
full_info = <API key>(context,
"java/lang/Class");
break;
case <API key>:
case <API key>:
if (context->major_version < <API key>)
CCerror(context, "Internal error
stack_results = "A";
switch (type_table[operand]) {
case <API key>:
full_info = <API key>(context,
"java/lang/invoke/MethodType");
break;
default: //<API key>
full_info = <API key>(context,
"java/lang/invoke/MethodHandle");
break;
}
break;
default:
CCerror(context, "Internal error
stack_results = ""; /* Never reached: keep lint happy */
}
break;
}
case JVM_OPC_getstatic: case JVM_OPC_getfield: {
/* Look to signature to determine correct result. */
int operand = this_idata->operand.i;
const char *signature = <API key>(context->env,
context->class,
operand);
check_and_push(context, signature, VM_STRING_UTF);
#ifdef DEBUG
if (verify_verbose) {
<API key>(context, operand);
}
#endif
buffer[0] = <API key>(context, &signature, &full_info);
buffer[1] = '\0';
stack_results = buffer;
pop_and_free(context);
break;
}
case <API key>: case <API key>:
case JVM_OPC_invokeinit:
case <API key>: case <API key>: {
/* Look to signature to determine correct result. */
int operand = this_idata->operand.i;
const char *signature = <API key>(context->env,
context->class,
operand);
const char *result_signature;
check_and_push(context, signature, VM_STRING_UTF);
result_signature = <API key>(signature);
if (result_signature++ == NULL) {
CCerror(context, "Illegal signature %s", signature);
}
if (result_signature[0] == JVM_SIGNATURE_VOID) {
stack_results = "";
} else {
buffer[0] = <API key>(context, &result_signature,
&full_info);
buffer[1] = '\0';
stack_results = buffer;
}
pop_and_free(context);
break;
}
case JVM_OPC_aconst_null:
stack_results = opcode_in_out[opcode][1];
full_info = NULL_FULLINFO; /* special NULL */
break;
case JVM_OPC_new:
case JVM_OPC_checkcast:
case JVM_OPC_newarray:
case JVM_OPC_anewarray:
case <API key>:
stack_results = opcode_in_out[opcode][1];
/* Conveniently, this result type is stored here */
full_info = this_idata->operand.fi;
break;
case JVM_OPC_aaload:
stack_results = opcode_in_out[opcode][1];
/* pop_stack() saved value for us. */
full_info = context->swap_table[0];
break;
case JVM_OPC_aload:
stack_results = opcode_in_out[opcode][1];
/* The register hasn't been modified, so we can use its value. */
full_info = this_idata->register_info.registers[operand];
break;
} /* of switch */
for (p = stack_results; *p != 0; p++) {
int type = *p;
stack_item_type *new_item = NEW(stack_item_type, 1);
new_item->next = stack;
stack = new_item;
switch (type) {
case 'I':
stack->item = MAKE_FULLINFO(ITEM_Integer, 0, 0); break;
case 'F':
stack->item = MAKE_FULLINFO(ITEM_Float, 0, 0); break;
case 'D':
stack->item = MAKE_FULLINFO(ITEM_Double, 0, 0);
stack_size++; break;
case 'L':
stack->item = MAKE_FULLINFO(ITEM_Long, 0, 0);
stack_size++; break;
case 'R':
stack->item = MAKE_FULLINFO(ITEM_ReturnAddress, 0, operand);
break;
case '1': case '2': case '3': case '4': {
/* Get the info saved in the swap_table */
fullinfo_type stype = context->swap_table[type - '1'];
stack->item = stype;
if (stype == MAKE_FULLINFO(ITEM_Long, 0, 0) ||
stype == MAKE_FULLINFO(ITEM_Double, 0, 0)) {
stack_size++; p++;
}
break;
}
case 'A':
/* full_info should have the appropriate value. */
assert(full_info != 0);
stack->item = full_info;
break;
default:
CCerror(context, "Internal error
} /* switch type */
stack_size++;
} /* outer for loop */
if (opcode == JVM_OPC_invokeinit) {
/* If there are any instances of "from" on the stack, we need to
* replace it with "to", since calling <init> initializes all versions
* of the object, obviously. */
fullinfo_type from = context->swap_table[0];
stack_item_type *ptr;
for (ptr = stack; ptr != NULL; ptr = ptr->next) {
if (ptr->item == from) {
fullinfo_type to = context->swap_table[1];
stack = copy_stack(context, stack);
for (ptr = stack; ptr != NULL; ptr = ptr->next)
if (ptr->item == from) ptr->item = to;
break;
}
}
}
new_stack_info->stack_size = stack_size;
new_stack_info->stack = stack;
}
/* We've performed an instruction, and determined the new registers and stack
* value. Look at all of the possibly subsequent instructions, and merge
* this stack value into theirs.
*/
static void
<API key>(context_type *context, unsigned int inumber,
register_info_type *register_info,
stack_info_type *stack_info,
flag_type and_flags, flag_type or_flags)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[inumber];
int opcode = this_idata->opcode;
int operand = this_idata->operand.i;
struct handler_info_type *handler_info = context->handler_info;
int handler_info_length =
<API key>(context->env,
context->class,
context->method_index);
int buffer[2]; /* default value for successors */
int *successors = buffer; /* table of successors */
int successors_count;
int i;
switch (opcode) {
default:
successors_count = 1;
buffer[0] = inumber + 1;
break;
case JVM_OPC_ifeq: case JVM_OPC_ifne: case JVM_OPC_ifgt:
case JVM_OPC_ifge: case JVM_OPC_iflt: case JVM_OPC_ifle:
case JVM_OPC_ifnull: case JVM_OPC_ifnonnull:
case JVM_OPC_if_icmpeq: case JVM_OPC_if_icmpne: case JVM_OPC_if_icmpgt:
case JVM_OPC_if_icmpge: case JVM_OPC_if_icmplt: case JVM_OPC_if_icmple:
case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
successors_count = 2;
buffer[0] = inumber + 1;
buffer[1] = operand;
break;
case JVM_OPC_jsr: case JVM_OPC_jsr_w:
if (this_idata->operand2.i != <API key>)
idata[this_idata->operand2.i].changed = JNI_TRUE;
/* FALLTHROUGH */
case JVM_OPC_goto: case JVM_OPC_goto_w:
successors_count = 1;
buffer[0] = operand;
break;
case JVM_OPC_ireturn: case JVM_OPC_lreturn: case JVM_OPC_return:
case JVM_OPC_freturn: case JVM_OPC_dreturn: case JVM_OPC_areturn:
case JVM_OPC_athrow:
/* The testing for the returns is handled in pop_stack() */
successors_count = 0;
break;
case JVM_OPC_ret: {
/* This is slightly slow, but good enough for a seldom used instruction.
* The EXTRA_ITEM_INFO of the ITEM_ReturnAddress indicates the
* address of the first instruction of the subroutine. We can return
* to 1 after any instruction that jsr's to that instruction.
*/
if (this_idata->operand2.ip == NULL) {
fullinfo_type *registers = this_idata->register_info.registers;
int called_instruction = GET_EXTRA_INFO(registers[operand]);
int i, count, *ptr;;
for (i = context->instruction_count, count = 0; --i >= 0; ) {
if (((idata[i].opcode == JVM_OPC_jsr) ||
(idata[i].opcode == JVM_OPC_jsr_w)) &&
(idata[i].operand.i == called_instruction))
count++;
}
this_idata->operand2.ip = ptr = NEW(int, count + 1);
*ptr++ = count;
for (i = context->instruction_count, count = 0; --i >= 0; ) {
if (((idata[i].opcode == JVM_OPC_jsr) ||
(idata[i].opcode == JVM_OPC_jsr_w)) &&
(idata[i].operand.i == called_instruction))
*ptr++ = i + 1;
}
}
successors = this_idata->operand2.ip; /* use this instead */
successors_count = *successors++;
break;
}
case JVM_OPC_tableswitch:
case <API key>:
successors = this_idata->operand.ip; /* use this instead */
successors_count = *successors++;
break;
}
#ifdef DEBUG
if (verify_verbose) {
jio_fprintf(stdout, " [");
for (i = handler_info_length; --i >= 0; handler_info++)
if (handler_info->start <= (int)inumber && handler_info->end > (int)inumber)
jio_fprintf(stdout, "%d* ", handler_info->handler);
for (i = 0; i < successors_count; i++)
jio_fprintf(stdout, "%d ", successors[i]);
jio_fprintf(stdout, "]\n");
}
#endif
handler_info = context->handler_info;
for (i = handler_info_length; --i >= 0; handler_info++) {
if (handler_info->start <= (int)inumber && handler_info->end > (int)inumber) {
int handler = handler_info->handler;
if (opcode != JVM_OPC_invokeinit) {
<API key>(context, inumber, handler,
&this_idata->register_info, /* old */
&handler_info->stack_info,
(flag_type) (and_flags
& this_idata->and_flags),
(flag_type) (or_flags
| this_idata->or_flags),
JNI_TRUE);
} else {
/* We need to be a little bit more careful with this
* instruction. Things could either be in the state before
* the instruction or in the state afterwards */
fullinfo_type from = context->swap_table[0];
flag_type temp_or_flags = or_flags;
if (from == MAKE_FULLINFO(ITEM_InitObject, 0, 0))
temp_or_flags |= FLAG_NO_RETURN;
<API key>(context, inumber, handler,
&this_idata->register_info, /* old */
&handler_info->stack_info,
this_idata->and_flags,
this_idata->or_flags,
JNI_TRUE);
<API key>(context, inumber, handler,
register_info,
&handler_info->stack_info,
and_flags, temp_or_flags, JNI_TRUE);
}
}
}
for (i = 0; i < successors_count; i++) {
int target = successors[i];
if (target >= context->instruction_count)
CCerror(context, "Falling off the end of the code");
<API key>(context, inumber, target,
register_info, stack_info, and_flags, or_flags,
JNI_FALSE);
}
}
/* We have a new set of registers and stack values for a given instruction.
* Merge this new set into the values that are already there.
*/
static void
<API key>(context_type *context,
unsigned int from_inumber, unsigned int to_inumber,
register_info_type *new_register_info,
stack_info_type *new_stack_info,
flag_type new_and_flags, flag_type new_or_flags,
jboolean isException)
{
<API key> *idata = context->instruction_data;
register_info_type register_info_buf;
stack_info_type stack_info_buf;
#ifdef DEBUG
<API key> *this_idata = &idata[to_inumber];
register_info_type old_reg_info;
stack_info_type old_stack_info;
flag_type old_and_flags = 0;
flag_type old_or_flags = 0;
#endif
#ifdef DEBUG
if (verify_verbose) {
old_reg_info = this_idata->register_info;
old_stack_info = this_idata->stack_info;
old_and_flags = this_idata->and_flags;
old_or_flags = this_idata->or_flags;
}
#endif
/* All uninitialized objects are set to "bogus" when jsr and
* ret are executed. Thus uninitialized objects can't propagate
* into or out of a subroutine.
*/
if (idata[from_inumber].opcode == JVM_OPC_ret ||
idata[from_inumber].opcode == JVM_OPC_jsr ||
idata[from_inumber].opcode == JVM_OPC_jsr_w) {
int new_register_count = new_register_info->register_count;
fullinfo_type *new_registers = new_register_info->registers;
int i;
stack_item_type *item;
for (item = new_stack_info->stack; item != NULL; item = item->next) {
if (GET_ITEM_TYPE(item->item) == ITEM_NewObject) {
/* This check only succeeds for hand-contrived code.
* Efficiency is not an issue.
*/
stack_info_buf.stack = copy_stack(context,
new_stack_info->stack);
stack_info_buf.stack_size = new_stack_info->stack_size;
new_stack_info = &stack_info_buf;
for (item = new_stack_info->stack; item != NULL;
item = item->next) {
if (GET_ITEM_TYPE(item->item) == ITEM_NewObject) {
item->item = MAKE_FULLINFO(ITEM_Bogus, 0, 0);
}
}
break;
}
}
for (i = 0; i < new_register_count; i++) {
if (GET_ITEM_TYPE(new_registers[i]) == ITEM_NewObject) {
/* This check only succeeds for hand-contrived code.
* Efficiency is not an issue.
*/
fullinfo_type *new_set = NEW(fullinfo_type,
new_register_count);
for (i = 0; i < new_register_count; i++) {
fullinfo_type t = new_registers[i];
new_set[i] = GET_ITEM_TYPE(t) != ITEM_NewObject ?
t : MAKE_FULLINFO(ITEM_Bogus, 0, 0);
}
register_info_buf.register_count = new_register_count;
register_info_buf.registers = new_set;
register_info_buf.mask_count = new_register_info->mask_count;
register_info_buf.masks = new_register_info->masks;
new_register_info = ®ister_info_buf;
break;
}
}
}
/* Returning from a subroutine is somewhat ugly. The actual thing
* that needs to get merged into the new instruction is a joining
* of info from the ret instruction with stuff in the jsr instruction
*/
if (idata[from_inumber].opcode == JVM_OPC_ret && !isException) {
int new_register_count = new_register_info->register_count;
fullinfo_type *new_registers = new_register_info->registers;
int new_mask_count = new_register_info->mask_count;
mask_type *new_masks = new_register_info->masks;
int operand = idata[from_inumber].operand.i;
int called_instruction = GET_EXTRA_INFO(new_registers[operand]);
<API key> *jsr_idata = &idata[to_inumber - 1];
register_info_type *jsr_reginfo = &jsr_idata->register_info;
if (jsr_idata->operand2.i != (int)from_inumber) {
if (jsr_idata->operand2.i != <API key>)
CCerror(context, "Multiple returns to single jsr");
jsr_idata->operand2.i = from_inumber;
}
if (jsr_reginfo->register_count == <API key>) {
/* We don't want to handle the returned-to instruction until
* we've dealt with the jsr instruction. When we get to the
* jsr instruction (if ever), we'll re-mark the ret instruction
*/
;
} else {
int register_count = jsr_reginfo->register_count;
fullinfo_type *registers = jsr_reginfo->registers;
int max_registers = MAX(register_count, new_register_count);
fullinfo_type *new_set = NEW(fullinfo_type, max_registers);
int *return_mask;
struct register_info_type <API key>;
int i;
for (i = new_mask_count; --i >= 0; )
if (new_masks[i].entry == called_instruction)
break;
if (i < 0)
CCerror(context, "Illegal return from subroutine");
/* pop the masks down to the indicated one. Remember the mask
* we're popping off. */
return_mask = new_masks[i].modifies;
new_mask_count = i;
for (i = 0; i < max_registers; i++) {
if (IS_BIT_SET(return_mask, i))
new_set[i] = i < new_register_count ?
new_registers[i] : MAKE_FULLINFO(ITEM_Bogus, 0, 0);
else
new_set[i] = i < register_count ?
registers[i] : MAKE_FULLINFO(ITEM_Bogus, 0, 0);
}
<API key>.register_count = max_registers;
<API key>.registers = new_set;
<API key>.mask_count = new_mask_count;
<API key>.masks = new_masks;
merge_stack(context, from_inumber, to_inumber, new_stack_info);
merge_registers(context, to_inumber - 1, to_inumber,
&<API key>);
merge_flags(context, from_inumber, to_inumber, new_and_flags, new_or_flags);
}
} else {
merge_stack(context, from_inumber, to_inumber, new_stack_info);
merge_registers(context, from_inumber, to_inumber, new_register_info);
merge_flags(context, from_inumber, to_inumber,
new_and_flags, new_or_flags);
}
#ifdef DEBUG
if (verify_verbose && idata[to_inumber].changed) {
register_info_type *register_info = &this_idata->register_info;
stack_info_type *stack_info = &this_idata->stack_info;
if (memcmp(&old_reg_info, register_info, sizeof(old_reg_info)) ||
memcmp(&old_stack_info, stack_info, sizeof(old_stack_info)) ||
(old_and_flags != this_idata->and_flags) ||
(old_or_flags != this_idata->or_flags)) {
jio_fprintf(stdout, " %2d:", to_inumber);
print_stack(context, &old_stack_info);
print_registers(context, &old_reg_info);
print_flags(context, old_and_flags, old_or_flags);
jio_fprintf(stdout, " => ");
print_stack(context, &this_idata->stack_info);
print_registers(context, &this_idata->register_info);
print_flags(context, this_idata->and_flags, this_idata->or_flags);
jio_fprintf(stdout, "\n");
}
}
#endif
}
static void
merge_stack(context_type *context, unsigned int from_inumber,
unsigned int to_inumber, stack_info_type *new_stack_info)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[to_inumber];
int new_stack_size = new_stack_info->stack_size;
stack_item_type *new_stack = new_stack_info->stack;
int stack_size = this_idata->stack_info.stack_size;
if (stack_size == UNKNOWN_STACK_SIZE) {
/* First time at this instruction. Just copy. */
this_idata->stack_info.stack_size = new_stack_size;
this_idata->stack_info.stack = new_stack;
this_idata->changed = JNI_TRUE;
} else if (new_stack_size != stack_size) {
CCerror(context, "Inconsistent stack height %d != %d",
new_stack_size, stack_size);
} else {
stack_item_type *stack = this_idata->stack_info.stack;
stack_item_type *old, *new;
jboolean change = JNI_FALSE;
for (old = stack, new = new_stack; old != NULL;
old = old->next, new = new->next) {
if (!isAssignableTo(context, new->item, old->item)) {
change = JNI_TRUE;
break;
}
}
if (change) {
stack = copy_stack(context, stack);
for (old = stack, new = new_stack; old != NULL;
old = old->next, new = new->next) {
if (new == NULL) {
break;
}
old->item = <API key>(context, old->item, new->item,
JNI_FALSE);
if (GET_ITEM_TYPE(old->item) == ITEM_Bogus) {
CCerror(context, "Mismatched stack types");
}
}
if (old != NULL || new != NULL) {
CCerror(context, "Mismatched stack types");
}
this_idata->stack_info.stack = stack;
this_idata->changed = JNI_TRUE;
}
}
}
static void
merge_registers(context_type *context, unsigned int from_inumber,
unsigned int to_inumber, register_info_type *new_register_info)
{
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[to_inumber];
register_info_type *this_reginfo = &this_idata->register_info;
int new_register_count = new_register_info->register_count;
fullinfo_type *new_registers = new_register_info->registers;
int new_mask_count = new_register_info->mask_count;
mask_type *new_masks = new_register_info->masks;
if (this_reginfo->register_count == <API key>) {
this_reginfo->register_count = new_register_count;
this_reginfo->registers = new_registers;
this_reginfo->mask_count = new_mask_count;
this_reginfo->masks = new_masks;
this_idata->changed = JNI_TRUE;
} else {
/* See if we've got new information on the register set. */
int register_count = this_reginfo->register_count;
fullinfo_type *registers = this_reginfo->registers;
int mask_count = this_reginfo->mask_count;
mask_type *masks = this_reginfo->masks;
jboolean copy = JNI_FALSE;
int i, j;
if (register_count > new_register_count) {
/* Any register larger than new_register_count is now bogus */
this_reginfo->register_count = new_register_count;
register_count = new_register_count;
this_idata->changed = JNI_TRUE;
}
for (i = 0; i < register_count; i++) {
fullinfo_type prev_value = registers[i];
if ((i < new_register_count)
? (!isAssignableTo(context, new_registers[i], prev_value))
: (prev_value != MAKE_FULLINFO(ITEM_Bogus, 0, 0))) {
copy = JNI_TRUE;
break;
}
}
if (copy) {
/* We need a copy. So do it. */
fullinfo_type *new_set = NEW(fullinfo_type, register_count);
for (j = 0; j < i; j++)
new_set[j] = registers[j];
for (j = i; j < register_count; j++) {
if (i >= new_register_count)
new_set[j] = MAKE_FULLINFO(ITEM_Bogus, 0, 0);
else
new_set[j] = <API key>(context,
new_registers[j],
registers[j], JNI_FALSE);
}
/* Some of the end items might now be bogus. This step isn't
* necessary, but it may save work later. */
while ( register_count > 0
&& GET_ITEM_TYPE(new_set[register_count-1]) == ITEM_Bogus)
register_count
this_reginfo->register_count = register_count;
this_reginfo->registers = new_set;
this_idata->changed = JNI_TRUE;
}
if (mask_count > 0) {
/* If the target instruction already has a sequence of masks, then
* we need to merge new_masks into it. We want the entries on
* the mask to be the longest common substring of the two.
* (e.g. a->b->d merged with a->c->d should give a->d)
* The bits set in the mask should be the or of the corresponding
* entries in each of the original masks.
*/
int i, j, k;
int matches = 0;
int last_match = -1;
jboolean copy_needed = JNI_FALSE;
for (i = 0; i < mask_count; i++) {
int entry = masks[i].entry;
for (j = last_match + 1; j < new_mask_count; j++) {
if (new_masks[j].entry == entry) {
/* We have a match */
int *prev = masks[i].modifies;
int *new = new_masks[j].modifies;
matches++;
/* See if new_mask has bits set for "entry" that
* weren't set for mask. If so, need to copy. */
for (k = context->bitmask_size - 1;
!copy_needed && k >= 0;
k
if (~prev[k] & new[k])
copy_needed = JNI_TRUE;
last_match = j;
break;
}
}
}
if ((matches < mask_count) || copy_needed) {
/* We need to make a copy for the new item, since either the
* size has decreased, or new bits are set. */
mask_type *copy = NEW(mask_type, matches);
for (i = 0; i < matches; i++) {
copy[i].modifies = NEW(int, context->bitmask_size);
}
this_reginfo->masks = copy;
this_reginfo->mask_count = matches;
this_idata->changed = JNI_TRUE;
matches = 0;
last_match = -1;
for (i = 0; i < mask_count; i++) {
int entry = masks[i].entry;
for (j = last_match + 1; j < new_mask_count; j++) {
if (new_masks[j].entry == entry) {
int *prev1 = masks[i].modifies;
int *prev2 = new_masks[j].modifies;
int *new = copy[matches].modifies;
copy[matches].entry = entry;
for (k = context->bitmask_size - 1; k >= 0; k
new[k] = prev1[k] | prev2[k];
matches++;
last_match = j;
break;
}
}
}
}
}
}
}
static void
merge_flags(context_type *context, unsigned int from_inumber,
unsigned int to_inumber,
flag_type new_and_flags, flag_type new_or_flags)
{
/* Set this_idata->and_flags &= new_and_flags
this_idata->or_flags |= new_or_flags
*/
<API key> *idata = context->instruction_data;
<API key> *this_idata = &idata[to_inumber];
flag_type this_and_flags = this_idata->and_flags;
flag_type this_or_flags = this_idata->or_flags;
flag_type merged_and = this_and_flags & new_and_flags;
flag_type merged_or = this_or_flags | new_or_flags;
if ((merged_and != this_and_flags) || (merged_or != this_or_flags)) {
this_idata->and_flags = merged_and;
this_idata->or_flags = merged_or;
this_idata->changed = JNI_TRUE;
}
}
/* Make a copy of a stack */
static stack_item_type *
copy_stack(context_type *context, stack_item_type *stack)
{
int length;
stack_item_type *ptr;
/* Find the length */
for (ptr = stack, length = 0; ptr != NULL; ptr = ptr->next, length++);
if (length > 0) {
stack_item_type *new_stack = NEW(stack_item_type, length);
stack_item_type *new_ptr;
for ( ptr = stack, new_ptr = new_stack;
ptr != NULL;
ptr = ptr->next, new_ptr++) {
new_ptr->item = ptr->item;
new_ptr->next = new_ptr + 1;
}
new_stack[length - 1].next = NULL;
return new_stack;
} else {
return NULL;
}
}
static mask_type *
copy_masks(context_type *context, mask_type *masks, int mask_count)
{
mask_type *result = NEW(mask_type, mask_count);
int bitmask_size = context->bitmask_size;
int *bitmaps = NEW(int, mask_count * bitmask_size);
int i;
for (i = 0; i < mask_count; i++) {
result[i].entry = masks[i].entry;
result[i].modifies = &bitmaps[i * bitmask_size];
memcpy(result[i].modifies, masks[i].modifies, bitmask_size * sizeof(int));
}
return result;
}
static mask_type *
add_to_masks(context_type *context, mask_type *masks, int mask_count, int d)
{
mask_type *result = NEW(mask_type, mask_count + 1);
int bitmask_size = context->bitmask_size;
int *bitmaps = NEW(int, (mask_count + 1) * bitmask_size);
int i;
for (i = 0; i < mask_count; i++) {
result[i].entry = masks[i].entry;
result[i].modifies = &bitmaps[i * bitmask_size];
memcpy(result[i].modifies, masks[i].modifies, bitmask_size * sizeof(int));
}
result[mask_count].entry = d;
result[mask_count].modifies = &bitmaps[mask_count * bitmask_size];
memset(result[mask_count].modifies, 0, bitmask_size * sizeof(int));
return result;
}
/* We create our own storage manager, since we malloc lots of little items,
* and I don't want to keep trace of when they become free. I sure wish that
* we had heaps, and I could just free the heap when done.
*/
#define CCSegSize 2000
struct CCpool { /* a segment of allocated memory in the pool */
struct CCpool *next;
int segSize; /* almost always CCSegSize */
int poolPad;
char space[CCSegSize];
};
/* Initialize the context's heap. */
static void CCinit(context_type *context)
{
struct CCpool *new = (struct CCpool *) malloc(sizeof(struct CCpool));
/* Set context->CCroot to 0 if new == 0 to tell CCdestroy to lay off */
context->CCroot = context->CCcurrent = new;
if (new == 0) {
CCout_of_memory(context);
}
new->next = NULL;
new->segSize = CCSegSize;
context->CCfree_size = CCSegSize;
context->CCfree_ptr = &new->space[0];
}
/* Reuse all the space that we have in the context's heap. */
static void CCreinit(context_type *context)
{
struct CCpool *first = context->CCroot;
context->CCcurrent = first;
context->CCfree_size = CCSegSize;
context->CCfree_ptr = &first->space[0];
}
/* Destroy the context's heap. */
static void CCdestroy(context_type *context)
{
struct CCpool *this = context->CCroot;
while (this) {
struct CCpool *next = this->next;
free(this);
this = next;
}
/* These two aren't necessary. But can't hurt either */
context->CCroot = context->CCcurrent = NULL;
context->CCfree_ptr = 0;
}
/* Allocate an object of the given size from the context's heap. */
static void *
CCalloc(context_type *context, int size, jboolean zero)
{
register char *p;
/* Round CC to the size of a pointer */
size = (size + (sizeof(void *) - 1)) & ~(sizeof(void *) - 1);
if (context->CCfree_size < size) {
struct CCpool *current = context->CCcurrent;
struct CCpool *new;
if (size > CCSegSize) { /* we need to allocate a special block */
new = (struct CCpool *)malloc(sizeof(struct CCpool) +
(size - CCSegSize));
if (new == 0) {
CCout_of_memory(context);
}
new->next = current->next;
new->segSize = size;
current->next = new;
} else {
new = current->next;
if (new == NULL) {
new = (struct CCpool *) malloc(sizeof(struct CCpool));
if (new == 0) {
CCout_of_memory(context);
}
current->next = new;
new->next = NULL;
new->segSize = CCSegSize;
}
}
context->CCcurrent = new;
context->CCfree_ptr = &new->space[0];
context->CCfree_size = new->segSize;
}
p = context->CCfree_ptr;
context->CCfree_ptr += size;
context->CCfree_size -= size;
if (zero)
memset(p, 0, size);
return p;
}
/* Get the class associated with a particular field or method or class in the
* constant pool. If is_field is true, we've got a field or method. If
* false, we've got a class.
*/
static fullinfo_type
<API key>(context_type *context, int cp_index, int kind)
{
JNIEnv *env = context->env;
fullinfo_type result;
const char *classname;
switch (kind) {
case JVM_CONSTANT_Class:
classname = <API key>(env,
context->class,
cp_index);
break;
case <API key>:
classname = <API key>(env,
context->class,
cp_index);
break;
case <API key>:
classname = <API key>(env,
context->class,
cp_index);
break;
default:
classname = NULL;
CCerror(context, "Internal error
}
check_and_push(context, classname, VM_STRING_UTF);
if (classname[0] == JVM_SIGNATURE_ARRAY) {
/* This make recursively call us, in case of a class array */
<API key>(context, &classname, &result);
} else {
result = <API key>(context, classname);
}
pop_and_free(context);
return result;
}
static int
print_CCerror_info(context_type *context)
{
JNIEnv *env = context->env;
jclass cb = context->class;
const char *classname = JVM_GetClassNameUTF(env, cb);
const char *name = 0;
const char *signature = 0;
int n = 0;
if (context->method_index != -1) {
name = <API key>(env, cb, context->method_index);
signature =
<API key>(env, cb, context->method_index);
n += jio_snprintf(context->message, context->message_buf_len,
"(class: %s, method: %s signature: %s) ",
(classname ? classname : ""),
(name ? name : ""),
(signature ? signature : ""));
} else if (context->field_index != -1 ) {
name = <API key>(env, cb, context->field_index);
n += jio_snprintf(context->message, context->message_buf_len,
"(class: %s, field: %s) ",
(classname ? classname : 0),
(name ? name : 0));
} else {
n += jio_snprintf(context->message, context->message_buf_len,
"(class: %s) ", classname ? classname : "");
}
JVM_ReleaseUTF(classname);
JVM_ReleaseUTF(name);
JVM_ReleaseUTF(signature);
return n;
}
static void
CCerror (context_type *context, char *format, ...)
{
int n = print_CCerror_info(context);
va_list args;
if (n >= 0 && n < context->message_buf_len) {
va_start(args, format);
jio_vsnprintf(context->message + n, context->message_buf_len - n,
format, args);
va_end(args);
}
context->err_code = CC_VerifyError;
longjmp(context->jump_buffer, 1);
}
static void
CCout_of_memory(context_type *context)
{
int n = print_CCerror_info(context);
context->err_code = CC_OutOfMemory;
longjmp(context->jump_buffer, 1);
}
static void
CFerror(context_type *context, char *format, ...)
{
int n = print_CCerror_info(context);
va_list args;
if (n >= 0 && n < context->message_buf_len) {
va_start(args, format);
jio_vsnprintf(context->message + n, context->message_buf_len - n,
format, args);
va_end(args);
}
context->err_code = CC_ClassFormatError;
longjmp(context->jump_buffer, 1);
}
/*
* Need to scan the entire signature to find the result type because
* types in the arg list and the result type could contain embedded ')'s.
*/
static const char* <API key>(const char* signature) {
const char *p;
for (p = signature; *p != <API key>; p++) {
switch (*p) {
case <API key>:
case JVM_SIGNATURE_BYTE:
case JVM_SIGNATURE_CHAR:
case JVM_SIGNATURE_SHORT:
case JVM_SIGNATURE_INT:
case JVM_SIGNATURE_FLOAT:
case <API key>:
case JVM_SIGNATURE_LONG:
case JVM_SIGNATURE_FUNC: /* ignore initial (, if given */
break;
case JVM_SIGNATURE_CLASS:
while (*p != <API key>) p++;
break;
case JVM_SIGNATURE_ARRAY:
while (*p == JVM_SIGNATURE_ARRAY) p++;
/* If an array of classes, skip over class name, too. */
if (*p == JVM_SIGNATURE_CLASS) {
while (*p != <API key>) p++;
}
break;
default:
/* Indicate an error. */
return NULL;
}
}
return p++; /* skip over ')'. */
}
static char
<API key>(context_type *context,
const char **signature_p, fullinfo_type *full_info_p)
{
const char *p = *signature_p;
fullinfo_type full_info = MAKE_FULLINFO(ITEM_Bogus, 0, 0);
char result;
int array_depth = 0;
for (;;) {
switch(*p++) {
default:
result = 0;
break;
case <API key>:
full_info = (array_depth > 0)
? MAKE_FULLINFO(ITEM_Boolean, 0, 0)
: MAKE_FULLINFO(ITEM_Integer, 0, 0);
result = 'I';
break;
case JVM_SIGNATURE_BYTE:
full_info = (array_depth > 0)
? MAKE_FULLINFO(ITEM_Byte, 0, 0)
: MAKE_FULLINFO(ITEM_Integer, 0, 0);
result = 'I';
break;
case JVM_SIGNATURE_CHAR:
full_info = (array_depth > 0)
? MAKE_FULLINFO(ITEM_Char, 0, 0)
: MAKE_FULLINFO(ITEM_Integer, 0, 0);
result = 'I';
break;
case JVM_SIGNATURE_SHORT:
full_info = (array_depth > 0)
? MAKE_FULLINFO(ITEM_Short, 0, 0)
: MAKE_FULLINFO(ITEM_Integer, 0, 0);
result = 'I';
break;
case JVM_SIGNATURE_INT:
full_info = MAKE_FULLINFO(ITEM_Integer, 0, 0);
result = 'I';
break;
case JVM_SIGNATURE_FLOAT:
full_info = MAKE_FULLINFO(ITEM_Float, 0, 0);
result = 'F';
break;
case <API key>:
full_info = MAKE_FULLINFO(ITEM_Double, 0, 0);
result = 'D';
break;
case JVM_SIGNATURE_LONG:
full_info = MAKE_FULLINFO(ITEM_Long, 0, 0);
result = 'L';
break;
case JVM_SIGNATURE_ARRAY:
array_depth++;
continue; /* only time we ever do the loop > 1 */
case JVM_SIGNATURE_CLASS: {
char buffer_space[256];
char *buffer = buffer_space;
char *finish = strchr(p, <API key>);
int length;
if (finish == NULL) {
/* Signature must have ';' after the class name.
* If it does not, return 0 and ITEM_Bogus in full_info. */
result = 0;
break;
}
length = finish - p;
if (length + 1 > (int)sizeof(buffer_space)) {
buffer = malloc(length + 1);
check_and_push(context, buffer, VM_MALLOC_BLK);
}
memcpy(buffer, p, length);
buffer[length] = '\0';
full_info = <API key>(context, buffer);
result = 'A';
p = finish + 1;
if (buffer != buffer_space)
pop_and_free(context);
break;
}
} /* end of switch */
break;
}
*signature_p = p;
if (array_depth == 0 || result == 0) {
/* either not an array, or result is bogus */
*full_info_p = full_info;
return result;
} else {
if (array_depth > <API key>)
CCerror(context, "Array with too many dimensions");
*full_info_p = MAKE_FULLINFO(GET_ITEM_TYPE(full_info),
array_depth,
GET_EXTRA_INFO(full_info));
return 'A';
}
}
/* Given an array type, create the type that has one less level of
* indirection.
*/
static fullinfo_type
<API key>(fullinfo_type array_info)
{
if (array_info == NULL_FULLINFO) {
return NULL_FULLINFO;
} else {
int type = GET_ITEM_TYPE(array_info);
int indirection = GET_INDIRECTION(array_info) - 1;
int extra_info = GET_EXTRA_INFO(array_info);
if ( (indirection == 0)
&& ((type == ITEM_Short || type == ITEM_Byte || type == ITEM_Boolean || type == ITEM_Char)))
type = ITEM_Integer;
return MAKE_FULLINFO(type, indirection, extra_info);
}
}
/* See if we can assign an object of the "from" type to an object
* of the "to" type.
*/
static jboolean isAssignableTo(context_type *context,
fullinfo_type from, fullinfo_type to)
{
return (<API key>(context, from, to, JNI_TRUE) == to);
}
/* Given two fullinfo_type's, find their lowest common denominator. If
* the assignable_p argument is non-null, we're really just calling to find
* out if "<target> := <value>" is a legitimate assignment.
*
* We treat all interfaces as if they were of type java/lang/Object, since the
* runtime will do the full checking.
*/
static fullinfo_type
<API key>(context_type *context,
fullinfo_type value, fullinfo_type target,
jboolean for_assignment)
{
JNIEnv *env = context->env;
if (value == target) {
/* If they're identical, clearly just return what we've got */
return value;
}
/* Both must be either arrays or objects to go further */
if (GET_INDIRECTION(value) == 0 && GET_ITEM_TYPE(value) != ITEM_Object)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
if (GET_INDIRECTION(target) == 0 && GET_ITEM_TYPE(target) != ITEM_Object)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
/* If either is NULL, return the other. */
if (value == NULL_FULLINFO)
return target;
else if (target == NULL_FULLINFO)
return value;
/* If either is java/lang/Object, that's the result. */
if (target == context->object_info)
return target;
else if (value == context->object_info) {
/* Minor hack. For assignments, Interface := Object, return Interface
* rather than Object, so that isAssignableTo() will get the right
* result. */
if (for_assignment && (<API key>(target) ==
MAKE_FULLINFO(ITEM_Object, 0, 0))) {
jclass cb = <API key>(context,
target);
int is_interface = cb && JVM_IsInterface(env, cb);
if (is_interface)
return target;
}
return value;
}
if (GET_INDIRECTION(value) > 0 || GET_INDIRECTION(target) > 0) {
/* At least one is an array. Neither is java/lang/Object or NULL.
* Moreover, the types are not identical.
* The result must either be Object, or an array of some object type.
*/
fullinfo_type value_base, target_base;
int dimen_value = GET_INDIRECTION(value);
int dimen_target = GET_INDIRECTION(target);
if (target == context->cloneable_info ||
target == context->serializable_info) {
return target;
}
if (value == context->cloneable_info ||
value == context->serializable_info) {
return value;
}
/* First, if either item's base type isn't ITEM_Object, promote it up
* to an object or array of object. If either is elemental, we can
* punt.
*/
if (GET_ITEM_TYPE(value) != ITEM_Object) {
if (dimen_value == 0)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
dimen_value
value = MAKE_Object_ARRAY(dimen_value);
}
if (GET_ITEM_TYPE(target) != ITEM_Object) {
if (dimen_target == 0)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
dimen_target
target = MAKE_Object_ARRAY(dimen_target);
}
/* Both are now objects or arrays of some sort of object type */
value_base = <API key>(value);
target_base = <API key>(target);
if (dimen_value == dimen_target) {
/* Arrays of the same dimension. Merge their base types. */
fullinfo_type result_base =
<API key>(context, value_base, target_base,
for_assignment);
if (result_base == MAKE_FULLINFO(ITEM_Bogus, 0, 0))
/* bogus in, bogus out */
return result_base;
return MAKE_FULLINFO(ITEM_Object, dimen_value,
GET_EXTRA_INFO(result_base));
} else {
/* Arrays of different sizes. If the smaller dimension array's base
* type is java/lang/Cloneable or java/io/Serializable, return it.
* Otherwise return java/lang/Object with a dimension of the smaller
* of the two */
if (dimen_value < dimen_target) {
if (value_base == context->cloneable_info ||
value_base == context ->serializable_info) {
return value;
}
return MAKE_Object_ARRAY(dimen_value);
} else {
if (target_base == context->cloneable_info ||
target_base == context->serializable_info) {
return target;
}
return MAKE_Object_ARRAY(dimen_target);
}
}
} else {
/* Both are non-array objects. Neither is java/lang/Object or NULL */
jclass cb_value, cb_target, cb_super_value, cb_super_target;
fullinfo_type result_info;
/* Let's get the classes corresponding to each of these. Treat
* interfaces as if they were java/lang/Object. See hack note above. */
cb_target = <API key>(context, target);
if (cb_target == 0)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
if (JVM_IsInterface(env, cb_target))
return for_assignment ? target : context->object_info;
cb_value = <API key>(context, value);
if (cb_value == 0)
return MAKE_FULLINFO(ITEM_Bogus, 0, 0);
if (JVM_IsInterface(env, cb_value))
return context->object_info;
/* If this is for assignment of target := value, we just need to see if
* cb_target is a superclass of cb_value. Save ourselves a lot of
* work.
*/
if (for_assignment) {
cb_super_value = (*env)->GetSuperclass(env, cb_value);
while (cb_super_value != 0) {
jclass tmp_cb;
if ((*env)->IsSameObject(env, cb_super_value, cb_target)) {
(*env)->DeleteLocalRef(env, cb_super_value);
return target;
}
tmp_cb = (*env)->GetSuperclass(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_super_value);
cb_super_value = tmp_cb;
}
(*env)->DeleteLocalRef(env, cb_super_value);
return context->object_info;
}
/* Find out whether cb_value or cb_target is deeper in the class
* tree by moving both toward the root, and seeing who gets there
* first. */
cb_super_value = (*env)->GetSuperclass(env, cb_value);
cb_super_target = (*env)->GetSuperclass(env, cb_target);
while((cb_super_value != 0) &&
(cb_super_target != 0)) {
jclass tmp_cb;
/* Optimization. If either hits the other when going up looking
* for a parent, then might as well return the parent immediately */
if ((*env)->IsSameObject(env, cb_super_value, cb_target)) {
(*env)->DeleteLocalRef(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_super_target);
return target;
}
if ((*env)->IsSameObject(env, cb_super_target, cb_value)) {
(*env)->DeleteLocalRef(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_super_target);
return value;
}
tmp_cb = (*env)->GetSuperclass(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_super_value);
cb_super_value = tmp_cb;
tmp_cb = (*env)->GetSuperclass(env, cb_super_target);
(*env)->DeleteLocalRef(env, cb_super_target);
cb_super_target = tmp_cb;
}
cb_value = (*env)->NewLocalRef(env, cb_value);
cb_target = (*env)->NewLocalRef(env, cb_target);
/* At most one of the following two while clauses will be executed.
* Bring the deeper of cb_target and cb_value to the depth of the
* shallower one.
*/
while (cb_super_value != 0) {
/* cb_value is deeper */
jclass cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_super_value);
cb_super_value = cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_value);
(*env)->DeleteLocalRef(env, cb_value);
cb_value = cb_tmp;
}
while (cb_super_target != 0) {
/* cb_target is deeper */
jclass cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_super_target);
(*env)->DeleteLocalRef(env, cb_super_target);
cb_super_target = cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_target);
(*env)->DeleteLocalRef(env, cb_target);
cb_target = cb_tmp;
}
/* Walk both up, maintaining equal depth, until a join is found. We
* know that we will find one. */
while (!(*env)->IsSameObject(env, cb_value, cb_target)) {
jclass cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_value);
(*env)->DeleteLocalRef(env, cb_value);
cb_value = cb_tmp;
cb_tmp = (*env)->GetSuperclass(env, cb_target);
(*env)->DeleteLocalRef(env, cb_target);
cb_target = cb_tmp;
}
result_info = make_class_info(context, cb_value);
(*env)->DeleteLocalRef(env, cb_value);
(*env)->DeleteLocalRef(env, cb_super_value);
(*env)->DeleteLocalRef(env, cb_target);
(*env)->DeleteLocalRef(env, cb_super_target);
return result_info;
} /* both items are classes */
}
/* Given a fullinfo_type corresponding to an Object, return the jclass
* of that type.
*
* This function always returns a global reference!
*/
static jclass
<API key>(context_type *context, fullinfo_type classinfo)
{
unsigned short info = GET_EXTRA_INFO(classinfo);
return ID_to_class(context, info);
}
static void free_block(void *ptr, int kind)
{
switch (kind) {
case VM_STRING_UTF:
JVM_ReleaseUTF(ptr);
break;
case VM_MALLOC_BLK:
free(ptr);
break;
}
}
static void check_and_push(context_type *context, const void *ptr, int kind)
{
alloc_stack_type *p;
if (ptr == 0)
CCout_of_memory(context);
if (context->alloc_stack_top < ALLOC_STACK_SIZE)
p = &(context->alloc_stack[context->alloc_stack_top++]);
else {
/* Otherwise we have to malloc */
p = malloc(sizeof(alloc_stack_type));
if (p == 0) {
/* Make sure we clean up. */
free_block((void *)ptr, kind);
CCout_of_memory(context);
}
}
p->kind = kind;
p->ptr = (void *)ptr;
p->next = context->allocated_memory;
context->allocated_memory = p;
}
static void pop_and_free(context_type *context)
{
alloc_stack_type *p = context->allocated_memory;
context->allocated_memory = p->next;
free_block(p->ptr, p->kind);
if (p < context->alloc_stack + ALLOC_STACK_SIZE &&
p >= context->alloc_stack)
context->alloc_stack_top
else
free(p);
}
static int <API key>(const char *method_signature)
{
const char *p;
int args_size = 0;
for (p = method_signature; *p != <API key>; p++) {
switch (*p) {
case <API key>:
case JVM_SIGNATURE_BYTE:
case JVM_SIGNATURE_CHAR:
case JVM_SIGNATURE_SHORT:
case JVM_SIGNATURE_INT:
case JVM_SIGNATURE_FLOAT:
args_size += 1;
break;
case JVM_SIGNATURE_CLASS:
args_size += 1;
while (*p != <API key>) p++;
break;
case JVM_SIGNATURE_ARRAY:
args_size += 1;
while ((*p == JVM_SIGNATURE_ARRAY)) p++;
/* If an array of classes, skip over class name, too. */
if (*p == JVM_SIGNATURE_CLASS) {
while (*p != <API key>)
p++;
}
break;
case <API key>:
case JVM_SIGNATURE_LONG:
args_size += 2;
break;
case JVM_SIGNATURE_FUNC: /* ignore initial (, if given */
break;
default:
/* Indicate an error. */
return 0;
}
}
return args_size;
}
#ifdef DEBUG
/* Below are for debugging. */
static void print_fullinfo_type(context_type *, fullinfo_type, jboolean);
static void
print_stack(context_type *context, stack_info_type *stack_info)
{
stack_item_type *stack = stack_info->stack;
if (stack_info->stack_size == UNKNOWN_STACK_SIZE) {
jio_fprintf(stdout, "x");
} else {
jio_fprintf(stdout, "(");
for ( ; stack != 0; stack = stack->next)
print_fullinfo_type(context, stack->item,
(jboolean)(verify_verbose > 1 ? JNI_TRUE : JNI_FALSE));
jio_fprintf(stdout, ")");
}
}
static void
print_registers(context_type *context, register_info_type *register_info)
{
int register_count = register_info->register_count;
if (register_count == <API key>) {
jio_fprintf(stdout, "x");
} else {
fullinfo_type *registers = register_info->registers;
int mask_count = register_info->mask_count;
mask_type *masks = register_info->masks;
int i, j;
jio_fprintf(stdout, "{");
for (i = 0; i < register_count; i++)
print_fullinfo_type(context, registers[i],
(jboolean)(verify_verbose > 1 ? JNI_TRUE : JNI_FALSE));
jio_fprintf(stdout, "}");
for (i = 0; i < mask_count; i++) {
char *separator = "";
int *modifies = masks[i].modifies;
jio_fprintf(stdout, "<%d: ", masks[i].entry);
for (j = 0;
j < <API key>(context->env,
context->class,
context->method_index);
j++)
if (IS_BIT_SET(modifies, j)) {
jio_fprintf(stdout, "%s%d", separator, j);
separator = ",";
}
jio_fprintf(stdout, ">");
}
}
}
static void
print_flags(context_type *context, flag_type and_flags, flag_type or_flags)
{
if (and_flags != ((flag_type)-1) || or_flags != 0) {
jio_fprintf(stdout, "<%x %x>", and_flags, or_flags);
}
}
static void
print_fullinfo_type(context_type *context, fullinfo_type type, jboolean verbose)
{
int i;
int indirection = GET_INDIRECTION(type);
for (i = indirection; i
jio_fprintf(stdout, "[");
switch (GET_ITEM_TYPE(type)) {
case ITEM_Integer:
jio_fprintf(stdout, "I"); break;
case ITEM_Float:
jio_fprintf(stdout, "F"); break;
case ITEM_Double:
jio_fprintf(stdout, "D"); break;
case ITEM_Double_2:
jio_fprintf(stdout, "d"); break;
case ITEM_Long:
jio_fprintf(stdout, "L"); break;
case ITEM_Long_2:
jio_fprintf(stdout, "l"); break;
case ITEM_ReturnAddress:
jio_fprintf(stdout, "a"); break;
case ITEM_Object:
if (!verbose) {
jio_fprintf(stdout, "A");
} else {
unsigned short extra = GET_EXTRA_INFO(type);
if (extra == 0) {
jio_fprintf(stdout, "/Null/");
} else {
const char *name = ID_to_class_name(context, extra);
const char *name2 = strrchr(name, '/');
jio_fprintf(stdout, "/%s/", name2 ? name2 + 1 : name);
}
}
break;
case ITEM_Char:
jio_fprintf(stdout, "C"); break;
case ITEM_Short:
jio_fprintf(stdout, "S"); break;
case ITEM_Boolean:
jio_fprintf(stdout, "Z"); break;
case ITEM_Byte:
jio_fprintf(stdout, "B"); break;
case ITEM_NewObject:
if (!verbose) {
jio_fprintf(stdout, "@");
} else {
int inum = GET_EXTRA_INFO(type);
fullinfo_type real_type =
context->instruction_data[inum].operand2.fi;
jio_fprintf(stdout, ">");
print_fullinfo_type(context, real_type, JNI_TRUE);
jio_fprintf(stdout, "<");
}
break;
case ITEM_InitObject:
jio_fprintf(stdout, verbose ? ">/this/<" : "@");
break;
default:
jio_fprintf(stdout, "?"); break;
}
for (i = indirection; i
jio_fprintf(stdout, "]");
}
static void
<API key>(context_type *context, int index)
{
JNIEnv *env = context->env;
jclass cb = context->class;
const char *classname = <API key>(env, cb, index);
const char *fieldname = <API key>(env, cb, index);
jio_fprintf(stdout, " <%s.%s>",
classname ? classname : "", fieldname ? fieldname : "");
JVM_ReleaseUTF(classname);
JVM_ReleaseUTF(fieldname);
}
static void
<API key>(context_type *context, int index)
{
JNIEnv *env = context->env;
jclass cb = context->class;
const char *classname = <API key>(env, cb, index);
const char *methodname = <API key>(env, cb, index);
jio_fprintf(stdout, " <%s.%s>",
classname ? classname : "", methodname ? methodname : "");
JVM_ReleaseUTF(classname);
JVM_ReleaseUTF(methodname);
}
#endif /*DEBUG*/ |
# linux/arch/arm/boot/compressed/Makefile
# create a compressed vmlinuz image from the original vmlinux
OBJS =
# Ensure that MMCIF loader code appears early in the image
# to minimise that number of bocks that have to be read in
# order to load it.
ifeq ($(<API key>),y)
OBJS += mmcif-sh7372.o
endif
# Ensure that SDHI loader code appears early in the image
# to minimise that number of bocks that have to be read in
# order to load it.
ifeq ($(<API key>),y)
OBJS += sdhi-shmobile.o
OBJS += sdhi-sh7372.o
endif
AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
# change@wtl.rsengott
# <API key> is start of kernel text in RAM
ifeq ($(CONFIG_CRYPTO_FIPS),y)
AFLAGS_head.o += -<API key>=0x00008000
endif
HEAD = head.o
OBJS += misc.o decompress.o
FONTC = $(srctree)/drivers/video/console/font_acorn_8x8.c
# string library code (-Os is enforced to keep it much smaller)
OBJS += string.o
CFLAGS_string.o := -Os
# Architecture dependencies
ifeq ($(CONFIG_ARCH_ACORN),y)
OBJS += ll_char_wr.o font.o
endif
ifeq ($(CONFIG_ARCH_SHARK),y)
OBJS += head-shark.o ofw-shark.o
endif
ifeq ($(CONFIG_ARCH_P720T),y)
# Borrow this code from SA1100
OBJS += head-sa1100.o
endif
ifeq ($(CONFIG_ARCH_SA1100),y)
OBJS += head-sa1100.o
endif
ifeq ($(CONFIG_ARCH_VT8500),y)
OBJS += head-vt8500.o
endif
ifeq ($(CONFIG_CPU_XSCALE),y)
OBJS += head-xscale.o
endif
ifeq ($(<API key>),y)
OBJS += head-sharpsl.o
endif
ifeq ($(<API key>),y)
ifeq ($(CONFIG_CPU_CP15),y)
OBJS += big-endian.o
else
# The endian should be set by h/w design.
endif
endif
ifeq ($(<API key>),y)
OBJS += head-shmobile.o
endif
# We now have a PIC decompressor implementation. Decompressors running
# from RAM should not define ZTEXTADDR. Decompressors running directly
# from ROM or Flash must define ZTEXTADDR (preferably via the config)
# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
ifeq ($(CONFIG_ZBOOT_ROM),y)
ZTEXTADDR := $(<API key>)
ZBSSADDR := $(<API key>)
else
ZTEXTADDR := 0
ZBSSADDR := ALIGN(8)
endif
SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
suffix_$(CONFIG_KERNEL_GZIP) = gzip
suffix_$(CONFIG_KERNEL_LZO) = lzo
suffix_$(CONFIG_KERNEL_LZMA) = lzma
suffix_$(CONFIG_KERNEL_XZ) = xzkern
# Borrowed libfdt files for the ATAG compatibility mode
libfdt := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
libfdt_hdrs := fdt.h libfdt.h libfdt_internal.h
libfdt_objs := $(addsuffix .o, $(basename $(libfdt)))
$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/%
$(call cmd,shipped)
$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
$(addprefix $(obj)/,$(libfdt_hdrs))
ifeq ($(<API key>),y)
OBJS += $(libfdt_objs) atags_to_fdt.o
endif
targets := vmlinux vmlinux.lds \
piggy.$(suffix_y) piggy.$(suffix_y).o \
lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S \
font.o font.c head.o misc.o $(OBJS)
# Make sure files are removed during clean
extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern \
lib1funcs.S ashldi3.S $(libfdt) $(libfdt_hdrs)
ifeq ($(<API key>),y)
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
endif
ccflags-y := -fpic -fno-builtin -I$(obj)
# Supply kernel BSS size to the decompressor via a linker symbol.
KBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \
awk 'END{print $$3}')
LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
# Supply ZRELADDR to the decompressor via a linker symbol.
ifneq ($(<API key>),y)
LDFLAGS_vmlinux += --defsym zreladdr=$(ZRELADDR)
endif
ifeq ($(<API key>),y)
LDFLAGS_vmlinux += --be8
endif
LDFLAGS_vmlinux += -p
# Report unresolved symbol references
LDFLAGS_vmlinux += --no-undefined
# Delete all temporary local symbols
LDFLAGS_vmlinux += -X
# Next argument is a linker script
LDFLAGS_vmlinux += -T
# For __aeabi_uidivmod
lib1funcs = $(obj)/lib1funcs.o
$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
$(call cmd,shipped)
# For __aeabi_llsl
ashldi3 = $(obj)/ashldi3.o
$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
$(call cmd,shipped)
# We need to prevent any GOTOFF relocs being used with references
# to symbols in the .bss section since we cannot relocate them
# independently from the rest at run time. This can be achieved by
# ensuring that no private .bss symbols exist, as global symbols
# always have a GOT entry which is what we need.
# The .data section is already discarded by the linker script so no need
# to bother about it here.
check_for_bad_syms = \
bad_syms=$$($(CROSS_COMPILE)nm $@ | sed -n 's/^.\{8\} [bc] \(.*\)/\1/p') && \
[ -z "$$bad_syms" ] || \
( echo "following symbols must have non local/private scope:" >&2; \
echo "$$bad_syms" >&2; rm -f $@; false )
<API key> = \
if [ $(words $(ZRELADDR)) -gt 1 -a "$(<API key>)" = "" ]; then \
echo 'multiple zreladdrs: $(ZRELADDR)'; \
echo 'This needs <API key> to be set'; \
false; \
fi
$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.$(suffix_y).o \
$(addprefix $(obj)/, $(OBJS)) $(lib1funcs) $(ashldi3) FORCE
@$(<API key>)
$(call if_changed,ld)
@$(check_for_bad_syms)
$(obj)/piggy.$(suffix_y): $(obj)/../Image FORCE
$(call if_changed,$(suffix_y))
$(obj)/piggy.$(suffix_y).o: $(obj)/piggy.$(suffix_y) FORCE
CFLAGS_font.o := -Dstatic=
$(obj)/font.c: $(FONTC)
$(call cmd,shipped)
$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in arch/arm/boot/Makefile $(KCONFIG_CONFIG)
@sed "$(SEDFLAGS)" < $< > $@ |
#include "<API key>.h"
#include "Creature.h"
<API key> si_idleMovement;
void
<API key>::Reset(Unit& /*owner*/)
{
}
void
<API key>::Initialize(Unit& owner)
{
owner.addUnitState(<API key>);
}
void
<API key>::Finalize(Unit& owner)
{
owner.clearUnitState(<API key>);
}
bool
<API key>::Update(Unit& /*owner*/, const uint32& time_diff)
{
if(time_diff > m_timer)
return false;
m_timer -= time_diff;
return true;
} |
<?php
/**
* @since 2.1.4
*/
class AWPCP_Email {
public function __construct() {
$this->headers = array();
$this->subject = '';
$this->from = null;
$this->to = array();
$this->cc = array();
$this->body = '';
$this->plain = '';
$this->html = '';
}
public function prepare($template, $params=array()) {
extract($params);
ob_start();
include($template);
$this->body = ob_get_contents();
ob_end_clean();
}
private function get_headers($format='plain') {
if (!$this->from) {
$this->from = <API key>();
}
switch ($format) {
case 'plain':
$content_type = 'text/plain; charset="' . get_option('blog_charset') . '"';
break;
case 'html':
$content_type = 'text/html; charset="' . get_option('blog_charset') . '"';
break;
}
$headers = array_merge(array(
'MIME-Version' => '1.0',
'Content-Type' => $content_type,
'From' => $this->from,
'Reply-To' => <API key>(),
), $this->headers);
$email_headers = '';
foreach ($headers as $k => $v) {
$email_headers .= sprintf("%s: %s\r\n", $k, $v);
}
return $email_headers;
}
/**
* Sends the email.
* @param string $format allowed values are 'html', 'plain' or 'both'
* @return boolean true on success, false otherwise
*/
public function send($format='plain') {
$headers = $this->get_headers($format);
$sent_date = <API key>();
$body = sprintf( "%s\n\n%s", $this->body, $sent_date );
if ($result = wp_mail($this->to, $this->subject, $body, $headers)) {
return $result;
}
if ($result = awpcp_send_email($this->from, $this->to, $this->subject, $body, $format === 'html')) {
return $result;
}
if ($result = @mail($this->to, $this->subject, $body, $headers)) {
return $result;
}
return false;
}
} |
#ifndef <API key>
#define <API key>
#include "<API key>.h"
namespace aria2 {
class <API key> : public <API key> {
protected:
virtual void afterSend(const std::shared_ptr<HttpServer>& httpServer,
DownloadEngine* e) CXX11_OVERRIDE;
public:
<API key>(cuid_t cuid,
const std::shared_ptr<HttpServer>& httpServer,
DownloadEngine* e,
const std::shared_ptr<SocketCore>& socket);
virtual ~<API key>();
};
} // namespace aria2
#endif // <API key> |
<?php
/**
* BuddyPress Messages Loader.
*
* A private messages component, for users to send messages to each other.
*
* @package BuddyPress
* @subpackage MessagesLoader
* @since 1.5.0
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Set up the bp-messages component.
*
* @since 1.5.0
*/
function bp_setup_messages() {
buddypress()->messages = new <API key>();
}
add_action( 'bp_setup_components', 'bp_setup_messages', 6 ); |
<?php
/**
* @file
* Contains \Drupal\image\ImageEffectBag.
*/
namespace Drupal\image;
use Drupal\Core\Plugin\DefaultPluginBag;
/**
* A collection of image effects.
*/
class ImageEffectBag extends DefaultPluginBag {
/**
* {@inheritdoc}
*
* @return \Drupal\image\<API key>
*/
public function &get($instance_id) {
return parent::get($instance_id);
}
/**
* Updates the configuration for an image effect instance.
*
* If there is no plugin instance yet, a new will be instantiated. Otherwise,
* the existing instance is updated with the new configuration.
*
* @param array $configuration
* The image effect configuration to set.
*
* @return string
* The image effect UUID.
*/
public function updateConfiguration(array $configuration) {
// Derive the instance ID from the configuration.
if (empty($configuration['uuid'])) {
$uuid_generator = \Drupal::service('uuid');
$configuration['uuid'] = $uuid_generator->generate();
}
$instance_id = $configuration['uuid'];
$this->addInstanceId($instance_id, $configuration);
return $instance_id;
}
/**
* {@inheritdoc}
*/
public function sortHelper($aID, $bID) {
$a_weight = $this->get($aID)->getWeight();
$b_weight = $this->get($bID)->getWeight();
if ($a_weight == $b_weight) {
return 0;
}
return ($a_weight < $b_weight) ? -1 : 1;
}
} |
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
#include <linux/time.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/backing-dev.h>
#include <linux/mpage.h>
#include <linux/falloc.h>
#include <linux/swap.h>
#include <linux/writeback.h>
#include <linux/statfs.h>
#include <linux/compat.h>
#include <linux/slab.h>
#include "ctree.h"
#include "disk-io.h"
#include "transaction.h"
#include "btrfs_inode.h"
#include "ioctl.h"
#include "print-tree.h"
#include "tree-log.h"
#include "locking.h"
#include "compat.h"
/*
* when auto defrag is enabled we
* queue up these defrag structs to remember which
* inodes need defragging passes
*/
struct inode_defrag {
struct rb_node rb_node;
/* objectid */
u64 ino;
/*
* transid where the defrag was added, we search for
* extents newer than this
*/
u64 transid;
/* root objectid */
u64 root;
/* last offset we were able to defrag */
u64 last_offset;
/* if we've wrapped around back to zero once already */
int cycled;
};
/* pop a record for an inode into the defrag tree. The lock
* must be held already
*
* If you're inserting a record for an older transid than an
* existing record, the transid already in the tree is lowered
*
* If an existing record is found the defrag item you
* pass in is freed
*/
static void <API key>(struct inode *inode,
struct inode_defrag *defrag)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct inode_defrag *entry;
struct rb_node **p;
struct rb_node *parent = NULL;
p = &root->fs_info->defrag_inodes.rb_node;
while (*p) {
parent = *p;
entry = rb_entry(parent, struct inode_defrag, rb_node);
if (defrag->ino < entry->ino)
p = &parent->rb_left;
else if (defrag->ino > entry->ino)
p = &parent->rb_right;
else {
/* if we're reinserting an entry for
* an old defrag run, make sure to
* lower the transid of our existing record
*/
if (defrag->transid < entry->transid)
entry->transid = defrag->transid;
if (defrag->last_offset > entry->last_offset)
entry->last_offset = defrag->last_offset;
goto exists;
}
}
BTRFS_I(inode)->in_defrag = 1;
rb_link_node(&defrag->rb_node, parent, p);
rb_insert_color(&defrag->rb_node, &root->fs_info->defrag_inodes);
return;
exists:
kfree(defrag);
return;
}
/*
* insert a defrag record for this inode if auto defrag is
* enabled
*/
int <API key>(struct btrfs_trans_handle *trans,
struct inode *inode)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct inode_defrag *defrag;
u64 transid;
if (!btrfs_test_opt(root, AUTO_DEFRAG))
return 0;
if (btrfs_fs_closing(root->fs_info))
return 0;
if (BTRFS_I(inode)->in_defrag)
return 0;
if (trans)
transid = trans->transid;
else
transid = BTRFS_I(inode)->root->last_trans;
defrag = kzalloc(sizeof(*defrag), GFP_NOFS);
if (!defrag)
return -ENOMEM;
defrag->ino = btrfs_ino(inode);
defrag->transid = transid;
defrag->root = root->root_key.objectid;
spin_lock(&root->fs_info->defrag_inodes_lock);
if (!BTRFS_I(inode)->in_defrag)
<API key>(inode, defrag);
else
kfree(defrag);
spin_unlock(&root->fs_info->defrag_inodes_lock);
return 0;
}
/*
* must be called with the defrag_inodes lock held
*/
struct inode_defrag *<API key>(struct btrfs_fs_info *info, u64 ino,
struct rb_node **next)
{
struct inode_defrag *entry = NULL;
struct rb_node *p;
struct rb_node *parent = NULL;
p = info->defrag_inodes.rb_node;
while (p) {
parent = p;
entry = rb_entry(parent, struct inode_defrag, rb_node);
if (ino < entry->ino)
p = parent->rb_left;
else if (ino > entry->ino)
p = parent->rb_right;
else
return entry;
}
if (next) {
while (parent && ino > entry->ino) {
parent = rb_next(parent);
entry = rb_entry(parent, struct inode_defrag, rb_node);
}
*next = parent;
}
return NULL;
}
/*
* run through the list of inodes in the FS that need
* defragging
*/
int <API key>(struct btrfs_fs_info *fs_info)
{
struct inode_defrag *defrag;
struct btrfs_root *inode_root;
struct inode *inode;
struct rb_node *n;
struct btrfs_key key;
struct <API key> range;
u64 first_ino = 0;
int num_defrag;
int defrag_batch = 1024;
memset(&range, 0, sizeof(range));
range.len = (u64)-1;
atomic_inc(&fs_info->defrag_running);
spin_lock(&fs_info->defrag_inodes_lock);
while(1) {
n = NULL;
/* find an inode to defrag */
defrag = <API key>(fs_info, first_ino, &n);
if (!defrag) {
if (n)
defrag = rb_entry(n, struct inode_defrag, rb_node);
else if (first_ino) {
first_ino = 0;
continue;
} else {
break;
}
}
/* remove it from the rbtree */
first_ino = defrag->ino + 1;
rb_erase(&defrag->rb_node, &fs_info->defrag_inodes);
if (btrfs_fs_closing(fs_info))
goto next_free;
spin_unlock(&fs_info->defrag_inodes_lock);
/* get the inode */
key.objectid = defrag->root;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
key.offset = (u64)-1;
inode_root = <API key>(fs_info, &key);
if (IS_ERR(inode_root))
goto next;
key.objectid = defrag->ino;
btrfs_set_key_type(&key, <API key>);
key.offset = 0;
inode = btrfs_iget(fs_info->sb, &key, inode_root, NULL);
if (IS_ERR(inode))
goto next;
/* do a chunk of defrag */
BTRFS_I(inode)->in_defrag = 0;
range.start = defrag->last_offset;
num_defrag = btrfs_defrag_file(inode, NULL, &range, defrag->transid,
defrag_batch);
/*
* if we filled the whole defrag batch, there
* must be more work to do. Queue this defrag
* again
*/
if (num_defrag == defrag_batch) {
defrag->last_offset = range.start;
<API key>(inode, defrag);
/*
* we don't want to kfree defrag, we added it back to
* the rbtree
*/
defrag = NULL;
} else if (defrag->last_offset && !defrag->cycled) {
/*
* we didn't fill our defrag batch, but
* we didn't start at zero. Make sure we loop
* around to the start of the file.
*/
defrag->last_offset = 0;
defrag->cycled = 1;
<API key>(inode, defrag);
defrag = NULL;
}
iput(inode);
next:
spin_lock(&fs_info->defrag_inodes_lock);
next_free:
kfree(defrag);
}
spin_unlock(&fs_info->defrag_inodes_lock);
atomic_dec(&fs_info->defrag_running);
/*
* during unmount, we use the transaction_wait queue to
* wait for the defragger to stop
*/
wake_up(&fs_info->transaction_wait);
return 0;
}
/* simple helper to fault in pages and copy. This should go away
* and be replaced with calls into generic code.
*/
static noinline int <API key>(loff_t pos, int num_pages,
size_t write_bytes,
struct page **prepared_pages,
struct iov_iter *i)
{
size_t copied = 0;
size_t total_copied = 0;
int pg = 0;
int offset = pos & (PAGE_CACHE_SIZE - 1);
while (write_bytes > 0) {
size_t count = min_t(size_t,
PAGE_CACHE_SIZE - offset, write_bytes);
struct page *page = prepared_pages[pg];
/*
* Copy data from userspace to the current page
*
* Disable pagefault to avoid recursive lock since
* the pages are already locked
*/
pagefault_disable();
copied = <API key>(page, i, offset, count);
pagefault_enable();
/* Flush processor's dcache for this page */
flush_dcache_page(page);
/*
* if we get a partial write, we can end up with
* partially up to date pages. These add
* a lot of complexity, so make sure they don't
* happen by forcing this copy to be retried.
*
* The rest of the btrfs_file_write code will fall
* back to page at a time copies after we return 0.
*/
if (!PageUptodate(page) && copied < count)
copied = 0;
iov_iter_advance(i, copied);
write_bytes -= copied;
total_copied += copied;
/* Return to <API key> to fault page */
if (unlikely(copied == 0))
break;
if (unlikely(copied < PAGE_CACHE_SIZE - offset)) {
offset += copied;
} else {
pg++;
offset = 0;
}
}
return total_copied;
}
/*
* unlocks pages after btrfs_file_write is done with them
*/
void btrfs_drop_pages(struct page **pages, size_t num_pages)
{
size_t i;
for (i = 0; i < num_pages; i++) {
/* page checked is some magic around finding pages that
* have been modified without going through <API key>
* clear it here
*/
ClearPageChecked(pages[i]);
unlock_page(pages[i]);
mark_page_accessed(pages[i]);
page_cache_release(pages[i]);
}
}
/*
* after copy_from_user, pages need to be dirtied and we need to make
* sure holes are created between the current EOF and the start of
* any next extents (if required).
*
* this also makes the decision about creating an inline extent vs
* doing real data extents, marking pages dirty and delalloc as required.
*/
int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode,
struct page **pages, size_t num_pages,
loff_t pos, size_t write_bytes,
struct extent_state **cached)
{
int err = 0;
int i;
u64 num_bytes;
u64 start_pos;
u64 end_of_last_block;
u64 end_pos = pos + write_bytes;
loff_t isize = i_size_read(inode);
start_pos = pos & ~((u64)root->sectorsize - 1);
num_bytes = (write_bytes + pos - start_pos +
root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
end_of_last_block = start_pos + num_bytes - 1;
err = <API key>(inode, start_pos, end_of_last_block,
cached);
if (err)
return err;
for (i = 0; i < num_pages; i++) {
struct page *p = pages[i];
SetPageUptodate(p);
ClearPageChecked(p);
set_page_dirty(p);
}
/*
* we've only changed i_size in ram, and we haven't updated
* the disk i_size. There is no need to log the inode
* at this time.
*/
if (end_pos > isize)
i_size_write(inode, end_pos);
return 0;
}
/*
* this drops all the extents in the cache that intersect the range
* [start, end]. Existing extents are split as required.
*/
int <API key>(struct inode *inode, u64 start, u64 end,
int skip_pinned)
{
struct extent_map *em;
struct extent_map *split = NULL;
struct extent_map *split2 = NULL;
struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
u64 len = end - start + 1;
int ret;
int testend = 1;
unsigned long flags;
int compressed = 0;
WARN_ON(end < start);
if (end == (u64)-1) {
len = (u64)-1;
testend = 0;
}
while (1) {
if (!split)
split = alloc_extent_map();
if (!split2)
split2 = alloc_extent_map();
BUG_ON(!split || !split2); /* -ENOMEM */
write_lock(&em_tree->lock);
em = <API key>(em_tree, start, len);
if (!em) {
write_unlock(&em_tree->lock);
break;
}
flags = em->flags;
if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
if (testend && em->start + em->len >= start + len) {
free_extent_map(em);
write_unlock(&em_tree->lock);
break;
}
start = em->start + em->len;
if (testend)
len = start + len - (em->start + em->len);
free_extent_map(em);
write_unlock(&em_tree->lock);
continue;
}
compressed = test_bit(<API key>, &em->flags);
clear_bit(EXTENT_FLAG_PINNED, &em->flags);
<API key>(em_tree, em);
if (em->block_start < <API key> &&
em->start < start) {
split->start = em->start;
split->len = start - em->start;
split->orig_start = em->orig_start;
split->block_start = em->block_start;
if (compressed)
split->block_len = em->block_len;
else
split->block_len = split->len;
split->bdev = em->bdev;
split->flags = flags;
split->compress_type = em->compress_type;
ret = add_extent_mapping(em_tree, split);
BUG_ON(ret); /* Logic error */
free_extent_map(split);
split = split2;
split2 = NULL;
}
if (em->block_start < <API key> &&
testend && em->start + em->len > start + len) {
u64 diff = start + len - em->start;
split->start = start + len;
split->len = em->start + em->len - (start + len);
split->bdev = em->bdev;
split->flags = flags;
split->compress_type = em->compress_type;
if (compressed) {
split->block_len = em->block_len;
split->block_start = em->block_start;
split->orig_start = em->orig_start;
} else {
split->block_len = split->len;
split->block_start = em->block_start + diff;
split->orig_start = split->start;
}
ret = add_extent_mapping(em_tree, split);
BUG_ON(ret); /* Logic error */
free_extent_map(split);
split = NULL;
}
write_unlock(&em_tree->lock);
/* once for us */
free_extent_map(em);
/* once for the tree*/
free_extent_map(em);
}
if (split)
free_extent_map(split);
if (split2)
free_extent_map(split2);
return 0;
}
/*
* this is very complex, but the basic idea is to drop all extents
* in the range start - end. hint_block is filled in with a block number
* that would be a good hint to the block allocator for this file.
*
* If an extent intersects the range but is not entirely inside the range
* it is either truncated or split. Anything entirely inside the range
* is deleted from the tree.
*/
int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
u64 start, u64 end, u64 *hint_byte, int drop_cache)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct extent_buffer *leaf;
struct <API key> *fi;
struct btrfs_path *path;
struct btrfs_key key;
struct btrfs_key new_key;
u64 ino = btrfs_ino(inode);
u64 search_start = start;
u64 disk_bytenr = 0;
u64 num_bytes = 0;
u64 extent_offset = 0;
u64 extent_end = 0;
int del_nr = 0;
int del_slot = 0;
int extent_type;
int recow;
int ret;
int modify_tree = -1;
if (drop_cache)
<API key>(inode, start, end - 1, 0);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
if (start >= BTRFS_I(inode)->disk_i_size)
modify_tree = 0;
while (1) {
recow = 0;
ret = <API key>(trans, root, path, ino,
search_start, modify_tree);
if (ret < 0)
break;
if (ret > 0 && path->slots[0] > 0 && search_start == start) {
leaf = path->nodes[0];
<API key>(leaf, &key, path->slots[0] - 1);
if (key.objectid == ino &&
key.type == <API key>)
path->slots[0]
}
ret = 0;
next_slot:
leaf = path->nodes[0];
if (path->slots[0] >= <API key>(leaf)) {
BUG_ON(del_nr > 0);
ret = btrfs_next_leaf(root, path);
if (ret < 0)
break;
if (ret > 0) {
ret = 0;
break;
}
leaf = path->nodes[0];
recow = 1;
}
<API key>(leaf, &key, path->slots[0]);
if (key.objectid > ino ||
key.type > <API key> || key.offset >= end)
break;
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
extent_type = <API key>(leaf, fi);
if (extent_type == <API key> ||
extent_type == <API key>) {
disk_bytenr = <API key>(leaf, fi);
num_bytes = <API key>(leaf, fi);
extent_offset = <API key>(leaf, fi);
extent_end = key.offset +
<API key>(leaf, fi);
} else if (extent_type == <API key>) {
extent_end = key.offset +
<API key>(leaf, fi);
} else {
WARN_ON(1);
extent_end = search_start;
}
if (extent_end <= search_start) {
path->slots[0]++;
goto next_slot;
}
search_start = max(key.offset, start);
if (recow || !modify_tree) {
modify_tree = -1;
btrfs_release_path(path);
continue;
}
if (start > key.offset && end < extent_end) {
BUG_ON(del_nr > 0);
BUG_ON(extent_type == <API key>);
memcpy(&new_key, &key, sizeof(new_key));
new_key.offset = start;
ret = <API key>(trans, root, path,
&new_key);
if (ret == -EAGAIN) {
btrfs_release_path(path);
continue;
}
if (ret < 0)
break;
leaf = path->nodes[0];
fi = btrfs_item_ptr(leaf, path->slots[0] - 1,
struct <API key>);
<API key>(leaf, fi,
start - key.offset);
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
extent_offset += start - key.offset;
<API key>(leaf, fi, extent_offset);
<API key>(leaf, fi,
extent_end - start);
<API key>(leaf);
if (disk_bytenr > 0) {
ret = <API key>(trans, root,
disk_bytenr, num_bytes, 0,
root->root_key.objectid,
new_key.objectid,
start - extent_offset, 0);
BUG_ON(ret); /* -ENOMEM */
*hint_byte = disk_bytenr;
}
key.offset = start;
}
if (start <= key.offset && end < extent_end) {
BUG_ON(extent_type == <API key>);
memcpy(&new_key, &key, sizeof(new_key));
new_key.offset = end;
<API key>(trans, root, path, &new_key);
extent_offset += end - key.offset;
<API key>(leaf, fi, extent_offset);
<API key>(leaf, fi,
extent_end - end);
<API key>(leaf);
if (disk_bytenr > 0) {
inode_sub_bytes(inode, end - key.offset);
*hint_byte = disk_bytenr;
}
break;
}
search_start = extent_end;
if (start > key.offset && end >= extent_end) {
BUG_ON(del_nr > 0);
BUG_ON(extent_type == <API key>);
<API key>(leaf, fi,
start - key.offset);
<API key>(leaf);
if (disk_bytenr > 0) {
inode_sub_bytes(inode, extent_end - start);
*hint_byte = disk_bytenr;
}
if (end == extent_end)
break;
path->slots[0]++;
goto next_slot;
}
if (start <= key.offset && end >= extent_end) {
if (del_nr == 0) {
del_slot = path->slots[0];
del_nr = 1;
} else {
BUG_ON(del_slot + del_nr != path->slots[0]);
del_nr++;
}
if (extent_type == <API key>) {
inode_sub_bytes(inode,
extent_end - key.offset);
extent_end = ALIGN(extent_end,
root->sectorsize);
} else if (disk_bytenr > 0) {
ret = btrfs_free_extent(trans, root,
disk_bytenr, num_bytes, 0,
root->root_key.objectid,
key.objectid, key.offset -
extent_offset, 0);
BUG_ON(ret); /* -ENOMEM */
inode_sub_bytes(inode,
extent_end - key.offset);
*hint_byte = disk_bytenr;
}
if (end == extent_end)
break;
if (path->slots[0] + 1 < <API key>(leaf)) {
path->slots[0]++;
goto next_slot;
}
ret = btrfs_del_items(trans, root, path, del_slot,
del_nr);
if (ret) {
<API key>(trans, root, ret);
goto out;
}
del_nr = 0;
del_slot = 0;
btrfs_release_path(path);
continue;
}
BUG_ON(1);
}
if (!ret && del_nr > 0) {
ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
if (ret)
<API key>(trans, root, ret);
}
out:
btrfs_free_path(path);
return ret;
}
static int extent_mergeable(struct extent_buffer *leaf, int slot,
u64 objectid, u64 bytenr, u64 orig_offset,
u64 *start, u64 *end)
{
struct <API key> *fi;
struct btrfs_key key;
u64 extent_end;
if (slot < 0 || slot >= <API key>(leaf))
return 0;
<API key>(leaf, &key, slot);
if (key.objectid != objectid || key.type != <API key>)
return 0;
fi = btrfs_item_ptr(leaf, slot, struct <API key>);
if (<API key>(leaf, fi) != <API key> ||
<API key>(leaf, fi) != bytenr ||
<API key>(leaf, fi) != key.offset - orig_offset ||
<API key>(leaf, fi) ||
<API key>(leaf, fi) ||
<API key>(leaf, fi))
return 0;
extent_end = key.offset + <API key>(leaf, fi);
if ((*start && *start != key.offset) || (*end && *end != extent_end))
return 0;
*start = key.offset;
*end = extent_end;
return 1;
}
/*
* Mark extent in the range start - end as written.
*
* This changes extent type from 'pre-allocated' to 'regular'. If only
* part of extent is marked as written, the extent will be split into
* two or three.
*/
int <API key>(struct btrfs_trans_handle *trans,
struct inode *inode, u64 start, u64 end)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct extent_buffer *leaf;
struct btrfs_path *path;
struct <API key> *fi;
struct btrfs_key key;
struct btrfs_key new_key;
u64 bytenr;
u64 num_bytes;
u64 extent_end;
u64 orig_offset;
u64 other_start;
u64 other_end;
u64 split;
int del_nr = 0;
int del_slot = 0;
int recow;
int ret;
u64 ino = btrfs_ino(inode);
<API key>(inode, start, end - 1, 0);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
again:
recow = 0;
split = start;
key.objectid = ino;
key.type = <API key>;
key.offset = split;
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0)
goto out;
if (ret > 0 && path->slots[0] > 0)
path->slots[0]
leaf = path->nodes[0];
<API key>(leaf, &key, path->slots[0]);
BUG_ON(key.objectid != ino || key.type != <API key>);
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
BUG_ON(<API key>(leaf, fi) !=
<API key>);
extent_end = key.offset + <API key>(leaf, fi);
BUG_ON(key.offset > start || extent_end < end);
bytenr = <API key>(leaf, fi);
num_bytes = <API key>(leaf, fi);
orig_offset = key.offset - <API key>(leaf, fi);
memcpy(&new_key, &key, sizeof(new_key));
if (start == key.offset && end < extent_end) {
other_start = 0;
other_end = start;
if (extent_mergeable(leaf, path->slots[0] - 1,
ino, bytenr, orig_offset,
&other_start, &other_end)) {
new_key.offset = end;
<API key>(trans, root, path, &new_key);
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
<API key>(leaf, fi,
extent_end - end);
<API key>(leaf, fi,
end - orig_offset);
fi = btrfs_item_ptr(leaf, path->slots[0] - 1,
struct <API key>);
<API key>(leaf, fi,
end - other_start);
<API key>(leaf);
goto out;
}
}
if (start > key.offset && end == extent_end) {
other_start = end;
other_end = 0;
if (extent_mergeable(leaf, path->slots[0] + 1,
ino, bytenr, orig_offset,
&other_start, &other_end)) {
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
<API key>(leaf, fi,
start - key.offset);
path->slots[0]++;
new_key.offset = start;
<API key>(trans, root, path, &new_key);
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
<API key>(leaf, fi,
other_end - start);
<API key>(leaf, fi,
start - orig_offset);
<API key>(leaf);
goto out;
}
}
while (start > key.offset || end < extent_end) {
if (key.offset == start)
split = end;
new_key.offset = split;
ret = <API key>(trans, root, path, &new_key);
if (ret == -EAGAIN) {
btrfs_release_path(path);
goto again;
}
if (ret < 0) {
<API key>(trans, root, ret);
goto out;
}
leaf = path->nodes[0];
fi = btrfs_item_ptr(leaf, path->slots[0] - 1,
struct <API key>);
<API key>(leaf, fi,
split - key.offset);
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
<API key>(leaf, fi, split - orig_offset);
<API key>(leaf, fi,
extent_end - split);
<API key>(leaf);
ret = <API key>(trans, root, bytenr, num_bytes, 0,
root->root_key.objectid,
ino, orig_offset, 0);
BUG_ON(ret); /* -ENOMEM */
if (split == start) {
key.offset = start;
} else {
BUG_ON(start != key.offset);
path->slots[0]
extent_end = end;
}
recow = 1;
}
other_start = end;
other_end = 0;
if (extent_mergeable(leaf, path->slots[0] + 1,
ino, bytenr, orig_offset,
&other_start, &other_end)) {
if (recow) {
btrfs_release_path(path);
goto again;
}
extent_end = other_end;
del_slot = path->slots[0] + 1;
del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
0, root->root_key.objectid,
ino, orig_offset, 0);
BUG_ON(ret); /* -ENOMEM */
}
other_start = 0;
other_end = start;
if (extent_mergeable(leaf, path->slots[0] - 1,
ino, bytenr, orig_offset,
&other_start, &other_end)) {
if (recow) {
btrfs_release_path(path);
goto again;
}
key.offset = other_start;
del_slot = path->slots[0];
del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
0, root->root_key.objectid,
ino, orig_offset, 0);
BUG_ON(ret); /* -ENOMEM */
}
if (del_nr == 0) {
fi = btrfs_item_ptr(leaf, path->slots[0],
struct <API key>);
<API key>(leaf, fi,
<API key>);
<API key>(leaf);
} else {
fi = btrfs_item_ptr(leaf, del_slot - 1,
struct <API key>);
<API key>(leaf, fi,
<API key>);
<API key>(leaf, fi,
extent_end - key.offset);
<API key>(leaf);
ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
if (ret < 0) {
<API key>(trans, root, ret);
goto out;
}
}
out:
btrfs_free_path(path);
return 0;
}
/*
* on error we return an unlocked page and the error value
* on success we return a locked page and 0
*/
static int <API key>(struct page *page, u64 pos,
bool force_uptodate)
{
int ret = 0;
if (((pos & (PAGE_CACHE_SIZE - 1)) || force_uptodate) &&
!PageUptodate(page)) {
ret = btrfs_readpage(NULL, page);
if (ret)
return ret;
lock_page(page);
if (!PageUptodate(page)) {
unlock_page(page);
return -EIO;
}
}
return 0;
}
/*
* this gets pages into the page cache and locks them down, it also properly
* waits for data=ordered extents to finish before allowing the pages to be
* modified.
*/
static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
struct page **pages, size_t num_pages,
loff_t pos, unsigned long first_index,
size_t write_bytes, bool force_uptodate)
{
struct extent_state *cached_state = NULL;
int i;
unsigned long index = pos >> PAGE_CACHE_SHIFT;
struct inode *inode = fdentry(file)->d_inode;
gfp_t mask = <API key>(inode->i_mapping);
int err = 0;
int faili = 0;
u64 start_pos;
u64 last_pos;
start_pos = pos & ~((u64)root->sectorsize - 1);
last_pos = ((u64)index + num_pages) << PAGE_CACHE_SHIFT;
again:
for (i = 0; i < num_pages; i++) {
pages[i] = find_or_create_page(inode->i_mapping, index + i,
mask | __GFP_WRITE);
if (!pages[i]) {
faili = i - 1;
err = -ENOMEM;
goto fail;
}
if (i == 0)
err = <API key>(pages[i], pos,
force_uptodate);
if (i == num_pages - 1)
err = <API key>(pages[i],
pos + write_bytes, false);
if (err) {
page_cache_release(pages[i]);
faili = i - 1;
goto fail;
}
<API key>(pages[i]);
}
err = 0;
if (start_pos < inode->i_size) {
struct <API key> *ordered;
lock_extent_bits(&BTRFS_I(inode)->io_tree,
start_pos, last_pos - 1, 0, &cached_state);
ordered = <API key>(inode,
last_pos - 1);
if (ordered &&
ordered->file_offset + ordered->len > start_pos &&
ordered->file_offset < last_pos) {
<API key>(ordered);
<API key>(&BTRFS_I(inode)->io_tree,
start_pos, last_pos - 1,
&cached_state, GFP_NOFS);
for (i = 0; i < num_pages; i++) {
unlock_page(pages[i]);
page_cache_release(pages[i]);
}
<API key>(inode, start_pos,
last_pos - start_pos);
goto again;
}
if (ordered)
<API key>(ordered);
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos,
last_pos - 1, EXTENT_DIRTY | EXTENT_DELALLOC |
<API key>, 0, 0, &cached_state,
GFP_NOFS);
<API key>(&BTRFS_I(inode)->io_tree,
start_pos, last_pos - 1, &cached_state,
GFP_NOFS);
}
for (i = 0; i < num_pages; i++) {
if (<API key>(pages[i]))
<API key>(pages[i]);
<API key>(pages[i]);
WARN_ON(!PageLocked(pages[i]));
}
return 0;
fail:
while (faili >= 0) {
unlock_page(pages[faili]);
page_cache_release(pages[faili]);
faili
}
return err;
}
static noinline ssize_t <API key>(struct file *file,
struct iov_iter *i,
loff_t pos)
{
struct inode *inode = fdentry(file)->d_inode;
struct btrfs_root *root = BTRFS_I(inode)->root;
struct page **pages = NULL;
unsigned long first_index;
size_t num_written = 0;
int nrptrs;
int ret = 0;
bool force_page_uptodate = false;
nrptrs = min((iov_iter_count(i) + PAGE_CACHE_SIZE - 1) /
PAGE_CACHE_SIZE, PAGE_CACHE_SIZE /
(sizeof(struct page *)));
nrptrs = min(nrptrs, current->nr_dirtied_pause - current->nr_dirtied);
nrptrs = max(nrptrs, 8);
pages = kmalloc(nrptrs * sizeof(struct page *), GFP_KERNEL);
if (!pages)
return -ENOMEM;
first_index = pos >> PAGE_CACHE_SHIFT;
while (iov_iter_count(i) > 0) {
size_t offset = pos & (PAGE_CACHE_SIZE - 1);
size_t write_bytes = min(iov_iter_count(i),
nrptrs * (size_t)PAGE_CACHE_SIZE -
offset);
size_t num_pages = (write_bytes + offset +
PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
size_t dirty_pages;
size_t copied;
WARN_ON(num_pages > nrptrs);
/*
* Fault pages before locking them in prepare_pages
* to avoid recursive lock
*/
if (unlikely(<API key>(i, write_bytes))) {
ret = -EFAULT;
break;
}
ret = <API key>(inode,
num_pages << PAGE_CACHE_SHIFT);
if (ret)
break;
/*
* This is going to setup the pages array with the number of
* pages we want, so we don't really need to worry about the
* contents of pages from loop to loop
*/
ret = prepare_pages(root, file, pages, num_pages,
pos, first_index, write_bytes,
force_page_uptodate);
if (ret) {
<API key>(inode,
num_pages << PAGE_CACHE_SHIFT);
break;
}
copied = <API key>(pos, num_pages,
write_bytes, pages, i);
/*
* if we have trouble faulting in the pages, fall
* back to one page at a time
*/
if (copied < write_bytes)
nrptrs = 1;
if (copied == 0) {
force_page_uptodate = true;
dirty_pages = 0;
} else {
force_page_uptodate = false;
dirty_pages = (copied + offset +
PAGE_CACHE_SIZE - 1) >>
PAGE_CACHE_SHIFT;
}
/*
* If we had a short copy we need to release the excess delaloc
* bytes we reserved. We need to increment outstanding_extents
* because <API key> will decrement it, but
* we still have an outstanding extent for the chunk we actually
* managed to copy.
*/
if (num_pages > dirty_pages) {
if (copied > 0) {
spin_lock(&BTRFS_I(inode)->lock);
BTRFS_I(inode)->outstanding_extents++;
spin_unlock(&BTRFS_I(inode)->lock);
}
<API key>(inode,
(num_pages - dirty_pages) <<
PAGE_CACHE_SHIFT);
}
if (copied > 0) {
ret = btrfs_dirty_pages(root, inode, pages,
dirty_pages, pos, copied,
NULL);
if (ret) {
<API key>(inode,
dirty_pages << PAGE_CACHE_SHIFT);
btrfs_drop_pages(pages, num_pages);
break;
}
}
btrfs_drop_pages(pages, num_pages);
cond_resched();
<API key>(inode->i_mapping,
dirty_pages);
if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
<API key>(root, 1);
pos += copied;
num_written += copied;
}
kfree(pages);
return num_written ? num_written : ret;
}
static ssize_t <API key>(struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs, loff_t pos,
loff_t *ppos, size_t count, size_t ocount)
{
struct file *file = iocb->ki_filp;
struct inode *inode = fdentry(file)->d_inode;
struct iov_iter i;
ssize_t written;
ssize_t written_buffered;
loff_t endbyte;
int err;
written = <API key>(iocb, iov, &nr_segs, pos, ppos,
count, ocount);
/*
* the generic O_DIRECT will update in-memory i_size after the
* DIOs are done. But our endio handlers that update the on
* disk i_size never update past the in memory i_size. So we
* need one more update here to catch any additions to the
* file
*/
if (inode->i_size != BTRFS_I(inode)->disk_i_size) {
<API key>(inode, inode->i_size, NULL);
mark_inode_dirty(inode);
}
if (written < 0 || written == count)
return written;
pos += written;
count -= written;
iov_iter_init(&i, iov, nr_segs, count, written);
written_buffered = <API key>(file, &i, pos);
if (written_buffered < 0) {
err = written_buffered;
goto out;
}
endbyte = pos + written_buffered - 1;
err = <API key>(file->f_mapping, pos, endbyte);
if (err)
goto out;
written += written_buffered;
*ppos = pos + written_buffered;
<API key>(file->f_mapping, pos >> PAGE_CACHE_SHIFT,
endbyte >> PAGE_CACHE_SHIFT);
out:
return written ? written : err;
}
static ssize_t <API key>(struct kiocb *iocb,
const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
struct file *file = iocb->ki_filp;
struct inode *inode = fdentry(file)->d_inode;
struct btrfs_root *root = BTRFS_I(inode)->root;
loff_t *ppos = &iocb->ki_pos;
u64 start_pos;
ssize_t num_written = 0;
ssize_t err = 0;
size_t count, ocount;
vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
mutex_lock(&inode->i_mutex);
err = <API key>(iov, &nr_segs, &ocount, VERIFY_READ);
if (err) {
mutex_unlock(&inode->i_mutex);
goto out;
}
count = ocount;
current->backing_dev_info = inode->i_mapping->backing_dev_info;
err = <API key>(file, &pos, &count, S_ISBLK(inode->i_mode));
if (err) {
mutex_unlock(&inode->i_mutex);
goto out;
}
if (count == 0) {
mutex_unlock(&inode->i_mutex);
goto out;
}
err = file_remove_suid(file);
if (err) {
mutex_unlock(&inode->i_mutex);
goto out;
}
/*
* If BTRFS flips readonly due to some impossible error
* (fs_info->fs_state now has <API key>),
* although we have opened a file as writable, we have
* to stop this write operation to ensure FS consistency.
*/
if (root->fs_info->fs_state & <API key>) {
mutex_unlock(&inode->i_mutex);
err = -EROFS;
goto out;
}
err = btrfs_update_time(file);
if (err) {
mutex_unlock(&inode->i_mutex);
goto out;
}
BTRFS_I(inode)->sequence++;
start_pos = round_down(pos, root->sectorsize);
if (start_pos > i_size_read(inode)) {
err = btrfs_cont_expand(inode, i_size_read(inode), start_pos);
if (err) {
mutex_unlock(&inode->i_mutex);
goto out;
}
}
if (unlikely(file->f_flags & O_DIRECT)) {
num_written = <API key>(iocb, iov, nr_segs,
pos, ppos, count, ocount);
} else {
struct iov_iter i;
iov_iter_init(&i, iov, nr_segs, count, num_written);
num_written = <API key>(file, &i, pos);
if (num_written > 0)
*ppos = pos + num_written;
}
mutex_unlock(&inode->i_mutex);
/*
* we want to make sure fsync finds this change
* but we haven't joined a transaction running right now.
*
* Later on, someone is sure to update the inode and get the
* real transid recorded.
*
* We set last_trans now to the fs_info generation + 1,
* this will either be one more than the running transaction
* or the generation used for the next transaction if there isn't
* one running right now.
*/
BTRFS_I(inode)->last_trans = root->fs_info->generation + 1;
if (num_written > 0 || num_written == -EIOCBQUEUED) {
err = generic_write_sync(file, pos, num_written);
if (err < 0 && num_written > 0)
num_written = err;
}
out:
current->backing_dev_info = NULL;
return num_written ? num_written : err;
}
int btrfs_release_file(struct inode *inode, struct file *filp)
{
/*
* ordered_data_close is set by settattr when we are about to truncate
* a file from a non-zero size to a zero size. This tries to
* flush down new bytes that may have been written if the
* application were using truncate to replace a file in place.
*/
if (BTRFS_I(inode)->ordered_data_close) {
BTRFS_I(inode)->ordered_data_close = 0;
<API key>(NULL, BTRFS_I(inode)->root, inode);
if (inode->i_size > <API key>)
filemap_flush(inode->i_mapping);
}
if (filp->private_data)
<API key>(filp);
return 0;
}
/*
* fsync call for both files and directories. This logs the inode into
* the tree log instead of forcing full commits whenever possible.
*
* It needs to call filemap_fdatawait so that all ordered extent updates are
* in the metadata btree are up to date for copying to the log.
*
* It drops the inode mutex before doing the tree log commit. This is an
* important optimization for directories because holding the mutex prevents
* new operations on the dir while we write to disk.
*/
int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
{
struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret = 0;
struct btrfs_trans_handle *trans;
<API key>(file, datasync);
ret = <API key>(inode->i_mapping, start, end);
if (ret)
return ret;
mutex_lock(&inode->i_mutex);
/* we wait first, since the writeback may change the inode */
root->log_batch++;
<API key>(inode, 0, (u64)-1);
root->log_batch++;
/*
* check the transaction that last modified this inode
* and see if its already been committed
*/
if (!BTRFS_I(inode)->last_trans) {
mutex_unlock(&inode->i_mutex);
goto out;
}
/*
* if the last transaction that changed this file was before
* the current transaction, we can bail out now without any
* syncing
*/
smp_mb();
if (BTRFS_I(inode)->last_trans <=
root->fs_info-><API key>) {
BTRFS_I(inode)->last_trans = 0;
mutex_unlock(&inode->i_mutex);
goto out;
}
/*
* ok we haven't committed the transaction yet, lets do a commit
*/
if (file->private_data)
<API key>(file);
trans = <API key>(root, 0);
if (IS_ERR(trans)) {
ret = PTR_ERR(trans);
mutex_unlock(&inode->i_mutex);
goto out;
}
ret = <API key>(trans, root, dentry);
if (ret < 0) {
mutex_unlock(&inode->i_mutex);
goto out;
}
/* we've logged all the items and now have a consistent
* version of the file in the log. It is possible that
* someone will come in and modify the file, but that's
* fine because the log is consistent on disk, and we
* have references to all of the file's extents
*
* It is possible that someone will come in and log the
* file again, but that will end up using the synchronization
* inside btrfs_sync_log to keep things safe.
*/
mutex_unlock(&inode->i_mutex);
if (ret != BTRFS_NO_LOG_SYNC) {
if (ret > 0) {
ret = <API key>(trans, root);
} else {
ret = btrfs_sync_log(trans, root);
if (ret == 0)
ret = <API key>(trans, root);
else
ret = <API key>(trans, root);
}
} else {
ret = <API key>(trans, root);
}
out:
return ret > 0 ? -EIO : ret;
}
static const struct <API key> btrfs_file_vm_ops = {
.fault = filemap_fault,
.page_mkwrite = btrfs_page_mkwrite,
};
static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)
{
struct address_space *mapping = filp->f_mapping;
if (!mapping->a_ops->readpage)
return -ENOEXEC;
file_accessed(filp);
vma->vm_ops = &btrfs_file_vm_ops;
vma->vm_flags |= VM_CAN_NONLINEAR;
return 0;
}
static long btrfs_fallocate(struct file *file, int mode,
loff_t offset, loff_t len)
{
struct inode *inode = file->f_path.dentry->d_inode;
struct extent_state *cached_state = NULL;
u64 cur_offset;
u64 last_byte;
u64 alloc_start;
u64 alloc_end;
u64 alloc_hint = 0;
u64 locked_end;
u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
struct extent_map *em;
int ret;
alloc_start = offset & ~mask;
alloc_end = (offset + len + mask) & ~mask;
/* We only support the FALLOC_FL_KEEP_SIZE mode */
if (mode & ~FALLOC_FL_KEEP_SIZE)
return -EOPNOTSUPP;
/*
* Make sure we have enough space before we do the
* allocation.
*/
ret = <API key>(inode, len);
if (ret)
return ret;
/*
* wait for ordered IO before we have any locks. We'll loop again
* below with the locks held.
*/
<API key>(inode, alloc_start, alloc_end - alloc_start);
mutex_lock(&inode->i_mutex);
ret = inode_newsize_ok(inode, alloc_end);
if (ret)
goto out;
if (alloc_start > inode->i_size) {
ret = btrfs_cont_expand(inode, i_size_read(inode),
alloc_start);
if (ret)
goto out;
}
locked_end = alloc_end - 1;
while (1) {
struct <API key> *ordered;
/* the extent lock is ordered inside the running
* transaction
*/
lock_extent_bits(&BTRFS_I(inode)->io_tree, alloc_start,
locked_end, 0, &cached_state);
ordered = <API key>(inode,
alloc_end - 1);
if (ordered &&
ordered->file_offset + ordered->len > alloc_start &&
ordered->file_offset < alloc_end) {
<API key>(ordered);
<API key>(&BTRFS_I(inode)->io_tree,
alloc_start, locked_end,
&cached_state, GFP_NOFS);
/*
* we can't wait on the range with the transaction
* running or with the extent lock held
*/
<API key>(inode, alloc_start,
alloc_end - alloc_start);
} else {
if (ordered)
<API key>(ordered);
break;
}
}
cur_offset = alloc_start;
while (1) {
u64 actual_end;
em = btrfs_get_extent(inode, NULL, 0, cur_offset,
alloc_end - cur_offset, 0);
if (IS_ERR_OR_NULL(em)) {
if (!em)
ret = -ENOMEM;
else
ret = PTR_ERR(em);
break;
}
last_byte = min(extent_map_end(em), alloc_end);
actual_end = min_t(u64, extent_map_end(em), offset + len);
last_byte = (last_byte + mask) & ~mask;
if (em->block_start == EXTENT_MAP_HOLE ||
(cur_offset >= inode->i_size &&
!test_bit(<API key>, &em->flags))) {
ret = <API key>(inode, mode, cur_offset,
last_byte - cur_offset,
1 << inode->i_blkbits,
offset + len,
&alloc_hint);
if (ret < 0) {
free_extent_map(em);
break;
}
} else if (actual_end > inode->i_size &&
!(mode & FALLOC_FL_KEEP_SIZE)) {
/*
* We didn't need to allocate any more space, but we
* still extended the size of the file so we need to
* update i_size.
*/
inode->i_ctime = CURRENT_TIME;
i_size_write(inode, actual_end);
<API key>(inode, actual_end, NULL);
}
free_extent_map(em);
cur_offset = last_byte;
if (cur_offset >= alloc_end) {
ret = 0;
break;
}
}
<API key>(&BTRFS_I(inode)->io_tree, alloc_start, locked_end,
&cached_state, GFP_NOFS);
out:
mutex_unlock(&inode->i_mutex);
/* Let go of our reservation. */
<API key>(inode, len);
return ret;
}
static int find_desired_extent(struct inode *inode, loff_t *offset, int whence)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct extent_map *em;
struct extent_state *cached_state = NULL;
u64 lockstart = *offset;
u64 lockend = i_size_read(inode);
u64 start = *offset;
u64 orig_start = *offset;
u64 len = i_size_read(inode);
u64 last_end = 0;
int ret = 0;
lockend = max_t(u64, root->sectorsize, lockend);
if (lockend <= lockstart)
lockend = lockstart + root->sectorsize;
len = lockend - lockstart + 1;
len = max_t(u64, len, root->sectorsize);
if (inode->i_size == 0)
return -ENXIO;
lock_extent_bits(&BTRFS_I(inode)->io_tree, lockstart, lockend, 0,
&cached_state);
/*
* Delalloc is such a pain. If we have a hole and we have pending
* delalloc for a portion of the hole we will get back a hole that
* exists for the entire range since it hasn't been actually written
* yet. So to take care of this case we need to look for an extent just
* before the position we want in case there is outstanding delalloc
* going on here.
*/
if (whence == SEEK_HOLE && start != 0) {
if (start <= root->sectorsize)
em = <API key>(inode, NULL, 0, 0,
root->sectorsize, 0);
else
em = <API key>(inode, NULL, 0,
start - root->sectorsize,
root->sectorsize, 0);
if (IS_ERR(em)) {
ret = PTR_ERR(em);
goto out;
}
last_end = em->start + em->len;
if (em->block_start == EXTENT_MAP_DELALLOC)
last_end = min_t(u64, last_end, inode->i_size);
free_extent_map(em);
}
while (1) {
em = <API key>(inode, NULL, 0, start, len, 0);
if (IS_ERR(em)) {
ret = PTR_ERR(em);
break;
}
if (em->block_start == EXTENT_MAP_HOLE) {
if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) {
if (last_end <= orig_start) {
free_extent_map(em);
ret = -ENXIO;
break;
}
}
if (whence == SEEK_HOLE) {
*offset = start;
free_extent_map(em);
break;
}
} else {
if (whence == SEEK_DATA) {
if (em->block_start == EXTENT_MAP_DELALLOC) {
if (start >= inode->i_size) {
free_extent_map(em);
ret = -ENXIO;
break;
}
}
*offset = start;
free_extent_map(em);
break;
}
}
start = em->start + em->len;
last_end = em->start + em->len;
if (em->block_start == EXTENT_MAP_DELALLOC)
last_end = min_t(u64, last_end, inode->i_size);
if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) {
free_extent_map(em);
ret = -ENXIO;
break;
}
free_extent_map(em);
cond_resched();
}
if (!ret)
*offset = min(*offset, inode->i_size);
out:
<API key>(&BTRFS_I(inode)->io_tree, lockstart, lockend,
&cached_state, GFP_NOFS);
return ret;
}
static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
int ret;
mutex_lock(&inode->i_mutex);
switch (whence) {
case SEEK_END:
case SEEK_CUR:
offset = generic_file_llseek(file, offset, whence);
goto out;
case SEEK_DATA:
case SEEK_HOLE:
if (offset >= i_size_read(inode)) {
mutex_unlock(&inode->i_mutex);
return -ENXIO;
}
ret = find_desired_extent(inode, &offset, whence);
if (ret) {
mutex_unlock(&inode->i_mutex);
return ret;
}
}
if (offset < 0 && !(file->f_mode & <API key>)) {
offset = -EINVAL;
goto out;
}
if (offset > inode->i_sb->s_maxbytes) {
offset = -EINVAL;
goto out;
}
/* Special lock needed here? */
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = 0;
}
out:
mutex_unlock(&inode->i_mutex);
return offset;
}
const struct file_operations <API key> = {
.llseek = btrfs_file_llseek,
.read = do_sync_read,
.write = do_sync_write,
.aio_read = <API key>,
.splice_read = <API key>,
.aio_write = <API key>,
.mmap = btrfs_file_mmap,
.open = generic_file_open,
.release = btrfs_release_file,
.fsync = btrfs_sync_file,
.fallocate = btrfs_fallocate,
.unlocked_ioctl = btrfs_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = btrfs_ioctl,
#endif
}; |
# states.rb
# This demonstration script creates a listbox widget that displays
# the names of the 50 states in the United States of America.
# listbox widget demo 'states' (called by 'widget')
# toplevel widget
if defined?($states_demo) && $states_demo
$states_demo.destroy
$states_demo = nil
end
# demo toplevel widget
$states_demo = TkToplevel.new {|w|
title("Listbox Demonstration (states)")
iconname("states")
positionWindow(w)
}
base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
# label
msg = TkLabel.new(base_frame) {
font $font
wraplength '4i'
justify 'left'
text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down."
}
msg.pack('side'=>'top')
# frame
TkFrame.new(base_frame) {|frame|
TkButton.new(frame) {
text 'Dismiss'
command proc{
tmppath = $states_demo
$states_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text 'Show Code'
command proc{showCode 'states'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame
states_lbox = nil
TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
s = TkScrollbar.new(w)
states_lbox = TkListbox.new(w) {
setgrid 1
height 12
yscrollcommand proc{|first,last| s.set first,last}
}
s.command(proc{|*args| states_lbox.yview(*args)})
s.pack('side'=>'right', 'fill'=>'y')
states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
ins_data = [
'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia',
'Hawaii', 'Idaho', 'Illinois',
'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland',
'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri',
'Montana', 'Nebraska', 'Nevada', 'New_Hampshire', 'New_Jersey', 'New_Mexico',
'New_York', 'North_Carolina', 'North_Dakota',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode_Island',
'South_Carolina', 'South_Dakota',
'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
'West_Virginia', 'Wisconsin', 'Wyoming'
]
states_lbox.insert(0, *ins_data) |
# irb.rb - irb main module
# $Revision: 39075 $
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
require "e2mmap"
require "irb/init"
require "irb/context"
require "irb/extend-command"
#require "irb/workspace"
require "irb/ruby-lex"
require "irb/input-method"
require "irb/locale"
STDOUT.sync = true
# IRB stands for "interactive ruby" and is a tool to interactively execute ruby
# expressions read from the standard input.
# The +irb+ command from your shell will start the interpreter.
# == Usage
# Use of irb is easy if you know ruby.
# When executing irb, prompts are displayed as follows. Then, enter the ruby
# expression. An input is executed when it is syntactically complete.
# $ irb
# irb(main):001:0> 1+2
# irb(main):002:0> class Foo
# irb(main):003:1> def foo
# irb(main):004:2> print 1
# irb(main):005:2> end
# irb(main):006:1> end
# #=> nil
# The Readline extension module can be used with irb. Use of Readline is
# default if it's installed.
# == Command line options
# Usage: irb.rb [options] [programfile] [arguments]
# -f Suppress read of ~/.irbrc
# -m Bc mode (load mathn, fraction or matrix are available)
# -d Set $DEBUG to true (same as `ruby -d')
# -r load-module Same as `ruby -r'
# -I path Specify $LOAD_PATH directory
# -U Same as `ruby -U`
# -E enc Same as `ruby -E`
# -w Same as `ruby -w`
# -W[level=2] Same as `ruby -W`
# --inspect Use `inspect' for output (default except for bc mode)
# --noinspect Don't use inspect for output
# --readline Use Readline extension module
# --noreadline Don't use Readline extension module
# --prompt prompt-mode
# --prompt-mode prompt-mode
# Switch prompt mode. Pre-defined prompt modes are
# `default', `simple', `xmp' and `inf-ruby'
# --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
# Suppresses --readline.
# --simple-prompt Simple prompt mode
# --noprompt No prompt mode
# --tracer Display trace for each execution of commands.
# --back-trace-limit n
# Display backtrace top n and tail n. The default
# value is 16.
# --irb_debug n Set internal debug level to n (not for popular use)
# -v, --version Print the version of irb
# == Configuration
# IRB reads from <code>~/.irbrc</code> when it's invoked.
# If <code>~/.irbrc</code> doesn't exist, +irb+ will try to read in the following order:
# * +.irbrc+
# * +irb.rc+
# * +_irbrc+
# * <code>$irbrc</code>
# The following are alternatives to the command line options. To use them type
# as follows in an +irb+ session:
# IRB.conf[:IRB_NAME]="irb"
# IRB.conf[:MATH_MODE]=false
# IRB.conf[:INSPECT_MODE]=nil
# IRB.conf[:IRB_RC] = nil
# IRB.conf[:BACK_TRACE_LIMIT]=16
# IRB.conf[:USE_LOADER] = false
# IRB.conf[:USE_READLINE] = nil
# IRB.conf[:USE_TRACER] = false
# IRB.conf[:IGNORE_SIGINT] = true
# IRB.conf[:IGNORE_EOF] = false
# IRB.conf[:PROMPT_MODE] = :DEFALUT
# IRB.conf[:PROMPT] = {...}
# IRB.conf[:DEBUG_LEVEL]=0
# To enable auto-indent mode in irb, add the following to your +.irbrc+:
# IRB.conf[:AUTO_INDENT] = true
# To enable autocompletion for irb, add the following to your +.irbrc+:
# require 'irb/completion'
# By default, irb disables history and will not store any commands you used.
# If you want to enable history, add the following to your +.irbrc+:
# IRB.conf[:SAVE_HISTORY] = 1000
# This will now store the last 1000 commands in <code>~/.irb_history</code>.
# See IRB::Context#save_history= for more information.
# == Customizing the IRB Prompt
# In order to customize the prompt, you can change the following Hash:
# IRB.conf[:PROMPT]
# This example can be used in your +.irbrc+
# IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
# :AUTO_INDENT => true # enables auto-indent mode
# :PROMPT_I => nil, # normal prompt
# :PROMPT_S => nil, # prompt for continuated strings
# :PROMPT_C => nil, # prompt for continuated statement
# :RETURN => " ==>%s\n" # format to return value
# IRB.conf[:PROMPT_MODE] = :MY_PROMPT
# Or, invoke irb with the above prompt mode by:
# irb --prompt my-prompt
# Constants +PROMPT_I+, +PROMPT_S+ and +PROMPT_C+ specify the format. In the
# prompt specification, some special strings are available:
# %N # command name which is running
# %m # to_s of main object (self)
# %M # inspect of main object (self)
# %l # type of string(", ', /, ]), `]' is inner %w[...]
# %NNi # indent level. NN is degits and means as same as printf("%NNd").
# # It can be ommited
# %NNn # line number.
# For instance, the default prompt mode is defined as follows:
# IRB.conf[:PROMPT_MODE][:DEFAULT] = {
# :PROMPT_I => "%N(%m):%03n:%i> ",
# :PROMPT_S => "%N(%m):%03n:%i%l ",
# :PROMPT_C => "%N(%m):%03n:%i* ",
# :RETURN => "%s\n" # used to printf
# irb comes with a number of available modes:
# # :NULL:
# # :PROMPT_I:
# # :PROMPT_N:
# # :PROMPT_S:
# # :PROMPT_C:
# # :RETURN: |
# # :DEFAULT:
# # :PROMPT_I: ! '%N(%m):%03n:%i> '
# # :PROMPT_N: ! '%N(%m):%03n:%i> '
# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
# # :PROMPT_C: ! '%N(%m):%03n:%i* '
# # :RETURN: |
# # :CLASSIC:
# # :PROMPT_I: ! '%N(%m):%03n:%i> '
# # :PROMPT_N: ! '%N(%m):%03n:%i> '
# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
# # :PROMPT_C: ! '%N(%m):%03n:%i* '
# # :RETURN: |
# # :SIMPLE:
# # :PROMPT_I: ! '>> '
# # :PROMPT_N: ! '>> '
# # :PROMPT_S:
# # :PROMPT_C: ! '?> '
# # :RETURN: |
# # :INF_RUBY:
# # :PROMPT_I: ! '%N(%m):%03n:%i> '
# # :PROMPT_N:
# # :PROMPT_S:
# # :PROMPT_C:
# # :RETURN: |
# # :AUTO_INDENT: true
# # :XMP:
# # :PROMPT_I:
# # :PROMPT_N:
# # :PROMPT_S:
# # :PROMPT_C:
# # :RETURN: |2
# == Restrictions
# Because irb evaluates input immediately after it is syntactically complete,
# the results may be slightly different than directly using ruby.
# == IRB Sessions
# IRB has a special feature, that allows you to manage many sessions at once.
# You can create new sessions with Irb.irb, and get a list of current sessions
# with the +jobs+ command in the prompt.
# JobManager provides commands to handle the current sessions:
# jobs # List of current sessions
# fg # Switches to the session of the given number
# kill # Kills the session with the given number
# The +exit+ command, or ::irb_exit, will quit the current session and call any
# exit hooks with IRB.irb_at_exit.
# A few commands for loading files within the session are also available:
# +source+::
# Loads a given file in the current session and displays the source lines,
# see IrbLoader#source_file
# +irb_load+::
# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
# +irb_require+::
# Loads the given file similarly to Kernel#require
# The command line options, or IRB.conf, specify the default behavior of
# Irb.irb.
# On the other hand, each conf in IRB@Command+line+options is used to
# individually configure IRB.irb.
# If a proc is set for IRB.conf[:IRB_RC], its will be invoked after execution
# of that proc with the context of the current session as its argument. Each
# session can be configured using this mechanism.
# There are a few variables in every Irb session that can come in handy:
# <code>_</code>::
# The value command executed, as a local variable
# <code>__</code>::
# The history of evaluated commands
# <code>__[line_no]</code>::
# Returns the evaluation value at the given line number, +line_no+.
# If +line_no+ is a negative, the return value +line_no+ many lines before
# the most recent return value.
# # invoke a new session
# irb(main):001:0> irb
# # list open sessions
# irb.1(main):001:0> jobs
# #0->irb on main (#<Thread:0x400fb7e4> : stop)
# #1->irb#1 on main (#<Thread:0x40125d64> : running)
# # change the active session
# irb.1(main):002:0> fg 0
# # define class Foo in top-level session
# irb(main):002:0> class Foo;end
# # invoke a new session with the context of Foo
# irb(main):003:0> irb Foo
# # define Foo#foo
# irb.2(Foo):001:0> def foo
# irb.2(Foo):002:1> print 1
# irb.2(Foo):003:1> end
# # change the active session
# irb.2(Foo):004:0> fg 0
# # list open sessions
# irb(main):004:0> jobs
# #0->irb on main (#<Thread:0x400fb7e4> : running)
# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
# # check if Foo#foo is available
# irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
# # change the active sesssion
# irb(main):006:0> fg 2
# # define Foo#bar in the context of Foo
# irb.2(Foo):005:0> def bar
# irb.2(Foo):006:1> print "bar"
# irb.2(Foo):007:1> end
# irb.2(Foo):010:0> Foo.instance_methods #=> [:bar, :foo, ...]
# # change the active session
# irb.2(Foo):011:0> fg 0
# irb(main):007:0> f = Foo.new #=> #<Foo:0x4010af3c>
# # invoke a new session with the context of f (instance of Foo)
# irb(main):008:0> irb f
# # list open sessions
# irb.3(<Foo:0x4010af3c>):001:0> jobs
# #0->irb on main (#<Thread:0x400fb7e4> : stop)
# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
# #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
# # evaluate f.foo
# irb.3(<Foo:0x4010af3c>):002:0> foo #=> 1 => nil
# # evaluate f.bar
# irb.3(<Foo:0x4010af3c>):003:0> bar #=> bar => nil
# # kill jobs 1, 2, and 3
# irb.3(<Foo:0x4010af3c>):004:0> kill 1, 2, 3
# # list open sesssions, should only include main session
# irb(main):009:0> jobs
# #0->irb on main (#<Thread:0x400fb7e4> : running)
# # quit irb
# irb(main):010:0> exit
module IRB
@RCS_ID='-$Id: irb.rb 39075 2013-02-05 15:57:19Z zzak $-'
# An exception raised by IRB.irb_abort
class Abort < Exception;end
@CONF = {}
# Displays current configuration.
# Modifing the configuration is achieved by sending a message to IRB.conf.
# See IRB@Configuration for more information.
def IRB.conf
@CONF
end
# Returns the current version of IRB, including release version and last
# updated date.
def IRB.version
if v = @CONF[:VERSION] then return v end
require "irb/version"
rv = @RELEASE_VERSION.sub(/\.0/, "")
@CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE)
end
# The current IRB::Context of the session, see IRB.conf
# irb
# irb(main):001:0> IRB.CurrentContext.irb_name = "foo"
# foo(main):002:0> IRB.conf[:MAIN_CONTEXT].irb_name #=> "foo"
def IRB.CurrentContext
IRB.conf[:MAIN_CONTEXT]
end
# Initializes IRB and creates a new Irb.irb object at the +TOPLEVEL_BINDING+
def IRB.start(ap_path = nil)
$0 = File::basename(ap_path, ".rb") if ap_path
IRB.setup(ap_path)
if @CONF[:SCRIPT]
irb = Irb.new(nil, @CONF[:SCRIPT])
else
irb = Irb.new
end
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
@CONF[:MAIN_CONTEXT] = irb.context
trap("SIGINT") do
irb.signal_handle
end
begin
catch(:IRB_EXIT) do
irb.eval_input
end
ensure
irb_at_exit
end
# print "\n"
end
# Calls each event hook of IRB.conf[:AT_EXIT] when the current session quits.
def IRB.irb_at_exit
@CONF[:AT_EXIT].each{|hook| hook.call}
end
# Quits irb
def IRB.irb_exit(irb, ret)
throw :IRB_EXIT, ret
end
# Aborts then interrupts irb.
# Will raise an Abort exception, or the given +exception+.
def IRB.irb_abort(irb, exception = Abort)
if defined? Thread
irb.context.thread.raise exception, "abort then interrupt!"
else
raise exception, "abort then interrupt!"
end
end
class Irb
# Creates a new irb session
def initialize(workspace = nil, input_method = nil, output_method = nil)
@context = Context.new(self, workspace, input_method, output_method)
@context.main.extend ExtendCommandBundle
@signal_status = :IN_IRB
@scanner = RubyLex.new
@scanner.<API key> = false
end
# Returns the current context of this irb session
attr_reader :context
# The lexer used by this irb session
attr_accessor :scanner
# Evaluates input for this session.
def eval_input
@scanner.set_prompt do
|ltype, indent, continue, line_no|
if ltype
f = @context.prompt_s
elsif continue
f = @context.prompt_c
elsif indent > 0
f = @context.prompt_n
else
f = @context.prompt_i
end
f = "" unless f
if @context.prompting?
@context.io.prompt = p = prompt(f, ltype, indent, line_no)
else
@context.io.prompt = p = ""
end
if @context.auto_indent_mode
unless ltype
ind = prompt(@context.prompt_i, ltype, indent, line_no)[/.*\z/].size +
indent * 2 - p.size
ind += 2 if continue
@context.io.prompt = p + " " * ind if ind > 0
end
end
end
@scanner.set_input(@context.io) do
signal_status(:IN_INPUT) do
if l = @context.io.gets
print l if @context.verbose?
else
if @context.ignore_eof? and @context.io.readable_after_eof?
l = "\n"
if @context.verbose?
printf "Use \"exit\" to leave %s\n", @context.ap_name
end
else
print "\n"
end
end
l
end
end
@scanner.<API key> do |line, line_no|
signal_status(:IN_EVAL) do
begin
line.untaint
@context.evaluate(line, line_no)
output_value if @context.echo?
exc = nil
rescue Interrupt => exc
rescue SystemExit, SignalException
raise
rescue Exception => exc
end
if exc
print exc.class, ": ", exc, "\n"
if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
!(SyntaxError === exc)
irb_bug = true
else
irb_bug = false
end
messages = []
lasts = []
levels = 0
for m in exc.backtrace
m = @context.workspace.filter_backtrace(m) unless irb_bug
if m
if messages.size < @context.back_trace_limit
messages.push "\tfrom "+m
else
lasts.push "\tfrom "+m
if lasts.size > @context.back_trace_limit
lasts.shift
levels += 1
end
end
end
end
print messages.join("\n"), "\n"
unless lasts.empty?
printf "... %d levels...\n", levels if levels > 0
print lasts.join("\n")
end
print "Maybe IRB bug!\n" if irb_bug
end
if $SAFE > 2
abort "Error: irb does not work for $SAFE level higher than 2"
end
end
end
end
# Evaluates the given block using the given +path+ as the Context#irb_path
# and +name+ as the Context#irb_name.
# Used by the irb command +source+, see IRB@IRB+Sessions for more
# information.
def suspend_name(path = nil, name = nil)
@context.irb_path, back_path = path, @context.irb_path if path
@context.irb_name, back_name = name, @context.irb_name if name
begin
yield back_path, back_name
ensure
@context.irb_path = back_path if path
@context.irb_name = back_name if name
end
end
# Evaluates the given block using the given +workspace+ as the
# Context#workspace.
# Used by the irb command +irb_load+, see IRB@IRB+Sessions for more
# information.
def suspend_workspace(workspace)
@context.workspace, back_workspace = workspace, @context.workspace
begin
yield back_workspace
ensure
@context.workspace = back_workspace
end
end
# Evaluates the given block using the given +input_method+ as the
# Context#io.
# Used by the irb commands +source+ and +irb_load+, see IRB@IRB+Sessions
# for more information.
def <API key>(input_method)
back_io = @context.io
@context.instance_eval{@io = input_method}
begin
yield back_io
ensure
@context.instance_eval{@io = back_io}
end
end
# Evaluates the given block using the given +context+ as the Context.
def suspend_context(context)
@context, back_context = context, @context
begin
yield back_context
ensure
@context = back_context
end
end
# Handler for the signal SIGINT, see Kernel#trap for more information.
def signal_handle
unless @context.ignore_sigint?
print "\nabort!\n" if @context.verbose?
exit
end
case @signal_status
when :IN_INPUT
print "^C\n"
raise RubyLex::TerminateLineInput
when :IN_EVAL
IRB.irb_abort(self)
when :IN_LOAD
IRB.irb_abort(self, LoadAbort)
when :IN_IRB
# ignore
else
# ignore other cases as well
end
end
# Evaluates the given block using the given +status+.
def signal_status(status)
return yield if @signal_status == :IN_LOAD
signal_status_back = @signal_status
@signal_status = status
begin
yield
ensure
@signal_status = signal_status_back
end
end
def prompt(prompt, ltype, indent, line_no) # :nodoc:
p = prompt.dup
p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
case $2
when "N"
@context.irb_name
when "m"
@context.main.to_s
when "M"
@context.main.inspect
when "l"
ltype
when "i"
if $1
format("%" + $1 + "d", indent)
else
indent.to_s
end
when "n"
if $1
format("%" + $1 + "d", line_no)
else
line_no.to_s
end
when "%"
"%"
end
end
p
end
def output_value # :nodoc:
printf @context.return_format, @context.inspect_last_value
end
# Outputs the local variables to this current session, including
# #signal_status and #context, using IRB::Locale.
def inspect
ary = []
for iv in instance_variables
case (iv = iv.to_s)
when "@signal_status"
ary.push format("%s=:%s", iv, @signal_status.id2name)
when "@context"
ary.push format("%s=%s", iv, eval(iv).__to_s__)
else
ary.push format("%s=%s", iv, eval(iv))
end
end
format("#<%s: %s>", self.class, ary.join(", "))
end
end
def @CONF.inspect
IRB.version unless self[:VERSION]
array = []
for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
case k
when :MAIN_CONTEXT, :__TMP__EHV__
array.push format("CONF[:%s]=...myself...", k.id2name)
when :PROMPT
s = v.collect{
|kk, vv|
ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
format(":%s=>{%s}", kk.id2name, ss.join(", "))
}
array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
else
array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
end
end
array.join("\n")
end
end |
/* { dg-do compile } */
/* { dg-options "-mcmse -mfloat-abi=softfp -mfpu=fpv5-d16" } */
/* { dg-skip-if "Incompatible float ABI" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=softfp" } } */
/* { dg-skip-if "Skip these if testing single precision" {*-*-*} {"-mfpu=*-sp-*"} {""} } */
#include "../../../cmse-13.x"
/* Checks for saving and clearing prior to function call. */
/* Shift on the same register as blxns. */
/* { dg-final { scan-assembler "lsrs\t(r\[1,4-9\]|r10|fp|ip), \\1, #1.*blxns\t\\1" } } */
/* { dg-final { scan-assembler "lsls\t(r\[1,4-9\]|r10|fp|ip), \\1, #1.*blxns\t\\1" } } */
/* { dg-final { scan-assembler-not "mov\tr0, r4" } } */
/* { dg-final { scan-assembler-not "mov\tr2, r4" } } */
/* { dg-final { scan-assembler-not "mov\tr3, r4" } } */
/* { dg-final { scan-assembler "push\t\{r4, r5, r6, r7, r8, r9, r10, fp\}" } } */
/* { dg-final { scan-assembler "vlstm\tsp" } } */
/* Check the right registers are cleared and none appears twice. */
/* { dg-final { scan-assembler "clrm\t\{(r1, )?(r4, )?(r5, )?(r6, )?(r7, )?(r8, )?(r9, )?(r10, )?(fp, )?(ip, )?APSR\}" } } */
/* Check that the right number of registers is cleared and thus only one
register is missing. */
/* { dg-final { scan-assembler "clrm\t\{((r\[1,4-9\]|r10|fp|ip), ){9}APSR\}" } } */
/* Check that no cleared register is used for blxns. */
/* { dg-final { scan-assembler-not "clrm\t\{\[^\}\]\+(r\[1,4-9\]|r10|fp|ip),\[^\}\]\+\}.*blxns\t\\1" } } */
/* { dg-final { scan-assembler "vlldm\tsp" } } */
/* { dg-final { scan-assembler "pop\t\{r4, r5, r6, r7, r8, r9, r10, fp\}" } } */
/* Now we check that we use the correct intrinsic to call. */
/* { dg-final { scan-assembler "blxns" } } */ |
package net.sf.launch4j.binding;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import net.sf.launch4j.Util;
import net.sf.launch4j.config.ConfigPersister;
public class Validator {
public static final String <API key> = "[\\w]*?";
public static final String ALPHA_PATTERN = "[\\w&&\\D]*?";
public static final String NUMERIC_PATTERN = "[\\d]*?";
public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?";
public static final int MAX_STR = 128;
public static final int MAX_PATH = 260;
public static final int MAX_BIG_STR = 8192; // or 16384;
public static final int MAX_ARGS = 32767 - 2048;
private Validator() {}
public static boolean isEmpty(String s) {
return s == null || s.equals("");
}
public static void checkNotNull(Object o, String property, String name) {
if (o == null) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
}
public static void checkString(String s, int maxLength, String property,
String name) {
if (s == null || s.length() == 0) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
if (s.length() > maxLength) {
<API key>(property, name, maxLength);
}
}
public static void checkOptStrings(List strings, int maxLength, int totalMaxLength,
String property, String name) {
if (strings == null) {
return;
}
int totalLength = 0;
for (Iterator iter = strings.iterator(); iter.hasNext();) {
String s = (String) iter.next();
checkString(s, maxLength, property, name);
totalLength += s.length();
if (totalLength > totalMaxLength) {
<API key>(property, name, totalMaxLength);
}
}
}
public static void checkString(String s, int maxLength, String pattern,
String property, String name) {
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property,
Messages.getString("Validator.invalid.data", name));
}
}
public static void checkOptStrings(List strings, int maxLength, int totalMaxLength,
String pattern, String property, String name, String msg) {
if (strings == null) {
return;
}
int totalLength = 0;
for (Iterator iter = strings.iterator(); iter.hasNext();) {
String s = (String) iter.next();
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property, msg != null
? msg
: Messages.getString("Validator.invalid.data", name));
}
totalLength += s.length();
if (totalLength > totalMaxLength) {
<API key>(property, name, totalMaxLength);
}
}
}
public static void checkOptString(String s, int maxLength, String property,
String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
<API key>(property, name, maxLength);
}
}
public static void checkOptString(String s, int maxLength, String pattern,
String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
<API key>(property, name, maxLength);
}
if (!s.matches(pattern)) {
signalViolation(property,
Messages.getString("Validator.invalid.data", name));
}
}
public static void checkRange(int value, int min, int max,
String property, String name) {
if (value < min || value > max) {
signalViolation(property,
Messages.getString("Validator.must.be.in.range", name,
String.valueOf(min), String.valueOf(max)));
}
}
public static void checkRange(char value, char min, char max,
String property, String name) {
if (value < min || value > max) {
signalViolation(property, Messages.getString("Validator.must.be.in.range",
name, String.valueOf(min), String.valueOf(max)));
}
}
public static void checkMin(int value, int min, String property, String name) {
if (value < min) {
signalViolation(property,
Messages.getString("Validator.must.be.at.least", name,
String.valueOf(min)));
}
}
public static void checkIn(String s, String[] strings, String property,
String name) {
if (isEmpty(s)) {
signalViolation(property,
Messages.getString("Validator.empty.field", name));
}
List list = Arrays.asList(strings);
if (!list.contains(s)) {
signalViolation(property,
Messages.getString("Validator.invalid.option", name, list.toString()));
}
}
public static void checkTrue(boolean condition, String property, String msg) {
if (!condition) {
signalViolation(property, msg);
}
}
public static void checkFalse(boolean condition, String property, String msg) {
if (condition) {
signalViolation(property, msg);
}
}
public static void <API key>(Collection c, String property,
String msg) {
if (c.contains(null)
|| new HashSet(c).size() != c.size()) {
signalViolation(property,
Messages.getString("Validator.already.exists", msg));
}
}
public static void checkElementsUnique(Collection c, String property, String msg) {
if (new HashSet(c).size() != c.size()) {
signalViolation(property,
Messages.getString("Validator.already.exists", msg));
}
}
public static void checkFile(File f, String property, String fileDescription) {
File cfgPath = ConfigPersister.getInstance().getConfigPath();
if (f == null
|| f.getPath().equals("")
|| (!f.exists() && !Util.getAbsoluteFile(cfgPath, f).exists())) {
signalViolation(property,
Messages.getString("Validator.doesnt.exist", fileDescription));
}
}
public static void checkOptFile(File f, String property, String fileDescription) {
if (f != null && f.getPath().length() > 0) {
checkFile(f, property, fileDescription);
}
}
public static void <API key>(String path, String property, String msg) {
if (path == null
|| path.equals("")
|| path.startsWith("/")
|| path.startsWith("\\")
|| path.indexOf(':') != -1) {
signalViolation(property, msg);
}
}
public static void <API key>(String property, String name,
int maxLength) {
signalViolation(property,
Messages.getString("Validator.exceeds.max.length", name,
String.valueOf(maxLength)));
}
public static void signalViolation(String property, String msg) {
throw new <API key>(property, msg);
}
} |
package com.mysql.jdbc.log;
import com.mysql.jdbc.Util;
import com.mysql.jdbc.profiler.ProfilerEvent;
public class LogUtils {
public static final String <API key> = "Caller information not available";
private static final String LINE_SEPARATOR = System
.getProperty("line.separator");
private static final int <API key> = LINE_SEPARATOR.length();
public static Object <API key>(
Object <API key>) {
if (<API key> instanceof ProfilerEvent) {
StringBuffer msgBuf = new StringBuffer();
ProfilerEvent evt = (ProfilerEvent) <API key>;
String locationInformation = evt.<API key>();
if (locationInformation == null) {
locationInformation = Util.stackTraceToString(new Throwable());
}
msgBuf.append("Profiler Event: [");
switch (evt.getEventType()) {
case ProfilerEvent.TYPE_EXECUTE:
msgBuf.append("EXECUTE");
break;
case ProfilerEvent.TYPE_FETCH:
msgBuf.append("FETCH");
break;
case ProfilerEvent.<API key>:
msgBuf.append("CONSTRUCT");
break;
case ProfilerEvent.TYPE_PREPARE:
msgBuf.append("PREPARE");
break;
case ProfilerEvent.TYPE_QUERY:
msgBuf.append("QUERY");
break;
case ProfilerEvent.TYPE_WARN:
msgBuf.append("WARN");
break;
case ProfilerEvent.TYPE_SLOW_QUERY:
msgBuf.append("SLOW QUERY");
break;
default:
msgBuf.append("UNKNOWN");
}
msgBuf.append("] ");
msgBuf.append(locationInformation);
msgBuf.append(" duration: ");
msgBuf.append(evt.getEventDuration());
msgBuf.append(" ");
msgBuf.append(evt.getDurationUnits());
msgBuf.append(", connection-id: ");
msgBuf.append(evt.getConnectionId());
msgBuf.append(", statement-id: ");
msgBuf.append(evt.getStatementId());
msgBuf.append(", resultset-id: ");
msgBuf.append(evt.getResultSetId());
String evtMessage = evt.getMessage();
if (evtMessage != null) {
msgBuf.append(", message: ");
msgBuf.append(evtMessage);
}
return msgBuf;
}
return <API key>;
}
public static String <API key>(Throwable t) {
String stackTraceAsString = Util.stackTraceToString(t);
String <API key> = <API key>;
int endInternalMethods = stackTraceAsString
.lastIndexOf("com.mysql.jdbc");
if (endInternalMethods != -1) {
int endOfLine = -1;
int compliancePackage = stackTraceAsString.indexOf(
"com.mysql.jdbc.compliance", endInternalMethods);
if (compliancePackage != -1) {
endOfLine = compliancePackage - <API key>;
} else {
endOfLine = stackTraceAsString.indexOf(LINE_SEPARATOR,
endInternalMethods);
}
if (endOfLine != -1) {
int nextEndOfLine = stackTraceAsString.indexOf(LINE_SEPARATOR,
endOfLine + <API key>);
if (nextEndOfLine != -1) {
<API key> = stackTraceAsString.substring(
endOfLine + <API key>, nextEndOfLine);
} else {
<API key> = stackTraceAsString
.substring(endOfLine + <API key>);
}
}
}
if (!<API key>.startsWith("\tat ") &&
!<API key>.startsWith("at ")) {
return "at " + <API key>;
}
return <API key>;
}
} |
# enigma2 reactor: based on pollreactor, which is
"""
Maintainer: U{Felix Domke<mailto:tmbinc@elitedvb.net>}
"""
# System imports
import select, errno, sys
# Twisted imports
from twisted.python import log, failure
from twisted.internet import main, posixbase, error
#from twisted.internet.pollreactor import PollReactor, poller
from enigma import getApplication
# globals
reads = {}
writes = {}
selectables = {}
POLL_DISCONNECTED = (select.POLLHUP | select.POLLERR | select.POLLNVAL)
class E2SharedPoll:
def __init__(self):
self.dict = { }
self.eApp = getApplication()
def register(self, fd, eventmask = select.POLLIN | select.POLLERR | select.POLLOUT):
self.dict[fd] = eventmask
def unregister(self, fd):
del self.dict[fd]
def poll(self, timeout = None):
try:
r = self.eApp.poll(timeout, self.dict)
except KeyboardInterrupt:
return None
return r
poller = E2SharedPoll()
class PollReactor(posixbase.PosixReactorBase):
"""A reactor that uses poll(2)."""
def _updateRegistration(self, fd):
"""Register/unregister an fd with the poller."""
try:
poller.unregister(fd)
except KeyError:
pass
mask = 0
if fd in reads:
mask = mask | select.POLLIN
if fd in writes:
mask = mask | select.POLLOUT
if mask != 0:
poller.register(fd, mask)
else:
if fd in selectables:
del selectables[fd]
poller.eApp.interruptPoll()
def _dictRemove(self, selectable, mdict):
try:
# the easy way
fd = selectable.fileno()
# make sure the fd is actually real. In some situations we can get
# -1 here.
mdict[fd]
except:
# the hard way: necessary because fileno() may disappear at any
# moment, thanks to python's underlying sockets impl
for fd, fdes in selectables.items():
if selectable is fdes:
break
else:
# Hmm, maybe not the right course of action? This method can't
# fail, because it happens inside error detection...
return
if fd in mdict:
del mdict[fd]
self._updateRegistration(fd)
def addReader(self, reader):
"""Add a FileDescriptor for notification of data available to read.
"""
fd = reader.fileno()
if fd not in reads:
selectables[fd] = reader
reads[fd] = 1
self._updateRegistration(fd)
def addWriter(self, writer, writes=writes, selectables=selectables):
"""Add a FileDescriptor for notification of data available to write.
"""
fd = writer.fileno()
if fd not in writes:
selectables[fd] = writer
writes[fd] = 1
self._updateRegistration(fd)
def removeReader(self, reader, reads=reads):
"""Remove a Selectable for notification of data available to read.
"""
return self._dictRemove(reader, reads)
def removeWriter(self, writer, writes=writes):
"""Remove a Selectable for notification of data available to write.
"""
return self._dictRemove(writer, writes)
def removeAll(self, reads=reads, writes=writes, selectables=selectables):
"""Remove all selectables, and return a list of them."""
if self.waker is not None:
self.removeReader(self.waker)
result = selectables.values()
fds = selectables.keys()
reads.clear()
writes.clear()
selectables.clear()
for fd in fds:
poller.unregister(fd)
if self.waker is not None:
self.addReader(self.waker)
return result
def doPoll(self, timeout,
reads=reads,
writes=writes,
selectables=selectables,
select=select,
log=log,
POLLIN=select.POLLIN,
POLLOUT=select.POLLOUT):
"""Poll the poller for new events."""
if timeout is not None:
timeout = int(timeout * 1000) # convert seconds to milliseconds
try:
l = poller.poll(timeout)
if l is None:
if self.running:
self.stop()
l = [ ]
except select.error, e:
if e[0] == errno.EINTR:
return
else:
raise
_drdw = self._doReadOrWrite
for fd, event in l:
try:
selectable = selectables[fd]
except KeyError:
# Handles the infrequent case where one selectable's
# handler disconnects another.
continue
log.callWithLogger(selectable, _drdw, selectable, fd, event, POLLIN, POLLOUT, log)
doIteration = doPoll
def _doReadOrWrite(self, selectable, fd, event, POLLIN, POLLOUT, log,
faildict={
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost())
}):
why = None
inRead = False
if event & POLL_DISCONNECTED and not (event & POLLIN):
why = main.CONNECTION_LOST
else:
try:
if event & POLLIN:
why = selectable.doRead()
inRead = True
if not why and event & POLLOUT:
why = selectable.doWrite()
inRead = False
if not selectable.fileno() == fd:
why = error.<API key>('Filedescriptor went away')
inRead = False
except:
log.deferr()
why = sys.exc_info()[1]
if why:
self.<API key>(selectable, why, inRead)
def callLater(self, *args, **kwargs):
poller.eApp.interruptPoll()
return posixbase.PosixReactorBase.callLater(self, *args, **kwargs)
def install():
"""Install the poll() reactor."""
p = PollReactor()
main.installReactor(p)
__all__ = ["PollReactor", "install"] |
<html>
<head>
<title>Docs For Class <API key></title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
<tr>
<td class="header_top"><API key></td>
</tr>
<tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr>
<tr>
<td class="header_menu">
[ <a href="../<API key>.html" class="menu">class tree: <API key></a> ]
[ <a href="../<API key>.html" class="menu">index: <API key></a> ]
[ <a href="../elementindex.html" class="menu">all elements</a> ]
</td>
</tr>
<tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt="" /></td></tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="200" class="menu">
<div id="todolist">
<p><a href="../todolist.html">Todo List</a></p>
</div>
<b>Packages:</b><br />
<a href="../li_PHPExcel.html">PHPExcel</a><br />
<a href="../li_JAMA.html">JAMA</a><br />
<a href="../li_Math_Stats.html">Math_Stats</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../li_PHPExcel_Cell.html">PHPExcel_Cell</a><br />
<a href="../li_PHPExcel_Chart.html">PHPExcel_Chart</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../li_PHPExcel_Reader.html">PHPExcel_Reader</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html">PHPExcel_RichText</a><br />
<a href="../<API key>.html">PHPExcel_Settings</a><br />
<a href="../li_PHPExcel_Shared.html">PHPExcel_Shared</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html">PHPExcel_Shared_OLE</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../li_PHPExcel_Style.html">PHPExcel_Style</a><br />
<a href="../<API key>.html">PHPExcel_Worksheet</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../li_PHPExcel_Writer.html">PHPExcel_Writer</a><br />
<a href="../<API key>.html"><API key></a><br />
<a href="../<API key>.html"><API key></a><br />
<br /><br />
<b>Files:</b><br />
<div class="package">
<a href="../<API key>/<API key>.php.html"> bestFitClass.php
</a><br>
<a href="../<API key>/<API key>.php.html"> <API key>.php
</a><br>
<a href="../<API key>/<API key>.php.html"> linearBestFitClass.php
</a><br>
<a href="../<API key>/<API key>.php.html"> <API key>.php
</a><br>
<a href="../<API key>/<API key>.php.html"> <API key>.php
</a><br>
<a href="../<API key>/<API key>.php.html"> powerBestFitClass.php
</a><br>
<a href="../<API key>/<API key>.php.html"> trendClass.php
</a><br>
</div><br />
<b>Classes:</b><br />
<div class="package">
<a href="../<API key>/PHPExcel_Best_Fit.html">PHPExcel_Best_Fit</a><br />
<a href="../<API key>/<API key>.html"><API key></a><br />
<a href="../<API key>/<API key>.html"><API key></a><br />
<a href="../<API key>/<API key>.html"><API key></a><br />
<a href="../<API key>/<API key>.html"><API key></a><br />
<a href="../<API key>/<API key>.html"><API key></a><br />
<a href="../<API key>/trendClass.html">trendClass</a><br />
</div>
</td>
<td>
<table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">
<h1>Class: <API key></h1>
Source Location: /PHPExcel/Shared/trend/powerBestFitClass.php<br /><br />
<table width="100%" border="0">
<tr><td valign="top">
<h3><a href="#class_details">Class Overview</a></h3>
<pre><a href="../<API key>/PHPExcel_Best_Fit.html">PHPExcel_Best_Fit</a>
|
--<API key></pre><br />
<div class="description"><API key></div><br /><br />
<h4>Author(s):</h4>
<ul>
</ul>
<h4>Copyright:</h4>
<ul>
<li>Copyright (c) 2006 - 2012 PHPExcel (http:
</ul>
</td>
<td valign="top">
<h3><a href="#class_vars">Variables</a></h3>
<ul>
<li><a href="../<API key>/<API key>.html#var$_bestFitType">$_bestFitType</a></li>
</ul>
</td>
<td valign="top">
<h3><a href="#class_methods">Methods</a></h3>
<ul>
<li><a href="../<API key>/<API key>.html#method__construct">__construct</a></li>
<li><a href="../<API key>/<API key>.html#methodgetEquation">getEquation</a></li>
<li><a href="../<API key>/<API key>.html#methodgetIntersect">getIntersect</a></li>
<li><a href="../<API key>/<API key>.html#<API key>">getValueOfXForY</a></li>
<li><a href="../<API key>/<API key>.html#<API key>">getValueOfYForX</a></li>
</ul>
</td>
</tr></table>
<hr />
<table width="100%" border="0"><tr>
<td valign="top">
<h3>Inherited Variables</h3>
<div class="tags">
<h4>Class: <a href="../<API key>/PHPExcel_Best_Fit.html">PHPExcel_Best_Fit</a></h4>
<dl>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_adjustToZero">PHPExcel_Best_Fit::$_adjustToZero</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_correlation">PHPExcel_Best_Fit::$_correlation</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_covariance">PHPExcel_Best_Fit::$_covariance</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_DFResiduals">PHPExcel_Best_Fit::$_DFResiduals</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_error">PHPExcel_Best_Fit::$_error</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_F">PHPExcel_Best_Fit::$_F</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_goodnessOfFit">PHPExcel_Best_Fit::$_goodnessOfFit</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_intersect">PHPExcel_Best_Fit::$_intersect</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_intersectSE">PHPExcel_Best_Fit::$_intersectSE</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_slope">PHPExcel_Best_Fit::$_slope</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_slopeSE">PHPExcel_Best_Fit::$_slopeSE</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_SSRegression">PHPExcel_Best_Fit::$_SSRegression</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_SSResiduals">PHPExcel_Best_Fit::$_SSResiduals</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_stdevOfResiduals">PHPExcel_Best_Fit::$_stdevOfResiduals</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_valueCount">PHPExcel_Best_Fit::$_valueCount</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_Xoffset">PHPExcel_Best_Fit::$_Xoffset</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_xValues">PHPExcel_Best_Fit::$_xValues</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_yBestFitValues">PHPExcel_Best_Fit::$_yBestFitValues</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_Yoffset">PHPExcel_Best_Fit::$_Yoffset</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#var$_yValues">PHPExcel_Best_Fit::$_yValues</a>
</dt>
<dd>
</dd>
</dl>
</div>
</td>
<td valign="top">
<h3>Inherited Methods</h3>
<div class="tags">
<h4>Class: <a href="../<API key>/PHPExcel_Best_Fit.html">PHPExcel_Best_Fit</a></h4>
<dl>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#method__construct">PHPExcel_Best_Fit::__construct()</a>
</dt>
<dd>
Define the regression
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getBestFitType()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getCorrelation()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetCovariance">PHPExcel_Best_Fit::getCovariance()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getDFResiduals()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetEquation">PHPExcel_Best_Fit::getEquation()</a>
</dt>
<dd>
Return the Equation of the best-fit line
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetError">PHPExcel_Best_Fit::getError()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetF">PHPExcel_Best_Fit::getF()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getGoodnessOfFit()</a>
</dt>
<dd>
Return the goodness of fit for this regression
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::<API key>()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetIntersect">PHPExcel_Best_Fit::getIntersect()</a>
</dt>
<dd>
Return the Value of X where it intersects Y = 0
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getIntersectSE()</a>
</dt>
<dd>
Return the standard error of the Intersect
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetSlope">PHPExcel_Best_Fit::getSlope()</a>
</dt>
<dd>
Return the Slope of the line
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetSlopeSE">PHPExcel_Best_Fit::getSlopeSE()</a>
</dt>
<dd>
Return the standard error of the Slope
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getSSRegression()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getSSResiduals()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getStdevOfResiduals()</a>
</dt>
<dd>
Return the standard deviation of the residuals for this regression
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getValueOfXForY()</a>
</dt>
<dd>
Return the X-Value for a specified value of Y
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getValueOfYForX()</a>
</dt>
<dd>
Return the Y-Value for a specified value of X
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#methodgetXValues">PHPExcel_Best_Fit::getXValues()</a>
</dt>
<dd>
Return the original set of X-Values
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getYBestFitValues()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::<API key>()</a>
</dt>
<dd>
</dd>
<dt>
<a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::_leastSquareFit()</a>
</dt>
<dd>
</dd>
</dl>
</div>
</td>
</tr></table>
<hr />
<a name="class_details"></a>
<h3>Class Details</h3>
<div class="tags">
[line 39]<br />
<API key><br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>copyright:</b> </td><td>Copyright (c) 2006 - 2012 PHPExcel (http:
</tr>
</table>
</div>
</div><br /><br />
<div class="top">[ <a href="#top">Top</a> ]</div><br />
<hr />
<a name="class_vars"></a>
<h3>Class Variables</h3>
<div class="tags">
<a name="var$_bestFitType"></a>
<p></p>
<h4>$_bestFitType = <span class="value"> 'power'</span></h4>
<p>[line 47]</p>
Algorithm type to use for best-fit (Name of this trend class)<br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>access:</b> </td><td>protected</td>
</tr>
</table>
</div>
<br />
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>Type:</b> </td>
<td>string</td>
</tr>
<tr>
<td><b>Overrides:</b> </td>
<td>Array</td>
</tr>
</table>
</div><br /><br />
<div class="top">[ <a href="#top">Top</a> ]</div><br />
</div><br />
<hr />
<a name="class_methods"></a>
<h3>Class Methods</h3>
<div class="tags">
<hr />
<a name="method__construct"></a>
<h3>constructor __construct <span class="smalllinenumber">[line 136]</span></h3>
<div class="function">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code><API key> __construct(
float[]
$yValues, [float[]
$xValues = array()], [boolean
$const = True])</code>
</td></tr></table>
</td></tr></table><br />
Define the regression and calculate the goodness of fit for a set of X and Y data values<br /><br /><br /><br />
Overrides <a href="../<API key>/PHPExcel_Best_Fit.html#method__construct">PHPExcel_Best_Fit::__construct()</a> (Define the regression)<br /><br />
<h4>Parameters:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="type">float[] </td>
<td><b>$yValues</b> </td>
<td>The set of Y-values for this regression</td>
</tr>
<tr>
<td class="type">float[] </td>
<td><b>$xValues</b> </td>
<td>The set of X-values for this regression</td>
</tr>
<tr>
<td class="type">boolean </td>
<td><b>$const</b> </td>
<td></td>
</tr>
</table>
</div><br />
<div class="top">[ <a href="#top">Top</a> ]</div>
</div>
<hr />
<a name="methodgetEquation"></a>
<h3>method getEquation <span class="smalllinenumber">[line 78]</span></h3>
<div class="function">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>string getEquation(
[int
$dp = 0])</code>
</td></tr></table>
</td></tr></table><br />
Return the Equation of the best-fit line<br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>access:</b> </td><td>public</td>
</tr>
</table>
</div>
<br /><br />
Overrides <a href="../<API key>/PHPExcel_Best_Fit.html#methodgetEquation">PHPExcel_Best_Fit::getEquation()</a> (Return the Equation of the best-fit line)<br /><br />
<h4>Parameters:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="type">int </td>
<td><b>$dp</b> </td>
<td>Number of places of decimal precision to display</td>
</tr>
</table>
</div><br />
<div class="top">[ <a href="#top">Top</a> ]</div>
</div>
<hr />
<a name="methodgetIntersect"></a>
<h3>method getIntersect <span class="smalllinenumber">[line 92]</span></h3>
<div class="function">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>string getIntersect(
[int
$dp = 0])</code>
</td></tr></table>
</td></tr></table><br />
Return the Value of X where it intersects Y = 0<br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>access:</b> </td><td>public</td>
</tr>
</table>
</div>
<br /><br />
Overrides <a href="../<API key>/PHPExcel_Best_Fit.html#methodgetIntersect">PHPExcel_Best_Fit::getIntersect()</a> (Return the Value of X where it intersects Y = 0)<br /><br />
<h4>Parameters:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="type">int </td>
<td><b>$dp</b> </td>
<td>Number of places of decimal precision to display</td>
</tr>
</table>
</div><br />
<div class="top">[ <a href="#top">Top</a> ]</div>
</div>
<hr />
<a name="<API key>"></a>
<h3>method getValueOfXForY <span class="smalllinenumber">[line 67]</span></h3>
<div class="function">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>float getValueOfXForY(
float
$yValue)</code>
</td></tr></table>
</td></tr></table><br />
Return the X-Value for a specified value of Y<br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>return:</b> </td><td>X-Value</td>
</tr>
<tr>
<td><b>access:</b> </td><td>public</td>
</tr>
</table>
</div>
<br /><br />
Overrides <a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getValueOfXForY()</a> (Return the X-Value for a specified value of Y)<br /><br />
<h4>Parameters:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="type">float </td>
<td><b>$yValue</b> </td>
<td>Y-Value</td>
</tr>
</table>
</div><br />
<div class="top">[ <a href="#top">Top</a> ]</div>
</div>
<hr />
<a name="<API key>"></a>
<h3>method getValueOfYForX <span class="smalllinenumber">[line 56]</span></h3>
<div class="function">
<table width="90%" border="0" cellspacing="0" cellpadding="1"><tr><td class="code_border">
<table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td class="code">
<code>float getValueOfYForX(
float
$xValue)</code>
</td></tr></table>
</td></tr></table><br />
Return the Y-Value for a specified value of X<br /><br /><br /><br />
<h4>Tags:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>return:</b> </td><td>Y-Value</td>
</tr>
<tr>
<td><b>access:</b> </td><td>public</td>
</tr>
</table>
</div>
<br /><br />
Overrides <a href="../<API key>/PHPExcel_Best_Fit.html#<API key>">PHPExcel_Best_Fit::getValueOfYForX()</a> (Return the Y-Value for a specified value of X)<br /><br />
<h4>Parameters:</h4>
<div class="tags">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="type">float </td>
<td><b>$xValue</b> </td>
<td>X-Value</td>
</tr>
</table>
</div><br />
<div class="top">[ <a href="#top">Top</a> ]</div>
</div>
</div><br />
<div class="credit">
<hr />
Documentation generated on Fri, 12 Oct 2012 00:17:28 +0200 by <a href="http:
</div>
</td></tr></table>
</td>
</tr>
</table>
</body>
</html> |
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
#include <linux/bitops.h>
#include <linux/gpio.h>
#include <asm/mach-ar71xx/ar71xx.h>
#include <asm/mach-ar71xx/platform.h>
#define DRV_DESC "Atheros AP83 board SPI Controller driver"
#define DRV_VERSION "0.1.0"
#define DRV_NAME "ap83-spi"
#define AP83_SPI_CLK_HIGH (1 << 23)
#define AP83_SPI_CLK_LOW 0
#define AP83_SPI_MOSI_HIGH (1 << 22)
#define AP83_SPI_MOSI_LOW 0
#define AP83_SPI_GPIO_CS 1
#define AP83_SPI_GPIO_MISO 3
struct ap83_spi {
struct spi_bitbang bitbang;
void __iomem *base;
u32 addr;
struct platform_device *pdev;
};
static inline u32 ap83_spi_rr(struct ap83_spi *sp, u32 reg)
{
return __raw_readl(sp->base + reg);
}
static inline struct ap83_spi *spidev_to_sp(struct spi_device *spi)
{
return <API key>(spi->master);
}
static inline void setsck(struct spi_device *spi, int val)
{
struct ap83_spi *sp = spidev_to_sp(spi);
if (val)
sp->addr |= AP83_SPI_CLK_HIGH;
else
sp->addr &= ~AP83_SPI_CLK_HIGH;
dev_dbg(&spi->dev, "addr=%08x, SCK set to %s\n",
sp->addr, (val) ? "HIGH" : "LOW");
ap83_spi_rr(sp, sp->addr);
}
static inline void setmosi(struct spi_device *spi, int val)
{
struct ap83_spi *sp = spidev_to_sp(spi);
if (val)
sp->addr |= AP83_SPI_MOSI_HIGH;
else
sp->addr &= ~AP83_SPI_MOSI_HIGH;
dev_dbg(&spi->dev, "addr=%08x, MOSI set to %s\n",
sp->addr, (val) ? "HIGH" : "LOW");
ap83_spi_rr(sp, sp->addr);
}
static inline u32 getmiso(struct spi_device *spi)
{
u32 ret;
ret = gpio_get_value(AP83_SPI_GPIO_MISO) ? 1 : 0;
dev_dbg(&spi->dev, "get MISO: %d\n", ret);
return ret;
}
static inline void do_spidelay(struct spi_device *spi, unsigned nsecs)
{
ndelay(nsecs);
}
static void ap83_spi_chipselect(struct spi_device *spi, int on)
{
struct ap83_spi *sp = spidev_to_sp(spi);
dev_dbg(&spi->dev, "set CS to %d\n", (on) ? 0 : 1);
if (on) {
<API key>();
sp->addr = 0;
ap83_spi_rr(sp, sp->addr);
gpio_set_value(AP83_SPI_GPIO_CS, 0);
} else {
gpio_set_value(AP83_SPI_GPIO_CS, 1);
<API key>();
}
}
#define spidelay(nsecs) \
do { \
/* Steal the spi_device pointer from our caller. \
* The bitbang-API should probably get fixed here... */ \
do_spidelay(spi, nsecs); \
} while (0)
#define EXPAND_BITBANG_TXRX
#include <linux/spi/spi_bitbang.h>
#include "spi_bitbang_txrx.h"
static u32 ap83_spi_txrx_mode0(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits)
{
dev_dbg(&spi->dev, "TXRX0 word=%08x, bits=%u\n", word, bits);
return <API key>(spi, nsecs, 0, 0, word, bits);
}
static u32 ap83_spi_txrx_mode1(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits)
{
dev_dbg(&spi->dev, "TXRX1 word=%08x, bits=%u\n", word, bits);
return <API key>(spi, nsecs, 0, 0, word, bits);
}
static u32 ap83_spi_txrx_mode2(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits)
{
dev_dbg(&spi->dev, "TXRX2 word=%08x, bits=%u\n", word, bits);
return <API key>(spi, nsecs, 1, 0, word, bits);
}
static u32 ap83_spi_txrx_mode3(struct spi_device *spi,
unsigned nsecs, u32 word, u8 bits)
{
dev_dbg(&spi->dev, "TXRX3 word=%08x, bits=%u\n", word, bits);
return <API key>(spi, nsecs, 1, 0, word, bits);
}
static int ap83_spi_probe(struct platform_device *pdev)
{
struct spi_master *master;
struct ap83_spi *sp;
struct <API key> *pdata;
struct resource *r;
int ret;
ret = gpio_request(AP83_SPI_GPIO_MISO, "spi-miso");
if (ret) {
dev_err(&pdev->dev, "gpio request failed for MISO\n");
return ret;
}
ret = gpio_request(AP83_SPI_GPIO_CS, "spi-cs");
if (ret) {
dev_err(&pdev->dev, "gpio request failed for CS\n");
goto err_free_miso;
}
ret = <API key>(AP83_SPI_GPIO_MISO);
if (ret) {
dev_err(&pdev->dev, "unable to set direction of MISO\n");
goto err_free_cs;
}
ret = <API key>(AP83_SPI_GPIO_CS, 0);
if (ret) {
dev_err(&pdev->dev, "unable to set direction of CS\n");
goto err_free_cs;
}
master = spi_alloc_master(&pdev->dev, sizeof(*sp));
if (master == NULL) {
dev_err(&pdev->dev, "failed to allocate spi master\n");
return -ENOMEM;
}
sp = <API key>(master);
<API key>(pdev, sp);
pdata = pdev->dev.platform_data;
sp->bitbang.master = spi_master_get(master);
sp->bitbang.chipselect = ap83_spi_chipselect;
sp->bitbang.txrx_word[SPI_MODE_0] = ap83_spi_txrx_mode0;
sp->bitbang.txrx_word[SPI_MODE_1] = ap83_spi_txrx_mode1;
sp->bitbang.txrx_word[SPI_MODE_2] = ap83_spi_txrx_mode2;
sp->bitbang.txrx_word[SPI_MODE_3] = ap83_spi_txrx_mode3;
sp->bitbang.master->bus_num = pdev->id;
sp->bitbang.master->num_chipselect = 1;
r = <API key>(pdev, IORESOURCE_MEM, 0);
if (r == NULL) {
ret = -ENOENT;
goto err_spi_put;
}
sp->base = ioremap_nocache(r->start, r->end - r->start + 1);
if (!sp->base) {
ret = -ENXIO;
goto err_spi_put;
}
ret = spi_bitbang_start(&sp->bitbang);
if (!ret)
goto err_unmap;
dev_info(&pdev->dev, "AP83 SPI adapter at %08x\n", r->start);
return 0;
err_unmap:
iounmap(sp->base);
err_spi_put:
<API key>(pdev, NULL);
spi_master_put(sp->bitbang.master);
err_free_cs:
gpio_free(AP83_SPI_GPIO_CS);
err_free_miso:
gpio_free(AP83_SPI_GPIO_MISO);
return ret;
}
static int ap83_spi_remove(struct platform_device *pdev)
{
struct ap83_spi *sp = <API key>(pdev);
spi_bitbang_stop(&sp->bitbang);
iounmap(sp->base);
<API key>(pdev, NULL);
spi_master_put(sp->bitbang.master);
return 0;
}
static struct platform_driver ap83_spi_drv = {
.probe = ap83_spi_probe,
.remove = ap83_spi_remove,
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
},
};
static int __init ap83_spi_init(void)
{
return <API key>(&ap83_spi_drv);
}
module_init(ap83_spi_init);
static void __exit ap83_spi_exit(void)
{
<API key>(&ap83_spi_drv);
}
module_exit(ap83_spi_exit);
MODULE_ALIAS("platform:" DRV_NAME);
MODULE_DESCRIPTION(DRV_DESC);
MODULE_VERSION(DRV_VERSION);
MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
MODULE_LICENSE("GPL v2"); |
/* Contributed by Steve Chamberlain, of Transmeta. sac@pobox.com. */
#define WORKING_DOT_WORD
#define <API key>
#define TARGET_ARCH bfd_arch_pj
#define TARGET_FORMAT (target_big_endian ? "elf32-pj" : "elf32-pjl")
#define LISTING_HEADER \
(target_big_endian \
? "Pico Java GAS Big Endian" \
: "Pico Java GAS Little Endian")
void pj_cons_fix_new_pj (struct frag *, int, int, expressionS *,
<API key>);
arelent *tc_gen_reloc (asection *, struct fix *);
#define md_section_align(SEGMENT, SIZE) (SIZE)
#define md_convert_frag(B, S, F) as_fatal (_("convert_frag\n"))
#define <API key>(A, B) (as_fatal (_("estimate size\n")),0)
#define md_undefined_symbol(NAME) 0
/* PC relative operands are relative to the start of the opcode, and
the operand is always one byte into the opcode. */
#define md_pcrel_from(FIX) \
((FIX)->fx_where + (FIX)->fx_frag->fr_address - 1)
#define TC_CONS_FIX_NEW(FRAG, WHERE, NBYTES, EXP, RELOC) \
pj_cons_fix_new_pj (FRAG, WHERE, NBYTES, EXP, RELOC)
/* No shared lib support, so we don't need to ensure externally
visible symbols can be overridden. */
#define EXTERN_FORCE_RELOC 0
/* Values passed to md_apply_fix don't include the symbol value. */
#define MD_APPLY_SYM_VALUE(FIX) 0
#define tc_fix_adjustable(FIX) \
(! ((FIX)->fx_r_type == <API key> \
|| (FIX)->fx_r_type == <API key>)) |
<?php
defined('_JEXEC') or die();
if (!class_exists('VmMediaHandler')) require(VMPATH_ADMIN.DS.'helpers'.DS.'mediahandler.php');
class VmImage extends VmMediaHandler {
function processAction($data){
if(empty($data['media_action'])) return $data;
$data = parent::processAction($data);
if( $data['media_action'] == 'upload_create_thumb' ){
$oldFileUrl = $this->file_url;
$file_name = $this->uploadFile($this->file_url_folder);
if($file_name){
if($file_name!=$oldFileUrl && !empty($this->filename)){
$this->deleteFile($oldFileUrl);
}
$this->file_url = $this->file_url_folder.$file_name;
$this->filename = $file_name;
$oldFileUrlThumb = $this->file_url_thumb;
$this->file_url_thumb = $this->createThumb();
if($this->file_url_thumb!=$oldFileUrlThumb){
$this->deleteFile($oldFileUrlThumb);
}
}
} //creating the thumbnail image
else if( $data['media_action'] == 'create_thumb' ){
$this->file_url_thumb = $this->createThumb();
}
if(empty($this->file_title) && !empty($file_name)) $this->file_title = $file_name;
return $data;
}
function displayMediaFull($imageArgs='',$lightbox=true,$effect ="class='modal'",$description = true ){
if(!$this->file_is_forSale){
// Remote image URL
if( substr( $this->file_url, 0, 4) == "http" ) {
$file_url = $this->file_url;
$file_alt = $this->file_title;
} else {
$rel_path = str_replace('/',DS,$this->file_url_folder);
$<API key> = VMPATH_ROOT.DS.$rel_path.$this->file_name.'.'.$this->file_extension;
if (!file_exists($<API key>)) {
$file_url = $this->theme_url.'assets/images/vmgeneral/'.VmConfig::get('no_image_found');
$file_alt = vmText::_('<API key>').' '.$this->file_description;
} else {
$file_url = $this->file_url;
$file_alt = $this->file_meta;
}
}
$postText = false;
if($description) $postText = $this->file_description;
if(!empty($this->file_class)){
$imageArgs = $this->filterImageArgs($imageArgs);
}
return $this->displayIt($file_url, $file_alt, $imageArgs,$lightbox,$effect,$postText);
} else {
//Media which should be sold, show them only as thumb (works as preview)
return $this->displayMediaThumb(array('id'=>'vm_display_image'),false);
}
}
public function createThumbFileUrl(){
$file_name = $this->createThumbName();
if(empty($this->file_name_thumb)) {
vmdebug('createThumbFileUrl empty file_name_thumb ',$this);
return false;
}
$file_url_thumb = $this->file_url_folder.'resized/'.$this->file_name_thumb.'.'.$this->file_extension;
return $file_url_thumb;
}
/**
* a small function that ensures that we always build the thumbnail name with the same method
*/
public function createThumbName($width=0,$height=0){
if(empty($this->file_name)) return false;
if(empty($width)) $width = VmConfig::get('img_width', 90);
if(empty($height)) $height = VmConfig::get('img_height', 90);
$this->file_name_thumb = $this->file_name.'_'.$width.'x'.$height;
return $this->file_name_thumb;
}
/**
* This function actually creates the thumb
* and when it is instanciated with one of the getImage function automatically updates the db
*
* @author Max Milbers
* @param boolean $save Execute update function
* @return name of the thumbnail
*/
public function createThumb($width=0,$height=0) {
if(empty($this->file_url_folder)){
vmError('Couldnt create thumb, no directory given. Activate vmdebug to understand which database entry is creating this error');
vmdebug('createThumb, no directory given',$this);
return FALSE;
}
if(empty($this->file_name)){
vmError('Couldnt create thumb, no name given. Activate vmdebug to understand which database entry is creating this error');
vmdebug('createThumb, no name given',$this);
return false;
}
$synchronise = vRequest::getString('synchronise',false);
if(!VmConfig::get('img_resize_enable') || $synchronise) return;
//now lets create the thumbnail, saving is done in this function
if(empty($width)) $width = VmConfig::get('img_width', 90);
if(empty($height)) $height = VmConfig::get('img_height', 90);
// Don't allow sizes beyond 2000 pixels //I dont think that this is good, should be config
// $width = min($width, 2000);
// $height = min($height, 2000);
$maxsize = false;
$bgred = 255;
$bggreen = 255;
$bgblue = 255;
$root = '';
$this->file_name_thumb = $this->createThumbName($width,$height);
if($this->file_is_forSale==0){
$rel_path = str_replace('/',DS,$this->file_url_folder);
$<API key> = VMPATH_ROOT.DS.$rel_path.$this->file_name.'.'.$this->file_extension;
} else {
$<API key> = $this->file_url_folder.$this->file_name.'.'.$this->file_extension;
}
$file_path_thumb = str_replace('/',DS,$this-><API key>);
$resizedFilenamePath = VMPATH_ROOT.DS.$file_path_thumb.$this->file_name_thumb.'.'.$this->file_extension;
$this-><API key>($file_path_thumb);
if (file_exists($<API key>)) {
if (!class_exists('Img2Thumb')) require(VMPATH_ADMIN.DS.'helpers'.DS.'img2thumb.php');
$createdImage = new Img2Thumb($<API key>, (int)$width, (int)$height, $resizedFilenamePath, $maxsize, $bgred, $bggreen, $bgblue);
if($createdImage){
return $this-><API key>.$this->file_name_thumb.'.'.$this->file_extension;
} else {
return 0;
}
} else {
vmError('Couldnt create thumb, file not found '.$<API key>);
return 0;
}
}
public function <API key>($path){
$elements = explode(DS,$path);
$examine = VMPATH_ROOT;
if(!class_exists('JFolder')){
require(VMPATH_LIBS.DS.'joomla'.DS.'filesystem'.DS.'folder.php');
}
foreach($elements as $piece){
$examine = $examine.DS.$piece;
if(!JFolder::exists($examine)){
JFolder::create($examine);
vmInfo('create folder for resized image '.$examine);
}
}
}
/**
* Display an image icon for the given image and create a link to the given link.
*
* @param string $link Link to use in the href tag
* @param string $image Name of the image file to display
* @param string $text Text to use for the image alt text and to display under the image.
*/
static public function displayImageButton($link, $imageclass, $text, $mainclass = 'vmicon48', $extra="") {
$button = '<a title="' . $text . '" href="' . $link . '" '.$extra.'>';
$button .= '<span class="'.$mainclass.' '.$imageclass.'"></span>';
$button .= '<br />' . $text.'</a>';
echo $button;
}
} |
#include <rtthread.h>
#include "spi_flash.h"
#include "spi_flash_sfud.h"
#include "drv_spi.h"
#if defined(BSP_USING_SPI_FLASH)
static int <API key>(void)
{
<API key>();
<API key>("spi2", "spi20", GPIOB, GPIO_PIN_12);
if (RT_NULL == rt_sfud_flash_probe("W25Q16", "spi20"))
{
return -RT_ERROR;
};
return RT_EOK;
}
<API key>(<API key>);
#endif |
+{
locale_version => 1.01,
entry => <<'ENTRY', # for DUCET v6.3.0
0101 ; [.15EB.001C.0002] # LATIN SMALL LETTER A WITH MACRON
0061 0304 ; [.15EB.001C.0002] # LATIN SMALL LETTER A WITH MACRON
0100 ; [.15EB.001C.0008] # LATIN CAPITAL LETTER A WITH MACRON
0041 0304 ; [.15EB.001C.0008] # LATIN CAPITAL LETTER A WITH MACRON
00E1 ; [.15EB.001D.0002] # LATIN SMALL LETTER A WITH ACUTE
0061 0301 ; [.15EB.001D.0002] # LATIN SMALL LETTER A WITH ACUTE
0061 0341 ; [.15EB.001D.0002] # LATIN SMALL LETTER A WITH ACUTE
00C1 ; [.15EB.001D.0008] # LATIN CAPITAL LETTER A WITH ACUTE
0041 0301 ; [.15EB.001D.0008] # LATIN CAPITAL LETTER A WITH ACUTE
0041 0341 ; [.15EB.001D.0008] # LATIN CAPITAL LETTER A WITH ACUTE
01CE ; [.15EB.001E.0002] # LATIN SMALL LETTER A WITH CARON
0061 030C ; [.15EB.001E.0002] # LATIN SMALL LETTER A WITH CARON
01CD ; [.15EB.001E.0008] # LATIN CAPITAL LETTER A WITH CARON
0041 030C ; [.15EB.001E.0008] # LATIN CAPITAL LETTER A WITH CARON
00E0 ; [.15EB.001F.0002] # LATIN SMALL LETTER A WITH GRAVE
0061 0300 ; [.15EB.001F.0002] # LATIN SMALL LETTER A WITH GRAVE
0061 0340 ; [.15EB.001F.0002] # LATIN SMALL LETTER A WITH GRAVE
00C0 ; [.15EB.001F.0008] # LATIN CAPITAL LETTER A WITH GRAVE
0041 0300 ; [.15EB.001F.0008] # LATIN CAPITAL LETTER A WITH GRAVE
0041 0340 ; [.15EB.001F.0008] # LATIN CAPITAL LETTER A WITH GRAVE
0113 ; [.1648.001C.0002] # LATIN SMALL LETTER E WITH MACRON
0065 0304 ; [.1648.001C.0002] # LATIN SMALL LETTER E WITH MACRON
0112 ; [.1648.001C.0008] # LATIN CAPITAL LETTER E WITH MACRON
0045 0304 ; [.1648.001C.0008] # LATIN CAPITAL LETTER E WITH MACRON
00E9 ; [.1648.001D.0002] # LATIN SMALL LETTER E WITH ACUTE
0065 0301 ; [.1648.001D.0002] # LATIN SMALL LETTER E WITH ACUTE
0065 0341 ; [.1648.001D.0002] # LATIN SMALL LETTER E WITH ACUTE
00C9 ; [.1648.001D.0008] # LATIN CAPITAL LETTER E WITH ACUTE
0045 0301 ; [.1648.001D.0008] # LATIN CAPITAL LETTER E WITH ACUTE
0045 0341 ; [.1648.001D.0008] # LATIN CAPITAL LETTER E WITH ACUTE
011B ; [.1648.001E.0002] # LATIN SMALL LETTER E WITH CARON
0065 030C ; [.1648.001E.0002] # LATIN SMALL LETTER E WITH CARON
011A ; [.1648.001E.0008] # LATIN CAPITAL LETTER E WITH CARON
0045 030C ; [.1648.001E.0008] # LATIN CAPITAL LETTER E WITH CARON
00E8 ; [.1648.001F.0002] # LATIN SMALL LETTER E WITH GRAVE
0065 0300 ; [.1648.001F.0002] # LATIN SMALL LETTER E WITH GRAVE
0065 0340 ; [.1648.001F.0002] # LATIN SMALL LETTER E WITH GRAVE
00C8 ; [.1648.001F.0008] # LATIN CAPITAL LETTER E WITH GRAVE
0045 0300 ; [.1648.001F.0008] # LATIN CAPITAL LETTER E WITH GRAVE
0045 0340 ; [.1648.001F.0008] # LATIN CAPITAL LETTER E WITH GRAVE
00EA 0304 ; [.1648.0021.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING MACRON>
00CA 0304 ; [.1648.0021.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING MACRON>
0065 0302 0304 ; [.1648.0021.0002] # <LATIN SMALL LETTER E, COMBINING CIRCUMFLEX ACCENT, COMBINING MACRON>
0045 0302 0304 ; [.1648.0021.0008] # <LATIN CAPITAL LETTER E, COMBINING CIRCUMFLEX ACCENT, COMBINING MACRON>
1EBF ; [.1648.0022.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE
0065 0302 0301 ; [.1648.0022.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE
0065 0302 0341 ; [.1648.0022.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE
1EBE ; [.1648.0022.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE
0045 0302 0301 ; [.1648.0022.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE
0045 0302 0341 ; [.1648.0022.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE
00EA 0301 ; [.1648.0022.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING ACUTE ACCENT>
00EA 0341 ; [.1648.0022.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING ACUTE TONE MARK>
00CA 0301 ; [.1648.0022.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING ACUTE ACCENT>
00CA 0341 ; [.1648.0022.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING ACUTE TONE MARK>
00EA 030C ; [.1648.0023.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING CARON>
00CA 030C ; [.1648.0023.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING CARON>
0065 0302 030C ; [.1648.0023.0002] # <LATIN SMALL LETTER E, COMBINING CIRCUMFLEX ACCENT, COMBINING CARON>
0045 0302 030C ; [.1648.0023.0008] # <LATIN CAPITAL LETTER E, COMBINING CIRCUMFLEX ACCENT, COMBINING CARON>
1EC1 ; [.1648.0024.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE
0065 0302 0300 ; [.1648.0024.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE
0065 0302 0340 ; [.1648.0024.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE
1EC0 ; [.1648.0024.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE
0045 0302 0300 ; [.1648.0024.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE
0045 0302 0340 ; [.1648.0024.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE
00EA 0300 ; [.1648.0024.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING GRAVE ACCENT>
00EA 0340 ; [.1648.0024.0002] # <LATIN SMALL LETTER E WITH CIRCUMFLEX, COMBINING GRAVE TONE MARK>
00CA 0300 ; [.1648.0024.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING GRAVE ACCENT>
00CA 0340 ; [.1648.0024.0008] # <LATIN CAPITAL LETTER E WITH CIRCUMFLEX, COMBINING GRAVE TONE MARK>
00EA ; [.1648.0025.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX
0065 0302 ; [.1648.0025.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX
00CA ; [.1648.0025.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
0045 0302 ; [.1648.0025.0008] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
1EC5 ; [.1648.0025.0002][.0000.002D.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE
1EC4 ; [.1648.0025.0008][.0000.002D.0002] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE
1EC3 ; [.1648.0025.0002][.0000.003B.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE
1EC2 ; [.1648.0025.0008][.0000.003B.0002] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE
1EC7 ; [.1648.0025.0002][.0000.0042.0002] # LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW
1EC6 ; [.1648.0025.0008][.0000.0042.0002] # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW
012B ; [.16C9.001C.0002] # LATIN SMALL LETTER I WITH MACRON
0069 0304 ; [.16C9.001C.0002] # LATIN SMALL LETTER I WITH MACRON
012A ; [.16C9.001C.0008] # LATIN CAPITAL LETTER I WITH MACRON
0049 0304 ; [.16C9.001C.0008] # LATIN CAPITAL LETTER I WITH MACRON
00ED ; [.16C9.001D.0002] # LATIN SMALL LETTER I WITH ACUTE
0069 0301 ; [.16C9.001D.0002] # LATIN SMALL LETTER I WITH ACUTE
0069 0341 ; [.16C9.001D.0002] # LATIN SMALL LETTER I WITH ACUTE
00CD ; [.16C9.001D.0008] # LATIN CAPITAL LETTER I WITH ACUTE
0049 0301 ; [.16C9.001D.0008] # LATIN CAPITAL LETTER I WITH ACUTE
0049 0341 ; [.16C9.001D.0008] # LATIN CAPITAL LETTER I WITH ACUTE
01D0 ; [.16C9.001E.0002] # LATIN SMALL LETTER I WITH CARON
0069 030C ; [.16C9.001E.0002] # LATIN SMALL LETTER I WITH CARON
01CF ; [.16C9.001E.0008] # LATIN CAPITAL LETTER I WITH CARON
0049 030C ; [.16C9.001E.0008] # LATIN CAPITAL LETTER I WITH CARON
00EC ; [.16C9.001F.0002] # LATIN SMALL LETTER I WITH GRAVE
0069 0300 ; [.16C9.001F.0002] # LATIN SMALL LETTER I WITH GRAVE
0069 0340 ; [.16C9.001F.0002] # LATIN SMALL LETTER I WITH GRAVE
00CC ; [.16C9.001F.0008] # LATIN CAPITAL LETTER I WITH GRAVE
0049 0300 ; [.16C9.001F.0008] # LATIN CAPITAL LETTER I WITH GRAVE
0049 0340 ; [.16C9.001F.0008] # LATIN CAPITAL LETTER I WITH GRAVE
006D 0304 ; [.173D.001C.0002] # <LATIN SMALL LETTER M, COMBINING MACRON>
004D 0304 ; [.173D.001C.0008] # <LATIN CAPITAL LETTER M, COMBINING MACRON>
1E3F ; [.173D.001D.0002] # LATIN SMALL LETTER M WITH ACUTE
006D 0301 ; [.173D.001D.0002] # LATIN SMALL LETTER M WITH ACUTE
006D 0341 ; [.173D.001D.0002] # LATIN SMALL LETTER M WITH ACUTE
1E3E ; [.173D.001D.0008] # LATIN CAPITAL LETTER M WITH ACUTE
004D 0301 ; [.173D.001D.0008] # LATIN CAPITAL LETTER M WITH ACUTE
004D 0341 ; [.173D.001D.0008] # LATIN CAPITAL LETTER M WITH ACUTE
006D 030C ; [.173D.001E.0002] # <LATIN SMALL LETTER M, COMBINING CARON>
004D 030C ; [.173D.001E.0008] # <LATIN CAPITAL LETTER M, COMBINING CARON>
006D 0300 ; [.173D.001F.0002] # <LATIN SMALL LETTER M, COMBINING GRAVE ACCENT>
006D 0340 ; [.173D.001F.0002] # <LATIN SMALL LETTER M, COMBINING GRAVE TONE MARK>
004D 0300 ; [.173D.001F.0008] # <LATIN CAPITAL LETTER M, COMBINING GRAVE ACCENT>
004D 0340 ; [.173D.001F.0008] # <LATIN CAPITAL LETTER M, COMBINING GRAVE TONE MARK>
006E 0304 ; [.174B.001C.0002] # <LATIN SMALL LETTER N, COMBINING MACRON>
004E 0304 ; [.174B.001C.0008] # <LATIN CAPITAL LETTER N, COMBINING MACRON>
0144 ; [.174B.001D.0002] # LATIN SMALL LETTER N WITH ACUTE
006E 0301 ; [.174B.001D.0002] # LATIN SMALL LETTER N WITH ACUTE
006E 0341 ; [.174B.001D.0002] # LATIN SMALL LETTER N WITH ACUTE
0143 ; [.174B.001D.0008] # LATIN CAPITAL LETTER N WITH ACUTE
004E 0301 ; [.174B.001D.0008] # LATIN CAPITAL LETTER N WITH ACUTE
004E 0341 ; [.174B.001D.0008] # LATIN CAPITAL LETTER N WITH ACUTE
0148 ; [.174B.001E.0002] # LATIN SMALL LETTER N WITH CARON
006E 030C ; [.174B.001E.0002] # LATIN SMALL LETTER N WITH CARON
0147 ; [.174B.001E.0008] # LATIN CAPITAL LETTER N WITH CARON
004E 030C ; [.174B.001E.0008] # LATIN CAPITAL LETTER N WITH CARON
01F9 ; [.174B.001F.0002] # LATIN SMALL LETTER N WITH GRAVE
006E 0300 ; [.174B.001F.0002] # LATIN SMALL LETTER N WITH GRAVE
006E 0340 ; [.174B.001F.0002] # LATIN SMALL LETTER N WITH GRAVE
01F8 ; [.174B.001F.0008] # LATIN CAPITAL LETTER N WITH GRAVE
004E 0300 ; [.174B.001F.0008] # LATIN CAPITAL LETTER N WITH GRAVE
004E 0340 ; [.174B.001F.0008] # LATIN CAPITAL LETTER N WITH GRAVE
014D ; [.176D.001C.0002] # LATIN SMALL LETTER O WITH MACRON
006F 0304 ; [.176D.001C.0002] # LATIN SMALL LETTER O WITH MACRON
014C ; [.176D.001C.0008] # LATIN CAPITAL LETTER O WITH MACRON
004F 0304 ; [.176D.001C.0008] # LATIN CAPITAL LETTER O WITH MACRON
00F3 ; [.176D.001D.0002] # LATIN SMALL LETTER O WITH ACUTE
006F 0301 ; [.176D.001D.0002] # LATIN SMALL LETTER O WITH ACUTE
006F 0341 ; [.176D.001D.0002] # LATIN SMALL LETTER O WITH ACUTE
00D3 ; [.176D.001D.0008] # LATIN CAPITAL LETTER O WITH ACUTE
004F 0301 ; [.176D.001D.0008] # LATIN CAPITAL LETTER O WITH ACUTE
004F 0341 ; [.176D.001D.0008] # LATIN CAPITAL LETTER O WITH ACUTE
01D2 ; [.176D.001E.0002] # LATIN SMALL LETTER O WITH CARON
006F 030C ; [.176D.001E.0002] # LATIN SMALL LETTER O WITH CARON
01D1 ; [.176D.001E.0008] # LATIN CAPITAL LETTER O WITH CARON
004F 030C ; [.176D.001E.0008] # LATIN CAPITAL LETTER O WITH CARON
00F2 ; [.176D.001F.0002] # LATIN SMALL LETTER O WITH GRAVE
006F 0300 ; [.176D.001F.0002] # LATIN SMALL LETTER O WITH GRAVE
006F 0340 ; [.176D.001F.0002] # LATIN SMALL LETTER O WITH GRAVE
00D2 ; [.176D.001F.0008] # LATIN CAPITAL LETTER O WITH GRAVE
004F 0300 ; [.176D.001F.0008] # LATIN CAPITAL LETTER O WITH GRAVE
004F 0340 ; [.176D.001F.0008] # LATIN CAPITAL LETTER O WITH GRAVE
016B ; [.1832.001C.0002] # LATIN SMALL LETTER U WITH MACRON
0075 0304 ; [.1832.001C.0002] # LATIN SMALL LETTER U WITH MACRON
016A ; [.1832.001C.0008] # LATIN CAPITAL LETTER U WITH MACRON
0055 0304 ; [.1832.001C.0008] # LATIN CAPITAL LETTER U WITH MACRON
00FA ; [.1832.001D.0002] # LATIN SMALL LETTER U WITH ACUTE
0075 0301 ; [.1832.001D.0002] # LATIN SMALL LETTER U WITH ACUTE
0075 0341 ; [.1832.001D.0002] # LATIN SMALL LETTER U WITH ACUTE
00DA ; [.1832.001D.0008] # LATIN CAPITAL LETTER U WITH ACUTE
0055 0301 ; [.1832.001D.0008] # LATIN CAPITAL LETTER U WITH ACUTE
0055 0341 ; [.1832.001D.0008] # LATIN CAPITAL LETTER U WITH ACUTE
01D4 ; [.1832.001E.0002] # LATIN SMALL LETTER U WITH CARON
0075 030C ; [.1832.001E.0002] # LATIN SMALL LETTER U WITH CARON
01D3 ; [.1832.001E.0008] # LATIN CAPITAL LETTER U WITH CARON
0055 030C ; [.1832.001E.0008] # LATIN CAPITAL LETTER U WITH CARON
00F9 ; [.1832.001F.0002] # LATIN SMALL LETTER U WITH GRAVE
0075 0300 ; [.1832.001F.0002] # LATIN SMALL LETTER U WITH GRAVE
0075 0340 ; [.1832.001F.0002] # LATIN SMALL LETTER U WITH GRAVE
00D9 ; [.1832.001F.0008] # LATIN CAPITAL LETTER U WITH GRAVE
0055 0300 ; [.1832.001F.0008] # LATIN CAPITAL LETTER U WITH GRAVE
0055 0340 ; [.1832.001F.0008] # LATIN CAPITAL LETTER U WITH GRAVE
01D6 ; [.1832.0021.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND MACRON
0075 0308 0304 ; [.1832.0021.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND MACRON
01D5 ; [.1832.0021.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON
0055 0308 0304 ; [.1832.0021.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON
00FC 0304 ; [.1832.0021.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING MACRON>
00DC 0304 ; [.1832.0021.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING MACRON>
01D8 ; [.1832.0022.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE
0075 0308 0301 ; [.1832.0022.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE
0075 0308 0341 ; [.1832.0022.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE
01D7 ; [.1832.0022.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE
0055 0308 0301 ; [.1832.0022.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE
0055 0308 0341 ; [.1832.0022.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE
00FC 0301 ; [.1832.0022.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING ACUTE ACCENT>
00FC 0341 ; [.1832.0022.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING ACUTE TONE MARK>
00DC 0301 ; [.1832.0022.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING ACUTE ACCENT>
00DC 0341 ; [.1832.0022.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING ACUTE TONE MARK>
01DA ; [.1832.0023.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND CARON
0075 0308 030C ; [.1832.0023.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND CARON
01D9 ; [.1832.0023.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON
0055 0308 030C ; [.1832.0023.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON
00FC 030C ; [.1832.0023.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING CARON>
00DC 030C ; [.1832.0023.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING CARON>
01DC ; [.1832.0024.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE
0075 0308 0300 ; [.1832.0024.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE
0075 0308 0340 ; [.1832.0024.0002] # LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE
01DB ; [.1832.0024.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE
0055 0308 0300 ; [.1832.0024.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE
0055 0308 0340 ; [.1832.0024.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE
00FC 0300 ; [.1832.0024.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING GRAVE ACCENT>
00FC 0340 ; [.1832.0024.0002] # <LATIN SMALL LETTER U WITH DIAERESIS, COMBINING GRAVE TONE MARK>
00DC 0300 ; [.1832.0024.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING GRAVE ACCENT>
00DC 0340 ; [.1832.0024.0008] # <LATIN CAPITAL LETTER U WITH DIAERESIS, COMBINING GRAVE TONE MARK>
00FC ; [.1832.0025.0002] # LATIN SMALL LETTER U WITH DIAERESIS
0075 0308 ; [.1832.0025.0002] # LATIN SMALL LETTER U WITH DIAERESIS
00DC ; [.1832.0025.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS
0055 0308 ; [.1832.0025.0008] # LATIN CAPITAL LETTER U WITH DIAERESIS
ENTRY
}; |
@font-face {
font-family: 'PTSansNarrowRegular';
src: url('PTN57F-webfont.eot');
src: url('PTN57F-webfont.eot?iefix') format('eot'),
url('PTN57F-webfont.woff') format('woff'),
url('PTN57F-webfont.ttf') format('truetype'),
url('PTN57F-webfont.svg#webfont3yLmuNsx') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansCaptionBold';
src: url('PTC75F-webfont.eot');
src: url('PTC75F-webfont.eot?iefix') format('eot'),
url('PTC75F-webfont.woff') format('woff'),
url('PTC75F-webfont.ttf') format('truetype'),
url('PTC75F-webfont.svg#webfontD2GEemFT') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: '<API key>';
src: url('PTC55F-webfont.eot');
src: url('PTC55F-webfont.eot?iefix') format('eot'),
url('PTC55F-webfont.woff') format('woff'),
url('PTC55F-webfont.ttf') format('truetype'),
url('PTC55F-webfont.svg#webfontYACgh6Fk') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansBoldItalic';
src: url('PTS76F-webfont.eot');
src: url('PTS76F-webfont.eot?iefix') format('eot'),
url('PTS76F-webfont.woff') format('woff'),
url('PTS76F-webfont.ttf') format('truetype'),
url('PTS76F-webfont.svg#webfontnHhDPJvF') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansBold';
src: url('PTS75F-webfont.eot');
src: url('PTS75F-webfont.eot?iefix') format('eot'),
url('PTS75F-webfont.woff') format('woff'),
url('PTS75F-webfont.ttf') format('truetype'),
url('PTS75F-webfont.svg#webfontO0AL69VA') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansItalic';
src: url('PTS56F-webfont.eot');
src: url('PTS56F-webfont.eot?iefix') format('eot'),
url('PTS56F-webfont.woff') format('woff'),
url('PTS56F-webfont.ttf') format('truetype'),
url('PTS56F-webfont.svg#webfontb3pcLB5e') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansRegular';
src: url('PTS55F-webfont.eot');
src: url('PTS55F-webfont.eot?iefix') format('eot'),
url('PTS55F-webfont.woff') format('woff'),
url('PTS55F-webfont.ttf') format('truetype'),
url('PTS55F-webfont.svg#webfontVOUaMV4S') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'PTSansNarrowBold';
src: url('PTN77F-webfont.eot');
src: url('PTN77F-webfont.eot?iefix') format('eot'),
url('PTN77F-webfont.woff') format('woff'),
url('PTN77F-webfont.ttf') format('truetype'),
url('PTN77F-webfont.svg#webfont2z2OKawW') format('svg');
font-weight: normal;
font-style: normal;
} |
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/leds-lp55xx.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/sysfs_helpers.h>
#include "leds-lp55xx-common.h"
#define <API key> 32
#define LP5562_MAX_LEDS 4
/* Registers */
#define LP5562_REG_ENABLE 0x00
#define LP5562_REG_OP_MODE 0x01
#define LP5562_REG_R_PWM 0x04
#define LP5562_REG_G_PWM 0x03
#define LP5562_REG_B_PWM 0x02
#define LP5562_REG_W_PWM 0x0E
#define <API key> 0x07
#define <API key> 0x06
#define <API key> 0x05
#define <API key> 0x0F
#define LP5562_REG_CONFIG 0x08
#define LP5562_REG_RESET 0x0D
#define <API key> 0x10
#define <API key> 0x30
#define <API key> 0x50
#define LP5562_REG_ENG_SEL 0x70
/* Bits in ENABLE register */
#define <API key> 0x40 /* Chip master enable */
#define <API key> 0x80 /* Logarithmic PWM adjustment */
#define LP5562_EXEC_RUN 0x2A
#define <API key> \
(<API key> | <API key>)
#define <API key> \
(<API key> | LP5562_EXEC_RUN)
/* Reset register value */
#define LP5562_RESET 0xFF
/* CONFIG register */
#define LP5562_DEFAULT_CFG \
(LP5562_PWM_HF | LP5562_PWRSAVE_EN | LP5562_CLK_INT)
/* Program Commands */
#define CMD_SET_PWM 0x40
#define CMD_WAIT_LSB 0x00
#define LP5562_CMD_DISABLE 0x00
#define LP5562_CMD_LOAD 0x15
#define LP5562_CMD_RUN 0x2A
#define LP5562_CMD_DIRECT 0x3F
#define MAX_BLINK_TIME 60000 /* 60 sec */
#define LP5562_ENG_SEL_PWM 0
#define LP5562_ENG_SEL_RGB 0x1B /* R:ENG1, G:ENG2, B:ENG3 */
#define LP5562_PATTERN_OFF 0
#define SEC_LED_SPECIFIC
/*#define LED_DEEP_DEBUG*/
#ifdef SEC_LED_SPECIFIC
extern struct class *sec_class;
static struct device *led_dev;
/*path : /sys/class/sec/led/led_pattern*/
/*path : /sys/class/sec/led/led_blink*/
/*path : /sys/class/sec/led/led_brightness*/
/*path : /sys/class/leds/led_r/brightness*/
/*path : /sys/class/leds/led_g/brightness*/
/*path : /sys/class/leds/led_b/brightness*/
#endif
struct lp55xx_chip *g_chip;
static u8 LED_DYNAMIC_CURRENT = 0x28;
static u8 LED_LOWPOWER_MODE = 0x0;
enum lp5562_wait_type {
<API key>,
LP5562_CYCLE_50ms,
LP5562_CYCLE_100ms,
LP5562_CYCLE_200ms,
LP5562_CYCLE_500ms,
LP5562_CYCLE_700ms,
LP5562_CYCLE_920ms,
LP5562_CYCLE_982ms,
LP5562_CYCLE_MAX,
};
struct lp5562_wait_param {
unsigned cycle;
unsigned limit;
u8 cmd;
};
enum colour_channel {
RED = 0,
GREEN = 1,
BLUE = 2
};
struct lp5562_pattern_data {
u8 r[<API key>];
u8 g[<API key>];
u8 b[<API key>];
unsigned pc_r;
unsigned pc_g;
unsigned pc_b;
};
static struct leds_control {
u8 current_low;
u8 current_high;
int blink_retention;
int blink_delay;
bool blink_fading;
int fade_in_time;
int fade_out_time;
u8 r;
u8 g;
u8 b;
} ledc = {
.current_low = 5,
.current_high = 40,
.blink_retention = 350,
.blink_delay = 3250,
.blink_fading = true,
.fade_in_time = 300,
.fade_out_time = 1300,
.r = 0,
.g = 0,
.b = 254,
};
static const struct lp5562_wait_param lp5562_wait_cycle[LP5562_CYCLE_MAX] = {
[LP5562_CYCLE_50ms] = {
.cycle = 50,
.limit = 3000,
.cmd = 0x43,
},
[LP5562_CYCLE_100ms] = {
.cycle = 100,
.limit = 6000,
.cmd = 0x46,
},
[LP5562_CYCLE_200ms] = {
.cycle = 200,
.limit = 10000,
.cmd = 0x4d,
},
[LP5562_CYCLE_500ms] = {
.cycle = 500,
.limit = 30000,
.cmd = 0x60,
},
[LP5562_CYCLE_700ms] = {
.cycle = 700,
.limit = 40000,
.cmd = 0x6d,
},
[LP5562_CYCLE_920ms] = {
.cycle = 920,
.limit = 50000,
.cmd = 0x7b,
},
[LP5562_CYCLE_982ms] = {
.cycle = 982,
.limit = 60000,
.cmd = 0x7f,
},
};
static inline void <API key>(void)
{
/* operation mode change needs to be longer than 153 us */
usleep_range(200, 300);
}
static inline void <API key>(void)
{
/* it takes more 488 us to update ENABLE register */
usleep_range(500, 600);
}
static void <API key>(struct lp55xx_led *led, u8 led_current)
{
u8 addr[] = {
<API key>,
<API key>,
<API key>,
<API key>,
};
led->led_current = led_current;
lp55xx_write(led->chip, addr[led->chan_nr], led_current);
}
static int <API key>(struct lp55xx_chip *chip)
{
int ret;
u8 update_cfg = chip->pdata->update_config ? : LP5562_DEFAULT_CFG;
/* Set all PWMs to direct control mode */
ret = lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT);
if (ret)
return ret;
<API key>();
ret = lp55xx_write(chip, LP5562_REG_CONFIG, update_cfg);
if (ret)
return ret;
/* Initialize all channels PWM to zero -> leds off */
lp55xx_write(chip, LP5562_REG_R_PWM, 0);
lp55xx_write(chip, LP5562_REG_G_PWM, 0);
lp55xx_write(chip, LP5562_REG_B_PWM, 0);
lp55xx_write(chip, LP5562_REG_W_PWM, 0);
/* Set engines are set to run state when OP_MODE enables engines */
ret = lp55xx_write(chip, LP5562_REG_ENABLE, <API key>);
if (ret)
return ret;
<API key>();
/* Set LED map as register PWM by default */
lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_PWM);
return 0;
}
static void <API key>(struct work_struct *work)
{
struct lp55xx_led *led = container_of(work, struct lp55xx_led,
brightness_work);
struct lp55xx_chip *chip = led->chip;
u8 addr[] = {
LP5562_REG_R_PWM,
LP5562_REG_G_PWM,
LP5562_REG_B_PWM,
LP5562_REG_W_PWM,
};
mutex_lock(&chip->lock);
lp55xx_write(chip, addr[led->chan_nr], led->brightness);
mutex_unlock(&chip->lock);
}
static void lp5562_stop_engine(struct lp55xx_chip *chip)
{
lp55xx_write(chip, LP5562_REG_OP_MODE, 0);
<API key>();
lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_PWM);
}
static enum lp5562_wait_type lp5562_lookup_cycle(unsigned int ms)
{
int i;
for (i = LP5562_CYCLE_50ms; i < LP5562_CYCLE_MAX; i++) {
if (ms > lp5562_wait_cycle[i-1].limit &&
ms <= lp5562_wait_cycle[i].limit)
return i;
}
return <API key>;
}
static void lp5562_set_wait_cmd(struct lp5562_pattern_data *ptn,
unsigned int ms, u8 jump)
{
enum lp5562_wait_type type = lp5562_lookup_cycle(ms);
unsigned int loop = ms / lp5562_wait_cycle[type].cycle;
u8 cmd_msb = lp5562_wait_cycle[type].cmd;
u8 msb;
u8 lsb;
u16 branch;
WARN_ON(!cmd_msb);
WARN_ON(loop > 64);
/* wait command */
ptn->r[ptn->pc_r++] = cmd_msb;
ptn->r[ptn->pc_r++] = CMD_WAIT_LSB;
ptn->g[ptn->pc_g++] = cmd_msb;
ptn->g[ptn->pc_g++] = CMD_WAIT_LSB;
ptn->b[ptn->pc_b++] = cmd_msb;
ptn->b[ptn->pc_b++] = CMD_WAIT_LSB;
/* branch command : if wait time is bigger than cycle msec,
branch is used for command looping */
if (loop > 1) {
branch = (5 << 13) | ((loop - 1) << 7) | jump;
msb = (branch >> 8) & 0xFF;
lsb = branch & 0xFF;
ptn->r[ptn->pc_r++] = msb;
ptn->r[ptn->pc_r++] = lsb;
ptn->g[ptn->pc_g++] = msb;
ptn->g[ptn->pc_g++] = lsb;
ptn->b[ptn->pc_b++] = msb;
ptn->b[ptn->pc_b++] = lsb;
}
}
static unsigned int lp5562_get_pc(struct lp5562_pattern_data *ptn,
enum colour_channel i)
{
if (i == RED) {
return ptn->pc_r / 2;
} else if (i == GREEN) {
return ptn->pc_g / 2;
} else {
return ptn->pc_b / 2;
}
}
static void <API key>(struct lp5562_pattern_data *ptn,
enum colour_channel i, u8 msb, u8 lsb)
{
if (i == RED) {
ptn->r[ptn->pc_r++] = msb;
ptn->r[ptn->pc_r++] = lsb;
} else if (i == GREEN) {
ptn->g[ptn->pc_g++] = msb;
ptn->g[ptn->pc_g++] = lsb;
} else {
ptn->b[ptn->pc_b++] = msb;
ptn->b[ptn->pc_b++] = lsb;
}
}
static void <API key>(struct lp5562_pattern_data *ptn,
enum colour_channel i,
unsigned int engines, bool wait)
{
unsigned int trigger;
u8 msb, lsb;
trigger = 0xE000 | engines << (wait ? 7 : 1);
msb = (trigger >> 8) & 0xFF;
lsb = trigger & 0xFF;
<API key>(ptn, i, msb, lsb);
}
static void <API key>(struct lp5562_pattern_data *ptn,
enum colour_channel i, bool prescale,
unsigned int steps)
{
u8 msb = 0, lsb = 0, jump;
unsigned int loop = steps / 63;
u16 branch;
WARN_ON(loop > 64);
if (loop > 0) {
jump = lp5562_get_pc(ptn, i);
msb = (prescale << 6) | 63;
<API key>(ptn, i, msb, 0);
--loop;
steps -= 63;
}
if (loop > 0) {
branch = (5 << 13) | (loop << 7) | jump;
msb = (branch >> 8) & 0xFF;
lsb = branch & 0xFF;
<API key>(ptn, i, msb, lsb);
steps -= loop * 63;
}
if (steps) {
msb = (prescale << 6) | (steps & 63);
<API key>(ptn, i, msb, 0);
}
}
static void <API key>(struct lp5562_pattern_data *ptn,
unsigned int ms)
{
unsigned int steps;
bool prescale;
ms *= 100000;
if (ms <= 3087000) {
prescale = false;
steps = ms / 49000;
} else {
prescale = true;
steps = ms / 1560000;
}
<API key>(ptn, RED, (1 << GREEN), true);
<API key>(ptn, BLUE, (1 << GREEN), true);
<API key>(ptn, GREEN, prescale, steps);
<API key>(ptn, GREEN, (1 << RED) | (1 << BLUE), false);
}
static void <API key>(unsigned int color, u8 *r, u8 *g, u8 *b)
{
*r = ((color >> 16) & 0xFE) / 2;
*g = ((color >> 8) & 0xFE) / 2;
*b = (color & 0xFE) / 2;
}
#define rgb_to_hex(r, g, b) ((r << 16) | (g << 8) | b)
static unsigned int <API key>(unsigned int color)
{
u8 r = 0, g = 0, b = 0;
<API key>(color, &r, &g, &b);
return rgb_to_hex(r, g, b);
}
static void lp5562_set_ramp_cmd(struct lp5562_pattern_data *ptn,
unsigned int color, unsigned int ms, bool rise)
{
u8 msb = 0, lsb = 0, step_time, maxval, minval;
bool prescale;
u8 rgb[3];
unsigned int ramp_time[3];
int i, trailing = 0;
<API key>(color, &rgb[RED], &rgb[GREEN], &rgb[BLUE]);
for (i = RED; i <= BLUE; i++) {
if (rgb[i] != 0) {
prescale = false;
step_time = ms / ((rgb[i] * 490) / 1000);
ramp_time[i] = step_time * (prescale ? 15600 : 490) * rgb[i];
/* Ramp command */
msb = (prescale << 14) | (step_time & ~0xC0);
lsb = !rise << 7;
lsb |= rgb[i] & ~0x80;
<API key>(ptn, i, msb, lsb);
}
}
maxval = max(ramp_time[RED], max(ramp_time[GREEN], ramp_time[BLUE]));
minval = min(ramp_time[RED], min(ramp_time[GREEN], ramp_time[BLUE]));
if (maxval == minval)
return;
for (i = RED; i <= BLUE; i++) {
if (ramp_time[i] == maxval) {
trailing = i;
break;
}
}
for (i = RED; i <= BLUE; i++) {
if (i == trailing) {
<API key>(ptn, i, ~(1 << trailing) & 7, false);
} else {
<API key>(ptn, i, (1 << trailing), true);
}
}
}
static void lp5562_set_pwm_cmd(struct lp5562_pattern_data *ptn,
unsigned int color)
{
u8 r = (color >> 16) & 0xFF;
u8 g = (color >> 8) & 0xFF;
u8 b = color & 0xFF;
ptn->r[ptn->pc_r++] = CMD_SET_PWM;
ptn->r[ptn->pc_r++] = r;
ptn->g[ptn->pc_g++] = CMD_SET_PWM;
ptn->g[ptn->pc_g++] = g;
ptn->b[ptn->pc_b++] = CMD_SET_PWM;
ptn->b[ptn->pc_b++] = b;
}
static void <API key>(struct lp55xx_chip *chip)
{
int i;
u8 rgb_mem[] = {
<API key>,
<API key>,
<API key>,
};
for (i = 0; i < ARRAY_SIZE(rgb_mem); i++) {
lp55xx_write(chip, rgb_mem[i], 0);
lp55xx_write(chip, rgb_mem[i] + 1, 0);
}
}
static void <API key>(struct lp55xx_chip *chip,
u8 base, u8 *rgb, int size)
{
int i;
if (!rgb || size <= 0)
return;
for (i = 0; i < size; i++)
lp55xx_write(chip, base + i, *(rgb + i));
lp55xx_write(chip, base + i, 0);
lp55xx_write(chip, base + i + 1, 0);
}
static inline bool _is_pc_overflow(struct lp5562_pattern_data *ptn)
{
return (ptn->pc_r >= <API key> ||
ptn->pc_g >= <API key> ||
ptn->pc_b >= <API key>);
}
static void <API key>(struct lp55xx_chip *chip,
struct lp5562_pattern_data *ptn)
{
WARN_ON(_is_pc_overflow(ptn));
/* Set LED map as RGB */
lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_RGB);
/* OP mode : LOAD */
lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_LOAD);
<API key>();
/* copy pattern commands into the program memory */
<API key>(chip);
<API key>(chip, <API key>,
ptn->r, ptn->pc_r);
<API key>(chip, <API key>,
ptn->g, ptn->pc_g);
<API key>(chip, <API key>,
ptn->b, ptn->pc_b);
/* OP mode : RUN */
lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_RUN);
<API key>();
lp55xx_write(chip, LP5562_REG_ENABLE, <API key>);
}
static ssize_t lp5562_show_blink(struct device *dev,
struct device_attribute *attr,
char *unused)
{
return 0;
}
/* LED blink with the internal program engine */
static ssize_t lp5562_store_blink(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
unsigned int rgb = 0;
unsigned int on = 0;
unsigned int off = 0;
struct lp5562_pattern_data ptn = { };
sscanf(buf, "0x%06x %d %d", &rgb, &on, &off);
lp5562_stop_engine(chip);
on = min_t(unsigned int, on, MAX_BLINK_TIME);
off = min_t(unsigned int, off, MAX_BLINK_TIME);
if (!rgb)
return len;
mutex_lock(&chip->lock);
if (ledc.blink_fading) {
if (LED_LOWPOWER_MODE == 1)
LED_DYNAMIC_CURRENT = ledc.current_low * 2;
else
LED_DYNAMIC_CURRENT = ledc.current_high * 2;
}
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
<API key>(&ptn, 500);
if (ledc.blink_fading && ledc.fade_in_time)
lp5562_set_ramp_cmd(&ptn, rgb, ledc.fade_in_time, true);
else {
lp5562_set_pwm_cmd(&ptn, ledc.blink_fading ? <API key>(rgb) : rgb);
}
if (!off) {
<API key>(&ptn, RED, (1 << BLUE), true);
<API key>(&ptn, GREEN, (1 << RED), true);
<API key>(&ptn, BLUE, (1 << GREEN), true);
goto run;
}
<API key>(&ptn, ledc.blink_retention + 1);
if (ledc.blink_fading && ledc.fade_out_time)
lp5562_set_ramp_cmd(&ptn, rgb, ledc.fade_out_time, false);
else
lp5562_set_pwm_cmd(&ptn, 0x000000);
<API key>(&ptn, off);
run:
/* run the pattern */
<API key>(chip, &ptn);
printk(KERN_DEBUG "led_blink is called, Color:0x%X Brightness:%i\n",
rgb, LED_DYNAMIC_CURRENT);
mutex_unlock(&chip->lock);
return len;
}
void lp5562_blink(int rgb, int on, int off)
{
struct lp55xx_chip *chip = g_chip;
struct lp5562_pattern_data ptn = { };
u8 jump_pc = 0;
lp5562_stop_engine(chip);
on = min_t(unsigned int, on, MAX_BLINK_TIME);
off = min_t(unsigned int, off, MAX_BLINK_TIME);
if (!rgb || !on || !off)
return;
mutex_lock(&chip->lock);
/* make on-time pattern */
lp5562_set_pwm_cmd(&ptn, rgb);
lp5562_set_wait_cmd(&ptn, on, jump_pc);
jump_pc = ptn.pc_r / 2; /* 16bit size program counter */
/* make off-time pattern */
lp5562_set_pwm_cmd(&ptn, 0);
lp5562_set_wait_cmd(&ptn, off, jump_pc);
/* run the pattern */
<API key>(chip, &ptn);
printk(KERN_DEBUG "led_blink is called, Color:0x%X Brightness:%i\n",
rgb, LED_DYNAMIC_CURRENT);
mutex_unlock(&chip->lock);
}
EXPORT_SYMBOL(lp5562_blink);
static int <API key>(struct lp55xx_chip *chip, u8 offset,
struct lp5562_pattern_data *ptn)
{
struct <API key> *predef;
if(offset < 1 || offset > chip->pdata->num_patterns)
return -EINVAL;
predef = chip->pdata->patterns + (offset - 1);
/* copy predefined pattern to internal data */
memcpy(ptn->r, predef->r, predef->size_r);
memcpy(ptn->g, predef->g, predef->size_g);
memcpy(ptn->b, predef->b, predef->size_b);
ptn->pc_r = predef->size_r;
ptn->pc_g = predef->size_g;
ptn->pc_b = predef->size_b;
return 0;
}
static int <API key>(struct lp55xx_chip *chip, int mode)
{
int num_patterns = chip->pdata->num_patterns;
int ret = -EINVAL;
unsigned int rgb;
/* invalid pattern data */
if (mode > num_patterns || !(chip->pdata->patterns))
return ret;
if (mode == LP5562_PATTERN_OFF) {
lp55xx_write(chip, LP5562_REG_ENABLE, <API key>);
<API key>();
lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DISABLE);
<API key>();
lp55xx_write(chip, LP5562_REG_ENG_SEL, LP5562_ENG_SEL_PWM);
lp55xx_write(chip, LP5562_REG_OP_MODE, LP5562_CMD_DIRECT);
<API key>();
} else {
struct lp5562_pattern_data ptn = { };
if (mode != 3) {
ret = <API key>(chip, mode, &ptn);
if (ret)
return ret;
}
if (LED_LOWPOWER_MODE == 1)
LED_DYNAMIC_CURRENT = ledc.current_low;
else
LED_DYNAMIC_CURRENT = ledc.current_high;
chip->pdata->led_config[0].led_current = LED_DYNAMIC_CURRENT;
chip->pdata->led_config[1].led_current = LED_DYNAMIC_CURRENT;
chip->pdata->led_config[2].led_current = LED_DYNAMIC_CURRENT;
if (mode == 3) {
rgb = ((ledc.r << 16) | (ledc.g << 8) | ledc.b);
LED_DYNAMIC_CURRENT *= 2;
<API key>(&ptn, 500);
if (ledc.blink_fading && ledc.fade_in_time)
lp5562_set_ramp_cmd(&ptn, rgb, ledc.fade_in_time, true);
else
lp5562_set_pwm_cmd(&ptn, !ledc.blink_fading ? <API key>(rgb) : rgb);
if (!ledc.blink_delay) {
<API key>(&ptn, RED, (1 << BLUE), true);
<API key>(&ptn, GREEN, (1 << RED), true);
<API key>(&ptn, BLUE, (1 << GREEN), true);
goto run;
}
<API key>(&ptn, ledc.blink_retention + 1);
if (ledc.blink_fading && ledc.fade_out_time)
lp5562_set_ramp_cmd(&ptn, rgb, ledc.fade_out_time, false);
else
lp5562_set_pwm_cmd(&ptn, 0x000000);
<API key>(&ptn, ledc.blink_delay);
}
run:
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
lp55xx_write(chip, <API key>, LED_DYNAMIC_CURRENT);
<API key>(chip, &ptn);
}
return 0;
}
static ssize_t lp5562_show_pattern(struct device *dev,
struct device_attribute *attr,
char *unused)
{
return 0;
}
static ssize_t <API key>(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
unsigned long val;
int ret;
ret = kstrtoul(buf, 0, &val);
if (ret)
return ret;
mutex_lock(&chip->lock);
<API key>(chip, val);
printk(KERN_DEBUG "led pattern : %lu is activated(Type:%d)\n",
val, LED_LOWPOWER_MODE);
mutex_unlock(&chip->lock);
return len;
}
void lp5562_run_pattern(int val)
{
if(!g_chip)
return;
mutex_lock(&g_chip->lock);
<API key>(g_chip, val);
printk(KERN_DEBUG "led pattern : %d is activated(Type:%d)\n",
val, LED_LOWPOWER_MODE);
mutex_unlock(&g_chip->lock);
}
EXPORT_SYMBOL(lp5562_run_pattern);
static DEVICE_ATTR(led_blink, 0664,
lp5562_show_blink, lp5562_store_blink);
static DEVICE_ATTR(led_pattern, 0664,
lp5562_show_pattern, <API key>);
#ifdef SEC_LED_SPECIFIC
static ssize_t store_led_r(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
char buff[10] = {0,};
int cnt, ret;
u8 brightness;
cnt = count;
cnt = (buf[cnt-1] == '\n') ? cnt-1 : cnt;
memcpy(buff, buf, cnt);
buff[cnt] = '\0';
ret = kstrtou8(buff, 0, &brightness);
if (ret != 0) {
dev_err(&chip->cl->dev, "fail to get brightness.\n");
goto out;
}
brightness = min((u8)40,brightness);
brightness = brightness * 255 / 40;
mutex_lock(&chip->lock);
lp55xx_write(chip, <API key>, 0x78);
lp55xx_write(chip, LP5562_REG_R_PWM, brightness);
mutex_unlock(&chip->lock);
out:
return count;
}
static ssize_t store_led_g(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
char buff[10] = {0,};
int cnt, ret;
u8 brightness;
cnt = count;
cnt = (buf[cnt-1] == '\n') ? cnt-1 : cnt;
memcpy(buff, buf, cnt);
buff[cnt] = '\0';
ret = kstrtou8(buff, 0, &brightness);
if (ret != 0) {
dev_err(&chip->cl->dev, "fail to get brightness.\n");
goto out;
}
brightness = min((u8)40,brightness);
brightness = brightness * 255 / 40;
mutex_lock(&chip->lock);
lp55xx_write(chip, <API key>, 0x78);
lp55xx_write(chip, LP5562_REG_G_PWM, brightness);
mutex_unlock(&chip->lock);
out:
return count;
}
static ssize_t store_led_b(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
char buff[10] = {0,};
int cnt, ret;
u8 brightness;
cnt = count;
cnt = (buf[cnt-1] == '\n') ? cnt-1 : cnt;
memcpy(buff, buf, cnt);
buff[cnt] = '\0';
ret = kstrtou8(buff, 0, &brightness);
if (ret != 0) {
dev_err(&chip->cl->dev, "fail to get brightness.\n");
goto out;
}
brightness = min((u8)40,brightness);
brightness = brightness * 255 / 40;
mutex_lock(&chip->lock);
lp55xx_write(chip, <API key>, 0x78);
lp55xx_write(chip, LP5562_REG_B_PWM, brightness);
mutex_unlock(&chip->lock);
out:
return count;
}
static ssize_t <API key>(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{
int retval;
u8 led_lowpower;
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
retval = kstrtou8(buf, 0, &led_lowpower);
if (retval != 0) {
dev_err(&chip->cl->dev, "fail to get led_lowpower.\n");
return count;
}
LED_LOWPOWER_MODE = led_lowpower;
printk(KERN_DEBUG "led_lowpower mode set to %i\n", led_lowpower);
return count;
}
static ssize_t <API key>(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{
int retval;
u8 brightness;
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
retval = kstrtou8(buf, 0, &brightness);
if (retval != 0) {
dev_err(&chip->cl->dev, "fail to get led_brightness.\n");
return count;
}
/*
if (brightness > LED_MAX_CURRENT)
brightness = LED_MAX_CURRENT;
*/
LED_DYNAMIC_CURRENT = brightness;
printk(KERN_DEBUG "led brightness set to %i\n", brightness);
return count;
}
static ssize_t <API key>(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{
int retval;
unsigned long brightness_lev;
struct i2c_client *client;
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
/*client = b_client;*/
retval = kstrtoul(buf, 16, &brightness_lev);
if (retval != 0) {
dev_err(&chip->cl->dev, "fail to get led_br_lev.\n");
return count;
}
/*leds_set_imax(client, brightness_lev);*/
return count;
}
#endif
static ssize_t show_leds_property(struct device *dev,
struct device_attribute *attr, char *buf);
static ssize_t store_leds_property(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len);
#define LEDS_ATTR(_name) \
{ \
.attr = { \
.name = #_name, \
.mode = S_IRUGO | S_IWUSR | S_IWGRP, \
}, \
.show = show_leds_property, \
.store = store_leds_property, \
}
static struct device_attribute leds_control_attrs[] = {
LEDS_ATTR(<API key>),LEDS_ATTR(<API key>),
LEDS_ATTR(led_blink_retention), LEDS_ATTR(led_blink_delay),
LEDS_ATTR(led_fade), LEDS_ATTR(led_fade_in_time),
LEDS_ATTR(led_fade_out_time), LEDS_ATTR(led_noti_r),
LEDS_ATTR(led_noti_g), LEDS_ATTR(led_noti_b),
};
enum {
LOWPOWER_CURRENT = 0, HIGHPOWER_CURRENT, BLINK_RETENTION, BLINK_DELAY,
BLINK_FADING, FADE_IN_TIME, FADE_OUT_TIME, LED_R, LED_G, LED_B
};
static ssize_t show_leds_property(struct device *dev,
struct device_attribute *attr, char *buf)
{
const ptrdiff_t offset = attr - leds_control_attrs;
switch (offset) {
case LOWPOWER_CURRENT:
return sprintf(buf, "%d", ledc.current_low);
case HIGHPOWER_CURRENT:
return sprintf(buf, "%d", ledc.current_high);
case BLINK_RETENTION:
return sprintf(buf, "%d", ledc.blink_retention);
case BLINK_DELAY:
return sprintf(buf, "%d", ledc.blink_delay);
case BLINK_FADING:
return sprintf(buf, "%d", ledc.blink_fading);
case FADE_IN_TIME:
return sprintf(buf, "%d", ledc.fade_in_time);
case FADE_OUT_TIME:
return sprintf(buf, "%d", ledc.fade_out_time);
case LED_R:
return sprintf(buf, "%d", ledc.r);
case LED_G:
return sprintf(buf, "%d", ledc.g);
case LED_B:
return sprintf(buf, "%d", ledc.b);
}
return -EINVAL;
}
static ssize_t store_leds_property(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
int val;
const ptrdiff_t offset = attr - leds_control_attrs;
if(sscanf(buf, "%d", &val) != 1)
return -EINVAL;
switch (offset) {
case LOWPOWER_CURRENT:
sanitize_min_max(val, 0, 120);
ledc.current_low = val;
break;
case HIGHPOWER_CURRENT:
sanitize_min_max(val, 0, 120);
ledc.current_high = val;
break;
case BLINK_RETENTION:
sanitize_min_max(val, 0, 2000);
ledc.blink_retention = val;
break;
case BLINK_DELAY:
sanitize_min_max(val, 0, 5000);
ledc.blink_delay = val;
break;
case BLINK_FADING:
ledc.blink_fading = !!val;
break;
case FADE_IN_TIME:
sanitize_min_max(val, 0, 1000);
ledc.fade_in_time = val;
break;
case FADE_OUT_TIME:
sanitize_min_max(val, 0, 2000);
ledc.fade_out_time = val;
break;
case LED_R:
sanitize_min_max(val, 0, 255);
ledc.r = val;
break;
case LED_G:
sanitize_min_max(val, 0, 255);
ledc.g = val;
break;
case LED_B:
sanitize_min_max(val, 0, 255);
ledc.b = val;
break;
}
return len;
}
#ifdef SEC_LED_SPECIFIC
/* below nodes is SAMSUNG specific nodes */
static DEVICE_ATTR(led_r, 0664, NULL, store_led_r);
static DEVICE_ATTR(led_g, 0664, NULL, store_led_g);
static DEVICE_ATTR(led_b, 0664, NULL, store_led_b);
/* To access sysfs node from other groups */
static DEVICE_ATTR(led_br_lev, 0664, NULL, \
<API key>);
static DEVICE_ATTR(led_brightness, 0664, NULL, \
<API key>);
static DEVICE_ATTR(led_lowpower, 0664, NULL, \
<API key>);
#endif
static struct attribute *lp5562_attributes[] = {
#ifndef SEC_LED_SPECIFIC
asdadsasdasd
&dev_attr_led_blink.attr,
&<API key>.attr,
#endif
NULL,
};
static const struct attribute_group lp5562_group = {
.attrs = lp5562_attributes,
};
#ifdef SEC_LED_SPECIFIC
static struct attribute *sec_led_attributes[] = {
&dev_attr_led_r.attr,
&dev_attr_led_g.attr,
&dev_attr_led_b.attr,
&<API key>.attr,
&dev_attr_led_blink.attr,
&dev_attr_led_br_lev.attr,
&<API key>.attr,
&<API key>.attr,
NULL,
};
static struct attribute_group sec_led_attr_group = {
.attrs = sec_led_attributes,
};
#endif
/* Chip specific configurations */
static struct <API key> lp5562_cfg = {
.max_channel = LP5562_MAX_LEDS,
.reset = {
.addr = LP5562_REG_RESET,
.val = LP5562_RESET,
},
.enable = {
.addr = LP5562_REG_ENABLE,
.val = <API key>,
},
.post_init_device = <API key>,
.brightness_work_fn = <API key>,
.set_led_current = <API key>,
.dev_attr_group = &lp5562_group,
};
static int __devinit lp5562_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int i, ret;
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct <API key> *pdata = client->dev.platform_data;
if (!pdata) {
dev_err(&client->dev, "no platform data\n");
return -EINVAL;
}
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
led = devm_kzalloc(&client->dev,
sizeof(*led) * pdata->num_channels, GFP_KERNEL);
if (!led)
return -ENOMEM;
chip->cl = client;
chip->pdata = pdata;
chip->cfg = &lp5562_cfg;
mutex_init(&chip->lock);
i2c_set_clientdata(client, led);
ret = lp55xx_init_device(chip);
if (ret)
goto err_init;
dev_info(&client->dev, "%s programmable led chip found\n", id->name);
ret = <API key>(led, chip);
if (ret)
goto err_register_leds;
ret = <API key>(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs;
}
#ifdef SEC_LED_SPECIFIC
led_dev = device_create(sec_class, NULL, 0, led, "led");
if (IS_ERR(led_dev)) {
dev_err(&client->dev,
"Failed to create device for samsung specific led\n");
ret = -ENODEV;
goto err_register_sysfs;
}
ret = sysfs_create_group(&led_dev->kobj, &sec_led_attr_group);
if (ret) {
dev_err(&client->dev,
"Failed to create sysfs group for samsung specific led\n");
goto err_register_sysfs;
}
#endif
for(i = 0; i < ARRAY_SIZE(leds_control_attrs); i++) {
ret = sysfs_create_file(&led_dev->kobj, &leds_control_attrs[i].attr);
}
g_chip = chip;
return 0;
err_register_sysfs:
<API key>(led, chip);
err_register_leds:
<API key>(chip);
err_init:
return ret;
}
static int __devexit lp5562_remove(struct i2c_client *client)
{
struct lp55xx_led *led = i2c_get_clientdata(client);
struct lp55xx_chip *chip = led->chip;
#ifdef SEC_LED_SPECIFIC
sysfs_remove_group(&led_dev->kobj, &sec_led_attr_group);
#endif
lp5562_stop_engine(chip);
<API key>(chip);
<API key>(led, chip);
<API key>(chip);
return 0;
}
static const struct i2c_device_id lp5562_id[] = {
{ "lp5562", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, lp5562_id);
static struct i2c_driver lp5562_driver = {
.driver = {
.name = "lp5562",
},
.probe = lp5562_probe,
.remove = __devexit_p(lp5562_remove),
.id_table = lp5562_id,
};
module_i2c_driver(lp5562_driver);
MODULE_DESCRIPTION("Texas Instruments LP5562 LED Driver");
MODULE_VERSION("A1");
MODULE_AUTHOR("Milo Kim");
MODULE_LICENSE("GPL"); |
#ifndef <API key>
#define <API key>
// proc_cache.h
// Cache details for an mcf5272
//
// This file is part of eCos, the Embedded Configurable Operating System.
// eCos is free software; you can redistribute it and/or modify it under
// Software Foundation; either version 2 or (at your option) any later
// version.
// eCos is distributed in the hope that it will be useful, but WITHOUT
// for more details.
// along with eCos; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// As a special exception, if other files instantiate templates or use
// macros or inline functions from this file, or you compile this file
// and link it with other works to produce a work based on this file,
// this file does not by itself cause the resulting work to be covered by
// must still be made available in accordance with section (3) of the GNU
// This exception does not invalidate any other reasons why a work based
//
//
// Author(s): bartv
//
#include <cyg/infra/cyg_type.h>
#include <cyg/hal/var_io.h>
// An mcf5272 has a 1k direct-mapped instruction cache, 64 lines * 16 bytes.
// There is no data cache. The cache control register is write-only so it
// is necessary to keep a soft copy.
externC cyg_uint32 hal_mcf5272_cacr;
#define HAL_ICACHE_SIZE 1024
#define <API key> 16
#define HAL_ICACHE_WAYS 64
#define HAL_ICACHE_SETS 1
#define HAL_ICACHE_ENABLE() \
CYG_MACRO_START \
hal_mcf5272_cacr = (hal_mcf5272_cacr & ~<API key>) | <API key>; \
asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr) : "memory") ; \
CYG_MACRO_END
#define HAL_ICACHE_DISABLE() \
CYG_MACRO_START \
hal_mcf5272_cacr &= ~(<API key> | <API key>); \
asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr) : "memory") ; \
CYG_MACRO_END
#define <API key>(_state_) \
CYG_MACRO_START \
_state_ = (0 != (hal_mcf5272_cacr & <API key>)); \
CYG_MACRO_END
// A full cache invalidate takes 64 cycles. This is expensive if only one
// or two lines need to be invalidated, but doing the arithmetic and tests
// needed to affect just the necessary lines would also take quite a few
// cycles. Hence it is simpler to just invalidate the lot.
#define <API key>() \
CYG_MACRO_START \
asm volatile ( "movec.l %0,%%cacr\n" : : "d" (hal_mcf5272_cacr | <API key>) : "memory" ); \
CYG_MACRO_END
#define <API key>(_base_, _size_) \
CYG_MACRO_START \
<API key>(); \
CYG_MACRO_END
#define HAL_ICACHE_SYNC() \
CYG_MACRO_START \
<API key>(); \
CYG_MACRO_END
#endif // ifndef <API key>
// End of proc_cache.h |
// #define DEBUG // error path messages, extra info
// #define VERBOSE // more; success messages
#include <linux/module.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
#include <linux/usb.h>
#include <linux/crc32.h>
#include <linux/usb/usbnet.h>
#include <linux/slab.h>
#define DRIVER_VERSION "14-Jun-2006"
static const char driver_name [] = "asix";
/* ASIX AX8817X based USB 2.0 Ethernet Devices */
#define AX_CMD_SET_SW_MII 0x06
#define AX_CMD_READ_MII_REG 0x07
#define <API key> 0x08
#define AX_CMD_SET_HW_MII 0x0a
#define AX_CMD_READ_EEPROM 0x0b
#define AX_CMD_WRITE_EEPROM 0x0c
#define AX_CMD_WRITE_ENABLE 0x0d
#define <API key> 0x0e
#define AX_CMD_READ_RX_CTL 0x0f
#define AX_CMD_WRITE_RX_CTL 0x10
#define AX_CMD_READ_IPG012 0x11
#define AX_CMD_WRITE_IPG0 0x12
#define AX_CMD_WRITE_IPG1 0x13
#define AX_CMD_READ_NODE_ID 0x13
#define <API key> 0x14
#define AX_CMD_WRITE_IPG2 0x14
#define <API key> 0x16
#define <API key> 0x17
#define AX_CMD_READ_PHY_ID 0x19
#define <API key> 0x1a
#define <API key> 0x1b
#define <API key> 0x1c
#define <API key> 0x1d
#define AX_CMD_READ_GPIOS 0x1e
#define AX_CMD_WRITE_GPIOS 0x1f
#define AX_CMD_SW_RESET 0x20
#define <API key> 0x21
#define <API key> 0x22
#define AX_MONITOR_MODE 0x01
#define AX_MONITOR_LINK 0x02
#define AX_MONITOR_MAGIC 0x04
#define AX_MONITOR_HSFS 0x10
/* AX88172 Medium Status Register values */
#define AX88172_MEDIUM_FD 0x02
#define AX88172_MEDIUM_TX 0x04
#define AX88172_MEDIUM_FC 0x10
#define <API key> \
( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
#define <API key> 8
#define AX_MAX_MCAST 64
#define AX_SWRESET_CLEAR 0x00
#define AX_SWRESET_RR 0x01
#define AX_SWRESET_RT 0x02
#define AX_SWRESET_PRTE 0x04
#define AX_SWRESET_PRL 0x08
#define AX_SWRESET_BZ 0x10
#define AX_SWRESET_IPRL 0x20
#define AX_SWRESET_IPPD 0x40
#define <API key> 0x15
#define <API key> 0x0c
#define <API key> 0x12
/* AX88772 & AX88178 Medium Mode Register */
#define AX_MEDIUM_PF 0x0080
#define AX_MEDIUM_JFE 0x0040
#define AX_MEDIUM_TFC 0x0020
#define AX_MEDIUM_RFC 0x0010
#define AX_MEDIUM_ENCK 0x0008
#define AX_MEDIUM_AC 0x0004
#define AX_MEDIUM_FD 0x0002
#define AX_MEDIUM_GM 0x0001
#define AX_MEDIUM_SM 0x1000
#define AX_MEDIUM_SBP 0x0800
#define AX_MEDIUM_PS 0x0200
#define AX_MEDIUM_RE 0x0100
#define <API key> \
(AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
AX_MEDIUM_RE )
#define <API key> \
(AX_MEDIUM_FD | AX_MEDIUM_RFC | \
AX_MEDIUM_TFC | AX_MEDIUM_PS | \
AX_MEDIUM_AC | AX_MEDIUM_RE )
/* AX88772 & AX88178 RX_CTL values */
#define AX_RX_CTL_SO 0x0080
#define AX_RX_CTL_AP 0x0020
#define AX_RX_CTL_AM 0x0010
#define AX_RX_CTL_AB 0x0008
#define AX_RX_CTL_SEP 0x0004
#define AX_RX_CTL_AMALL 0x0002
#define AX_RX_CTL_PRO 0x0001
#define AX_RX_CTL_MFB_2048 0x0000
#define AX_RX_CTL_MFB_4096 0x0100
#define AX_RX_CTL_MFB_8192 0x0200
#define AX_RX_CTL_MFB_16384 0x0300
#define AX_DEFAULT_RX_CTL \
(AX_RX_CTL_SO | AX_RX_CTL_AB )
/* GPIO 0 .. 2 toggles */
#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
#define AX_GPIO_RESERVED 0x40 /* Reserved */
#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
#define AX_EEPROM_MAGIC 0xdeadbeef
#define AX88172_EEPROM_LEN 0x40
#define AX88772_EEPROM_LEN 0xff
#define PHY_MODE_MARVELL 0x0000
#define <API key> 0x0018
#define MII_MARVELL_STATUS 0x001b
#define MII_MARVELL_CTRL 0x0014
#define MARVELL_LED_MANUAL 0x0019
#define <API key> 0x0004
#define <API key> 0x0002
#define <API key> 0x0080
/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
struct asix_data {
u8 multi_filter[<API key>];
u8 mac_addr[ETH_ALEN];
u8 phymode;
u8 ledmode;
u8 eeprom_len;
};
struct ax88172_int_data {
__le16 res1;
u8 link;
__le16 res2;
u8 status;
__le16 res3;
} __packed;
static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
{
void *buf;
int err = -ENOMEM;
netdev_dbg(dev->net, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
cmd, value, index, size);
buf = kmalloc(size, GFP_KERNEL);
if (!buf)
goto out;
err = usb_control_msg(
dev->udev,
usb_rcvctrlpipe(dev->udev, 0),
cmd,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value,
index,
buf,
size,
<API key>);
if (err == size)
memcpy(data, buf, size);
else if (err >= 0)
err = -EINVAL;
kfree(buf);
out:
return err;
}
static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
{
void *buf = NULL;
int err = -ENOMEM;
netdev_dbg(dev->net, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
cmd, value, index, size);
if (data) {
buf = kmemdup(data, size, GFP_KERNEL);
if (!buf)
goto out;
}
err = usb_control_msg(
dev->udev,
usb_sndctrlpipe(dev->udev, 0),
cmd,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value,
index,
buf,
size,
<API key>);
kfree(buf);
out:
return err;
}
static void <API key>(struct urb *urb)
{
struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
int status = urb->status;
if (status < 0)
printk(KERN_DEBUG "<API key>() failed with %d",
status);
kfree(req);
usb_free_urb(urb);
}
static void
<API key>(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data)
{
struct usb_ctrlrequest *req;
int status;
struct urb *urb;
netdev_dbg(dev->net, "<API key>() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
cmd, value, index, size);
if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n");
return;
}
if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
netdev_err(dev->net, "Failed to allocate memory for control request\n");
usb_free_urb(urb);
return;
}
req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
req->bRequest = cmd;
req->wValue = cpu_to_le16(value);
req->wIndex = cpu_to_le16(index);
req->wLength = cpu_to_le16(size);
<API key>(urb, dev->udev,
usb_sndctrlpipe(dev->udev, 0),
(void *)req, data, size,
<API key>, req);
if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
netdev_err(dev->net, "Error submitting the control message: status=%d\n",
status);
kfree(req);
usb_free_urb(urb);
}
}
static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{
int offset = 0;
int res_size = 0;
while (offset + sizeof(u32) < skb->len) {
u16 size;
u32 header = get_unaligned_le32(skb->data + offset);
offset += sizeof(u32);
/* get the packet length */
size = (u16) (header & 0x7ff);
if (size != ((~header >> 16) & 0x07ff)) {
netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n");
return 0;
}
if ((size > dev->net->mtu + ETH_HLEN) ||
(size + offset > skb->len)) {
netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
size);
return 0;
}
memmove(skb->data + res_size, skb->data + offset, size);
res_size += size;
offset += (size + 1) & 0xfffe;
}
if (skb->len != offset) {
netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d\n",
skb->len);
return 0;
}
skb_trim(skb, res_size);
return 1;
}
static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
gfp_t flags)
{
int padlen;
int headroom = skb_headroom(skb);
int tailroom = skb_tailroom(skb);
u32 packet_len;
u32 padbytes = 0xffff0000;
padlen = ((skb->len + 4) % 512) ? 0 : 4;
if ((!skb_cloned(skb)) &&
((headroom + tailroom) >= (4 + padlen))) {
if ((headroom < 4) || (tailroom < padlen)) {
skb->data = memmove(skb->head + 4, skb->data, skb->len);
<API key>(skb, skb->len);
}
} else {
struct sk_buff *skb2;
skb2 = skb_copy_expand(skb, 4, padlen, flags);
dev_kfree_skb_any(skb);
skb = skb2;
if (!skb)
return NULL;
}
skb_push(skb, 4);
packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
cpu_to_le32s(&packet_len);
<API key>(skb, &packet_len, sizeof(packet_len));
if ((skb->len % 512) == 0) {
cpu_to_le32s(&padbytes);
memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
skb_put(skb, sizeof(padbytes));
}
return skb;
}
static void asix_status(struct usbnet *dev, struct urb *urb)
{
struct ax88172_int_data *event;
int link;
if (urb->actual_length < 8)
return;
event = urb->transfer_buffer;
link = event->link & 0x01;
if (netif_carrier_ok(dev->net) != link) {
if (link) {
netif_carrier_on(dev->net);
usbnet_defer_kevent (dev, EVENT_LINK_RESET );
} else
netif_carrier_off(dev->net);
netdev_dbg(dev->net, "Link Status is: %d\n", link);
}
}
static inline int asix_set_sw_mii(struct usbnet *dev)
{
int ret;
ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to enable software MII access\n");
return ret;
}
static inline int asix_set_hw_mii(struct usbnet *dev)
{
int ret;
ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to enable hardware MII access\n");
return ret;
}
static inline int asix_get_phy_addr(struct usbnet *dev)
{
u8 buf[2];
int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
netdev_dbg(dev->net, "asix_get_phy_addr()\n");
if (ret < 0) {
netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret);
goto out;
}
netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n",
*((__le16 *)buf));
ret = buf[1];
out:
return ret;
}
static int asix_sw_reset(struct usbnet *dev, u8 flags)
{
int ret;
ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to send software reset: %02x\n", ret);
return ret;
}
static u16 asix_read_rx_ctl(struct usbnet *dev)
{
__le16 v;
int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
if (ret < 0) {
netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret);
goto out;
}
ret = le16_to_cpu(v);
out:
return ret;
}
static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
{
int ret;
netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode);
ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n",
mode, ret);
return ret;
}
static u16 <API key>(struct usbnet *dev)
{
__le16 v;
int ret = asix_read_cmd(dev, <API key>, 0, 0, 2, &v);
if (ret < 0) {
netdev_err(dev->net, "Error reading Medium Status register: %02x\n",
ret);
goto out;
}
ret = le16_to_cpu(v);
out:
return ret;
}
static int <API key>(struct usbnet *dev, u16 mode)
{
int ret;
netdev_dbg(dev->net, "<API key>() - mode = 0x%04x\n", mode);
ret = asix_write_cmd(dev, <API key>, mode, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n",
mode, ret);
return ret;
}
static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
{
int ret;
netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value);
ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
if (ret < 0)
netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n",
value, ret);
if (sleep)
msleep(sleep);
return ret;
}
/*
* AX88772 & AX88178 have a 16-bit RX_CTL value
*/
static void asix_set_multicast(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
struct asix_data *data = (struct asix_data *)&dev->data;
u16 rx_ctl = AX_DEFAULT_RX_CTL;
if (net->flags & IFF_PROMISC) {
rx_ctl |= AX_RX_CTL_PRO;
} else if (net->flags & IFF_ALLMULTI ||
netdev_mc_count(net) > AX_MAX_MCAST) {
rx_ctl |= AX_RX_CTL_AMALL;
} else if (netdev_mc_empty(net)) {
/* just broadcast and directed */
} else {
/* We use the 20 byte dev->data
* for our 8 byte filter buffer
* to avoid allocating memory that
* is tricky to free later */
struct netdev_hw_addr *ha;
u32 crc_bits;
memset(data->multi_filter, 0, <API key>);
/* Build the multicast hash filter. */
<API key>(ha, net) {
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
data->multi_filter[crc_bits >> 3] |=
1 << (crc_bits & 7);
}
<API key>(dev, <API key>, 0, 0,
<API key>, data->multi_filter);
rx_ctl |= AX_RX_CTL_AM;
}
<API key>(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
}
static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
__le16 res;
mutex_lock(&dev->phy_mutex);
asix_set_sw_mii(dev);
asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
(__u16)loc, 2, &res);
asix_set_hw_mii(dev);
mutex_unlock(&dev->phy_mutex);
netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
phy_id, loc, le16_to_cpu(res));
return le16_to_cpu(res);
}
static void
asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
__le16 res = cpu_to_le16(val);
netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
phy_id, loc, val);
mutex_lock(&dev->phy_mutex);
asix_set_sw_mii(dev);
asix_write_cmd(dev, <API key>, phy_id, (__u16)loc, 2, &res);
asix_set_hw_mii(dev);
mutex_unlock(&dev->phy_mutex);
}
/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
static u32 asix_get_phyid(struct usbnet *dev)
{
int phy_reg;
u32 phy_id;
phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
if (phy_reg < 0)
return 0;
phy_id = (phy_reg & 0xffff) << 16;
phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
if (phy_reg < 0)
return 0;
phy_id |= (phy_reg & 0xffff);
return phy_id;
}
static void
asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
{
struct usbnet *dev = netdev_priv(net);
u8 opt;
if (asix_read_cmd(dev, <API key>, 0, 0, 1, &opt) < 0) {
wolinfo->supported = 0;
wolinfo->wolopts = 0;
return;
}
wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
wolinfo->wolopts = 0;
if (opt & AX_MONITOR_MODE) {
if (opt & AX_MONITOR_LINK)
wolinfo->wolopts |= WAKE_PHY;
if (opt & AX_MONITOR_MAGIC)
wolinfo->wolopts |= WAKE_MAGIC;
}
}
static int
asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
{
struct usbnet *dev = netdev_priv(net);
u8 opt = 0;
if (wolinfo->wolopts & WAKE_PHY)
opt |= AX_MONITOR_LINK;
if (wolinfo->wolopts & WAKE_MAGIC)
opt |= AX_MONITOR_MAGIC;
if (opt != 0)
opt |= AX_MONITOR_MODE;
if (asix_write_cmd(dev, <API key>,
opt, 0, 0, NULL) < 0)
return -EINVAL;
return 0;
}
static int asix_get_eeprom_len(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
struct asix_data *data = (struct asix_data *)&dev->data;
return data->eeprom_len;
}
static int asix_get_eeprom(struct net_device *net,
struct ethtool_eeprom *eeprom, u8 *data)
{
struct usbnet *dev = netdev_priv(net);
__le16 *ebuf = (__le16 *)data;
int i;
/* Crude hack to ensure that we don't overwrite memory
* if an odd length is supplied
*/
if (eeprom->len % 2)
return -EINVAL;
eeprom->magic = AX_EEPROM_MAGIC;
/* ax8817x returns 2 bytes from eeprom on read */
for (i=0; i < eeprom->len / 2; i++) {
if (asix_read_cmd(dev, AX_CMD_READ_EEPROM,
eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
return -EINVAL;
}
return 0;
}
static void asix_get_drvinfo (struct net_device *net,
struct ethtool_drvinfo *info)
{
struct usbnet *dev = netdev_priv(net);
struct asix_data *data = (struct asix_data *)&dev->data;
/* Inherit standard device info */
usbnet_get_drvinfo(net, info);
strncpy (info->driver, driver_name, sizeof info->driver);
strncpy (info->version, DRIVER_VERSION, sizeof info->version);
info->eedump_len = data->eeprom_len;
}
static u32 asix_get_link(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
return mii_link_ok(&dev->mii);
}
static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
{
struct usbnet *dev = netdev_priv(net);
return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
}
static int <API key>(struct net_device *net, void *p)
{
struct usbnet *dev = netdev_priv(net);
struct asix_data *data = (struct asix_data *)&dev->data;
struct sockaddr *addr = p;
if (netif_running(net))
return -EBUSY;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
/* We use the 20 byte dev->data
* for our 6 byte mac buffer
* to avoid allocating memory that
* is tricky to free later */
memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
<API key>(dev, <API key>, 0, 0, ETH_ALEN,
data->mac_addr);
return 0;
}
/* We need to override some ethtool_ops so we require our
own structure so we don't interfere with other usbnet
devices that may be connected at the same time. */
static const struct ethtool_ops ax88172_ethtool_ops = {
.get_drvinfo = asix_get_drvinfo,
.get_link = asix_get_link,
.get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel,
.get_wol = asix_get_wol,
.set_wol = asix_set_wol,
.get_eeprom_len = asix_get_eeprom_len,
.get_eeprom = asix_get_eeprom,
.get_settings = usbnet_get_settings,
.set_settings = usbnet_set_settings,
.nway_reset = usbnet_nway_reset,
};
static void <API key>(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
struct asix_data *data = (struct asix_data *)&dev->data;
u8 rx_ctl = 0x8c;
if (net->flags & IFF_PROMISC) {
rx_ctl |= 0x01;
} else if (net->flags & IFF_ALLMULTI ||
netdev_mc_count(net) > AX_MAX_MCAST) {
rx_ctl |= 0x02;
} else if (netdev_mc_empty(net)) {
/* just broadcast and directed */
} else {
/* We use the 20 byte dev->data
* for our 8 byte filter buffer
* to avoid allocating memory that
* is tricky to free later */
struct netdev_hw_addr *ha;
u32 crc_bits;
memset(data->multi_filter, 0, <API key>);
/* Build the multicast hash filter. */
<API key>(ha, net) {
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
data->multi_filter[crc_bits >> 3] |=
1 << (crc_bits & 7);
}
<API key>(dev, <API key>, 0, 0,
<API key>, data->multi_filter);
rx_ctl |= 0x10;
}
<API key>(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
}
static int ax88172_link_reset(struct usbnet *dev)
{
u8 mode;
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
mii_check_media(&dev->mii, 1, 1);
mii_ethtool_gset(&dev->mii, &ecmd);
mode = <API key>;
if (ecmd.duplex != DUPLEX_FULL)
mode |= ~AX88172_MEDIUM_FD;
netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
<API key>(dev, mode);
return 0;
}
static const struct net_device_ops ax88172_netdev_ops = {
.ndo_open = usbnet_open,
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = asix_ioctl,
.<API key> = <API key>,
};
static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
{
int ret = 0;
u8 buf[ETH_ALEN];
int i;
unsigned long gpio_bits = dev->driver_info->data;
struct asix_data *data = (struct asix_data *)&dev->data;
data->eeprom_len = AX88172_EEPROM_LEN;
<API key>(dev,intf);
/* Toggle the GPIOs in a manufacturer/model specific way */
for (i = 2; i >= 0; i
if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(gpio_bits >> (i * 8)) & 0xff, 0, 0,
NULL)) < 0)
goto out;
msleep(5);
}
if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0)
goto out;
/* Get the MAC address */
if ((ret = asix_read_cmd(dev, <API key>,
0, 0, ETH_ALEN, buf)) < 0) {
dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
goto out;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* Initialize MII structure */
dev->mii.dev = dev->net;
dev->mii.mdio_read = asix_mdio_read;
dev->mii.mdio_write = asix_mdio_write;
dev->mii.phy_id_mask = 0x3f;
dev->mii.reg_num_mask = 0x1f;
dev->mii.phy_id = asix_get_phy_addr(dev);
dev->net->netdev_ops = &ax88172_netdev_ops;
dev->net->ethtool_ops = &ax88172_ethtool_ops;
asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(&dev->mii);
return 0;
out:
return ret;
}
static const struct ethtool_ops ax88772_ethtool_ops = {
.get_drvinfo = asix_get_drvinfo,
.get_link = asix_get_link,
.get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel,
.get_wol = asix_get_wol,
.set_wol = asix_set_wol,
.get_eeprom_len = asix_get_eeprom_len,
.get_eeprom = asix_get_eeprom,
.get_settings = usbnet_get_settings,
.set_settings = usbnet_set_settings,
.nway_reset = usbnet_nway_reset,
};
static int ax88772_link_reset(struct usbnet *dev)
{
u16 mode;
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
mii_check_media(&dev->mii, 1, 1);
mii_ethtool_gset(&dev->mii, &ecmd);
mode = <API key>;
if (ethtool_cmd_speed(&ecmd) != SPEED_100)
mode &= ~AX_MEDIUM_PS;
if (ecmd.duplex != DUPLEX_FULL)
mode &= ~AX_MEDIUM_FD;
netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
<API key>(dev, mode);
return 0;
}
static const struct net_device_ops ax88772_netdev_ops = {
.ndo_open = usbnet_open,
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
.ndo_set_mac_address = <API key>,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = asix_ioctl,
.<API key> = asix_set_multicast,
};
static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
{
int ret, embd_phy;
u16 rx_ctl;
struct asix_data *data = (struct asix_data *)&dev->data;
u8 buf[ETH_ALEN];
u32 phyid;
data->eeprom_len = AX88772_EEPROM_LEN;
<API key>(dev,intf);
if ((ret = asix_write_gpio(dev,
AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0)
goto out;
/* 0x10 is the phy id of the embedded 10/100 ethernet phy */
embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
if ((ret = asix_write_cmd(dev, <API key>,
embd_phy, 0, 0, NULL)) < 0) {
dbg("Select PHY #1 failed: %d", ret);
goto out;
}
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL)) < 0)
goto out;
msleep(150);
if ((ret = asix_sw_reset(dev, AX_SWRESET_CLEAR)) < 0)
goto out;
msleep(150);
if (embd_phy) {
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL)) < 0)
goto out;
}
else {
if ((ret = asix_sw_reset(dev, AX_SWRESET_PRTE)) < 0)
goto out;
}
msleep(150);
rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0)
goto out;
rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
/* Get the MAC address */
if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
0, 0, ETH_ALEN, buf)) < 0) {
dbg("Failed to read MAC address: %d", ret);
goto out;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* Initialize MII structure */
dev->mii.dev = dev->net;
dev->mii.mdio_read = asix_mdio_read;
dev->mii.mdio_write = asix_mdio_write;
dev->mii.phy_id_mask = 0x1f;
dev->mii.reg_num_mask = 0x1f;
dev->mii.phy_id = asix_get_phy_addr(dev);
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0)
goto out;
msleep(150);
if ((ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL)) < 0)
goto out;
msleep(150);
dev->net->netdev_ops = &ax88772_netdev_ops;
dev->net->ethtool_ops = &ax88772_ethtool_ops;
asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA);
mii_nway_restart(&dev->mii);
if ((ret = <API key>(dev, <API key>)) < 0)
goto out;
if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
<API key> | <API key>,
<API key>, 0, NULL)) < 0) {
dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
goto out;
}
/* Set RX_CTL to default values with 2k buffer, and enable cactus */
if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
goto out;
rx_ctl = asix_read_rx_ctl(dev);
dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
rx_ctl = <API key>(dev);
dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) {
/* hard_mtu is still the default - the device does not support
jumbo eth frames */
dev->rx_urb_size = 2048;
}
return 0;
out:
return ret;
}
static struct ethtool_ops ax88178_ethtool_ops = {
.get_drvinfo = asix_get_drvinfo,
.get_link = asix_get_link,
.get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel,
.get_wol = asix_get_wol,
.set_wol = asix_set_wol,
.get_eeprom_len = asix_get_eeprom_len,
.get_eeprom = asix_get_eeprom,
.get_settings = usbnet_get_settings,
.set_settings = usbnet_set_settings,
.nway_reset = usbnet_nway_reset,
};
static int marvell_phy_init(struct usbnet *dev)
{
struct asix_data *data = (struct asix_data *)&dev->data;
u16 reg;
netdev_dbg(dev->net, "marvell_phy_init()\n");
reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
<API key> | <API key>);
if (data->ledmode) {
reg = asix_mdio_read(dev->net, dev->mii.phy_id,
<API key>);
netdev_dbg(dev->net, "<API key> (1) = 0x%04x\n", reg);
reg &= 0xf8ff;
reg |= (1 + 0x0100);
asix_mdio_write(dev->net, dev->mii.phy_id,
<API key>, reg);
reg = asix_mdio_read(dev->net, dev->mii.phy_id,
<API key>);
netdev_dbg(dev->net, "<API key> (2) = 0x%04x\n", reg);
reg &= 0xfc0f;
}
return 0;
}
static int marvell_led_status(struct usbnet *dev, u16 speed)
{
u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg);
/* Clear out the center LED bits - 0x03F0 */
reg &= 0xfc0f;
switch (speed) {
case SPEED_1000:
reg |= 0x03e0;
break;
case SPEED_100:
reg |= 0x03b0;
break;
default:
reg |= 0x02f0;
}
netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg);
asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
return 0;
}
static int ax88178_link_reset(struct usbnet *dev)
{
u16 mode;
struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
struct asix_data *data = (struct asix_data *)&dev->data;
u32 speed;
netdev_dbg(dev->net, "ax88178_link_reset()\n");
mii_check_media(&dev->mii, 1, 1);
mii_ethtool_gset(&dev->mii, &ecmd);
mode = <API key>;
speed = ethtool_cmd_speed(&ecmd);
if (speed == SPEED_1000)
mode |= AX_MEDIUM_GM;
else if (speed == SPEED_100)
mode |= AX_MEDIUM_PS;
else
mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
mode |= AX_MEDIUM_ENCK;
if (ecmd.duplex == DUPLEX_FULL)
mode |= AX_MEDIUM_FD;
else
mode &= ~AX_MEDIUM_FD;
netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
speed, ecmd.duplex, mode);
<API key>(dev, mode);
if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
marvell_led_status(dev, speed);
return 0;
}
static void ax88178_set_mfb(struct usbnet *dev)
{
u16 mfb = AX_RX_CTL_MFB_16384;
u16 rxctl;
u16 medium;
int old_rx_urb_size = dev->rx_urb_size;
if (dev->hard_mtu < 2048) {
dev->rx_urb_size = 2048;
mfb = AX_RX_CTL_MFB_2048;
} else if (dev->hard_mtu < 4096) {
dev->rx_urb_size = 4096;
mfb = AX_RX_CTL_MFB_4096;
} else if (dev->hard_mtu < 8192) {
dev->rx_urb_size = 8192;
mfb = AX_RX_CTL_MFB_8192;
} else if (dev->hard_mtu < 16384) {
dev->rx_urb_size = 16384;
mfb = AX_RX_CTL_MFB_16384;
}
rxctl = asix_read_rx_ctl(dev);
asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb);
medium = <API key>(dev);
if (dev->net->mtu > 1500)
medium |= AX_MEDIUM_JFE;
else
medium &= ~AX_MEDIUM_JFE;
<API key>(dev, medium);
if (dev->rx_urb_size > old_rx_urb_size)
<API key>(dev);
}
static int ax88178_change_mtu(struct net_device *net, int new_mtu)
{
struct usbnet *dev = netdev_priv(net);
int ll_mtu = new_mtu + net->hard_header_len + 4;
netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu);
if (new_mtu <= 0 || ll_mtu > 16384)
return -EINVAL;
if ((ll_mtu % dev->maxpacket) == 0)
return -EDOM;
net->mtu = new_mtu;
dev->hard_mtu = net->mtu + net->hard_header_len;
ax88178_set_mfb(dev);
return 0;
}
static const struct net_device_ops ax88178_netdev_ops = {
.ndo_open = usbnet_open,
.ndo_stop = usbnet_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_set_mac_address = <API key>,
.ndo_validate_addr = eth_validate_addr,
.<API key> = asix_set_multicast,
.ndo_do_ioctl = asix_ioctl,
.ndo_change_mtu = ax88178_change_mtu,
};
static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
{
struct asix_data *data = (struct asix_data *)&dev->data;
int ret;
u8 buf[ETH_ALEN];
__le16 eeprom;
u8 status;
int gpio0 = 0;
u32 phyid;
<API key>(dev,intf);
asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status);
dbg("GPIO Status: 0x%04x", status);
asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
asix_write_cmd(dev, <API key>, 0, 0, 0, NULL);
dbg("EEPROM index 0x17 is 0x%04x", eeprom);
if (eeprom == cpu_to_le16(0xffff)) {
data->phymode = PHY_MODE_MARVELL;
data->ledmode = 0;
gpio0 = 1;
} else {
data->phymode = le16_to_cpu(eeprom) & 7;
data->ledmode = le16_to_cpu(eeprom) >> 8;
gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
}
dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
if ((le16_to_cpu(eeprom) >> 8) != 1) {
asix_write_gpio(dev, 0x003c, 30);
asix_write_gpio(dev, 0x001c, 300);
asix_write_gpio(dev, 0x003c, 30);
} else {
dbg("gpio phymode == 1 path");
asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
}
asix_sw_reset(dev, 0);
msleep(150);
asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
msleep(150);
asix_write_rx_ctl(dev, 0);
/* Get the MAC address */
if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
0, 0, ETH_ALEN, buf)) < 0) {
dbg("Failed to read MAC address: %d", ret);
goto out;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* Initialize MII structure */
dev->mii.dev = dev->net;
dev->mii.mdio_read = asix_mdio_read;
dev->mii.mdio_write = asix_mdio_write;
dev->mii.phy_id_mask = 0x1f;
dev->mii.reg_num_mask = 0xff;
dev->mii.supports_gmii = 1;
dev->mii.phy_id = asix_get_phy_addr(dev);
dev->net->netdev_ops = &ax88178_netdev_ops;
dev->net->ethtool_ops = &ax88178_ethtool_ops;
phyid = asix_get_phyid(dev);
dbg("PHYID=0x%08x", phyid);
if (data->phymode == PHY_MODE_MARVELL) {
marvell_phy_init(dev);
msleep(60);
}
asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
BMCR_RESET | BMCR_ANENABLE);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
ADVERTISE_1000FULL);
mii_nway_restart(&dev->mii);
if ((ret = <API key>(dev, <API key>)) < 0)
goto out;
if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
goto out;
/* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
if (dev->driver_info->flags & FLAG_FRAMING_AX) {
/* hard_mtu is still the default - the device does not support
jumbo eth frames */
dev->rx_urb_size = 2048;
}
return 0;
out:
return ret;
}
static const struct driver_info ax8817x_info = {
.description = "ASIX AX8817x USB 2.0 Ethernet",
.bind = ax88172_bind,
.status = asix_status,
.link_reset = ax88172_link_reset,
.reset = ax88172_link_reset,
.flags = FLAG_ETHER | FLAG_LINK_INTR,
.data = 0x00130103,
};
static const struct driver_info dlink_dub_e100_info = {
.description = "DLink DUB-E100 USB Ethernet",
.bind = ax88172_bind,
.status = asix_status,
.link_reset = ax88172_link_reset,
.reset = ax88172_link_reset,
.flags = FLAG_ETHER | FLAG_LINK_INTR,
.data = 0x009f9d9f,
};
static const struct driver_info netgear_fa120_info = {
.description = "Netgear FA-120 USB Ethernet",
.bind = ax88172_bind,
.status = asix_status,
.link_reset = ax88172_link_reset,
.reset = ax88172_link_reset,
.flags = FLAG_ETHER | FLAG_LINK_INTR,
.data = 0x00130103,
};
static const struct driver_info hawking_uf200_info = {
.description = "Hawking UF200 USB Ethernet",
.bind = ax88172_bind,
.status = asix_status,
.link_reset = ax88172_link_reset,
.reset = ax88172_link_reset,
.flags = FLAG_ETHER | FLAG_LINK_INTR,
.data = 0x001f1d1f,
};
static const struct driver_info ax88772_info = {
.description = "ASIX AX88772 USB 2.0 Ethernet",
.bind = ax88772_bind,
.status = asix_status,
.link_reset = ax88772_link_reset,
.reset = ax88772_link_reset,
.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR,
.rx_fixup = asix_rx_fixup,
.tx_fixup = asix_tx_fixup,
};
static const struct driver_info ax88178_info = {
.description = "ASIX AX88178 USB 2.0 Ethernet",
.bind = ax88178_bind,
.status = asix_status,
.link_reset = ax88178_link_reset,
.reset = ax88178_link_reset,
.flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR,
.rx_fixup = asix_rx_fixup,
.tx_fixup = asix_tx_fixup,
};
static const struct usb_device_id products [] = {
{
// Linksys USB200M
USB_DEVICE (0x077b, 0x2226),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Netgear FA120
USB_DEVICE (0x0846, 0x1040),
.driver_info = (unsigned long) &netgear_fa120_info,
}, {
// DLink DUB-E100
USB_DEVICE (0x2001, 0x1a00),
.driver_info = (unsigned long) &dlink_dub_e100_info,
}, {
// Intellinet, ST Lab USB Ethernet
USB_DEVICE (0x0b95, 0x1720),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Hawking UF200, TrendNet TU2-ET100
USB_DEVICE (0x07b8, 0x420a),
.driver_info = (unsigned long) &hawking_uf200_info,
}, {
// Billionton Systems, USB2AR
USB_DEVICE (0x08dd, 0x90ff),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// ATEN UC210T
USB_DEVICE (0x0557, 0x2009),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Buffalo LUA-U2-KTX
USB_DEVICE (0x0411, 0x003d),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Buffalo LUA-U2-GT 10/100/1000
USB_DEVICE (0x0411, 0x006e),
.driver_info = (unsigned long) &ax88178_info,
}, {
// Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
USB_DEVICE (0x6189, 0x182d),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter"
USB_DEVICE (0x0df6, 0x0056),
.driver_info = (unsigned long) &ax88178_info,
}, {
// corega FEther USB2-TX
USB_DEVICE (0x07aa, 0x0017),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// Surecom EP-1427X-2
USB_DEVICE (0x1189, 0x0893),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// goodway corp usb gwusb2e
USB_DEVICE (0x1631, 0x6200),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// JVC MP-PRX1 Port Replicator
USB_DEVICE (0x04f1, 0x3008),
.driver_info = (unsigned long) &ax8817x_info,
}, {
// ASIX AX88772B 10/100
USB_DEVICE (0x0b95, 0x772b),
.driver_info = (unsigned long) &ax88772_info,
}, {
// ASIX AX88772 10/100
USB_DEVICE (0x0b95, 0x7720),
.driver_info = (unsigned long) &ax88772_info,
}, {
// ASIX AX88178 10/100/1000
USB_DEVICE (0x0b95, 0x1780),
.driver_info = (unsigned long) &ax88178_info,
}, {
// Logitec LAN-GTJ/U2A
USB_DEVICE (0x0789, 0x0160),
.driver_info = (unsigned long) &ax88178_info,
}, {
// Linksys USB200M Rev 2
USB_DEVICE (0x13b1, 0x0018),
.driver_info = (unsigned long) &ax88772_info,
}, {
// 0Q0 cable ethernet
USB_DEVICE (0x1557, 0x7720),
.driver_info = (unsigned long) &ax88772_info,
}, {
// DLink DUB-E100 H/W Ver B1
USB_DEVICE (0x07d1, 0x3c05),
.driver_info = (unsigned long) &ax88772_info,
}, {
// DLink DUB-E100 H/W Ver B1 Alternate
USB_DEVICE (0x2001, 0x3c05),
.driver_info = (unsigned long) &ax88772_info,
}, {
// Linksys USB1000
USB_DEVICE (0x1737, 0x0039),
.driver_info = (unsigned long) &ax88178_info,
}, {
// IO-DATA ETG-US2
USB_DEVICE (0x04bb, 0x0930),
.driver_info = (unsigned long) &ax88178_info,
}, {
// Belkin F5D5055
USB_DEVICE(0x050d, 0x5055),
.driver_info = (unsigned long) &ax88178_info,
}, {
// Apple USB Ethernet Adapter
USB_DEVICE(0x05ac, 0x1402),
.driver_info = (unsigned long) &ax88772_info,
}, {
// Cables-to-Go USB Ethernet Adapter
USB_DEVICE(0x0b95, 0x772a),
.driver_info = (unsigned long) &ax88772_info,
}, {
// ABOCOM for pci
USB_DEVICE(0x14ea, 0xab11),
.driver_info = (unsigned long) &ax88178_info,
}, {
// ASIX 88772a
USB_DEVICE(0x0db0, 0xa877),
.driver_info = (unsigned long) &ax88772_info,
}, {
// Asus USB Ethernet Adapter
USB_DEVICE (0x0b95, 0x7e2b),
.driver_info = (unsigned long) &ax88772_info,
},
{ }, // END
};
MODULE_DEVICE_TABLE(usb, products);
static struct usb_driver asix_driver = {
.name = "asix",
.id_table = products,
.probe = usbnet_probe,
.suspend = usbnet_suspend,
.resume = usbnet_resume,
.disconnect = usbnet_disconnect,
.<API key> = 1,
};
static int __init asix_init(void)
{
return usb_register(&asix_driver);
}
module_init(asix_init);
static void __exit asix_exit(void)
{
usb_deregister(&asix_driver);
}
module_exit(asix_exit);
MODULE_AUTHOR("David Hollis");
MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices");
MODULE_LICENSE("GPL"); |
package org.ovirt.engine.core.bll;
import org.ovirt.engine.core.common.config.Config;
import org.ovirt.engine.core.common.config.ConfigValues;
import org.ovirt.engine.core.common.queries.TimeZoneQueryParams;
public class <API key><P extends TimeZoneQueryParams> extends QueriesCommandBase<P> {
public <API key>(P parameters) {
super(parameters);
}
@Override
protected void executeQueryCommand() {
ConfigValues <API key>;
switch (getParameters().getTimeZoneType()) {
default:
case GENERAL_TIMEZONE:
<API key> = ConfigValues.<API key>;
break;
case WINDOWS_TIMEZONE:
<API key> = ConfigValues.<API key>;
break;
}
String timeZone = Config.<String> getValue(<API key>);
getQueryReturnValue().setReturnValue(timeZone);
}
} |
#pragma once
#include <stddef.h>
float* short2FloatArray(short* in, size_t len);
double* short2DoubleArray(short* in, size_t len, bool scale = true);
void freeFloatArray(float* floats);
void freeDoubleArray(double* floats);
double FreqToNote(double freq);
/*
namespace Native{
namespace PitchTracking{
CTone^ <API key>(Tone* tone){
CTone^ result = gcnew CTone();
result->Freq = tone->freq;
result->DB = tone->db;
result->Stabledb = tone->stabledb;
result->Age = static_cast<int>(tone->age);
result->NoteExact = 12.0 * std::log(tone->freq / 127.09) / std::log(2.0) + 27.5 - 16; // 16 = C2
result->Note = static_cast<int>(std::round(result->NoteExact));
return result;
}
}
}
*/ |
package org.syncany.operations.daemon.messages;
import org.simpleframework.xml.Element;
import org.syncany.operations.daemon.messages.api.FolderRequest;
public class <API key> extends FolderRequest {
@Element(required = true)
private String fileHistoryId;
@Element(required = true)
private int version;
public String getFileHistoryId() {
return fileHistoryId;
}
public int getVersion() {
return version;
}
public void setFileHistoryId(String fileHistoryId) {
this.fileHistoryId = fileHistoryId;
}
public void setVersion(int version) {
this.version = version;
}
} |
// This file is part of the ClearCanvas RIS/PACS open source project.
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// the ClearCanvas RIS/PACS open source project. If not, see
#endregion
namespace ClearCanvas.Enterprise.Core
{
<summary>
Base interface for all persistence broker interfaces. This interface is not implemented directly.
</summary>
public interface IPersistenceBroker
{
<summary>
Used by the framework to establish the <see cref="IPersistenceContext"/> in which an instance of
this broker will act.
</summary>
<param name="context"></param>
void SetContext(IPersistenceContext context);
}
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!
</head>
<body bgcolor="white">
Contains the interfaces for converting JTS objects to and from other formats.
<P>
The Java Topology Suite (JTS) is a Java API that implements a core set of spatial data operations using an explicit precision model and robust geometric algorithms. JTS is intended to be used in the development of applications that support the validation, cleaning, integration and querying of spatial datasets.
<P>
JTS attempts to implement the OpenGIS Simple Features Specification (SFS) as accurately as possible. In some cases the SFS is unclear or omits a specification; in this case JTS attempts to choose a reasonable and consistent alternative. Differences from and elaborations of the SFS are documented in this specification.
<h2>Package Specification</h2>
<ul>
<li>Java Topology Suite Technical Specifications
<li><A HREF="http:
OpenGIS Simple Features Specification for SQL</A>
</ul>
</body>
</html> |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
#include "<API key>.hpp"
#include "common.hpp"
#include "core/logger.hpp"
#include "core/privilege-helper.hpp"
#include "core/config-file.hpp"
namespace nfd {
namespace general {
NFD_LOG_INIT("<API key>");
static void
onConfig(const ConfigSection& configSection,
bool isDryRun,
const std::string& filename)
{
// general
// ; user "ndn-user"
// ; group "ndn-user"
std::string user;
std::string group;
for (ConfigSection::const_iterator i = configSection.begin();
i != configSection.end();
++i)
{
if (i->first == "user")
{
try
{
user = i->second.get_value<std::string>("user");
if (user.empty())
{
throw ConfigFile::Error("Invalid value for \"user\""
" in \"general\" section");
}
}
catch (const boost::property_tree::ptree_error& error)
{
throw ConfigFile::Error("Invalid value for \"user\""
" in \"general\" section");
}
}
else if (i->first == "group")
{
try
{
group = i->second.get_value<std::string>("group");
if (group.empty())
{
throw ConfigFile::Error("Invalid value for \"group\""
" in \"general\" section");
}
}
catch (const boost::property_tree::ptree_error& error)
{
throw ConfigFile::Error("Invalid value for \"group\""
" in \"general\" section");
}
}
}
NFD_LOG_TRACE("using user \"" << user << "\" group \"" << group << "\"");
PrivilegeHelper::initialize(user, group);
}
void
setConfigFile(ConfigFile& configFile)
{
configFile.addSectionHandler("general", &onConfig);
}
} // namespace general
} // namespace nfd |
// This file is part of the "Irrlicht Engine".
#ifndef <API key>
#define <API key>
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "SMeshBufferLightMap.h"
#include "IMeshManipulator.h"
#include "matrix4.h"
#include "quaternion.h"
#include "CSkinnedMesh.h"
namespace irr
{
namespace scene
{
//! Meshloader capable of loading ogre meshes.
class COgreMeshFileLoader : public IMeshLoader
{
public:
//! Constructor
COgreMeshFileLoader(io::IFileSystem* fs, video::IVideoDriver* driver);
//! destructor
virtual ~COgreMeshFileLoader();
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".cob")
virtual bool <API key>(const io::path& filename) const;
//! creates/loads an animated mesh from the file.
//! \return Pointer to the created mesh. Returns 0 if loading failed.
//! If you no longer need the mesh, you should call IAnimatedMesh::drop().
//! See IReferenceCounted::drop() for more information.
virtual IAnimatedMesh* createMesh(io::IReadFile* file);
private:
// byte-align structures
#include "irrpack.h"
struct ChunkHeader
{
u16 id;
u32 length;
} PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
struct ChunkData
{
ChunkData() : read(0) {}
ChunkHeader header;
u32 read;
};
struct OgreTexture
{
core::array<core::stringc> Filename;
core::stringc Alias;
core::stringc CoordsType;
core::stringc MipMaps;
core::stringc Alpha;
};
struct OgrePass
{
OgrePass() : AmbientTokenColor(false),
DiffuseTokenColor(false), SpecularTokenColor(false),
EmissiveTokenColor(false),
MaxLights(8), PointSize(1.0f), PointSprites(false),
PointSizeMin(0), PointSizeMax(0) {}
video::SMaterial Material;
OgreTexture Texture;
bool AmbientTokenColor;
bool DiffuseTokenColor;
bool SpecularTokenColor;
bool EmissiveTokenColor;
u32 MaxLights;
f32 PointSize;
bool PointSprites;
u32 PointSizeMin;
u32 PointSizeMax;
};
struct OgreTechnique
{
OgreTechnique() : Name(""), LODIndex(0) {}
core::stringc Name;
core::stringc Scheme;
u16 LODIndex;
core::array<OgrePass> Passes;
};
struct OgreMaterial
{
OgreMaterial() : Name(""), ReceiveShadows(true),
<API key>(false) {}
core::stringc Name;
bool ReceiveShadows;
bool <API key>;
core::array<f32> LODDistances;
core::array<OgreTechnique> Techniques;
};
struct OgreVertexBuffer
{
OgreVertexBuffer() : BindIndex(0), VertexSize(0), Data(0) {}
u16 BindIndex;
u16 VertexSize;
core::array<f32> Data;
};
struct OgreVertexElement
{
u16 Source,
Type,
Semantic,
Offset,
Index;
};
struct OgreGeometry
{
s32 NumVertex;
core::array<OgreVertexElement> Elements;
core::array<OgreVertexBuffer> Buffers;
core::array<core::vector3df> Vertices;
core::array<core::vector3df> Normals;
core::array<s32> Colors;
core::array<core::vector2df> TexCoords;
};
struct OgreTextureAlias
{
OgreTextureAlias() {};
OgreTextureAlias(const core::stringc& a, const core::stringc& b) : Texture(a), Alias(b) {};
core::stringc Texture;
core::stringc Alias;
};
struct OgreBoneAssignment
{
s32 VertexID;
u16 BoneID;
f32 Weight;
};
struct OgreSubMesh
{
core::stringc Material;
bool SharedVertices;
core::array<s32> Indices;
OgreGeometry Geometry;
u16 Operation;
core::array<OgreTextureAlias> TextureAliases;
core::array<OgreBoneAssignment> BoneAssignments;
bool Indices32Bit;
};
struct OgreMesh
{
bool SkeletalAnimation;
OgreGeometry Geometry;
core::array<OgreSubMesh> SubMeshes;
core::array<OgreBoneAssignment> BoneAssignments;
core::vector3df BBoxMinEdge;
core::vector3df BBoxMaxEdge;
f32 BBoxRadius;
};
struct OgreBone
{
core::stringc Name;
core::vector3df Position;
core::quaternion Orientation;
core::vector3df Scale;
u16 Handle;
u16 Parent;
};
struct OgreKeyframe
{
u16 BoneID;
f32 Time;
core::vector3df Position;
core::quaternion Orientation;
core::vector3df Scale;
};
struct OgreAnimation
{
core::stringc Name;
f32 Length;
core::array<OgreKeyframe> Keyframes;
};
struct OgreSkeleton
{
core::array<OgreBone> Bones;
core::array<OgreAnimation> Animations;
};
bool readChunk(io::IReadFile* file);
bool readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh);
bool readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry);
bool <API key>(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry);
bool readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry);
bool readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh);
void readChunkData(io::IReadFile* file, ChunkData& data);
void readString(io::IReadFile* file, ChunkData& data, core::stringc& out);
void readBool(io::IReadFile* file, ChunkData& data, bool& out);
void readInt(io::IReadFile* file, ChunkData& data, s32* out, u32 num=1);
void readShort(io::IReadFile* file, ChunkData& data, u16* out, u32 num=1);
void readFloat(io::IReadFile* file, ChunkData& data, f32* out, u32 num=1);
void readVector(io::IReadFile* file, ChunkData& data, core::vector3df& out);
void readQuaternion(io::IReadFile* file, ChunkData& data, core::quaternion& out);
void <API key>(scene::IMeshBuffer* mb, const core::stringc& materialName);
scene::SMeshBuffer* composeMeshBuffer(const core::array<s32>& indices, const OgreGeometry& geom);
scene::SMeshBufferLightMap* <API key>(const core::array<s32>& indices, const OgreGeometry& geom);
scene::IMeshBuffer* <API key>(scene::CSkinnedMesh& mesh, const core::array<s32>& indices, const OgreGeometry& geom);
void composeObject(void);
bool readColor(io::IReadFile* meshFile, video::SColor& col);
void getMaterialToken(io::IReadFile* file, core::stringc& token, bool noNewLine=false);
void readTechnique(io::IReadFile* meshFile, OgreMaterial& mat);
void readPass(io::IReadFile* file, OgreTechnique& technique);
void loadMaterials(io::IReadFile* file);
bool loadSkeleton(io::IReadFile* meshFile, const core::stringc& name);
void clearMeshes();
io::IFileSystem* FileSystem;
video::IVideoDriver* Driver;
core::stringc Version;
bool SwapEndian;
core::array<OgreMesh> Meshes;
io::path <API key>;
core::array<OgreMaterial> Materials;
OgreSkeleton Skeleton;
IMesh* Mesh;
u32 NumUV;
};
} // end namespace scene
} // end namespace irr
#endif |
#pragma region License
// This file is part of the ClearCanvas RIS/PACS open source project.
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// the ClearCanvas RIS/PACS open source project. If not, see
#pragma endregion
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here |
# coding=utf-8
# Authors:
# Pedro Jose Pereira Vieito <pvieito@gmail.com> (Twitter: @pvieito)
# This file is part of SickRage.
# SickRage is free software: you can redistribute it and/or modify
# (at your option) any later version.
# SickRage is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
import sickbeard
from sickbeard.clients.generic import GenericClient
class DownloadStationAPI(GenericClient):
def __init__(self, host=None, username=None, password=None):
super(DownloadStationAPI, self).__init__('DownloadStation', host, username, password)
self.url = self.host + 'webapi/DownloadStation/task.cgi'
def _get_auth(self):
auth_url = self.host + 'webapi/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account=' + self.username + '&passwd=' + self.password + '&session=DownloadStation&format=sid'
try:
self.response = self.session.get(auth_url, verify=False)
self.auth = self.response.json()['data']['sid']
except Exception:
return None
return self.auth
def _add_torrent_uri(self, result):
data = {
'api': 'SYNO.DownloadStation.Task',
'version': '1',
'method': 'create',
'session': 'DownloadStation',
'_sid': self.auth,
'uri': result.url
}
if sickbeard.TORRENT_PATH:
data['destination'] = sickbeard.TORRENT_PATH
self._request(method='post', data=data)
return self.response.json()['success']
def _add_torrent_file(self, result):
data = {
'api': 'SYNO.DownloadStation.Task',
'version': '1',
'method': 'create',
'session': 'DownloadStation',
'_sid': self.auth
}
if sickbeard.TORRENT_PATH:
data['destination'] = sickbeard.TORRENT_PATH
files = {'file': (result.name + '.torrent', result.content)}
self._request(method='post', data=data, files=files)
return self.response.json()['success']
api = DownloadStationAPI() |
YUI.add('arraylist-add', function (Y, NAME) {
/**
* Collection utilities beyond what is provided in the YUI core
* @module collection
* @submodule arraylist-add
* @deprecated Use ModelList or a custom ArrayList subclass
*/
/*
* Adds methods add and remove to Y.ArrayList
*/
Y.mix(Y.ArrayList.prototype, {
/**
* Add a single item to the ArrayList. Does not prevent duplicates.
*
* @method add
* @param { mixed } item Item presumably of the same type as others in the
* ArrayList.
* @param {Number} index (Optional.) Number representing the position at
* which the item should be inserted.
* @return {ArrayList} the instance.
* @for ArrayList
* @deprecated Use ModelList or a custom ArrayList subclass
* @chainable
*/
add: function(item, index) {
var items = this._items;
if (Y.Lang.isNumber(index)) {
items.splice(index, 0, item);
}
else {
items.push(item);
}
return this;
},
/**
* Removes first or all occurrences of an item to the ArrayList. If a
* comparator is not provided, uses itemsAreEqual method to determine
* matches.
*
* @method remove
* @param { mixed } needle Item to find and remove from the list.
* @param { Boolean } all If true, remove all occurrences.
* @param { Function } comparator optional a/b function to test equivalence.
* @return {ArrayList} the instance.
* @for ArrayList
* @deprecated Use ModelList or a custom ArrayList subclass
* @chainable
*/
remove: function(needle, all, comparator) {
comparator = comparator || this.itemsAreEqual;
for (var i = this._items.length - 1; i >= 0; --i) {
if (comparator.call(this, needle, this.item(i))) {
this._items.splice(i, 1);
if (!all) {
break;
}
}
}
return this;
},
/**
* Default comparator for items stored in this list. Used by remove().
*
* @method itemsAreEqual
* @param { mixed } a item to test equivalence with.
* @param { mixed } b other item to test equivalance.
* @return { Boolean } true if items are deemed equivalent.
* @for ArrayList
* @deprecated Use ModelList or a custom ArrayList subclass
*/
itemsAreEqual: function(a, b) {
return a === b;
}
});
}, '3.8.0', {"requires": ["arraylist"]}); |
package org.openmrs.propertyeditor;
import org.junit.Assert;
import org.junit.Test;
import org.openmrs.Drug;
import org.openmrs.test.<API key>;
import org.openmrs.test.Verifies;
public class DrugEditorTest extends <API key> {
/**
* @see {@link DrugEditor#setAsText(String)}
*/
@Test
@Verifies(value = "should set value to the drug with the specified identifier", method = "setAsText(String)")
public void <API key>() throws Exception {
DrugEditor drugEditor = new DrugEditor();
drugEditor.setAsText("2");
Drug drug = (Drug) drugEditor.getValue();
Assert.assertNotNull(drug);
Assert.assertEquals("", Integer.valueOf(2), drug.getDrugId());
}
/**
* @see DrugEditor#setAsText(String)
* @verifies set using uuid
*/
@Test
public void <API key>() throws Exception {
DrugEditor drugEditor = new DrugEditor();
drugEditor.setAsText("<API key>");
Assert.assertNotNull(drugEditor.getValue());
}
} |
"""Views for enabling cross-domain requests. """
import logging
import json
from django.conf import settings
from django.views.decorators.cache import cache_page
from django.http import <API key>
from edxmako.shortcuts import render_to_response
from .models import <API key>
log = logging.getLogger(__name__)
<API key> = getattr(settings, '<API key>', 60 * 15)
@cache_page(<API key>)
def xdomain_proxy(request): # pylint: disable=unused-argument
config = <API key>.current()
if not config.enabled:
return <API key>()
allowed_domains = []
for domain in config.whitelist.split("\n"):
if domain.strip():
allowed_domains.append(domain.strip())
if not allowed_domains:
log.warning(
u"No whitelist configured for cross-domain proxy. "
u"You can configure the whitelist in Django Admin "
u"using the <API key> model."
)
return <API key>()
context = {
'xdomain_masters': json.dumps({
domain: '*'
for domain in allowed_domains
})
}
return render_to_response('cors_csrf/xdomain_proxy.html', context) |
define([
'jquery' ,
'jquery.<API key>' /* fragmentChange */,
'jquery.templateData' /* getTemplateData */,
'vendor/jquery.scrollTo' /* /\.scrollTo/ */,
'compiled/behaviors/quiz_selectmenu'
], function($) {
var parentWindow = {
exists: function(){
return (window.parent && window.parent.INST);
},
respondsTo: function(funcName){
return (parentWindow.exists() && $.isFunction(window.parent.INST[funcName]));
},
hasProperty: function(propName){
return (parentWindow.exists() && window.parent.INST[propName]);
},
set: function(propName, value){
if(parentWindow.exists()){
window.parent.INST[propName] = value;
}
},
get: function(propName){
if(parentWindow.hasProperty(propName)){
return window.parent.INST[propName];
}
}
};
// end parentWindow object
var data = $("#submission_details").getTemplateData({textValues: ['version_number', 'user_id']});
var scoringSnapshot = {
snapshot: {
user_id: data.user_id || null,
version_number: data.version_number,
<API key>: null,
question_updates: {},
fudge_points: 0
},
$quizBody: null,
jumpPosition: function(question_id) {
$question = $("#question_" + question_id);
if($question.length > 0) {
return $question.offset().top - 110;
} else {
return 0;
}
},
checkQuizBody: function() {
if(scoringSnapshot.$quizBody === null){
scoringSnapshot.$quizBody = $('html,body');
}
},
// Animates scrolling to question if there is no page reload
jumpToQuestion: function(question_id) {
var top = scoringSnapshot.jumpPosition(question_id);
scoringSnapshot.checkQuizBody();
scoringSnapshot.$quizBody.stop();
scoringSnapshot.$quizBody.clearQueue();
scoringSnapshot.$quizBody.animate({scrollTop: top}, 500);
},
// Jumps directly to question upon a page reload
<API key>: function(question_id) {
var top = scoringSnapshot.jumpPosition(question_id);
scoringSnapshot.checkQuizBody();
scoringSnapshot.$quizBody.scrollTop(top);
},
externallySet: false,
setSnapshot: function(data, <API key>) {
if(data) {
if(<API key> && scoringSnapshot.externallySet) { return; }
scoringSnapshot.externallySet = true;
scoringSnapshot.snapshot = data;
for(var idx in data.question_updates) {
var question = data.question_updates[idx];
var $question = $("#question_" + idx);
if (!ENV.GRADE_BY_QUESTION) {
$question.addClass('<API key>');
}
$question.find(".user_points :text").val(question.points).end()
.find(".<API key> .<API key> textarea").val(question.comments);
}
if(parentWindow.hasProperty('lastQuestionTouched') && !ENV.GRADE_BY_QUESTION) {
scoringSnapshot.jumpToQuestion(window.parent.INST.lastQuestionTouched);
} else if(scoringSnapshot.snapshot.<API key> && !ENV.GRADE_BY_QUESTION) {
scoringSnapshot.jumpToQuestion(scoringSnapshot.snapshot.<API key>);
}
} else if(<API key>) {
if(parentWindow.hasProperty('lastQuestionTouched') && !ENV.GRADE_BY_QUESTION) {
scoringSnapshot.jumpToQuestion(window.parent.INST.lastQuestionTouched);
}
}
if(scoringSnapshot.externallySet || <API key>) {
$("#<API key>").show();
}
if(parentWindow.respondsTo('<API key>')) {
window.parent.INST.<API key>(scoringSnapshot.snapshot);
}
},
update: function(question_id, data){
scoringSnapshot.snapshot.question_updates[question_id] = data;
scoringSnapshot.snapshot.<API key> = question_id;
scoringSnapshot.setSnapshot();
}
}
//end of scoringSnapshot object
var gradingForm = {
<API key>: function(){
$("input[type=text]").focus(function() {
$(this).select();
});
},
<API key>: function(event, hash) {
if(hash.indexOf("#question") == 0) {
var id = hash.substring(10);
scoringSnapshot.jumpToQuestion(id);
}
},
updateSnapshotFor: function($question){
var question_id = $question.attr('id').substring(9) || null;
if(question_id) {
var data = {};
if (!ENV.GRADE_BY_QUESTION) {
$question.addClass('<API key>');
}
data.points = parseFloat($question.find(".user_points :text").val(), 10);
data.comments = $question.find(".<API key> .<API key> textarea").val() || "";
scoringSnapshot.update(question_id, data);
}
$(document).triggerHandler('score_changed');
},
addFudgePoints: function(points){
if(points || points === 0) {
scoringSnapshot.snapshot.fudge_points = points;
scoringSnapshot.setSnapshot();
}
$(document).triggerHandler('score_changed');
},
setInitialSnapshot: function(data){
$("#<API key>").show();
if(data) {
scoringSnapshot.setSnapshot(data);
} else {
scoringSnapshot.setSnapshot(null, true);
}
},
onScoreChanged: function(){
var $total = $("#<API key>");
var total = 0;
$(".display_question .user_points:visible").each(function() {
var points = parseFloat($(this).find("input[type=number]").val(), 10) || 0;
points = Math.round(points * 100.0) / 100.0;
total = total + points;
});
var fudge = (parseFloat($("#fudge_points_entry").val(), 10) || 0);
fudge = Math.round(fudge * 100.0) / 100.0;
total = total + fudge;
$total.text(total || "0");
},
questions: function(){
return $('.question_holder').map(function(index, el) {
return $(el).position().top - 320;
}).toArray();
},
onScroll: function(){
var qNum = quizNavBar.activateCorrectLink();
quizNavBar.toggleDropShadow();
},
onWindowResize: function(){
//Add padding to the bottom of the last question
var winHeight = $(window).innerHeight();
var lastHeight = $('div.question_holder:last-child').outerHeight();
var fixedButtonHeight = $('#<API key>').outerHeight();
var paddingHeight = Math.max(winHeight - lastHeight - 150, fixedButtonHeight);
$('#update_history_form .quiz-submission.headless').css('marginBottom', paddingHeight + 'px');
}
};
//end of gradingForm object
var quizNavBar = {
index: 0,
windowSize: 10,
minWidth: 66,
startingLeftPos: 32,
navItemWidth: 34,
initialize: function(){
$('.user_points > .question_input').each(function(index){
quizNavBar.updateStatusFor($(this));
});
if (ENV.GRADE_BY_QUESTION) {
var questionIndex = parseInt(parentWindow.get('<API key>'));
var questionId = $('.q' + questionIndex).data('id');
if(!isNaN(questionId)){
scoringSnapshot.<API key>(questionId);
}
}
quizNavBar.updateWindowSize();
quizNavBar.<API key>(0);
},
size: function(){
return $('.question-nav-link').length;
},
tooBig: function(){
return quizNavBar.size() > quizNavBar.windowSize;
},
updateWindowSize: function(){
var fullWidth = $('.quiz-nav, .quiz-nav-fullpage').width();
var minPadding = 10;
var maxWidth = fullWidth - (minPadding * 2);
var itemCount = Math.floor((maxWidth - quizNavBar.minWidth) / quizNavBar.navItemWidth);
quizNavBar.windowSize = itemCount;
var actualWidth = (itemCount * quizNavBar.navItemWidth) + quizNavBar.minWidth;
$('.quiz-nav .nav, .quiz-nav-fullpage .nav').animate({width: actualWidth + 'px'}, 10);
},
navArrowCache: null,
$navArrows: function(){
if(quizNavBar.navArrowCache === null){
quizNavBar.navArrowCache = $('.quiz-nav .nav-arrow, .quiz-nav-fullpage .nav-arrow');
}
return quizNavBar.navArrowCache;
},
navWrapperCache: null,
$navWrapper: function(){
if(quizNavBar.navWrapperCache === null){
quizNavBar.navWrapperCache = $('#<API key>');
}
return quizNavBar.navWrapperCache;
},
updateArrows: function(){
if(quizNavBar.tooBig()){
quizNavBar.$navArrows().show();
quizNavBar.$navWrapper().css({position: 'absolute'});
} else {
quizNavBar.$navArrows().hide();
quizNavBar.$navWrapper().css({position: 'relative'});
}
},
toggleDropShadow: function(){
//Add shadow to top bar
$('.quiz-nav').toggleClass('drshadow', ($(document).scrollTop() > 0));
},
updateStatusFor: function($scoreInput){
try{
var questionId = $scoreInput.attr('name').split('_')[2];
var scoreValue = $scoreInput.val();
$('#quiz_nav_' + questionId).toggleClass('complete', (!isNaN(parseFloat(scoreValue))));
} catch(err) {
// do nothing; if there's no status to update, continue with other execution
}
},
activateLink: function(index){
$('.quiz-nav li').removeClass('active');
$('.q' + index).addClass('active');
},
activateCorrectLink: function(){
var qNum = 1;
var qArray = gradingForm.questions();
var docScroll = $(document).scrollTop();
var maxScroll = $(document).height() - $('body').height();
if (docScroll >= maxScroll) {
qNum = qArray.length;
quizNavBar.activateLink(qNum);
} else {
$questions = $('.question')
for(var t = 0; t <= qArray.length; t++) {
$question = $($questions[t])
qNum = t + 1;
if ( (docScroll > qArray[t] && docScroll < qArray[t+1]) || ( t == (qArray.length - 1) && docScroll > qArray[t])) {
parentWindow.set('<API key>', qNum);
quizNavBar.activateLink(qNum);
$question.addClass('<API key>');
} else {
$('.q'+ qNum).removeClass('active');
$question.removeClass('<API key>');
}
}
}
quizNavBar.<API key>(qNum);
return qNum;
},
<API key>: function(startingIndex, endingIndex){
var $navWrapper = $('#<API key>');
var leftPosition = quizNavBar.startingLeftPos - (startingIndex * quizNavBar.navItemWidth);
var newPos = '' + leftPosition + 'px';
var currentPos = $navWrapper.css('left');
if(newPos !== currentPos){
$navWrapper.stop();
$navWrapper.clearQueue();
$navWrapper.animate({left: leftPosition + 'px'}, 300);
}
},
windowScrollLength: function(){
return Math.floor(quizNavBar.windowSize/2.0);
},
<API key>: function(currentIndex){
if(isNaN(currentIndex)){
currentIndex = 0;
}
quizNavBar.index = currentIndex;
quizNavBar.updateArrows();
if(quizNavBar.tooBig()){
var startingIndex = currentIndex - quizNavBar.windowScrollLength();
var maxStartingIndex = quizNavBar.size() - quizNavBar.windowSize;
if(startingIndex < 0){
startingIndex = 0;
quizNavBar.index = 0;
}else if(startingIndex > maxStartingIndex){
startingIndex = maxStartingIndex;
quizNavBar.index = maxStartingIndex + quizNavBar.windowScrollLength();
}
endingIndex = startingIndex + quizNavBar.windowSize - 1;
quizNavBar.<API key>(startingIndex, endingIndex);
}
},
<API key>: function(){
quizNavBar.<API key>(quizNavBar.index - quizNavBar.windowSize);
},
nextQuestionBlock: function(){
quizNavBar.<API key>(quizNavBar.index + quizNavBar.windowSize);
}
};
//End of quizNavBar object
$(document).ready(function() {
gradingForm.<API key>();
if (ENV.GRADE_BY_QUESTION) {
$(document).scroll(gradingForm.onScroll);
gradingForm.onWindowResize();
$('.question_holder').click(function() {
$('.quiz-nav li').removeClass('active');
$('.question').removeClass('<API key>');
var $questions = $('.question')
var $question = $(this).find('.question');
var questionIndex = $questions.index($question) + 1;
parentWindow.set('<API key>', questionIndex);
$('.q' + questionIndex).addClass('active');
$question.addClass('<API key>');
});
}
quizNavBar.initialize();
$(document).fragmentChange(gradingForm.<API key>);
if(parentWindow.respondsTo('<API key>')) {
var data = window.parent.INST.<API key>(scoringSnapshot.snapshot.user_id, scoringSnapshot.snapshot.version_number);
gradingForm.setInitialSnapshot(data);
}
$(".question_holder .user_points input[type=number],.question_holder .<API key> .<API key> textarea").change(function() {
var $question = $(this).parents(".display_question");
var questionId = $question.attr('id');
gradingForm.updateSnapshotFor($question);
if($(this).hasClass('question_input')){
quizNavBar.updateStatusFor($(this));
}
});
$("#fudge_points_entry").change(function() {
var points = parseFloat($(this).val(), 10);
gradingForm.addFudgePoints(points);
});
$(document).bind('score_changed', gradingForm.onScoreChanged);
$('.question-nav-link').click(function(e) {
e.preventDefault();
var questionId = $(this).attr('data-id');
scoringSnapshot.jumpToQuestion(questionId);
});
$('#nav-prev').click(function(e){
e.preventDefault();
quizNavBar.<API key>();
});
$('#nav-next').click(function(e){
e.preventDefault();
quizNavBar.nextQuestionBlock();
});
$(window).resize(function () {
quizNavBar.updateWindowSize();
quizNavBar.<API key>(quizNavBar.index);
gradingForm.onWindowResize();
});
});
if (ENV.SCORE_UPDATED) {
$(document).ready(function() {
if(parentWindow.respondsTo('refreshGrades')) {
window.parent.INST.refreshGrades();
}
if(parentWindow.respondsTo('<API key>')) {
window.parent.INST.<API key>(scoringSnapshot.snapshot);
}
});
}
}); |
# Numenta Platform for Intelligent Computing (NuPIC)
# following terms and conditions apply:
# This program is free software: you can redistribute it and/or modify
# published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
Temporal Memory mixin that enables detailed monitoring of history.
"""
import copy
from collections import defaultdict
from nupic.algorithms.monitor_mixin.metric import Metric
from nupic.algorithms.monitor_mixin.monitor_mixin_base import MonitorMixinBase
from prettytable import PrettyTable
from nupic.algorithms.monitor_mixin.trace import (IndicesTrace, CountsTrace,
BoolsTrace, StringsTrace)
class <API key>(MonitorMixinBase):
"""
Mixin for TemporalMemory that stores a detailed history, for inspection and
debugging.
"""
def __init__(self, *args, **kwargs):
super(<API key>, self).__init__(*args, **kwargs)
self._mmResetActive = True # First iteration is always a reset
def <API key>(self):
"""
@return (Trace) Trace of active columns
"""
return self._mmTraces["activeColumns"]
def <API key>(self):
"""
@return (Trace) Trace of predictive cells
"""
return self._mmTraces["predictiveCells"]
def <API key>(self):
"""
@return (Trace) Trace of # segments
"""
return self._mmTraces["numSegments"]
def <API key>(self):
"""
@return (Trace) Trace of # synapses
"""
return self._mmTraces["numSynapses"]
def <API key>(self):
"""
@return (Trace) Trace of sequence labels
"""
return self._mmTraces["sequenceLabels"]
def mmGetTraceResets(self):
"""
@return (Trace) Trace of resets
"""
return self._mmTraces["resets"]
def <API key>(self):
"""
@return (Trace) Trace of predicted => active cells
"""
self.<API key>()
return self._mmTraces["<API key>"]
def <API key>(self):
"""
@return (Trace) Trace of predicted => inactive cells
"""
self.<API key>()
return self._mmTraces["<API key>"]
def <API key>(self):
"""
@return (Trace) Trace of predicted => active columns
"""
self.<API key>()
return self._mmTraces["<API key>"]
def <API key>(self):
"""
@return (Trace) Trace of predicted => inactive columns
"""
self.<API key>()
return self._mmTraces["<API key>"]
def <API key>(self):
"""
@return (Trace) Trace of unpredicted => active columns
"""
self.<API key>()
return self._mmTraces["<API key>"]
def <API key>(self, trace):
"""
Convenience method to compute a metric over an indices trace, excluding
resets.
@param (IndicesTrace) Trace of indices
@return (Metric) Metric over trace excluding resets
"""
return Metric.createFromTrace(trace.makeCountsTrace(),
excludeResets=self.mmGetTraceResets())
def <API key>(self):
"""
Metric for number of predicted => active cells per column for each sequence
@return (Metric) metric
"""
self.<API key>()
numCellsPerColumn = []
for <API key> in (
self._mmData["<API key>"].values()):
cellsForColumn = self.mapCellsToColumns(<API key>)
numCellsPerColumn += [len(x) for x in cellsForColumn.values()]
return Metric(self,
"# predicted => active cells per column for each sequence",
numCellsPerColumn)
def <API key>(self):
"""
Metric for number of sequences each predicted => active cell appears in
Note: This metric is flawed when it comes to high-order sequences.
@return (Metric) metric
"""
self.<API key>()
numSequencesForCell = defaultdict(lambda: 0)
for <API key> in (
self._mmData["<API key>"].values()):
for cell in <API key>:
numSequencesForCell[cell] += 1
return Metric(self,
"# sequences each predicted => active cells appears in",
numSequencesForCell.values())
def <API key>(self):
"""
Pretty print the connections in the temporal memory.
TODO: Use PrettyTable.
@return (string) Pretty-printed text
"""
text = ""
text += ("Segments: (format => "
"(#) [(source cell=permanence ...), ...]\n")
text += "
columns = range(self.numberOfColumns())
for column in columns:
cells = self.cellsForColumn(column)
for cell in cells:
segmentDict = dict()
for seg in self.connections.segmentsForCell(cell):
synapseList = []
for synapse in self.connections.synapsesForSegment(seg):
synapseData = self.connections.dataForSynapse(synapse)
synapseList.append(
(synapseData.presynapticCell, synapseData.permanence))
synapseList.sort()
synapseStringList = ["{0:3}={1:.2f}".format(sourceCell, permanence) for
sourceCell, permanence in synapseList]
segmentDict[seg] = "({0})".format(" ".join(synapseStringList))
text += ("Column {0:3} / Cell {1:3}:\t({2}) {3}\n".format(
column, cell,
len(segmentDict.values()),
"[{0}]".format(", ".join(segmentDict.values()))))
if column < len(columns) - 1: # not last
text += "\n"
text += "
return text
def <API key>(self, sortby="Column"):
"""
Pretty print the cell representations for sequences in the history.
@param sortby (string) Column of table to sort by
@return (string) Pretty-printed text
"""
self.<API key>()
table = PrettyTable(["Pattern", "Column", "predicted=>active cells"])
for sequenceLabel, <API key> in (
self._mmData["<API key>"].iteritems()):
cellsForColumn = self.mapCellsToColumns(<API key>)
for column, cells in cellsForColumn.iteritems():
table.add_row([sequenceLabel, column, list(cells)])
return table.get_string(sortby=sortby).encode("utf-8")
# Helper methods
def <API key>(self):
"""
Computes the transition traces, if necessary.
Transition traces are the following:
predicted => active cells
predicted => inactive cells
predicted => active columns
predicted => inactive columns
unpredicted => active columns
"""
if not self.<API key>:
return
self._mmData["<API key>"] = defaultdict(set)
self._mmTraces["<API key>"] = IndicesTrace(self,
"predicted => active cells (correct)")
self._mmTraces["<API key>"] = IndicesTrace(self,
"predicted => inactive cells (extra)")
self._mmTraces["<API key>"] = IndicesTrace(self,
"predicted => active columns (correct)")
self._mmTraces["<API key>"] = IndicesTrace(self,
"predicted => inactive columns (extra)")
self._mmTraces["<API key>"] = IndicesTrace(self,
"unpredicted => active columns (bursting)")
predictedCellsTrace = self._mmTraces["predictedCells"]
for i, activeColumns in enumerate(self.<API key>().data):
<API key> = set()
<API key> = set()
<API key> = set()
<API key> = set()
for predictedCell in predictedCellsTrace.data[i]:
predictedColumn = self.columnForCell(predictedCell)
if predictedColumn in activeColumns:
<API key>.add(predictedCell)
<API key>.add(predictedColumn)
sequenceLabel = self.<API key>().data[i]
if sequenceLabel is not None:
self._mmData["<API key>"][sequenceLabel].add(
predictedCell)
else:
<API key>.add(predictedCell)
<API key>.add(predictedColumn)
<API key> = activeColumns - <API key>
self._mmTraces["<API key>"].data.append(<API key>)
self._mmTraces["<API key>"].data.append(<API key>)
self._mmTraces["<API key>"].data.append(<API key>)
self._mmTraces["<API key>"].data.append(
<API key>)
self._mmTraces["<API key>"].data.append(
<API key>)
self.<API key> = False
# Overrides
def compute(self, activeColumns, sequenceLabel=None, **kwargs):
# Append last cycle's predictiveCells to *predicTEDCells* trace
self._mmTraces["predictedCells"].data.append(set(self.getPredictiveCells()))
super(<API key>, self).compute(activeColumns, **kwargs)
# Append this cycle's predictiveCells to *predicTIVECells* trace
self._mmTraces["predictiveCells"].data.append(set(self.getPredictiveCells()))
self._mmTraces["activeCells"].data.append(set(self.getActiveCells()))
self._mmTraces["activeColumns"].data.append(activeColumns)
self._mmTraces["numSegments"].data.append(self.connections.numSegments())
self._mmTraces["numSynapses"].data.append(self.connections.numSynapses())
self._mmTraces["sequenceLabels"].data.append(sequenceLabel)
self._mmTraces["resets"].data.append(self._mmResetActive)
self._mmResetActive = False
self.<API key> = True
def reset(self):
super(<API key>, self).reset()
self._mmResetActive = True
def mmGetDefaultTraces(self, verbosity=1):
traces = [
self.<API key>(),
self.<API key>(),
self.<API key>(),
self.<API key>(),
self.<API key>(),
self.<API key>()
]
if verbosity == 1:
traces = [trace.makeCountsTrace() for trace in traces]
traces += [
self.<API key>(),
self.<API key>()
]
return traces + [self.<API key>()]
def mmGetDefaultMetrics(self, verbosity=1):
resetsTrace = self.mmGetTraceResets()
return ([Metric.createFromTrace(trace, excludeResets=resetsTrace)
for trace in self.mmGetDefaultTraces()[:-3]] +
[Metric.createFromTrace(trace)
for trace in self.mmGetDefaultTraces()[-3:-1]] +
[self.<API key>(),
self.<API key>()])
def mmClearHistory(self):
super(<API key>, self).mmClearHistory()
self._mmTraces["predictedCells"] = IndicesTrace(self, "predicted cells")
self._mmTraces["activeColumns"] = IndicesTrace(self, "active columns")
self._mmTraces["activeCells"] = IndicesTrace(self, "active cells")
self._mmTraces["predictiveCells"] = IndicesTrace(self, "predictive cells")
self._mmTraces["numSegments"] = CountsTrace(self, "# segments")
self._mmTraces["numSynapses"] = CountsTrace(self, "# synapses")
self._mmTraces["sequenceLabels"] = StringsTrace(self, "sequence labels")
self._mmTraces["resets"] = BoolsTrace(self, "resets")
self.<API key> = True
def <API key>(self, title="", showReset=False,
resetShading=0.25, activityType="activeCells"):
"""
Returns plot of the cell activity.
@param title (string) an optional title for the figure
@param showReset (bool) if true, the first set of cell activities
after a reset will have a gray background
@param resetShading (float) if showReset is true, this float specifies the
intensity of the reset background with 0.0
being white and 1.0 being black
@param activityType (string) The type of cell activity to display. Valid
types include "activeCells",
"predictiveCells", "predictedCells",
and "<API key>"
@return (Plot) plot
"""
if activityType == "<API key>":
self.<API key>()
cellTrace = copy.deepcopy(self._mmTraces[activityType].data)
for i in xrange(len(cellTrace)):
cellTrace[i] = self.getCellIndices(cellTrace[i])
return self.mmGetCellTracePlot(cellTrace, self.numberOfCells(),
activityType, title, showReset,
resetShading) |
#include "player.h"
#include <QDir>
#include <QUrl>
#include <QGlib/Connect>
#include <QGlib/Error>
#include <QGst/Pipeline>
#include <QGst/ElementFactory>
#include <QGst/Bus>
#include <QGst/Message>
#include <QGst/Query>
#include <QGst/ClockTime>
#include <QGst/Event>
#include <QGst/StreamVolume>
Player::Player(QWidget *parent)
: QGst::Ui::VideoWidget(parent)
{
//this timer is used to tell the ui to change its position slider & label
//every 100 ms, but only when the pipeline is playing
connect(&m_positionTimer, SIGNAL(timeout()), this, SIGNAL(positionChanged()));
}
Player::~Player()
{
if (m_pipeline) {
m_pipeline->setState(QGst::StateNull);
stopPipelineWatch();
}
}
void Player::setUri(const QString & uri)
{
QString realUri = uri;
//if uri is not a real uri, assume it is a file path
if (realUri.indexOf(":
realUri = QUrl::fromLocalFile(realUri).toEncoded();
}
if (!m_pipeline) {
m_pipeline = QGst::ElementFactory::make("playbin").dynamicCast<QGst::Pipeline>();
if (m_pipeline) {
//let the video widget watch the pipeline for new video sinks
watchPipeline(m_pipeline);
//watch the bus for messages
QGst::BusPtr bus = m_pipeline->bus();
bus->addSignalWatch();
QGlib::connect(bus, "message", this, &Player::onBusMessage);
} else {
qCritical() << "Failed to create the pipeline";
}
}
if (m_pipeline) {
m_pipeline->setProperty("uri", realUri);
}
}
QTime Player::position() const
{
if (m_pipeline) {
//here we query the pipeline about its position
//and we request that the result is returned in time format
QGst::PositionQueryPtr query = QGst::PositionQuery::create(QGst::FormatTime);
m_pipeline->query(query);
return QGst::ClockTime(query->position()).toTime();
} else {
return QTime(0,0);
}
}
void Player::setPosition(const QTime & pos)
{
QGst::SeekEventPtr evt = QGst::SeekEvent::create(
1.0, QGst::FormatTime, QGst::SeekFlagFlush,
QGst::SeekTypeSet, QGst::ClockTime::fromTime(pos),
QGst::SeekTypeNone, QGst::ClockTime::None
);
m_pipeline->sendEvent(evt);
}
int Player::volume() const
{
if (m_pipeline) {
QGst::StreamVolumePtr svp =
m_pipeline.dynamicCast<QGst::StreamVolume>();
if (svp) {
return svp->volume(QGst::<API key>) * 10;
}
}
return 0;
}
void Player::setVolume(int volume)
{
if (m_pipeline) {
QGst::StreamVolumePtr svp =
m_pipeline.dynamicCast<QGst::StreamVolume>();
if(svp) {
svp->setVolume((double)volume / 10, QGst::<API key>);
}
}
}
QTime Player::length() const
{
if (m_pipeline) {
//here we query the pipeline about the content's duration
//and we request that the result is returned in time format
QGst::DurationQueryPtr query = QGst::DurationQuery::create(QGst::FormatTime);
m_pipeline->query(query);
return QGst::ClockTime(query->duration()).toTime();
} else {
return QTime(0,0);
}
}
QGst::State Player::state() const
{
return m_pipeline ? m_pipeline->currentState() : QGst::StateNull;
}
void Player::play()
{
if (m_pipeline) {
m_pipeline->setState(QGst::StatePlaying);
}
}
void Player::pause()
{
if (m_pipeline) {
m_pipeline->setState(QGst::StatePaused);
}
}
void Player::stop()
{
if (m_pipeline) {
m_pipeline->setState(QGst::StateNull);
//once the pipeline stops, the bus is flushed so we will
//not receive any StateChangedMessage about this.
//so, to inform the ui, we have to emit this signal manually.
Q_EMIT stateChanged();
}
}
void Player::onBusMessage(const QGst::MessagePtr & message)
{
switch (message->type()) {
case QGst::MessageEos: //End of stream. We reached the end of the file.
stop();
break;
case QGst::MessageError: //Some error occurred.
qCritical() << message.staticCast<QGst::ErrorMessage>()->error();
stop();
break;
case QGst::MessageStateChanged: //The element in message->source() has changed state
if (message->source() == m_pipeline) {
<API key>(message.staticCast<QGst::StateChangedMessage>());
}
break;
default:
break;
}
}
void Player::<API key>(const QGst::<API key> & scm)
{
switch (scm->newState()) {
case QGst::StatePlaying:
//start the timer when the pipeline starts playing
m_positionTimer.start(100);
break;
case QGst::StatePaused:
//stop the timer when the pipeline pauses
if(scm->oldState() == QGst::StatePlaying) {
m_positionTimer.stop();
}
break;
default:
break;
}
Q_EMIT stateChanged();
}
#include "moc_player.cpp" |
package org.jtalks.jcommune.model.validation;
import org.jtalks.jcommune.model.validation.annotations.IntegerRange;
import org.jtalks.jcommune.model.validation.validators.<API key>;
import org.mockito.Mock;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static io.qala.datagen.RandomShortApi.integer;
import static io.qala.datagen.RandomShortApi.positiveInteger;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/**
* @author skythet
*/
public class <API key> {
private static final int DEFAULT_MIN = -100;
private static final int DEFAULT_MAX = 100;
@Mock
private IntegerRange integerRange;
@BeforeMethod
public void init() {
initMocks(this);
}
@Test
public void testValidate() {
<API key> validator = new <API key>();
int min = integer(DEFAULT_MIN, 0);
int max = integer(0, DEFAULT_MAX);
integerRange(min, max);
validator.initialize(integerRange);
assertTrue(validator.isValid(integer(min, max) + "", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
int min = integer(DEFAULT_MIN, 0);
int max = integer(0, DEFAULT_MAX);
integerRange(max, min);
validator.initialize(integerRange);
assertFalse(validator.isValid(integer(min, max) + "", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
int randomNumber = integer(DEFAULT_MAX);
integerRange(randomNumber, randomNumber);
validator.initialize(integerRange);
assertTrue(validator.isValid(randomNumber + "", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
assertFalse(validator.isValid(null, null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
assertFalse(validator.isValid("123v", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
assertFalse(validator.isValid("", null));
assertFalse(validator.isValid(" ", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
assertFalse(validator.isValid(" 12", null));
assertFalse(validator.isValid("12 ", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
int min = integer(DEFAULT_MIN, 0);
int max = integer(0, DEFAULT_MAX);
integerRange(min, max);
validator.initialize(integerRange);
assertFalse(validator.isValid(max + positiveInteger() + "", null));
}
@Test
public void <API key>() {
<API key> validator = new <API key>();
int min = integer(DEFAULT_MIN, 0);
int max = integer(0, DEFAULT_MAX);
integerRange(min, max);
validator.initialize(integerRange);
assertFalse(validator.isValid(DEFAULT_MIN + (positiveInteger() * -1) + "", null));
}
private void integerRange(int min, int max) {
when(integerRange.min()).thenReturn(min);
when(integerRange.max()).thenReturn(max);
}
} |
#include "../../QGst/Quick/videoitem.h"
#include "../../QGst/Quick/videosurface.h"
#include <QtQml/QQmlExtensionPlugin>
class QtGStreamerPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.freedesktop.gstreamer.QtGStreamerQuick2-1.0"
FILE "QtGStreamerQuick2.json")
public:
virtual void registerTypes(const char *uri);
};
void QtGStreamerPlugin::registerTypes(const char *uri)
{
// @uri org.freedesktop.gstreamer.QtGStreamerQuick2-1.0
qmlRegisterType<QGst::Quick::VideoItem>(uri, 1, 0, "VideoItem");
<API key><QGst::Quick::VideoSurface>(uri, 1, 0, "VideoSurface",
QLatin1String("Creating a QGst::Quick::VideoSurface from QML is not supported"));
}
#include "plugin.moc" |
/**
* @ingroup boards_common_stm32
* @{
*
* @file
* @brief Common configuration for STM32 Timer peripheral based on TIM5
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*/
#ifndef CFG_TIMER_TIM5_H
#define CFG_TIMER_TIM5_H
#include "periph_cpu.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Timer configuration
* @{
*/
static const timer_conf_t timer_config[] = {
{
.dev = TIM5,
.max = 0xffffffff,
.rcc_mask = RCC_APB1ENR_TIM5EN,
.bus = APB1,
.irqn = TIM5_IRQn
}
};
#define TIMER_0_ISR isr_tim5
#define TIMER_NUMOF ARRAY_SIZE(timer_config)
#ifdef __cplusplus
}
#endif
#endif /* CFG_TIMER_TIM5_H */ |
package org.fenixedu.academic.domain.candidacy.workflow.form;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.fenixedu.academic.domain.Country;
import org.fenixedu.academic.domain.Person;
import org.fenixedu.academic.domain.util.workflow.Form;
import org.fenixedu.academic.util.Bundle;
import org.fenixedu.academic.util.LabelFormatter;
import org.joda.time.YearMonthDay;
public class FiliationForm extends Form {
private static final long serialVersionUID = 1L;
private YearMonthDay dateOfBirth;
private Country nationality;
private String parishOfBirth;
private String <API key>;
private String districtOfBirth;
private String fatherName;
private String motherName;
private Country countryOfBirth;
public FiliationForm() {
super();
}
public static FiliationForm createFromPerson(final Person person) {
final Country nationality = person.getCountry() != null ? person.getCountry() : Country.readDefault();
final Country countryOfBirth = person.getCountryOfBirth() != null ? person.getCountryOfBirth() : Country.readDefault();
return new FiliationForm(person.<API key>(), person.getDistrictOfBirth(),
person.<API key>(), person.getNameOfFather(), person.getNameOfMother(), nationality,
person.getParishOfBirth(), countryOfBirth);
}
private FiliationForm(YearMonthDay dateOfBirth, String districtOfBirth, String <API key>, String fatherName,
String motherName, Country nationality, String parishOfBirth, Country countryOfBirth) {
this();
this.dateOfBirth = dateOfBirth;
this.districtOfBirth = districtOfBirth;
this.<API key> = <API key>;
this.fatherName = fatherName;
this.motherName = motherName;
setNationality(nationality);
this.parishOfBirth = parishOfBirth;
setCountryOfBirth(countryOfBirth);
}
public YearMonthDay getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(YearMonthDay dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getDistrictOfBirth() {
return districtOfBirth;
}
public void setDistrictOfBirth(String districtOfBirth) {
this.districtOfBirth = districtOfBirth;
}
public String <API key>() {
return <API key>;
}
public void <API key>(String <API key>) {
this.<API key> = <API key>;
}
public String getFatherName() {
return fatherName;
}
public void setFatherName(String fatherName) {
this.fatherName = fatherName;
}
public String getMotherName() {
return motherName;
}
public void setMotherName(String motherName) {
this.motherName = motherName;
}
public Country getNationality() {
return this.nationality;
}
public void setNationality(Country nationality) {
this.nationality = nationality;
}
public String getParishOfBirth() {
return parishOfBirth;
}
public void setParishOfBirth(String parishOfBirth) {
this.parishOfBirth = parishOfBirth;
}
public Country getCountryOfBirth() {
return this.countryOfBirth;
}
public void setCountryOfBirth(Country countryOfBirth) {
this.countryOfBirth = countryOfBirth;
}
@Override
public List<LabelFormatter> validate() {
if (getCountryOfBirth().isDefaultCountry()) {
if (StringUtils.isEmpty(getDistrictOfBirth()) || StringUtils.isEmpty(<API key>())
|| StringUtils.isEmpty(getParishOfBirth())) {
return Collections.singletonList(new LabelFormatter(
"error.candidacy.workflow.FiliationForm.zone.information.is.required.for.national.students",
Bundle.CANDIDATE));
}
}
return Collections.emptyList();
}
@Override
public String getFormName() {
return "label.candidacy.workflow.filiationForm";
}
} |
({
fontSize: "Taille",
fontName: "Police",
formatBlock: "Mise en forme",
serif: "serif",
"sans-serif": "sans serif",
monospace: "espacement fixe",
cursive: "cursive",
fantasy: "fantaisie",
p: "Paragraphe",
h1: "En-tête",
h2: "Sous-en-tête",
h3: "Sous-sous-en-tête",
pre: "Pré-mise en forme",
1: "xxs",
2: "xs",
3: "s",
4: "m",
5: "l",
6: "xl",
7: "xxl"
}) |
package coreosutil
import (
"encoding/json"
"fmt"
"net/http"
)
func GetAMIData(channel string) (map[string]map[string]string, error) {
r, err := http.Get(fmt.Sprintf("https://coreos.com/dist/aws/aws-%s.json", channel))
if err != nil {
return nil, fmt.Errorf("failed to get AMI data: %s: %v", channel, err)
}
if r.StatusCode != 200 {
return nil, fmt.Errorf("failed to get AMI data: %s: invalid status code: %d", channel, r.StatusCode)
}
output := map[string]map[string]string{}
err = json.NewDecoder(r.Body).Decode(&output)
if err != nil {
return nil, fmt.Errorf("failed to parse AMI data: %s: %v", channel, err)
}
r.Body.Close()
return output, nil
} |
package accounts
import "github.com/rackspace/rack/internal/github.com/rackspace/gophercloud"
// GetOptsBuilder allows extensions to add additional headers to the Get
// request.
type GetOptsBuilder interface {
ToAccountGetMap() (map[string]string, error)
}
// GetOpts is a structure that contains parameters for getting an account's
// metadata.
type GetOpts struct {
Newest bool `h:"X-Newest"`
}
// ToAccountGetMap formats a GetOpts into a map[string]string of headers.
func (opts GetOpts) ToAccountGetMap() (map[string]string, error) {
return gophercloud.BuildHeaders(opts)
}
// Get is a function that retrieves an account's metadata. To extract just the
// custom metadata, call the ExtractMetadata method on the GetResult. To extract
// all the headers that are returned (including the metadata), call the
// ExtractHeader method on the GetResult.
func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) GetResult {
var res GetResult
h := c.<API key>()
if opts != nil {
headers, err := opts.ToAccountGetMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
resp, err := c.Request("HEAD", getURL(c), gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{204},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
// UpdateOptsBuilder allows extensions to add additional headers to the Update
// request.
type UpdateOptsBuilder interface {
ToAccountUpdateMap() (map[string]string, error)
}
// UpdateOpts is a structure that contains parameters for updating, creating, or
// deleting an account's metadata.
type UpdateOpts struct {
Metadata map[string]string
DeleteMetadata []string
ContentType string `h:"Content-Type"`
DetectContentType bool `h:"<API key>"`
TempURLKey string `h:"<API key>"`
TempURLKey2 string `h:"<API key>"`
}
// ToAccountUpdateMap formats an UpdateOpts into a map[string]string of headers.
func (opts UpdateOpts) ToAccountUpdateMap() (map[string]string, error) {
headers, err := gophercloud.BuildHeaders(opts)
if err != nil {
return nil, err
}
for k, v := range opts.Metadata {
headers["X-Account-Meta-"+k] = v
}
for _, k := range opts.DeleteMetadata {
headers["<API key>-"+k] = "true"
}
return headers, err
}
// Update is a function that creates, updates, or deletes an account's metadata.
// To extract the headers returned, call the Extract method on the UpdateResult.
func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
h := make(map[string]string)
if opts != nil {
headers, err := opts.ToAccountUpdateMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
} |
<!DOCTYPE HTML PUBLIC "-
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_92) on Tue Jul 26 12:40:39 PDT 2016 -->
<title>org.apache.edgent.analytics.sensors (Edgent v0.4.0)</title>
<meta name="date" content="2016-07-26">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<h1 class="bar"><a href="../../../../../org/apache/edgent/analytics/sensors/package-summary.html" target="classFrame">org.apache.edgent.analytics.sensors</a></h1>
<div class="indexContainer">
<h2 title="Classes">Classes</h2>
<ul title="Classes">
<li><a href="Deadtime.html" title="class in org.apache.edgent.analytics.sensors" target="classFrame">Deadtime</a></li>
<li><a href="Filters.html" title="class in org.apache.edgent.analytics.sensors" target="classFrame">Filters</a></li>
<li><a href="Range.html" title="class in org.apache.edgent.analytics.sensors" target="classFrame">Range</a></li>
<li><a href="Ranges.html" title="class in org.apache.edgent.analytics.sensors" target="classFrame">Ranges</a></li>
</ul>
<h2 title="Enums">Enums</h2>
<ul title="Enums">
<li><a href="Range.BoundType.html" title="enum in org.apache.edgent.analytics.sensors" target="classFrame">Range.BoundType</a></li>
</ul>
</div>
</body>
</html> |
<reference path='fourslash.ts'/>
/class A<T> { }
/class B<T> { }
/class C<T> { constructor(val: T) { } }
/class D<T> { constructor(val: T) { } }
/
/new /*Asig*/A<string>();
/new /*Bsig*/B("");
/new /*Csig*/C("");
/new /*Dsig*/D<string>();
var A = 'A';
var B = 'B';
var C = 'C';
var D = 'D'
goTo.marker(B);
edit.insert('constructor(val: T) { }');
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<string>(val: string): C<string>",
Dsig: "constructor D<T>(val: T): D<T>" // Cannot resolve signature
});
goTo.marker(C);
edit.deleteAtCaret('constructor(val: T) { }'.length);
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<T>(): C<T>", // Cannot resolve signature
Dsig: "constructor D<T>(val: T): D<T>" // Cannot resolve signature
});
goTo.marker(D);
edit.deleteAtCaret("val: T".length);
verify.quickInfos({
Asig: "constructor A<string>(): A<string>",
Bsig: "constructor B<string>(val: string): B<string>",
Csig: "constructor C<T>(): C<T>", // Cannot resolve signature
Dsig: "constructor D<string>(): D<string>"
}); |
#ifndef <API key>
#define <API key>
namespace perftools {
namespace gputools {
class Platform;
} // namespace gputools
} // namespace perftools
namespace tensorflow {
// Returns the GPU machine manager singleton, creating it and
// initializing the GPUs on the machine if needed the first time it is
// called.
perftools::gputools::Platform* GPUMachineManager();
} // namespace tensorflow
#endif // <API key> |
layout: "docs_api"
version: "1.0.0-beta.14"
versionHref: "/docs"
path: "api/directive/onSwipeRight/"
title: "on-swipe-right"
header_sub_title: "Directive in module ionic"
doc: "onSwipeRight"
docType: "directive"
<div class="improve-docs">
<a href='http://github.com/driftyco/ionic/tree/master/js/angular/directive/gesture.js#L188'>
View Source
</a>
<a href='http://github.com/driftyco/ionic/edit/master/js/angular/directive/gesture.js#L188'>
Improve this doc
</a>
</div>
<h1 class="api-title">
on-swipe-right
</h1>
Called when a moving touch has a high velocity moving to the right.
<h2 id="usage">Usage</h2>
html
<button on-swipe-right="onSwipeRight()" class="button">Test</button> |
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.16.0
// source: envoy/type/matcher/v3/value.proto
package <API key>
import (
_ "github.com/cncf/xds/go/udpa/annotations"
_ "github.com/envoyproxy/protoc-gen-validate/validate"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.<API key>
// Specifies the way to match a ProtobufWkt::Value. Primitive values and ListValue are supported.
// StructValue is not supported and is always not matched.
// [#next-free-field: 7]
type ValueMatcher struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Specifies how to match a value.
// Types that are assignable to MatchPattern:
// *<API key>
// *<API key>
// *<API key>
// *<API key>
// *<API key>
// *<API key>
MatchPattern <API key> `protobuf_oneof:"match_pattern"`
}
func (x *ValueMatcher) Reset() {
*x = ValueMatcher{}
if protoimpl.UnsafeEnabled {
mi := &<API key>[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ValueMatcher) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValueMatcher) ProtoMessage() {}
func (x *ValueMatcher) ProtoReflect() protoreflect.Message {
mi := &<API key>[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValueMatcher.ProtoReflect.Descriptor instead.
func (*ValueMatcher) Descriptor() ([]byte, []int) {
return <API key>(), []int{0}
}
func (m *ValueMatcher) GetMatchPattern() <API key> {
if m != nil {
return m.MatchPattern
}
return nil
}
func (x *ValueMatcher) GetNullMatch() *<API key> {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.NullMatch
}
return nil
}
func (x *ValueMatcher) GetDoubleMatch() *DoubleMatcher {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.DoubleMatch
}
return nil
}
func (x *ValueMatcher) GetStringMatch() *StringMatcher {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.StringMatch
}
return nil
}
func (x *ValueMatcher) GetBoolMatch() bool {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.BoolMatch
}
return false
}
func (x *ValueMatcher) GetPresentMatch() bool {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.PresentMatch
}
return false
}
func (x *ValueMatcher) GetListMatch() *ListMatcher {
if x, ok := x.GetMatchPattern().(*<API key>); ok {
return x.ListMatch
}
return nil
}
type <API key> interface {
<API key>()
}
type <API key> struct {
// If specified, a match occurs if and only if the target value is a NullValue.
NullMatch *<API key> `protobuf:"bytes,1,opt,name=null_match,json=nullMatch,proto3,oneof"`
}
type <API key> struct {
// If specified, a match occurs if and only if the target value is a double value and is
// matched to this field.
DoubleMatch *DoubleMatcher `protobuf:"bytes,2,opt,name=double_match,json=doubleMatch,proto3,oneof"`
}
type <API key> struct {
// If specified, a match occurs if and only if the target value is a string value and is
// matched to this field.
StringMatch *StringMatcher `protobuf:"bytes,3,opt,name=string_match,json=stringMatch,proto3,oneof"`
}
type <API key> struct {
// If specified, a match occurs if and only if the target value is a bool value and is equal
// to this field.
BoolMatch bool `protobuf:"varint,4,opt,name=bool_match,json=boolMatch,proto3,oneof"`
}
type <API key> struct {
// If specified, value match will be performed based on whether the path is referring to a
// valid primitive value in the metadata. If the path is referring to a non-primitive value,
// the result is always not matched.
PresentMatch bool `protobuf:"varint,5,opt,name=present_match,json=presentMatch,proto3,oneof"`
}
type <API key> struct {
// If specified, a match occurs if and only if the target value is a list value and
// is matched to this field.
ListMatch *ListMatcher `protobuf:"bytes,6,opt,name=list_match,json=listMatch,proto3,oneof"`
}
func (*<API key>) <API key>() {}
func (*<API key>) <API key>() {}
func (*<API key>) <API key>() {}
func (*<API key>) <API key>() {}
func (*<API key>) <API key>() {}
func (*<API key>) <API key>() {}
// Specifies the way to match a list value.
type ListMatcher struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Types that are assignable to MatchPattern:
// *ListMatcher_OneOf
MatchPattern <API key> `protobuf_oneof:"match_pattern"`
}
func (x *ListMatcher) Reset() {
*x = ListMatcher{}
if protoimpl.UnsafeEnabled {
mi := &<API key>[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListMatcher) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListMatcher) ProtoMessage() {}
func (x *ListMatcher) ProtoReflect() protoreflect.Message {
mi := &<API key>[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListMatcher.ProtoReflect.Descriptor instead.
func (*ListMatcher) Descriptor() ([]byte, []int) {
return <API key>(), []int{1}
}
func (m *ListMatcher) GetMatchPattern() <API key> {
if m != nil {
return m.MatchPattern
}
return nil
}
func (x *ListMatcher) GetOneOf() *ValueMatcher {
if x, ok := x.GetMatchPattern().(*ListMatcher_OneOf); ok {
return x.OneOf
}
return nil
}
type <API key> interface {
<API key>()
}
type ListMatcher_OneOf struct {
// If specified, at least one of the values in the list must match the value specified.
OneOf *ValueMatcher `protobuf:"bytes,1,opt,name=one_of,json=oneOf,proto3,oneof"`
}
func (*ListMatcher_OneOf) <API key>() {}
// NullMatch is an empty message to specify a null value.
type <API key> struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *<API key>) Reset() {
*x = <API key>{}
if protoimpl.UnsafeEnabled {
mi := &<API key>[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *<API key>) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*<API key>) ProtoMessage() {}
func (x *<API key>) ProtoReflect() protoreflect.Message {
mi := &<API key>[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use <API key>.ProtoReflect.Descriptor instead.
func (*<API key>) Descriptor() ([]byte, []int) {
return <API key>(), []int{0, 0}
}
var <API key> protoreflect.FileDescriptor
var <API key> = []byte{
0x0a, 0x21, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74,
0x63, 0x68, 0x65, 0x72, 0x2f, 0x76, 0x33, 0x2f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x15, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e,
0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x1a, 0x22, 0x65, 0x6e, 0x76, 0x6f,
0x79, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2f, 0x76,
0x33, 0x2f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x22,
0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x61, 0x74, 0x63, 0x68,
0x65, 0x72, 0x2f, 0x76, 0x33, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x1a, 0x1d, 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x1a, 0x21, 0x75, 0x64, 0x70, 0x61, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76,
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x03,
0x0a, 0x0c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x12, 0x4e,
0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e,
0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65,
0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x61, 0x74, 0x63,
0x68, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x49,
0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x44, 0x6f, 0x75,
0x62, 0x6c, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f,
0x75, 0x62, 0x6c, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x49, 0x0a, 0x0c, 0x73, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x24, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74,
0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x61,
0x74, 0x63, 0x68, 0x65, 0x72, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d,
0x61, 0x74, 0x63, 0x68, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x6d, 0x61, 0x74,
0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c,
0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x25, 0x0a, 0x0d, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74,
0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0c,
0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x43, 0x0a, 0x0a,
0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x22, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61,
0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x74,
0x63, 0x68, 0x65, 0x72, 0x48, 0x00, 0x52, 0x09, 0x6c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x74, 0x63,
0x68, 0x1a, 0x3d, 0x0a, 0x09, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x3a, 0x30,
0x9a, 0xc5, 0x88, 0x1e, 0x2b, 0x0a, 0x29, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70,
0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4d,
0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x4d, 0x61, 0x74, 0x63, 0x68,
0x3a, 0x26, 0x9a, 0xc5, 0x88, 0x1e, 0x21, 0x0a, 0x1f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74,
0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x56, 0x61, 0x6c, 0x75,
0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x42, 0x14, 0x0a, 0x0d, 0x6d, 0x61, 0x74, 0x63,
0x68, 0x5f, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x22, 0x88,
0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x12, 0x3c,
0x0a, 0x06, 0x6f, 0x6e, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23,
0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63,
0x68, 0x65, 0x72, 0x2e, 0x76, 0x33, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4d, 0x61, 0x74, 0x63,
0x68, 0x65, 0x72, 0x48, 0x00, 0x52, 0x05, 0x6f, 0x6e, 0x65, 0x4f, 0x66, 0x3a, 0x25, 0x9a, 0xc5,
0x88, 0x1e, 0x20, 0x0a, 0x1e, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e,
0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x61, 0x74, 0x63,
0x68, 0x65, 0x72, 0x42, 0x14, 0x0a, 0x0d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x70, 0x61, 0x74,
0x74, 0x65, 0x72, 0x6e, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x42, 0x3b, 0x0a, 0x23, 0x69, 0x6f, 0x2e,
0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x65, 0x6e, 0x76, 0x6f, 0x79,
0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x76, 0x33,
0x42, 0x0a, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0xba, 0x80,
0xc8, 0xd1, 0x06, 0x02, 0x10, 0x02, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
<API key> sync.Once
<API key> = <API key>
)
func <API key>() []byte {
<API key>.Do(func() {
<API key> = protoimpl.X.CompressGZIP(<API key>)
})
return <API key>
}
var <API key> = make([]protoimpl.MessageInfo, 3)
var <API key> = []interface{}{
(*ValueMatcher)(nil), // 0: envoy.type.matcher.v3.ValueMatcher
(*ListMatcher)(nil), // 1: envoy.type.matcher.v3.ListMatcher
(*<API key>)(nil), // 2: envoy.type.matcher.v3.ValueMatcher.NullMatch
(*DoubleMatcher)(nil), // 3: envoy.type.matcher.v3.DoubleMatcher
(*StringMatcher)(nil), // 4: envoy.type.matcher.v3.StringMatcher
}
var <API key> = []int32{
2, // 0: envoy.type.matcher.v3.ValueMatcher.null_match:type_name -> envoy.type.matcher.v3.ValueMatcher.NullMatch
3, // 1: envoy.type.matcher.v3.ValueMatcher.double_match:type_name -> envoy.type.matcher.v3.DoubleMatcher
4, // 2: envoy.type.matcher.v3.ValueMatcher.string_match:type_name -> envoy.type.matcher.v3.StringMatcher
1, // 3: envoy.type.matcher.v3.ValueMatcher.list_match:type_name -> envoy.type.matcher.v3.ListMatcher
0, // 4: envoy.type.matcher.v3.ListMatcher.one_of:type_name -> envoy.type.matcher.v3.ValueMatcher
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { <API key>() }
func <API key>() {
if <API key> != nil {
return
}
<API key>()
<API key>()
if !protoimpl.UnsafeEnabled {
<API key>[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ValueMatcher); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
<API key>[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMatcher); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
<API key>[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*<API key>); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
<API key>[0].OneofWrappers = []interface{}{
(*<API key>)(nil),
(*<API key>)(nil),
(*<API key>)(nil),
(*<API key>)(nil),
(*<API key>)(nil),
(*<API key>)(nil),
}
<API key>[1].OneofWrappers = []interface{}{
(*ListMatcher_OneOf)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: <API key>,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: <API key>,
DependencyIndexes: <API key>,
MessageInfos: <API key>,
}.Build()
<API key> = out.File
<API key> = nil
<API key> = nil
<API key> = nil
} |
// Purpose: Combat behaviors for AIs in a relatively <API key> mode.
// Lots of cover taking and attempted shots out of cover.
#include "cbase.h"
#include "ai_hint.h"
#include "ai_node.h"
#include "ai_navigator.h"
#include "ai_tacticalservices.h"
#include "<API key>.h"
#include "ai_senses.h"
#include "ai_squad.h"
#include "ai_goalentity.h"
#include "ndebugoverlay.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define <API key> Vector( FLT_MAX, FLT_MAX, FLT_MAX )
ConVar DrawBattleLines( "ai_drawbattlelines", "0", FCVAR_CHEAT );
static AI_StandoffParams_t <API key> = { AIHCR_MOVE_ON_COVER, true, 1.5, 2.5, 1, 3, 25, 0 };
#define MAKE_ACTMAP_KEY( posture, activity ) ( (((unsigned)(posture)) << 16) | ((unsigned)(activity)) )
// #define DEBUG_STANDOFF 1
#ifdef DEBUG_STANDOFF
#define StandoffMsg( msg ) DevMsg( GetOuter(), msg )
#define StandoffMsg1( msg, a ) DevMsg( GetOuter(), msg, a )
#define StandoffMsg2( msg, a, b ) DevMsg( GetOuter(), msg, a, b )
#define StandoffMsg3( msg, a, b, c ) DevMsg( GetOuter(), msg, a, b, c )
#define StandoffMsg4( msg, a, b, c, d ) DevMsg( GetOuter(), msg, a, b, c, d )
#define StandoffMsg5( msg, a, b, c, d, e ) DevMsg( GetOuter(), msg, a, b, c, d, e )
#else
#define StandoffMsg( msg ) ((void)0)
#define StandoffMsg1( msg, a ) ((void)0)
#define StandoffMsg2( msg, a, b ) ((void)0)
#define StandoffMsg3( msg, a, b, c ) ((void)0)
#define StandoffMsg4( msg, a, b, c, d ) ((void)0)
#define StandoffMsg5( msg, a, b, c, d, e ) ((void)0)
#endif
// CAI_BattleLine
const float AIBL_THINK_INTERVAL = 0.3;
class CAI_BattleLine : public CBaseEntity
{
DECLARE_CLASS( CAI_BattleLine, CBaseEntity );
public:
string_t m_iszActor;
bool m_fActive;
bool m_fStrict;
void Spawn()
{
if ( m_fActive )
{
SetThink(&CAI_BattleLine::MovementThink);
SetNextThink( gpGlobals->curtime + AIBL_THINK_INTERVAL );
m_SelfMoveMonitor.SetMark( this, 60 );
}
}
virtual void InputActivate( inputdata_t &inputdata )
{
if ( !m_fActive )
{
m_fActive = true;
<API key>();
SetThink(&CAI_BattleLine::MovementThink);
SetNextThink( gpGlobals->curtime + AIBL_THINK_INTERVAL );
m_SelfMoveMonitor.SetMark( this, 60 );
}
}
virtual void InputDeactivate( inputdata_t &inputdata )
{
if ( m_fActive )
{
m_fActive = false;
<API key>();
SetThink(NULL);
}
}
void UpdateOnRemove()
{
if ( m_fActive )
{
m_fActive = false;
<API key>();
}
BaseClass::UpdateOnRemove();
}
bool Affects( CAI_BaseNPC *pNpc )
{
const char *pszNamedActor = STRING( m_iszActor );
if ( pNpc->NameMatches( pszNamedActor ) ||
pNpc->ClassMatches( pszNamedActor ) ||
( pNpc->GetSquad() && stricmp( pNpc->GetSquad()->GetName(), pszNamedActor ) == 0 ) )
{
return true;
}
return false;
}
void MovementThink()
{
if ( m_SelfMoveMonitor.TargetMoved( this ) )
{
<API key>();
m_SelfMoveMonitor.SetMark( this, 60 );
}
SetNextThink( gpGlobals->curtime + AIBL_THINK_INTERVAL );
}
private:
void <API key>()
{
for ( int i = 0; i < g_AI_Manager.NumAIs(); i++ )
{
CAI_BaseNPC *pNpc = (g_AI_Manager.AccessAIs())[i];
if ( Affects( pNpc ) )
{
<API key> *pBehavior;
if ( pNpc->GetBehavior( &pBehavior ) )
{
pBehavior-><API key>();
}
}
}
}
CAI_MoveMonitor m_SelfMoveMonitor;
DECLARE_DATADESC();
};
<API key>( ai_battle_line, CAI_BattleLine );
BEGIN_DATADESC( CAI_BattleLine )
DEFINE_KEYFIELD( m_iszActor, FIELD_STRING, "Actor" ),
DEFINE_KEYFIELD( m_fActive, FIELD_BOOLEAN, "Active" ),
DEFINE_KEYFIELD( m_fStrict, FIELD_BOOLEAN, "Strict" ),
DEFINE_EMBEDDED( m_SelfMoveMonitor ),
// Inputs
DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ),
DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ),
DEFINE_THINKFUNC( MovementThink ),
END_DATADESC()
// <API key>
<API key>( AI_StandoffParams_t )
DEFINE_FIELD( hintChangeReaction, FIELD_INTEGER ),
DEFINE_FIELD( fPlayerIsBattleline, FIELD_BOOLEAN ),
DEFINE_FIELD( fCoverOnReload, FIELD_BOOLEAN ),
DEFINE_FIELD( minTimeShots, FIELD_FLOAT ),
DEFINE_FIELD( maxTimeShots, FIELD_FLOAT ),
DEFINE_FIELD( minShots, FIELD_INTEGER ),
DEFINE_FIELD( maxShots, FIELD_INTEGER ),
DEFINE_FIELD( oddsCover, FIELD_INTEGER ),
DEFINE_FIELD( fStayAtCover, FIELD_BOOLEAN ),
DEFINE_FIELD( flAbandonTimeLimit, FIELD_FLOAT ),
END_DATADESC();
BEGIN_DATADESC( <API key> )
DEFINE_FIELD( m_fActive, FIELD_BOOLEAN ),
DEFINE_FIELD( m_fTestNoDamage, FIELD_BOOLEAN ),
DEFINE_FIELD( <API key>, <API key> ),
DEFINE_FIELD( m_posture, FIELD_INTEGER ),
DEFINE_EMBEDDED( m_params ),
DEFINE_FIELD( m_hStandoffGoal, FIELD_EHANDLE ),
DEFINE_FIELD( m_fTakeCover, FIELD_BOOLEAN ),
DEFINE_FIELD( m_SavedDistTooFar, FIELD_FLOAT ),
DEFINE_FIELD( m_fForceNewEnemy, FIELD_BOOLEAN ),
DEFINE_EMBEDDED( m_PlayerMoveMonitor ),
DEFINE_EMBEDDED( <API key> ),
DEFINE_EMBEDDED( <API key> ),
DEFINE_EMBEDDED( <API key> ),
// <API key> (not saved, only an in-think item)
// m_BattleLines (not saved, rebuilt)
DEFINE_FIELD( m_fIgnoreFronts, FIELD_BOOLEAN ),
// m_ActivityMap (not saved, rebuilt)
// <API key> (not saved, rebuilt)
DEFINE_FIELD( m_nSavedMinShots, FIELD_INTEGER ),
DEFINE_FIELD( m_nSavedMaxShots, FIELD_INTEGER ),
DEFINE_FIELD( m_flSavedMinRest, FIELD_FLOAT ),
DEFINE_FIELD( m_flSavedMaxRest, FIELD_FLOAT ),
END_DATADESC();
<API key>::<API key>( CAI_BaseNPC *pOuter )
: <API key>( pOuter )
{
m_fActive = false;
SetParameters( <API key> );
SetPosture( AIP_STANDING );
m_SavedDistTooFar = FLT_MAX;
m_fForceNewEnemy = false;
<API key>.Set( 3.0, 6.0 );
m_fIgnoreFronts = false;
<API key> = false;
}
void <API key>::SetActive( bool fActive )
{
if ( fActive != m_fActive )
{
if ( fActive )
{
GetOuter()->SpeakSentence( <API key> );
}
else
{
GetOuter()->SpeakSentence( <API key> );
}
m_fActive = fActive;
<API key>();
}
}
void <API key>::SetParameters( const AI_StandoffParams_t ¶ms, CAI_GoalEntity *pGoalEntity )
{
m_params = params;
m_hStandoffGoal = pGoalEntity;
<API key> = <API key>;
if ( GetOuter() && GetOuter()->GetShotRegulator() )
{
GetOuter()->GetShotRegulator()-><API key>( m_params.minShots, m_params.maxShots );
GetOuter()->GetShotRegulator()->SetRestInterval( m_params.minTimeShots, m_params.maxTimeShots );
}
}
bool <API key>::CanSelectSchedule()
{
if ( !<API key> )
m_fActive = false;
if ( !m_fActive )
return false;
return ( GetNpcState() == NPC_STATE_COMBAT && GetOuter()->GetActiveWeapon() != NULL );
}
void <API key>::Spawn()
{
BaseClass::Spawn();
<API key>();
}
void <API key>::<API key>()
{
m_fTakeCover = true;
// FIXME: Improve!!!
GetOuter()->GetShotRegulator()-><API key>( &m_nSavedMinShots, &m_nSavedMaxShots );
GetOuter()->GetShotRegulator()->GetRestInterval( &m_flSavedMinRest, &m_flSavedMaxRest );
GetOuter()->GetShotRegulator()-><API key>( m_params.minShots, m_params.maxShots );
GetOuter()->GetShotRegulator()->SetRestInterval( m_params.minTimeShots, m_params.maxTimeShots );
GetOuter()->GetShotRegulator()->Reset();
m_SavedDistTooFar = GetOuter()->m_flDistTooFar;
GetOuter()->m_flDistTooFar = FLT_MAX;
<API key>.Set( 8, false );
<API key>.Set( 8, 16, false );
<API key>();
}
void <API key>::<API key>()
{
GetOuter()->GetShotRegulator()-><API key>( m_params.minShots, m_params.maxShots );
GetOuter()->GetShotRegulator()->SetRestInterval( m_params.minTimeShots, m_params.maxTimeShots );
}
void <API key>::<API key>()
{
UnlockHintNode();
<API key> = <API key>;
GetOuter()->m_flDistTooFar = m_SavedDistTooFar;
// FIXME: Improve!!!
GetOuter()->GetShotRegulator()-><API key>( m_nSavedMinShots, m_nSavedMaxShots );
GetOuter()->GetShotRegulator()->SetRestInterval( m_flSavedMinRest, m_flSavedMaxRest );
}
void <API key>::PrescheduleThink()
{
VPROF_BUDGET( "<API key>::PrescheduleThink", <API key> );
BaseClass::PrescheduleThink();
if( DrawBattleLines.GetInt() != 0 )
{
CBaseEntity *pEntity = NULL;
while ((pEntity = gEntList.<API key>( pEntity, "ai_battle_line" )) != NULL)
{
// Visualize the battle line and its normal.
CAI_BattleLine *pLine = dynamic_cast<CAI_BattleLine *>(pEntity);
if( pLine->m_fActive )
{
Vector normal;
pLine->GetVectors( &normal, NULL, NULL );
NDebugOverlay::Line( pLine->GetAbsOrigin() - Vector( 0, 0, 64 ), pLine->GetAbsOrigin() + Vector(0,0,64), 0,255,0, false, 0.1 );
}
}
}
}
void <API key>::GatherConditions()
{
CBaseEntity *pLeader = GetPlayerLeader();
if ( pLeader && <API key>.Expired() )
{
if ( m_PlayerMoveMonitor.IsMarkSet() )
{
if (m_PlayerMoveMonitor.TargetMoved( pLeader ) )
{
<API key>();
m_PlayerMoveMonitor.ClearMark();
}
}
else
{
m_PlayerMoveMonitor.SetMark( pLeader, 60 );
}
}
if ( m_fForceNewEnemy )
{
<API key>.Reset();
GetOuter()->SetEnemy( NULL );
DevMsg(2, "Forcing lose enemy from standoff\n");
}
BaseClass::GatherConditions();
m_fForceNewEnemy = false;
ClearCondition( <API key> );
bool bAbandonStandoff = false;
CAI_Squad *pSquad = GetOuter()->GetSquad();
AISquadIter_t iter;
if ( GetEnemy() )
{
AI_EnemyInfo_t *pEnemyInfo = GetOuter()->GetEnemies()->Find( GetEnemy() );
if ( pEnemyInfo &&
m_params.flAbandonTimeLimit > 0 &&
( ( pEnemyInfo->timeAtFirstHand != AI_INVALID_TIME &&
gpGlobals->curtime - pEnemyInfo->timeLastSeen > m_params.flAbandonTimeLimit ) ||
( pEnemyInfo->timeAtFirstHand == AI_INVALID_TIME &&
gpGlobals->curtime - pEnemyInfo->timeFirstSeen > m_params.flAbandonTimeLimit * 2 ) ) )
{
SetCondition( <API key> );
bAbandonStandoff = true;
if ( pSquad )
{
for ( CAI_BaseNPC *pSquadMate = pSquad->GetFirstMember( &iter ); pSquadMate; pSquadMate = pSquad->GetNextMember( &iter ) )
{
if ( pSquadMate->IsAlive() && pSquadMate != GetOuter() )
{
<API key> *pSquadmateStandoff;
pSquadMate->GetBehavior( &pSquadmateStandoff );
if ( pSquadmateStandoff && pSquadmateStandoff->IsActive() &&
pSquadmateStandoff->m_hStandoffGoal == m_hStandoffGoal &&
!pSquadmateStandoff->HasCondition( <API key> ) )
{
bAbandonStandoff = false;
break;
}
}
}
}
}
}
if ( bAbandonStandoff )
{
if ( pSquad )
{
for ( CAI_BaseNPC *pSquadMate = pSquad->GetFirstMember( &iter ); pSquadMate; pSquadMate = pSquad->GetNextMember( &iter ) )
{
<API key> *pSquadmateStandoff;
pSquadMate->GetBehavior( &pSquadmateStandoff );
if ( pSquadmateStandoff && pSquadmateStandoff->IsActive() && pSquadmateStandoff->m_hStandoffGoal == m_hStandoffGoal )
pSquadmateStandoff->SetActive( false );
}
}
else
SetActive( false );
}
else if ( GetOuter()->m_debugOverlays & <API key> )
{
if( DrawBattleLines.GetInt() != 0 )
{
if ( IsBehindBattleLines( GetAbsOrigin() ) )
{
NDebugOverlay::Box( GetOuter()->GetAbsOrigin(), -Vector(48,48,4), Vector(48,48,4), 255,0,0,8, 0.1 );
}
else
{
NDebugOverlay::Box( GetOuter()->GetAbsOrigin(), -Vector(48,48,4), Vector(48,48,4), 0,255,0,8, 0.1 );
}
}
}
}
int <API key>::<API key>( void )
{
// Check if need to reload
if ( HasCondition ( <API key> ) || HasCondition ( <API key> ))
{
StandoffMsg( "Out of ammo, reloading\n" );
if ( m_params.fCoverOnReload )
{
GetOuter()->SpeakSentence( <API key> );
return <API key>;
}
return SCHED_RELOAD;
}
// Otherwise, update planned shots to fire before taking cover again
if ( HasCondition( COND_LIGHT_DAMAGE ) )
{
// if hurt:
int iPercent = random->RandomInt(0,99);
if ( iPercent <= m_params.oddsCover && GetEnemy() != NULL )
{
<API key>();
StandoffMsg( "Hurt, firing one more shot before cover\n" );
if ( !GetOuter()->GetShotRegulator()->IsInRestInterval() )
{
GetOuter()->GetShotRegulator()-><API key>( 1 );
}
}
}
return SCHED_NONE;
}
int <API key>::<API key>( void )
{
if ( m_fTakeCover )
{
m_fTakeCover = false;
if ( GetEnemy() )
{
GetOuter()->SpeakSentence( <API key> );
StandoffMsg( "Taking forced cover\n" );
return <API key>;
}
}
if ( GetOuter()->GetShotRegulator()->IsInRestInterval() )
{
StandoffMsg( "Regulated to not shoot\n" );
if ( GetHintType() == <API key> )
SetPosture( AIP_CROUCHING );
else
SetPosture( AIP_STANDING );
if ( random->RandomInt(0,99) < 80 )
<API key>();
return <API key>;
}
return SCHED_NONE;
}
int <API key>::<API key>( void )
{
if ( HasCondition( COND_ENEMY_OCCLUDED ) )
{
if ( GetPosture() == AIP_CROUCHING )
{
// force a stand up, just in case
GetOuter()->SpeakSentence( <API key> );
StandoffMsg( "Crouching, standing up to gain LOS\n" );
SetPosture( AIP_PEEKING );
return SCHED_STANDOFF;
}
else if ( GetPosture() == AIP_PEEKING )
{
if ( <API key>.Expired() )
{
// Look for a new enemy
m_fForceNewEnemy = true;
StandoffMsg( "Looking for enemy\n" );
}
}
#if 0
else
{
return <API key>;
}
#endif
}
return SCHED_NONE;
}
int <API key>::<API key>( void )
{
if ( GetPosture() == AIP_PEEKING || GetPosture() == AIP_STANDING )
{
if ( !HasCondition( <API key> ) &&
!HasCondition( <API key> ) &&
HasCondition( <API key> ) )
{
if ( GetOuter()->GetActiveWeapon() && ( GetOuter()->GetActiveWeapon()->CapabilitiesGet() & <API key> ) )
{
if ( !HasCondition( COND_ENEMY_OCCLUDED ) || random->RandomInt(0,99) < 50 )
// Don't advance, just fire anyway
return SCHED_RANGE_ATTACK1;
}
}
}
return SCHED_NONE;
}
int <API key>::SelectSchedule( void )
{
switch ( GetNpcState() )
{
case NPC_STATE_COMBAT:
{
int schedule = SCHED_NONE;
schedule = <API key>();
if ( schedule != SCHED_NONE )
return schedule;
schedule = <API key>();
if ( schedule != SCHED_NONE )
return schedule;
schedule = <API key>();
if ( schedule != SCHED_NONE )
return schedule;
schedule = <API key>();
if ( schedule != SCHED_NONE )
return schedule;
break;
}
}
return BaseClass::SelectSchedule();
}
int <API key>::TranslateSchedule( int schedule )
{
if ( schedule == SCHED_CHASE_ENEMY )
{
StandoffMsg( "trying <API key>\n" );
return <API key>;
}
return BaseClass::TranslateSchedule( schedule );
}
void <API key>::<API key>()
{
BaseClass::<API key>();
if ( IsCurSchedule( <API key> ) )
GetOuter()-><API key>( COND_NEW_ENEMY );
}
Activity <API key>::GetMappedActivity( AI_Posture_t posture, Activity activity )
{
if ( posture != AIP_STANDING )
{
unsigned short <API key> = m_ActivityMap.Find( MAKE_ACTMAP_KEY( posture, activity ) );
if ( <API key> != m_ActivityMap.InvalidIndex() )
{
Activity result = m_ActivityMap[<API key>];
return result;
}
}
return ACT_INVALID;
}
Activity <API key>::<API key>( Activity activity )
{
Activity coverActivity = GetCoverActivity();
if ( coverActivity != ACT_INVALID )
{
if ( activity == ACT_IDLE )
activity = coverActivity;
if ( GetPosture() == AIP_STANDING && coverActivity == ACT_COVER_LOW )
SetPosture( AIP_CROUCHING );
}
Activity result = GetMappedActivity( GetPosture(), activity );
if ( result != ACT_INVALID)
return result;
return BaseClass::<API key>( activity );
}
// Purpose:
// Input : &vecPos -
void <API key>::<API key>( const Vector &vecPos )
{
<API key> = vecPos;
UpdateBattleLines();
<API key>();
GetOuter()->ClearSchedule( "Standoff goal position changed" );
}
// Purpose:
// Input : &vecPos -
void <API key>::<API key>()
{
if ( <API key> != <API key> )
{
<API key> = <API key>;
UpdateBattleLines();
<API key>();
GetOuter()->ClearSchedule( "Standoff goal position cleared" );
}
}
// Purpose:
// Output : Vector
Vector <API key>::<API key>()
{
if( <API key> != <API key> )
{
return <API key>;
}
else if( PlayerIsLeading() )
{
return UTIL_GetLocalPlayer()->GetAbsOrigin();
}
else
{
CAI_BattleLine *pBattleLine = NULL;
for (;;)
{
pBattleLine = (CAI_BattleLine *)gEntList.<API key>( pBattleLine, "ai_battle_line" );
if ( !pBattleLine )
break;
if ( pBattleLine->m_fActive && pBattleLine->Affects( GetOuter() ) )
{
StandoffMsg1( "Using battleline %s as goal\n", STRING( pBattleLine->GetEntityName() ) );
return pBattleLine->GetAbsOrigin();
}
}
}
return GetAbsOrigin();
}
void <API key>::UpdateBattleLines()
{
if ( <API key>.EnterThink() )
{
// @TODO (toml 06-19-03): This is the quick to code thing. Could use some optimization/caching to not recalc everything (up to) each think
m_BattleLines.RemoveAll();
bool bHaveGoalPosition = ( <API key> != <API key> );
if ( bHaveGoalPosition )
{
// If we have a valid standoff goal position, it takes precendence.
const float DIST_GOAL_PLANE = 180;
BattleLine_t goalLine;
if ( <API key>( &goalLine.normal ) )
{
goalLine.point = <API key>() + goalLine.normal * DIST_GOAL_PLANE;
m_BattleLines.AddToTail( goalLine );
}
}
else if ( PlayerIsLeading() && GetEnemy() )
{
if ( m_params.fPlayerIsBattleline )
{
const float DIST_PLAYER_PLANE = 180;
CBaseEntity *pPlayer = UTIL_GetLocalPlayer();
BattleLine_t playerLine;
if ( <API key>( &playerLine.normal ) )
{
playerLine.point = pPlayer->GetAbsOrigin() + playerLine.normal * DIST_PLAYER_PLANE;
m_BattleLines.AddToTail( playerLine );
}
}
}
CAI_BattleLine *pBattleLine = NULL;
for (;;)
{
pBattleLine = (CAI_BattleLine *)gEntList.<API key>( pBattleLine, "ai_battle_line" );
if ( !pBattleLine )
break;
if ( pBattleLine->m_fActive && (pBattleLine->m_fStrict || !bHaveGoalPosition ) && pBattleLine->Affects( GetOuter() ) )
{
BattleLine_t battleLine;
battleLine.point = pBattleLine->GetAbsOrigin();
battleLine.normal = UTIL_YawToVector( pBattleLine->GetAbsAngles().y );
m_BattleLines.AddToTail( battleLine );
}
}
}
}
bool <API key>::IsBehindBattleLines( const Vector &point )
{
UpdateBattleLines();
Vector vecToPoint;
for ( int i = 0; i < m_BattleLines.Count(); i++ )
{
vecToPoint = point - m_BattleLines[i].point;
VectorNormalize( vecToPoint );
vecToPoint.z = 0;
if ( DotProduct( m_BattleLines[i].normal, vecToPoint ) > 0 )
{
if( DrawBattleLines.GetInt() != 0 )
{
NDebugOverlay::Box( point, -Vector(48,48,4), Vector(48,48,4), 0,255,0,8, 1 );
NDebugOverlay::Line( point, GetOuter()->GetAbsOrigin(), 0,255,0,true, 1 );
}
return false;
}
}
if( DrawBattleLines.GetInt() != 0 )
{
NDebugOverlay::Box( point, -Vector(48,48,4), Vector(48,48,4), 255,0,0,8, 1 );
NDebugOverlay::Line( point, GetOuter()->GetAbsOrigin(), 255,0,0,true, 1 );
}
return true;
}
bool <API key>::IsValidCover( const Vector &vecCoverLocation, const CAI_Hint *pHint )
{
if ( !BaseClass::IsValidCover( vecCoverLocation, pHint ) )
return false;
if ( IsCurSchedule( <API key> ) )
return true;
return ( m_fIgnoreFronts || IsBehindBattleLines( vecCoverLocation ) );
}
bool <API key>::<API key>( const Vector &vLocation, CAI_Node *pNode, const CAI_Hint *pHint )
{
if ( !BaseClass::<API key>( vLocation, pNode, pHint ) )
return false;
return ( m_fIgnoreFronts || IsBehindBattleLines( vLocation ) );
}
void <API key>::StartTask( const Task_t *pTask )
{
bool fCallBase = false;
switch ( pTask->iTask )
{
case TASK_RANGE_ATTACK1:
{
fCallBase = true;
break;
}
case <API key>:
{
StandoffMsg( "<API key>\n" );
// If within time window to force change
if ( !m_params.fStayAtCover && (!<API key>.Expired() || <API key>.Expired()) )
{
<API key>.Force();
<API key>.Set( 8, 16, false );
// @TODO (toml 03-24-03): clean this up be tool-izing base tasks. Right now, this is here to force to not use lateral cover search
CBaseEntity *pEntity = GetEnemy();
if ( pEntity == NULL )
{
// Find cover from self if no enemy available
pEntity = GetOuter();
}
CBaseEntity *pLeader = GetPlayerLeader();
if ( pLeader )
{
m_PlayerMoveMonitor.SetMark( pLeader, 60 );
}
Vector coverPos = vec3_origin;
<API key> * pTacticalServices = GetTacticalServices();
const Vector & enemyPos = pEntity->GetAbsOrigin();
Vector enemyEyePos = pEntity->EyePosition();
float coverRadius = GetOuter()->CoverRadius();
const Vector & goalPos = <API key>();
bool bTryGoalPosFirst = true;
if( pLeader && <API key> == <API key> )
{
if( random->RandomInt(1, 100) <= 50 )
{
// Half the time, if the player is leading, try to find a spot near them
bTryGoalPosFirst = false;
StandoffMsg( "Not trying goal pos\n" );
}
}
if( bTryGoalPosFirst )
{
// Firstly, try to find cover near the goal position.
pTacticalServices->FindCoverPos( goalPos, enemyPos, enemyEyePos, 0, 15*12, &coverPos );
if ( coverPos == vec3_origin )
pTacticalServices->FindCoverPos( goalPos, enemyPos, enemyEyePos, 15*12-0.1, 40*12, &coverPos );
StandoffMsg1( "Trying goal pos, %s\n", ( coverPos == vec3_origin ) ? "failed" : "succeeded" );
}
if ( coverPos == vec3_origin )
{
// Otherwise, find a node near to self
StandoffMsg( "Looking for near cover\n" );
if ( !GetTacticalServices()->FindCoverPos( enemyPos, enemyEyePos, 0, coverRadius, &coverPos ) )
{
// Try local lateral cover
if ( !GetTacticalServices()->FindLateralCover( enemyEyePos, 0, &coverPos ) )
{
// At this point, try again ignoring front lines. Any cover probably better than hanging out in the open
m_fIgnoreFronts = true;
if ( !GetTacticalServices()->FindCoverPos( enemyPos, enemyEyePos, 0, coverRadius, &coverPos ) )
{
if ( !GetTacticalServices()->FindLateralCover( enemyEyePos, 0, &coverPos ) )
{
Assert( coverPos == vec3_origin );
}
}
m_fIgnoreFronts = false;
}
}
}
if ( coverPos != vec3_origin )
{
AI_NavGoal_t goal(GOALTYPE_COVER, coverPos, ACT_RUN, AIN_HULL_TOLERANCE, AIN_DEF_FLAGS);
GetNavigator()->SetGoal( goal );
GetOuter()-><API key> = gpGlobals->curtime + pTask->flTaskData;
TaskComplete();
}
else
TaskFail(FAIL_NO_COVER);
}
else
{
fCallBase = true;
}
break;
}
default:
{
fCallBase = true;
}
}
if ( fCallBase )
BaseClass::StartTask( pTask );
}
void <API key>::OnChangeHintGroup( string_t oldGroup, string_t newGroup )
{
<API key>();
}
void <API key>::<API key>()
{
if ( m_params.hintChangeReaction > AIHCR_DEFAULT_AI )
<API key>.Set( 8.0, false );
if ( m_params.hintChangeReaction == <API key> )
m_fTakeCover = true;
}
bool <API key>::PlayerIsLeading()
{
CBaseEntity *pPlayer = AI_GetSinglePlayer();
return ( pPlayer && GetOuter()->IRelationType( pPlayer ) == D_LI );
}
CBaseEntity *<API key>::GetPlayerLeader()
{
CBaseEntity *pPlayer = AI_GetSinglePlayer();
if ( pPlayer && GetOuter()->IRelationType( pPlayer ) == D_LI )
return pPlayer;
return NULL;
}
bool <API key>::<API key>( Vector *pDir )
{
if ( GetEnemy() )
{
*pDir = GetEnemy()->GetAbsOrigin() - GetAbsOrigin();
VectorNormalize( *pDir );
pDir->z = 0;
return true;
}
return false;
}
Hint_e <API key>::GetHintType()
{
CAI_Hint *pHintNode = GetHintNode();
if ( pHintNode )
return pHintNode->HintType();
return HINT_NONE;
}
void <API key>::<API key>()
{
CAI_Hint *pHintNode = GetHintNode();
if ( pHintNode && pHintNode->GetNode() && pHintNode->GetNode()->IsLocked() )
pHintNode->GetNode()->Unlock();
}
void <API key>::UnlockHintNode()
{
CAI_Hint *pHintNode = GetHintNode();
if ( pHintNode )
{
if ( pHintNode->IsLocked() && pHintNode->IsLockedBy( GetOuter() ) )
pHintNode->Unlock();
CAI_Node *pNode = pHintNode->GetNode();
if ( pNode && pNode->IsLocked() )
pNode->Unlock();
ClearHintNode();
}
}
Activity <API key>::GetCoverActivity()
{
CAI_Hint *pHintNode = GetHintNode();
if ( pHintNode && pHintNode->HintType() == <API key> )
return GetOuter()->GetCoverActivity( pHintNode );
return ACT_INVALID;
}
struct <API key>
{
AI_Posture_t posture;
Activity activity;
const char * pszWeapon;
Activity translation;
};
void <API key>::<API key>()
{
<API key> mappings[] = // This array cannot be static, as some activity values are set on a per-map-load basis
{
{ AIP_CROUCHING, ACT_IDLE, NULL, ACT_COVER_LOW, },
{ AIP_CROUCHING, ACT_IDLE_ANGRY, NULL, ACT_COVER_LOW, },
{ AIP_CROUCHING, ACT_WALK, NULL, ACT_WALK_CROUCH, },
{ AIP_CROUCHING, ACT_RUN, NULL, ACT_RUN_CROUCH, },
{ AIP_CROUCHING, ACT_WALK_AIM, NULL, ACT_WALK_CROUCH_AIM, },
{ AIP_CROUCHING, ACT_RUN_AIM, NULL, ACT_RUN_CROUCH_AIM, },
{ AIP_CROUCHING, ACT_RELOAD, NULL, ACT_RELOAD_LOW, },
{ AIP_CROUCHING, <API key>, NULL, <API key>, },
{ AIP_CROUCHING, <API key>, NULL, <API key>, },
{ AIP_PEEKING, ACT_IDLE, NULL, ACT_RANGE_AIM_LOW, },
{ AIP_PEEKING, ACT_IDLE_ANGRY, NULL, ACT_RANGE_AIM_LOW, },
{ AIP_PEEKING, ACT_COVER_LOW, NULL, ACT_RANGE_AIM_LOW, },
{ AIP_PEEKING, ACT_RANGE_ATTACK1, NULL, <API key>, },
{ AIP_PEEKING, ACT_RELOAD, NULL, ACT_RELOAD_LOW, },
};
m_ActivityMap.RemoveAll();
CBaseCombatWeapon *pWeapon = GetOuter()->GetActiveWeapon();
const char *pszWeaponClass = ( pWeapon ) ? pWeapon->GetClassname() : "";
for ( int i = 0; i < ARRAYSIZE(mappings); i++ )
{
if ( !mappings[i].pszWeapon || stricmp( mappings[i].pszWeapon, pszWeaponClass ) == 0 )
{
if ( <API key>( mappings[i].translation ) || <API key>( GetOuter()-><API key>( mappings[i].translation ) ) )
{
Assert( m_ActivityMap.Find( MAKE_ACTMAP_KEY( mappings[i].posture, mappings[i].activity ) ) == m_ActivityMap.InvalidIndex() );
m_ActivityMap.Insert( MAKE_ACTMAP_KEY( mappings[i].posture, mappings[i].activity ), mappings[i].translation );
}
}
}
}
void <API key>::<API key>()
{
BaseClass::<API key>();
Activity lowCoverActivity = GetMappedActivity( AIP_CROUCHING, ACT_COVER_LOW );
if ( lowCoverActivity == ACT_INVALID )
lowCoverActivity = ACT_COVER_LOW;
<API key> = ( ( CapabilitiesGet() & bits_CAP_DUCK ) && (GetOuter()->TranslateActivity( lowCoverActivity ) != ACT_INVALID));
CBaseCombatWeapon *pWeapon = GetOuter()->GetActiveWeapon();
if ( pWeapon && (GetOuter()->TranslateActivity( lowCoverActivity ) == ACT_INVALID ))
DevMsg( "Note: NPC class %s lacks ACT_COVER_LOW, therefore cannot participate in standoff\n", GetOuter()->GetClassname() );
}
void <API key>::<API key>( CBaseCombatWeapon *pOldWeapon, CBaseCombatWeapon *pNewWeapon )
{
<API key>();
}
void <API key>::OnRestore()
{
<API key>();
}
<API key>(<API key>)
DECLARE_CONDITION( <API key> )
<API key>()
// CAI_StandoffGoal
// Purpose: A level tool to control the standoff behavior. Use is not required
// in order to use behavior.
AI_StandoffParams_t <API key>[] =
{
// hintChangeReaction, fCoverOnReload, PlayerBtlLn, minTimeShots, maxTimeShots, minShots, maxShots, oddsCover flAbandonTimeLimit
{ AIHCR_MOVE_ON_COVER, true, true, 4.0, 8.0, 2, 4, 50, false, 30 }, // AGGR_VERY_LOW
{ AIHCR_MOVE_ON_COVER, true, true, 2.0, 5.0, 3, 5, 25, false, 20 }, // AGGR_LOW
{ AIHCR_MOVE_ON_COVER, true, true, 0.6, 2.5, 3, 6, 25, false, 10 }, // AGGR_MEDIUM
{ AIHCR_MOVE_ON_COVER, true, true, 0.2, 1.5, 5, 8, 10, false, 10 }, // AGGR_HIGH
{ AIHCR_MOVE_ON_COVER, false, true, 0, 0, 100, 100, 0, false, 5 }, // AGGR_VERY_HIGH
};
class CAI_StandoffGoal : public CAI_GoalEntity
{
DECLARE_CLASS( CAI_StandoffGoal, CAI_GoalEntity );
public:
CAI_StandoffGoal()
{
m_aggressiveness = AGGR_MEDIUM;
<API key> = true;
<API key> = AIHCR_DEFAULT_AI;
m_fStayAtCover = false;
<API key> = false;
m_customParams = <API key>;
}
void EnableGoal( CAI_BaseNPC *pAI )
{
<API key> *pBehavior;
if ( !pAI->GetBehavior( &pBehavior ) )
return;
pBehavior->SetActive( true );
SetBehaviorParams( pBehavior);
}
void DisableGoal( CAI_BaseNPC *pAI )
{
// @TODO (toml 04-07-03): remove the no damage spawn flag once stable. The implementation isn't very good.
<API key> *pBehavior;
if ( !pAI->GetBehavior( &pBehavior ) )
return;
pBehavior->SetActive( false );
SetBehaviorParams( pBehavior);
}
void InputActivate( inputdata_t &inputdata )
{
ValidateAggression();
BaseClass::InputActivate( inputdata );
}
void InputDeactivate( inputdata_t &inputdata )
{
ValidateAggression();
BaseClass::InputDeactivate( inputdata );
}
void <API key>( inputdata_t &inputdata )
{
int newVal = inputdata.value.Int();
m_aggressiveness = (Aggressiveness_t)newVal;
ValidateAggression();
UpdateActors();
const CUtlVector<AIHANDLE> &actors = AccessActors();
for ( int i = 0; i < actors.Count(); i++ )
{
CAI_BaseNPC *pAI = actors[i];
<API key> *pBehavior;
if ( !pAI->GetBehavior( &pBehavior ) )
continue;
SetBehaviorParams( pBehavior);
}
}
void SetBehaviorParams( <API key> *pBehavior )
{
AI_StandoffParams_t params;
if ( m_aggressiveness != AGGR_CUSTOM )
params = <API key>[m_aggressiveness];
else
params = m_customParams;
params.hintChangeReaction = <API key>;
params.fPlayerIsBattleline = <API key>;
params.fStayAtCover = m_fStayAtCover;
if ( !<API key> )
params.flAbandonTimeLimit = 0;
pBehavior->SetParameters( params, this );
pBehavior-><API key>();
if ( pBehavior->IsRunning() )
pBehavior->GetOuter()->ClearSchedule( "Standoff behavior parms changed" );
}
void ValidateAggression()
{
if ( m_aggressiveness < AGGR_VERY_LOW || m_aggressiveness > AGGR_VERY_HIGH )
{
if ( m_aggressiveness != AGGR_CUSTOM )
{
DevMsg( "Invalid aggressiveness value %d\n", m_aggressiveness );
if ( m_aggressiveness < AGGR_VERY_LOW )
m_aggressiveness = AGGR_VERY_LOW;
else if ( m_aggressiveness > AGGR_VERY_HIGH )
m_aggressiveness = AGGR_VERY_HIGH;
}
}
}
private:
DECLARE_DATADESC();
enum Aggressiveness_t
{
AGGR_VERY_LOW,
AGGR_LOW,
AGGR_MEDIUM,
AGGR_HIGH,
AGGR_VERY_HIGH,
AGGR_CUSTOM,
};
Aggressiveness_t m_aggressiveness;
<API key> <API key>;
bool <API key>;
bool m_fStayAtCover;
bool <API key>;
AI_StandoffParams_t m_customParams;
};
<API key>( ai_goal_standoff, CAI_StandoffGoal );
BEGIN_DATADESC( CAI_StandoffGoal )
DEFINE_KEYFIELD( m_aggressiveness, FIELD_INTEGER, "Aggressiveness" ),
// m_customParams (individually)
DEFINE_KEYFIELD( <API key>, FIELD_INTEGER, "<API key>" ),
DEFINE_KEYFIELD( <API key>, FIELD_BOOLEAN, "PlayerBattleline" ),
DEFINE_KEYFIELD( m_fStayAtCover, FIELD_BOOLEAN, "StayAtCover" ),
DEFINE_KEYFIELD( <API key>, FIELD_BOOLEAN, "AbandonIfEnemyHides" ),
DEFINE_KEYFIELD( m_customParams.fCoverOnReload, FIELD_BOOLEAN, "CustomCoverOnReload" ),
DEFINE_KEYFIELD( m_customParams.minTimeShots, FIELD_FLOAT, "CustomMinTimeShots" ),
DEFINE_KEYFIELD( m_customParams.maxTimeShots, FIELD_FLOAT, "CustomMaxTimeShots" ),
DEFINE_KEYFIELD( m_customParams.minShots, FIELD_INTEGER, "CustomMinShots" ),
DEFINE_KEYFIELD( m_customParams.maxShots, FIELD_INTEGER, "CustomMaxShots" ),
DEFINE_KEYFIELD( m_customParams.oddsCover, FIELD_INTEGER, "CustomOddsCover" ),
// Inputs
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetAggressiveness", <API key> ),
END_DATADESC() |
// This source file is part of the Swift.org open source project
// This file defines the Stmt class and subclasses.
#ifndef SWIFT_AST_STMT_H
#define SWIFT_AST_STMT_H
#include "swift/AST/Availability.h"
#include "swift/AST/AvailabilitySpec.h"
#include "swift/AST/ASTNode.h"
#include "swift/Basic/NullablePtr.h"
namespace swift {
class ASTContext;
class ASTWalker;
class Decl;
class Expr;
class FuncDecl;
class Pattern;
class PatternBindingDecl;
class VarDecl;
enum class StmtKind {
#define STMT(ID, PARENT) ID,
#define STMT_RANGE(Id, FirstId, LastId) \
First_##Id##Stmt = FirstId, Last_##Id##Stmt = LastId,
#include "swift/AST/StmtNodes.def"
};
Stmt - Base class for all statements in swift.
class alignas(8) Stmt {
Stmt(const Stmt&) = delete;
void operator=(const Stmt&) = delete;
Kind - The subclass of Stmt that this is.
unsigned Kind : 31;
Implicit - Whether this statement is implicit.
unsigned Implicit : 1;
protected:
Return the given value for the 'implicit' flag if present, or if None,
return true if the location is invalid.
static bool <API key>(Optional<bool> implicit, SourceLoc keyLoc){
return implicit.hasValue() ? *implicit : keyLoc.isInvalid();
}
public:
Stmt(StmtKind kind, bool implicit)
: Kind(unsigned(kind)), Implicit(unsigned(implicit)) {}
StmtKind getKind() const { return StmtKind(Kind); }
\brief Retrieve the name of the given statement kind.
This name should only be used for debugging dumps and other
developer aids, and should never be part of a diagnostic or exposed
to the user of the compiler in any way.
static StringRef getKindName(StmtKind kind);
\brief Return the location of the start of the statement.
SourceLoc getStartLoc() const;
\brief Return the location of the end of the statement.
SourceLoc getEndLoc() const;
SourceRange getSourceRange() const;
SourceLoc TrailingSemiLoc;
isImplicit - Determines whether this statement was <API key>,
rather than explicitly written in the AST.
bool isImplicit() const { return bool(Implicit); }
walk - This recursively walks the AST rooted at this statement.
Stmt *walk(ASTWalker &walker);
Stmt *walk(ASTWalker &&walker) { return walk(walker); }
<API key>(
void dump() const LLVM_ATTRIBUTE_USED,
"only for use within the debugger");
void print(raw_ostream &OS, unsigned Indent = 0) const;
// Only allow allocation of Exprs using the allocator in ASTContext
// or by doing a placement new.
void *operator new(size_t Bytes, ASTContext &C,
unsigned Alignment = alignof(Stmt));
void *operator new(size_t Bytes) throw() = delete;
void operator delete(void *Data) throw() = delete;
void *operator new(size_t Bytes, void *Mem) throw() = delete;
};
BraceStmt - A brace enclosed sequence of expressions, stmts, or decls, like
{ var x = 10; print(10) }.
class BraceStmt : public Stmt {
private:
unsigned NumElements;
SourceLoc LBLoc;
SourceLoc RBLoc;
BraceStmt(SourceLoc lbloc, ArrayRef<ASTNode> elements,SourceLoc rbloc,
Optional<bool> implicit);
ASTNode *getElementsStorage() {
return reinterpret_cast<ASTNode*>(this + 1);
}
public:
static BraceStmt *create(ASTContext &ctx, SourceLoc lbloc,
ArrayRef<ASTNode> elements,
SourceLoc rbloc,
Optional<bool> implicit = None);
SourceLoc getLBraceLoc() const { return LBLoc; }
SourceLoc getRBraceLoc() const { return RBLoc; }
SourceRange getSourceRange() const { return SourceRange(LBLoc, RBLoc); }
unsigned getNumElements() const { return NumElements; }
ASTNode getElement(unsigned i) const { return getElements()[i]; }
void setElement(unsigned i, ASTNode node) { getElements()[i] = node; }
The elements contained within the BraceStmt.
MutableArrayRef<ASTNode> getElements() {
return MutableArrayRef<ASTNode>(getElementsStorage(), NumElements);
}
The elements contained within the BraceStmt (const version).
ArrayRef<ASTNode> getElements() const {
return const_cast<BraceStmt*>(this)->getElements();
}
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Brace; }
};
ReturnStmt - A return statement. The result is optional; "return" without
an expression is semantically equivalent to "return ()".
return 42
class ReturnStmt : public Stmt {
SourceLoc ReturnLoc;
Expr *Result;
public:
ReturnStmt(SourceLoc ReturnLoc, Expr *Result,
Optional<bool> implicit = None)
: Stmt(StmtKind::Return, <API key>(implicit, ReturnLoc)),
ReturnLoc(ReturnLoc), Result(Result) {}
SourceLoc getReturnLoc() const { return ReturnLoc; }
SourceLoc getStartLoc() const;
SourceLoc getEndLoc() const;
bool hasResult() const { return Result != 0; }
Expr *getResult() const {
assert(Result && "ReturnStmt doesn't have a result");
return Result;
}
void setResult(Expr *e) { Result = e; }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Return;}
};
DeferStmt - A 'defer' statement. This runs the substatement it contains
when the enclosing scope is exited.
defer { cleanUp() }
The AST representation for a defer statement is a bit weird. We model this
as if they wrote:
func tmpClosure() { body }
tmpClosure() // This is emitted on each path that needs to run this.
As such, the body of the 'defer' is actually type checked within the
closure's DeclContext. We do this because of unfortunateness in SILGen,
some expressions (e.g. OpenExistentialExpr) cannot be multiply emitted in a
composable way. When this gets fixed, patches r27767 and r27768 can be
reverted to go back to the simpler and more obvious representation.
class DeferStmt : public Stmt {
SourceLoc DeferLoc;
This is the bound temp function.
FuncDecl *tempDecl;
This is the invocation of the closure, which is to be emitted on any error
paths.
Expr *callExpr;
public:
DeferStmt(SourceLoc DeferLoc,
FuncDecl *tempDecl, Expr *callExpr)
: Stmt(StmtKind::Defer, /*implicit*/false),
DeferLoc(DeferLoc), tempDecl(tempDecl),
callExpr(callExpr) {}
SourceLoc getDeferLoc() const { return DeferLoc; }
SourceLoc getStartLoc() const { return DeferLoc; }
SourceLoc getEndLoc() const;
FuncDecl *getTempDecl() const { return tempDecl; }
Expr *getCallExpr() const { return callExpr; }
void setCallExpr(Expr *E) { callExpr = E; }
Dig the original users's body of the defer out for AST fidelity.
BraceStmt *getBodyAsWritten() const;
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Defer; }
};
\brief An expression that guards execution based on whether the run-time
configuration supports a given API, e.g.,
#available(OSX >= 10.9, iOS >= 7.0).
class alignas(8) PoundAvailableInfo {
SourceLoc PoundLoc;
SourceLoc RParenLoc;
// The number of queries tail allocated after this object.
unsigned NumQueries;
The version range when this query will return true. This value is
filled in by Sema.
VersionRange AvailableRange;
PoundAvailableInfo(SourceLoc PoundLoc, ArrayRef<AvailabilitySpec *> queries,
SourceLoc RParenLoc)
: PoundLoc(PoundLoc), RParenLoc(RParenLoc), NumQueries(queries.size()),
AvailableRange(VersionRange::empty()) {
memcpy((void*)getQueries().data(), queries.data(),
queries.size() * sizeof(AvailabilitySpec *));
}
public:
static PoundAvailableInfo *create(ASTContext &ctx, SourceLoc PoundLoc,
ArrayRef<AvailabilitySpec *> queries,
SourceLoc RParenLoc);
ArrayRef<AvailabilitySpec *> getQueries() const {
auto buf = reinterpret_cast<AvailabilitySpec *const*>(this + 1);
return ArrayRef<AvailabilitySpec *>(buf, NumQueries);
}
SourceLoc getStartLoc() const { return PoundLoc; }
SourceLoc getEndLoc() const;
SourceLoc getLoc() const { return PoundLoc; }
SourceRange getSourceRange() const { return SourceRange(getStartLoc(),
getEndLoc()); }
const VersionRange &getAvailableRange() const { return AvailableRange; }
void setAvailableRange(const VersionRange &Range) { AvailableRange = Range; }
void <API key>(SmallVectorImpl<CharSourceRange>
&PlatformRanges);
};
This represents an entry in an "if" or "while" condition. Pattern bindings
can bind any number of names in the pattern binding decl, and may have an
associated where clause. When "if let" is involved, an arbitrary number of
pattern bindings and conditional expressions are permitted, e.g.:
if let x = ..., y = ... where x > y,
let z = ...
which would be represented as four <API key> entries, one for
the "x" binding, one for the "y" binding, one for the where clause, one for
"z"'s binding. A simple "if" statement is represented as a single binding.
class <API key> {
If this is a pattern binding, it may be the first one in a declaration, in
which case this is the location of the var/let/case keyword. If this is
the second pattern (e.g. for 'y' in "var x = ..., y = ...") then this
location is invalid.
SourceLoc IntroducerLoc;
In a pattern binding, this is pattern being matched. In the case of an
"implicit optional" pattern, the OptionalSome pattern is explicitly added
to this as an 'implicit' pattern.
Pattern *ThePattern = nullptr;
This is either the boolean condition, the initializer for a pattern
binding, or the #available information.
llvm::PointerUnion<PoundAvailableInfo*, Expr *> CondInitOrAvailable;
public:
<API key>() {}
<API key>(SourceLoc IntroducerLoc, Pattern *ThePattern,
Expr *Init)
: IntroducerLoc(IntroducerLoc), ThePattern(ThePattern),
CondInitOrAvailable(Init) {}
<API key>(Expr *cond) : CondInitOrAvailable(cond) {}
<API key>(PoundAvailableInfo *Info) : CondInitOrAvailable(Info) {}
SourceLoc getIntroducerLoc() const { return IntroducerLoc; }
void setIntroducerLoc(SourceLoc loc) { IntroducerLoc = loc; }
ConditionKind - This indicates the sort of condition this is.
enum ConditionKind {
CK_Boolean,
CK_PatternBinding,
CK_Availability
};
ConditionKind getKind() const {
if (ThePattern) return CK_PatternBinding;
return CondInitOrAvailable.is<Expr*>() ? CK_Boolean : CK_Availability;
}
Boolean Condition Accessors.
Expr *getBooleanOrNull() const {
return getKind() == CK_Boolean ? CondInitOrAvailable.get<Expr*>() : nullptr;
}
Expr *getBoolean() const {
assert(getKind() == CK_Boolean && "Not a condition");
return CondInitOrAvailable.get<Expr*>();
}
void setBoolean(Expr *E) {
assert(getKind() == CK_Boolean && "Not a condition");
CondInitOrAvailable = E;
}
Pattern Binding Accessors.
Pattern *getPatternOrNull() const {
return ThePattern;
}
Pattern *getPattern() const {
assert(getKind() == CK_PatternBinding && "Not a pattern binding condition");
return ThePattern;
}
void setPattern(Pattern *P) {
assert(getKind() == CK_PatternBinding && "Not a pattern binding condition");
ThePattern = P;
}
Expr *getInitializer() const {
assert(getKind() == CK_PatternBinding && "Not a pattern binding condition");
return CondInitOrAvailable.get<Expr*>();
}
void setInitializer(Expr *E) {
assert(getKind() == CK_PatternBinding && "Not a pattern binding condition");
CondInitOrAvailable = E;
}
// Availability Accessors
PoundAvailableInfo *getAvailability() const {
assert(getKind() == CK_Availability && "Not an #available condition");
return CondInitOrAvailable.get<PoundAvailableInfo*>();
}
void setAvailability(PoundAvailableInfo *Info) {
assert(getKind() == CK_Availability && "Not an #available condition");
CondInitOrAvailable = Info;
}
SourceLoc getStartLoc() const;
SourceLoc getEndLoc() const;
SourceRange getSourceRange() const;
Recursively walks the AST rooted at this statement condition element
<API key> *walk(ASTWalker &walker);
<API key> *walk(ASTWalker &&walker) { return walk(walker); }
};
struct LabeledStmtInfo {
Identifier Name;
SourceLoc Loc;
// Evaluates to true if set.
operator bool() const { return !Name.empty(); }
};
LabeledStmt - Common base class between the labeled statements (loops and
switch).
class LabeledStmt : public Stmt {
LabeledStmtInfo LabelInfo;
protected:
SourceLoc <API key>(SourceLoc L) const {
return LabelInfo ? LabelInfo.Loc : L;
}
public:
LabeledStmt(StmtKind Kind, bool Implicit, LabeledStmtInfo LabelInfo)
: Stmt(Kind, Implicit), LabelInfo(LabelInfo) {}
LabeledStmtInfo getLabelInfo() const { return LabelInfo; }
void setLabelInfo(LabeledStmtInfo L) { LabelInfo = L; }
Is this statement a valid target of "continue" if labeled?
For the most part, non-looping constructs shouldn't be
continue-able, but we threw in "do" as a sop.
bool <API key>() const;
Is this statement a valid target of an unlabeled "break" or
"continue"?
The nice, consistent language rule is that unlabeled "break" and
"continue" leave the innermost loop. We have to include
"switch" (for "break") for consistency with C: Swift doesn't
require "break" to leave a switch case, but it's still way too
similar to C's switch to allow different behavior for "break".
bool requiresLabelOnJump() const;
static bool classof(const Stmt *S) {
return S->getKind() >= StmtKind::First_LabeledStmt &&
S->getKind() <= StmtKind::Last_LabeledStmt;
}
};
DoStmt - do statement, without any trailing clauses.
class DoStmt : public LabeledStmt {
SourceLoc DoLoc;
Stmt *Body;
public:
DoStmt(LabeledStmtInfo labelInfo, SourceLoc doLoc,
Stmt *body, Optional<bool> implicit = None)
: LabeledStmt(StmtKind::Do, <API key>(implicit, doLoc),
labelInfo),
DoLoc(doLoc), Body(body) {}
SourceLoc getDoLoc() const { return DoLoc; }
SourceLoc getStartLoc() const { return <API key>(DoLoc); }
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Do; }
};
An individual 'catch' clause.
This isn't really an independent statement any more than CaseStmt
is; it's just a structural part of a DoCatchStmt.
class CatchStmt : public Stmt {
SourceLoc CatchLoc;
SourceLoc WhereLoc;
Pattern *ErrorPattern;
Expr *GuardExpr;
Stmt *CatchBody;
public:
CatchStmt(SourceLoc catchLoc, Pattern *errorPattern,
SourceLoc whereLoc, Expr *guardExpr, Stmt *body,
Optional<bool> implicit = None)
: Stmt(StmtKind::Catch, <API key>(implicit, catchLoc)),
CatchLoc(catchLoc), WhereLoc(whereLoc),
ErrorPattern(nullptr), GuardExpr(guardExpr), CatchBody(body) {
setErrorPattern(errorPattern);
}
SourceLoc getCatchLoc() const { return CatchLoc; }
The location of the 'where' keyword if there's a guard expression.
SourceLoc getWhereLoc() const { return WhereLoc; }
SourceLoc getStartLoc() const { return CatchLoc; }
SourceLoc getEndLoc() const { return CatchBody->getEndLoc(); }
Stmt *getBody() const { return CatchBody; }
void setBody(Stmt *body) { CatchBody = body; }
Pattern *getErrorPattern() { return ErrorPattern; }
const Pattern *getErrorPattern() const { return ErrorPattern; }
void setErrorPattern(Pattern *pattern);
Is this catch clause "syntactically exhaustive"?
bool <API key>() const;
Return the guard expression if present, or null if the catch has
no guard.
Expr *getGuardExpr() const { return GuardExpr; }
void setGuardExpr(Expr *guard) { GuardExpr = guard; }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Catch; }
};
DoCatchStmt - do statement with trailing 'catch' clauses.
class DoCatchStmt : public LabeledStmt {
SourceLoc DoLoc;
Stmt *Body;
unsigned NumCatches;
CatchStmt **getCatchesBuffer() {
return reinterpret_cast<CatchStmt **>(this+1);
}
CatchStmt * const *getCatchesBuffer() const {
return reinterpret_cast<CatchStmt * const *>(this+1);
}
DoCatchStmt(LabeledStmtInfo labelInfo, SourceLoc doLoc,
Stmt *body, ArrayRef<CatchStmt*> catches,
Optional<bool> implicit)
: LabeledStmt(StmtKind::DoCatch, <API key>(implicit, doLoc),
labelInfo),
DoLoc(doLoc), Body(body), NumCatches(catches.size()) {
memcpy(getCatchesBuffer(), catches.data(),
catches.size() * sizeof(catches[0]));
}
public:
static DoCatchStmt *create(ASTContext &ctx, LabeledStmtInfo labelInfo,
SourceLoc doLoc, Stmt *body,
ArrayRef<CatchStmt*> catches,
Optional<bool> implicit = None);
SourceLoc getDoLoc() const { return DoLoc; }
SourceLoc getStartLoc() const { return <API key>(DoLoc); }
SourceLoc getEndLoc() const { return getCatches().back()->getEndLoc(); }
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
ArrayRef<CatchStmt*> getCatches() const {
return ArrayRef<CatchStmt*>(getCatchesBuffer(), NumCatches);
}
MutableArrayRef<CatchStmt*> getMutableCatches() {
return MutableArrayRef<CatchStmt*>(getCatchesBuffer(), NumCatches);
}
Does this statement contain a syntactically exhaustive catch
clause?
Note that an exhaustive do/catch statement can still throw
errors out of its catch block(s).
bool <API key>() const;
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::DoCatch;
}
};
Either an "if let" case or a simple boolean expression can appear as the
condition of an 'if' or 'while' statement.
using StmtCondition = MutableArrayRef<<API key>>;
This is the common base class between statements that can have labels, and
also have complex "if let" style conditions: 'if' and 'while'.
class <API key> : public LabeledStmt {
StmtCondition Cond;
public:
<API key>(StmtKind Kind, bool Implicit,
LabeledStmtInfo LabelInfo, StmtCondition Cond)
: LabeledStmt(Kind, Implicit, LabelInfo) {
setCond(Cond);
}
StmtCondition getCond() const { return Cond; }
void setCond(StmtCondition e);
static bool classof(const Stmt *S) {
return S->getKind() >= StmtKind::<API key> &&
S->getKind() <= StmtKind::<API key>;
}
};
IfStmt - if/then/else statement. If no 'else' is specified, then the
ElseLoc location is not specified and the Else statement is null. After
type-checking, the condition is of type Builtin.Int1.
class IfStmt : public <API key> {
SourceLoc IfLoc;
SourceLoc ElseLoc;
Stmt *Then;
Stmt *Else;
public:
IfStmt(LabeledStmtInfo LabelInfo, SourceLoc IfLoc, StmtCondition Cond,
Stmt *Then, SourceLoc ElseLoc, Stmt *Else,
Optional<bool> implicit = None)
: <API key>(StmtKind::If,
<API key>(implicit, IfLoc),
LabelInfo, Cond),
IfLoc(IfLoc), ElseLoc(ElseLoc), Then(Then), Else(Else) {}
IfStmt(SourceLoc IfLoc, Expr *Cond, Stmt *Then, SourceLoc ElseLoc,
Stmt *Else, Optional<bool> implicit, ASTContext &Ctx);
SourceLoc getIfLoc() const { return IfLoc; }
SourceLoc getElseLoc() const { return ElseLoc; }
SourceLoc getStartLoc() const {
return <API key>(IfLoc);
}
SourceLoc getEndLoc() const {
return (Else ? Else->getEndLoc() : Then->getEndLoc());
}
Stmt *getThenStmt() const { return Then; }
void setThenStmt(Stmt *s) { Then = s; }
Stmt *getElseStmt() const { return Else; }
void setElseStmt(Stmt *s) { Else = s; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::If; }
};
GuardStmt - 'guard' statement. Evaluate a condition and if it fails, run
its body. The body is always guaranteed to exit the current scope (or
abort), it never falls through.
class GuardStmt : public <API key> {
SourceLoc GuardLoc;
Stmt *Body;
public:
GuardStmt(SourceLoc GuardLoc, StmtCondition Cond,
Stmt *Body, Optional<bool> implicit = None)
: <API key>(StmtKind::Guard,
<API key>(implicit, GuardLoc),
LabeledStmtInfo(), Cond),
GuardLoc(GuardLoc), Body(Body) {}
GuardStmt(SourceLoc GuardLoc, Expr *Cond, Stmt *Body,
Optional<bool> implicit, ASTContext &Ctx);
SourceLoc getGuardLoc() const { return GuardLoc; }
SourceLoc getStartLoc() const {
return <API key>(GuardLoc);
}
SourceLoc getEndLoc() const {
return Body->getEndLoc();
}
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Guard; }
};
This represents one part of a #if block. If the condition field is
non-null, then this represents a #if or a #elseif, otherwise it represents
an #else block.
struct IfConfigStmtClause {
The location of the #if, #elseif, or #else keyword.
SourceLoc Loc;
The condition guarding this #if or #elseif block. If this is null, this
is a #else clause.
Expr *Cond;
Elements inside the clause
ArrayRef<ASTNode> Elements;
True if this is the active clause of the #if block. Since this is
evaluated at parse time, this is always known.
bool isActive;
IfConfigStmtClause(SourceLoc Loc, Expr *Cond,
ArrayRef<ASTNode> Elements, bool isActive)
: Loc(Loc), Cond(Cond), Elements(Elements), isActive(isActive) {
}
};
IfConfigStmt - This class models the statement-side representation of
#if/#else/#endif blocks.
class IfConfigStmt : public Stmt {
An array of clauses controlling each of the #if/#elseif/#else conditions.
The array is ASTContext allocated.
ArrayRef<IfConfigStmtClause> Clauses;
SourceLoc EndLoc;
bool HadMissingEnd;
public:
IfConfigStmt(ArrayRef<IfConfigStmtClause> Clauses, SourceLoc EndLoc,
bool HadMissingEnd)
: Stmt(StmtKind::IfConfig, /*implicit=*/false),
Clauses(Clauses), EndLoc(EndLoc), HadMissingEnd(HadMissingEnd) {}
SourceLoc getIfLoc() const { return Clauses[0].Loc; }
SourceLoc getStartLoc() const { return getIfLoc(); }
SourceLoc getEndLoc() const { return EndLoc; }
bool hadMissingEnd() const { return HadMissingEnd; }
const ArrayRef<IfConfigStmtClause> &getClauses() const { return Clauses; }
ArrayRef<ASTNode> <API key>() const {
for (auto &Clause : Clauses)
if (Clause.isActive)
return Clause.Elements;
return ArrayRef<ASTNode>();
}
// Implement isa/cast/dyncast/etc.
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::IfConfig;
}
};
WhileStmt - while statement. After type-checking, the condition is of
type Builtin.Int1.
class WhileStmt : public <API key> {
SourceLoc WhileLoc;
StmtCondition Cond;
Stmt *Body;
public:
WhileStmt(LabeledStmtInfo LabelInfo, SourceLoc WhileLoc, StmtCondition Cond,
Stmt *Body, Optional<bool> implicit = None)
: <API key>(StmtKind::While,
<API key>(implicit, WhileLoc),
LabelInfo, Cond),
WhileLoc(WhileLoc), Body(Body) {}
SourceLoc getStartLoc() const { return <API key>(WhileLoc); }
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::While; }
};
RepeatWhileStmt - repeat/while statement. After type-checking, the
condition is of type Builtin.Int1.
class RepeatWhileStmt : public LabeledStmt {
SourceLoc RepeatLoc, WhileLoc;
Stmt *Body;
Expr *Cond;
public:
RepeatWhileStmt(LabeledStmtInfo LabelInfo, SourceLoc RepeatLoc, Expr *Cond,
SourceLoc WhileLoc, Stmt *Body, Optional<bool> implicit = None)
: LabeledStmt(StmtKind::RepeatWhile,
<API key>(implicit, RepeatLoc),
LabelInfo),
RepeatLoc(RepeatLoc), WhileLoc(WhileLoc), Body(Body), Cond(Cond) {}
SourceLoc getStartLoc() const { return <API key>(RepeatLoc); }
SourceLoc getEndLoc() const;
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
Expr *getCond() const { return Cond; }
void setCond(Expr *e) { Cond = e; }
static bool classof(const Stmt *S) {return S->getKind() == StmtKind::RepeatWhile;}
};
ForStmt - for statement. After type-checking, the condition is of
type Builtin.Int1. Note that the condition is optional. If not present,
it always evaluates to true. The Initializer and Increment are also
optional.
class ForStmt : public LabeledStmt {
SourceLoc ForLoc, Semi1Loc, Semi2Loc;
NullablePtr<Expr> Initializer;
ArrayRef<Decl*> InitializerVarDecls;
NullablePtr<Expr> Cond;
NullablePtr<Expr> Increment;
Stmt *Body;
public:
ForStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc,
NullablePtr<Expr> Initializer,
ArrayRef<Decl*> InitializerVarDecls,
SourceLoc Semi1Loc, NullablePtr<Expr> Cond, SourceLoc Semi2Loc,
NullablePtr<Expr> Increment,
Stmt *Body,
Optional<bool> implicit = None)
: LabeledStmt(StmtKind::For, <API key>(implicit, ForLoc),
LabelInfo),
ForLoc(ForLoc), Semi1Loc(Semi1Loc),
Semi2Loc(Semi2Loc), Initializer(Initializer),
InitializerVarDecls(InitializerVarDecls),
Cond(Cond), Increment(Increment), Body(Body) {
}
SourceLoc getStartLoc() const { return <API key>(ForLoc); }
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
NullablePtr<Expr> getInitializer() const { return Initializer; }
void setInitializer(Expr *V) { Initializer = V; }
ArrayRef<Decl*> <API key>() const { return InitializerVarDecls; }
void <API key>(ArrayRef<Decl*> D) { InitializerVarDecls = D; }
NullablePtr<Expr> getCond() const { return Cond; }
void setCond(NullablePtr<Expr> C) { Cond = C; }
NullablePtr<Expr> getIncrement() const { return Increment; }
void setIncrement(Expr *V) { Increment = V; }
Stmt *getBody() const { return Body; }
void setBody(Stmt *s) { Body = s; }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::For; }
};
ForEachStmt - foreach statement that iterates over the elements in a
container.
Example:
\code
for i in 0...10 {
print(String(i))
}
\endcode
class ForEachStmt : public LabeledStmt {
SourceLoc ForLoc;
Pattern *Pat;
SourceLoc InLoc;
Expr *Sequence;
Expr *WhereExpr = nullptr;
BraceStmt *Body;
The generator variable along with its initializer.
PatternBindingDecl *Generator = nullptr;
The expression that advances the generator and returns an Optional with
the next value or None to signal end-of-stream.
Expr *GeneratorNext = nullptr;
public:
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, Pattern *Pat,
SourceLoc InLoc, Expr *Sequence, Expr *WhereExpr, BraceStmt *Body,
Optional<bool> implicit = None)
: LabeledStmt(StmtKind::ForEach, <API key>(implicit, ForLoc),
LabelInfo),
ForLoc(ForLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
WhereExpr(WhereExpr), Body(Body) {
setPattern(Pat);
}
getForLoc - Retrieve the location of the 'for' keyword.
SourceLoc getForLoc() const { return ForLoc; }
getInLoc - Retrieve the location of the 'in' keyword.
SourceLoc getInLoc() const { return InLoc; }
getPattern - Retrieve the pattern describing the iteration variables.
These variables will only be visible within the body of the loop.
Pattern *getPattern() const { return Pat; }
void setPattern(Pattern *p);
Expr *getWhere() const { return WhereExpr; }
void setWhere(Expr *W) { WhereExpr = W; }
getSequence - Retrieve the Sequence whose elements will be visited
by this foreach loop, as it was written in the source code and
subsequently type-checked. To determine the semantic behavior of this
expression to extract a range, use \c getRangeInit().
Expr *getSequence() const { return Sequence; }
void setSequence(Expr *S) { Sequence = S; }
Retrieve the pattern binding that contains the (implicit) generator
variable and its initialization from the container.
PatternBindingDecl *getGenerator() const { return Generator; }
void setGenerator(PatternBindingDecl *G) { Generator = G; }
Retrieve the expression that advances the generator.
Expr *getGeneratorNext() const { return GeneratorNext; }
void setGeneratorNext(Expr *E) { GeneratorNext = E; }
getBody - Retrieve the body of the loop.
BraceStmt *getBody() const { return Body; }
void setBody(BraceStmt *B) { Body = B; }
SourceLoc getStartLoc() const { return <API key>(ForLoc); }
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::ForEach;
}
};
A pattern and an optional guard expression used in a 'case' statement.
class CaseLabelItem {
Pattern *CasePattern;
SourceLoc WhereLoc;
llvm::PointerIntPair<Expr *, 1, bool> <API key>;
public:
CaseLabelItem(const CaseLabelItem &) = default;
CaseLabelItem(bool IsDefault, Pattern *CasePattern, SourceLoc WhereLoc,
Expr *GuardExpr)
: CasePattern(CasePattern), WhereLoc(WhereLoc),
<API key>(GuardExpr, IsDefault) {}
SourceLoc getWhereLoc() const { return WhereLoc; }
SourceLoc getStartLoc() const;
SourceLoc getEndLoc() const;
SourceRange getSourceRange() const;
Pattern *getPattern() { return CasePattern; }
const Pattern *getPattern() const { return CasePattern; }
void setPattern(Pattern *CasePattern) { this->CasePattern = CasePattern; }
Return the guard expression if present, or null if the case label has
no guard.
Expr *getGuardExpr() { return <API key>.getPointer(); }
const Expr *getGuardExpr() const {
return <API key>.getPointer();
}
void setGuardExpr(Expr *e) { <API key>.setPointer(e); }
Returns true if this is syntactically a 'default' label.
bool isDefault() const { return <API key>.getInt(); }
};
A 'case' or 'default' block of a switch statement. Only valid as the
substatement of a SwitchStmt. A case block begins either with one or more
CaseLabelItems or a single 'default' label.
Some examples:
\code
case 1:
case 2, 3:
case Foo(var x, var y) where x < y:
case 2 where foo(), 3 where bar():
default:
\endcode
class CaseStmt : public Stmt {
SourceLoc CaseLoc;
SourceLoc ColonLoc;
llvm::PointerIntPair<Stmt *, 1, bool> <API key>;
unsigned NumPatterns;
const CaseLabelItem *<API key>() const {
return reinterpret_cast<const CaseLabelItem *>(this + 1);
}
CaseLabelItem *<API key>() {
return reinterpret_cast<CaseLabelItem *>(this + 1);
}
CaseStmt(SourceLoc CaseLoc, ArrayRef<CaseLabelItem> CaseLabelItems,
bool HasBoundDecls, SourceLoc ColonLoc, Stmt *Body,
Optional<bool> Implicit);
public:
static CaseStmt *create(ASTContext &C, SourceLoc CaseLoc,
ArrayRef<CaseLabelItem> CaseLabelItems,
bool HasBoundDecls, SourceLoc ColonLoc, Stmt *Body,
Optional<bool> Implicit = None);
ArrayRef<CaseLabelItem> getCaseLabelItems() const {
return { <API key>(), NumPatterns };
}
MutableArrayRef<CaseLabelItem> <API key>() {
return { <API key>(), NumPatterns };
}
Stmt *getBody() const { return <API key>.getPointer(); }
void setBody(Stmt *body) { <API key>.setPointer(body); }
True if the case block declares any patterns with local variable bindings.
bool hasBoundDecls() const { return <API key>.getInt(); }
Get the source location of the 'case' or 'default' of the first label.
SourceLoc getLoc() const { return CaseLoc; }
SourceLoc getStartLoc() const { return getLoc(); }
SourceLoc getEndLoc() const { return getBody()->getEndLoc(); }
bool isDefault() { return getCaseLabelItems()[0].isDefault(); }
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Case; }
};
Switch statement.
class SwitchStmt : public LabeledStmt {
SourceLoc SwitchLoc, LBraceLoc, RBraceLoc;
Expr *SubjectExpr;
unsigned CaseCount;
CaseStmt * const *getCaseBuffer() const {
return reinterpret_cast<CaseStmt * const *>(this + 1);
}
CaseStmt **getCaseBuffer() {
return reinterpret_cast<CaseStmt **>(this + 1);
}
SwitchStmt(LabeledStmtInfo LabelInfo, SourceLoc SwitchLoc, Expr *SubjectExpr,
SourceLoc LBraceLoc, unsigned CaseCount, SourceLoc RBraceLoc,
Optional<bool> implicit = None)
: LabeledStmt(StmtKind::Switch, <API key>(implicit, SwitchLoc),
LabelInfo),
SwitchLoc(SwitchLoc), LBraceLoc(LBraceLoc), RBraceLoc(RBraceLoc),
SubjectExpr(SubjectExpr), CaseCount(CaseCount)
{}
public:
Allocate a new SwitchStmt in the given ASTContext.
static SwitchStmt *create(LabeledStmtInfo LabelInfo, SourceLoc SwitchLoc,
Expr *SubjectExpr,
SourceLoc LBraceLoc,
ArrayRef<CaseStmt*> Cases,
SourceLoc RBraceLoc,
ASTContext &C);
Get the source location of the 'switch' keyword.
SourceLoc getSwitchLoc() const { return SwitchLoc; }
Get the source location of the opening brace.
SourceLoc getLBraceLoc() const { return LBraceLoc; }
Get the source location of the closing brace.
SourceLoc getRBraceLoc() const { return RBraceLoc; }
SourceLoc getLoc() const { return SwitchLoc; }
SourceLoc getStartLoc() const { return <API key>(SwitchLoc); }
SourceLoc getEndLoc() const { return RBraceLoc; }
Get the subject expression of the switch.
Expr *getSubjectExpr() const { return SubjectExpr; }
void setSubjectExpr(Expr *e) { SubjectExpr = e; }
Get the list of case clauses.
ArrayRef<CaseStmt*> getCases() const {
return {getCaseBuffer(), CaseCount};
}
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Switch;
}
};
BreakStmt - The "break" and "break label" statement.
class BreakStmt : public Stmt {
SourceLoc Loc;
Identifier TargetName; // Named target statement, if specified in the source.
SourceLoc TargetLoc;
LabeledStmt *Target; // Target stmt, wired up by Sema.
public:
BreakStmt(SourceLoc Loc, Identifier TargetName, SourceLoc TargetLoc,
Optional<bool> implicit = None)
: Stmt(StmtKind::Break, <API key>(implicit, Loc)), Loc(Loc),
TargetName(TargetName), TargetLoc(TargetLoc) {
}
SourceLoc getLoc() const { return Loc; }
Identifier getTargetName() const { return TargetName; }
void setTargetName(Identifier N) { TargetName = N; }
SourceLoc getTargetLoc() const { return TargetLoc; }
void setTargetLoc(SourceLoc L) { TargetLoc = L; }
// Manipulate the target loop/switch that is bring broken out of. This is set
// by sema during type checking.
void setTarget(LabeledStmt *LS) { Target = LS; }
LabeledStmt *getTarget() const { return Target; }
SourceLoc getStartLoc() const { return Loc; }
SourceLoc getEndLoc() const {
return (TargetLoc.isValid() ? TargetLoc : Loc);
}
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Break;
}
};
ContinueStmt - The "continue" and "continue label" statement.
class ContinueStmt : public Stmt {
SourceLoc Loc;
Identifier TargetName; // Named target statement, if specified in the source.
SourceLoc TargetLoc;
LabeledStmt *Target;
public:
ContinueStmt(SourceLoc Loc, Identifier TargetName, SourceLoc TargetLoc,
Optional<bool> implicit = None)
: Stmt(StmtKind::Continue, <API key>(implicit, Loc)), Loc(Loc),
TargetName(TargetName), TargetLoc(TargetLoc) {
}
Identifier getTargetName() const { return TargetName; }
void setTargetName(Identifier N) { TargetName = N; }
SourceLoc getTargetLoc() const { return TargetLoc; }
void setTargetLoc(SourceLoc L) { TargetLoc = L; }
// Manipulate the target loop that is bring continued. This is set by sema
// during type checking.
void setTarget(LabeledStmt *LS) { Target = LS; }
LabeledStmt *getTarget() const { return Target; }
SourceLoc getLoc() const { return Loc; }
SourceLoc getStartLoc() const { return Loc; }
SourceLoc getEndLoc() const {
return (TargetLoc.isValid() ? TargetLoc : Loc);
}
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Continue;
}
};
FallthroughStmt - The keyword "fallthrough".
class FallthroughStmt : public Stmt {
SourceLoc Loc;
CaseStmt *FallthroughDest;
public:
FallthroughStmt(SourceLoc Loc, Optional<bool> implicit = None)
: Stmt(StmtKind::Fallthrough, <API key>(implicit, Loc)),
Loc(Loc), FallthroughDest(nullptr)
{}
SourceLoc getLoc() const { return Loc; }
SourceRange getSourceRange() const { return Loc; }
Get the CaseStmt block to which the fallthrough transfers control.
Set during Sema.
CaseStmt *getFallthroughDest() const {
assert(FallthroughDest && "fallthrough dest is not set until Sema");
return FallthroughDest;
}
void setFallthroughDest(CaseStmt *C) {
assert(!FallthroughDest && "fallthrough dest already set?!");
FallthroughDest = C;
}
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Fallthrough;
}
};
FailStmt - A statement that indicates a failable, which is currently
spelled as "return nil" and can only be used within failable initializers.
class FailStmt : public Stmt {
SourceLoc ReturnLoc;
SourceLoc NilLoc;
public:
FailStmt(SourceLoc returnLoc, SourceLoc nilLoc,
Optional<bool> implicit = None)
: Stmt(StmtKind::Fail, <API key>(implicit, returnLoc)),
ReturnLoc(returnLoc), NilLoc(nilLoc)
{}
SourceLoc getLoc() const { return ReturnLoc; }
SourceRange getSourceRange() const { return SourceRange(ReturnLoc, NilLoc); }
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Fail;
}
};
ThrowStmt - Throws an error.
class ThrowStmt : public Stmt {
Expr *SubExpr;
SourceLoc ThrowLoc;
public:
explicit ThrowStmt(SourceLoc throwLoc, Expr *subExpr)
: Stmt(StmtKind::Throw, /*Implicit=*/false),
SubExpr(subExpr), ThrowLoc(throwLoc) {}
SourceLoc getThrowLoc() const { return ThrowLoc; }
SourceLoc getStartLoc() const { return ThrowLoc; }
SourceLoc getEndLoc() const;
SourceRange getSourceRange() const {
return SourceRange(ThrowLoc, getEndLoc());
}
Expr *getSubExpr() const { return SubExpr; }
void setSubExpr(Expr *subExpr) { SubExpr = subExpr; }
static bool classof(const Stmt *S) {
return S->getKind() == StmtKind::Throw;
}
};
} // end namespace swift
#endif |
require 'spec_helper'
describe <API key>('schisamo') do
it { should <API key> }
it { should have_description('passwords are for suckers') }
it { should have_password('superseekret') }
end
describe <API key>('schisamo2') do
it { should <API key> }
it { should have_id('<API key>') }
it { should have_password('superseekret') }
end
describe <API key>('schisamo3') do
it { should <API key> }
it { should have_id('schisamo3') }
it { should have_password('superseekret') }
end
describe <API key>('jenkins') do
it { should <API key> }
it { should have_description('this is more like it') }
it { should have_private_key(File.read("#{<API key>}/test_id_rsa")) }
end
describe <API key>('jenkins2') do
it { should <API key> }
it { should have_private_key(File.read("#{<API key>}/<API key>"), 'secret') }
it { should have_passphrase('secret') }
end
describe <API key>('jenkins3') do
it { should <API key> }
it { should have_description('I specified an ID') }
it { should have_id('<API key>') }
it { should have_private_key(File.read("#{<API key>}/test_id_rsa")) }
end
describe <API key>('ecdsa_nopasswd') do
it { should <API key> }
it { should have_private_key(File.read("#{<API key>}/test_id_ecdsa")) }
end
describe <API key>('ecdsa_passwd') do
it { should <API key> }
it { should have_private_key(File.read("#{<API key>}/<API key>"), 'secret') }
it { should have_passphrase('secret') }
end
describe <API key>('dollarbills') do
it { should <API key> }
it { should have_password('$uper$ecret') }
end
describe jenkins_<API key>('dollarbills_secret') do
it { should <API key> }
it { should have_secret('$uper$ecret') }
end |
var timerender = (function () {
var exports = {};
var next_timerender_id = 0;
var set_to_start_of_day = function (time) {
return time.setMilliseconds(0).setSeconds(0).setMinutes(0).setHours(0);
};
// Given an XDate object 'time', return a two-element list containing
// - a string for the current human-formatted version
// - a boolean for if it will need to be updated when the day changes
exports.render_now = function (time) {
var start_of_today = set_to_start_of_day(new XDate());
var start_of_other_day = set_to_start_of_day(time.clone());
// How many days old is 'time'? 0 = today, 1 = yesterday, 7 = a
// week ago, -1 = tomorrow, etc.
// Presumably the result of diffDays will be an integer in this
// case, but round it to be sure before comparing to integer
// constants.
var days_old = Math.round(start_of_other_day.diffDays(start_of_today));
if (days_old === 0) {
return ["Today", true];
} else if (days_old === 1) {
return ["Yesterday", true];
} else if (days_old >= 365) {
// For long running servers, searching backlog can get ambiguous
// without a year stamp. Only show year if message is over a year old.
return [time.toString("MMM\xa0dd,\xa0yyyy"), false];
}
// For now, if we get a message from tomorrow, we don't bother
// rewriting the timestamp when it gets to be tomorrow.
// "\xa0" is U+00A0 NO-BREAK SPACE.
// Can't use as that represents the literal string " ".
return [time.toString("MMM\xa0dd"), false];
};
// List of the dates that need to be updated when the day changes.
// Each timestamp is represented as a list of length 2:
// [id of the span element, XDate representing the time]
var update_list = [];
// The time at the beginning of the next day, when the timestamps are updated.
// Represented as an XDate with hour, minute, second, millisecond 0.
var next_update;
$(function () {
next_update = set_to_start_of_day(new XDate()).addDays(1);
});
// time_above is an optional argument, to support dates that look like:
function <API key>(needs_update, id, time, time_above) {
if (needs_update) {
if (time_above !== undefined) {
update_list.push([id, time, time_above]);
} else {
update_list.push([id, time]);
}
}
}
function render_date_span(elem, time_str, time_above_str) {
elem.text("");
if (time_above_str !== undefined) {
return elem.append('<i class="date-direction <API key>"></i>' +
time_above_str).append($('<hr class="date-line">')).append('<i class="date-direction <API key>"></i>'
+ time_str);
}
return elem.append(time_str);
}
// Given an XDate object 'time', return a DOM node that initially
// displays the human-formatted date, and is updated automatically as
// necessary (e.g. changing "Today" to "Yesterday" to "Jul 1").
// If two dates are given, it renders them as:
// (What's actually spliced into the message template is the contents
// of this DOM node as HTML, so effectively a copy of the node. That's
// okay since to update the time later we look up the node by its id.)
exports.render_date = function (time, time_above) {
var id = "timerender" + next_timerender_id;
next_timerender_id += 1;
var rendered_time = exports.render_now(time);
var node = $("<span />").attr('id', id);
if (time_above !== undefined) {
var rendered_time_above = exports.render_now(time_above);
node = render_date_span(node, rendered_time[0], rendered_time_above[0]);
} else {
node = render_date_span(node, rendered_time[0]);
}
<API key>(rendered_time[1], id, time, time_above);
return node;
};
// This isn't expected to be called externally except manually for
// testing purposes.
exports.update_timestamps = function () {
var time = new XDate();
if (time >= next_update) {
var to_process = update_list;
update_list = [];
_.each(to_process, function (elem) {
var id = elem[0];
var element = document.getElementById(id);
// The element might not exist any more (because it
// was in the zfilt table, or because we added
// messages above it and re-collapsed).
if (element !== null) {
var time = elem[1];
var time_above;
var rendered_time = exports.render_now(time);
if (elem.length === 3) {
time_above = elem[2];
var rendered_time_above = exports.render_now(time_above);
render_date_span($(element), rendered_time[0], rendered_time_above[0]);
} else {
render_date_span($(element), rendered_time[0]);
}
<API key>(rendered_time[1], id, time, time_above);
}
});
next_update = set_to_start_of_day(time.clone().addDays(1));
}
};
setInterval(exports.update_timestamps, 60 * 1000);
// TODO: Remove the duplication with the below; it's a bit tricky
// because the return type models are pretty different.
exports.get_full_time = function (timestamp) {
var time = new XDate(timestamp * 1000);
// Convert to number of hours ahead/behind UTC.
// The sign of getTimezoneOffset() is reversed wrt
// the conventional meaning of UTC+n / UTC-n
var tz_offset = -time.getTimezoneOffset() / 60;
var full_date_str = time.toLocaleDateString();
var full_time_str = time.toLocaleTimeString() +
' (UTC' + ((tz_offset < 0) ? '' : '+') + tz_offset + ')';
return full_date_str + ' ' + full_time_str;
};
// this is for rendering absolute time based off the preferences for twenty-four
// hour time in the format of "%mmm %d, %h:%m %p".
exports.absolute_time = (function () {
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var fmt_time = function (date, H_24) {
var payload = {
hours: date.getHours(),
minutes: date.getMinutes(),
};
if (payload.hours > 12 && !H_24) {
payload.hours -= 12;
payload.is_pm = true;
}
var str = ("0" + payload.hours).slice(-2) + ":" + ("0" + payload.minutes).slice(-2);
if (!H_24) {
str += payload.is_pm ? " PM" : " AM";
}
return str;
};
return function (timestamp) {
var date = new Date(timestamp);
var H_24 = page_params.<API key>;
return MONTHS[date.getMonth()] + " " + date.getDate() + ", " + fmt_time(date, H_24);
};
}());
// XDate.toLocaleDateString and XDate.toLocaleTimeString are
// expensive, so we delay running the following code until we need
// the full date and time strings.
exports.set_full_datetime = function <API key>(message, time_elem) {
if (message.full_date_str !== undefined) {
return;
}
var time = new XDate(message.timestamp * 1000);
// Convert to number of hours ahead/behind UTC.
// The sign of getTimezoneOffset() is reversed wrt
// the conventional meaning of UTC+n / UTC-n
var tz_offset = -time.getTimezoneOffset() / 60;
message.full_date_str = time.toLocaleDateString();
message.full_time_str = time.toLocaleTimeString() +
' (UTC' + ((tz_offset < 0) ? '' : '+') + tz_offset + ')';
time_elem.attr('title', message.full_date_str + ' ' + message.full_time_str);
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = timerender;
} |
#include "chrome/browser/extensions/extension_apitest.h"
#include "net/dns/mock_host_resolver.h"
<API key>(ExtensionApiTest, <API key>) {
host_resolver()->AddRule("a.com", "127.0.0.1");
host_resolver()->AddRule("b.com", "127.0.0.1");
ASSERT_TRUE(StartTestServer());
ASSERT_TRUE(RunExtensionTest("tabs/<API key>")) << message_;
} |
<!DOCTYPE html>
<html>
<head>
<!
This file loads only the mandatory JavaScript.
It is feeded into `sencha create jsb` command to create a
concatenated+compressed version of the Docs app JavaScript.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">Docs = {localStorageDb: "docs"};</script>
<script type="text/javascript" src="extjs/ext.js"></script>
<!-- BEGIN JS -->
<script type="text/javascript" src="resources/codemirror/codemirror.js"></script>
<script type="text/javascript" src="resources/codemirror/javascript.js"></script>
<script type="text/javascript" src="resources/prettify/prettify.js"></script>
<script type="text/javascript" src="app.js"></script>
<!-- END JS -->
<script type="text/javascript" src="data.js"></script>
</head>
<body>
</body>
</html> |
CREATE TABLE IF NOT EXISTS <API key> (
username text PRIMARY KEY,
hash text NOT NULL,
salt text NOT NULL,
role text NOT NULL,
created timestamp without time zone DEFAULT now() NOT NULL
); |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.LanguageServices.CSharp.Snippets.SnippetFunctions;
using Microsoft.VisualStudio.LanguageServices.Implementation.Snippets;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using MSXML;
using Roslyn.Utilities;
using VsTextSpan = Microsoft.VisualStudio.TextManager.Interop.TextSpan;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.Snippets
{
internal sealed partial class <API key> : <API key>
{
public <API key>(Guid languageServiceGuid, ITextView textView, ITextBuffer subjectBuffer, <API key> <API key>)
: base(languageServiceGuid, textView, subjectBuffer, <API key>)
{
}
<returns>The tracking span of the inserted "" if there is an $end$ location, null
otherwise.</returns>
protected override ITrackingSpan <API key>()
{
VsTextSpan[] <API key> = new VsTextSpan[1];
if (ExpansionSession.GetEndSpan(<API key>) != VSConstants.S_OK)
{
return null;
}
SnapshotSpan <API key>;
if (!<API key>(<API key>[0], out <API key>))
{
return null;
}
var endPosition = <API key>.Start.Position;
string commentString = "";
SubjectBuffer.Insert(endPosition, commentString);
var commentSpan = new Span(endPosition, commentString.Length);
return SubjectBuffer.CurrentSnapshot.CreateTrackingSpan(commentSpan, SpanTrackingMode.EdgeExclusive);
}
public override int <API key>(IXMLDOMNode xmlFunctionNode, string bstrFieldName, out <API key> pFunc)
{
string snippetFunctionName, param;
if (!<API key>(xmlFunctionNode, out snippetFunctionName, out param))
{
pFunc = null;
return VSConstants.E_INVALIDARG;
}
switch (snippetFunctionName)
{
case "SimpleTypeName":
pFunc = new <API key>(this, TextView, SubjectBuffer, bstrFieldName, param);
return VSConstants.S_OK;
case "ClassName":
pFunc = new <API key>(this, TextView, SubjectBuffer, bstrFieldName);
return VSConstants.S_OK;
case "GenerateSwitchCases":
pFunc = new <API key>(this, TextView, SubjectBuffer, bstrFieldName, param);
return VSConstants.S_OK;
default:
pFunc = null;
return VSConstants.E_INVALIDARG;
}
}
internal override Document AddImports(Document document, XElement snippetNode, bool <API key>, Cancellation<API key>)
{
var importsNode = snippetNode.Element(XName.Get("Imports", snippetNode.Name.NamespaceName));
if (importsNode == null ||
!importsNode.HasElements)
{
return document;
}
var newUsingDirectives = <API key>(document, snippetNode, importsNode, cancellationToken);
if (!newUsingDirectives.Any())
{
return document;
}
// In Venus/Razor, inserting imports statements into the subject buffer does not work.
// Instead, we add the imports through the contained language host.
if (<API key>(document, newUsingDirectives.Where(u => u.Alias == null).Select(u => u.Name.ToString())))
{
return document;
}
var root = document.<API key>(cancellationToken);
var newRoot = ((<API key>)root).AddUsingDirectives(newUsingDirectives, <API key>);
var newDocument = document.WithSyntaxRoot(newRoot);
var formattedDocument = Formatter.FormatAsync(newDocument, Formatter.Annotation, cancellation<API key>).WaitAndGetResult(cancellationToken);
document.Project.Solution.Workspace.<API key>(formattedDocument, cancellationToken);
return formattedDocument;
}
private static IList<<API key>> <API key>(Document document, XElement snippetNode, XElement importsNode, Cancellation<API key>)
{
var namespaceXmlName = XName.Get("Namespace", snippetNode.Name.NamespaceName);
var root = document.<API key>(cancellationToken);
var existingUsings = ((<API key>)root).Usings;
var newUsings = new List<<API key>>();
foreach (var import in importsNode.Elements(XName.Get("Import", snippetNode.Name.NamespaceName)))
{
var namespaceElement = import.Element(namespaceXmlName);
if (namespaceElement == null)
{
continue;
}
var namespaceToImport = namespaceElement.Value.Trim();
if (string.IsNullOrEmpty(namespaceToImport))
{
continue;
}
var candidateUsing = SyntaxFactory.<API key>("using " + namespaceToImport + ";").DescendantNodes().OfType<<API key>>().FirstOrDefault();
if (candidateUsing == null)
{
continue;
}
if (!existingUsings.Any(u => UsingsMatch(u, candidateUsing)))
{
newUsings.Add(candidateUsing.<API key>(Formatter.Annotation).<API key>(SyntaxFactory.<API key>));
}
}
return newUsings;
}
private static bool UsingsMatch(<API key> usingDirective1, <API key> usingDirective2)
{
return usingDirective1.Name.ToString() == usingDirective2.Name.ToString() && GetAliasName(usingDirective1) == GetAliasName(usingDirective2);
}
private static string GetAliasName(<API key> usingDirective)
{
return (usingDirective.Alias == null || usingDirective.Alias.Name == null) ? null : usingDirective.Alias.Name.ToString();
}
}
} |
// This file should be placed between "inputEx/field.js" and all other inputEx fields
(function() {
var lang = YAHOO.lang;
/**
* Copy of the original inputEx.Field class that we're gonna override to extend it.
* @class BaseField
* @namespace inputEx
*/
inputEx.BaseField = inputEx.Field;
/**
* Class to make inputEx Fields "wirable".Re-create inputEx.Field adding the wirable properties
* @class Field
* @namespace inputEx
* @extends inputEx.BaseField
*/
inputEx.Field = function(options) {
inputEx.Field.superclass.constructor.call(this,options);
};
lang.extend(inputEx.Field, inputEx.BaseField, {
/**
* Adds a wirable option to every field
* @method setOptions
*/
setOptions: function(options) {
inputEx.Field.superclass.setOptions.call(this, options);
this.options.wirable = lang.isUndefined(options.wirable) ? false : options.wirable;
this.options.container = options.container;
},
/**
* Adds a terminal to each field
* @method render
*/
render: function() {
inputEx.Field.superclass.render.call(this);
if(this.options.wirable) {
this.renderTerminal();
}
},
/**
* Render the associated input terminal
* @method renderTerminal
*/
renderTerminal: function() {
var wrapper = inputEx.cn('div', {className: '<API key>'});
this.divEl.insertBefore(wrapper, this.fieldContainer);
this.terminal = new WireIt.Terminal(wrapper, {
name: this.options.name,
direction: [-1,0],
fakeDirection: [0, 1],
ddConfig: {
type: "input",
allowedTypes: ["output"]
},
nMaxWires: 1 }, this.options.container);
// Dfly name for this terminal
this.terminal.dflyName = "input_"+this.options.name;
// Reference to the container
if(this.options.container) {
this.options.container.terminals.push(this.terminal);
}
// Register the events
this.terminal.eventAddWire.subscribe(this.onAddWire, this, true);
this.terminal.eventRemoveWire.subscribe(this.onRemoveWire, this, true);
},
/**
* Remove the input wired state on the
* @method onAddWire
*/
onAddWire: function(e, params) {
this.options.container.onAddWire(e,params);
this.disable();
this.el.value = "[wired]";
},
/**
* Remove the input wired state on the
* @method onRemoveWire
*/
onRemoveWire: function(e, params) {
this.options.container.onRemoveWire(e,params);
this.enable();
this.el.value = "";
}
});
})(); |
# DExTer : Debugging Experience Tester
# <API key>: Apache-2.0 WITH LLVM-exception
"""Set of data classes for representing the complete debug program state at a
fixed point in execution.
"""
import os
from collections import OrderedDict
from typing import List
class SourceLocation:
def __init__(self, path: str = None, lineno: int = None, column: int = None):
if path:
path = os.path.normcase(path)
self.path = path
self.lineno = lineno
self.column = column
def __str__(self):
return '{}({}:{})'.format(self.path, self.lineno, self.column)
def match(self, other) -> bool:
"""Returns true iff all the properties that appear in `self` have the
same value in `other`, but not necessarily vice versa.
"""
if not other or not isinstance(other, SourceLocation):
return False
if self.path and (self.path != other.path):
return False
if self.lineno and (self.lineno != other.lineno):
return False
if self.column and (self.column != other.column):
return False
return True
class StackFrame:
def __init__(self,
function: str = None,
is_inlined: bool = None,
location: SourceLocation = None,
watches: OrderedDict = None):
if watches is None:
watches = {}
self.function = function
self.is_inlined = is_inlined
self.location = location
self.watches = watches
def __str__(self):
return '{}{}: {} | {}'.format(
self.function,
' (inlined)' if self.is_inlined else '',
self.location,
{k: str(self.watches[k]) for k in self.watches})
def match(self, other) -> bool:
"""Returns true iff all the properties that appear in `self` have the
same value in `other`, but not necessarily vice versa.
"""
if not other or not isinstance(other, StackFrame):
return False
if self.location and not self.location.match(other.location):
return False
if self.watches:
for name in iter(self.watches):
try:
if isinstance(self.watches[name], dict):
for attr in iter(self.watches[name]):
if (getattr(other.watches[name], attr, None) !=
self.watches[name][attr]):
return False
else:
if other.watches[name].value != self.watches[name]:
return False
except KeyError:
return False
return True
class ProgramState:
def __init__(self, frames: List[StackFrame] = None):
self.frames = frames
def __str__(self):
return '\n'.join(map(
lambda enum: 'Frame {}: {}'.format(enum[0], enum[1]),
enumerate(self.frames)))
def match(self, other) -> bool:
"""Returns true iff all the properties that appear in `self` have the
same value in `other`, but not necessarily vice versa.
"""
if not other or not isinstance(other, ProgramState):
return False
if self.frames:
for idx, frame in enumerate(self.frames):
try:
if not frame.match(other.frames[idx]):
return False
except (IndexError, KeyError):
return False
return True |
package org.dspace.app.xmlui.aspect.discovery;
import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.core.Context;
import java.sql.SQLException;
/**
* Class used to display facets for an item
*
* @author Kevin Van de Velde (kevin at atmire dot com)
* @author Mark Diggory (markd at atmire dot com)
* @author Ben Bosman (ben at atmire dot com)
*/
public class ItemFacets extends <API key>
{
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ItemFacets.class);
/**
* Display a single item
*/
public void addBody(org.dspace.app.xmlui.wing.element.Body body) throws org.xml.sax.SAXException, org.dspace.app.xmlui.wing.WingException,
org.dspace.app.xmlui.utils.UIException, java.sql.SQLException, java.io.IOException, org.dspace.authorize.AuthorizeException
{
org.dspace.content.DSpaceObject dso = org.dspace.app.xmlui.utils.HandleUtil.obtainHandle(objectModel);
if (!(dso instanceof org.dspace.content.Item))
{
return;
}
org.dspace.content.Item item = (org.dspace.content.Item) dso;
try {
performSearch(item);
} catch (org.dspace.discovery.<API key> e) {
log.error(e.getMessage(),e);
}
}
@Override
public void performSearch(org.dspace.content.DSpaceObject dso) throws SQLException, org.dspace.discovery.<API key> {
if(queryResults != null)
{
return;
}
this.queryArgs = <API key>(getView());
this.queryArgs.setRows(1);
this.queryArgs.setQuery("handle:" + dso.getHandle());
Context context = ContextUtil.obtainContext(objectModel);
queryResults = getSearchService().search(context, queryArgs);
}
public String getView()
{
return "item";
}
/**
* Recycle
*/
public void recycle() {
this.queryArgs = null;
this.queryResults = null;
super.recycle();
}
} |
<?php
namespace PDepend\Source\AST;
use PDepend\Source\ASTVisitor\ASTVisitor;
class ASTFinallyStatement extends ASTStatement
{
/**
* Accept method of the visitor design pattern. This method will be called
* by a visitor during tree traversal.
*
* @param \PDepend\Source\ASTVisitor\ASTVisitor $visitor
* @param mixed $data
* @return mixed
*/
public function accept(ASTVisitor $visitor, $data = null)
{
return $visitor-><API key>($this, $data);
}
} |
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
test(function(t) {
// It is not clear from the spec whether this is supposed to work and how.
// Therefore, we do not validate the rendering results. We just make sure
// this does not crash the browser.
var canvas1 = document.createElement('canvas');
var ctx1 = canvas1.getContext('2d');
var htmlDoc = document.implementation.createHTMLDocument('', '', null);
htmlDoc.adoptNode(canvas1);
var canvas2 = htmlDoc.createElement('canvas');
var ctx2 = canvas2.getContext('2d');
ctx1.font = 'italic 30px Arial';
ctx2.font = 'italic 30px Arial';
ctx1.fillText('Text1', 0, 30);
ctx2.fillText('Text1', 0, 30);
ctx1.strokeText('Text2', 0, 60);
ctx2.strokeText('Text2', 0, 60);
ctx1.measureText('Text3');
ctx2.measureText('Text3');
}, "This verifies that the browser does not crash when drawing text to a canvas in a frame-less document.");
</script>
</body> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.