This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Trashman::BaseRecord | |
| abstract def callstack : CallStack | |
| abstract def allocations : Uint64 | |
| abstract def deallocations : Uint64 | |
| abstract def untrack : Void | |
| abstract def type_str : String | |
| end | |
| module Trashman::Statistics | |
| @@records = [] of BaseRecord |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module CrystalClear | |
| macro included | |
| def test_invariant_contracts(method="") | |
| {% verbatim do %} | |
| {% for c in Contracts::INVARIANTS %} | |
| {% str = c[0]; condition = c[1] %} | |
| test = CrystalClear.perform_test(self) {{condition}} | |
| if !test | |
| Contracts.on_contract_fail(:invariant, {{str}}, {{@type}}, method) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fetch_method(klass : U) forall U | |
| comp = fetch_method? klass # Return type is BaseClass | Nil | |
| # I want to return with the type provided to find | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Boleite::GUI | |
| class Window < Container | |
| # ... | |
| Cute.signal header_drag(pos : Vector2f) | |
| def initialize | |
| # ... | |
| state_change.on &->update_header_size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WidgetInput < InputReceiver | |
| def initialize(widget) | |
| register WidgetLeftClick ->widget.left_click.emit | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Boleite::GUI | |
| abstract class Widget | |
| Cute.signal mouse_enter | |
| Cute.signal mouse_leave | |
| Cute.signal mouse_over(x : Float64, y : Float64) | |
| Cute.signal left_click(x : Float64, y : Float64) | |
| Cute.signal right_click(x : Float64, y : Float64) | |
| Cute.signal key_pressed | |
| Cute.signal key_released | |
| Cute.signal text_entered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Container < Widget | |
| includes CrystalClear | |
| @children = [] of Widget | |
| requires child.parent.nil? | |
| ensures @children.count child == 1 | |
| def add(child) | |
| @children << child | |
| child.parent = self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| include CrystalClear | |
| def on_contract_fail(contract, condition, method) # some args with info | |
| # Default behaviour but you can overide it in this method | |
| raise CrystalClear::ContractError.new("Failed #{self.class} #{contract} contract: #{condition}" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Papierkorb suggestion | |
| class Foo | |
| include CrystalClear | |
| requires var > 5 | |
| ensures result.query? | |
| assert def foo # Apply contract semantics to method | |
| # Code | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| font = Boleite::Font.new app.graphics, "/usr/share/fonts/TTF/arial.ttf" | |
| text = Boleite::Text.new font, "Hello world?\nHello new line!" | |
| text.size = 150u32 | |
| text.default_color = Boleite::Color.blue | |
| text.position = Boleite::Vector2f.new 10.0, 10.0 | |
| text.formatter.add /(Hello)/, Boleite::Color.green | |
| text.formatter.add /(\!|\?)/, Boleite::Color.black | |
| renderer.draw text |
NewerOlder