[Qtcsharp-patches] Bugtussle/src/Writers CWriter.cs,1.13,1.14 KylixWriter.cs,1.15,1.16
Status: Inactive
Brought to you by:
manyoso
|
From: Andreas H. <ah...@us...> - 2005-06-12 20:53:00
|
Update of /cvsroot/qtcsharp/Bugtussle/src/Writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4052/src/Writers Modified Files: CWriter.cs KylixWriter.cs Log Message: Index: KylixWriter.cs =================================================================== RCS file: /cvsroot/qtcsharp/Bugtussle/src/Writers/KylixWriter.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** KylixWriter.cs 14 May 2005 15:31:09 -0000 1.15 --- KylixWriter.cs 12 Jun 2005 20:52:51 -0000 1.16 *************** *** 63,69 **** --- 63,71 ---- basicTypes.Add("int", "Integer"); basicTypes.Add("signed int", "Integer"); + basicTypes.Add("signed", "Integer"); basicTypes.Add("uint", "Cardinal"); basicTypes.Add("unsigned int", "Cardinal"); + basicTypes.Add("unsigned", "Cardinal"); basicTypes.Add("short", "Smallint"); *************** *** 185,188 **** --- 187,192 ---- reservedNames.Add("raise"); reservedNames.Add("Result"); + + reservedNames.Add("qs"); } *************** *** 212,221 **** cw.WriteLine(" {$MODE DELPHI}"); cw.WriteLine(" {$ASMMODE Intel}"); - //cw.WriteLine(" {$DEFINE QSW} // extended WideString support is disabled due to a method-implementation bug (fpc 1.9.5)"); cw.WriteLine("{$ELSE}"); cw.WriteLine(" {$A4,B-,C-,D-,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}"); if(weakPackageUnit) cw.WriteLine(" {$WEAKPACKAGEUNIT ON}"); - //cw.WriteLine(" {$DEFINE QSW}"); cw.WriteLine("{$ENDIF}"); cw.WriteLine(); --- 216,223 ---- *************** *** 304,310 **** cw.WriteLine("LibWrapperIntf = '{0}c.dll';", api.ApiName ); cw.WriteLine("{$ELSE}"); ! cw.WriteLine("LibWrapperIntf = '{0}.so';", api.CLibName ); cw.WriteLine("{$ENDIF MSWINDOWS}"); - cw.WriteLine("//LibWrapper = ''; // see initialization section"); cw.WriteLine("LibWrapper = LibWrapperIntf;"); cw.Indent--; --- 306,311 ---- cw.WriteLine("LibWrapperIntf = '{0}c.dll';", api.ApiName ); cw.WriteLine("{$ELSE}"); ! cw.WriteLine("LibWrapperIntf = '{0}.so.1';", api.CLibName ); cw.WriteLine("{$ENDIF MSWINDOWS}"); cw.WriteLine("LibWrapper = LibWrapperIntf;"); cw.Indent--; *************** *** 355,359 **** cw.Indent++; cw.WriteLine("{{$INCLUDE {0}ForwardClasses.inc}}", ApiName); ! BeginFile(ApiName + "ForwardClasses.inc"); try { --- 356,360 ---- cw.Indent++; cw.WriteLine("{{$INCLUDE {0}ForwardClasses.inc}}", ApiName); ! BeginFile(ApiName + "ForwardClasses.inc"); try { *************** *** 517,524 **** foreach(string key in api.Defines.Keys) { string value = (string)api.Defines[key]; string ret; ! if ( value == "" ) ! list.Add(String.Format("{0} = True;", key)); else if(value[0] == '"' || value[0] == '\'') --- 518,535 ---- foreach(string key in api.Defines.Keys) { + bool hasFunction = false; + foreach(Function f in api.GlobalNamespace.Functions) + { + if (String.Compare(key, ResolveClassName(f.Name), /*ignore case=*/true ) == 0) + { + Console.WriteLine(" " + ResolveClassName(f.Name)); + hasFunction = true; + break; + } + } string value = (string)api.Defines[key]; string ret; ! if(value == "") ! list.Add(String.Format("{0}{1} = True;", (hasFunction ? "Const" : ""), key)); else if(value[0] == '"' || value[0] == '\'') *************** *** 538,542 **** { ret = ParseConstString(value); ! list.Add(String.Format("{0} = {1};", ResolveName(key), ret)); } } --- 549,553 ---- { ret = ParseConstString(value); ! list.Add(String.Format("{0}{1} = {2};", (hasFunction ? "Const" : ""), ResolveName(key), ret)); } } *************** *** 545,549 **** { if(ret.IndexOf('#') == -1 && ret != "" && (ret[0] == '$' || Char.IsDigit(ret[0])) ) ! list.Add(String.Format("{0} = {1};", ResolveName(key), ret)); } } --- 556,560 ---- { if(ret.IndexOf('#') == -1 && ret != "" && (ret[0] == '$' || Char.IsDigit(ret[0])) ) ! list.Add(String.Format("{0}{1} = {2};", (hasFunction ? "Const" : ""), ResolveName(key), ret)); } } *************** *** 633,636 **** --- 644,648 ---- } + private Hashtable writtenEnums = new Hashtable(); private void WriteEnums(TypeContainer c) *************** *** 667,670 **** --- 679,686 ---- { string enumName = ResolveClassName(e.GetFullTypeName()); + if(writtenEnums.Contains(enumName)) + continue; + writtenEnums.Add(enumName, ""); + EnumItem[] items = (EnumItem[])e.Items.ToArray(typeof(EnumItem)); *************** *** 1050,1054 **** // paramstr = "; " + paramstr; sb = new StringBuilder(); ! if(m.ReturnType.IsVoidValue) sb.Append("procedure"); else --- 1066,1079 ---- // paramstr = "; " + paramstr; sb = new StringBuilder(); ! bool IsValueRetType = Function.IsValueRetFunction(m); ! if (IsValueRetType) ! { ! if (paramstr != null && paramstr.Length > 0) ! paramstr = String.Format("out{{byValue}} Result: {0}H; {1}", m.ReturnType.GetFullTypeName(), paramstr); ! else ! paramstr = String.Format("out{{byValue}} Result: {0}H", m.ReturnType.GetFullTypeName()); ! } ! ! if(m.ReturnType.IsVoidValue || IsValueRetType) sb.Append("procedure"); else *************** *** 1056,1060 **** //sb.AppendFormat("(Handle: {0}H{1})", rfullname, paramstr); sb.AppendFormat("({0})", paramstr); ! if(!m.ReturnType.IsVoidValue) sb.AppendFormat(": {0}", TypeReferenceToString(m.ReturnType, false, c)); //sb.Append("; cdecl"); --- 1081,1085 ---- //sb.AppendFormat("(Handle: {0}H{1})", rfullname, paramstr); sb.AppendFormat("({0})", paramstr); ! if(!m.ReturnType.IsVoidValue && !IsValueRetType) sb.AppendFormat(": {0}", TypeReferenceToString(m.ReturnType, false, c)); //sb.Append("; cdecl"); *************** *** 1109,1116 **** if(IsQStringFunction(m)) { - // cw.Write("{$IFDEF QSW}"); CreatePascalMethodIntern(m, funcName, c, methodSignatures, ctorClass, prefix, staticNew, true, inInterfaceSection); - // cw.WriteLine("{$ENDIF}"); } } --- 1134,1139 ---- *************** *** 1990,1994 **** string typeName; string defValue = null; ! TypeBase tb = API.GetTypeBase(parameters[i].Type.RefId); string paramName = ResolveClassName(parameters[i].Name); if(paramName == "") --- 2013,2017 ---- string typeName; string defValue = null; ! //TypeBase tb = API.GetTypeBase(parameters[i].Type.RefId); string paramName = ResolveClassName(parameters[i].Name); if(paramName == "") *************** *** 2184,2188 **** { ArrayList methods = c.GetSignals(); ! string baseHook = GetBaseSignalHookClassName(c); string rfullname = ResolveClassName(c.GetFullTypeName()); StringBuilder sb; --- 2207,2211 ---- { ArrayList methods = c.GetSignals(); ! //string baseHook = GetBaseSignalHookClassName(c); string rfullname = ResolveClassName(c.GetFullTypeName()); StringBuilder sb; Index: CWriter.cs =================================================================== RCS file: /cvsroot/qtcsharp/Bugtussle/src/Writers/CWriter.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CWriter.cs 14 May 2005 12:36:38 -0000 1.13 --- CWriter.cs 12 Jun 2005 20:52:51 -0000 1.14 *************** *** 663,666 **** --- 663,668 ---- if ( overrideClasses.Contains( c ) ) { + if ( c.BaseClasses.Count == 0 && destructor.VirtualKind == VirtualKind.None && c.HasVirtualMethods( true ) ) + cw.Write( "virtual " ); // it is a autogenerated non-virtual destructor (see Class.cs) but we need a virtual destructor cw.WriteLine( "~{0}() {{ if(overrideHook.destructor) overrideHook.destructor(overrideHook.destructorInst); }}", GetXClassName( c ), destructor.Name.Substring(1) ); *************** *** 804,809 **** protected void CreateNewFunction( Constructor ctor, Class c ) { - StringBuilder sb = new StringBuilder(); - // CLASS_EX* new_NAME(PARAMETERS) { return new CLASS_EX(PARAMETERS); } --- 806,809 ---- *************** *** 1024,1036 **** // { // if (overrideHook.NAME) [{ ! // RETTYPE returnValue = / return] ! // [*/&]overrideHook.NAME(overrideHookNAMEInst[, PARAMETERS]); ! // [RETTYPE returnValueValue = returnValue; ! // delete &returnValue; ! // return returnValueValue; // }] // [else [return] METHODOWNER::Name(PARAMETERS);] // } string ConstFunction = m.Const ? " const" : ""; --- 1024,1057 ---- // { // if (overrideHook.NAME) [{ ! // [TYPE* tmp;] ! // [return / return ::valueType((] ! // overrideHook.NAME(overrideHookNAMEInst[, PARAMETERS][, _tmp])[, _tmp))]; // }] // [else [return] METHODOWNER::Name(PARAMETERS);] // } + /* + example: + <code> + QVariant getText() { + if (overrideHook.getText) { + QVariant* _tmp; + return ::valueType((overrideHook.getText(overrideHookgetTextInst, _tmp), _tmp)); + } + else + return base_getText(); + } + </code> + + <code> + int getValue() { + if (overrideHook.getValue) + return overrideHook.getValue(overrideHookgetTextInst); + else + return base_getText(); + } + </code> + */ + string ConstFunction = m.Const ? " const" : ""; *************** *** 1044,1050 **** cw.Indent++; - //Function cfunc = Function.GetValueRetFunction( m ); - Function cfunc = m; - if (m.Name == "qt_cast") { --- 1065,1068 ---- *************** *** 1058,1071 **** if (m.VirtualKind != VirtualKind.Pure ) // abstract methods have no base_xx method cw.Write( "if (overrideHook.{0}) ", m.UniqueName ); ! string paramstr = ParametersToString( cfunc.GetParameters(), ParameterStyle.CXXtoCInvocation, null ); if ( paramstr != "" ) paramstr = ", " + paramstr; ! if ( Function.IsValueRetFunction( m ) ) { // Handle value return types. If a copy constructor exists, use it. ! // If none exist, try to use the first parameter type as reference ! // and create the return type object after the overrideHooks ! // invocation. if ( m.VirtualKind != VirtualKind.Pure ) { --- 1076,1089 ---- if (m.VirtualKind != VirtualKind.Pure ) // abstract methods have no base_xx method cw.Write( "if (overrideHook.{0}) ", m.UniqueName ); ! string paramstr = ParametersToString( m.GetParameters(), ParameterStyle.CXXtoCInvocation, null ); if ( paramstr != "" ) paramstr = ", " + paramstr; ! bool IsValueRetType = Function.IsValueRetFunction( m ); ! if ( IsValueRetType ) { // Handle value return types. If a copy constructor exists, use it. ! // If none exist, use the <class T>::valueType(T*) template function ! // to receive a stack based instance of the pointer. if ( m.VirtualKind != VirtualKind.Pure ) { *************** *** 1073,1095 **** cw.Indent++; } ! cw.Write( "{0} returnValue = ", m.ReturnType.Name ); // here "m." because we need the type name } //cw.WriteLine("{2}{3}overrideHook.{0}(this{1});", ! cw.WriteLine( "{2}{3}overrideHook.{0}(overrideHook.{0}Inst{1});", m.UniqueName, paramstr, ! (Function.IsValueRetFunction( m ) || cfunc.ReturnType.IsVoidValue) ? "" : "return ", ! cfunc.ReturnType.IsVoidValue ? "" : TypeReferenceToString( "", cfunc.ReturnType, ParameterStyle.CtoCXXInvocation ) ); ! if ( Function.IsValueRetFunction( m ) ) { ! cw.WriteLine( "{0} returnValueValue = returnValue;", m.ReturnType.Name ); ! cw.WriteLine( "delete &returnValue;" ); ! cw.WriteLine( "return returnValueValue;" ); ! if ( m.VirtualKind != VirtualKind.Pure ) ! { ! cw.Indent--; ! cw.WriteLine( "}" ); ! } } --- 1091,1112 ---- cw.Indent++; } ! cw.WriteLine( "{0}* _tmp;", m.ReturnType.Name ); ! cw.Write( "return ::valueType((" ); ! paramstr = ", _tmp" + paramstr; } //cw.WriteLine("{2}{3}overrideHook.{0}(this{1});", ! cw.Write( "{2}{3}overrideHook.{0}(overrideHook.{0}Inst{1})", m.UniqueName, paramstr, ! (IsValueRetType || m.ReturnType.IsVoidValue) ? "" : "return ", ! m.ReturnType.IsVoidValue ? "" : TypeReferenceToString( "", m.ReturnType, ParameterStyle.CtoCXXInvocation )); ! if ( IsValueRetType ) ! cw.Write( ", _tmp))" ); ! cw.WriteLine( ";" ); ! if ( IsValueRetType && m.VirtualKind != VirtualKind.Pure ) { ! cw.Indent--; ! cw.WriteLine( "}" ); } *************** *** 1237,1241 **** /*cw.WriteLine( "typedef void(*destructorHookType)({0}* instPtr);", c.Destructor.Name.Substring( 1 ) );*/ ! cw.WriteLine( "typedef void(*destructorHookType)(void* hookData);" ); cw.WriteLine( "destructorHookType destructor;" ); cw.WriteLine( "void* destructorInst;" ); --- 1254,1258 ---- /*cw.WriteLine( "typedef void(*destructorHookType)({0}* instPtr);", c.Destructor.Name.Substring( 1 ) );*/ ! cw.WriteLine( "typedef void(*destructorHookType)(void*);" ); cw.WriteLine( "destructorHookType destructor;" ); cw.WriteLine( "void* destructorInst;" ); *************** *** 1244,1254 **** foreach ( Method m in ownVirtMethods ) { ! /*Function cfunc = Function.GetValueRetFunction( m );*/ ! Function cfunc = m; ! string paramstr = ParametersToString( cfunc.GetParameters(), ParameterStyle.CDeclaration, c ); if ( paramstr != "" ) paramstr = ", " + paramstr; //cw.WriteLine( "typedef {0}(*{1}HookType)({2}{3}* instPtr{4});", ! cw.WriteLine( "typedef {0}(*{1}HookType)(void* hookData{4});", TypeReferenceToString( "", cfunc.ReturnType, ParameterStyle.CDeclaration, c ), m.UniqueName, --- 1261,1278 ---- foreach ( Method m in ownVirtMethods ) { ! Function cfunc = Function.GetValueRetFunction( m ); ! string paramstr = ParametersToString( m.GetParameters(), ParameterStyle.CDeclaration, c ); ! bool IsValueRetType = Function.IsValueRetFunction( m ); ! if (IsValueRetType) ! { ! if ( paramstr != "" ) ! paramstr = String.Format("{0}*&, {1}", m.ReturnType.Name, paramstr); ! else ! paramstr = String.Format("{0}*&", m.ReturnType.Name); ! } if ( paramstr != "" ) paramstr = ", " + paramstr; //cw.WriteLine( "typedef {0}(*{1}HookType)({2}{3}* instPtr{4});", ! cw.WriteLine( "typedef {0}(*{1}HookType)(void*{4});", TypeReferenceToString( "", cfunc.ReturnType, ParameterStyle.CDeclaration, c ), m.UniqueName, *************** *** 1391,1394 **** --- 1415,1420 ---- string baseHook = GetBaseSignalHookClassName( c ); + // TODO: Convert class-info to signal-info and call WriteSignalSignalHook(SignalHook s, bool inHeader) + if ( inHeader ) { |