示例#1
0
void BuiltinSymbols::ImportExtProperties(AnalysisResultPtr ar,
                                         VariableTablePtr dest,
                                         ClassInfo *cls) {
  ClassInfo::PropertyVec src = cls->getPropertiesVec();
  for (auto it = src.begin(); it != src.end(); ++it) {
    ClassInfo::PropertyInfo *pinfo = *it;
    int attrs = pinfo->attribute;
    ModifierExpressionPtr modifiers(
      new ModifierExpression(BlockScopePtr(), LocationPtr()));
    if (attrs & ClassInfo::IsPrivate) {
      modifiers->add(T_PRIVATE);
    } else if (attrs & ClassInfo::IsProtected) {
      modifiers->add(T_PROTECTED);
    }
    if (attrs & ClassInfo::IsStatic) {
      modifiers->add(T_STATIC);
    }

    dest->add(pinfo->name.data(),
              typePtrFromDataType(pinfo->type, Type::Variant),
              false, ar, ExpressionPtr(), modifiers);
  }
}
void VariableSerializer::write(CObjRef v) {
  if (!v.isNull() && m_type == JSON) {
    Array props = v->o_toArray();
    ClassInfo::PropertyVec properties;
    ClassInfo::GetClassProperties(properties, v->o_getClassName());
    for (ClassInfo::PropertyVec::const_iterator iter = properties.begin();
         iter != properties.end(); ++iter) {
      if ((*iter)->attribute & ClassInfo::IsProtected) {
        props.remove((*iter)->name);
      }
    }
    // Remove private props
    for (ArrayIter it(props); !it.end(); it.next()) {
      if (it.first().toString().charAt(0) == '\0') {
        props.remove(it.first());
      }
    }
    setObjectInfo(v->o_getClassName(), v->o_getId());
    props.serialize(this);
  } else {
    v.serialize(this);
  }
}