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
import io; | |
class Color { | |
// Keeps numerical RGB value of the color | |
protected property value; | |
// Internal list of color names and RGB pairs. | |
protected property names = hash[[ | |
"white" : 0xFFFFFF, |
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
import io; | |
class Color { | |
// Keeps numerical RGB value of the color | |
protected property value; | |
// Internal list of color names and RGB pairs. | |
protected property names = hash[[ | |
"white" : 0xFFFFFF, |
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
➜ saffire git:(cpuid) cat test.sf | |
import io,cpu; | |
io.println("CPU Info:"); | |
io.println(" Vendor: ", cpu.vendor()); | |
io.println(" Vendor ID: ", cpu.vendorId()); | |
io.println(" Brand: ", cpu.brand()); | |
io.println(" Codename: ", cpu.codename()); |
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
➜ webserver git:(moreup) ✗ sf webserver.sf 0.0.0.0 4000 | |
> Serving Saffire on 0.0.0.0:4000 | |
> Press CTRL-C to quit. | |
> Accepting connections... | |
O> GET / HTTP/1.1 | |
_ _ | |
| | (_) | |
_____ _____ ___ _ __ | |_ _ ___ _ __ | |
/ _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \ | |
| __/> < (_| __/ |_) | |_| | (_) | | | | |
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
JSON 1: {"foo":"bar","foo2":"bar2","foo3":"bar3"} | |
JSON 2: {"foo":"bar","foo2":"bar2","foo3":"bar3"} | |
JSON 3: { "foo": "bar", "foo2": "bar2", "foo3": "bar3" } | |
JSON 4: {"foo":"bar","foo2":"bar2","foo3":"bar3"} | |
JSON 4: { | |
"foo":"bar", | |
"foo2":"bar2", | |
"foo3":"bar3" | |
} | |
JSON 5: { |
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
#include "saffire.h" | |
#include <stdio.h> | |
Saffire::Object greet_method(Saffire::Arguments &args) { | |
Saffire::String s; | |
args.parse("s", &s); | |
return Saffire::String( std::string("hello ") + s.value() ); | |
} |
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
SAFFIRE_MODULE_METHOD(file, write) { | |
t_file_object *file_obj = (t_file_object *)self; | |
t_string_object *str_obj; | |
if (! object_parse_arguments(SAFFIRE_METHOD_ARGS, "s", &str_obj)) { | |
return NULL; | |
} | |
long bytes_written = fwrite(str_obj->data.value->val, 1, str_obj->data.value->len, file_obj->data.fp); |
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
import io; | |
import file; | |
f = file.open("test.txt", "r"); | |
io.print("FILE 1: ", f.path(), " => ", f.fileNo(), "\n"); | |
f2 = file.open("test.txt", "r"); | |
io.print("FILE 2: ", f2.path(), " => ", f2.fileNo(), "\n"); | |
io.dump(f.stat()); |
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
interface DataInterface { | |
public method getData(); | |
} | |
class NullableData implements DataInterface { | |
} | |
class chartA implements DataInterface { | |
} | |
class chartB implements DataInterface { |
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
namespace Application; | |
class Controller { | |
protected $app; | |
function __construct($app) { | |
$this->app = $app; | |
} |