Переглянути джерело

--- Merging r17304 into '.':
U packages/graph/src/win32/wincrt.pp
U packages/graph/src/win32/winmouse.pp
--- Merging r17305 into '.':
U packages/graph/src/win32/graph.pp
--- Merging r17306 into '.':
U packages/graph/Makefile.fpc
C packages/graph/Makefile
--- Merging r17311 into '.':
U rtl/win/wininc/base.inc
--- Merging r17387 into '.':
U packages/winunits-base/src/activex.pp
--- Merging r17391 into '.':
U rtl/objpas/typinfo.pp
Summary of conflicts:
Text conflicts: 1

# revisions: 17304,17305,17306,17311,17387,17391
------------------------------------------------------------------------
r17304 | pierre | 2011-04-11 12:19:04 +0200 (Mon, 11 Apr 2011) | 1 line
Changed paths:
M /trunk/packages/graph/src/win32/wincrt.pp
M /trunk/packages/graph/src/win32/winmouse.pp

* Change Message function return type to be Win64 compatible
------------------------------------------------------------------------
------------------------------------------------------------------------
r17305 | pierre | 2011-04-11 12:19:43 +0200 (Mon, 11 Apr 2011) | 1 line
Changed paths:
M /trunk/packages/graph/src/win32/graph.pp

* Use system thread functions and allow win64 compilation
------------------------------------------------------------------------
------------------------------------------------------------------------
r17306 | pierre | 2011-04-11 12:20:46 +0200 (Mon, 11 Apr 2011) | 1 line
Changed paths:
M /trunk/packages/graph/Makefile
M /trunk/packages/graph/Makefile.fpc

+ Add graph, wincrt and winmouse units for win64 OS target
------------------------------------------------------------------------
------------------------------------------------------------------------
r17311 | paul | 2011-04-13 10:47:05 +0200 (Wed, 13 Apr 2011) | 1 line
Changed paths:
M /trunk/rtl/win/wininc/base.inc

rtl: fix printer hook procedures - they return PTR_UINT instead of UINT
------------------------------------------------------------------------
------------------------------------------------------------------------
r17387 | sergei | 2011-04-30 20:09:44 +0200 (Sat, 30 Apr 2011) | 2 lines
Changed paths:
M /trunk/packages/winunits-base/src/activex.pp

* TPropVariant must be packed record, its size should match Variant (16 bytes)
* LPVERSIONEDSTREAM is a pointer type.
------------------------------------------------------------------------
------------------------------------------------------------------------
r17391 | michael | 2011-05-02 21:16:53 +0200 (Mon, 02 May 2011) | 1 line
Changed paths:
M /trunk/rtl/objpas/typinfo.pp

* Fixed setting of RAW interfaces
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@17594 -

marco 14 роки тому
батько
коміт
b818aca03d

+ 7 - 2
packages/graph/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/02/22]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/05/18]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -331,7 +331,7 @@ ifeq ($(FULL_TARGET),x86_64-freebsd)
 override TARGET_UNITS+=graph $(GGIGRAPH_UNIT)
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_UNITS+=ptcgraph ptccrt
+override TARGET_UNITS+=graph wincrt winmouse ptcgraph ptccrt
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 override TARGET_UNITS+=$(GRAPH_UNIT) $(GGIGRAPH_UNIT) ptcgraph ptccrt
@@ -2893,8 +2893,13 @@ include fpcmake.loc
 endif
 include src/inc/makefile.inc
 GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES)) $(UNIXINCDEPS)
+ifeq ($(OS_TARGET),win64)
+graph$(PPUEXT) : src/win32/graph.pp $(GRAPHINCDEPS)
+	$(COMPILER) -I$(GRAPHDIR) src/win32/graph.pp
+else
 graph$(PPUEXT) : graph.pp $(GRAPHINCDEPS)
 	$(COMPILER) -I$(GRAPHDIR) $(GRAPHUNIT_DIR)/graph.pp
+endif
 ggigraph$(PPUEXT) : $(UNIXINC)/ggigraph.pp $(GRAPHINCDEPS)
 	$(COMPILER) -I$(GRAPHDIR) $(UNIXINC)/ggigraph.pp
 winmouse$(PPUEXT) : src/win32/winmouse.pp graph$(PPUEXT)

+ 6 - 0
packages/graph/Makefile.fpc

@@ -28,6 +28,7 @@ units=
 units_linux=$(GRAPH_UNIT) $(GGIGRAPH_UNIT) ptcgraph ptccrt
 units_freebsd=graph $(GGIGRAPH_UNIT)
 units_win32=graph wincrt winmouse
+units_win64=graph wincrt winmouse
 units_go32v2=graph
 units_amiga=graph
 units_i386_linux=sdlgraph
@@ -92,8 +93,13 @@ endif
 include src/inc/makefile.inc
 GRAPHINCDEPS=$(addprefix $(GRAPHDIR)/,$(GRAPHINCNAMES)) $(UNIXINCDEPS)
 
+ifeq ($(OS_TARGET),win64)
+graph$(PPUEXT) : src/win32/graph.pp $(GRAPHINCDEPS)
+        $(COMPILER) -I$(GRAPHDIR) src/win32/graph.pp
+else
 graph$(PPUEXT) : graph.pp $(GRAPHINCDEPS)
         $(COMPILER) -I$(GRAPHDIR) $(GRAPHUNIT_DIR)/graph.pp
+endif
 
 ggigraph$(PPUEXT) : $(UNIXINC)/ggigraph.pp $(GRAPHINCDEPS)
         $(COMPILER) -I$(GRAPHDIR) $(UNIXINC)/ggigraph.pp

+ 51 - 4
packages/graph/src/win32/graph.pp

@@ -15,6 +15,18 @@
 unit Graph;
 interface
 
+{
+  To be able to use standard file handles in the graph thread,
+  we need to use the system functions handling threads,
+  to ensure that thread varaibles are correctly initialized.
+  This new default setting can be overridden by defining
+  USE_WINDOWS_API_THREAD_FUNCTIONS macro.
+}
+
+{$ifndef USE_WINDOWS_API_THREAD_FUNCTIONS}
+  {$define USE_SYSTEM_BEGIN_THREAD}
+{$endif ndef USE_WINDOWS_API_THREAD_FUNCTIONS}
+
 uses
   windows;
 
@@ -142,7 +154,15 @@ var
    pal : ^rgbrec;
 //   SavePtr : pointer; { we don't use that pointer }
    MessageThreadHandle : Handle;
+{$ifdef WIN64}
+  {$ifdef USE_SYSTEM_BEGIN_THREAD}
+     MessageThreadId : Qword;
+  {$else}
+     MessageThreadId : DWord;
+  {$endif}
+{$else not WIN64}
    MessageThreadID : DWord;
+{$endif not WIN64}
 
 function GetPaletteEntry(r,g,b : word) : word;
 
@@ -1471,7 +1491,13 @@ end;
 const
    winregistered : boolean = false;
 
-function MessageHandleThread(p : pointer) : DWord;StdCall;
+   { Thread functions have different return type and calling convention
+     for system unit funcitons andfor windows API. }
+{$ifdef USE_SYSTEM_BEGIN_THREAD}
+function MessageHandleThread(p : pointer) : ptrint;
+{$else not USE_SYSTEM_BEGIN_THREAD}
+function MessageHandleThread(p : pointer) : DWord; stdcall;
+{$endif not USE_SYSTEM_BEGIN_THREAD}
 
   var
      AMessage: Msg;
@@ -1484,7 +1510,11 @@ function MessageHandleThread(p : pointer) : DWord;StdCall;
                if not(WinRegisterWithChild) then
                  begin
                     MessageBox(0, 'Window registration failed', nil, mb_Ok);
-                    ExitThread(1);
+{$ifdef USE_SYSTEM_BEGIN_THREAD}
+                    System.EndThread(1);
+{$else not USE_SYSTEM_BEGIN_THREAD}
+                    Windows.ExitThread(1);
+{$endif not USE_SYSTEM_BEGIN_THREAD}
                  end;
             end
           else
@@ -1492,7 +1522,11 @@ function MessageHandleThread(p : pointer) : DWord;StdCall;
                if not(WinRegister) then
                  begin
                     MessageBox(0, 'Window registration failed', nil, mb_Ok);
-                    ExitThread(1);
+{$ifdef USE_SYSTEM_BEGIN_THREAD}
+                    System.EndThread(1);
+{$else not USE_SYSTEM_BEGIN_THREAD}
+                    Windows.ExitThread(1);
+{$endif not USE_SYSTEM_BEGIN_THREAD}
                  end;
             end;
           winregistered:=true;
@@ -1500,7 +1534,11 @@ function MessageHandleThread(p : pointer) : DWord;StdCall;
      GraphWindow:=WinCreate;
      if longint(GraphWindow) = 0 then begin
        MessageBox(0, 'Window creation failed', nil, mb_Ok);
-       ExitThread(1);
+{$ifdef USE_SYSTEM_BEGIN_THREAD}
+       System.EndThread(1);
+{$else not USE_SYSTEM_BEGIN_THREAD}
+       Windows.ExitThread(1);
+{$endif not USE_SYSTEM_BEGIN_THREAD}
      end;
      while longint(GetMessage(@AMessage, 0, 0, 0))=longint(true) do
        begin
@@ -1528,8 +1566,17 @@ procedure InitWin32GUI16colors;
      { start graph subsystem }
      InitializeCriticalSection(graphdrawing);
      graphrunning:=false;
+     {Use system BeginThread instead of CreteThreead
+     function BeginThread(sa : Pointer;stacksize : SizeUInt;
+  ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword;
+  var ThreadId : TThreadID) : TThreadID;}
+{$ifdef USE_SYSTEM_BEGIN_THREAD}
+     MessageThreadHandle:=System.BeginThread(nil,0,@MessageHandleThread,
+       nil,0,MessageThreadID);
+{$else not USE_SYSTEM_BEGIN_THREAD}
      MessageThreadHandle:=CreateThread(nil,0,@MessageHandleThread,
        nil,0,MessageThreadID);
+{$endif not USE_SYSTEM_BEGIN_THREAD}
      repeat
        GetExitCodeThread(MessageThreadHandle,@threadexitcode);
      until graphrunning or (threadexitcode<>STILL_ACTIVE);

+ 1 - 1
packages/graph/src/win32/wincrt.pp

@@ -139,7 +139,7 @@ unit wincrt;
        ctrlkey : boolean = false;
        shiftkey : boolean = false;
 
-    function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): Longint; stdcall;
+    function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): LResult; stdcall;
 
       begin
          case amessage of

+ 1 - 1
packages/graph/src/win32/winmouse.pp

@@ -125,7 +125,7 @@ unit winmouse;
          Windows.ShowCursor(false);
       end;
 
-    function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): Longint; stdcall;
+    function msghandler(Window: HWnd; AMessage:UInt; WParam : WParam; LParam: LParam): LResult; stdcall;
 
       begin
          { we catch the double click messages here too, }

+ 3 - 2
packages/winunits-base/src/activex.pp

@@ -1683,7 +1683,7 @@ TYPE
      end;
    VERSIONEDSTREAM = tagVersionedStream;
    TVERSIONEDSTREAM = tagVersionedStream;
-   LPVERSIONEDSTREAM = tagVersionedStream;
+   LPVERSIONEDSTREAM = ^tagVersionedStream;
    PVERSIONEDSTREAM = ^TagVersionedStream;
 
 
@@ -1853,7 +1853,8 @@ TYPE
    IPropertyStorage    = Interface;
    IEnumSTATPROPSETSTG = interface;
 
-   TPROPVARIANT = record
+   { size of this record must be 16, i.e. match Variant }
+   TPROPVARIANT = packed record
           vt : VARTYPE;
           wReserved1 : PROPVAR_PAD1;
           wReserved2 : PROPVAR_PAD2;

+ 67 - 0
rtl/objpas/typinfo.pp

@@ -329,6 +329,11 @@ function GetInterfaceProp(Instance: TObject; PropInfo: PPropInfo): IInterface;
 procedure SetInterfaceProp(Instance: TObject; const PropName: string; const Value: IInterface);
 procedure SetInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: IInterface);
 
+function GetRawInterfaceProp(Instance: TObject; const PropName: string): Pointer;
+function GetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
+procedure SetRawInterfaceProp(Instance: TObject; const PropName: string; const Value: Pointer);
+procedure SetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
+
 // Auxiliary routines, which may be useful
 Function GetEnumName(TypeInfo : PTypeInfo;Value : Integer) : string;
 Function GetEnumValue(TypeInfo : PTypeInfo;const Name : string) : Integer;
@@ -1248,6 +1253,68 @@ begin
             end;
         end;
       end;
+    tkInterfaceRaw:
+      Raise Exception.Create('Cannot set RAW interface from IUnknown interface');
+  end;
+end;
+
+{ ---------------------------------------------------------------------
+    RAW (Corba) Interface wrapprers
+  ---------------------------------------------------------------------}
+
+
+function GetRawInterfaceProp(Instance: TObject; const PropName: string): Pointer;
+
+begin
+  Result:=GetRawInterfaceProp(Instance,FindPropInfo(Instance,PropName));
+end;
+
+function GetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo): Pointer;
+
+begin
+{$ifdef cpu64}
+  Result:=Pointer(GetInt64Prop(Instance,PropInfo));
+{$else cpu64}
+  Result:=Pointer(PtrInt(GetOrdProp(Instance,PropInfo)));
+{$endif cpu64}
+end;
+
+procedure SetRawInterfaceProp(Instance: TObject; const PropName: string; const Value: Pointer);
+
+begin
+  SetRawInterfaceProp(Instance,FindPropInfo(Instance,PropName),Value);
+end;
+
+procedure SetRawInterfaceProp(Instance: TObject; PropInfo: PPropInfo; const Value: Pointer);
+type
+  TSetPointerProcIndex=procedure(index:longint;const i:Pointer) of object;
+  TSetPointerProc=procedure(i:Pointer) of object;
+var
+  AMethod : TMethod;
+begin
+  case Propinfo^.PropType^.Kind of
+    tkInterfaceRaw:
+      begin
+        case (PropInfo^.PropProcs shr 2) and 3 of
+          ptField:
+            PPointer(Pointer(Instance)+PtrUInt(PropInfo^.SetProc))^:=Value;
+          ptstatic,
+          ptvirtual :
+            begin
+              if ((PropInfo^.PropProcs shr 2) and 3)=ptStatic then
+                AMethod.Code:=PropInfo^.SetProc
+              else
+                AMethod.Code:=PPointer(Pointer(Instance.ClassType)+PtrUInt(PropInfo^.SetProc))^;
+              AMethod.Data:=Instance;
+              if ((PropInfo^.PropProcs shr 6) and 1)<>0 then
+                TSetPointerProcIndex(AMethod)(PropInfo^.Index,Value)
+              else
+                TSetPointerProc(AMethod)(Value);
+            end;
+        end;
+      end;
+    tkInterface:
+      Raise Exception.Create('Cannot set interface from RAW interface');
   end;
 end;
 

+ 6 - 6
rtl/win/wininc/base.inc

@@ -559,13 +559,13 @@
 
      EDITSTREAMCALLBACK = function (_para1:DWORD; _para2:LPBYTE; _para3:LONG; _para4:LONG):DWORD;stdcall;
 
-     LPFRHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPFRHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
-     LPOFNHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPOFNHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
-     LPPRINTHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPPRINTHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
-     LPSETUPHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPSETUPHOOKPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
      DLGPROC = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):LRESULT;stdcall;
 
@@ -617,9 +617,9 @@
 
      TABORTPROC = function (_para1:HDC; _para2:longint):WINBOOL;stdcall;
 
-     LPPAGEPAINTHOOK = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPPAGEPAINTHOOK = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
-     LPPAGESETUPHOOK = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT;stdcall;
+     LPPAGESETUPHOOK = function (_para1:HWND; _para2:UINT; _para3:WPARAM; _para4:LPARAM):UINT_PTR;stdcall;
 
      ICMENUMPROC = function (_para1:LPTSTR; _para2:LPARAM):longint;stdcall;