/**
 * @file lv_calendar.c
 *
 */

/*********************
 *      INCLUDES
 *********************/
#include "lv_calendar.h"
#if LV_USE_CALENDAR != 0

#include "../lv_core/lv_debug.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_hal/lv_hal_indev.h"
#include "../lv_misc/lv_utils.h"
#include "../lv_core/lv_indev.h"
#include "../lv_themes/lv_theme.h"
#include <string.h>

/*********************
 *      DEFINES
 *********************/
#define LV_OBJX_NAME "lv_calendar"

/**********************
 *      TYPEDEFS
 **********************/
enum {
    DAY_DRAW_PREV_MONTH,
    DAY_DRAW_ACT_MONTH,
    DAY_DRAW_NEXT_MONTH,
};
typedef uint8_t day_draw_state_t;

/**********************
 *  STATIC PROTOTYPES
 **********************/
static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * param);
static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touched_point);
static lv_coord_t get_header_height(lv_obj_t * calendar);
static lv_coord_t get_day_names_height(lv_obj_t * calendar);
static void draw_header(lv_obj_t * calendar, const lv_area_t * mask);
static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask);
static void draw_days(lv_obj_t * calendar, const lv_area_t * mask);
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day);
static bool is_highlighted(lv_obj_t * calendar, int32_t year, int32_t month, int32_t day);
static const char * get_day_name(lv_obj_t * calendar, uint8_t day);
static const char * get_month_name(lv_obj_t * calendar, int32_t month);
static uint8_t get_month_length(int32_t year, int32_t month);
static uint8_t is_leap_year(uint32_t year);

/**********************
 *  STATIC VARIABLES
 **********************/
static lv_signal_cb_t ancestor_signal;
static lv_design_cb_t ancestor_design;
static const char * day_name[7]    = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"};
static const char * month_name[12] = {"January", "February", "March",     "April",   "May",      "June",
                                      "July",    "August",   "September", "October", "November", "December"};

/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
 **********************/

/**
 * Create a calendar object
 * @param par pointer to an object, it will be the parent of the new calendar
 * @param copy pointer to a calendar object, if not NULL then the new object will be copied from it
 * @return pointer to the created calendar
 */
lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy)
{
    LV_LOG_TRACE("calendar create started");

    /*Create the ancestor of calendar*/
    lv_obj_t * new_calendar = lv_obj_create(par, copy);
    LV_ASSERT_MEM(new_calendar);
    if(new_calendar == NULL) return NULL;

    /*Allocate the calendar type specific extended data*/
    lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t));
    LV_ASSERT_MEM(ext);
    if(ext == NULL) return NULL;
    if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar);
    if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar);

    /*Initialize the allocated 'ext' */
    ext->today.year  = 2018;
    ext->today.month = 1;
    ext->today.day   = 1;

    ext->showed_date.year  = 2018;
    ext->showed_date.month = 1;
    ext->showed_date.day   = 1;

    ext->pressed_date.year  = 0;
    ext->pressed_date.month = 0;
    ext->pressed_date.day   = 0;

    ext->highlighted_dates      = NULL;
    ext->highlighted_dates_num  = 0;
    ext->day_names              = NULL;
    ext->month_names            = NULL;
    ext->style_header           = &lv_style_plain_color;
    ext->style_header_pr        = &lv_style_pretty_color;
    ext->style_highlighted_days = &lv_style_plain_color;
    ext->style_inactive_days    = &lv_style_btn_ina;
    ext->style_week_box         = &lv_style_plain_color;
    ext->style_today_box        = &lv_style_pretty_color;
    ext->style_day_names        = &lv_style_pretty;

    /*The signal and design functions are not copied so set them here*/
    lv_obj_set_signal_cb(new_calendar, lv_calendar_signal);
    lv_obj_set_design_cb(new_calendar, lv_calendar_design);

    /*Init the new calendar calendar*/
    if(copy == NULL) {
        lv_obj_set_size(new_calendar, LV_DPI * 2, LV_DPI * 2);
        lv_obj_set_style(new_calendar, &lv_style_pretty);

        lv_theme_t * th = lv_theme_get_current();
        if(th) {
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS,
                                  th->style.calendar.highlighted_days);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days);
        } else {
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, ext->style_header_pr);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days);
            lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days);
        }
    }
    /*Copy an existing calendar*/
    else {
        lv_calendar_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
        ext->today.year              = copy_ext->today.year;
        ext->today.month             = copy_ext->today.month;
        ext->today.day               = copy_ext->today.day;

        ext->showed_date.year  = copy_ext->showed_date.year;
        ext->showed_date.month = copy_ext->showed_date.month;
        ext->showed_date.day   = copy_ext->showed_date.day;

        ext->highlighted_dates     = copy_ext->highlighted_dates;
        ext->highlighted_dates_num = copy_ext->highlighted_dates_num;
        ext->day_names             = copy_ext->day_names;

        ext->month_names            = copy_ext->month_names;
        ext->style_header           = copy_ext->style_header;
        ext->style_header_pr        = copy_ext->style_header_pr;
        ext->style_highlighted_days = copy_ext->style_highlighted_days;
        ext->style_inactive_days    = copy_ext->style_inactive_days;
        ext->style_week_box         = copy_ext->style_week_box;
        ext->style_today_box        = copy_ext->style_today_box;
        ext->style_day_names        = copy_ext->style_day_names;
        /*Refresh the style with new signal function*/
        lv_obj_refresh_style(new_calendar);
    }

    LV_LOG_INFO("calendar created");

    return new_calendar;
}

/*======================
 * Add/remove functions
 *=====================*/

/*
 * New object specific "add" or "remove" functions come here
 */

/*=====================
 * Setter functions
 *====================*/

/**
 * Set the today's date
 * @param calendar pointer to a calendar object
 * @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value
 * will be saved it can be local variable too.
 */
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
    LV_ASSERT_NULL(today);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    ext->today.year         = today->year;
    ext->today.month        = today->month;
    ext->today.day          = today->day;

    lv_obj_invalidate(calendar);
}

/**
 * Set the currently showed
 * @param calendar pointer to a calendar object
 * @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value
 * will be saved it can be local variable too.
 */
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
    LV_ASSERT_NULL(showed);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    ext->showed_date.year   = showed->year;
    ext->showed_date.month  = showed->month;
    ext->showed_date.day    = showed->day;

    lv_obj_invalidate(calendar);
}

/**
 * Set the the highlighted dates
 * @param calendar pointer to a calendar object
 * @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER
 * WILL BE SAVED! CAN'T BE LOCAL ARRAY.
 * @param date_num number of dates in the array
 */
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t highlighted[], uint16_t date_num)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
    LV_ASSERT_NULL(highlighted);

    lv_calendar_ext_t * ext    = lv_obj_get_ext_attr(calendar);
    ext->highlighted_dates     = highlighted;
    ext->highlighted_dates_num = date_num;

    lv_obj_invalidate(calendar);
}

/**
 * Set the name of the days
 * @param calendar pointer to a calendar object
 * @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon",
 * ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
 * later.
 */
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
    LV_ASSERT_NULL(day_names);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    ext->day_names          = day_names;
    lv_obj_invalidate(calendar);
}

/**
 * Set the name of the month
 * @param calendar pointer to a calendar object
 * @param month_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
 * ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
 * later.
 */
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** month_names)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);
    LV_ASSERT_NULL(month_names);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    ext->month_names        = month_names;
    lv_obj_invalidate(calendar);
}

/**
 * Set a style of a calendar.
 * @param calendar pointer to calendar object
 * @param type which style should be set
 * @param style pointer to a style
 *  */
void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const lv_style_t * style)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);

    switch(type) {
        case LV_CALENDAR_STYLE_BG: lv_obj_set_style(calendar, style); break;
        case LV_CALENDAR_STYLE_DAY_NAMES: ext->style_day_names = style; break;
        case LV_CALENDAR_STYLE_HEADER: ext->style_header = style; break;
        case LV_CALENDAR_STYLE_HEADER_PR: ext->style_header_pr = style; break;
        case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS: ext->style_highlighted_days = style; break;
        case LV_CALENDAR_STYLE_INACTIVE_DAYS: ext->style_inactive_days = style; break;
        case LV_CALENDAR_STYLE_TODAY_BOX: ext->style_today_box = style; break;
        case LV_CALENDAR_STYLE_WEEK_BOX: ext->style_week_box = style; break;
    }

    lv_obj_invalidate(calendar);
}

/*=====================
 * Getter functions
 *====================*/

/**
 * Get the today's date
 * @param calendar pointer to a calendar object
 * @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
 */
lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return &ext->today;
}

/**
 * Get the currently showed
 * @param calendar pointer to a calendar object
 * @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
 */
lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return &ext->showed_date;
}

/**
 * Get the the pressed date.
 * @param calendar pointer to a calendar object
 * @return pointer to an `lv_calendar_date_t` variable containing the pressed date.
 * `NULL` if not date pressed (e.g. the header)
 */
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return ext->pressed_date.year != 0 ? &ext->pressed_date : NULL;
}

/**
 * Get the the highlighted dates
 * @param calendar pointer to a calendar object
 * @return pointer to an `lv_calendar_date_t` array containing the dates.
 */
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return ext->highlighted_dates;
}

/**
 * Get the number of the highlighted dates
 * @param calendar pointer to a calendar object
 * @return number of highlighted days
 */
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return ext->highlighted_dates_num;
}

/**
 * Get the name of the days
 * @param calendar pointer to a calendar object
 * @return pointer to the array of day names
 */
const char ** lv_calendar_get_day_names(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return ext->day_names;
}

/**
 * Get the name of the month
 * @param calendar pointer to a calendar object
 * @return pointer to the array of month names
 */
const char ** lv_calendar_get_month_names(const lv_obj_t * calendar)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    return ext->month_names;
}

/**
 * Get style of a calendar.
 * @param calendar pointer to calendar object
 * @param type which style should be get
 * @return style pointer to the style
 *  */
const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type)
{
    LV_ASSERT_OBJ(calendar, LV_OBJX_NAME);

    const lv_style_t * style = NULL;
    lv_calendar_ext_t * ext  = lv_obj_get_ext_attr(calendar);

    switch(type) {
        case LV_CALENDAR_STYLE_BG: style = lv_obj_get_style(calendar); break;
        case LV_CALENDAR_STYLE_HEADER: style = ext->style_header; break;
        case LV_CALENDAR_STYLE_HEADER_PR: style = ext->style_header_pr; break;
        case LV_CALENDAR_STYLE_DAY_NAMES: style = ext->style_day_names; break;
        case LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS: style = ext->style_highlighted_days; break;
        case LV_CALENDAR_STYLE_INACTIVE_DAYS: style = ext->style_inactive_days; break;
        case LV_CALENDAR_STYLE_WEEK_BOX: style = ext->style_week_box; break;
        case LV_CALENDAR_STYLE_TODAY_BOX: style = ext->style_today_box; break;
        default: style = NULL; break;
    }

    return style;
}

/*=====================
 * Other functions
 *====================*/

/*
 * New object specific "other" functions come here
 */

/**********************
 *   STATIC FUNCTIONS
 **********************/

/**
 * Handle the drawing related tasks of the calendars
 * @param calendar pointer to an object
 * @param mask the object will be drawn only in this area
 * @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
 *                                  (return 'true' if yes)
 *             LV_DESIGN_DRAW: draw the object (always return 'true')
 *             LV_DESIGN_DRAW_POST: drawing after every children are drawn
 * @param return true/false, depends on 'mode'
 */
static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_design_mode_t mode)
{
    /*Return false if the object is not covers the mask_p area*/
    if(mode == LV_DESIGN_COVER_CHK) {
        return ancestor_design(calendar, mask, mode);
    }
    /*Draw the object*/
    else if(mode == LV_DESIGN_DRAW_MAIN) {
        lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
        lv_draw_rect(&calendar->coords, mask, lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG), opa_scale);

        draw_header(calendar, mask);
        draw_day_names(calendar, mask);
        draw_days(calendar, mask);

    }
    /*Post draw when the children are drawn*/
    else if(mode == LV_DESIGN_DRAW_POST) {
    }

    return true;
}

/**
 * Signal function of the calendar
 * @param calendar pointer to a calendar object
 * @param sign a signal type from lv_signal_t enum
 * @param param pointer to a signal specific variable
 * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
 */
static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_signal(calendar, sign, param);
    if(res != LV_RES_OK) return res;
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

    if(sign == LV_SIGNAL_CLEANUP) {
        /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
    } else if(sign == LV_SIGNAL_PRESSING) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        lv_area_t header_area;
        lv_area_copy(&header_area, &calendar->coords);
        header_area.y2 = header_area.y1 + get_header_height(calendar);

        lv_indev_t * indev = lv_indev_get_act();
        lv_point_t p;
        lv_indev_get_point(indev, &p);

        /*If the header is pressed mark an arrow as pressed*/
        if(lv_area_is_point_on(&header_area, &p)) {
            if(p.x < header_area.x1 + lv_area_get_width(&header_area) / 2) {
                if(ext->btn_pressing != -1) lv_obj_invalidate(calendar);
                ext->btn_pressing = -1;
            } else {
                if(ext->btn_pressing != 1) lv_obj_invalidate(calendar);
                ext->btn_pressing = 1;
            }

            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
        /*If a day is pressed save it*/
        else if(calculate_touched_day(calendar, &p)) {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing = 0;
        }
        /*ELse set a deafault state*/
        else {
            if(ext->btn_pressing != 0) lv_obj_invalidate(calendar);
            ext->btn_pressing       = 0;
            ext->pressed_date.year  = 0;
            ext->pressed_date.month = 0;
            ext->pressed_date.day   = 0;
        }
    } else if(sign == LV_SIGNAL_PRESS_LOST) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        ext->btn_pressing       = 0;
        lv_obj_invalidate(calendar);

    } else if(sign == LV_SIGNAL_RELEASED) {
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(ext->btn_pressing < 0) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
        } else if(ext->btn_pressing > 0) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
        } else if(ext->pressed_date.year != 0) {
            res = lv_event_send(calendar, LV_EVENT_VALUE_CHANGED, NULL);
            if(res != LV_RES_OK) return res;
        }

        ext->btn_pressing = 0;
        lv_obj_invalidate(calendar);
    } else if(sign == LV_SIGNAL_CONTROL) {
        uint8_t c               = *((uint8_t *)param);
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
            if(ext->showed_date.month >= 12) {
                ext->showed_date.month = 1;
                ext->showed_date.year++;
            } else {
                ext->showed_date.month++;
            }
            lv_obj_invalidate(calendar);
        } else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
            if(ext->showed_date.month <= 1) {
                ext->showed_date.month = 12;
                ext->showed_date.year--;
            } else {
                ext->showed_date.month--;
            }
            lv_obj_invalidate(calendar);
        }
    }

    return res;
}

/**
 * It will check if the days part of calendar is touched
 * and if it is, it will calculate the day and put it in pressed_date of calendar object.
 * @param calendar pointer to a calendar object
 * @param pointer to a point
 * @return true: days part of calendar is touched and its related date is put in pressed date
 * false: the point is out of days part area.
 */
static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touched_point)
{
    lv_area_t days_area;
    lv_area_copy(&days_area, &calendar->coords);
    const lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG);
    days_area.x1 += style_bg->body.padding.left;
    days_area.x2 -= style_bg->body.padding.right;
    days_area.y1 =
        calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.top;

    if(lv_area_is_point_on(&days_area, touched_point)) {
        lv_coord_t w  = (days_area.x2 - days_area.x1 + 1) / 7;
        lv_coord_t h  = (days_area.y2 - days_area.y1 + 1) / 6;
        uint8_t x_pos = 0;
        x_pos         = (touched_point->x - days_area.x1) / w;
        if(x_pos > 6) x_pos = 6;
        uint8_t y_pos = 0;
        y_pos         = (touched_point->y - days_area.y1) / h;
        if(y_pos > 5) y_pos = 5;

        uint8_t i_pos           = 0;
        i_pos                   = (y_pos * 7) + x_pos;
        lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
        if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) {
            ext->pressed_date.year  = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0);
            ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1);
            ext->pressed_date.day   = get_month_length(ext->pressed_date.year, ext->pressed_date.month) -
                                    get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos;
        } else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) +
                           get_month_length(ext->showed_date.year, ext->showed_date.month))) {
            ext->pressed_date.year  = ext->showed_date.year;
            ext->pressed_date.month = ext->showed_date.month;
            ext->pressed_date.day   = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
        } else if(i_pos < 42) {
            ext->pressed_date.year  = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0);
            ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1);
            ext->pressed_date.day   = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) -
                                    get_month_length(ext->showed_date.year, ext->showed_date.month);
        }
        return true;
    } else {
        return false;
    }
}

/**
 * Get the height of a calendar's header based on it's style
 * @param calendar point to a calendar
 * @return the header's height
 */
static lv_coord_t get_header_height(lv_obj_t * calendar)
{
    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);

    return lv_font_get_line_height(ext->style_header->text.font) + ext->style_header->body.padding.top +
           ext->style_header->body.padding.bottom;
}

/**
 * Get the height of a calendar's day_names based on it's style
 * @param calendar point to a calendar
 * @return the day_names's height
 */
static lv_coord_t get_day_names_height(lv_obj_t * calendar)
{
    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);

    return lv_font_get_line_height(ext->style_day_names->text.font) + ext->style_day_names->body.padding.top +
           ext->style_day_names->body.padding.bottom;
}

/**
 * Draw the calendar header with month name and arrows
 * @param calendar point to a calendar
 * @param mask a mask for drawing
 */
static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
{
    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);

    lv_bidi_dir_t bidi_dir = lv_obj_get_base_dir(calendar);

    lv_opa_t opa_scale      = lv_obj_get_opa_scale(calendar);

    lv_area_t header_area;
    header_area.x1 = calendar->coords.x1;
    header_area.x2 = calendar->coords.x2;
    header_area.y1 = calendar->coords.y1;
    header_area.y2 = calendar->coords.y1 + get_header_height(calendar);

    lv_draw_rect(&header_area, mask, ext->style_header, opa_scale);

    /*Add the year + month name*/
    char txt_buf[64];
    lv_utils_num_to_str(ext->showed_date.year, txt_buf);
    txt_buf[4] = ' ';
    txt_buf[5] = '\0';
    strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
    header_area.y1 += ext->style_header->body.padding.top;
    lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, NULL, NULL, NULL, bidi_dir);

    /*Add the left arrow*/
    const lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header;
    header_area.x1 += ext->style_header->body.padding.left;
    lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, NULL, NULL, NULL, bidi_dir);

    /*Add the right arrow*/
    arrow_style    = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header;
    header_area.x1 = header_area.x2 - ext->style_header->body.padding.right -
                     lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), arrow_style->text.font,
                                      arrow_style->text.line_space, LV_TXT_FLAG_NONE);
    lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL, NULL, NULL, bidi_dir);
}

/**
 * Draw the day's name below the header
 * @param calendar point to a calendar
 * @param mask a mask for drawing
 */
static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask)
{
    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    lv_bidi_dir_t bidi_dir = lv_obj_get_base_dir(calendar);
    lv_opa_t opa_scale      = lv_obj_get_opa_scale(calendar);

    lv_coord_t l_pad = ext->style_day_names->body.padding.left;
    lv_coord_t w =
        lv_obj_get_width(calendar) - ext->style_day_names->body.padding.left - ext->style_day_names->body.padding.right;
    lv_coord_t box_w = w / 7;
    lv_area_t label_area;
    label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top;
    label_area.y2 = label_area.y1 + lv_font_get_line_height(ext->style_day_names->text.font);
    uint32_t i;
    for(i = 0; i < 7; i++) {
        label_area.x1 = calendar->coords.x1 + (w * i) / 7 + l_pad;
        label_area.x2 = label_area.x1 + box_w - 1;
        lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i), LV_TXT_FLAG_CENTER,
                      NULL, NULL, NULL, bidi_dir);
    }
}

/**
 * Draw the date numbers in a matrix
 * @param calendar point to a calendar
 * @param mask a mask for drawing
 */
static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
{
    lv_calendar_ext_t * ext     = lv_obj_get_ext_attr(calendar);
    lv_bidi_dir_t bidi_dir = lv_obj_get_base_dir(calendar);
    const lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG);
    lv_area_t label_area;
    lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
    label_area.y1      = calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top +
                    lv_font_get_line_height(ext->style_day_names->text.font) +
                    ext->style_day_names->body.padding.bottom;
    label_area.y2 = label_area.y1 + lv_font_get_line_height(style_bg->text.font);

    lv_coord_t w          = lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right;
    lv_coord_t h          = calendar->coords.y2 - label_area.y1 - style_bg->body.padding.bottom;
    lv_coord_t box_w      = w / 7;
    lv_coord_t vert_space = (h - (6 * lv_font_get_line_height(style_bg->text.font))) / 5;

    uint32_t week;
    uint8_t day_cnt;
    uint8_t month_start_day = get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1);
    day_draw_state_t draw_state; /*true: Not the prev. or next month is drawn*/
    const lv_style_t * act_style;

    /*If starting with the first day of the week then the previous month is not visible*/
    if(month_start_day == 0) {
        day_cnt    = 1;
        draw_state = DAY_DRAW_ACT_MONTH;
        act_style  = style_bg;
    } else {
        draw_state = DAY_DRAW_PREV_MONTH;
        day_cnt = get_month_length(ext->showed_date.year, ext->showed_date.month - 1); /*Length of the previous month*/
        day_cnt -= month_start_day - 1; /*First visible number of the previous month*/
        act_style = ext->style_inactive_days;
    }

    bool month_of_today_shown = false;
    if(ext->showed_date.year == ext->today.year && ext->showed_date.month == ext->today.month) {
        month_of_today_shown = true;
    }

    char buf[3];
    bool in_week_box = false;

    /*Draw 6 weeks*/
    for(week = 0; week < 6; week++) {

        /*Draw the "week box"*/
        if(month_of_today_shown &&
           ((draw_state == DAY_DRAW_ACT_MONTH && ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) ||
            (draw_state == DAY_DRAW_PREV_MONTH && ext->today.day <= 7 - month_start_day && week == 0))) {
            lv_area_t week_box_area;
            lv_area_copy(&week_box_area, &label_area); /*'label_area' is already set for this row*/
            week_box_area.x1 =
                calendar->coords.x1 + style_bg->body.padding.left - ext->style_week_box->body.padding.left;
            week_box_area.x2 =
                calendar->coords.x2 - style_bg->body.padding.right + ext->style_week_box->body.padding.right;

            week_box_area.y1 -= ext->style_week_box->body.padding.top;
            week_box_area.y2 += ext->style_week_box->body.padding.bottom;
            lv_draw_rect(&week_box_area, mask, ext->style_week_box, opa_scale);

            in_week_box = true;
        } else {
            in_week_box = false;
        }

        /*Draw the 7 days of a week*/
        uint32_t day;
        for(day = 0; day < 7; day++) {
            /*The previous month is over*/
            if(draw_state == DAY_DRAW_PREV_MONTH && day == month_start_day) {
                draw_state = DAY_DRAW_ACT_MONTH;
                day_cnt    = 1;
                act_style  = style_bg;
            }
            /*The current month is over*/
            if(draw_state == DAY_DRAW_ACT_MONTH &&
               day_cnt > get_month_length(ext->showed_date.year, ext->showed_date.month)) {
                draw_state = DAY_DRAW_NEXT_MONTH;
                day_cnt    = 1;
                act_style  = ext->style_inactive_days;
            }

            label_area.x1 =
                calendar->coords.x1 + (w * day) / 7 + style_bg->body.padding.left;
            label_area.x2 = label_area.x1 + box_w - 1;

            /*Draw the "today box"*/
            if(draw_state == DAY_DRAW_ACT_MONTH && month_of_today_shown && ext->today.day == day_cnt) {
                lv_area_t today_box_area;
                lv_area_copy(&today_box_area, &label_area);
                today_box_area.x1 = label_area.x1;
                today_box_area.x2 = label_area.x2;

                today_box_area.y1 = label_area.y1 - ext->style_today_box->body.padding.top;
                today_box_area.y2 = label_area.y2 + ext->style_today_box->body.padding.bottom;
                lv_draw_rect(&today_box_area, mask, ext->style_today_box, opa_scale);
            }

            /*Get the final style : highlighted/week box/today box/normal*/
            const lv_style_t * final_style;
            if(draw_state == DAY_DRAW_PREV_MONTH &&
               is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0),
                              ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1, day_cnt)) {
                final_style = ext->style_highlighted_days;
            } else if(draw_state == DAY_DRAW_ACT_MONTH &&
                      is_highlighted(calendar, ext->showed_date.year, ext->showed_date.month, day_cnt)) {
                final_style = ext->style_highlighted_days;
            } else if(draw_state == DAY_DRAW_NEXT_MONTH &&
                      is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0),
                                     ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1, day_cnt)) {
                final_style = ext->style_highlighted_days;
            } else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH)
                final_style = ext->style_today_box;
            else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH)
                final_style = ext->style_week_box;
            else
                final_style = act_style;

            /*Write the day's number*/
            lv_utils_num_to_str(day_cnt, buf);
            lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, NULL, NULL, bidi_dir);

            /*Go to the next day*/
            day_cnt++;
        }

        /*Got to the next weeks row*/
        label_area.y1 += vert_space + lv_font_get_line_height(style_bg->text.font);
        label_area.y2 += vert_space + lv_font_get_line_height(style_bg->text.font);
    }
}

/**
 * Check weather a date is highlighted or not
 * @param calendar pointer to a calendar object
 * @param year a year
 * @param month a  month [1..12]
 * @param day a day [1..31]
 * @return true: highlighted
 */
static bool is_highlighted(lv_obj_t * calendar, int32_t year, int32_t month, int32_t day)
{
    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);

    if(ext->highlighted_dates == NULL || ext->highlighted_dates_num == 0) return false;

    uint32_t i;
    for(i = 0; i < ext->highlighted_dates_num; i++) {
        if(ext->highlighted_dates[i].year == year && ext->highlighted_dates[i].month == month &&
           ext->highlighted_dates[i].day == day) {
            return true;
        }
    }

    return false;
}

/**
 * Get the day name
 * @param calendar pointer to a calendar object
 * @param day a day in [0..6]
 * @return
 */
static const char * get_day_name(lv_obj_t * calendar, uint8_t day)
{

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    if(ext->day_names)
        return ext->day_names[day];
    else
        return day_name[day];
}

/**
 * Get the month name
 * @param calendar pointer to a calendar object
 * @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle
 * previous year
 * @return
 */
static const char * get_month_name(lv_obj_t * calendar, int32_t month)
{
    month--; /*Range of months id [1..12] but range of indexes is [0..11]*/
    if(month < 0) month = 12 + month;

    lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
    if(ext->month_names)
        return ext->month_names[month];
    else
        return month_name[month];
}

/**
 * Get the number of days in a month
 * @param year a year
 * @param month a month. The range is basically [1..12] but [-11..1] is also supported to handle
 * previous year
 * @return [28..31]
 */
static uint8_t get_month_length(int32_t year, int32_t month)
{
    month--; /*Range of months id [1..12] but range of indexes is [0..11]*/
    if(month < 0) {
        year--;             /*Already in the previous year (won't be less then -12 to skip a whole year)*/
        month = 12 + month; /*`month` is negative, the result will be < 12*/
    }
    if(month >= 12) {
        year++;
        month -= 12;
    }

    /*month == 1 is february*/
    return (month == 1) ? (28 + is_leap_year(year)) : 31 - month % 7 % 2;
}

/**
 * Tells whether a year is leap year or not
 * @param year a year
 * @return 0: not leap year; 1: leap year
 */
static uint8_t is_leap_year(uint32_t year)
{
    return (year % 4) || ((year % 100 == 0) && (year % 400)) ? 0 : 1;
}

/**
 * Get the day of the week
 * @param year a year
 * @param month a  month
 * @param day a day
 * @return [0..6] which means [Sun..Sat]
 */
static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
{
    uint32_t a = month < 3 ? 1 : 0;
    uint32_t b = year - a;

    uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7;

    return day_of_week;
}

#endif


<?php
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\Util;

use PHPUnit\Framework\TestCase;

class RegularExpressionTest extends TestCase
{
    public function validRegexpProvider()
    {
        return [
          ['#valid regexp#', 'valid regexp', 1],
          [';val.*xp;', 'valid regexp', 1],
          ['/val.*xp/i', 'VALID REGEXP', 1],
          ['/a val.*p/','valid regexp', 0],
        ];
    }

    public function invalidRegexpProvider()
    {
        return [
          ['valid regexp', 'valid regexp'],
          [';val.*xp', 'valid regexp'],
          ['val.*xp/i', 'VALID REGEXP'],
        ];
    }

    /**
     * @dataProvider validRegexpProvider
     */
    public function testValidRegex($pattern, $subject, $return)
    {
        $this->assertEquals($return, RegularExpression::safeMatch($pattern, $subject));
    }

    /**
     * @dataProvider invalidRegexpProvider
     */
    public function testInvalidRegex($pattern, $subject)
    {
        $this->assertFalse(RegularExpression::safeMatch($pattern, $subject));
    }
}


#!/usr/bin/env bash

rm -f ~/.sdim/use_cand_as_comp=false
touch ~/.sdim/use_cand_as_comp=true
echo check_env | nc localhost 31415


.so man3/cacosh.3


ace.define("ace/snippets/matlab",["require","exports","module"], function(require, exports, module) {
"use strict";

exports.snippetText =undefined;
exports.scope = "matlab";

});


{ defer } = require('lodash')

{ react, lift, link, signal, signals } = require("../../core/modules/dataflow")
{ stringify } = require('../../core/modules/prelude')

module.exports = (_, _go) ->
  _key = signal ''
  _rows = signal 10000
  _columns = signal 100
  _seed = signal 7595850248774471522
  _seed_for_column_types = signal -1
  _randomize = signal yes
  _value = signal 0
  _realRange = signal 100
  _categoricalFraction = signal 0.1
  _factors = signal 5
  _integerFraction = signal 0.5
  _binaryFraction = signal 0.1
  _binaryOnesFraction = signal 0.02
  _timeFraction = signal 0
  _stringFraction = signal 0
  _integerRange = signal 1
  _missingFraction = signal 0.01
  _responseFactors = signal 2
  _hasResponse = signal no

  createFrame = ->
    opts =
      dest: _key()
      rows: _rows()
      cols: _columns()
      seed: _seed()
      seed_for_column_types: _seed_for_column_types()
      randomize: _randomize()
      value: _value()
      real_range: _realRange()
      categorical_fraction: _categoricalFraction()
      factors: _factors()
      integer_fraction: _integerFraction()
      binary_fraction: _binaryFraction()
      binary_ones_fraction: _binaryOnesFraction()
      time_fraction: _timeFraction()
      string_fraction: _stringFraction()
      integer_range: _integerRange()
      missing_fraction: _missingFraction()
      response_factors: _responseFactors()
      has_response: _hasResponse()

    _.insertAndExecuteCell 'cs', "createFrame #{stringify opts}"

  defer _go

  key: _key
  rows: _rows
  columns: _columns
  seed: _seed
  seed_for_column_types: _seed_for_column_types
  randomize: _randomize
  value: _value
  realRange: _realRange
  categoricalFraction: _categoricalFraction
  factors: _factors
  integerFraction: _integerFraction
  binaryFraction: _binaryFraction
  binaryOnesFraction: _binaryOnesFraction
  timeFraction: _timeFraction
  stringFraction: _stringFraction
  integerRange: _integerRange
  missingFraction: _missingFraction
  responseFactors: _responseFactors
  hasResponse: _hasResponse
  createFrame: createFrame
  template: 'flow-create-frame-input'


Total cross sectional area (XSA): 4.0921
Total rotated (x=0) volume (VOL): 44.1212

Distance to boundary WRT dA / XSA = 0.345476
Distance to boundary WRT dA / VOL = 0.0320418
Distance to boundary WRT dV / XSA = 3.60131
Distance to boundary WRT dV / VOL = 0.33401
Distance to origin   WRT dA       = 9.8225

NOTE -- additional calculations are available if
        a density plot is selected for this query.

Eulerian for domain 0 is 1

u -- Min = -1 (node 946 at coord <-0.444246, 4.22672>)
u -- Max = 1 (node 931 at coord <4.22672, 0.444246>)

The total RevolvedVolume is 449.134 cm^3
The total Surface Area is 27.1095 cm^2
The actual number of nodes is 1053.
The number of ghost nodes is 218.
The actual number of zones is 988.
The number of ghost zones is 212.

MinMax Actual:
vel -- Min = 1 (node 270 at coord <-1.73974, 1.93218>)
vel -- Max = 1 (node 1151 at coord <4.36218, 1.94217>)

MinMax Original:
vel -- Min = 1 (node 270 at coord <-1.73974, 1.93218>)
vel -- Max = 1 (node 1151 at coord <4.36218, 1.94217>)


/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.gameservices.v1beta.model;

/**
 * The game server cluster changes made by the game server deployment.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Game Services API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class DeployedClusterState extends com.google.api.client.json.GenericJson {

  /**
   * The name of the cluster.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String cluster;

  /**
   * The details about the Agones fleets and autoscalers created in the game server cluster.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.util.List<DeployedFleetDetails> fleetDetails;

  /**
   * The name of the cluster.
   * @return value or {@code null} for none
   */
  public java.lang.String getCluster() {
    return cluster;
  }

  /**
   * The name of the cluster.
   * @param cluster cluster or {@code null} for none
   */
  public DeployedClusterState setCluster(java.lang.String cluster) {
    this.cluster = cluster;
    return this;
  }

  /**
   * The details about the Agones fleets and autoscalers created in the game server cluster.
   * @return value or {@code null} for none
   */
  public java.util.List<DeployedFleetDetails> getFleetDetails() {
    return fleetDetails;
  }

  /**
   * The details about the Agones fleets and autoscalers created in the game server cluster.
   * @param fleetDetails fleetDetails or {@code null} for none
   */
  public DeployedClusterState setFleetDetails(java.util.List<DeployedFleetDetails> fleetDetails) {
    this.fleetDetails = fleetDetails;
    return this;
  }

  @Override
  public DeployedClusterState set(String fieldName, Object value) {
    return (DeployedClusterState) super.set(fieldName, value);
  }

  @Override
  public DeployedClusterState clone() {
    return (DeployedClusterState) super.clone();
  }

}


/*
 * Copyright (c) 2017, GoMint, BlackyPaw and geNAZt
 *
 * This code is licensed under the BSD license found in the
 * LICENSE file in the root directory of this source tree.
 */

package io.gomint.inventory;

/**
 * @author geNAZt
 * @version 1.0
 * @stability 2
 */
public enum InventoryType {

    PLAYER,
    ARMOR,
    CRAFTING,
    CONTAINER,
    CREATIVE,
    CURSOR,
    OFFHAND

}


package de.neuland.jade4j.template;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import de.neuland.jade4j.helper.beans.IterableMap;
import org.junit.Test;

import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.TestFileHelper;
import de.neuland.jade4j.exceptions.JadeCompilerException;
import de.neuland.jade4j.model.JadeModel;

public class JadeRunFullTemplateTest {

    private JadeConfiguration cfg = new JadeConfiguration();

    @Test
    public void testFullRun() throws IOException {

        Map<String, Object> root = new HashMap<String, Object>();
        root.put("hello", "world");
        root.put("hallo", null);
        JadeModel model = new JadeModel(root);

        JadeTemplate temp = cfg.getTemplate(getResourcePath("fullrun"));

        StringWriter out = new StringWriter();
        try {
            temp.process(model, out);
        } catch (JadeCompilerException e) {
            e.printStackTrace();
            fail();
        }
        out.flush();
        assertEquals("

Hi everybody

", out.toString());

    }

    @Test
    public void testEachLoopWithIterableMap() throws Exception {

        IterableMap users = new IterableMap();
        users.put("bob", "Robert Smith");
        users.put("alex", "Alex Supertramp");

        Map<String, Object> root = new HashMap<String, Object>();
        root.put("users", users);
        JadeModel model = new JadeModel(root);

        JadeTemplate temp = cfg.getTemplate(getResourcePath("each_loop"));

        StringWriter out = new StringWriter();
        try {
            temp.process(model, out);
        } catch (JadeCompilerException e) {
            e.printStackTrace();
            fail();
        }
        out.flush();
        assertEquals("

Robert Smith

Alex Supertramp

", out.toString());

    }

    public String getResourcePath(String fileName) {
        try {
            return TestFileHelper.getRootResourcePath() + "/template/" + fileName;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}


<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Application Name
    |--------------------------------------------------------------------------
    |
    | This value is the name of your application. This value is used when the
    | framework needs to place the application's name in a notification or
    | any other location as required by the application or its packages.
    */
    'name' => 'My Application',

    /*
   |--------------------------------------------------------------------------
   | Application cache
   |--------------------------------------------------------------------------
   | Set this to true to use the cache decorators, this will greatly improve
   | the application speed and performance
   */
    'cache' => env('APP_CACHE', false),

    /*
    |--------------------------------------------------------------------------
    | Application Environment
    |--------------------------------------------------------------------------
    |
    | This value determines the "environment" your application is currently
    | running in. This may determine how you prefer to configure various
    | services your application utilizes. Set this in your ".env" file.
    |
    */

    'env' => env('APP_ENV', 'production'),

    /*
    |--------------------------------------------------------------------------
    | Application Debug Mode
    |--------------------------------------------------------------------------
    |
    | When your application is in debug mode, detailed error messages with
    | stack traces will be shown on every error that occurs within your
    | application. If disabled, a simple generic error page is shown.
    |
    */

    'debug' => env('APP_DEBUG', false),

    /*
    |--------------------------------------------------------------------------
    | Application URL
    |--------------------------------------------------------------------------
    |
    | This URL is used by the console to properly generate URLs when using
    | the Artisan command line tool. You should set this to the root of
    | your application so that it is used when running Artisan tasks.
    |
    */

    'url' => env('APP_URL', 'http://localhost'),

    /*
    |--------------------------------------------------------------------------
    | Allow static translations to be editable via GUI
    |--------------------------------------------------------------------------
    | Enabling this will have slight performance hit,
    | about 20 to 50ms page load time increase.
    */
    'translations-gui' => true,

    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'UTC',

    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */

    'locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Application Fallback Locale
    |--------------------------------------------------------------------------
    |
    | The fallback locale determines the locale to use when the current one
    | is not available. You may change the value to correspond to any of
    | the language folders that are provided through your application.
    |
    */

    'fallback_locale' => 'en',

    /*
    |--------------------------------------------------------------------------
    | Encryption Key
    |--------------------------------------------------------------------------
    |
    | This key is used by the Illuminate encrypter service and should be set
    | to a random, 32 character string, otherwise these encrypted strings
    | will not be safe. Please do this before deploying an application!
    |
    */

    'key' => env('APP_KEY'),

    'cipher' => 'AES-256-CBC',

    /*
    |--------------------------------------------------------------------------
    | Logging Configuration
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log settings for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Settings: "single", "daily", "syslog", "errorlog"
    |
    */
    'log' => env('APP_LOG', 'single'),
    'log_level' => env('APP_LOG_LEVEL', 'debug'),

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        Laravel\Tinker\TinkerServiceProvider::class,

        Modules\Core\Providers\AsgardServiceProvider::class,

        App\Providers\RouteServiceProvider::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        'Blade' => Illuminate\Support\Facades\Blade::class,
        'Cache' => Illuminate\Support\Facades\Cache::class,
        'Config' => Illuminate\Support\Facades\Config::class,
        'Cookie' => Illuminate\Support\Facades\Cookie::class,
        'Crypt' => Illuminate\Support\Facades\Crypt::class,
        'DB' => Illuminate\Support\Facades\DB::class,
        'Eloquent' => Illuminate\Database\Eloquent\Model::class,
        'Event' => Illuminate\Support\Facades\Event::class,
        'File' => Illuminate\Support\Facades\File::class,
        'Gate' => Illuminate\Support\Facades\Gate::class,
        'Hash' => Illuminate\Support\Facades\Hash::class,
        'Lang' => Illuminate\Support\Facades\Lang::class,
        'Log' => Illuminate\Support\Facades\Log::class,
        'Mail' => Illuminate\Support\Facades\Mail::class,
        'Password' => Illuminate\Support\Facades\Password::class,
        'Queue' => Illuminate\Support\Facades\Queue::class,
        'Redirect' => Illuminate\Support\Facades\Redirect::class,
        'Redis' => Illuminate\Support\Facades\Redis::class,
        'Request' => Illuminate\Support\Facades\Request::class,
        'Response' => Illuminate\Support\Facades\Response::class,
        'Route' => Illuminate\Support\Facades\Route::class,
        'Schema' => Illuminate\Support\Facades\Schema::class,
        'Session' => Illuminate\Support\Facades\Session::class,
        'Storage' => Illuminate\Support\Facades\Storage::class,
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,
        'Notification' => Illuminate\Support\Facades\Notification::class,
    ],

];


/**
 * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */

CKEDITOR.plugins.setLang( 'button', 'zh-cn', {
	selectedLabel: '已选中 %1 项'
} );


Physical Destruction of Device or Component

An adversary conducts a physical attack a device or component, destroying it such that it no longer functions as intended.


; RUN: opt -early-cse -S < %s | FileCheck %s
; RUN: opt -basicaa -early-cse-memssa -S < %s | FileCheck %s
; Same as GVN/edge.ll, but updated to reflect EarlyCSE's less powerful
; implementation.  EarlyCSE currently doesn't exploit equality comparisons
; against constants.

define i32 @f1(i32 %x) {
  ; CHECK-LABEL: define i32 @f1(
bb0:
  %cmp = icmp eq i32 %x, 0
  br i1 %cmp, label %bb2, label %bb1
bb1:
  br label %bb2
bb2:
  %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
  %foo = add i32 %cond, %x
  ret i32 %foo
  ; CHECK: bb2:
  ; CHECK: %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
}

define i32 @f2(i32 %x) {
  ; CHECK-LABEL: define i32 @f2(
bb0:
  %cmp = icmp ne i32 %x, 0
  br i1 %cmp, label %bb1, label %bb2
bb1:
  br label %bb2
bb2:
  %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
  %foo = add i32 %cond, %x
  ret i32 %foo
  ; CHECK: bb2:
  ; CHECK: %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
}

define i32 @f3(i32 %x) {
  ; CHECK-LABEL: define i32 @f3(
bb0:
  switch i32 %x, label %bb1 [ i32 0, label %bb2]
bb1:
  br label %bb2
bb2:
  %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
  %foo = add i32 %cond, %x
  ret i32 %foo
  ; CHECK: bb2:
  ; CHECK: %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ]
}

declare void @g(i1)
define void @f4(i8 * %x)  {
; CHECK-LABEL: define void @f4(
bb0:
  %y = icmp eq i8* null, %x
  br i1 %y, label %bb2, label %bb1
bb1:
  br label %bb2
bb2:
  %zed = icmp eq i8* null, %x
  call void @g(i1 %zed)
; CHECK: call void @g(i1 %y)
  ret void
}

define double @fcmp_oeq_not_zero(double %x, double %y) {
entry:
  %cmp = fcmp oeq double %y, 2.0
  br i1 %cmp, label %if, label %return

if:
  %div = fdiv double %x, %y
  br label %return

return:
  %retval = phi double [ %div, %if ], [ %x, %entry ]
  ret double %retval

; CHECK-LABEL: define double @fcmp_oeq_not_zero(
; CHECK: %div = fdiv double %x, %y
}

define double @fcmp_une_not_zero(double %x, double %y) {
entry:
  %cmp = fcmp une double %y, 2.0
  br i1 %cmp, label %return, label %else

else:
  %div = fdiv double %x, %y
  br label %return

return:
  %retval = phi double [ %div, %else ], [ %x, %entry ]
  ret double %retval

; CHECK-LABEL: define double @fcmp_une_not_zero(
; CHECK: %div = fdiv double %x, %y
}

; PR22376 - We can't propagate zero constants because -0.0
; compares equal to 0.0. If %y is -0.0 in this test case,
; we would produce the wrong sign on the infinity return value.
define double @fcmp_oeq_zero(double %x, double %y) {
entry:
  %cmp = fcmp oeq double %y, 0.0
  br i1 %cmp, label %if, label %return

if:
  %div = fdiv double %x, %y
  br label %return

return:
  %retval = phi double [ %div, %if ], [ %x, %entry ]
  ret double %retval

; CHECK-LABEL: define double @fcmp_oeq_zero(
; CHECK: %div = fdiv double %x, %y
}

define double @fcmp_une_zero(double %x, double %y) {
entry:
  %cmp = fcmp une double %y, -0.0
  br i1 %cmp, label %return, label %else

else:
  %div = fdiv double %x, %y
  br label %return

return:
  %retval = phi double [ %div, %else ], [ %x, %entry ]
  ret double %retval

; CHECK-LABEL: define double @fcmp_une_zero(
; CHECK: %div = fdiv double %x, %y
}

; We also cannot propagate a value if it's not a constant.
; This is because the value could be 0.0 or -0.0.

define double @fcmp_oeq_maybe_zero(double %x, double %y, double %z1, double %z2) {
entry:
 %z = fadd double %z1, %z2
 %cmp = fcmp oeq double %y, %z
 br i1 %cmp, label %if, label %return

if:
 %div = fdiv double %x, %z
 br label %return

return:
 %retval = phi double [ %div, %if ], [ %x, %entry ]
 ret double %retval

; CHECK-LABEL: define double @fcmp_oeq_maybe_zero(
; CHECK: %div = fdiv double %x, %z
}

define double @fcmp_une_maybe_zero(double %x, double %y, double %z1, double %z2) {
entry:
 %z = fadd double %z1, %z2
 %cmp = fcmp une double %y, %z
 br i1 %cmp, label %return, label %else

else:
 %div = fdiv double %x, %z
 br label %return

return:
 %retval = phi double [ %div, %else ], [ %x, %entry ]
 ret double %retval

; CHECK-LABEL: define double @fcmp_une_maybe_zero(
; CHECK: %div = fdiv double %x, %z
}


/*
 * Copyright (C) 2013 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"
#include "DFGFlushedAt.h"

#if ENABLE(DFG_JIT)

#include "JSCInlines.h"

namespace JSC { namespace DFG {

void FlushedAt::dump(PrintStream& out) const
{
    if (m_format == DeadFlush || m_format == ConflictingFlush)
        out.print(m_format);
    else if (m_virtualRegister.isValid())
        out.print(m_virtualRegister, ":", m_format);
    else
        out.print(m_format);
}

void FlushedAt::dumpInContext(PrintStream& out, DumpContext*) const
{
    dump(out);
}

} } // namespace JSC::DFG

#endif // ENABLE(DFG_JIT)


//
// Copyright 2012 Hakan Kjellerstrand
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Google.OrTools.LinearSolver;

public class Volsay2
{

  /**
   *
   * Volsay problem.
   *
   * From the OPL model volsay.mod.
   *
   *
   *
   * Also see
   *  http://www.hakank.org/or-tools/volsay.cs
   *  http://www.hakank.org/or-tools/volsay2.py
   *
   */
  private static void Solve()
  {

    Solver solver = new Solver("Volsay2",
                               Solver.CLP_LINEAR_PROGRAMMING);

    int num_products = 2;
    IEnumerable<int> PRODUCTS = Enumerable.Range(0, num_products);
    int Gas = 0;
    int Chloride = 1;
    String[] products = {"Gas", "Chloride"};

    //
    // Variables
    //
    Variable[] production = new Variable[num_products];
    foreach(int p in PRODUCTS) {
      production[p] = solver.MakeNumVar(0, 100000, products[p]);
    }

    int num_constraints = 2;
    IEnumerable<int> CONSTRAINTS = Enumerable.Range(0, num_constraints);
    Constraint[] cons = new Constraint[num_constraints];
    cons[0] = solver.Add(production[Gas] + production[Chloride] <= 50);
    cons[1] = solver.Add(3 * production[Gas] + 4 * production[Chloride] <= 180);

    solver.Maximize(40 * production[Gas] + 50 * production[Chloride]);

    Console.WriteLine("NumConstraints: {0}", solver.NumConstraints());

    int resultStatus = solver.Solve();

    if (resultStatus != Solver.OPTIMAL) {
      Console.WriteLine("The problem don't have an optimal solution.");
      return;
    }

    foreach(int p in PRODUCTS) {
      Console.WriteLine("{0,-10}: {1} ReducedCost: {2}",
                        products[p],
                        production[p].SolutionValue(),
                        production[p].ReducedCost());
    }

    foreach(int c in CONSTRAINTS) {
      Console.WriteLine("Constraint {0} DualValue {1} Activity: {2} lb: {3} ub: {4}",
                        c.ToString(),
                        cons[c].DualValue(),
                        cons[c].Activity(),
                        cons[c].Lb(),
                        cons[c].Ub()
                        );
    }

    Console.WriteLine("\nWallTime: " + solver.WallTime());
    Console.WriteLine("Iterations: " + solver.Iterations());

  }

  public static void Main(String[] args)
  {
    Solve();
  }
}


<?php

/*
 *
 *  ____            _        _   __  __ _                  __  __ ____
 * |  _ \ ___   ___| | _____| |_|  \/  (_)_ __   ___      |  \/  |  _ \
 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
 * |  __/ (_) | (__|   <  __/ |_| |  | | | | | |  __/_____| |  | |  __/
 * |_|   \___/ \___|_|\_\___|\__|_|  |_|_|_| |_|\___|     |_|  |_|_|
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * @author PocketMine Team
 * @link http://www.pocketmine.net/
 *
 *
*/

namespace pocketmine\network\protocol;

#include <rules/DataPacket.h>

class SetTimePacket extends DataPacket{
	const NETWORK_ID = Info::SET_TIME_PACKET;

	public $time;
	public $started = true;

	public function decode(){

	}

	public function encode(){
		$this->reset();
		$this->putInt($this->time);
		$this->putByte($this->started ? 1 : 0);
	}

}


import { writeFileSync } from 'fs';
import {
  addSyntheticLeadingComment,
  ArrayLiteralExpression,
  ClassElement,
  ClassExpression,
  createArrayLiteral,
  createAssignment,
  createBindingElement,
  createBlock,
  createCall,
  createClassExpression,
  createExpressionStatement,
  createFunctionDeclaration,
  createFunctionExpression,
  createIdentifier,
  createImportClause,
  createImportDeclaration,
  createImportSpecifier,
  createLiteral,
  createMethod,
  createModifier,
  createNamedImports,
  createNew,
  createObjectBindingPattern,
  createObjectLiteral,
  createParameter,
  createPrinter,
  createProperty,
  createPropertyAccess,
  createPropertyAssignment,
  createReturn,
  createShorthandPropertyAssignment,
  createSourceFile,
  createVariableDeclaration,
  createVariableDeclarationList,
  createVariableStatement,
  EmitHint,
  Expression,
  Identifier,
  ImportDeclaration,
  MethodDeclaration,
  Node,
  NodeFlags,
  ObjectLiteralElementLike,
  ObjectLiteralExpression,
  ParameterDeclaration,
  Printer,
  PropertyAccessExpression,
  PropertyDeclaration,
  ReturnStatement,
  ScriptTarget,
  SourceFile,
  Statement,
  SyntaxKind,
  VariableDeclaration,
  VariableStatement
} from 'typescript';

export function emit(path: string, ...nodes: Node[]): void {
  const emptyFile: SourceFile = createSourceFile('', '', ScriptTarget.Latest);
  const printer: Printer = createPrinter({ removeComments: false });
  let content = '';
  for (const node of nodes) {
    if (node === null) {
      content += '\n';
    } else {
      content += `${printer.printNode(EmitHint.Unspecified, node, emptyFile)}\n`;
    }
  }
  writeFileSync(path, `${content.slice(0, -1)}\r\n`, { encoding: 'utf8' });
}

export function addRange(start: number, end: number, ...records: Record<string, boolean>[]): void {
  for (let i = start; i <= end; ++i) {
    records.forEach(r => r[String.fromCharCode(i)] = true);
  }
}
const identPart = {};
const identStart = {};
addRange('a'.charCodeAt(0), 'z'.charCodeAt(0), identPart, identStart);
addRange('A'.charCodeAt(0), 'Z'.charCodeAt(0), identPart, identStart);
addRange('$'.charCodeAt(0), '$'.charCodeAt(0), identPart, identStart);
addRange('_'.charCodeAt(0), '_'.charCodeAt(0), identPart, identStart);
addRange('0'.charCodeAt(0), '9'.charCodeAt(0), identPart);

export function $name(input: string): string {
  let value = '';
  let first = true;
  let char: string;
  for (let i = 0, ii = input.length; i < ii; ++i) {
    char = input.charAt(i);
    if (first) {
      value = value + (identStart[char] ? char : '_');
    } else {
      value = value + (identPart[char] ? char : '_');
    }
    first = false;
  }
  return value;
}

export function $id(name: string): Identifier;
export function $id(id: Identifier): Identifier;
export function $id(nameOrId: string | Identifier): Identifier;
export function $id(expr: Expression): Expression;
export function $id(nameOrExpr: string | Expression): Identifier | Expression;
export function $id(idOrExpr: Identifier | Expression): Identifier | Expression;
export function $id(nameOrExprOrId: string | Expression | Identifier): Expression | Identifier;
export function $id(nameOrExprOrId: string | Expression | Identifier): Expression | Identifier {
  return typeof nameOrExprOrId === 'string' ? createIdentifier(nameOrExprOrId) : nameOrExprOrId;
}

export function $access(name: string): Identifier;
export function $access(path: [string | Expression | Identifier, ...(string | Identifier)[]]): PropertyAccessExpression;
export function $access(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): PropertyAccessExpression | Identifier;
export function $access(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): PropertyAccessExpression | Identifier {
  if (Array.isArray(nameOrPath)) {
    let left = $id(nameOrPath[0]);
    const rest = nameOrPath.slice(1) as (string | Identifier)[];
    rest.forEach(name => {
      left = createPropertyAccess(left, $id(name));
    });
    return left as PropertyAccessExpression;
  } else {
    return createIdentifier(nameOrPath);
  }
}

export function $call(name: string, variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $call(path: [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $call(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $call(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions: (string | Expression | Identifier)[] = []): Expression {
  const left = $access(nameOrPath);
  const args: Expression[] = [];

  variablesOrExpressions.forEach(varOrExpr => {
    if (typeof varOrExpr === 'string') {
      args.push(createIdentifier(varOrExpr));
    } else {
      args.push(varOrExpr);
    }
  });
  return createCall(left, [], args);
}

export function $$call(name: string, variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$call(path: [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$call(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$call(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions: (string | Expression | Identifier)[] = []): Statement {
  return createExpressionStatement($call(nameOrPath, variablesOrExpressions));
}

export function $assign(leftName: string, rightName: string): Expression;
export function $assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightName: string): Expression;
export function $assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightName: string): Expression;
export function $assign(leftName: string, rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftName: string, rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Expression;
export function $assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Expression {
  const left = $access(leftNameOrPath);
  const right = $access(rightNameOrPath);
  return createAssignment(left, right);
}

export function $$assign(leftName: string, rightName: string): Statement;
export function $$assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightName: string): Statement;
export function $$assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightName: string): Statement;
export function $$assign(leftName: string, rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightPath: [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftName: string, rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftPath: [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Statement;
export function $$assign(leftNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], rightNameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]]): Statement {
  return createExpressionStatement($assign(leftNameOrPath, rightNameOrPath));
}

export function $new(name: string, variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $new(path: [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $new(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Expression;
export function $new(nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions: (string | Expression | Identifier)[] = []): Expression {
  const left = $access(nameOrPath);
  const args: Expression[] = [];

  variablesOrExpressions.forEach(varOrExpr => {
    if (typeof varOrExpr === 'string') {
      args.push(createIdentifier(varOrExpr));
    } else {
      args.push(varOrExpr);
    }
  });
  return createNew(left, [], args);
}

export function $$new(variable: string, name: string, variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$new(variable: string, path: [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$new(variable: string, nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions?: (string | Expression | Identifier)[]): Statement;
export function $$new(variable: string, nameOrPath: string | [string | Expression | Identifier, ...(string | Identifier)[]], variablesOrExpressions: (string | Expression | Identifier)[] = []): Statement {
  return $$const(variable, $new(nameOrPath, variablesOrExpressions));
}

export function $$comment(comment: string, arg: Statement): Statement {
  return addSyntheticLeadingComment(arg, SyntaxKind.SingleLineCommentTrivia, ` ${comment}`, true);
}

export function $$const(name: string, initializer: Expression): VariableStatement;
export function $$const(names: string[], initializer: Expression): VariableStatement;
export function $$const(nameOrNames: string | string[], initializer: Expression): VariableStatement {
  let declaration: VariableDeclaration;
  if (Array.isArray(nameOrNames)) {
    const elements = nameOrNames.map(n => createBindingElement(undefined, undefined, n));
    declaration = createVariableDeclaration(createObjectBindingPattern(elements), undefined, initializer);
  } else {
    declaration = createVariableDeclaration(createIdentifier(nameOrNames), undefined, initializer);
  }
  return createVariableStatement([], createVariableDeclarationList([declaration], NodeFlags.Const));
}

export function $expression(value: any, multiline: number = 0, level: number = 0): Expression {

  function $objectLiteral(obj: any, $multiline: number, $level: number): ObjectLiteralExpression {
    const properties: ObjectLiteralElementLike[] = [];
    Object.keys(obj).forEach(key => {
      const identifier = createIdentifier(key);
      const objValue = obj[key];
      if (key === objValue) {
        properties.push(createShorthandPropertyAssignment(identifier));
      } else {
        const initializer = $expression(obj[key], $multiline, $level + 1);
        properties.push(createPropertyAssignment(identifier, initializer));
      }
    });
    return createObjectLiteral(properties, $multiline > $level);
  }

  function $arrayLiteral(arr: any[], $multiline: number, $level: number): ArrayLiteralExpression {
    const expressions: Expression[] = [];
    arr.forEach(arrValue => {
      expressions.push($expression(arrValue, $multiline, $level + 1));
    });
    return createArrayLiteral(expressions, $multiline > $level);
  }

  switch (Object.prototype.toString.call(value)) {
    case '[object Undefined]':
      return createIdentifier('undefined');
    case '[object Null]':
      return createIdentifier('null');
    case '[object Number]':
    case '[object Boolean]':
    case '[object String]':
      return createLiteral(value);
    case '[object Array]':
      return $arrayLiteral(value, multiline, level);
    case '[object Object]':
      return $objectLiteral(value, multiline, level);
    default:
      if (typeof value === 'function') {
        return $id(value.name);
      } else {
        return $objectLiteral(value, multiline, level);
      }
  }
}

export function $$return(value: any): ReturnStatement {
  return createReturn($expression(value));
}

export function $property(name: string, value?: any, isStatic?: boolean): PropertyDeclaration {
  const modifiers = [];
  if (isStatic === true) {
    modifiers.push(createModifier(SyntaxKind.StaticKeyword));
  }
  if (arguments.length === 1) {
    return createProperty([], modifiers, $id(name), undefined, undefined, undefined);
  } else {
    return createProperty([], modifiers, $id(name), undefined, undefined, value && value.escapedText ? value : $expression(value));
  }
}
export function $method(name: string, statements: Statement[], params?: ParameterDeclaration[], isStatic?: boolean): MethodDeclaration {
  const modifiers = [];
  if (isStatic === true) {
    modifiers.push(createModifier(SyntaxKind.StaticKeyword));
  }
  if (arguments.length === 2) {
    return createMethod([], modifiers, undefined, $id(name), undefined, undefined, [], undefined, createBlock(statements, true));
  } else {
    return createMethod([], modifiers, undefined, $id(name), undefined, undefined, params, undefined, createBlock(statements, true));
  }
}
export function $class(elements: readonly ClassElement[]): ClassExpression {
  return createClassExpression([], undefined, [], [], elements);
}
export function $functionExpr(parameters: ParameterDeclaration[], statements: Statement[]): Expression;
export function $functionExpr(statements: Statement[]): Expression;
export function $functionExpr(statementsOrParameters: Statement[] | ParameterDeclaration[], statements?: Statement[]): Expression {
  return createFunctionExpression(
    [],
    undefined,
    undefined,
    [],
    arguments.length === 1 ? [] : statementsOrParameters as ParameterDeclaration[],
    undefined,
    createBlock(arguments.length === 1 ? statementsOrParameters as Statement[] : statements, true)
  );
}
export function $$functionExpr(name: string, args: Expression[]): Statement {
  return createExpressionStatement($call(name, args));
}
export function $$functionDecl(name: string, statements: Statement[], parameters: ParameterDeclaration[]): Statement {
  return createFunctionDeclaration([], [], undefined, createIdentifier(name), [], parameters, undefined, createBlock(statements, true));
}
export function $param(name: string): ParameterDeclaration {
  return createParameter(
    [],
    [],
    undefined,
    createIdentifier(name),
    undefined,
    undefined,
    undefined
  );
}
export function $$import(path: string, ...names: string[]): ImportDeclaration {
  return createImportDeclaration(
    [],
    [],
    createImportClause(
      undefined,
      createNamedImports(names.map(name => createImportSpecifier(undefined, createIdentifier(name))))
    ),
    createLiteral(path)
  );
}
export function $element(name: string, inner: string, ...attributes: string[]): string {
  return attributes.length
    ? `<${name} ${attributes.join(' ')}>${inner}</${name}>`
    : `<${name}>${inner}</${name}>`;
}
export function $div(inner: string, ...attributes: string[]): string {
  return $element('div', inner, ...attributes);
}
$div.$name = 'div';
export function $tpl(inner: string, ...attributes: string[]): string {
  return $element('template', inner, ...attributes);
}
$tpl.$name = 'tpl';
type CreateElement = { $name: string } & ((inner: string, ...attributes: string[]) => string);

export function $attr(create: CreateElement, ...attributes: string[]): CreateElement {
  const createWrapped = (inner: string) => {
    return create(inner, ...attributes);
  };
  createWrapped.$name = this.$name;
  return createWrapped;
}


<?php

namespace App\Request\ParamConverter\Library;

use App\Entity\Library\Author;
use Rebolon\Request\ParamConverter\ItemAbstractConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;

class AuthorConverter extends ItemAbstractConverter
{
    const NAME = 'author';

    const RELATED_ENTITY = Author::class;

    /**
     * {@inheritdoc}
     * for this kind of json:
     * {
     *   "author": {
     *     "firstname": "Paul",
     *     "lastname": "Smith"
     *   }
     * }
     */
    public function getEzPropsName(): array
    {
        return ['id', 'firstname', 'lastname', ];
    }

    /**
     * {@inheritdoc}
     */
    public function getManyRelPropsName():array
    {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public function getOneRelPropsName():array
    {
        return [];
    }
}


/*
 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

/**
 * @constructor
 * @extends {WebInspector.View}
 */
WebInspector.ResourceWebSocketFrameView = function(resource)
{
    WebInspector.View.call(this);
    this.element.addStyleClass("resource-websocket");
    this.resource = resource;
    this.element.removeChildren();

    var dataGrid = new WebInspector.DataGrid({
        data: {title: WebInspector.UIString("Data"), sortable: false},
        length: {title: WebInspector.UIString("Length"), sortable: false, aligned: "right", width: "50px"},
        time: {title: WebInspector.UIString("Time"), width: "70px"}
    });

    var frames = this.resource.frames();
    for (var i = 0; i < frames.length; i++) {
        var payload = frames[i];

        var date = new Date(payload.time * 1000);
        var row = {
            data: "",
            length: payload.payloadData.length.toString(),
            time: date.toLocaleTimeString()
        };

        var rowClass = "";
        if (payload.errorMessage) {
            rowClass = "error";
            row.data = payload.errorMessage;
        } else if (payload.opcode == WebInspector.ResourceWebSocketFrameView.OpCodes.TextFrame) {
            if (payload.sent)
                rowClass = "outcoming";

            row.data = payload.payloadData;
        } else {
            rowClass = "opcode";
            var opcodeMeaning = "";
            switch (payload.opcode) {
            case WebInspector.ResourceWebSocketFrameView.OpCodes.ContinuationFrame:
                opcodeMeaning = WebInspector.UIString("Continuation Frame");
                break;
            case WebInspector.ResourceWebSocketFrameView.OpCodes.BinaryFrame:
                opcodeMeaning = WebInspector.UIString("Binary Frame");
                break;
            case WebInspector.ResourceWebSocketFrameView.OpCodes.ConnectionCloseFrame:
                opcodeMeaning = WebInspector.UIString("Connection Close Frame");
                break;
            case WebInspector.ResourceWebSocketFrameView.OpCodes.PingFrame:
                opcodeMeaning = WebInspector.UIString("Ping Frame");
                break;
            case WebInspector.ResourceWebSocketFrameView.OpCodes.PongFrame:
                opcodeMeaning = WebInspector.UIString("Pong Frame");
                break;
            }
            row.data = WebInspector.UIString("%s (Opcode %d%s)", opcodeMeaning, payload.opcode, (payload.mask ? ", mask" : ""));
        }

        var node = new WebInspector.DataGridNode(row, false);
        dataGrid.rootNode().appendChild(node);

        if (rowClass)
            node.element.classList.add("resource-websocket-row-" + rowClass);

    }
    dataGrid.show(this.element);
}

WebInspector.ResourceWebSocketFrameView.OpCodes = {
    ContinuationFrame: 0,
    TextFrame: 1,
    BinaryFrame: 2,
    ConnectionCloseFrame: 8,
    PingFrame: 9,
    PongFrame: 10
};

WebInspector.ResourceWebSocketFrameView.prototype = {
    __proto__: WebInspector.View.prototype
}


// Copyright 2012 Citrix Systems, Inc. Licensed under the
// Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License.  Citrix Systems, Inc.
// reserves all rights not expressly granted by the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
package com.cloud.network.lb.dao;

import java.util.List;

import javax.ejb.Local;

import com.cloud.network.ElasticLbVmMapVO;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerDaoImpl;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.JoinBuilder.JoinType;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.DomainRouterDaoImpl;

@Local(value={ElasticLbVmMapDao.class})
public class ElasticLbVmMapDaoImpl extends GenericDaoBase<ElasticLbVmMapVO, Long> implements ElasticLbVmMapDao {
    protected final DomainRouterDao _routerDao = ComponentLocator.inject(DomainRouterDaoImpl.class);
    protected final LoadBalancerDao _loadbalancerDao = ComponentLocator.inject(LoadBalancerDaoImpl.class);

    protected final SearchBuilder<ElasticLbVmMapVO> AllFieldsSearch;
    protected final SearchBuilder<ElasticLbVmMapVO> UnusedVmSearch;
    protected final SearchBuilder<ElasticLbVmMapVO> LoadBalancersForElbVmSearch;

    protected final SearchBuilder<DomainRouterVO> ElbVmSearch;

    protected final SearchBuilder<LoadBalancerVO> LoadBalancerSearch;

    protected ElasticLbVmMapDaoImpl() {
        AllFieldsSearch  = createSearchBuilder();
        AllFieldsSearch.and("ipId", AllFieldsSearch.entity().getIpAddressId(), SearchCriteria.Op.EQ);
        AllFieldsSearch.and("lbId", AllFieldsSearch.entity().getLbId(), SearchCriteria.Op.EQ);
        AllFieldsSearch.and("elbVmId", AllFieldsSearch.entity().getElbVmId(), SearchCriteria.Op.EQ);
        AllFieldsSearch.done();

        ElbVmSearch = _routerDao.createSearchBuilder();
        ElbVmSearch.and("role", ElbVmSearch.entity().getRole(), SearchCriteria.Op.EQ);
        UnusedVmSearch  = createSearchBuilder();
        UnusedVmSearch.and("elbVmId", UnusedVmSearch.entity().getElbVmId(), SearchCriteria.Op.NULL);
        ElbVmSearch.join("UnusedVmSearch", UnusedVmSearch, ElbVmSearch.entity().getId(), UnusedVmSearch.entity().getElbVmId(), JoinType.LEFTOUTER);
        ElbVmSearch.done();
        UnusedVmSearch.done();

        LoadBalancerSearch = _loadbalancerDao.createSearchBuilder();
        LoadBalancersForElbVmSearch = createSearchBuilder();
        LoadBalancersForElbVmSearch.and("elbVmId", LoadBalancersForElbVmSearch.entity().getElbVmId(), SearchCriteria.Op.EQ);
        LoadBalancerSearch.join("LoadBalancersForElbVm", LoadBalancersForElbVmSearch, LoadBalancerSearch.entity().getId(), LoadBalancersForElbVmSearch.entity().getLbId(), JoinType.INNER);
        LoadBalancersForElbVmSearch.done();
        LoadBalancerSearch.done();

    }

    @Override
    public ElasticLbVmMapVO findOneByLbIdAndElbVmId(long lbId, long elbVmId) {
        SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("lbId", lbId);
        sc.setParameters("elbVmId", elbVmId);
        return findOneBy(sc);
    }

    @Override
    public List<ElasticLbVmMapVO> listByLbId(long lbId) {
        SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("lbId", lbId);
        return listBy(sc);
    }

    @Override
    public List<ElasticLbVmMapVO> listByElbVmId(long elbVmId) {
        SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("elbVmId", elbVmId);
        return listBy(sc);
    }

    @Override
    public int deleteLB(long lbId) {
    	SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("lbId", lbId);
        return super.expunge(sc);
    }

    @Override
    public ElasticLbVmMapVO findOneByIpIdAndElbVmId(long ipId, long elbVmId) {
        SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("ipId", ipId);
        sc.setParameters("elbVmId", elbVmId);
        return findOneBy(sc);
    }

    @Override
    public ElasticLbVmMapVO findOneByIp(long ipId) {
        SearchCriteria<ElasticLbVmMapVO> sc = AllFieldsSearch.create();
        sc.setParameters("ipId", ipId);
        return findOneBy(sc);
    }

    public List<DomainRouterVO> listUnusedElbVms() {
        SearchCriteria<DomainRouterVO> sc = ElbVmSearch.create();
        sc.setParameters("role", Role.LB);
        return _routerDao.search(sc, null);
    }

    @Override
    public List<LoadBalancerVO> listLbsForElbVm(long elbVmId) {
        SearchCriteria<LoadBalancerVO> sc = LoadBalancerSearch.create();
        sc.setJoinParameters("LoadBalancersForElbVm", "elbVmId", elbVmId);
        return _loadbalancerDao.search(sc, null);
    }

}


# Created by: Brendan Molloy <brendan+freebsd@bbqsrc.net>
# $FreeBSD$

PORTNAME=	matrix-angular-sdk
PORTVERSION=	0.6.8
CATEGORIES=	devel www python
MASTER_SITES=	CHEESESHOP
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}

MAINTAINER=	miwi@FreeBSD.org
COMMENT=	Matrix Angular SDK

LICENSE=	APACHE20
LICENSE_FILE=	${WRKSRC}/LICENSE

USES=		python
USE_PYTHON=	autoplist distutils

NO_ARCH=	yes

.include <bsd.port.mk>


/*
 * Copyright MapStruct Authors.
 *
 * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package org.mapstruct.itest.jsr330;

import javax.inject.Inject;
import javax.inject.Named;

public abstract class SecondSourceTargetMapperDecorator implements SecondDecoratedSourceTargetMapper {

    @Inject
    @Named("org.mapstruct.itest.jsr330.SecondDecoratedSourceTargetMapperImpl_")
    private SecondDecoratedSourceTargetMapper delegate;

    @Override
    public Target sourceToTarget(Source source) {
        Target t = delegate.sourceToTarget( source );
        t.setFoo( 43L );
        return t;
    }
}