string NameBuilder(wsdlParser.qname qn) { if (m_namemap.ContainsKey(qn.ExpandedName)) { return((string)m_namemap[qn.ExpandedName]); } string name = vcProject.safeClassName(qn.localname); string suffix = ""; int num = 0; string newName = name; while (m_namemap.ContainsValue(newName)) { suffix = ""; while (num > 0) { suffix = suffix + ((num % 26) + 'A'); num = num / 26; } ++num; newName = name + suffix; } m_namemap[qn.ExpandedName] = newName; return(newName); }
public Parameter(CppType cppType, string cppName, wsdlParser.qname xmlName, bool isHeader, IdlDirection dir) { populateWords(); this.cppType = cppType; this.cppName = safeCppName(cppName); this.xmlName = xmlName; this.isHeader = isHeader; this.idlDirection = dir; }
internal CppType mapType(wsdlParser.qname type) { if (m_sf.IsAnyType(type.localname, type.@namespace)) { return(CppType.Create((int)VarEnum.VT_VARIANT, "VARIANT", CppType.ArrayType.NotArray, CppType.TypeStyle.Primative, false, type)); } CppType t = null; try { Object ct = m_sf.FindComType(type.localname, type.@namespace); if (ct is int) { return(CppType.TypeFromVariantType((int)ct, type)); } return(CppType.Create((int)VarEnum.VT_VARIANT, "VARIANT", type)); } catch (Exception ex) { // todo, catch specific exception // todo, handle complex types. // Console.WriteLine(type.ExpandedName + " : " + ex.Message); } // handle non-primitive types // first off, check the cache t = (CppType)m_typesCache[type.ExpandedName]; if (t != null) { return(t); } // look for a schema definition MSXML2.ISchema schema = SchemaForType(type); MSXML2.ISchemaType oType = (MSXML2.ISchemaType)schema.types.itemByQName(type.localname, type.@namespace); if (oType is MSXML2.ISchemaComplexType) { t = CreateComplexType(type, (MSXML2.ISchemaComplexType)oType); } else if (oType.enumeration.length > 0) { t = CreateEnumType(type, oType); } else if ((oType.itemType == MSXML2.SOMITEMTYPE.SOMITEM_SIMPLETYPE) && (oType.derivedBy == MSXML2.SCHEMADERIVATIONMETHOD.SCHEMADERIVATIONMETHOD_RESTRICTION)) { t = CreateRestrictedSimpleType(type, oType); } else { throw new ApplicationException("Sorry, this type " + type.ExpandedName + " is not yet supported"); } return(t); }
public SerializerWriter(vcProject project, wsdlParser.qname serializerQName, string serializerName, string serializeeName) { ProjectClass cls = project.AddClass(serializerName, new Interface("ISoapSerializer", "IUnknown")); m_hdr = cls.header.Create(); m_impl = cls.impl.Create(); m_cppName = serializerName; m_serializeeName = serializeeName; InitFiles(); m_deserA = new ArrayList(); m_deserE = new ArrayList(); m_deserC = new ArrayList(); }
// note that sc.getSchema(someNS) fails when xs:import is used, as imported types will appear in the // schema that imported them, not in the original schmea (which isn't in the schema collection) private MSXML2.ISchema SchemaForType(wsdlParser.qname qn) { MSXML2.IXMLDOMSchemaCollection2 sc = m_wsdl.Schemas; MSXML2.ISchema s; for (int idx = 0; idx < sc.length; idx++) { s = sc.getSchema(sc[idx]); foreach (MSXML2.ISchemaType t in s.types) { if ((t.name == qn.localname) && (t.namespaceURI == qn.@namespace)) { return(s); } } } throw new ArgumentException("Unable to find schema for " + qn.ExpandedName); }
CppType HandleArrayType(wsdlParser.qname typeName, MSXML2.ISchemaComplexType typeDesc) { MSXML2.ISchemaComplexType ct = typeDesc; MSXML2.ISchemaItem encArrayType = ct.attributes.itemByQName("arrayType", Consts.SOAP_11_ENCODING); string wsdlArrayType = null; for (int idx = 0; idx < encArrayType.unhandledAttributes.length; idx++) { if ((encArrayType.unhandledAttributes.getLocalName(idx) == "arrayType") && (encArrayType.unhandledAttributes.getURI(idx) == Consts.WSDL_URL)) { wsdlArrayType = encArrayType.unhandledAttributes.getValue(idx); break; } } if (wsdlArrayType == null) { throw new ApplicationException("SOAP-ENC:Array derivation must include a wsdl:arrayType attribute"); } wsdlParser.qname qn = new wsdlParser.qnameClass(); int lastColon = wsdlArrayType.LastIndexOf(":"); qn.@namespace = wsdlArrayType.Substring(0, lastColon); int rank = wsdlArrayType.IndexOf("[", lastColon); qn.localname = wsdlArrayType.Substring(lastColon + 1, rank - lastColon - 1); CppType itemType = mapType(qn); CppType t = CppType.CreateArray(itemType, CppType.ArrayType.Encoded, false, qn); m_typesCache.Add(typeName.ExpandedName, t); if (t.Style == CppType.TypeStyle.Object) { string qnln = m_factory.IdForString(qn.localname, IdType.Localname); string qnns = m_factory.IdForString(qn.@namespace, IdType.Namespace); string psad = m_factory.IdForString("PocketSOAP.ArrayDeserializer.1", IdType.ProgId); string psas = m_factory.IdForString("PocketSOAP.ArraySerializer.1", IdType.ProgId); m_factory.Add(string.Format("m_sf->Deserializer({0}, {1}, VARIANT_TRUE, VT_UNKNOWN, {2});", qnln, qnns, psad)); m_factory.Add(string.Format("m_sf->Serializer(VT_UNKNOWN | VT_ARRAY, {0}, {1}, {2});", qnln, qnns, psas)); } return(t); }
void AddElementsToContainer(wsdlParser.qname xmlName, MSXML2.ISchemaModelGroup smg, ComplexTypeWriter ctw, SerializerWriter sw) { foreach (MSXML2.ISchemaParticle particle in smg.particles) { if ((particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_ALL) || (particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_SEQUENCE)) { AddElementsToContainer(xmlName, particle as MSXML2.ISchemaModelGroup, ctw, sw); } else if (particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_ELEMENT) { MSXML2.ISchemaElement e = (MSXML2.ISchemaElement)particle; CppType itemType = CppType.FromParticle(this, particle); string itemName = vcProject.safeClassName(particle.name); ctw.AddPropertyField(itemName, itemType); sw.AddElement(itemName, itemType, e); } } }
public static CppType TypeFromVariantType(int vt, wsdlParser.qname xmlType) { CppType t = null; Mapping m = (Mapping)mappings[(VarEnum)vt]; if (m != null) { t = Create((int)m.vt, m.name, xmlType, m.style); } else { t = Create(vt, "VARIANT", xmlType, TypeStyle.Primative); } if ((vt & (int)VarEnum.VT_ARRAY) > 0) { return(Factory(t, ArrayType.Encoded, TypeStyle.Primative, false, xmlType)); } return(t); }
CppType CreateComplexType(wsdlParser.qname typeName, MSXML2.ISchemaComplexType typeDesc) { // look to see if its a section 5 encoded array first foreach (MSXML2.ISchemaType bt in typeDesc.baseTypes) { if ((bt.name == "Array") && (bt.namespaceURI == Consts.SOAP_11_ENCODING)) { return(HandleArrayType(typeName, typeDesc)); } } CppType t = CppType.Create((int)VarEnum.VT_UNKNOWN, NameBuilder(typeName), CppType.ArrayType.NotArray, CppType.TypeStyle.Object, false, typeName); // a qname for the serializer class wsdlParser.qname tSerQName = new wsdlParser.qnameClass(); tSerQName.localname = "s" + typeName.localname; tSerQName.@namespace = "http://serializers.schemas.pocketsoap.com/"; // register the type mapping now, incase there is some recursive nonsense going on m_typesCache[typeName.ExpandedName] = t; // a complexTypeWriter ComplexTypeWriter ctw = new ComplexTypeWriter(m_project, typeName.ExpandedName, t.CppName); // a SerializerWriter SerializerWriter sw = new SerializerWriter(m_project, tSerQName, NameBuilder(tSerQName), t.CppName); MSXML2.ISchemaComplexType complexType = typeDesc; MSXML2.ISchemaModelGroup smg = complexType.contentModel; // walk through each contained particle // attributes foreach (MSXML2.ISchemaAttribute attr in complexType.attributes) { wsdlParser.qname ptype = new wsdlParser.qnameClass(); ptype.@namespace = attr.type.namespaceURI; ptype.localname = attr.type.name; CppType itemType = mapType(ptype); string itemName = vcProject.safeClassName(attr.name); ctw.AddPropertyField(itemName, itemType); sw.AddAttribute(itemName, itemType, attr, ptype); } AddElementsToContainer(typeName, smg, ctw, sw); ctw.Complete(); sw.Complete(); // add type registrations string serProgId = m_project.ProjectName + "." + sw.SerializerName; string clsProgId = m_project.ProjectName + "." + ctw.ComplexTypeName; string clsItfIID = string.Format("CComVariant(OLESTR(\"{{{0}}}\"))", ctw.InterfaceIID); m_factory.Add(string.Format("m_sf->Serializer({0}, CComBSTR(OLESTR(\"{1}\")), CComBSTR(OLESTR(\"{2}\")), CComBSTR(OLESTR(\"{3}\")));", clsItfIID, typeDesc.name, typeDesc.namespaceURI, serProgId)); string typeLN = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.localname); string typeNS = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.@namespace); m_factory.Add(string.Format("m_sf->Deserializer({0}, {1}, VARIANT_FALSE, CComVariant(OLESTR(\"{2}\")), {3});", typeLN, typeNS, clsProgId, makeBstr(serProgId))); return(t); }
private static CppType Factory(int vt, string name, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) { if (name == "BSTR") { return(new CppTypeBSTR(vt, name, array, style, optional, xmlType)); } if (name == "DATE") { return(new CppTypeDate(vt, name, array, style, optional, xmlType)); } if (name == "VARIANT_BOOL") { return(new CppTypeBool(vt, name, array, style, optional, xmlType)); } if (style == TypeStyle.Object) { return(new CppTypeInterface(vt, name, array, style, optional, xmlType)); } return(new CppType(vt, name, array, style, optional, xmlType)); }
private CppType genDocLiteralType(wsdlParser.qname elementName) { // todo return(CppType.Create("VARIANT")); }
protected CppType(int vt, string name, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) { this.cppName = name; this.Array = array; this.Style = style; this.Optional = optional; this.XmlType = xmlType; this.vt = vt; }
CppType CreateRestrictedSimpleType(wsdlParser.qname typeName, MSXML2.ISchemaType typeDesc) { throw new ApplicationException("Sorry, this type " + typeName.ExpandedName + " is not yet supported"); }
public static CppType Create(int vt, string name, wsdlParser.qname xmlType, TypeStyle style) { return(Factory(vt, name, ArrayType.NotArray, style, false, xmlType)); }
public static CppType Create(int vt, string name, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) { return(Factory(vt, name, array, style, optional, xmlType)); }
// todo: fix all the VarEnum/int casting nonsense private static CppType Factory(CppType arrayItem, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) { return(new CppTypeArray((int)VarEnum.VT_ARRAY, arrayItem, array, style, optional, xmlType)); }
public void AddAttribute(string propertyName, CppType propType, MSXML2.ISchemaAttribute attr, wsdlParser.qname xmlType) { getValItf(); if (m_firstAttr) { m_firstAttr = false; m_impl.WriteLine("\tCComQIPtr<ISerializerOutput2> dest2(dest);"); m_deserA.Add("\tCComQIPtr<ISoapDeSerializerAttributes2> a(Attributes);"); m_deserA.Add("\tCComVariant av;"); } // serializer m_impl.WriteLine("\t{0} {1};", propType.CppName, propertyName); m_impl.WriteLine("\t_HR(obj->get_{0}(&{1}));", propertyName, propertyName); m_impl.WriteLine("\t_HR(dest2->SerializeAttribute(CComVariant({0}), CComBSTR(OLESTR(\"{1}\")), CComBSTR(OLESTR(\"{2}\"))));", propertyName, attr.name, attr.namespaceURI); // de-serializer m_deserA.Add(string.Format("\t_HR(a->get_AsValue(CComBSTR(OLESTR(\"{0}\")), CComBSTR(OLESTR(\"{1}\")), CComBSTR(OLESTR(\"{2}\")), CComBSTR(OLESTR(\"{3}\")), &av);", attr.name, attr.namespaceURI, xmlType.localname, xmlType.@namespace)); m_deserA.Add(string.Format("\t_HR(m_obj->put_{1}(av);")); m_deserA.Add("\tav.Clear();"); }
public static CppType CreateArray(CppType arrayItem, ArrayType array, bool optional, wsdlParser.qname xmlType) { return(Factory(arrayItem, array, TypeStyle.Primative, optional, xmlType)); }
internal CppTypeInterface(int vt, string name, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) : base(vt, name, array, style, optional, xmlType) { }
public CppTypeArray(int vt, CppType arrayItem, ArrayType array, TypeStyle style, bool optional, wsdlParser.qname xmlType) : base(vt, "SAFEARRAY *", array, style, optional, xmlType) { this.arrayItemType = arrayItem; }