[Qtcsharp-patches] Bugtussle/src/Writers CWriter.cs,1.11,1.12 KylixWriter.cs,1.12,1.13
Status: Inactive
Brought to you by:
manyoso
|
From: Andreas H. <ah...@us...> - 2005-04-18 09:31:15
|
Update of /cvsroot/qtcsharp/Bugtussle/src/Writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17120/src/Writers Modified Files: CWriter.cs KylixWriter.cs Log Message: Update KylixWriter: Int64 -> Integer Index: KylixWriter.cs =================================================================== RCS file: /cvsroot/qtcsharp/Bugtussle/src/Writers/KylixWriter.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** KylixWriter.cs 13 Oct 2004 18:47:27 -0000 1.12 --- KylixWriter.cs 18 Apr 2005 09:31:03 -0000 1.13 *************** *** 214,218 **** //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}"); --- 214,218 ---- //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}"); *************** *** 295,299 **** cw.WriteLine("Windows;"); cw.WriteLine("{$ELSE}"); ! cw.WriteLine("Libc, Xlib, Types;"); cw.WriteLine("{$ENDIF MSWINDOWS}"); cw.Indent--; --- 295,299 ---- cw.WriteLine("Windows;"); cw.WriteLine("{$ELSE}"); ! cw.WriteLine("Libc, Xlib;"); cw.WriteLine("{$ENDIF MSWINDOWS}"); cw.Indent--; *************** *** 674,678 **** cw.WriteLine("{0} = (", enumName); else if(e.ExceedsInt32) ! cw.WriteLine("{0} = type Int64;", enumName); else if(e.HasNegatives) cw.WriteLine("{0} = type Integer;", enumName); --- 674,678 ---- cw.WriteLine("{0} = (", enumName); else if(e.ExceedsInt32) ! cw.WriteLine("{0} = type Integer;", enumName); else if(e.HasNegatives) cw.WriteLine("{0} = type Integer;", enumName); *************** *** 1206,1210 **** // add function name sb.Append(funcName); ! if (m.OverloadIndex > 0 && m.Const) sb.Append('C'); // const flag, but only when this function is overloaded --- 1206,1210 ---- // add function name sb.Append(funcName); ! if (m.OverloadIndex > 0 && m.Const && !m.HasUniqueParameters()) sb.Append('C'); // const flag, but only when this function is overloaded *************** *** 1343,1347 **** cw.Write("{0}{1}({2})", funcName, ! (m.OverloadIndex > 0 && m.Const ? "C" : ""), ParametersToString(cfunc.GetParameters(), ParameterStyle.DelphiToDelphiInvocation, isStringMethod, c, true)); if(hasStringRetValue && cfunc.ReturnType.Name == "QString") --- 1343,1347 ---- cw.Write("{0}{1}({2})", funcName, ! (m.OverloadIndex > 0 && m.Const && !m.HasUniqueParameters() ? "C" : ""), ParametersToString(cfunc.GetParameters(), ParameterStyle.DelphiToDelphiInvocation, isStringMethod, c, true)); if(hasStringRetValue && cfunc.ReturnType.Name == "QString") *************** *** 1368,1372 **** --- 1368,1377 ---- // ---- getter ---- Method method = new Method(String.Format("get_{0}", v.ExportName), null, v.Type); + if(Function.IsValueRetFunction(method)) + method = new Method(String.Format("get_{0}", v.ExportName), null, + new TypeReference(v.Type.GetFullTypeName(), PassByMode.Pointer)); method.ExportName = method.Name; + + CreatePascalMethod(method, null, null, null, false, "", inInterfaceSection); *************** *** 1381,1385 **** } ! private void CreateClassStaticVariableGetterSetter(Class c, bool inInterfaceSection) { --- 1386,1390 ---- } ! private void CreateClassStaticVariableGetterSetter(Class c, bool inInterfaceSection) { *************** *** 2091,2094 **** --- 2096,2102 ---- cw.WriteLine("type"); cw.Indent++; + cw.WriteLine("TSignalHookType_eventFilter = function(Sender: QObjectH; Event: QEventH): Boolean of object; cdecl;"); + cw.WriteLine("TSignalHookType_objectDestroyed = procedure(Obj: QObjectH) of object; cdecl;"); + cw.WriteLine(); cw.WriteLine("TSignalHookBase = class(TObject)"); cw.WriteLine("public"); *************** *** 2097,2100 **** --- 2105,2110 ---- cw.WriteLine("procedure Delete; cdecl;"); cw.WriteLine("procedure Free;"); + cw.WriteLine("procedure eventFilter(hook: TSignalHookType_eventFilter);"); + cw.WriteLine("procedure objectDestroyed(hook: TSignalHookType_objectDestroyed);"); cw.Indent--; cw.WriteLine("end;"); *************** *** 2136,2139 **** --- 2146,2164 ---- cw.WriteLine("end;"); cw.WriteLine(); + cw.WriteLine("procedure SignalHookBase_setEventFilter(Handle: TSignalHookBase; Data, Hook: Pointer); cdecl; external LibWrapper name Prefix+'SignalHookBase_setEventFilter';"); + cw.WriteLine("procedure TSignalHookBase.eventFilter(hook: TSignalHookType_eventFilter);"); + cw.WriteLine("begin"); + cw.Indent++; + cw.WriteLine("SignalHookBase_setEventFilter(Self, TMethod(hook).Data, TMethod(hook).Code);"); + cw.Indent--; + cw.WriteLine("end;"); + cw.WriteLine("procedure SignalHookBase_setObjectDestroyed(Handle: TSignalHookBase; Data, Hook: Pointer); cdecl; external LibWrapper name Prefix+'SignalHookBase_setObjectDestroyed';"); + cw.WriteLine("procedure TSignalHookBase.objectDestroyed(hook: TSignalHookType_objectDestroyed);"); + cw.WriteLine("begin"); + cw.Indent++; + cw.WriteLine("SignalHookBase_setObjectDestroyed(Self, TMethod(hook).Data, TMethod(hook).Code);"); + cw.Indent--; + cw.WriteLine("end;"); + cw.WriteLine(); cw.WriteLine("end."); } *************** *** 2251,2257 **** cw.WriteLine("{$IFDEF MSWINDOWS}"); cw.WriteLine("Windows,"); - cw.WriteLine("{$ELSE}"); - cw.WriteLine("Libc, Xlib, Types,"); cw.WriteLine("{$ENDIF MSWINDOWS}"); cw.WriteLine("{0}Library;", ApiName); cw.Indent--; --- 2276,2283 ---- cw.WriteLine("{$IFDEF MSWINDOWS}"); cw.WriteLine("Windows,"); cw.WriteLine("{$ENDIF MSWINDOWS}"); + cw.WriteLine("{$IFDEF LINUX}"); + cw.WriteLine("Libc, Xlib,"); + cw.WriteLine("{$ENDIF LINUX}"); cw.WriteLine("{0}Library;", ApiName); cw.Indent--; Index: CWriter.cs =================================================================== RCS file: /cvsroot/qtcsharp/Bugtussle/src/Writers/CWriter.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CWriter.cs 13 Oct 2004 16:28:51 -0000 1.11 --- CWriter.cs 18 Apr 2005 09:31:03 -0000 1.12 *************** *** 18,27 **** } - public enum VariableGetter - { - Yes, - No - } - /*! --- 18,21 ---- *************** *** 781,785 **** cw.WriteLine( "{0};", invocation ); else ! WriteFunctionReturn( method, invocation, VariableGetter.No ); cw.Indent--; --- 775,779 ---- cw.WriteLine( "{0};", invocation ); else ! WriteFunctionReturn( method, invocation ); cw.Indent--; *************** *** 789,793 **** ! private void WriteFunctionReturn( Method method, StringBuilder invocation, VariableGetter isVarGetter ) { if ( Function.IsValueRetFunction( method ) ) --- 783,787 ---- ! private void WriteFunctionReturn( Method method, StringBuilder invocation ) { if ( Function.IsValueRetFunction( method ) ) *************** *** 797,807 **** cw.WriteLine( "returnValue = {0};", invocation ); cw.Indent--; ! if ( isVarGetter == VariableGetter.No ) ! { ! cw.WriteLine( "else" ); ! cw.Indent++; ! cw.WriteLine( "{0};", invocation ); // ignore return value ! cw.Indent--; ! } } else --- 791,798 ---- cw.WriteLine( "returnValue = {0};", invocation ); cw.Indent--; ! cw.WriteLine( "else" ); ! cw.Indent++; ! cw.WriteLine( "{0};", invocation ); // ignore return value ! cw.Indent--; } else *************** *** 1056,1059 **** --- 1047,1059 ---- Function cfunc = m; + if (m.Name == "qt_cast") + { + /* We use qt_cast() for a get_overrideHook method because it is virtual + and has the correct return type (and the name fits */ + cw.WriteLine( "if ({0} && {0}[0] == '\\255')", m.Parameters[0].Name ); + cw.Indent++; + cw.WriteLine( "return &overrideHook;" ); + cw.Indent--; + } if (m.VirtualKind != VirtualKind.Pure ) // abstract methods have no base_xx method cw.Write( "if (overrideHook.{0}) ", m.UniqueName ); *************** *** 1077,1081 **** //cw.WriteLine("{2}{3}overrideHook.{0}(this{1});", ! cw.WriteLine( "{2}{3}overrideHook.{0}((void*)overrideHook.{0}Data{1});", // (void*) because of a gcc bug m.UniqueName, paramstr, --- 1077,1081 ---- //cw.WriteLine("{2}{3}overrideHook.{0}(this{1});", ! cw.WriteLine( "{2}{3}overrideHook.{0}(overrideHook.{0}Data{1});", m.UniqueName, paramstr, *************** *** 1122,1126 **** cw.WriteLine( "{" ); cw.Indent++; ! cw.WriteLine( "return &(instPtr->overrideHook);" ); cw.Indent--; cw.WriteLine( "}" ); --- 1122,1133 ---- cw.WriteLine( "{" ); cw.Indent++; ! if ( c.Name == "QObject" || c.Inherits( "QObject" ) ) ! { ! /* we need a virtual method in order to return the overrideHook and qt_cast seems to be perfect by ! name and return type. */ ! cw.WriteLine( "return ({0}OverrideHook*)(instPtr->qt_cast(\"\\255\"));", c.Name ); ! } ! else ! cw.WriteLine( "return &(instPtr->overrideHook);" ); cw.Indent--; cw.WriteLine( "}" ); *************** *** 1674,1678 **** cw.WriteLine( "{0};", invocation ); else ! WriteFunctionReturn( method, invocation, VariableGetter.No ); cw.Indent--; cw.WriteLine( "}" ); --- 1681,1685 ---- cw.WriteLine( "{0};", invocation ); else ! WriteFunctionReturn( method, invocation ); cw.Indent--; cw.WriteLine( "}" ); *************** *** 1695,1702 **** // ---- getter ---- Method method = new Method( String.Format( "get_{0}", v.ExportName ), null, v.Type ); ! Function cfunc = Function.GetValueRetFunction( method ); sbHeader = new StringBuilder(); sbHeader.Append( TypeReferenceToString( "", cfunc.ReturnType, ParameterStyle.CDeclaration, ns ) ); sbHeader.Append( "QTC_EXPORT " ); sbHeader.Append( method.Name ); --- 1702,1713 ---- // ---- getter ---- Method method = new Method( String.Format( "get_{0}", v.ExportName ), null, v.Type ); ! Function cfunc = method; //Function.GetValueRetFunction( method ); ! bool isValueRet = Function.IsValueRetFunction( method ); sbHeader = new StringBuilder(); sbHeader.Append( TypeReferenceToString( "", cfunc.ReturnType, ParameterStyle.CDeclaration, ns ) ); + bool isRefValueRet = sbHeader.Length > 2 && sbHeader[sbHeader.Length - 2] == '&'; + if ( isValueRet && !isRefValueRet ) + sbHeader.Append("* "); sbHeader.Append( "QTC_EXPORT " ); sbHeader.Append( method.Name ); *************** *** 1720,1724 **** invocation.AppendFormat( "{0}::", v.Container.GetFullTypeName() ); invocation.Append( TypeReferenceToString( v.Name, v.Type, ParameterStyle.CtoCXXInvocation, ns ) ); ! WriteFunctionReturn( method, invocation, VariableGetter.Yes ); cw.Indent--; cw.WriteLine( "}" ); --- 1731,1744 ---- invocation.AppendFormat( "{0}::", v.Container.GetFullTypeName() ); invocation.Append( TypeReferenceToString( v.Name, v.Type, ParameterStyle.CtoCXXInvocation, ns ) ); ! ! // function return "type" ! cw.Write( "return " ); ! if ( isValueRet && !isRefValueRet ) ! cw.Write( '&' ); ! cw.WriteLine( "{0};", invocation ); ! //WriteFunctionReturn( method, invocation ); ! // ---- ! ! cw.Indent--; cw.WriteLine( "}" ); *************** *** 1790,1794 **** string proDir = Path.GetDirectoryName(outputDirectory); ! headerFiles.Add( "../static/clib/libqtcglobal.h" ); headerFiles.Add( "../static/clib/signalhookbase.h" ); --- 1810,1814 ---- string proDir = Path.GetDirectoryName(outputDirectory); ! headerFiles.Add( String.Format( "../static/clib/lib{0}cglobal.h", api.ApiName.ToLower() ) ); headerFiles.Add( "../static/clib/signalhookbase.h" ); |