Example #1
0
	SharedString KObject::DisplayString(int levels)
	{
		std::stringstream ss;

		if (levels == 0)
		{
			ss << "<KObject at " << this << ">";
		}
		else
		{
			SharedStringList props = this->GetPropertyNames();
			ss << "{";
			for (size_t i = 0; i < props->size(); i++)
			{
				SharedValue prop = this->Get(props->at(i));
				SharedString disp_string = prop->DisplayString(levels);

				ss << " " << *(props->at(i))
				    << " : " << *disp_string << ",";
			}

			if (props->size() > 0) // Erase last comma
				ss.seekp((int)ss.tellp() - 1);

			ss << "}";
		}

		return new std::string(ss.str());
	}
	void AppBinding::StdErr(const ValueList& args, SharedValue result)
	{
		for (size_t c = 0; c < args.size(); c++)
		{
			SharedValue arg = args.at(c);
			if (arg->IsString())
			{
				const char *s = arg->ToString();
				std::cerr << s;
			}
			else
			{
				SharedString ss = arg->DisplayString();
				std::cerr << *ss;
			}
		}
		std::cerr << std::endl;
	}