text:
.class public Lcom/htc/widget/QuickTips$TipAnchor;
.super Ljava/lang/Object;
.source "QuickTips.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/htc/widget/QuickTips;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "TipAnchor"
.end annotation

# static fields
.field public static final ANCHOR_MODE_BOTTOM:I = 0x20

.field public static final ANCHOR_MODE_CENTER:I = 0x2

.field public static final ANCHOR_MODE_LEFT:I = 0x1

.field public static final ANCHOR_MODE_MIDDLE:I = 0x10

.field public static final ANCHOR_MODE_RIGHT:I = 0x4

.field public static final ANCHOR_MODE_TOP:I = 0x8

# instance fields
.field private anchorMode:I

.field private content:Lcom/htc/widget/QuickTips$TipItem;

.field private location:Landroid/graphics/Point;

.field private quickTips:Lcom/htc/widget/QuickTips;

.field private relativeLocation:Landroid/graphics/Point;

.field private targetItem:Lcom/htc/widget/QuickTips$TipItem;

.field private targetRect:Landroid/graphics/Rect;

.field private targetView:Landroid/view/View;

.field private targetViewId:I

# direct methods
.method public constructor <init>(Lcom/htc/widget/QuickTips;I)V
    .locals 2
    .parameter "quickTips"
    .parameter "targetViewId"

    .prologue
    .line 1370
    const/16 v0, 0x9

    const/4 v1, 0x0

    invoke-direct {p0, p1, p2, v0, v1}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;IILandroid/graphics/Point;)V

    .line 1371
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;II)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetViewId"
    .parameter "anchorMode"

    .prologue
    .line 1381
    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, p3, v0}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;IILandroid/graphics/Point;)V

    .line 1382
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;IILandroid/graphics/Point;)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetViewId"
    .parameter "anchorMode"
    .parameter "relativeLocation"

    .prologue
    .line 1404
    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 1405
    iput-object p1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    .line 1406
    iput p2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    .line 1407
    iput p3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    .line 1408
    if-nez p4, :cond_0

    new-instance p4, Landroid/graphics/Point;

    .end local p4
    invoke-direct {p4}, Landroid/graphics/Point;-><init>()V

    :cond_0
    iput-object p4, p0, Lcom/htc/widget/QuickTips$TipAnchor;->relativeLocation:Landroid/graphics/Point;

    .line 1409
    #calls: Lcom/htc/widget/QuickTips;->getView(I)Landroid/view/View;
    invoke-static {p1, p2}, Lcom/htc/widget/QuickTips;->access$2300(Lcom/htc/widget/QuickTips;I)Landroid/view/View;

    move-result-object v0

    iput-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    .line 1410
    iget v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    if-gtz v0, :cond_1

    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    if-eqz v0, :cond_2

    .line 1411
    :cond_1
    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    invoke-virtual {v0, p1}, Landroid/view/View;->addOnLayoutChangeListener(Landroid/view/View$OnLayoutChangeListener;)V

    .line 1413
    :cond_2
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;ILandroid/graphics/Point;)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetViewId"
    .parameter "relativeLocation"

    .prologue
    .line 1392
    const/16 v0, 0x9

    invoke-direct {p0, p1, p2, v0, p3}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;IILandroid/graphics/Point;)V

    .line 1393
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Point;)V
    .locals 3
    .parameter "quickTips"
    .parameter "absoluteLocation"

    .prologue
    .line 1361
    const/16 v0, -0x2710

    const/16 v1, 0x9

    const/4 v2, 0x0

    invoke-direct {p0, p1, v0, v1, v2}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;IILandroid/graphics/Point;)V

    .line 1362
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;)V
    .locals 2
    .parameter "quickTips"
    .parameter "targetRect"

    .prologue
    .line 1470
    const/16 v0, 0x9

    const/4 v1, 0x0

    invoke-direct {p0, p1, p2, v0, v1}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;ILandroid/graphics/Point;)V

    .line 1471
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;I)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetRect"
    .parameter "anchorMode"

    .prologue
    .line 1481
    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, p3, v0}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;ILandroid/graphics/Point;)V

    .line 1482
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;ILandroid/graphics/Point;)V
    .locals 0
    .parameter "quickTips"
    .parameter "targetRect"
    .parameter "anchorMode"
    .parameter "relativeLocation"

    .prologue
    .line 1504
    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 1505
    iput-object p1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    .line 1506
    iput-object p2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    .line 1507
    iput p3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    .line 1508
    if-nez p4, :cond_0

    new-instance p4, Landroid/graphics/Point;

    .end local p4
    invoke-direct {p4}, Landroid/graphics/Point;-><init>()V

    :cond_0
    iput-object p4, p0, Lcom/htc/widget/QuickTips$TipAnchor;->relativeLocation:Landroid/graphics/Point;

    .line 1509
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;Landroid/graphics/Point;)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetRect"
    .parameter "relativeLocation"

    .prologue
    .line 1493
    const/16 v0, 0x9

    invoke-direct {p0, p1, p2, v0, p3}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Landroid/graphics/Rect;ILandroid/graphics/Point;)V

    .line 1494
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;)V
    .locals 2
    .parameter "quickTips"
    .parameter "targetItem"

    .prologue
    .line 1422
    const/16 v0, 0x9

    const/4 v1, 0x0

    invoke-direct {p0, p1, p2, v0, v1}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;ILandroid/graphics/Point;)V

    .line 1423
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;I)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetItem"
    .parameter "anchorMode"

    .prologue
    .line 1433
    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, p3, v0}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;ILandroid/graphics/Point;)V

    .line 1434
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;ILandroid/graphics/Point;)V
    .locals 0
    .parameter "quickTips"
    .parameter "targetItem"
    .parameter "anchorMode"
    .parameter "relativeLocation"

    .prologue
    .line 1456
    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 1457
    iput-object p1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    .line 1458
    iput-object p2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetItem:Lcom/htc/widget/QuickTips$TipItem;

    .line 1459
    iput p3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    .line 1460
    if-nez p4, :cond_0

    new-instance p4, Landroid/graphics/Point;

    .end local p4
    invoke-direct {p4}, Landroid/graphics/Point;-><init>()V

    :cond_0
    iput-object p4, p0, Lcom/htc/widget/QuickTips$TipAnchor;->relativeLocation:Landroid/graphics/Point;

    .line 1461
    return-void
.end method

.method public constructor <init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;Landroid/graphics/Point;)V
    .locals 1
    .parameter "quickTips"
    .parameter "targetItem"
    .parameter "relativeLocation"

    .prologue
    .line 1445
    const/16 v0, 0x9

    invoke-direct {p0, p1, p2, v0, p3}, Lcom/htc/widget/QuickTips$TipAnchor;-><init>(Lcom/htc/widget/QuickTips;Lcom/htc/widget/QuickTips$TipItem;ILandroid/graphics/Point;)V

    .line 1446
    return-void
.end method

.method static synthetic access$1600(Lcom/htc/widget/QuickTips$TipAnchor;)I
    .locals 1
    .parameter "x0"

    .prologue
    .line 1314
    iget v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    return v0
.end method

.method static synthetic access$1700(Lcom/htc/widget/QuickTips$TipAnchor;)Landroid/view/View;
    .locals 1
    .parameter "x0"

    .prologue
    .line 1314
    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    return-object v0
.end method

.method static synthetic access$2200(Lcom/htc/widget/QuickTips$TipAnchor;)Lcom/htc/widget/QuickTips$TipItem;
    .locals 1
    .parameter "x0"

    .prologue
    .line 1314
    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->content:Lcom/htc/widget/QuickTips$TipItem;

    return-object v0
.end method

.method static synthetic access$2600(Lcom/htc/widget/QuickTips$TipAnchor;)Lcom/htc/widget/QuickTips;
    .locals 1
    .parameter "x0"

    .prologue
    .line 1314
    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    return-object v0
.end method

.method private setLocation(Landroid/graphics/Point;)V
    .locals 0
    .parameter "location"

    .prologue
    .line 1512
    iput-object p1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    .line 1513
    return-void
.end method

# virtual methods
.method public draw(Landroid/graphics/Canvas;)V
    .locals 6
    .parameter "canvas"

    .prologue
    .line 1589
    const-string v1, "QuickTips"

    const/4 v2, 0x2

    invoke-static {v1, v2}, Landroid/util/Log;->isLoggable(Ljava/lang/String;I)Z

    move-result v1

    if-eqz v1, :cond_0

    .line 1590
    new-instance v0, Landroid/graphics/Paint;

    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    #calls: Lcom/htc/widget/QuickTips;->getPaint()Landroid/graphics/Paint;
    invoke-static {v1}, Lcom/htc/widget/QuickTips;->access$2400(Lcom/htc/widget/QuickTips;)Landroid/graphics/Paint;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/graphics/Paint;-><init>(Landroid/graphics/Paint;)V

    .line 1591
    .local v0, p:Landroid/graphics/Paint;
    sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 1592
    const v1, -0xff0100

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    .line 1593
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetItem:Lcom/htc/widget/QuickTips$TipItem;

    if-eqz v1, :cond_2

    .line 1609
    .end local v0           #p:Landroid/graphics/Paint;
    :cond_0
    :goto_0
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->content:Lcom/htc/widget/QuickTips$TipItem;

    if-eqz v1, :cond_1

    .line 1610
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->content:Lcom/htc/widget/QuickTips$TipItem;

    invoke-interface {v1, p1}, Lcom/htc/widget/QuickTips$TipItem;->draw(Landroid/graphics/Canvas;)V

    .line 1612
    :cond_1
    return-void

    .line 1595
    .restart local v0       #p:Landroid/graphics/Paint;
    :cond_2
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v1, v1, Landroid/graphics/Point;->x:I

    int-to-float v1, v1

    iget-object v2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v2, v2, Landroid/graphics/Point;->y:I

    int-to-float v2, v2

    const/high16 v3, 0x4080

    invoke-virtual {p1, v1, v2, v3, v0}, Landroid/graphics/Canvas;->drawCircle(FFFLandroid/graphics/Paint;)V

    .line 1596
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    if-eqz v1, :cond_3

    .line 1597
    const-string v1, "QuickTips"

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "highlight rect="

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    iget-object v3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 1598
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    invoke-virtual {p1, v1, v0}, Landroid/graphics/Canvas;->drawRect(Landroid/graphics/Rect;Landroid/graphics/Paint;)V

    .line 1604
    :goto_1
    const v1, -0xff0001

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    .line 1605
    sget-object v1, Landroid/graphics/Paint$Style;->FILL:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 1606
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v1, v1, Landroid/graphics/Point;->x:I

    int-to-float v1, v1

    iget-object v2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v2, v2, Landroid/graphics/Point;->y:I

    int-to-float v2, v2

    const/high16 v3, 0x40a0

    invoke-virtual {p1, v1, v2, v3, v0}, Landroid/graphics/Canvas;->drawCircle(FFFLandroid/graphics/Paint;)V

    goto :goto_0

    .line 1600
    :cond_3
    const-string v1, "QuickTips"

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "highlight rect ="

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    iget-object v3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    iget v4, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    iget-object v5, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    #calls: Lcom/htc/widget/QuickTips;->getViewRect(ILandroid/view/View;)Landroid/graphics/Rect;
    invoke-static {v3, v4, v5}, Lcom/htc/widget/QuickTips;->access$1800(Lcom/htc/widget/QuickTips;ILandroid/view/View;)Landroid/graphics/Rect;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 1601
    iget-object v1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    iget v2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    iget-object v3, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    #calls: Lcom/htc/widget/QuickTips;->getViewRect(ILandroid/view/View;)Landroid/graphics/Rect;
    invoke-static {v1, v2, v3}, Lcom/htc/widget/QuickTips;->access$1800(Lcom/htc/widget/QuickTips;ILandroid/view/View;)Landroid/graphics/Rect;

    move-result-object v1

    invoke-virtual {p1, v1, v0}, Landroid/graphics/Canvas;->drawRect(Landroid/graphics/Rect;Landroid/graphics/Paint;)V

    goto :goto_1
.end method

.method public getLocation()Landroid/graphics/Point;
    .locals 10

    .prologue
    .line 1518
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    if-eqz v7, :cond_0

    .line 1519
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    .line 1573
    :goto_0
    return-object v7

    .line 1521
    :cond_0
    const/4 v5, 0x0

    .line 1522
    .local v5, x:I
    const/4 v6, 0x0

    .line 1523
    .local v6, y:I
    const/4 v4, 0x0

    .line 1524
    .local v4, w:I
    const/4 v0, 0x0

    .line 1525
    .local v0, h:I
    iget-object v2, p0, Lcom/htc/widget/QuickTips$TipAnchor;->relativeLocation:Landroid/graphics/Point;

    .line 1526
    .local v2, rloc:Landroid/graphics/Point;
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetItem:Lcom/htc/widget/QuickTips$TipItem;

    if-eqz v7, :cond_1

    .line 1527
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetItem:Lcom/htc/widget/QuickTips$TipItem;

    invoke-interface {v7}, Lcom/htc/widget/QuickTips$TipItem;->getBounds()Landroid/graphics/Rect;

    move-result-object v1

    .line 1528
    .local v1, itemBounds:Landroid/graphics/Rect;
    iget v5, v1, Landroid/graphics/Rect;->left:I

    .line 1529
    iget v6, v1, Landroid/graphics/Rect;->top:I

    .line 1530
    invoke-virtual {v1}, Landroid/graphics/Rect;->width()I

    move-result v4

    .line 1531
    invoke-virtual {v1}, Landroid/graphics/Rect;->height()I

    move-result v0

    .line 1545
    .end local v1           #itemBounds:Landroid/graphics/Rect;
    :goto_1
    new-instance v7, Landroid/graphics/Point;

    invoke-direct {v7}, Landroid/graphics/Point;-><init>()V

    iput-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    .line 1546
    iget v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    and-int/lit8 v7, v7, 0x7

    packed-switch v7, :pswitch_data_0

    .line 1557
    :pswitch_0
    new-instance v7, Ljava/lang/RuntimeException;

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "Unknown anchor mode: 0x"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget v9, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    invoke-static {v9}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v7, v8}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v7

    .line 1532
    :cond_1
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    if-eqz v7, :cond_2

    .line 1533
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    iget v5, v7, Landroid/graphics/Rect;->left:I

    .line 1534
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    iget v6, v7, Landroid/graphics/Rect;->top:I

    .line 1535
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    invoke-virtual {v7}, Landroid/graphics/Rect;->width()I

    move-result v4

    .line 1536
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetRect:Landroid/graphics/Rect;

    invoke-virtual {v7}, Landroid/graphics/Rect;->height()I

    move-result v0

    goto :goto_1

    .line 1538
    :cond_2
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    iget v8, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetViewId:I

    iget-object v9, p0, Lcom/htc/widget/QuickTips$TipAnchor;->targetView:Landroid/view/View;

    #calls: Lcom/htc/widget/QuickTips;->getViewRect(ILandroid/view/View;)Landroid/graphics/Rect;
    invoke-static {v7, v8, v9}, Lcom/htc/widget/QuickTips;->access$1800(Lcom/htc/widget/QuickTips;ILandroid/view/View;)Landroid/graphics/Rect;

    move-result-object v3

    .line 1539
    .local v3, viewBounds:Landroid/graphics/Rect;
    iget v5, v3, Landroid/graphics/Rect;->left:I

    .line 1540
    iget v6, v3, Landroid/graphics/Rect;->top:I

    .line 1541
    invoke-virtual {v3}, Landroid/graphics/Rect;->width()I

    move-result v4

    .line 1542
    invoke-virtual {v3}, Landroid/graphics/Rect;->height()I

    move-result v0

    goto :goto_1

    .line 1548
    .end local v3           #viewBounds:Landroid/graphics/Rect;
    :pswitch_1
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v8, v2, Landroid/graphics/Point;->x:I

    add-int/2addr v8, v5

    iput v8, v7, Landroid/graphics/Point;->x:I

    .line 1559
    :goto_2
    iget v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    and-int/lit8 v7, v7, 0x38

    sparse-switch v7, :sswitch_data_0

    .line 1570
    new-instance v7, Ljava/lang/RuntimeException;

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "Unknown anchor mode: 0x"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget v9, p0, Lcom/htc/widget/QuickTips$TipAnchor;->anchorMode:I

    invoke-static {v9}, Ljava/lang/Integer;->toHexString(I)Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v7, v8}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v7

    .line 1551
    :pswitch_2
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    div-int/lit8 v8, v4, 0x2

    add-int/2addr v8, v5

    iget v9, v2, Landroid/graphics/Point;->x:I

    add-int/2addr v8, v9

    iput v8, v7, Landroid/graphics/Point;->x:I

    goto :goto_2

    .line 1554
    :pswitch_3
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    add-int v8, v5, v4

    iget v9, v2, Landroid/graphics/Point;->x:I

    add-int/2addr v8, v9

    iput v8, v7, Landroid/graphics/Point;->x:I

    goto :goto_2

    .line 1561
    :sswitch_0
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    iget v8, v2, Landroid/graphics/Point;->y:I

    add-int/2addr v8, v6

    iput v8, v7, Landroid/graphics/Point;->y:I

    .line 1572
    :goto_3
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    invoke-direct {p0, v7}, Lcom/htc/widget/QuickTips$TipAnchor;->setLocation(Landroid/graphics/Point;)V

    .line 1573
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    goto/16 :goto_0

    .line 1564
    :sswitch_1
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    div-int/lit8 v8, v0, 0x2

    add-int/2addr v8, v6

    iget v9, v2, Landroid/graphics/Point;->y:I

    add-int/2addr v8, v9

    iput v8, v7, Landroid/graphics/Point;->y:I

    goto :goto_3

    .line 1567
    :sswitch_2
    iget-object v7, p0, Lcom/htc/widget/QuickTips$TipAnchor;->location:Landroid/graphics/Point;

    add-int v8, v6, v0

    iget v9, v2, Landroid/graphics/Point;->y:I

    add-int/2addr v8, v9

    iput v8, v7, Landroid/graphics/Point;->y:I

    goto :goto_3

    .line 1546
    nop

    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_1
        :pswitch_2
        :pswitch_0
        :pswitch_3
    .end packed-switch

    .line 1559
    :sswitch_data_0
    .sparse-switch
        0x8 -> :sswitch_0
        0x10 -> :sswitch_1
        0x20 -> :sswitch_2
    .end sparse-switch
.end method

.method public setContent(Lcom/htc/widget/QuickTips$TipItem;)V
    .locals 1
    .parameter "item"

    .prologue
    .line 1581
    iget-object v0, p0, Lcom/htc/widget/QuickTips$TipAnchor;->quickTips:Lcom/htc/widget/QuickTips;

    #calls: Lcom/htc/widget/QuickTips;->getPaint()Landroid/graphics/Paint;
    invoke-static {v0}, Lcom/htc/widget/QuickTips;->access$2400(Lcom/htc/widget/QuickTips;)Landroid/graphics/Paint;

    move-result-object v0

    invoke-interface {p1, v0}, Lcom/htc/widget/QuickTips$TipItem;->setPaint(Landroid/graphics/Paint;)V

    .line 1582
    invoke-interface {p1, p0}, Lcom/htc/widget/QuickTips$TipItem;->setAnchor(Lcom/htc/widget/QuickTips$TipAnchor;)V

    .line 1583
    iput-object p1, p0, Lcom/htc/widget/QuickTips$TipAnchor;->content:Lcom/htc/widget/QuickTips$TipItem;

    .line 1584
    return-void
.end method


text:
package forplay.tests;

import forplay.java.JavaPlatform;

import org.junit.BeforeClass;
import org.junit.Ignore;

@Ignore("JUnit should ignore this by default, but it doesn't")
public abstract class AbstractForPlayTest {

  @BeforeClass
  public static void initializePlatform() {
    JavaPlatform.register();
  }
}

redpajama_set_name: RedPajamaGithub


text:
"""
=========================================================
The Digit Dataset
=========================================================
This dataset is made up of 1797 8x8 images. Each image,
like the one shown below, is of a hand-written digit.
In order to ultilise an 8x8 figure like this, we'd have to
first transform it into a feature vector with lengh 64.

See `here
<http://archive.ics.uci.edu/ml/datasets/Pen-Based+Recognition+of+Handwritten+Digits>`_
for more information about this dataset.
"""
print __doc__

# Code source: Gael Varoqueux
# Modified for Documentation merge by Jaques Grobler
# License: BSD

from sklearn import datasets

import pylab as pl

#Load the digits dataset
digits = datasets.load_digits()

#Display the first digit
pl.figure(1, figsize=(3, 3))
pl.imshow(digits.images[-1], cmap=pl.cm.gray_r, interpolation='nearest')
pl.show()


text:
package com.datatorrent.lib.io.jms;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.commons.io.FileUtils;

import com.datatorrent.api.Attribute.AttributeMap.DefaultAttributeMap;
import com.datatorrent.api.DAG;
import com.datatorrent.lib.helper.OperatorContextTestHelper;
import com.datatorrent.lib.helper.OperatorContextTestHelper.TestIdOperatorContext;
import com.datatorrent.lib.util.ActiveMQMultiTypeMessageListener;

/**
 * Test to verify JMS output operator adapter.
 */
public class JMSMultiPortOutputOperatorTest extends JMSTestBase
{
  private static final Logger logger = LoggerFactory.getLogger(JMSMultiPortOutputOperator.class);
  public  int tupleCount = 0;
  public static final transient int maxTuple = 20;

  public static final String CLIENT_ID = "Client1";
  public static final String APP_ID = "appId";
  public static final int OPERATOR_ID = 1;
  public JMSMultiPortOutputOperator outputOperator;
  public static  OperatorContextTestHelper.TestIdOperatorContext testOperatorContext;
  public static final int HALF_BATCH_SIZE = 5;
  public static final int BATCH_SIZE = HALF_BATCH_SIZE * 2;
  public  final Random random = new Random();

  public static class TestMeta extends TestWatcher
  {
    @Override
    protected void starting(org.junit.runner.Description description)
    {
      logger.debug("Starting test {}", description.getMethodName());
      DefaultAttributeMap attributes = new DefaultAttributeMap();
      attributes.put(DAG.APPLICATION_ID, APP_ID);
      testOperatorContext = new TestIdOperatorContext(OPERATOR_ID, attributes);

      try {
        FileUtils.deleteDirectory(new File(FSPsuedoTransactionableStore.DEFAULT_RECOVERY_DIRECTORY));
      } catch (IOException ex) {
        throw new RuntimeException(ex);
      }
    }

    @Override
    protected void finished(org.junit.runner.Description description)
    {
      try {
        FileUtils.deleteDirectory(new File(FSPsuedoTransactionableStore.DEFAULT_RECOVERY_DIRECTORY));
      } catch (IOException ex) {
        throw new RuntimeException(ex);
      }
    }
  }

  @Rule
  public TestMeta testMeta = new TestMeta();

  @Test
  @SuppressWarnings("deprecation")
  public void testJMSMultiPortOutputOperator() throws Exception
  {
    // Setup a message listener to receive the message
    final ActiveMQMultiTypeMessageListener listener = new ActiveMQMultiTypeMessageListener();
    listener.setMaximumReceiveMessages(0);
    listener.setupConnection();
    listener.run();

    // Malhar module to send message
    JMSMultiPortOutputOperator node = new JMSMultiPortOutputOperator();
    // Set configuration parameters for JMS

    node.getConnectionFactoryProperties().put("userName", "");
    node.getConnectionFactoryProperties().put("password", "");
    node.getConnectionFactoryProperties().put("brokerURL", "tcp://localhost:61617");
    node.setAckMode("CLIENT_ACKNOWLEDGE");
    node.setClientId("Client1");
    node.setSubject("TEST.FOO");
    node.setMessageSize(255);
    node.setBatch(10);
    node.setTopic(false);
    node.setDurable(false);
    logger.debug("Before set store");
    node.setStore(new JMSTransactionableStore());
    logger.debug("After set store");
    logger.debug("Store class {}", node.getStore());
    node.setVerbose(true);

    node.setup(testOperatorContext);
    node.beginWindow(1);

    int i = 0;
    byte[] byteArray = {0,1,2,3};

    while (i < maxTuple) {
      String tuple = "testString " + (++i);
      node.inputStringTypePort.process(tuple);
      node.inputObjectPort.process(i);
      Map<String,Integer> map = new HashMap<String, Integer>();
      map.put(tuple, i);
      node.inputMapPort.process(map);
      node.inputByteArrayPort.process(byteArray);
      tupleCount++;
    }

    node.endWindow();
    node.teardown();

    final long emittedCount = 80;

    Thread.sleep(1000);

    // Check values send vs received
    Assert.assertEquals("Number of emitted tuples", emittedCount, listener.receivedData.size());
    logger.debug(String.format("Number of emitted tuples: %d", listener.receivedData.size()));
    Assert.assertEquals("First tuple", "testString 1", listener.receivedData.get(1));
    Assert.assertEquals("Second Tuple",1, listener.receivedData.get(2));
    Map<String,Object> testmap = (HashMap<String,Object>)listener.receivedData.get(3);
    Map<String,Integer> map = new HashMap<String, Integer>();
    map.put("testString 1", 1);
    Assert.assertEquals("Third Tuple",map,testmap);
    Assert.assertArrayEquals("Fourth tuple",byteArray, (byte[])listener.receivedData.get(4));
    listener.closeConnection();
  }

}


text:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright (c) 2014 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.xwalk.embedding.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.LinearLayout;

/*
 * This is a lightweight activity for tests that only require XWalk functionality.
 */
public class XWalkViewInternalTestRunnerActivity extends Activity {

    private LinearLayout mLinearLayout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

        mLinearLayout = new LinearLayout(this);
        mLinearLayout.setOrientation(LinearLayout.VERTICAL);
        mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        mLinearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));

        setContentView(mLinearLayout);
    }

    /**
     * Adds a view to the main linear layout.
     */
    public void addView(View view) {
        view.setLayoutParams(new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
        mLinearLayout.addView(view);
    }

    /**
     * Clears the main linear layout.
     */
    public void removeAllViews() {
        mLinearLayout.removeAllViews();
    }
}


text:
Has it been days? Weeks? You can't remember how long you've been standing at the door to the vault.
You can't remember the last time you slept
or ate,
or had a drop of water, for that matter.
But all of that is insignificant, in the presence of the untold fortunes that must lie just beyond the threshold.

But the door. It won't budge. It says it will answer only to the DUNGEON_MASTER.
Have you not shown your worth?
But more than that,
It demands to know your secrets.

Nothing you've tried has worked.
You've pled, begged, cursed, but the door holds steadfast, harshly judging your failed requests.

But with each failed attempt you start to notice more and more
that there's something peculiar about the way the door responds to you.

Maybe the door knows more than it's letting on.
...Or perhaps it's letting on more than it knows?

**NOTE: DO NOT USE AUTOMATED TOOLS**
Connect
http://chal1.swampctf.com:2694

---

## Solution:

We are presented with a login screen and since this is a web challenge, I tend to use my favourite http proxy: Burp. This allows me to view all traffic received/sent from the webserver. Sending `foobar` as username and `bazqux` as password, the UI pops up an alert stating "invalid credentials". Burp however intercepted the following response:

```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>No such user: foobar</pre>
</body>
</html>
```

The website and the challenge description both state that only the `DUNGEON_MASTER` may enter the vault, let's try that as username:

![only dungeon master may enter](files/only_dungeon_master.png?raw=true)

Wrong credentials again but the response was different this time:

```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>test_hash [972c5e1203896784a7cf9dd60acd443a1065e19ad5f92e59a9180c185f065c04] does not match real_hash[40f5d109272941b79fdf078a0e41477227a9b4047ca068fff6566104302169ce]</pre>
</body>
</html>
```

The passwords are hashed but showing the expected hash in the response is definitely not right. Turns out that the hashing algorithm is SHA256.
Next step is to figure out the original value of the hash. Since hashing algorithms are one way, there's no way to turn back unless we use bruteforce, rainbow tables or just google for websites with huge databases that have done this before. Some sites didn't contain the hash but the following did: https://crackstation.net/ . The original value for hash `40f5d109272941b79fdf078a0e41477227a9b4047ca068fff6566104302169ce`
is `smaug123`.

Get flag!

![get flag](files/flag.png?raw=true)

Btw, here's a nice tool for hash identification: https://github.com/psypanda/hashID


text:
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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.

/*******************************************************************************
 * NOTICE
 * The hal is not public api, don't use in application code.
 * See readme.md in soc/include/hal/readme.md
 ******************************************************************************/

// The HAL layer for SPI (common part)

// SPI HAL usages:
// 1. initialize the bus
// 2. initialize the DMA descriptors if DMA used
// 3. setup the clock speed (since this takes long time)
// 4. call setup_device to update parameters for the specific device
// 5. call setup_trans to update parameters for the specific transaction
// 6. prepare data to send, and prepare the receiving buffer
// 7. trigger user defined SPI transaction to start
// 8. wait until the user transaction is done
// 9. fetch the received data
// Parameter to be updated only during ``setup_device`` will be highlighted in the
// field comments.

#pragma once
#include "spi_ll.h"
#include <esp_err.h>
#include "soc/lldesc.h"

/**
 * Timing configuration structure that should be calculated by
 * ``spi_hal_setup_clock`` at initialization and hold. Filled into the
 * ``timing_conf`` member of the context of HAL before setup a device.
 */
typedef struct {
    spi_ll_clock_val_t clock_reg;   ///< Register value used by the LL layer
    int timing_dummy;               ///< Extra dummy needed to compensate the timing
    int timing_miso_delay;          ///< Extra miso delay clocks to compensate the timing
} spi_hal_timing_conf_t;

/**
 * Context that should be maintained by both the driver and the HAL.
 */
typedef struct {
    /* configured by driver at initialization */
    lldesc_t *dmadesc_tx; /**< Array of DMA descriptor used by the TX DMA.
                           *   The amount should be larger than dmadesc_n. The driver should ensure that
                           *   the data to be sent is shorter than the descriptors can hold.
                           */
    lldesc_t *dmadesc_rx; /**< Array of DMA descriptor used by the RX DMA.
                           *   The amount should be larger than dmadesc_n. The driver should ensure that
                           *   the data to be sent is shorter than the descriptors can hold.
                           */
    int dmadesc_n;        ///< The amount of descriptors of both ``dmadesc_tx`` and ``dmadesc_rx`` that the HAL can use.
    /*
     * Device specific, all these parameters will be updated to the peripheral
     * only when ``spi_hal_setup_device``. They may not get updated when
     * ``spi_hal_setup_trans``.
     */
    int mode;                           ///< SPI mode, device specific
    int cs_setup;                       ///< Setup time of CS active edge before the first SPI clock, device specific
    int cs_hold;                        ///< Hold time of CS inactive edge after the last SPI clock, device specific
    int cs_pin_id;                      ///< CS pin to use, 0-2, otherwise all the CS pins are not used. Device specific
    spi_hal_timing_conf_t *timing_conf; /**< Pointer to an structure holding
                                         *   the pre-calculated timing configuration for the device at initialization,
                                         *   device specific
                                         */
    struct {
        uint32_t sio : 1;           ///< Whether to use SIO mode, device specific
        uint32_t half_duplex : 1;   ///< Whether half duplex mode is used, device specific
        uint32_t tx_lsbfirst : 1;   ///< Whether LSB is sent first for TX data, device specific
        uint32_t rx_lsbfirst : 1;   ///< Whether LSB is received first for RX data, device specific
        uint32_t dma_enabled : 1;   ///< Whether the DMA is enabled, do not update after initialization
        uint32_t no_compensate : 1; ///< No need to add dummy to compensate the timing, device specific
        uint32_t as_cs  : 1;        ///< Whether the AS_CS feature is enabled, device specific
        uint32_t positive_cs : 1;   ///< Whether the postive CS feature is abled, device specific
    };//boolean configurations

    /*
     * Transaction specific (data), all these parameters will be updated to the
     * peripheral every transaction.
     */
    uint16_t cmd;           ///< Command value to be sent
    int cmd_bits;           ///< Length (in bits) of the command phase
    int addr_bits;          ///< Length (in bits) of the address phase
    int dummy_bits;         ///< Base length (in bits) of the dummy phase. Note when the compensation is enabled, some extra dummy bits may be appended.
    int tx_bitlen;          ///< TX length, in bits
    int rx_bitlen;          ///< RX length, in bits
    uint64_t addr;          ///< Address value to be sent
    uint8_t *send_buffer;   ///< Data to be sent
    uint8_t *rcv_buffer;    ///< Buffer to hold the receive data.
    spi_ll_io_mode_t io_mode;   ///< IO mode of the master

    /* auto generated at initialization, don't touch */
    spi_dev_t *hw;          ///< Beginning address of the peripheral registers.
} spi_hal_context_t;

/**
 * Init the peripheral and the context.
 *
 * @param hal Context of the HAL layer.
 * @param host_id Index of the SPI peripheral. 0 for SPI1, 1 for HSPI (SPI2) and 2 for VSPI (SPI3).
 */
void spi_hal_init(spi_hal_context_t *hal, int host_id);

/**
 * Deinit the peripheral (and the context if needed).
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_deinit(spi_hal_context_t *hal);

/**
 * Setup device-related configurations according to the settings in the context.
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_setup_device(const spi_hal_context_t *hal);

/**
 * Setup transaction related configurations according to the settings in the context.
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_setup_trans(const spi_hal_context_t *hal);

/**
 * Prepare the data for the current transaction.
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_prepare_data(const spi_hal_context_t *hal);

/**
 * Trigger start a user-defined transaction.
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_user_start(const spi_hal_context_t *hal);

/**
 * Check whether the transaction is done (trans_done is set).
 *
 * @param hal Context of the HAL layer.
 */
bool spi_hal_usr_is_done(const spi_hal_context_t *hal);

/**
 * Post transaction operations, mainly fetch data from the buffer.
 *
 * @param hal Context of the HAL layer.
 */
void spi_hal_fetch_result(const spi_hal_context_t *hal);

/*----------------------------------------------------------
 * Utils
 * ---------------------------------------------------------*/
/**
 * Get the configuration of clock and timing. The configuration will be used when ``spi_hal_setup_device``.
 *
 * It is highly suggested to do this at initialization, since it takes long time.
 *
 * @param hal Context of the HAL layer.
 * @param speed_hz Desired frequency.
 * @param duty_cycle Desired duty cycle of SPI clock
 * @param use_gpio true if the GPIO matrix is used, otherwise false
 * @param input_delay_ns Maximum delay between SPI launch clock and the data to
 *                      be valid. This is used to compensate/calculate the maximum frequency
 *                      allowed. Left 0 if not known.
 * @param out_freq Output of the actual frequency, left NULL if not required.
 * @param timing_conf Output of the timing configuration.
 *
 * @return ESP_OK if desired is available, otherwise fail.
 */
esp_err_t spi_hal_get_clock_conf(const spi_hal_context_t *hal, int speed_hz, int duty_cycle, bool use_gpio, int input_delay_ns, int *out_freq, spi_hal_timing_conf_t *timing_conf);

/**
 * Get the frequency actual used.
 *
 * @param hal Context of the HAL layer.
 * @param fapb APB clock frequency.
 * @param hz Desired frequencyc.
 * @param duty_cycle Desired duty cycle.
 */
int spi_hal_master_cal_clock(int fapb, int hz, int duty_cycle);

/**
 * Get the timing configuration for given parameters.
 *
 * @param eff_clk Actual SPI clock frequency
 * @param gpio_is_used true if the GPIO matrix is used, otherwise false.
 * @param input_delay_ns Maximum delay between SPI launch clock and the data to
 *                      be valid. This is used to compensate/calculate the maximum frequency
 *                      allowed. Left 0 if not known.
 * @param dummy_n Dummy cycles required to correctly read the data.
 * @param miso_delay_n suggested delay on the MISO line, in APB clocks.
 */
void spi_hal_cal_timing(int eff_clk, bool gpio_is_used, int input_delay_ns, int *dummy_n, int *miso_delay_n);

/**
 * Get the maximum frequency allowed to read if no compensation is used.
 *
 * @param gpio_is_used true if the GPIO matrix is used, otherwise false.
 * @param input_delay_ns Maximum delay between SPI launch clock and the data to
 *                      be valid. This is used to compensate/calculate the maximum frequency
 *                      allowed. Left 0 if not known.
 */
int spi_hal_get_freq_limit(bool gpio_is_used, int input_delay_ns);


text:
package play.libs.ws;

import java.io.IOException;

/**
 * This is the WS Client interface for Java.
 *
 * Most of the time you will access this through dependency injection, i.e.
 *
 *

 * import javax.inject.Inject;
 * import play.libs.ws.*;
 * import java.util.concurrent.CompletionStage;
 *
 * public class MyService {
 *   {@literal @}Inject WSClient ws;
 *
 *    // ...
 * }
 *
 *

 *
 * Please see https://www.playframework.com/documentation/latest/JavaWS for more details.
 */
public interface WSClient extends java.io.Closeable {

    /**
     * The underlying implementation of the client, if any.  You must cast the returned value to the type you want.
     *
     * @return the backing class.
     */
    Object getUnderlying();

    /**
     * Returns a WSRequest object representing the URL.  You can append additional
     * properties on the WSRequest by chaining calls, and execute the request to
     * return an asynchronous {@code Promise<WSResponse>}.
     *
     * @param url the URL to request
     * @return the request
     */
    WSRequest url(String url);

    /**
     * Closes this client, and releases underlying resources.
     *

     * Use this for manually instantiated clients.
     */
    void close() throws IOException;
}


text:
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from optparse import make_option
from sumo.models import *
from random import shuffle

class Command(BaseCommand):
    args = '<type>'
    help = 'Calculate points.'

    def handle(self, *args, **options):
        try:
            group_type = args[0]
        except IndexError:
            raise CommandError('See help.')

        if not group_type in ("normal", "final"):
            raise CommandError('See help.')

        if group_type == "normal":
            groups = SumoGroup.objects.filter(is_final=False)
            for group in groups:
                teams = SumoGroupTeam.objects.filter(group=group)
                teams.update(point=0, average=0)
                matches = SumoGroupMatch.objects.filter(group=group)

                # calculate point and average
                for match in matches:
                    home = teams.get(robot=match.home)
                    away = teams.get(robot=match.away)

                    if match.home_score == match.away_score:
                        home.point += 1
                        home.save()
                        away.point += 1
                        away.save()
                    elif match.home_score > match.away_score:
                        home.point += 3
                        home.average += match.home_score - match.away_score
                        home.save()
                        away.average += match.away_score - match.home_score
                        away.save()
                    else:
                        home.average += match.home_score - match.away_score
                        home.save()
                        away.point += 3
                        away.average += match.away_score - match.home_score
                        away.save()
        else:
            group = SumoGroup.objects.get(is_final=True)
            matches = SumoGroupMatch.objects.filter(group=group)
            teams = SumoGroupTeam.objects.filter(group=group)
            teams.update(point=0, average=0)
            # calculate point and average
            for match in matches:
                home = teams.get(robot=match.home)
                away = teams.get(robot=match.away)

                if match.home_score == match.away_score:
                    home.point += 1
                    home.save()
                    away.point += 1
                    away.save()
                elif match.home_score > match.away_score:
                    home.point += 3
                    home.average += match.home_score - match.away_score
                    home.save()
                    away.average += match.away_score - match.home_score
                    away.save()
                else:
                    home.average += match.home_score - match.away_score
                    home.save()
                    away.point += 3
                    away.average += match.away_score - match.home_score
                    away.save()
        self.stdout.write("Points calculated.")


text:
package au.edu.uts.eng.remotelabs.schedserver.ands.impl;

import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.ConfigDao;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.ProjectDao;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.SessionDao;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.entities.Collection;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.entities.Config;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.entities.Project;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.entities.Rig;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.entities.Session;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.listener.RigEventListener;
import au.edu.uts.eng.remotelabs.schedserver.dataaccess.listener.SessionEventListener;
import au.edu.uts.eng.remotelabs.schedserver.logger.Logger;
import au.edu.uts.eng.remotelabs.schedserver.logger.LoggerActivator;

/**
 * Generates Redbox metadata ingest files for auto-publish sessions.
 */
public class RedboxIngestFilesGenerator implements SessionEventListener, RigEventListener, Runnable
{
    /** The name of the database configuration property that stores the location
     *  of the ANDS datastore. */
    public static final String STORAGE_PROP_KEY = "ANDS_Storage_Mount";

    /** List of pending sessions to generate metadata from. */
    private final Map<Rig, Session> pendingSessions;

    /** Logger. */
    private Logger logger;

    public RedboxIngestFilesGenerator()
    {
        this.logger = LoggerActivator.getLogger();
        this.pendingSessions = new ConcurrentHashMap<Rig, Session>();
    }

    @Override
    public void eventOccurred(SessionEvent event, Session session, org.hibernate.Session db)
    {
        /* Handles session events that are relevant to generating research
         * metadata. Finishing a session checks tracks whether metadata
         * should potentially be generated. Assigning a session is when
         * metadata is actually generated as there will be no more pending
         * data file updates from the Rig Client. */
        switch (event)
        {
            case ASSIGNED:
                if (this.pendingSessions.containsKey(session.getRig()))
                {
                    /* A rig will no longer transfer data files for the previous
                     * session if it starting a new session as the only transmits
                     * data files during session. */
                    this.triggerGeneration(this.pendingSessions.remove(session.getRig()), db);
                }
                break;

            case FINISHED:
                /* and we only care about sessions that have a project
                 * that is published and auto-publishes metadata. */
                Project project = new ProjectDao(db).getLatestProject(session, true);
                if (project == null || project.getPublishTime() == null || !project.isAutoPublishCollections()) return;

                this.pendingSessions.put(session.getRig(), session);
                break;
        }
    }

    @Override
    public void eventOccurred(RigStateChangeEvent event, Rig rig, org.hibernate.Session db)
    {
        /* Handles rig events that are relevant to generating rig metadata. If
         * a rig gets unregistered then it will no longer send session data and
         * so we can safely generate metadata. */
        if (event == RigStateChangeEvent.REMOVED && this.pendingSessions.containsKey(rig))
        {
            /* We will not receive any more files from this rig so we are free to generate
             * metadata. */
            this.logger.debug("Generating metadata for rig " + rig.getName() + " because it is going offline or " +
            		"being unregistered.");
            this.triggerGeneration(this.pendingSessions.remove(rig), db);
        }
    }

    @Override
    public void run()
    {
        SessionDao dao = null;
        Date earliestFin = new Date(System.currentTimeMillis() - 600000);

        /* If a rig is infrequently used, there may not be events that allow
         * metadata generation to proceed. This is periodically run and will
         * generate metadata after 1 hour of the session finishing. */
        try
        {
            Iterator<Entry<Rig, Session>> it = this.pendingSessions.entrySet().iterator();
            while (it.hasNext())
            {
                Entry<Rig, Session> e = it.next();
                if (e.getValue().getRemovalTime().before(earliestFin))
                {
                    /* Session finished greater than an hour ago, so we can generate
                     * metadata. */
                    it.remove();
                    if (dao == null) dao = new SessionDao();
                    this.triggerGeneration(e.getValue(), dao.getSession());
                }

            }
        }
        finally
        {
            if (dao != null) dao.closeSession();
        }
    }

    /**
     * Trigger generation of data.
     *
     * @param session session to generate metadata from
     * @param db database session
     */
    private void triggerGeneration(Session session, org.hibernate.Session db)
    {
        /* We need to get a persistent instance of session. */
        session = (Session)db.load(Session.class, session.getId());

        Project project = new ProjectDao(db).getLatestProject(session, true);
        if (project == null) return;

        /* We only need to publish a collection if the session
         * produced files. */
        if (session.getFiles().size() == 0) return;

        this.logger.info("Auto publishing collection metadata for project '" + project.getActivity() + "'.");

        /* Add the collection. */
        Collection col = new Collection();
        col.setProject(project);
        col.setPublishTime(new Date());
        col.setUserManaged(false);
        col.setSessions(new HashSet<Session>(1));
        col.getSessions().add(session);

        db.beginTransaction();
        db.persist(col);
        db.getTransaction().commit();

        /* Get the storage location. */
        Config property = new ConfigDao(db).getConfig(STORAGE_PROP_KEY);
        if (property == null)
        {
            this.logger.warn("Unable to auto publish collection metadata for project '" + project.getActivity() + "'.");
            return;
        }

        /* Generate the metadata. */
        if (!new RedboxIngestFile().generateAndStore(col, property.getValue()))
        {
            this.logger.warn("Failed to generate metadata ingest data for project '" + project.getActivity() + "'. " +
            		"It will need to be manually created.");
        }
    }

}


text:
package com.thegrid.models;

import com.google.api.server.spi.config.ApiResourceProperty;

public class Etiqueta {

    @ApiResourceProperty(name = "nombre")
    private String _nombre;

    public Etiqueta() {

    }

    public Etiqueta(String nombre){
        _nombre = nombre;
    }
}


text:
#include <common.h>
#include <malloc.h>
#include <spi.h>
#include <pci.h>
#include <pci_ids.h>
#include <asm/io.h>

#include "ich.h"

#define SPI_OPCODE_WREN      0x06
#define SPI_OPCODE_FAST_READ 0x0b

struct ich_ctlr {
	pci_dev_t dev;		/* PCI device number */
	int ich_version;	/* Controller version, 7 or 9 */
	int ichspi_lock;
	int locked;
	uint8_t *opmenu;
	int menubytes;
	void *base;		/* Base of register set */
	uint16_t *preop;
	uint16_t *optype;
	uint32_t *addr;
	uint8_t *data;
	unsigned databytes;
	uint8_t *status;
	uint16_t *control;
	uint32_t *bbar;
	uint32_t *pr;		/* only for ich9 */
	uint8_t *speed;		/* pointer to speed control */
	ulong max_speed;	/* Maximum bus speed in MHz */
};

struct ich_ctlr ctlr;

static inline struct ich_spi_slave *to_ich_spi(struct spi_slave *slave)
{
	return container_of(slave, struct ich_spi_slave, slave);
}

static unsigned int ich_reg(const void *addr)
{
	return (unsigned)(addr - ctlr.base) & 0xffff;
}

static u8 ich_readb(const void *addr)
{
	u8 value = readb(addr);

	debug("read %2.2x from %4.4x\n", value, ich_reg(addr));

	return value;
}

static u16 ich_readw(const void *addr)
{
	u16 value = readw(addr);

	debug("read %4.4x from %4.4x\n", value, ich_reg(addr));

	return value;
}

static u32 ich_readl(const void *addr)
{
	u32 value = readl(addr);

	debug("read %8.8x from %4.4x\n", value, ich_reg(addr));

	return value;
}

static void ich_writeb(u8 value, void *addr)
{
	writeb(value, addr);
	debug("wrote %2.2x to %4.4x\n", value, ich_reg(addr));
}

static void ich_writew(u16 value, void *addr)
{
	writew(value, addr);
	debug("wrote %4.4x to %4.4x\n", value, ich_reg(addr));
}

static void ich_writel(u32 value, void *addr)
{
	writel(value, addr);
	debug("wrote %8.8x to %4.4x\n", value, ich_reg(addr));
}

static void write_reg(const void *value, void *dest, uint32_t size)
{
	memcpy_toio(dest, value, size);
}

static void read_reg(const void *src, void *value, uint32_t size)
{
	memcpy_fromio(value, src, size);
}

static void ich_set_bbar(struct ich_ctlr *ctlr, uint32_t minaddr)
{
	const uint32_t bbar_mask = 0x00ffff00;
	uint32_t ichspi_bbar;

	minaddr &= bbar_mask;
	ichspi_bbar = ich_readl(ctlr->bbar) & ~bbar_mask;
	ichspi_bbar |= minaddr;
	ich_writel(ichspi_bbar, ctlr->bbar);
}

int spi_cs_is_valid(unsigned int bus, unsigned int cs)
{
	puts("spi_cs_is_valid used but not implemented\n");
	return 0;
}

struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
		unsigned int max_hz, unsigned int mode)
{
	struct ich_spi_slave *ich;

	ich = spi_alloc_slave(struct ich_spi_slave, bus, cs);
	if (!ich) {
		puts("ICH SPI: Out of memory\n");
		return NULL;
	}

	/*
	 * Yes this controller can only write a small number of bytes at
	 * once! The limit is typically 64 bytes.
	 */
	ich->slave.max_write_size = ctlr.databytes;
	ich->speed = max_hz;

	return &ich->slave;
}

void spi_free_slave(struct spi_slave *slave)
{
	struct ich_spi_slave *ich = to_ich_spi(slave);

	free(ich);
}

/*
 * Check if this device ID matches one of supported Intel PCH devices.
 *
 * Return the ICH version if there is a match, or zero otherwise.
 */
static int get_ich_version(uint16_t device_id)
{
	if (device_id == PCI_DEVICE_ID_INTEL_TGP_LPC)
		return 7;

	if ((device_id >= PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MIN &&
	     device_id <= PCI_DEVICE_ID_INTEL_COUGARPOINT_LPC_MAX) ||
	    (device_id >= PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MIN &&
	     device_id <= PCI_DEVICE_ID_INTEL_PANTHERPOINT_LPC_MAX))
		return 9;

	return 0;
}

/* @return 1 if the SPI flash supports the 33MHz speed */
static int ich9_can_do_33mhz(pci_dev_t dev)
{
	u32 fdod, speed;

	/* Observe SPI Descriptor Component Section 0 */
	pci_write_config_dword(dev, 0xb0, 0x1000);

	/* Extract the Write/Erase SPI Frequency from descriptor */
	pci_read_config_dword(dev, 0xb4, &fdod);

	/* Bits 23:21 have the fast read clock frequency, 0=20MHz, 1=33MHz */
	speed = (fdod >> 21) & 7;

	return speed == 1;
}

static int ich_find_spi_controller(pci_dev_t *devp, int *ich_versionp)
{
	int last_bus = pci_last_busno();
	int bus;

	if (last_bus == -1) {
		debug("No PCI busses?\n");
		return -1;
	}

	for (bus = 0; bus <= last_bus; bus++) {
		uint16_t vendor_id, device_id;
		uint32_t ids;
		pci_dev_t dev;

		dev = PCI_BDF(bus, 31, 0);
		pci_read_config_dword(dev, 0, &ids);
		vendor_id = ids;
		device_id = ids >> 16;

		if (vendor_id == PCI_VENDOR_ID_INTEL) {
			*devp = dev;
			*ich_versionp = get_ich_version(device_id);
			return 0;
		}
	}

	debug("ICH SPI: No ICH found.\n");
	return -1;
}

static int ich_init_controller(struct ich_ctlr *ctlr)
{
	uint8_t *rcrb; /* Root Complex Register Block */
	uint32_t rcba; /* Root Complex Base Address */

	pci_read_config_dword(ctlr->dev, 0xf0, &rcba);
	/* Bits 31-14 are the base address, 13-1 are reserved, 0 is enable. */
	rcrb = (uint8_t *)(rcba & 0xffffc000);
	if (ctlr->ich_version == 7) {
		struct ich7_spi_regs *ich7_spi;

		ich7_spi = (struct ich7_spi_regs *)(rcrb + 0x3020);
		ctlr->ichspi_lock = ich_readw(&ich7_spi->spis) & SPIS_LOCK;
		ctlr->opmenu = ich7_spi->opmenu;
		ctlr->menubytes = sizeof(ich7_spi->opmenu);
		ctlr->optype = &ich7_spi->optype;
		ctlr->addr = &ich7_spi->spia;
		ctlr->data = (uint8_t *)ich7_spi->spid;
		ctlr->databytes = sizeof(ich7_spi->spid);
		ctlr->status = (uint8_t *)&ich7_spi->spis;
		ctlr->control = &ich7_spi->spic;
		ctlr->bbar = &ich7_spi->bbar;
		ctlr->preop = &ich7_spi->preop;
		ctlr->base = ich7_spi;
	} else if (ctlr->ich_version == 9) {
		struct ich9_spi_regs *ich9_spi;

		ich9_spi = (struct ich9_spi_regs *)(rcrb + 0x3800);
		ctlr->ichspi_lock = ich_readw(&ich9_spi->hsfs) & HSFS_FLOCKDN;
		ctlr->opmenu = ich9_spi->opmenu;
		ctlr->menubytes = sizeof(ich9_spi->opmenu);
		ctlr->optype = &ich9_spi->optype;
		ctlr->addr = &ich9_spi->faddr;
		ctlr->data = (uint8_t *)ich9_spi->fdata;
		ctlr->databytes = sizeof(ich9_spi->fdata);
		ctlr->status = &ich9_spi->ssfs;
		ctlr->control = (uint16_t *)ich9_spi->ssfc;
		ctlr->speed = ich9_spi->ssfc + 2;
		ctlr->bbar = &ich9_spi->bbar;
		ctlr->preop = &ich9_spi->preop;
		ctlr->pr = &ich9_spi->pr[0];
		ctlr->base = ich9_spi;
	} else {
		debug("ICH SPI: Unrecognized ICH version %d.\n",
		      ctlr->ich_version);
		return -1;
	}
	debug("ICH SPI: Version %d detected\n", ctlr->ich_version);

	/* Work out the maximum speed we can support */
	ctlr->max_speed = 20000000;
	if (ctlr->ich_version == 9 && ich9_can_do_33mhz(ctlr->dev))
		ctlr->max_speed = 33000000;

	ich_set_bbar(ctlr, 0);

	return 0;
}

void spi_init(void)
{
	uint8_t bios_cntl;

	if (ich_find_spi_controller(&ctlr.dev, &ctlr.ich_version)) {
		printf("ICH SPI: Cannot find device\n");
		return;
	}

	if (ich_init_controller(&ctlr)) {
		printf("ICH SPI: Cannot setup controller\n");
		return;
	}

	/*
	 * Disable the BIOS write protect so write commands are allowed.  On
	 * v9, deassert SMM BIOS Write Protect Disable.
	 */
	pci_read_config_byte(ctlr.dev, 0xdc, &bios_cntl);
	if (ctlr.ich_version == 9)
		bios_cntl &= ~(1 << 5);
	pci_write_config_byte(ctlr.dev, 0xdc, bios_cntl | 0x1);
}

int spi_claim_bus(struct spi_slave *slave)
{
	/* Handled by ICH automatically. */
	return 0;
}

void spi_release_bus(struct spi_slave *slave)
{
	/* Handled by ICH automatically. */
}

void spi_cs_activate(struct spi_slave *slave)
{
	/* Handled by ICH automatically. */
}

void spi_cs_deactivate(struct spi_slave *slave)
{
	/* Handled by ICH automatically. */
}

static inline void spi_use_out(struct spi_trans *trans, unsigned bytes)
{
	trans->out += bytes;
	trans->bytesout -= bytes;
}

static inline void spi_use_in(struct spi_trans *trans, unsigned bytes)
{
	trans->in += bytes;
	trans->bytesin -= bytes;
}

static void spi_setup_type(struct spi_trans *trans, int data_bytes)
{
	trans->type = 0xFF;

	/* Try to guess spi type from read/write sizes. */
	if (trans->bytesin == 0) {
		if (trans->bytesout + data_bytes > 4)
			/*
			 * If bytesin = 0 and bytesout > 4, we presume this is
			 * a write data operation, which is accompanied by an
			 * address.
			 */
			trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS;
		else
			trans->type = SPI_OPCODE_TYPE_WRITE_NO_ADDRESS;
		return;
	}

	if (trans->bytesout == 1) {	/* and bytesin is > 0 */
		trans->type = SPI_OPCODE_TYPE_READ_NO_ADDRESS;
		return;
	}

	if (trans->bytesout == 4)	/* and bytesin is > 0 */
		trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;

	/* Fast read command is called with 5 bytes instead of 4 */
	if (trans->out[0] == SPI_OPCODE_FAST_READ && trans->bytesout == 5) {
		trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;
		--trans->bytesout;
	}
}

static int spi_setup_opcode(struct spi_trans *trans)
{
	uint16_t optypes;
	uint8_t opmenu[ctlr.menubytes];

	trans->opcode = trans->out[0];
	spi_use_out(trans, 1);
	if (!ctlr.ichspi_lock) {
		/* The lock is off, so just use index 0. */
		ich_writeb(trans->opcode, ctlr.opmenu);
		optypes = ich_readw(ctlr.optype);
		optypes = (optypes & 0xfffc) | (trans->type & 0x3);
		ich_writew(optypes, ctlr.optype);
		return 0;
	} else {
		/* The lock is on. See if what we need is on the menu. */
		uint8_t optype;
		uint16_t opcode_index;

		/* Write Enable is handled as atomic prefix */
		if (trans->opcode == SPI_OPCODE_WREN)
			return 0;

		read_reg(ctlr.opmenu, opmenu, sizeof(opmenu));
		for (opcode_index = 0; opcode_index < ctlr.menubytes;
				opcode_index++) {
			if (opmenu[opcode_index] == trans->opcode)
				break;
		}

		if (opcode_index == ctlr.menubytes) {
			printf("ICH SPI: Opcode %x not found\n",
			       trans->opcode);
			return -1;
		}

		optypes = ich_readw(ctlr.optype);
		optype = (optypes >> (opcode_index * 2)) & 0x3;
		if (trans->type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS &&
		    optype == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS &&
		    trans->bytesout >= 3) {
			/* We guessed wrong earlier. Fix it up. */
			trans->type = optype;
		}
		if (optype != trans->type) {
			printf("ICH SPI: Transaction doesn't fit type %d\n",
			       optype);
			return -1;
		}
		return opcode_index;
	}
}

static int spi_setup_offset(struct spi_trans *trans)
{
	/* Separate the SPI address and data. */
	switch (trans->type) {
	case SPI_OPCODE_TYPE_READ_NO_ADDRESS:
	case SPI_OPCODE_TYPE_WRITE_NO_ADDRESS:
		return 0;
	case SPI_OPCODE_TYPE_READ_WITH_ADDRESS:
	case SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS:
		trans->offset = ((uint32_t)trans->out[0] << 16) |
				((uint32_t)trans->out[1] << 8) |
				((uint32_t)trans->out[2] << 0);
		spi_use_out(trans, 3);
		return 1;
	default:
		printf("Unrecognized SPI transaction type %#x\n", trans->type);
		return -1;
	}
}

/*
 * Wait for up to 6s til status register bit(s) turn 1 (in case wait_til_set
 * below is true) or 0. In case the wait was for the bit(s) to set - write
 * those bits back, which would cause resetting them.
 *
 * Return the last read status value on success or -1 on failure.
 */
static int ich_status_poll(u16 bitmask, int wait_til_set)
{
	int timeout = 600000; /* This will result in 6s */
	u16 status = 0;

	while (timeout--) {
		status = ich_readw(ctlr.status);
		if (wait_til_set ^ ((status & bitmask) == 0)) {
			if (wait_til_set)
				ich_writew((status & bitmask), ctlr.status);
			return status;
		}
		udelay(10);
	}

	printf("ICH SPI: SCIP timeout, read %x, expected %x\n",
	       status, bitmask);
	return -1;
}

/*
int spi_xfer(struct spi_slave *slave, const void *dout,
		unsigned int bitsout, void *din, unsigned int bitsin)
*/
int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
		void *din, unsigned long flags)
{
	struct ich_spi_slave *ich = to_ich_spi(slave);
	uint16_t control;
	int16_t opcode_index;
	int with_address;
	int status;
	int bytes = bitlen / 8;
	struct spi_trans *trans = &ich->trans;
	unsigned type = flags & (SPI_XFER_BEGIN | SPI_XFER_END);
	int using_cmd = 0;
	/* Align read transactions to 64-byte boundaries */
	char buff[ctlr.databytes];

	/* Ee don't support writing partial bytes. */
	if (bitlen % 8) {
		debug("ICH SPI: Accessing partial bytes not supported\n");
		return -1;
	}

	/* An empty end transaction can be ignored */
	if (type == SPI_XFER_END && !dout && !din)
		return 0;

	if (type & SPI_XFER_BEGIN)
		memset(trans, '\0', sizeof(*trans));

	/* Dp we need to come back later to finish it? */
	if (dout && type == SPI_XFER_BEGIN) {
		if (bytes > ICH_MAX_CMD_LEN) {
			debug("ICH SPI: Command length limit exceeded\n");
			return -1;
		}
		memcpy(trans->cmd, dout, bytes);
		trans->cmd_len = bytes;
		debug("ICH SPI: Saved %d bytes\n", bytes);
		return 0;
	}

	/*
	 * We process a 'middle' spi_xfer() call, which has no
	 * SPI_XFER_BEGIN/END, as an independent transaction as if it had
	 * an end. We therefore repeat the command. This is because ICH
	 * seems to have no support for this, or because interest (in digging
	 * out the details and creating a special case in the code) is low.
	 */
	if (trans->cmd_len) {
		trans->out = trans->cmd;
		trans->bytesout = trans->cmd_len;
		using_cmd = 1;
		debug("ICH SPI: Using %d bytes\n", trans->cmd_len);
	} else {
		trans->out = dout;
		trans->bytesout = dout ? bytes : 0;
	}

	trans->in = din;
	trans->bytesin = din ? bytes : 0;

	/* There has to always at least be an opcode. */
	if (!trans->bytesout) {
		debug("ICH SPI: No opcode for transfer\n");
		return -1;
	}

	if (ich_status_poll(SPIS_SCIP, 0) == -1)
		return -1;

	ich_writew(SPIS_CDS | SPIS_FCERR, ctlr.status);

	spi_setup_type(trans, using_cmd ? bytes : 0);
	opcode_index = spi_setup_opcode(trans);
	if (opcode_index < 0)
		return -1;
	with_address = spi_setup_offset(trans);
	if (with_address < 0)
		return -1;

	if (trans->opcode == SPI_OPCODE_WREN) {
		/*
		 * Treat Write Enable as Atomic Pre-Op if possible
		 * in order to prevent the Management Engine from
		 * issuing a transaction between WREN and DATA.
		 */
		if (!ctlr.ichspi_lock)
			ich_writew(trans->opcode, ctlr.preop);
		return 0;
	}

	if (ctlr.speed && ctlr.max_speed >= 33000000) {
		int byte;

		byte = ich_readb(ctlr.speed);
		if (ich->speed >= 33000000)
			byte |= SSFC_SCF_33MHZ;
		else
			byte &= ~SSFC_SCF_33MHZ;
		ich_writeb(byte, ctlr.speed);
	}

	/* See if we have used up the command data */
	if (using_cmd && dout && bytes) {
		trans->out = dout;
		trans->bytesout = bytes;
		debug("ICH SPI: Moving to data, %d bytes\n", bytes);
	}

	/* Preset control fields */
	control = ich_readw(ctlr.control);
	control &= ~SSFC_RESERVED;
	control = SPIC_SCGO | ((opcode_index & 0x07) << 4);

	/* Issue atomic preop cycle if needed */
	if (ich_readw(ctlr.preop))
		control |= SPIC_ACS;

	if (!trans->bytesout && !trans->bytesin) {
		/* SPI addresses are 24 bit only */
		if (with_address)
			ich_writel(trans->offset & 0x00FFFFFF, ctlr.addr);

		/*
		 * This is a 'no data' command (like Write Enable), its
		 * bitesout size was 1, decremented to zero while executing
		 * spi_setup_opcode() above. Tell the chip to send the
		 * command.
		 */
		ich_writew(control, ctlr.control);

		/* wait for the result */
		status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1);
		if (status == -1)
			return -1;

		if (status & SPIS_FCERR) {
			debug("ICH SPI: Command transaction error\n");
			return -1;
		}

		return 0;
	}

	/*
	 * Check if this is a write command atempting to transfer more bytes
	 * than the controller can handle. Iterations for writes are not
	 * supported here because each SPI write command needs to be preceded
	 * and followed by other SPI commands, and this sequence is controlled
	 * by the SPI chip driver.
	 */
	if (trans->bytesout > ctlr.databytes) {
		debug("ICH SPI: Too much to write. This should be prevented by the driver's max_write_size?\n");
		return -1;
	}

	/*
	 * Read or write up to databytes bytes at a time until everything has
	 * been sent.
	 */
	while (trans->bytesout || trans->bytesin) {
		uint32_t data_length;
		uint32_t aligned_offset;
		uint32_t diff;

		aligned_offset = trans->offset & ~(ctlr.databytes - 1);
		diff = trans->offset - aligned_offset;

		/* SPI addresses are 24 bit only */
		ich_writel(aligned_offset & 0x00FFFFFF, ctlr.addr);

		if (trans->bytesout)
			data_length = min(trans->bytesout, ctlr.databytes);
		else
			data_length = min(trans->bytesin, ctlr.databytes);

		/* Program data into FDATA0 to N */
		if (trans->bytesout) {
			write_reg(trans->out, ctlr.data, data_length);
			spi_use_out(trans, data_length);
			if (with_address)
				trans->offset += data_length;
		}

		/* Add proper control fields' values */
		control &= ~((ctlr.databytes - 1) << 8);
		control |= SPIC_DS;
		control |= (data_length - 1) << 8;

		/* write it */
		ich_writew(control, ctlr.control);

		/* Wait for Cycle Done Status or Flash Cycle Error. */
		status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1);
		if (status == -1)
			return -1;

		if (status & SPIS_FCERR) {
			debug("ICH SPI: Data transaction error\n");
			return -1;
		}

		if (trans->bytesin) {
			if (diff) {
				data_length -= diff;
				read_reg(ctlr.data, buff, ctlr.databytes);
				memcpy(trans->in, buff + diff, data_length);
			} else {
				read_reg(ctlr.data, trans->in, data_length);
			}
			spi_use_in(trans, data_length);
			if (with_address)
				trans->offset += data_length;
		}
	}

	/* Clear atomic preop now that xfer is done */
	ich_writew(0, ctlr.preop);

	return 0;
}

/*
 * This uses the SPI controller from the Intel Cougar Point and Panther Point
 * PCH to write-protect portions of the SPI flash until reboot. The changes
 * don't actually take effect until the HSFS[FLOCKDN] bit is set, but that's
 * done elsewhere.
 */
int spi_write_protect_region(uint32_t lower_limit, uint32_t length, int hint)
{
	uint32_t tmplong;
	uint32_t upper_limit;

	if (!ctlr.pr) {
		printf("%s: operation not supported on this chipset\n",
		       __func__);
		return -1;
	}

	if (length == 0 ||
	    lower_limit > (0xFFFFFFFFUL - length) + 1 ||
	    hint < 0 || hint > 4) {
		printf("%s(0x%x, 0x%x, %d): invalid args\n", __func__,
		       lower_limit, length, hint);
		return -1;
	}

	upper_limit = lower_limit + length - 1;

	/*
	 * Determine bits to write, as follows:
	 *  31     Write-protection enable (includes erase operation)
	 *  30:29  reserved
	 *  28:16  Upper Limit (FLA address bits 24:12, with 11:0 == 0xfff)
	 *  15     Read-protection enable
	 *  14:13  reserved
	 *  12:0   Lower Limit (FLA address bits 24:12, with 11:0 == 0x000)
	 */
	tmplong = 0x80000000 |
		((upper_limit & 0x01fff000) << 4) |
		((lower_limit & 0x01fff000) >> 12);

	printf("%s: writing 0x%08x to %p\n", __func__, tmplong,
	       &ctlr.pr[hint]);
	ctlr.pr[hint] = tmplong;

	return 0;
}


text:
/*
	Fetch a sky map (astro viewer) for a specific location input by the user.
	* The user feeds the application with the name of his/her observing location, e.g. a specific city.
	* Then the application makes use of the proper Google APIs, retrieving the necessary information, e.g. the
	  location coordinates [ lat, long ].
	* Finally, the application submits a http GET request with the proper query parameters fetching the sky
      map for the input location; sky map built by Dirk Matussek on server side.
*/

/*  Initialize application by fetching the sky map of Athens, Greece; set-up the proper image source address.
    Why this one ? Because it is my home city @ lat: 37.983810, lng: 23.727539 */
var sky_map_src = "http://www.astrobot.eu/skymapserver/skymap?type=png&size=580&colorset=0&lang=en&lon=23.7275&lat=37.9838&city=Athens%2C+Greece+%3A%0D%0A37.9838%C2%B0+N%2C+23.7275%C2%B0+E&timezone=UTC&deco=16399";

// Set the source attribute of the sky map image element after the document (DOM) is loaded.
$( document ).ready( function() {
	$( '#sky_map' ).attr( 'src', sky_map_src );
});

/* -------------------------------------------------------------------------------------------------- */

// Callback function.
function sky_map() {
	// A user can type the name of his/her observing location, such as the name of a city.
	var location = document.getElementById( 'location' );
	// Use the Place "Autocomplete" widget to provide a type-ahead search box.
	var location_autocomplete = new google.maps.places.Autocomplete( location );

	google.maps.event.addListener( location_autocomplete, 'place_changed', function() {
		// When the user selects an "Autocomplete" result, a "getPlace()" request is being sent.
		var place = location_autocomplete.getPlace();

		// User entered the name of a "Place" that was not suggested and
		// pressed the "Enter" key, or the "Place Details" request failed.
		if ( !place.geometry ) {
			$( "#about" ).modal();
			$( ".modal-body p" ).html( "No details available for input location : '" + place.name + "'" );

			return;
		}

		// The "place" has a geometry; save location's coordinates ( latitude, longitude ) and its name ( URL encoded ).
		var lat  = encodeURI( place.geometry.location.lat().toFixed( 4 ) );
		var lon  = encodeURI( place.geometry.location.lng().toFixed( 4 ) );
		var city = encodeURI( place.formatted_address )+ "+%3A%0D%0A" + lat + "%C2%B0+N%2C+" + lon + "%C2%B0+E";

		// Set-up the proper image source address for the input location.
		sky_map_src = "http://www.astrobot.eu/skymapserver/skymap?type=png&size=580&colorset=0&lang=en&lon=" + lon + "&lat=" + lat + "&city=" + city + "&timezone=UTC&deco=16399";

		// Set the source attribute of the sky map image element.
		$( '#sky_map' ).attr( 'src', sky_map_src );
	})
}

/* -------------------------------------------------------------------------------------------------- */


text:
<?php

namespace Good\Memory\SQL;

class Join
{
    public $tableNumberOrigin;
    public $fieldNameOrigin;
    public $tableNameDestination;
    public $tableNumberDestination;
    public $fieldNameDestination;

    public function __construct($tableNumberOrigin, $fieldNameOrigin, $tableNameDestination, $tableNumberDestination, $fieldNameDestination)
    {
        $this->tableNumberOrigin = $tableNumberOrigin;
        $this->fieldNameOrigin = $fieldNameOrigin;
        $this->tableNameDestination = $tableNameDestination;
        $this->tableNumberDestination = $tableNumberDestination;
        $this->fieldNameDestination = $fieldNameDestination;
    }
}

?>


text: GitFlowTutorial


text:
import r from 'rethinkdb';
import itemTypes from '../data/itemTypes.json';

export default async function(conn, ownerUserId) {
  for(let item of itemTypes) {
    item.owner = ownerUserId;
    await r.table('itemType').insert(item).run(conn);
  }
  console.log(`Loaded ${itemTypes.length} item types into the db owned by ${ownerUserId}`);

  return itemTypes.length;
}


text:
A helper for setting up Sequelize models and their associations while avoiding issues with circular dependencies.

# Install

```
npm install --save sequelize-registry
```

# Usage

Create a models folder and a model definition file. The directory name may be anything you choose.

```
$ mkdir my_entity_definitions
$ vim my_entity_definitions/blog_post.js
```

Example:

### `blog_post.js`

```
var Sequelize = require('sequelize');

module.exports = {
  name: 'blog_post',
  cols: {
    title: Sequelize.STRING
  },
  refs: [
    // see API docs below ...
  ],
  opts: {
    // see API docs below ...
  }
};
```

Initialize the registry by pointing the init function to your models directory as indicated in the API documentation below. The absolute path to your model definitions folder must be provided. Then proceed to use sequelize as you would normally.

Example:

### `app.js`

```
var Sequelize = require('sequelize');
var defineModels = require('sequelize-registry').defineModels;

var sequelize = new Sequelize(...);
defineModels(sequelize, '/home/johndoe/myproject/my_entity_definitions');

// after running the defineModels function, you may then
// retrieve any model from the sequelize instance as usual
var BlogPost = sequelize.model('blog_post');

// the retrieved model should automatically have any
// defined associations available for use as would
// be expected by defining the associations manually
BlogPost.findById(3).then(function(post) {
  var comments = post.getComments();
  // ...
});
```

## Example

Here is an example of a simple blog.

### `models/post.js`

```
var Sequelize = require('sequelize');

module.exports = {
  // this will define a model with sequelize.define('blog_post', ...)
  name: 'blog_post',

  cols: {
    title: Sequelize.STRING,
    body: Sequelize.TEXT,
    author: Sequelize.STRING
  },

  refs: [
    {
      type: 'hasMany',
      model: 'post_comment'
    }
  ],

  opts: {
    underscored: true,
    freezeTableName: true
  }
};
```

### `models/comment.js`

```
var Sequelize = require('sequelize');

module.exports = {
  // this will define a model with sequelize.define('post_comment', ...)
  name: 'post_comment',

  cols: {
    post_id: Sequelize.INTEGER,
    body: Sequelize.TEXT,
    author: Sequelize.STRING
  },

  refs: [
    {
      type: 'belongsTo',
      model: 'blog_post',

      // The config property is optional, but may be specified if extra
      // configuration options are desired. Valid properties of the config
      // object are any options valid for that Sequelize association type.
      config: {
        foreignKey: 'post_id',
        targetKey: 'id'
      }
    }
  ],

  opts: {
    underscored: true,
    freezeTableName: true
  }
};
```

### Results

The above model definition files, when used with this package, will result in the equivalent of:

```
sequelize.define('blog_post', {
  title: Sequelize.STRING,
  body: Sequelize.TEXT,
  author: Sequelize.STRING
}, {
  underscored: true,
  freezeTableName: true
});

sequelize.define('post_comment', {
  title: Sequelize.STRING,
  body: Sequelize.TEXT,
  author: Sequelize.STRING
}, {
  underscored: true,
  freezeTableName: true
});

sequelize.model('blog_post').hasMany(sequelize.model('post_comment'));
sequelize.model('post_comment').belongsTo(sequelize.model('blog_post'), {
  foreignKey: 'post_id',
  targetKey: 'id'
});
```

# API

## Init Method

The initialization method is called `defineModels`.

```
defineModels(sequelizeInstance, modelsDirectoryPath);

  @param sequelizeInstance Object REQUIRED An instance of Sequelize instantiated with `new` e.g. `var sequelizeInstance = new Sequelize(...)`
  @param modelsDirectoryPath String REQUIRED Absolute path to the directory where model definition files are stored.
  @return undefined
```

Example:

```
var path = require('path');
var Sequelize = require('sequelize');

var defineModels = require('sequelize-registry').defineModels;

var sequelize = new Sequelize('postgres://admin:supersecret@localhost:5432/myblog');
var modelsDir = path.join(__dirname, 'models');

defineModels(sequelize, modelsDir);
```

## Model Definitions

Model definitions mostly mirror the exact same options you would normally pass to `sequelize.define`. Consult the Sequelize documentation for further reference.

Model definitions are "Plain Old JavaScript Objects" (POJOs) with properties corresponding to associations and the various parameters of `sequelize.define`.

Example:

```
var definition = {
  // properties go here
};

module.exports = definition;
```

The `definition` object will be used to define a sequelize model via the `sequelize.define()` method.

Briefly, the `definition` object will be used as follows:

```
sequelize.define(definition.name, definition.cols, definition.opts || {});
```

### Configuration Property Reference

#### DEFINITION PROPERTIES

A definition may have the following properties.

#### `definition.name` (String) REQUIRED

The `name` property will be passed as the first parameter to `sequelize.define()`

Example:

```
var definition = {
  name: 'blog_post'
};

module.exports = definition;
```

#### `definition.cols` (Object) REQUIRED

The `cols` property will be passed as the second parameter to `sequelize.define()`. The options for the `cols` property are the exact same options as may be passed to Sequelize for defining columns in a model. Consult the Sequelize documentation for further information.

Example:

```
var Sequelize = require('sequelize');

var definition = {
  cols: {
    name: {
      type: Sequelize.STRING,
      allowNull: false,
      defaultValue: 'Untitled'
    },
    price: Sequelize.INTEGER
  }
};

module.exports = definition;
```

#### `definition.opts` (Object) OPTIONAL

The `opts` property, if present, will be passed as the third parameter to `sequelize.define()`.  The options for the `opts` property are the exact same options as may be passed to Sequelize for defining the extra configuration options of a model. Consult the Sequelize documentation for further information.

Example:

```
var definition = {
  opts: {
    timestamps: false
  }
};

module.exports = definition;
```

#### `definition.refs` (Array of Objects) OPTIONAL

The `refs` property will be used to define associations. The `refs` property must be an array of objects. Each object in the array is a definition for an assocation to another model, also called a `ref`. See the `ref` properties documentation below.

Example:

```
var definition = {
  refs: [
    {
      // this is an individual ref object
      // ref options go here
    }
  ]
};

module.exports = definition;
```

#### REF PROPERTIES

A ref may have the following properties.

#### `ref.type` (String) REQUIRED

The `type` property of a ref will be used to determine the type of association.

Available options for a ref `type` are the names of the Sequelize association methods:

  - `hasOne`
  - `hasMany`
  - `belongsTo`
  - `belongsToMany`

Example:

```
var definition = {
  refs: [
    {
      type: 'hasMany',
      // ...
    }
  ]
};

module.exports = definition;
```

### `ref.model` (String) REQUIRED

The `model` property of a ref will be used to retrieve the associated model, by name, using `sequelize.model(ref.model)`.

Example:

```
var definition = {
  refs: [
    {
      type: 'belongsTo',
      model: 'category'
    }
  ]
};

module.exports = definition;
```

### `ref.config` (Object) OPTIONAL

The `config` property of a ref will be passed as the second argument to the association method. The keys of the object are any keys valid for the standard options accepted by Sequelize for that association type. As with a standard Sequelize association, this property may be omitted if the defaults association configuration options are acceptable.

Examples:

```
var definition = {
  refs: [
    {
      type: 'belongsTo',
      model: 'user',
      config: {
        foreignKey: 'uuid',
        targetKey: 'session_id',
        as: 'profile'
      }
    }
  ]
};

module.exports = definition;
```

```
var definition = {
  refs: [
    {
      type: 'belongsToMany',
      model: 'tag',
      config: {
        through: 'PostTags'
      }
    }
  ]
};

module.exports = definition;
```

# Known Limitations

 - Nested model directories are not supported yet. Model definition files must use a flat file structure.
 - Validation of definition structure exists but errors in configuration are still possible with any options passed directly to Sequelize.


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/songInstance"
    android:layout_width="match_parent"
    android:layout_height="@dimen/list_height"
    android:layout_centerVertical="true"
    android:background="?selectableItemBackground"
    android:gravity="center">

    <ImageView
        android:id="@+id/handle"
        android:layout_width="@dimen/drag_handle_size"
        android:layout_height="@dimen/drag_handle_size"
        android:src="@drawable/ic_drag_handle"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/handle"
        android:layout_toEndOf="@+id/handle"
        android:layout_toStartOf="@+id/instancePlayingIndicator"
        android:layout_toLeftOf="@+id/instancePlayingIndicator">

        <TextView
            android:id="@+id/instanceTitle"
            style="@style/listTitleText"
            android:paddingLeft="0dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:singleLine="true" />

        <TextView
            android:id="@+id/instanceDetail"
            style="@style/listDetailText"
            android:paddingLeft="0dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:singleLine="true" />

    </LinearLayout>

    <ImageView
        android:id="@+id/instancePlayingIndicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp"
        android:src="@drawable/ic_play_circle_filled_24dp"
        android:tint="?attr/colorAccent"
        android:layout_toLeftOf="@+id/instanceMore"
        android:layout_toStartOf="@+id/instanceMore"
        android:layout_centerVertical="true"/>

    <ImageView
        android:id="@+id/instanceMore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:scaleType="center"
        android:src="@drawable/abc_ic_menu_moreoverflow_mtrl_alpha"
        android:tint="?textColorPrimary"
        android:background="?selectableItemBackgroundBorderless"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

</RelativeLayout>


text:
#ifndef _COMPFILE_H
#define _COMPFILE_H

#include "compiler.h"

#define LINESIZE 8192
#define GLOBAL_BUFSIZE  4096

#define SZMAX_STORENAME	80
#define SZMAX_GROUPNAME 80
#define SZMAX_DEADKEYNAME 80
#define SZMAX_ERRORTEXT 512
#define SZMAX_VKDICTIONARYNAME 80

#define MAX_WARNINGS 100

#define T_COMMENT	 1			// A comment line
#define	T_KEYTOKEY	 2			// A rule line
#define T_BLANK		 3			// A blank line

#define T_W_START	 4			// Start of easily matched line types
#define T_STORE		 4			// A store line
#define T_VERSION	 5			// A 'VERSION 3.2/3.1/3.0' line
#define	T_NAME		 6			// A 'NAME "xxxx"' line
#define T_BITMAP	 7			// A 'BITMAP bmpfile' line
#define T_HOTKEY	 8			// A 'HOTKEY "^%+C"' line
#define T_BEGIN		 9			// A 'begin > use(xxxx)' line
#define T_GROUP		10			// A 'group(xxxx)' line
#define T_MATCH		11			// A 'match > "XXXX"' line
#define T_NOMATCH	12			// A 'nomatch > "XXXX"' line
#define T_SHIFT		13			// A 'SHIFT FREES CAPS' line
#define T_CAPSON	14			// A 'CAPS ON ONLY' line
#define T_CAPSOFF	15			// A 'CAPS ALWAYS OFF' line
#define T_LANGUAGE	16			// A 'LANGUAGE xxxh, xxh' line
#define T_LAYOUT	17			// A 'LAYOUT xxxxh' line
#define T_COPYRIGHT 18			// A 'COPYRIGHT "so and so"' line
#define T_MESSAGE   19			// A 'MESSAGE "so and so"' line
#define T_LANGUAGENAME 20		// A 'LANGUAGENAME "xxxx"' line
#define T_BITMAPS	21			// An unused 'BITMAPS' line (version 3.x)
#define T_W_END		21          // End of easily matched rule types

#define T_UNKNOWN	99			// Unrecognized line type (illegal line)

#define GDS_CUTLEAD	0x01		// GetDelimitedString: cut leading spaces
#define GDS_CUTFOLL	0x02		// GetDelimitedString: cut following spaces

#define GXS_LINE	0x00		// GetExtendedString error: in a "line"
#define GXS_RULE	0x01		// GetExtendedString error: in a "rule"
#define GXS_STORE	0x02		// GetExtendedString error: in a "store"

enum FileStoreType { FST_STORE, FST_OPTION, FST_RESERVED };

struct FILE_STORE {
	DWORD dwSystemID;
	WCHAR szName[SZMAX_STORENAME];	// the name of the store
	PWSTR dpString;	    				// from start of store structure
  //FileStoreType fstType;
  BOOL fIsStore;
  BOOL fIsReserved;
  BOOL fIsOption;
  BOOL fIsDebug;
  BOOL fIsCall;
  int line; // TODO: int vs dword, line vs Line (see FILE_KEY, FILE_GROUP)
	};

typedef FILE_STORE *PFILE_STORE;

struct FILE_KEY {
	WCHAR   Key;            // WCHAR for consistency; only a byte used however
	DWORD   Line;
	DWORD   ShiftFlags;
	PWSTR  dpOutput;		// from start of key structure
	PWSTR  dpContext;		// from start of key structure
	};

typedef FILE_KEY *PFILE_KEY;

struct FILE_GROUP {
	WCHAR		szName[SZMAX_GROUPNAME];
	PFILE_KEY	dpKeyArray;         // address of first item in key array, from start of group structure
	PWSTR      dpMatch;             // from start of group structure
	PWSTR      dpNoMatch;           // from start of group structure
	DWORD cxKeyArray;               // in array items
	BOOL  fUsingKeys;               // group(xx) [using keys] <-- specified or not
  BOOL  fReadOnly;                // group(xx) [readonly] <-- specified or not
  DWORD Line;
};

typedef FILE_GROUP *PFILE_GROUP;

struct FILE_DEADKEY
{
	WCHAR szName[SZMAX_DEADKEYNAME];
};

typedef FILE_DEADKEY *PFILE_DEADKEY;

struct FILE_VKDICTIONARY
{
  WCHAR szName[SZMAX_VKDICTIONARYNAME];
};

typedef FILE_VKDICTIONARY *PFILE_VKDICTIONARY;

struct FILE_KEYBOARD {
	DWORD KeyboardID;			// as stored in HKEY_LOCAL_MACHINE//system//currentcontrolset//control//keyboard layouts

	DWORD version;				// keyboard file version with VERSION keyword

	PFILE_STORE dpStoreArray;	// address of first item in store array, from start of store structure
	PFILE_GROUP dpGroupArray;	// address of first item in group array, from start of group structure

	DWORD cxStoreArray;			// in number of items
	DWORD cxGroupArray;			// in number of items
	DWORD StartGroup[2];		// index of starting groups [ANSI=0, Unicode=1]

	DWORD dwHotKey;				// standard windows hotkey (hiword=shift/ctrl/alt stuff, loword=vkey)

	WCHAR szName[SZMAX_KEYBOARDNAME];			// Keyboard layout name
	WCHAR szLanguageName[SZMAX_LANGUAGENAME];	// Language name
	WCHAR szCopyright[SZMAX_COPYRIGHT];			// Copyright information
	WCHAR szMessage[SZMAX_MESSAGE];				// General information about the keyboard
	PBYTE lpBitmap;
	DWORD dwBitmapSize;
	DWORD dwFlags;					// Flags for the keyboard file

	DWORD currentGroup;				// temp - current processing group
	DWORD currentStore;				// temp - current processing store
	DWORD cxDeadKeyArray;
	PFILE_DEADKEY dpDeadKeyArray;	// temp - dead key array
  DWORD cxVKDictionary;
  PFILE_VKDICTIONARY dpVKDictionary; // temp - virtual key dictionary
	};

typedef FILE_KEYBOARD *PFILE_KEYBOARD;

/*
  These size values are used in unit tests to ensure
  that the structure sizes correspond precisely across
  compilers (pas and c++).
*/

const DWORD sz_FILE_STORE = sizeof(FILE_STORE);
const DWORD sz_FILE_KEY = sizeof(FILE_KEY);
const DWORD sz_FILE_GROUP = sizeof(FILE_GROUP);
const DWORD sz_FILE_DEADKEY = sizeof(FILE_DEADKEY);
const DWORD sz_FILE_VKDICTIONARY = sizeof(FILE_VKDICTIONARY);
const DWORD sz_FILE_KEYBOARD = sizeof(FILE_KEYBOARD);

struct COMPMSG {
	char szText[SZMAX_ERRORTEXT];
	DWORD Line;
	DWORD dwMsgCode;
	};

typedef COMPMSG *PCOMPMSG;

struct COMPILEMESSAGES {
	int nMessages;
	int nErrors;

	PCOMPMSG cm;

	DWORD fatalCode;
	char szFatalText[SZMAX_ERRORTEXT];

	DWORD currentLine;
	};

typedef COMPILEMESSAGES *PCOMPILEMESSAGES;

/*
struct TVersion
{
	//int MinVersion;	// 0x0500 usually
	//int CompilerVersion[4];
	//int MinCompilerVersion[4];
	int KeyboardVersion;	// 0x0500 usually
};

extern TVersion FVersionInfo;
*/

/*
#define bstrcpy(c,d)	(LPBYTE)strcpy((LPSTR)(c),(LPSTR)(d))
#define bstrlen(c)		strlen((LPSTR)(c))
#define bstrcmp(c,d)	strcmp((LPSTR)(c),(LPSTR)(d))
#define bstrncmp(c,d,n)	strncmp((LPSTR)(c),(LPSTR)(d),(n))
#define bstrnicmp(c,d,n)	strnicmp((LPSTR)(c),(LPSTR)(d),(n))
#define bstricmp(c,d)	stricmp((LPSTR)(c),(LPSTR)(d))
#define bstrchr(c,ch)   (LPBYTE)strchr((LPSTR)(c),(char)ch)
#define bstrncpy(c,d,n)	(LPBYTE)strncpy((LPSTR)(c),(LPSTR)(d),(n))
#define bstrtok(c,d)	(LPBYTE)strtok((LPSTR)(c),(LPSTR)(d))
#define bstrcat(c,d)	(LPBYTE)strcat((LPSTR)(c),(LPSTR)(d))
#define bstrncat(c,d,n)	(LPBYTE)strncat((LPSTR)(c),(LPSTR)(d),(n))
#define bstrrev(c)		(LPBYTE)strrev((LPSTR)(c))
#define batoi(c)		atoi((LPSTR)(c))
#define bstrtol(c,d,n)	strtol((LPSTR)(c),(LPSTR *)(d),(n))
*/

#endif	// _COMPFILE_H


text:
Resgen::FacetManager.facet(:mvp => [:gwt]) do |facet|
  facet.enhance(Resgen::Model::UibinderFile) do
    def pre_init
      @abstract_ui_component_name = nil
    end

    attr_writer :abstract_ui_component_name

    def abstract_ui_component_name
      @abstract_ui_component_name || "Abstract#{uibinder_file.name}"
    end

    def qualified_abstract_ui_component_name
      "#{uibinder_file.asset_directory.name}.#{abstract_ui_component_name}"
    end

    java_artifact(:abstract_uibinder_component,
                  :abstract_ui_component,
                  :guard => '!uibinder_file.gwt.cell?')
  end
end


text:
Function Invoke-MySQL {
	Param(
		[Parameter(
		Mandatory = $true,
		ParameterSetName = '',
		ValueFromPipeline = $true)]
		[string]$Query,
		[Parameter(Mandatory = $true)][string]$User,
		[Parameter(Mandatory = $true)][String]$Passw,
		[Parameter(Mandatory = $true)][String]$Server,
		[Parameter(Mandatory = $true)][String]$Database,
		[String]$Port = 3306
	)
	$ConnectionString = "server=" + $Server + ";port=3306;uid=" + $User + ";pwd=" + $Passw + ";database=" + $Database

	Try {
		[void][System.Reflection.Assembly]::LoadWithPartialName("MySql.Data")
		$Connection = New-Object MySql.Data.MySqlClient.MySqlConnection($ConnectionString)
		$Connection.Open()

		$Command = New-Object MySql.Data.MySqlClient.MySqlCommand($Query, $Connection)
		$DataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($Command)
		$DataSet = New-Object System.Data.DataSet
		$RecordCount = $DataAdapter.Fill($DataSet, "data")
		$DataSet.Tables[0]
	}

	Catch {
		$_
	}

	Finally {
		$Connection.Close()
	}
}