Skip to content

Instantly share code, notes, and snippets.

@wycats
Created February 5, 2014 19:44
Show Gist options
  • Save wycats/8831523 to your computer and use it in GitHub Desktop.
Save wycats/8831523 to your computer and use it in GitHub Desktop.
#[feature(macro_rules)];
#[crate_id = "skylight#0.0.1"];
#[no_uv];
#[desc = "Direwolf Agent"];
#[license = "MIT"];
use std::prelude::*;
extern mod std = "std#0.10-pre";
extern mod buffoon;
extern mod extra;
use extra::time;
use trace::{Trace, IntValue, DoubleValue, StringValue, NestedValue};
use batch::Batch;
use to_out_ptr::ToOutPtr;
use buffoon::Message;
// used by expanded macros
use macros::close_task;
mod macros {
// TODO: Should buffoon really be taking a ~[u8] here?
// TODO: Should buffoon really be taking a ~[u8] here?
#[macro_escape];
use std::prelude::*;
use std::rt::task::Task;
use std::rt::local::Local;
mod libunwind {
//! Unwind library interface
#[allow(non_camel_case_types)];
#[allow(dead_code)];
use std::prelude::*;
use std::libc::uintptr_t;
#[cfg(not(target_arch = "arm"))]
#[repr(C)]
pub enum _Unwind_Action {
_UA_SEARCH_PHASE = 1,
_UA_CLEANUP_PHASE = 2,
_UA_HANDLER_FRAME = 4,
_UA_FORCE_UNWIND = 8,
_UA_END_OF_STACK = 16,
}
#[repr(C)]
pub enum _Unwind_Reason_Code {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8,
_URC_FAILURE = 9,
}
pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = uintptr_t;
#[cfg(not(target_arch = "arm"))]
pub static unwinder_private_data_size: int = 2;
pub struct _Unwind_Exception {
exception_class: _Unwind_Exception_Class,
exception_cleanup: _Unwind_Exception_Cleanup_Fn,
private: [_Unwind_Word, ..unwinder_private_data_size],
}
pub enum _Unwind_Context { }
pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn
(unwind_code: _Unwind_Reason_Code,
exception: *_Unwind_Exception);
extern "C" {
pub fn _Unwind_RaiseException(exception: *_Unwind_Exception) ->
_Unwind_Reason_Code;
pub fn _Unwind_DeleteException(exception: *_Unwind_Exception);
}
}
pub fn close_task() {
use std::rt::task::LocalStorage;
fn close_outputs() {
let mut task = Local::borrow(None::<Task>);
let logger = task.get().logger.take();
let stderr = task.get().stderr.take();
let stdout = task.get().stdout.take();
drop(task);
drop(logger);
match stdout { Some(mut w) => w.flush(), None => { } }
match stderr { Some(mut w) => w.flush(), None => { } }
}
close_outputs();
let mut task = Local::borrow(None::<Task>);
{
let task = task.get();
let LocalStorage(ref mut optmap) = task.storage;
if optmap.is_some() { drop(optmap.take()) }
}
drop(task);
close_outputs();
}
}
mod libunwind {
//! Unwind library interface
#[allow(non_camel_case_types)];
#[allow(dead_code)];
use std::prelude::*;
use std::libc::uintptr_t;
#[cfg(not(target_arch = "arm"))]
#[repr(C)]
pub enum _Unwind_Action {
_UA_SEARCH_PHASE = 1,
_UA_CLEANUP_PHASE = 2,
_UA_HANDLER_FRAME = 4,
_UA_FORCE_UNWIND = 8,
_UA_END_OF_STACK = 16,
}
#[repr(C)]
pub enum _Unwind_Reason_Code {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8,
_URC_FAILURE = 9,
}
pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = uintptr_t;
#[cfg(not(target_arch = "arm"))]
pub static unwinder_private_data_size: int = 2;
pub struct _Unwind_Exception {
exception_class: _Unwind_Exception_Class,
exception_cleanup: _Unwind_Exception_Cleanup_Fn,
private: [_Unwind_Word, ..unwinder_private_data_size],
}
pub enum _Unwind_Context { }
pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn
(unwind_code: _Unwind_Reason_Code, exception: *_Unwind_Exception);
extern "C" {
pub fn _Unwind_RaiseException(exception: *_Unwind_Exception) ->
_Unwind_Reason_Code;
pub fn _Unwind_DeleteException(exception: *_Unwind_Exception);
}
}
mod trace {
use std::prelude::*;
use buffoon;
use buffoon::Message;
#[deriving(Clone, Eq)]
struct SpanData {
time: u64,
idx: u32,
stack_index: u32,
annotations: ~[Option<buffoon::Annotation>],
annotation_parents: ~[Option<u32>],
}
#[doc = "Automatically derived."]
impl ::std::clone::Clone for SpanData {
#[inline]
fn clone(&self) -> SpanData {
match *self {
SpanData{time: ref __self_0_0,
idx: ref __self_0_1,
stack_index: ref __self_0_2,
annotations: ref __self_0_3,
annotation_parents: ref __self_0_4} =>
SpanData{time: (*__self_0_0).clone(),
idx: (*__self_0_1).clone(),
stack_index: (*__self_0_2).clone(),
annotations: (*__self_0_3).clone(),
annotation_parents: (*__self_0_4).clone(),}
}
}
}
#[doc = "Automatically derived."]
impl ::std::cmp::Eq for SpanData {
#[inline]
fn eq(&self, __arg_0: &SpanData) -> ::bool {
match *__arg_0 {
SpanData{time: ref __self_1_0,
idx: ref __self_1_1,
stack_index: ref __self_1_2,
annotations: ref __self_1_3,
annotation_parents: ref __self_1_4} =>
match *self {
SpanData{time: ref __self_0_0,
idx: ref __self_0_1,
stack_index: ref __self_0_2,
annotations: ref __self_0_3,
annotation_parents: ref __self_0_4} =>
true && (*__self_0_0).eq(&(*__self_1_0)) &&
(*__self_0_1).eq(&(*__self_1_1)) &&
(*__self_0_2).eq(&(*__self_1_2)) &&
(*__self_0_3).eq(&(*__self_1_3)) &&
(*__self_0_4).eq(&(*__self_1_4))
}
}
}
#[inline]
fn ne(&self, __arg_0: &SpanData) -> ::bool {
match *__arg_0 {
SpanData{time: ref __self_1_0,
idx: ref __self_1_1,
stack_index: ref __self_1_2,
annotations: ref __self_1_3,
annotation_parents: ref __self_1_4} =>
match *self {
SpanData{time: ref __self_0_0,
idx: ref __self_0_1,
stack_index: ref __self_0_2,
annotations: ref __self_0_3,
annotation_parents: ref __self_0_4} =>
false || (*__self_0_0).ne(&(*__self_1_0)) ||
(*__self_0_1).ne(&(*__self_1_1)) ||
(*__self_0_2).ne(&(*__self_1_2)) ||
(*__self_0_3).ne(&(*__self_1_3)) ||
(*__self_0_4).ne(&(*__self_1_4))
}
}
}
}
#[deriving(Clone, Eq)]
pub struct Trace {
/**
This is a time that is represented against an arbitrary epoch.
Its meaning is opaque, but all other APIs provide their values
as relative to this time, in increments of 1/10th of a millisecond.
*/
started_at: u64,
trace: buffoon::Trace,
stack: ~[SpanData],
}
#[doc = "Automatically derived."]
impl ::std::clone::Clone for Trace {
#[inline]
fn clone(&self) -> Trace {
match *self {
Trace{started_at: ref __self_0_0,
trace: ref __self_0_1,
stack: ref __self_0_2} =>
Trace{started_at: (*__self_0_0).clone(),
trace: (*__self_0_1).clone(),
stack: (*__self_0_2).clone(),}
}
}
}
#[doc = "Automatically derived."]
impl ::std::cmp::Eq for Trace {
#[inline]
fn eq(&self, __arg_0: &Trace) -> ::bool {
match *__arg_0 {
Trace{started_at: ref __self_1_0,
trace: ref __self_1_1,
stack: ref __self_1_2} =>
match *self {
Trace{started_at: ref __self_0_0,
trace: ref __self_0_1,
stack: ref __self_0_2} =>
true && (*__self_0_0).eq(&(*__self_1_0)) &&
(*__self_0_1).eq(&(*__self_1_1)) &&
(*__self_0_2).eq(&(*__self_1_2))
}
}
}
#[inline]
fn ne(&self, __arg_0: &Trace) -> ::bool {
match *__arg_0 {
Trace{started_at: ref __self_1_0,
trace: ref __self_1_1,
stack: ref __self_1_2} =>
match *self {
Trace{started_at: ref __self_0_0,
trace: ref __self_0_1,
stack: ref __self_0_2} =>
false || (*__self_0_0).ne(&(*__self_1_0)) ||
(*__self_0_1).ne(&(*__self_1_1)) ||
(*__self_0_2).ne(&(*__self_1_2))
}
}
}
}
#[deriving(Clone, Eq)]
pub enum AnnotationValue {
StringValue(~str),
IntValue(i64),
DoubleValue(f64),
NestedValue,
}
#[doc = "Automatically derived."]
impl ::std::clone::Clone for AnnotationValue {
#[inline]
fn clone(&self) -> AnnotationValue {
match *self {
StringValue(ref __self_0) => StringValue((*__self_0).clone()),
IntValue(ref __self_0) => IntValue((*__self_0).clone()),
DoubleValue(ref __self_0) => DoubleValue((*__self_0).clone()),
NestedValue => NestedValue
}
}
}
#[doc = "Automatically derived."]
impl ::std::cmp::Eq for AnnotationValue {
#[inline]
fn eq(&self, __arg_0: &AnnotationValue) -> ::bool {
match *self {
StringValue(ref __self_0) =>
match *__arg_0 {
StringValue(ref __arg_1_0) =>
true && (*__self_0).eq(&(*__arg_1_0)),
_ => false
},
IntValue(ref __self_0) =>
match *__arg_0 {
IntValue(ref __arg_1_0) =>
true && (*__self_0).eq(&(*__arg_1_0)),
_ => false
},
DoubleValue(ref __self_0) =>
match *__arg_0 {
DoubleValue(ref __arg_1_0) =>
true && (*__self_0).eq(&(*__arg_1_0)),
_ => false
},
NestedValue =>
match *__arg_0 { NestedValue => true, _ => false }
}
}
#[inline]
fn ne(&self, __arg_0: &AnnotationValue) -> ::bool {
match *self {
StringValue(ref __self_0) =>
match *__arg_0 {
StringValue(ref __arg_1_0) =>
false || (*__self_0).ne(&(*__arg_1_0)),
_ => true
},
IntValue(ref __self_0) =>
match *__arg_0 {
IntValue(ref __arg_1_0) =>
false || (*__self_0).ne(&(*__arg_1_0)),
_ => true
},
DoubleValue(ref __self_0) =>
match *__arg_0 {
DoubleValue(ref __arg_1_0) =>
false || (*__self_0).ne(&(*__arg_1_0)),
_ => true
},
NestedValue =>
match *__arg_0 { NestedValue => false, _ => true }
}
}
}
impl Trace {
pub fn new(start: u64, uuid: ~str) -> Trace {
let trace = buffoon::Trace{uuid: uuid, name: None, spans: ~[],};
Trace{started_at: start, trace: trace, stack: ~[],}
}
pub fn set_name(&mut self, name: ~str) { self.trace.set_name(name) }
pub fn get_name<'a>(&'a self) -> Option<&'a str> {
self.trace.get_name()
}
pub fn get_uuid<'a>(&'a self) -> &'a str { self.trace.get_uuid() }
pub fn start_span(&mut self, mut time: u64, category: ~str) -> u32 {
let idx = self.trace.get_spans().len() as u32;
if idx == 0 { time = self.started_at }
let raw_time = time;
let relative_time = self.relativize(time);
let stack = &mut self.stack;
let event = buffoon::Event::new(category);
let mut span = ~buffoon::Span::new(event, relative_time);
let stack_index = stack.len() as u32;
if stack_index > 0 { span.set_parent(stack.last().unwrap().idx); }
stack.push(SpanData{time: raw_time,
idx: idx,
stack_index: stack_index,
annotations: ~[],
annotation_parents: ~[],});
self.trace.add_span(span);
idx
}
pub fn add_annotation(&mut self, span_id: u32, parent: Option<u32>,
key: Option<&str>, value: AnnotationValue) ->
uint {
let mut annotation = buffoon::Annotation::new();
add_value(&mut annotation, key, ~value);
let span_data = self.span_data_for_index(span_id).unwrap();
span_data.annotations.push(Some(annotation));
span_data.annotation_parents.push(parent);
span_data.annotations.len() - 1
}
pub fn stop(&mut self, index: u32, time: u64) {
while self.stack.len() > 0 {
if self.stop_current_span(time) == index { break }
}
}
pub fn span_set_title(&mut self, index: u64, title: ~str) {
self.trace.mut_spans()[index].mut_event().set_title(title);
}
pub fn span_set_description(&mut self, index: u64,
description: ~str) {
self.trace.mut_spans()[index].mut_event().set_description(description);
}
pub fn serialize(&self) -> ~[u8] { self.trace.serialize() }
fn stop_current_span(&mut self, time: u64) -> u32 {
let relative_time = self.relativize(time);
let span_data = self.stack.pop().unwrap();
let idx = span_data.idx;
{
let span = &mut *self.trace.mut_spans()[span_data.idx];
done_annotations(span_data, span);
span.set_duration(relative_time);
}
idx
}
fn span_data_for_index<'a>(&'a mut self, index: u32) ->
Option<&'a mut SpanData> {
match &mut self.stack.mut_rev_iter() {
i =>
loop {
match i.next() {
None => break ,
Some(span_data) => {
if span_data.idx == index {
return Some(span_data)
}
}
}
}
}
None
}
fn relativize(&self, time: u64) -> u32 {
if self.stack.is_empty() {
(time - self.started_at) as u32
} else { (time - self.stack.last().unwrap().time) as u32 }
}
}
fn add_value(annotation: &mut buffoon::Annotation, key: Option<&str>,
value: ~AnnotationValue) {
annotation.key = key.map(|key| key.to_owned());
match *value {
IntValue(value) => annotation.set_int(value),
StringValue(value) => annotation.set_string(value),
DoubleValue(value) => annotation.set_double(value),
NestedValue => ()
}
}
fn compact<T>(vector: &mut ~[T], keep: |&T| -> bool) {
let mut kept = 0;
let mut finger = 0;
while finger < vector.len() {
if keep(&vector[finger]) { vector.swap(kept, finger); kept += 1; }
finger += 1;
}
vector.truncate(kept);
}
fn done_annotations(span_data: SpanData, span: &mut buffoon::Span) {
let SpanData{annotation_parents: annotation_parents,
annotations: annotations, ..} = span_data;
let end = annotation_parents.len() - 1;
let mut annotations = annotations;
match &mut annotation_parents.rev_iter().enumerate() {
i =>
loop {
match i.next() {
None => break ,
Some((index, parent_index)) => {
match *parent_index {
None => (),
Some(parent_index) => {
let annotation =
annotations[end - index].take_unwrap();
let parent =
annotations[parent_index].get_mut_ref();
parent.mut_annotations().unshift(annotation);
}
}
}
}
}
}
compact(&mut annotations, (|el| el.is_some()));
span.set_annotations(annotations.move_iter().map(|x|
x.unwrap()).collect());
}
}
mod batch {
use std::prelude::*;
use std::hashmap::HashMap;
use buffoon;
use buffoon::Message;
#[deriving(Clone, Eq)]
pub struct Batch {
timestamp: u32,
hostname: Option<~str>,
endpoints: HashMap<~str, ~[~[u8]]>,
counts: HashMap<~str, u64>,
}
#[doc = "Automatically derived."]
impl ::std::clone::Clone for Batch {
#[inline]
fn clone(&self) -> Batch {
match *self {
Batch{timestamp: ref __self_0_0,
hostname: ref __self_0_1,
endpoints: ref __self_0_2,
counts: ref __self_0_3} =>
Batch{timestamp: (*__self_0_0).clone(),
hostname: (*__self_0_1).clone(),
endpoints: (*__self_0_2).clone(),
counts: (*__self_0_3).clone(),}
}
}
}
#[doc = "Automatically derived."]
impl ::std::cmp::Eq for Batch {
#[inline]
fn eq(&self, __arg_0: &Batch) -> ::bool {
match *__arg_0 {
Batch{timestamp: ref __self_1_0,
hostname: ref __self_1_1,
endpoints: ref __self_1_2,
counts: ref __self_1_3} =>
match *self {
Batch{timestamp: ref __self_0_0,
hostname: ref __self_0_1,
endpoints: ref __self_0_2,
counts: ref __self_0_3} =>
true && (*__self_0_0).eq(&(*__self_1_0)) &&
(*__self_0_1).eq(&(*__self_1_1)) &&
(*__self_0_2).eq(&(*__self_1_2)) &&
(*__self_0_3).eq(&(*__self_1_3))
}
}
}
#[inline]
fn ne(&self, __arg_0: &Batch) -> ::bool {
match *__arg_0 {
Batch{timestamp: ref __self_1_0,
hostname: ref __self_1_1,
endpoints: ref __self_1_2,
counts: ref __self_1_3} =>
match *self {
Batch{timestamp: ref __self_0_0,
hostname: ref __self_0_1,
endpoints: ref __self_0_2,
counts: ref __self_0_3} =>
false || (*__self_0_0).ne(&(*__self_1_0)) ||
(*__self_0_1).ne(&(*__self_1_1)) ||
(*__self_0_2).ne(&(*__self_1_2)) ||
(*__self_0_3).ne(&(*__self_1_3))
}
}
}
}
impl Batch {
pub fn new(timestamp: u32, hostname: Option<~str>) -> Batch {
Batch{endpoints: hash_map(),
counts: hash_map(),
timestamp: timestamp,
hostname: hostname,}
}
pub fn add(&mut self, name: ~str, trace: ~[u8]) {
self.endpoints.find_or_insert_with(name.clone(),
|_| ~[]).push(trace);
}
pub fn set_endpoint_count(&mut self, endpoint: ~str, count: u64) {
self.counts.insert(endpoint, count);
}
pub fn serialize(&self) -> ~[u8] {
let mut batch =
buffoon::Batch{timestamp: self.timestamp,
hostname: self.hostname.clone(),
endpoints: ~[],};
match &mut self.endpoints.iter() {
i =>
loop {
match i.next() {
None => break ,
Some((name, traces)) => {
let count = self.counts.get(&*name);
let traces =
traces.iter().map(|t|
buffoon::message::SerializedMessage(t.clone())).collect();
let endpoint =
buffoon::Endpoint{name: name.clone(),
count: *count,
traces: traces,};
batch.add_endpoint(endpoint);
}
}
}
}
batch.serialize()
}
}
fn hash_map<K: Hash + Eq, V>() -> HashMap<K, V> {
HashMap::<K, V>::with_capacity_and_keys(32, 0, 0)
}
}
mod to_out_ptr {
use std::prelude::*;
use std::ptr::replace_ptr;
use std::cast::transmute;
use std::unstable::intrinsics::move_val_init;
pub trait ToOutPtr<T> {
fn to_out_ptr(self, *mut T) -> bool;
}
impl <T> ToOutPtr<T> for Option<T> {
fn to_out_ptr(self, out: *mut T) -> bool {
match self {
None => false,
Some(val) => unsafe { replace_ptr(out, val); true }
}
}
}
impl <'a, T> ToOutPtr<T> for ~T {
fn to_out_ptr(self, out: *mut T) -> bool {
unsafe { move_val_init(transmute(out), self); true }
}
}
impl <'a, T> ToOutPtr<T> for &'a str {
fn to_out_ptr(self, out: *mut T) -> bool {
unsafe { move_val_init(transmute(out), self); true }
}
}
impl <'a, T> ToOutPtr<T> for ~[u8] {
fn to_out_ptr(self, out: *mut T) -> bool {
unsafe { move_val_init(transmute(out), self); true }
}
}
impl <'a, T> ToOutPtr<T> for u32 {
fn to_out_ptr(self, out: *mut T) -> bool {
unsafe { move_val_init(transmute(out), self); true }
}
}
impl <'a, T> ToOutPtr<T> for u64 {
fn to_out_ptr(self, out: *mut T) -> bool {
unsafe { move_val_init(transmute(out), self); true }
}
}
}
/**
Rust utilities
*/
/**
Style Guide
Every Rust function that is exposed over the FFI must either:
* return a borrowed value
* return an owned value and include `_into_new_<type>` in its name.
If a Rust function exposes an owned value, it must provide a
deallocator named `skylight_free_<type>`.
This will ensure that C programmers working with this API are
aware when an externed Rust function is allocating memory and
can be sure to free it explicitly using an idiomatic "free"
API.
This may require additional copying at the FFI boundary or in
APIs called by the FFI boundary. This is acceptable in order to
ensure an idiomatic, explicit C API.
*/
#[no_mangle]
pub extern "C" fn skylight_free_buf(_: ~[u8]) { }
#[no_mangle]
pub extern "C" fn skylight_slice_to_owned(slice: &str) -> ~str {
slice.to_owned()
}
#[no_mangle]
pub extern "C" fn bootstrap_rust_runtime() { }
#[no_mangle]
pub extern "C" fn factory() { }
#[no_mangle]
pub extern "C" fn skylight_high_res_time(out: *mut u64) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args {
out: *mut u64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let Args{out: out}: Args = transmute(args);
{ time::precise_time_ns() }.to_out_ptr(out);
}
}
let args = Args{out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_new<'a>(version: &'a str, config: u32,
out: *mut buffoon::Hello) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
version: &'a str,
config: u32,
out: *mut buffoon::Hello,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{version: version, config: config, out: out}: ~Args =
transmute(args);
{
~buffoon::Hello{version: version.to_owned(),
config: Some(config),
cmd: ~[],}
}.to_out_ptr(out);
}
}
let args = ~Args{version: version, config: config, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_free<'a>(hello: ~buffoon::Hello) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: ~buffoon::Hello,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe { let ~Args{hello: hello}: ~Args = transmute(args); { }; }
}
let args = ~Args{hello: hello,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_load<'a>(protobuf: &'a [u8],
out: *mut buffoon::Hello) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
protobuf: &'a [u8],
out: *mut buffoon::Hello,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{protobuf: protobuf, out: out}: ~Args = transmute(args);
{
~buffoon::load::<buffoon::Hello>(protobuf.to_owned())
}.to_out_ptr(out);
}
}
let args = ~Args{protobuf: protobuf, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_cmd_length<'a>(hello: &'a mut buffoon::Hello,
out: *mut u32) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: &'a mut buffoon::Hello,
out: *mut u32,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{hello: hello, out: out}: ~Args = transmute(args);
{ hello.cmd.len() as u32 }.to_out_ptr(out);
}
}
let args = ~Args{hello: hello, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_cmd_add<'a>(hello: &'a mut buffoon::Hello,
part: &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: &'a mut buffoon::Hello,
part: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{hello: hello, part: part}: ~Args = transmute(args);
{ hello.add_cmd(part.to_owned()) };
}
}
let args = ~Args{hello: hello, part: part,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_get_version<'a>(hello: &'a buffoon::Hello,
out: *mut &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: &'a buffoon::Hello,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{hello: hello, out: out}: ~Args = transmute(args);
{ hello.get_version() }.to_out_ptr(out);
}
}
let args = ~Args{hello: hello, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_get_cmd<'a>(hello: &'a buffoon::Hello,
off: u32, out: *mut &'a str) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: &'a buffoon::Hello,
off: u32,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{hello: hello, off: off, out: out}: ~Args =
transmute(args);
{ hello.cmd[off].as_slice() }.to_out_ptr(out);
}
}
let args = ~Args{hello: hello, off: off, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_hello_serialize_into_new_buffer<'a>(hello:
&'a buffoon::Hello,
out:
*mut ~[u8])
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
hello: &'a buffoon::Hello,
out: *mut ~[u8],
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{hello: hello, out: out}: ~Args = transmute(args);
{ hello.serialize() }.to_out_ptr(out);
}
}
let args = ~Args{hello: hello, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_new<'a>(group: &'a str, description: &'a str,
out: *mut buffoon::Error) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
group: &'a str,
description: &'a str,
out: *mut buffoon::Error,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{group: group, description: description, out: out}:
~Args = transmute(args);
{
~buffoon::Error{group: group.to_owned(),
description: description.to_owned(),
details: None,}
}.to_out_ptr(out);
}
}
let args = ~Args{group: group, description: description, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_free<'a>(error: ~buffoon::Error) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: ~buffoon::Error,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe { let ~Args{error: error}: ~Args = transmute(args); { }; }
}
let args = ~Args{error: error,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_load<'a>(protobuf: &'a [u8],
out: *mut buffoon::Error) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
protobuf: &'a [u8],
out: *mut buffoon::Error,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{protobuf: protobuf, out: out}: ~Args = transmute(args);
{
~buffoon::load::<buffoon::Error>(protobuf.to_owned())
}.to_out_ptr(out);
}
}
let args = ~Args{protobuf: protobuf, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_get_group<'a>(error: &'a buffoon::Error,
out: *mut &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: &'a buffoon::Error,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{error: error, out: out}: ~Args = transmute(args);
{ error.get_group() }.to_out_ptr(out);
}
}
let args = ~Args{error: error, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_get_description<'a>(error:
&'a buffoon::Error,
out: *mut &'a str) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: &'a buffoon::Error,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{error: error, out: out}: ~Args = transmute(args);
{ error.get_description() }.to_out_ptr(out);
}
}
let args = ~Args{error: error, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_get_details<'a>(error: &'a buffoon::Error,
out: *mut &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: &'a buffoon::Error,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{error: error, out: out}: ~Args = transmute(args);
{ error.get_details() }.to_out_ptr(out);
}
}
let args = ~Args{error: error, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_set_details<'a>(error:
&'a mut buffoon::Error,
details: &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: &'a mut buffoon::Error,
details: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{error: error, details: details}: ~Args =
transmute(args);
{ error.set_details(details.to_owned()) };
}
}
let args = ~Args{error: error, details: details,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_error_serialize_into_new_buffer<'a>(error:
&'a buffoon::Error,
out:
*mut ~[u8])
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
error: &'a buffoon::Error,
out: *mut ~[u8],
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{error: error, out: out}: ~Args = transmute(args);
{ error.serialize() }.to_out_ptr(out);
}
}
let args = ~Args{error: error, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_new<'a>(start: u64, uuid: &'a str,
out: *mut Trace) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
start: u64,
uuid: &'a str,
out: *mut Trace,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{start: start, uuid: uuid, out: out}: ~Args =
transmute(args);
{ ~Trace::new(start, uuid.to_owned()) }.to_out_ptr(out);
}
}
let args = ~Args{start: start, uuid: uuid, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_free<'a>(trace: ~Trace) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: ~Trace,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe { let ~Args{trace: trace}: ~Args = transmute(args); { }; }
}
let args = ~Args{trace: trace,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_load<'a>(protobuf: &'a [u8], out: *mut Trace)
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
protobuf: &'a [u8],
out: *mut Trace,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{protobuf: protobuf, out: out}: ~Args = transmute(args);
{
let trace_message: buffoon::Trace =
buffoon::load(protobuf.to_owned());
let mut trace =
~Trace::new(0, trace_message.get_uuid().to_owned());
trace.trace = trace_message;
trace
}.to_out_ptr(out);
}
}
let args = ~Args{protobuf: protobuf, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_name_from_serialized_into_new_buffer<'a>(protobuf:
&'a [u8],
out:
*mut &'a str)
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
protobuf: &'a [u8],
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{protobuf: protobuf, out: out}: ~Args = transmute(args);
{
buffoon::trace::extract_name(protobuf).unwrap()
}.to_out_ptr(out);
}
}
let args = ~Args{protobuf: protobuf, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_get_started_at<'a>(trace: &'a Trace,
out: *mut u64) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a Trace,
out: *mut u64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, out: out}: ~Args = transmute(args);
{ trace.started_at }.to_out_ptr(out);
}
}
let args = ~Args{trace: trace, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_set_name<'a>(trace: &'a mut Trace,
string: &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
string: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, string: string}: ~Args = transmute(args);
{ trace.set_name(string.to_owned()) };
}
}
let args = ~Args{trace: trace, string: string,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_get_name<'a>(trace: &'a Trace,
out: *mut &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a Trace,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, out: out}: ~Args = transmute(args);
{ trace.get_name() }.to_out_ptr(out);
}
}
let args = ~Args{trace: trace, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_get_uuid<'a>(trace: &'a Trace,
out: *mut &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a Trace,
out: *mut &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, out: out}: ~Args = transmute(args);
{ trace.get_uuid() }.to_out_ptr(out);
}
}
let args = ~Args{trace: trace, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_start_span<'a>(trace: &'a mut Trace,
time: u64, category: &'a str,
out: *mut u32) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
time: u64,
category: &'a str,
out: *mut u32,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, time: time, category: category, out: out}:
~Args = transmute(args);
{ trace.start_span(time, category.to_owned()) }.to_out_ptr(out);
}
}
let args = ~Args{trace: trace, time: time, category: category, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_stop_span<'a>(trace: &'a mut Trace,
index: u32, time: u64) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
index: u32,
time: u64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, index: index, time: time}: ~Args =
transmute(args);
{ trace.stop(index, time) };
}
}
let args = ~Args{trace: trace, index: index, time: time,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_span_set_title<'a>(trace: &'a mut Trace,
index: u64,
title: &'a str) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
index: u64,
title: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, index: index, title: title}: ~Args =
transmute(args);
{ trace.span_set_title(index, title.to_owned()) };
}
}
let args = ~Args{trace: trace, index: index, title: title,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_span_set_description<'a>(trace:
&'a mut Trace,
index: u64,
description:
&'a str) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
index: u64,
description: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, index: index, description: description}:
~Args = transmute(args);
{ trace.span_set_description(index, description.to_owned()) };
}
}
let args = ~Args{trace: trace, index: index, description: description,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_serialize_into_new_buffer<'a>(trace:
&'a Trace,
out:
*mut ~[u8])
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a Trace,
out: *mut ~[u8],
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace, out: out}: ~Args = transmute(args);
{ trace.serialize() }.to_out_ptr(out);
}
}
let args = ~Args{trace: trace, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_add_annotation_int<'a>(trace: &'a mut Trace,
span_id: u32,
parent:
Option<&'a u32>,
key: Option<&'a str>,
value: i64) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
span_id: u32,
parent: Option<&'a u32>,
key: Option<&'a str>,
value: i64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value}: ~Args = transmute(args);
{
trace.add_annotation(span_id, parent.map(|x| *x), key,
IntValue(value))
};
}
}
let args =
~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_add_annotation_double<'a>(trace:
&'a mut Trace,
span_id: u32,
parent:
Option<&'a u32>,
key:
Option<&'a str>,
value: f64) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
span_id: u32,
parent: Option<&'a u32>,
key: Option<&'a str>,
value: f64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value}: ~Args = transmute(args);
{
trace.add_annotation(span_id, parent.map(|x| *x), key,
DoubleValue(value))
};
}
}
let args =
~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_add_annotation_string<'a>(trace:
&'a mut Trace,
span_id: u32,
parent:
Option<&'a u32>,
key:
Option<&'a str>,
value: &'a str) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
span_id: u32,
parent: Option<&'a u32>,
key: Option<&'a str>,
value: &'a str,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value}: ~Args = transmute(args);
{
trace.add_annotation(span_id, parent.map(|x| *x), key,
StringValue(value.to_owned()))
};
}
}
let args =
~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
value: value,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_trace_add_annotation_nested<'a>(trace:
&'a mut Trace,
span_id: u32,
parent:
Option<&'a u32>,
key:
Option<&'a str>,
out: *mut u32) ->
bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
trace: &'a mut Trace,
span_id: u32,
parent: Option<&'a u32>,
key: Option<&'a str>,
out: *mut u32,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
out: out}: ~Args = transmute(args);
{
trace.add_annotation(span_id, parent.map(|x| *x), key,
NestedValue) as u32
}.to_out_ptr(out);
}
}
let args =
~Args{trace: trace,
span_id: span_id,
parent: parent,
key: key,
out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_batch_new<'a>(timestamp: u32,
hostname: Option<~str>,
out: *mut Batch) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
timestamp: u32,
hostname: Option<~str>,
out: *mut Batch,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{timestamp: timestamp, hostname: hostname, out: out}:
~Args = transmute(args);
{ ~Batch::new(timestamp, hostname) }.to_out_ptr(out);
}
}
let args = ~Args{timestamp: timestamp, hostname: hostname, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_batch_set_endpoint_count<'a>(batch: &'a mut Batch,
endpoint_name:
&'a str,
count: u64) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
batch: &'a mut Batch,
endpoint_name: &'a str,
count: u64,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{batch: batch,
endpoint_name: endpoint_name,
count: count}: ~Args = transmute(args);
{ batch.set_endpoint_count(endpoint_name.to_owned(), count); };
}
}
let args =
~Args{batch: batch, endpoint_name: endpoint_name, count: count,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_batch_move_in<'a>(batch: &'a mut Batch,
trace: ~[u8]) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
batch: &'a mut Batch,
trace: ~[u8],
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{batch: batch, trace: trace}: ~Args = transmute(args);
{
let name = buffoon::trace::extract_name(trace);
match name {
None => (),
Some(name) => { batch.add(name, trace); }
}
};
}
}
let args = ~Args{batch: batch, trace: trace,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_batch_serialize_into_new_buffer<'a>(batch:
&'a Batch,
out:
*mut ~[u8])
-> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
batch: &'a Batch,
out: *mut ~[u8],
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe {
let ~Args{batch: batch, out: out}: ~Args = transmute(args);
{ batch.serialize() }.to_out_ptr(out);
}
}
let args = ~Args{batch: batch, out: out,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
#[no_mangle]
#[allow(unused_variable)]
pub extern "C" fn skylight_batch_free<'a>(batch: ~Batch) -> bool {
use std::libc::c_void;
use std::cast::transmute;
struct Args<'a> {
batch: ~Batch,
}
extern "C" fn code(args: *c_void, _: *c_void) {
unsafe { let ~Args{batch: batch}: ~Args = transmute(args); { }; }
}
let args = ~Args{batch: batch,};
{
use std::cast::transmute;
use std::rt::local::Local;
use std::rt::task::Task;
if !Local::exists(None::<Task>) {
let task = ~Task::new();
Local::put(task);
}
extern "C" {
fn rust_try(f: extern "C" fn(*c_void, *c_void), code: *c_void,
data: *c_void) -> *libunwind::_Unwind_Exception;
}
unsafe {
let ep = rust_try(code, transmute(args), 0 as *c_void);
if !ep.is_null() {
libunwind::_Unwind_DeleteException(ep);
close_task();
let mut task: ~std::rt::task::Task =
std::rt::local::Local::take();
task.destroyed = true;
false
} else { true }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment