Example #1
0
Value SuThread::Name(BuiltinArgs& args) {
	args.usage("Thread.Name() or Thread.Name(string)");
	if (Value name = args.getValue("string", Value()))
		Fibers::set_name(name.gcstr());
	args.end();
	return new SuString(Fibers::get_name());
}
Example #2
0
Value SuThread::Sleep(BuiltinArgs& args) {
	args.usage("Thread.Sleep(ms)");
	int ms = args.getint("ms");
	args.end();
	Fibers::sleep(ms);
	return Value();
}
Example #3
0
Value Sha256::Update(BuiltinArgs& args) {
	args.usage("sha256.Update(string)");
	gcstring s = args.getgcstr("string");
	args.end();

	update(s);
	return this;
}
Example #4
0
Value BuiltinClass<SuThread>::callclass(BuiltinArgs& args) {
	args.usage("Thread(block)");
	Value func = args.getValue("block");
	args.end();
	persist_if_block(func);
	Fibers::create(thread, new ThreadInfo(func));
	return Value();
}
Example #5
0
Value Md5::Update(BuiltinArgs& args)
	{
	args.usage("usage: md5.Update(string)");
	gcstring s = args.getgcstr("string");
	args.end();

	update(s);
	return this;
	}
Example #6
0
Value SuAdler32::Update(BuiltinArgs& args)
	{
	args.usage("usage: adler32.Update(string)");
	gcstring s = args.getgcstr("string");
	args.end();

	update(s);
	return this;
	}
Example #7
0
Value BuiltinClass<Sha256>::callclass(BuiltinArgs& args) {
	args.usage("Sha256(@strings)");
	Sha256* a = new BuiltinInstance<Sha256>();
	if (!args.hasUnnamed())
		return a;
	while (Value x = args.getNextUnnamed())
		a->update(x.gcstr());
	return new SuString(a->value());
}
Example #8
0
Value BuiltinClass<SuAdler32>::callclass(BuiltinArgs& args)
	{
	args.usage("usage: Adler32(@strings)");
	SuAdler32* a = new BuiltinInstance<SuAdler32>();
	if (! args.hasUnnamed())
		return a;
	while (Value x = args.getNextUnnamed())
		a->update(x.gcstr());
	return a->value;
	}
Example #9
0
Value SuThread::List(BuiltinArgs& args) {
	args.usage("Thread.List()").end();
	SuObject* list = new SuObject();
	Fibers::foreach_fiber_info([list](gcstring name, const char* status) {
		list->putdata(new SuString(name), status);
	});
	return list;
}
Example #10
0
Value BuiltinClass<Md5>::instantiate(BuiltinArgs& args)
	{
	args.usage("usage: new Md5()");
	args.end();
	return new BuiltinInstance<Md5>();
	}
Example #11
0
Value Md5::ValueFn(BuiltinArgs& args)
	{
	args.usage("usage: md5.Value()");
	args.end();
	return new SuString(value());
	}
Example #12
0
Value SuAdler32::ValueFn(BuiltinArgs& args)
	{
	args.usage("usage: adler32.Value()");
	args.end();
	return value;
	}
Example #13
0
Value BuiltinClass<SuAdler32>::instantiate(BuiltinArgs& args)
	{
	args.usage("usage: new Adler32()");
	args.end();
	return new BuiltinInstance<SuAdler32>();
	}
Example #14
0
Value Sha256::ValueFn(BuiltinArgs& args) {
	args.usage("sha256.Value()").end();
	return new SuString(value());
}
Example #15
0
Value BuiltinClass<Sha256>::instantiate(BuiltinArgs& args) {
	args.usage("new Sha256()").end();
	return new BuiltinInstance<Sha256>();
}
Example #16
0
Value SuThread::Count(BuiltinArgs& args) {
	args.usage("Thread.Count()").end();
	return Fibers::size();
}