コード例 #1
0
ファイル: xdebug_var.cpp プロジェクト: Dream-Seeker/hhvm
// Exports the given xml key value pair as an xml child of the given parent node
static void xdebug_array_element_export_xml_node(xdebug_xml_node& parent,
                                                 const char* parentName,
                                                 const Variant& key,
                                                 const Variant& val,
                                                 XDebugExporter& exporter) {
  String key_str = key.toString();
  Variant full_name = init_null();

  // Construct the full name
  StringBuffer buf;
  if (parentName != nullptr)  {
    if (key.isInteger()) {
      buf.printf("%s[%s]", parentName, key_str.data());
    } else {
      buf.printf("%s['%s']", parentName, key_str.data());
    }
    full_name = buf.detach();
  }
  const char* full_name_str = full_name.isNull() ?
    nullptr : full_name.toString().data();

  // Recursively add the child
  xdebug_xml_node* child = xdebug_var_export_xml_node(xdstrdup(key_str.data()),
                                                      xdstrdup(full_name_str),
                                                      nullptr,
                                                      val, exporter);
  xdebug_xml_add_child(&parent, child);
}
コード例 #2
0
static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           int lineFocus0, int charFocus0, int lineFocus1,
                           int charFocus1, const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  TRACE(7, "debugger_base:append_line_no\n");
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                   colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == nullptr) {
    if (line) {
      if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                     colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        ++line;
        sb.append(begin, p - begin);
        if (color) sb.append(ANSI_COLOR_END);
        sb.append('\n');
        if (colorLineNo) color_line_no(sb, line, lineFocus0, lineFocus1,
                                       colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
コード例 #3
0
static void append_line_no(StringBuffer &sb, const char *text,
                           int &line, const char *color, const char *end,
                           const char **palette =
                           DebuggerClient::DefaultCodeColors) {
  const char *colorLineNo = palette[CodeColorLineNo * 2];
  const char *endLineNo = palette[CodeColorLineNo * 2 + 1];

  // beginning
  if (line && sb.empty()) {
    if (colorLineNo) sb.append(colorLineNo);
    sb.printf(DebuggerClient::LineNoFormat, line);
    if (endLineNo) sb.append(endLineNo);
  }

  // ending
  if (text == NULL) {
    if (line) {
      if (colorLineNo) sb.append(colorLineNo);
      sb.append("(END)\n");
      if (endLineNo) sb.append(endLineNo);
    }
    return;
  }

  if (color) sb.append(color);

  if (line == 0) {
    sb.append(text);
  } else {
    const char *begin = text;
    const char *p = begin;
    for (; *p; p++) {
      if (*p == '\n') {
        sb.append(begin, p - begin);
        if (end) sb.append(end);
        sb.append('\n');
        if (colorLineNo) sb.append(colorLineNo);
        sb.printf(DebuggerClient::LineNoFormat, ++line);
        if (endLineNo) sb.append(endLineNo);
        if (color) sb.append(color);
        begin = p + 1;
      }
    }
    if (p - begin > 0) {
      sb.append(begin, p - begin);
    }
  }

  if (end) sb.append(end);
}
コード例 #4
0
ファイル: bson.cpp プロジェクト: divrt/mongo-hhvm-driver
/* {{{ Special objects that implement MongoDB\BSON\Serializable */
void VariantToBsonConverter::_convertSerializable(bson_t *bson, const char *key, Object v)
{
	Variant result;
	Array   properties;
	TypedValue args[1] = { *(Variant(v)).asCell() };
	Class *cls;
	Func *m;

	cls = v.get()->getVMClass();
	m = cls->lookupMethod(s_MongoDriverBsonSerializable_functionName.get());
	
	g_context->invokeFuncFew(
		result.asTypedValue(),
		m,
		v.get(),
		nullptr,
		1, args
	);

	if ( ! (
			result.isArray() || 
			(result.isObject() && result.toObject().instanceof(s_stdClass))
		)
	) {
		StringBuffer buf;
		buf.printf(
			"Expected %s::%s() to return an array or stdClass, %s given",
			cls->nameStr().c_str(),
			s_MongoDriverBsonSerializable_functionName.data(),
			result.isObject() ? result.toObject()->getVMClass()->nameStr().c_str() : HPHP::getDataTypeString(result.getType()).data()
		);
		Variant full_name = buf.detach();

		throw MongoDriver::Utils::throwUnexpectedValueException((char*) full_name.toString().c_str());
	}

	/* Convert to array so that we can handle it well */
	properties = result.toArray();

	if (v.instanceof(s_MongoDriverBsonPersistable_className)) {
		const char *class_name = cls->nameStr().c_str();
		Object obj = createMongoBsonBinaryObject(
			(const uint8_t *) class_name,
			strlen(class_name),
			(bson_subtype_t) 0x80
		);
		properties.add(String(s_MongoDriverBsonODM_fieldName), obj);
	}

	convertDocument(bson, key, result.isObject() ? Variant(Variant(properties).toObject()) : Variant(properties));
}
コード例 #5
0
ファイル: eval.cpp プロジェクト: ArPharazon/hiphop-php
String Eval::location_to_string(const Location *loc) {
  StringBuffer buf;
  buf.printf("%s:%d:%d", loc->file, loc->line1, loc->char1);
  return buf.detach();
}
コード例 #6
0
ファイル: parser.cpp プロジェクト: kreshano/hiphop-php
String Location::toString() const {
  StringBuffer buf;
  buf.printf("%s:%d:%d", this->file, this->line1, this->char1);
  return buf.detach();
}