Sync to trunk (r44371)

svn path=/branches/ros-amd64-bringup/; revision=44373
This commit is contained in:
Samuel Serapion
2009-12-03 07:28:23 +00:00
54 changed files with 4591 additions and 3323 deletions
+20 -2
View File
@@ -152,6 +152,11 @@ $(error ReactOS's makefiles use GNU Make 3.80+ features, you have $(MAKE_VERSION
endif
# END of code borrowed from GMSL ( http://gmsl.sourceforge.net/ )
define NL
endef
.PHONY: all
.PHONY: clean
.PHONY: world
@@ -234,7 +239,7 @@ ifeq ($(HALFVERBOSEECHO),yes)
ECHO_CVTRES =@echo $(QUOTE)[CVTRES] $@$(QUOTE)
ECHO_WIDL =@echo $(QUOTE)[WIDL] $@$(QUOTE)
ECHO_BIN2RES =@echo $(QUOTE)[BIN2RES] $<$(QUOTE)
ECHO_DLLTOOL =@echo $(QUOTE)[DLLTOOL] $@$(QUOTE)
ECHO_IMPLIB =@echo $(QUOTE)[IMPLIB] $@$(QUOTE)
ECHO_LD =@echo $(QUOTE)[LD] $@$(QUOTE)
ECHO_HOSTLD =@echo $(QUOTE)[HOST-LD] $@$(QUOTE)
ECHO_LINK =@echo $(QUOTE)[LINK] $@$(QUOTE)
@@ -242,6 +247,7 @@ ifeq ($(HALFVERBOSEECHO),yes)
ECHO_OBJDUMP =@echo $(QUOTE)[OBJDUMP] $@$(QUOTE)
ECHO_RBUILD =@echo $(QUOTE)[RBUILD] $@$(QUOTE)
ECHO_RSYM =@echo $(QUOTE)[RSYM] $@$(QUOTE)
ECHO_PEFIXUP =@echo $(QUOTE)[PEFIXUP] $@$(QUOTE)
ECHO_WMC =@echo $(QUOTE)[WMC] $@$(QUOTE)
ECHO_NCI =@echo $(QUOTE)[NCI] $@$(QUOTE)
ECHO_CABMAN =@echo $(QUOTE)[CABMAN] $<$(QUOTE)
@@ -253,6 +259,7 @@ ifeq ($(HALFVERBOSEECHO),yes)
ECHO_STRIP =@echo $(QUOTE)[STRIP] $@$(QUOTE)
ECHO_RGENSTAT=@echo $(QUOTE)[RGENSTAT] $@$(QUOTE)
ECHO_DEPENDS =@echo $(QUOTE)[DEPENDS] $<$(QUOTE)
ECHO_RSP =@echo $(QUOTE)[RSP] $@$(QUOTE)
else
ECHO_CP =
ECHO_MKDIR =
@@ -272,7 +279,7 @@ else
ECHO_CVTRES =
ECHO_WIDL =
ECHO_BIN2RES =
ECHO_DLLTOOL =
ECHO_IMPLIB =
ECHO_LD =
ECHO_HOSTLD =
ECHO_NM =
@@ -290,6 +297,7 @@ else
ECHO_STRIP =
ECHO_RGENSTAT=
ECHO_DEPENDS =
ECHO_RSP =
endif
# Set host compiler/linker
@@ -521,6 +529,11 @@ msvc9: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
$(Q)$(ROS_BUILDENGINE) $(RBUILD_FLAGS) $(ROS_RBUILDFLAGS) -vs9.00 -voversionconfiguration msvc
.PHONY: msvc10
msvc10: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
$(Q)$(ROS_BUILDENGINE) $(RBUILD_FLAGS) $(ROS_RBUILDFLAGS) -vs10.00 -voversionconfiguration msvc
.PHONY: msvc6_clean
msvc6_clean: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
@@ -546,6 +559,11 @@ msvc9_clean: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
$(Q)$(ROS_BUILDENGINE) $(RBUILD_FLAGS) $(ROS_RBUILDFLAGS) -c -vs9.00 -voversionconfiguration msvc
.PHONY: msvc10_clean
msvc10_clean: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
$(Q)$(ROS_BUILDENGINE) $(RBUILD_FLAGS) $(ROS_RBUILDFLAGS) -c -vs10.00 -voversionconfiguration msvc
.PHONY: msvc_clean
msvc_clean: $(ROS_BUILDENGINE)
$(ECHO_RBUILD)
+13 -4
View File
@@ -20,7 +20,6 @@
<property name="PLATFORM" value="PC"/>
<property name="usewrc" value="false"/>
<property name="WINEBUILD_FLAGS" value="--kill-at"/>
<property name="NTOSKRNL_SHARED" value="-shared"/>
<if property="OPTIMIZE" value="1">
<compilerflag>-Os</compilerflag>
@@ -49,9 +48,14 @@
<compilerflag>-Wno-multichar</compilerflag>
<compilerflag>-Wno-format</compilerflag>
<!-- compilerflag>-H</compilerflag> enable this for header traces -->
<group linkerset="ld">
<linkerflag>-disable-stdcall-fixup</linkerflag>
<linkerflag>-static</linkerflag>
<linkerflag>--unique=.eh_frame</linkerflag>
<linkerflag>-file-alignment=0x1000</linkerflag>
<linkerflag>-section-alignment=0x1000</linkerflag>
</group>
<!-- Here starts <xi:include href="ReactOS-generic.rbuild" /> -->
@@ -173,9 +177,9 @@
<xi:include href="drivers/ksfilter/directory.rbuild" />
</directory>
<!-- directory name="multimedia">
<directory name="multimedia">
<xi:include href="drivers/multimedia/directory.rbuild" />
</directory -->
</directory >
<directory name="network">
<xi:include href="drivers/network/directory.rbuild" />
@@ -190,7 +194,7 @@
<xi:include href="drivers/setup/directory.rbuild" />
</directory>
<directory name="storage">
<xi:include href="drivers/storage/directory.rbuild" />
<xi:include href="drivers/storage/directory.rbuild" />
</directory>
<directory name="usb">
<xi:include href="drivers/usb/directory.rbuild" />
@@ -255,6 +259,11 @@
<xi:include href="lib/3rdparty/zlib/zlib.rbuild" />
</directory>
</directory>
<if property="USERMODE" value="1">
<directory name="atl">
<xi:include href="lib/atl/atl.rbuild" />
</directory>
</if>
<directory name="sdk">
<xi:include href="lib/sdk/sdk.rbuild" />
</directory>
+2 -1
View File
@@ -16,7 +16,6 @@
<define name="USE_COMPILER_EXCEPTIONS" />
<property name="NTOSKRNL_SHARED" value="-file-alignment=0x1000 -section-alignment=0x1000 -shared"/>
<property name="WINEBUILD_FLAGS" value="--kill-at"/>
<include>include/reactos/arm</include>
@@ -38,6 +37,8 @@
<group linkerset="ld">
<linkerflag>--strip-debug</linkerflag> <!-- INVESTIGATE -->
<linkerflag>-static</linkerflag> <!-- INVESTIGATE -->
<linkerflag>-file-alignment=0x1000</linkerflag>
<linkerflag>-section-alignment=0x1000</linkerflag>
</group>
<directory name="media">
+2 -1
View File
@@ -16,7 +16,6 @@
<define name="USE_COMPILER_EXCEPTIONS" />
<property name="NTOSKRNL_SHARED" value="-file-alignment=0x1000 -section-alignment=0x1000 -shared"/>
<property name="PLATFORM" value="PC"/>
<group compilerset="gcc">
@@ -30,6 +29,8 @@
<group linkerset="ld">
<linkerflag>-disable-stdcall-fixup</linkerflag>
<linkerflag>-file-alignment=0x1000</linkerflag>
<linkerflag>-section-alignment=0x1000</linkerflag>
</group>
<directory name="base">
+1 -1
View File
@@ -65,7 +65,7 @@
enable this (except they/you purchased a license from the patent owner).
This settings is disabled (0) by default.
-->
<property name="NSWPAT" value="1" />
<property name="NSWPAT" value="0" />
<!--
Whether to compile with the KD protocol. This will disable support for KDBG
+117
View File
@@ -0,0 +1,117 @@
::
:: This script is called from the Makefile command line within Visual Studio using the following parameters:
::
:: %1 - $(build)
:: %2 - $(target)
::
:: Examples:
::
:: Call build.bat build ntoskrnl
:: Call build.bat clean win32k
::
@echo off
if "%1"=="" goto :err_params
if "%2"=="" goto :err_params
:: Get the RosBE path... ::
:: Set the command we'll use to check if RosBE exists
set _IS_ROSBE_INSTALLED_COMMAND="reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\ReactOS Build Environment for Windows" /v UninstallString"
:: Check the key actually exists !!!!FIXME: Why is this returning 'The system cannot find the path specified.'!!!!
%_IS_ROSBE_INSTALLED_COMMAND%
IF NOT errorlevel 0 goto :err_no_rosbe
:: This is a bit hackish. What we do is look for REG_SZ which is the second token on the second line and dump it into i
:: We then assign all remaining text to the next variable in the sequence, which is j. This leaves us with the path
for /F "tokens=2,* skip=1 delims=\ " %%i in ('%_IS_ROSBE_INSTALLED_COMMAND%') do (
set _ROSBE_UNINSTALL_PATH_=%%j
)
:: Now strip the file name from the end of the path and we should have our RosBE install directory
set _ROSBE_PATH_DIR=
set _ROSBE_PATH_=
for %%i in ("%_ROSBE_UNINSTALL_PATH_%") do set _ROSBE_PATH_DIR=%%~di
for %%i in ("%_ROSBE_UNINSTALL_PATH_%") do set "_ROSBE_PATH_=%%~pi"
set "_ROSBE_FULL_PATH_=%_ROSBE_PATH_DIR%%_ROSBE_PATH_%"
::echo RosBE insall path = %_ROSBE_FULL_PATH_%
:: Set the path which contains our build tools
set _ROSBE_BIN_PATH=%_ROSBE_FULL_PATH_%i386\bin
:: Add the path to the search path
path=%path%;%_ROSBE_BIN_PATH%
:: Set the make path
set _MAKE_COMMAND=""
if exist "%_ROSBE_BIN_PATH%\mingw32-make.exe" (
set _MAKE_COMMAND=mingw32-make.exe
)
if exist "%_ROSBE_BIN_PATH%\make.exe" (
set _MAKE_COMMAND=make.exe
)
if %_MAKE_COMMAND% == "" (
goto err_no_make
)
:: This file is located in the source root
set _ROS_SOURCE_ROOT=%~dp0
:: Change the current dir to the source root
cd %_ROS_SOURCE_ROOT%
:: Run the requested build task
if "%1" == "build" (
goto :build
)
if "%1" == "rebuild" (
goto clean
)
if "%1" == "clean" (
goto :clean
)
goto :err_params
:clean
echo.
echo Cleaning...
echo.
call "%_MAKE_COMMAND%" -j 1 %2%_clean
if "%1" == "rebuild" (
goto :build
)
goto :exit
:build
echo.
echo Building...
echo.
call "%_MAKE_COMMAND%" -j 1 %2%
goto :exit
:err_no_make
echo.
echo Cannot find a make executable
goto :err_no_rosbe
:err_no_rosbe
echo.
echo You need to have RosBE installed to use this configuration
echo.
exit 1
:err_params
echo.
echo Invalid parameters required, Check your command line.
echo.
exit 2
:exit
echo.
-1
View File
@@ -3,7 +3,6 @@
<module name="ntvdm" type="win32cui" installbase="system32" installname="ntvdm.exe">
<include base="ntvdm">.</include>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<library>advapi32</library>
@@ -6,7 +6,6 @@
<include base="csr">include</include>
<library>ntdll</library>
<library>csrsrv</library>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<file>dllmain.c</file>
@@ -9,7 +9,6 @@
<include base="console">.</include>
<compilerflag compilerset="gcc">-fms-extensions</compilerflag>
<library>ntdll</library>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<library>advapi32</library>
@@ -4,11 +4,13 @@
#include <winddi.h>
typedef struct _DRIVERS
{
LIST_ENTRY ListEntry;
PVOID SectionPointer;
PVOID BaseAddress;
UNICODE_STRING DriverName;
}DRIVERS, *PDRIVERS;
BOOL DRIVER_RegisterDriver(LPCWSTR Name, PFN_DrvEnableDriver EnableDriver);
PFN_DrvEnableDriver DRIVER_FindExistingDDIDriver(LPCWSTR Name);
@@ -188,7 +188,7 @@ co_IntSendMessageTimeout(HWND hWnd,
LRESULT FASTCALL
IntDispatchMessage(MSG* Msg);
BOOL FASTCALL
IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl);
IntTranslateKbdMessage(LPMSG lpMsg, UINT flags);
VOID FASTCALL
co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
+13 -37
View File
@@ -26,15 +26,9 @@
#include <debug.h>
typedef struct _DRIVERS
{
LIST_ENTRY ListEntry;
HANDLE ImageHandle;
UNICODE_STRING DriverName;
}DRIVERS, *PDRIVERS;
extern LIST_ENTRY GlobalDriverListHead;
/*
* Blatantly stolen from ldr/utils.c in ntdll. I can't link ntdll from
* here, though.
@@ -180,7 +174,7 @@ EngFindImageProcAddress(IN HANDLE Module,
return NULL;
}
RtlInitAnsiString(&ProcNameString, ProcName);
Status = LdrGetProcedureAddress(Module,
Status = LdrGetProcedureAddress(((PDRIVERS)Module)->BaseAddress,
&ProcNameString,
0,
&Function);
@@ -199,8 +193,8 @@ HANDLE
APIENTRY
EngLoadImage (LPWSTR DriverName)
{
HANDLE hImageHandle = NULL;
SYSTEM_GDI_DRIVER_INFORMATION GdiDriverInfo;
PDRIVERS DriverInfo = NULL;
NTSTATUS Status;
RtlInitUnicodeString(&GdiDriverInfo.DriverName, DriverName);
@@ -213,14 +207,14 @@ EngLoadImage (LPWSTR DriverName)
{
Current = CONTAINING_RECORD(CurrentEntry, DRIVERS, ListEntry);
if( Current && (0 == RtlCompareUnicodeString(&GdiDriverInfo.DriverName, &Current->DriverName, FALSE)) ) {
hImageHandle = Current->ImageHandle;
DriverInfo = Current;
break;
}
CurrentEntry = CurrentEntry->Flink;
};
}
if( !hImageHandle )
if( !DriverInfo )
{
/* the driver was not loaded before, so let's do that */
Status = ZwSetSystemInformation(SystemLoadGdiDriverInformation, &GdiDriverInfo, sizeof(SYSTEM_GDI_DRIVER_INFORMATION));
@@ -228,19 +222,18 @@ EngLoadImage (LPWSTR DriverName)
DPRINT1("ZwSetSystemInformation failed with Status 0x%lx\n", Status);
}
else {
PDRIVERS DriverInfo;
hImageHandle = (HANDLE)GdiDriverInfo.ImageAddress;
DriverInfo = ExAllocatePool(PagedPool, sizeof(DRIVERS));
DriverInfo->DriverName.MaximumLength = GdiDriverInfo.DriverName.MaximumLength;
DriverInfo->DriverName.Length = GdiDriverInfo.DriverName.Length;
DriverInfo->DriverName.Buffer = ExAllocatePool(PagedPool, GdiDriverInfo.DriverName.MaximumLength);
RtlCopyUnicodeString(&DriverInfo->DriverName, &GdiDriverInfo.DriverName);
DriverInfo->ImageHandle = hImageHandle;
DriverInfo->SectionPointer = GdiDriverInfo.SectionPointer;
DriverInfo->BaseAddress = GdiDriverInfo.ImageAddress;
InsertHeadList(&GlobalDriverListHead, &DriverInfo->ListEntry);
}
}
return hImageHandle;
return DriverInfo;
}
VOID
@@ -248,11 +241,12 @@ APIENTRY
EngUnloadImage ( IN HANDLE hModule )
{
NTSTATUS Status;
PDRIVERS DriverInfo = (PDRIVERS)hModule;
DPRINT("hModule 0x%x\n", hModule);
Status = ZwSetSystemInformation(SystemUnloadGdiDriverInformation,
&hModule, sizeof(HANDLE));
DriverInfo->SectionPointer, sizeof(PVOID));
if(!NT_SUCCESS(Status))
{
@@ -261,28 +255,10 @@ EngUnloadImage ( IN HANDLE hModule )
}
else
{
/* remove from the list */
if( !IsListEmpty(&GlobalDriverListHead) )
{
PLIST_ENTRY CurrentEntry = GlobalDriverListHead.Flink;
PDRIVERS Current;
/* probably the driver was already loaded, let's try to find it out */
while( CurrentEntry != &GlobalDriverListHead )
{
Current = CONTAINING_RECORD(CurrentEntry, DRIVERS, ListEntry);
if( Current ) {
if(Current->ImageHandle == hModule) {
ExFreePool(Current->DriverName.Buffer);
RemoveEntryList(&Current->ListEntry);
ExFreePool(Current);
break;
ExFreePool(DriverInfo->DriverName.Buffer);
RemoveEntryList(&DriverInfo->ListEntry);
ExFreePool(DriverInfo);
}
}
CurrentEntry = CurrentEntry->Flink;
};
}
}
}
/* EOF */
@@ -1154,7 +1154,7 @@ IntGetClassAtom(IN PUNICODE_STRING ClassName,
&pi->pclsPrivateList,
Link);
if (Class != NULL)
{
{ DPRINT("Step 1: 0x%x\n",Class );
goto FoundClass;
}
@@ -1165,7 +1165,7 @@ IntGetClassAtom(IN PUNICODE_STRING ClassName,
&pi->pclsPublicList,
Link);
if (Class != NULL)
{
{ DPRINT("Step 2: 0x%x 0x%x\n",Class, Class->hModule);
goto FoundClass;
}
@@ -1175,7 +1175,7 @@ IntGetClassAtom(IN PUNICODE_STRING ClassName,
&pi->pclsPrivateList,
Link);
if (Class != NULL)
{
{ DPRINT("Step 3: 0x%x\n",Class );
goto FoundClass;
}
@@ -1188,7 +1188,7 @@ IntGetClassAtom(IN PUNICODE_STRING ClassName,
{
SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
return (RTL_ATOM)0;
}
}else{DPRINT("Step 4: 0x%x\n",Class );}
FoundClass:
*BaseClass = Class;
@@ -2402,6 +2402,7 @@ InvalidParameter:
if (Ret)
{
DPRINT("GetClassInfo(%wZ, 0x%x)\n", ClassName, hInstance);
ClassAtom = IntGetClassAtom( &SafeClassName,
hInstance,
ppi,
@@ -581,10 +581,10 @@ NtUserEmptyClipboard(VOID)
return ret;
}
HANDLE APIENTRY
DWORD_PTR APIENTRY
NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
{
HANDLE ret = NULL;
DWORD_PTR ret = 0;
UserEnterShared();
@@ -607,7 +607,7 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
co_IntSendMessage(ClipboardOwnerWindow->hSelf, WM_RENDERFORMAT, (WPARAM)uFormat, 0);
data = intIsFormatAvailable(uFormat);
ASSERT(data->size);
ret = (HANDLE)(ULONG_PTR)data->size;
ret = data->size;
}
}
else
@@ -618,12 +618,12 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
}
}
ret = (HANDLE)(ULONG_PTR)data->size;
ret = data->size;
}
else
{
/* there is no data in this format */
//ret = (HANDLE)FALSE;
//ret = FALSE;
}
}
else
@@ -646,12 +646,12 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
PCLIPBOARDELEMENT data = intIsFormatAvailable(CF_DIB);
if (data)
{
ret = renderBITMAPfromDIB(data->hData);
ret = (DWORD_PTR)renderBITMAPfromDIB(data->hData);
}
}
else
{
ret = (HANDLE)pBuffer;
ret = (DWORD_PTR)pBuffer;
_SEH2_TRY
{
@@ -660,7 +660,7 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ret = NULL;
ret = 0;
}
_SEH2_END
@@ -669,7 +669,7 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
}
else
{
ret = (HANDLE)pBuffer;
ret = (DWORD_PTR)pBuffer;
_SEH2_TRY
{
@@ -678,7 +678,7 @@ NtUserGetClipboardData(UINT uFormat, PVOID pBuffer)
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ret = NULL;
ret = 0;
}
_SEH2_END
}
@@ -77,8 +77,10 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
/* Send palette messages */
if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
{
co_IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING,
(WPARAM)hWnd, 0);
UserPostMessage( HWND_BROADCAST,
WM_PALETTEISCHANGING,
(WPARAM)hWnd,
0);
}
if (UserGetWindow(hWnd, GW_HWNDPREV) != NULL)
@@ -163,7 +163,7 @@ static BOOL UserLoadKbdDll(WCHAR *wsKLID,
DPRINT("Loaded %wZ\n", &FullLayoutPath);
RtlInitAnsiString( &kbdProcedureName, "KbdLayerDescriptor" );
LdrGetProcedureAddress((PVOID)*phModule,
LdrGetProcedureAddress((*(PDRIVERS*)phModule)->BaseAddress,
&kbdProcedureName,
0,
(PVOID*)&layerDescGetFn);
@@ -419,7 +419,7 @@ CLEANUP:
BOOL FASTCALL
IntTranslateKbdMessage(LPMSG lpMsg,
HKL dwhkl)
UINT Flags)
{
PTHREADINFO pti;
static INT dead_char = 0;
@@ -335,6 +335,9 @@ IntDispatchMessage(PMSG pMsg)
LARGE_INTEGER TickCount;
LONG Time;
LRESULT retval;
PMSGMEMORY MsgMemoryEntry;
INT lParamBufferSize;
LPARAM lParamPacked;
PWINDOW_OBJECT Window = NULL;
if (pMsg->hwnd)
@@ -376,9 +379,37 @@ IntDispatchMessage(PMSG pMsg)
}
}
// Need a window!
if (!Window) return 0;
if ( !Window || !Window->Wnd ) return 0;
retval = co_IntPostOrSendMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
/* See if this message type is present in the table */
MsgMemoryEntry = FindMsgMemory(pMsg->message);
if ( !MsgMemoryEntry )
{
lParamBufferSize = -1;
}
else
{
lParamBufferSize = MsgMemorySize(MsgMemoryEntry, pMsg->wParam, pMsg->lParam);
}
if (! NT_SUCCESS(PackParam(&lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam)))
{
DPRINT1("Failed to pack message parameters\n");
return 0;
}
retval = co_IntCallWindowProc( Window->Wnd->lpfnWndProc,
!Window->Wnd->Unicode,
pMsg->hwnd,
pMsg->message,
pMsg->wParam,
lParamPacked,
lParamBufferSize);
if (! NT_SUCCESS(UnpackParam(lParamPacked, pMsg->message, pMsg->wParam, pMsg->lParam)))
{
DPRINT1("Failed to unpack message parameters\n");
}
if (pMsg->message == WM_PAINT)
{
@@ -482,7 +513,7 @@ NtUserDispatchMessage(PMSG UnsafeMsgInfo)
BOOL APIENTRY
NtUserTranslateMessage(LPMSG lpMsg,
HKL dwhkl)
UINT Flags)
{
NTSTATUS Status;
MSG SafeMsg;
@@ -498,7 +529,7 @@ NtUserTranslateMessage(LPMSG lpMsg,
RETURN( FALSE);
}
RETURN( IntTranslateKbdMessage(&SafeMsg, dwhkl));
RETURN( IntTranslateKbdMessage(&SafeMsg, Flags));
CLEANUP:
DPRINT("Leave NtUserTranslateMessage: ret=%i\n",_ret_);
@@ -1324,7 +1355,7 @@ UserPostThreadMessage( DWORD idThread,
if( Status == STATUS_SUCCESS )
{
pThread = (PTHREADINFO)peThread->Tcb.Win32Thread;
if( !pThread || !pThread->MessageQueue )
if( !pThread || !pThread->MessageQueue || (pThread->TIF_flags & TIF_INCLEANUP))
{
ObDereferenceObject( peThread );
return FALSE;
@@ -1370,7 +1401,6 @@ UserPostMessage(HWND Wnd,
wParam,
lParam);
pti = PsGetCurrentThreadWin32Thread();
if (Wnd == HWND_BROADCAST)
{
HWND *List;
@@ -1392,10 +1422,18 @@ UserPostMessage(HWND Wnd,
PWINDOW_OBJECT Window;
Window = UserGetWindowObject(Wnd);
if (NULL == Window)
if ( !Window || !Window->Wnd )
{
return FALSE;
}
pti = Window->Wnd->head.pti;
if ( pti->TIF_flags & TIF_INCLEANUP )
{
DPRINT1("Attempted to post message to window 0x%x when the thread is in cleanup!\n", Wnd);
return FALSE;
}
if(Window->Status & WINDOWSTATUS_DESTROYING)
{
DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd);
@@ -1761,6 +1799,9 @@ co_IntDoSendMessage(HWND hWnd,
Info.Ansi = !Window->Wnd->Unicode;
Info.Proc = Window->Wnd->lpfnWndProc;
// Make the call from here if CALLWNDPROC or CALLWNDPROCRET are hooked
// or just do it in User32!
IntCallWndProcRet( Window, hWnd, Msg, wParam, lParam, &Result);
}
else
@@ -462,7 +462,7 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT Win
*ScreenPoint = Message->Msg.pt;
if((Window != NULL && (int)Window != 1 && CaptureWindow->hSelf != Window->hSelf) ||
if((Window != NULL && PtrToInt(Window) != 1 && CaptureWindow->hSelf != Window->hSelf) ||
((FilterLow != 0 || FilterHigh != 0) && (Msg < FilterLow || Msg > FilterHigh)))
{
/* Reject the message because it doesn't match the filter */
@@ -1383,7 +1383,7 @@ co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
{
CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
ListEntry);
if ((!Window || (int)Window == 1 || Window->hSelf == CurrentMessage->Msg.hwnd) &&
if ((!Window || PtrToInt(Window) == 1 || Window->hSelf == CurrentMessage->Msg.hwnd) &&
((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
(MsgFilterLow <= CurrentMessage->Msg.message &&
MsgFilterHigh >= CurrentMessage->Msg.message)))
@@ -1997,7 +1997,7 @@ MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue,
Timer = CONTAINING_RECORD(MessageQueue->TimerListHead.Flink,
TIMER_ENTRY, ListEntry);
EnumEntry = EnumEntry->Flink;
if ((NULL == WndFilter || (int)WndFilter == 1 || Timer->Wnd == WndFilter->hSelf) &&
if ((NULL == WndFilter || PtrToInt(WndFilter) == 1 || Timer->Wnd == WndFilter->hSelf) &&
((MsgFilterMin == 0 && MsgFilterMax == 0) ||
(MsgFilterMin <= Timer->Msg &&
Timer->Msg <= MsgFilterMax)))
@@ -15,6 +15,11 @@
/** Functions *****************************************************************/
/*
flOpts :
GetTextExtentPoint32W = 0
GetTextExtentPointW = 1
*/
BOOL
FASTCALL
GreGetTextExtentW(
@@ -65,6 +70,12 @@ GreGetTextExtentW(
return Result;
}
/*
fl :
GetTextExtentExPointW = 0 and everything else that uses this.
GetTextExtentExPointI = 1
*/
BOOL
FASTCALL
GreGetTextExtentExW(
@@ -235,6 +246,12 @@ NtGdiGetTextCharsetInfo(
return Ret;
}
/*
fl :
GetTextExtentExPointW = 0 and everything else that uses this.
GetTextExtentExPointI = 1
*/
W32KAPI
BOOL
APIENTRY
@@ -389,6 +406,12 @@ NtGdiGetTextExtentExW(
return TRUE;
}
/*
flOpts :
GetTextExtentPoint32W = 0
GetTextExtentPointW = 1
*/
BOOL
APIENTRY
NtGdiGetTextExtent(HDC hdc,
@@ -1,4 +1,3 @@
#include "include/reactos/msvctarget.h"
#undef i386
@ stdcall -arch=i386 FLOATOBJ_AddFloatObj(ptr ptr) FLOATOBJ_Add
+11 -14
View File
@@ -1,10 +1,17 @@
<?xml version="1.0"?>
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
<group>
<module name="win32k_base" type="objectlibrary" allowwarnings="true">
<include base="win32k_base">.</include>
<include base="win32k_base">include</include>
<include base="win32k_base" root="intermediate">.</include>
<module name="win32k" type="kernelmodedriver" installbase="system32" installname="win32k.sys" crt="libcntpr" allowwarnings="true">
<importlibrary definition="win32k.pspec" />
<library>pseh</library>
<library>ntoskrnl</library>
<library>hal</library>
<library>ftfd</library>
<library>dxguid</library>
<file>win32k.rc</file>
<include base="win32k">.</include>
<include base="win32k">include</include>
<include base="win32k" root="intermediate">.</include>
<include base="ntoskrnl">include</include>
<include base="freetype">include</include>
<include base="ReactOS">include/reactos/subsys</include>
@@ -202,14 +209,4 @@
<!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38054#c7 -->
<compilerflag compilerset="gcc">-fno-unit-at-a-time</compilerflag>
</module>
<module name="win32k" type="kernelmodedriver" installbase="system32" installname="win32k.sys" crt="libcntpr">
<importlibrary definition="win32k.pspec" />
<library>win32k_base</library>
<library>pseh</library>
<library>ntoskrnl</library>
<library>hal</library>
<library>ftfd</library>
<library>dxguid</library>
<file>win32k.rc</file>
</module>
</group>
@@ -598,7 +598,7 @@ CBBackend::_generate_cbproj ( const Module& module )
if ( sys )
{
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint(false) == "" ? "DriverEntry@8" : module.GetEntryPoint(false).c_str ());
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint() == "" ? "DriverEntry@8" : module.GetEntryPoint().c_str ());
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x10000" : baseaddr.c_str () );
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--nostdlib\" />\r\n" );
}
@@ -623,7 +623,7 @@ CBBackend::_generate_cbproj ( const Module& module )
}
else if ( dll )
{
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint(false).c_str () );
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint().c_str () );
fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x40000" : baseaddr.c_str () );
if ( module.type == Win32DLL)
@@ -1,32 +1,83 @@
#~ #(module, objs, deps, ldflags, output, libs, subsys, entry, base, falign, salign)
#~ define RBUILD_LINK
LDFLAG_DLL:=-shared
LDFLAG_DRIVER:=-shared --subsystem=native
LDFLAG_NOSTDLIB:=-nostartfiles -nostdlib
LDFLAG_CONSOLE:=--subsystem=console
LDFLAG_WINDOWS:=--subsystem=windows
LDFLAG_NATIVE:=--subsystem=native
#~ $(5) ${call RBUILD_output_dir,$(5)}$$(SEP)$(basename $(notdir $(5))).map: $(2) $(3) $(6) | ${call RBUILD_dir,$(5)}
#~ $$(ECHO_CC)
#~ $${ld} -subsystem=$(7) -entry=$(8) -base=$(9) -file-alignment=$(10) -section-alignment=$(11) $(2) $(6) ${call RBUILD_ldflags,$(1),$(4)} -o $(5)
#~ ifeq ($(ROS_BUILDMAP),full)
#~ $$(ECHO_OBJDUMP)
#~ $${objdump} -d -S $$@ > ${call RBUILD_output_dir,$(5)}$$(SEP)$(basename $(notdir $(5))).map
#~ else
#~ ifeq ($(ROS_BUILDMAP),yes)
#~ $$(ECHO_NM)
#~ $${nm} --numeric-sort $$@ > ${call RBUILD_output_dir,$(5)}$$(SEP)$(basename $(notdir $(5))).map
#~ endif
#~ endif
#~ ifeq ($(ROS_BUILDNOSTRIP),yes)
#~ $$(ECHO_CP)
#~ $${cp} $(5) $(basename $(5)).nostrip$(suffix $(5)) 1>$(NUL)
#~ endif
#~ ifneq ($(ROS_GENERATE_RSYM),no)
#~ $$(ECHO_RSYM)
#~ $$(Q)$$(rsym_TARGET) $$@ $$@
#~ endif
#~ ifeq ($(ROS_LEAN_AND_MEAN),yes)
#~ $$(ECHO_STRIP)
#~ $${strip} -s -x -X $$@
#~ endif
#~ #(module, objs, deps, ldflags, output, def, libs, entry, base)
#(module, objs, deps, ldflags, output, def, libs, entry, base, extralibs)
define RBUILD_LINK
#~ endef
ifneq ($(6),)
${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.a: $(6) | ${call RBUILD_intermediate_path,$(5)}
$$(ECHO_IMPLIB)
$${dlltool} --def $(6) --kill-at --output-lib=$$@
#~ #(module, dependencies, ldflags, subsys, entry, base, falign, salign)
#~ RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(1)_OBJS,$(2),$(3),$(1)_TARGET,$(1)_LIBS,$(4),$(5),$(6),$(7),$(8)}
${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.delayimp.a: $(6) | ${call RBUILD_intermediate_path,$(5)}
$$(ECHO_IMPLIB)
$${dlltool} --def $(6) --kill-at --output-delaylib=$$@
${call RBUILD_intermediate_path_noext,$(5)}.exp: $(6) | ${call RBUILD_intermediate_path,$(5)}
$$(ECHO_IMPLIB)
$${dlltool} --def $(6) --kill-at --output-exp=$$@
$(1)_CLEANFILES+=\
${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib$(notdir $(5)).a \
${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib$(notdir $(5)).delayimp.a \
${call RBUILD_intermediate_path_noext,$(5)}.exp
endif
# TODO: refactor this out of here and into rules.mak
${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp: $(2) $$(if $(6),${call RBUILD_intermediate_path_noext,$(5)}.exp) $(3) | ${call RBUILD_intermediate_dir,$(5)}
$$(ECHO_RSP)
-@$${rm} $$@ 2>$$(NUL)
$${cp} $$(NUL) $$@ >$$(NUL)
$$(foreach obj,$(2) $$(if $(6),${call RBUILD_intermediate_path_noext,$(5)}.exp),$$(Q)echo $$(QUOTE)$$(subst \,\\,$$(obj))$$(QUOTE)>>$$@$$(NL))
$(1)_CLEANFILES+=${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp
$(5): ${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(7) $(3) $$(RSYM_TARGET) $$(PEFIXUP_TARGET) | ${call RBUILD_dir,$(5)}
$$(ECHO_LD)
#~ $${ld} --entry=$(8) --image-base=$(9) @${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(7) ${call RBUILD_ldflags,$(1),$(4)} -o $$@
$${ld} --entry=$(8) --image-base=$(9) @${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(10) $(7) $(10) ${call RBUILD_ldflags,$(1),$(4)} -o $$@
ifneq ($(or $(6),$$(MODULETYPE$$($(1)_TYPE)_KMODE)),)
$$(ECHO_PEFIXUP)
$$(Q)$$(PEFIXUP_TARGET) $$@ $(if $(6),-exports) $$(if $$(MODULETYPE$($(1)_TYPE)_KMODE),-sections)
endif
ifeq ($(ROS_BUILDMAP),full)
$$(ECHO_OBJDUMP)
$${objdump} -d -S $$@ > ${call RBUILD_output_path_noext,$(5)}.map
else
ifeq ($(ROS_BUILDMAP),yes)
$$(ECHO_NM)
$${nm} --numeric-sort $$@ > ${call RBUILD_output_path_noext,$(5)}.map
endif
endif
ifeq ($(ROS_BUILDNOSTRIP),yes)
$$(ECHO_CP)
$${cp} $(5) $(basename $(5)).nostrip$(suffix $(5)) 1>$(NUL)
endif
ifneq ($(ROS_GENERATE_RSYM),no)
$$(ECHO_RSYM)
$$(Q)$$(RSYM_TARGET) $$@ $$@
endif
ifeq ($(ROS_LEAN_AND_MEAN),yes)
$$(ECHO_STRIP)
$${strip} -s -x -X $$@
endif
ifneq ($(ROS_BUILDMAP),)
$(1)_CLEANFILES+=${call RBUILD_output_path_noext,$(5)}.map
endif
ifeq ($(ROS_BUILDNOSTRIP),yes)
$(1)_CLEANFILES+=$(basename $(5)).nostrip$(suffix $(5))
endif
endef
#~ #(module, def, deps, ldflags, libs, entry, base)
#~ RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(value $(1)_OBJS),$(3),$(4),$(value $(1)_TARGET),$(2),$(5) $(value $(1)_LIBS) $(5),$(6),$(7)}
#(module, def, deps, ldflags, libs, entry, base, extralibs)
RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(value $(1)_OBJS),$(3),$(4),$(value $(1)_TARGET),$(2),$(value $(1)_LIBS),$(6),$(7),$(5)}
+50 -41
View File
@@ -38,16 +38,16 @@ const struct ModuleHandlerInformations ModuleHandlerInformations[] = {
{ HostTrue, "", "", "" }, // BuildTool
{ HostFalse, "", "", "" }, // StaticLibrary
{ HostFalse, "", "", "" }, // ObjectLibrary
{ HostFalse, "", "", "" }, // Kernel
{ HostFalse, "", "", "" }, // KernelModeDLL
{ HostFalse, "-D__NTDRIVER__", "", "" }, // KernelModeDriver
{ HostFalse, "", "", "" }, // NativeDLL
{ HostFalse, "-D__NTAPP__", "", "" }, // NativeCUI
{ HostFalse, "", "", "" }, // Win32DLL
{ HostFalse, "", "", "" }, // Win32OCX
{ HostFalse, "", "", "" }, // Win32CUI
{ HostFalse, "", "", "" }, // Win32GUI
{ HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootLoader
{ HostFalse, "", "", "$(LDFLAG_DRIVER)" }, // Kernel
{ HostFalse, "", "", "$(LDFLAG_DRIVER)" }, // KernelModeDLL
{ HostFalse, "-D__NTDRIVER__", "", "$(LDFLAG_DRIVER)" }, // KernelModeDriver
{ HostFalse, "", "", "$(LDFLAG_DLL)" }, // NativeDLL
{ HostFalse, "-D__NTAPP__", "", "$(LDFLAG_NATIVE)" }, // NativeCUI
{ HostFalse, "", "", "$(LDFLAG_DLL)" }, // Win32DLL
{ HostFalse, "", "", "$(LDFLAG_DLL)" }, // Win32OCX
{ HostFalse, "", "", "$(LDFLAG_CONSOLE)" }, // Win32CUI
{ HostFalse, "", "", "$(LDFLAG_WINDOWS)" }, // Win32GUI
{ HostFalse, "", "", "" }, // BootLoader
{ HostFalse, "", "-f bin", "" }, // BootSector
{ HostFalse, "", "", "" }, // Iso
{ HostFalse, "", "", "" }, // LiveIso
@@ -55,8 +55,8 @@ const struct ModuleHandlerInformations ModuleHandlerInformations[] = {
{ HostFalse, "", "", "" }, // RpcServer
{ HostFalse, "", "", "" }, // RpcClient
{ HostFalse, "", "", "" }, // Alias
{ HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootProgram
{ HostFalse, "", "", "" }, // Win32SCR
{ HostFalse, "", "", "" }, // BootProgram
{ HostFalse, "", "", "$(LDFLAG_WINDOWS)" }, // Win32SCR
{ HostFalse, "", "", "" }, // IdlHeader
{ HostFalse, "", "", "" }, // IdlInterface
{ HostFalse, "", "", "" }, // EmbeddedTypeLib
@@ -64,7 +64,7 @@ const struct ModuleHandlerInformations ModuleHandlerInformations[] = {
{ HostFalse, "", "", "" }, // RpcProxy
{ HostTrue, "", "", "" }, // HostStaticLibrary
{ HostFalse, "", "", "" }, // Cabinet
{ HostFalse, "", "", "" }, // KeyboardLayout
{ HostFalse, "", "", "$(LDFLAG_DLL)" }, // KeyboardLayout
{ HostFalse, "", "", "" }, // MessageHeader
};
@@ -413,17 +413,17 @@ MingwBackend::GenerateGlobalProperties (
}
string
MingwBackend::GenerateProjectLFLAGS () const
MingwBackend::GenerateProjectLDFLAGS () const
{
string lflags;
string ldflags;
for ( size_t i = 0; i < ProjectNode.linkerFlags.size (); i++ )
{
LinkerFlag& linkerFlag = *ProjectNode.linkerFlags[i];
if ( lflags.length () > 0 )
lflags += " ";
lflags += linkerFlag.flag;
if ( ldflags.length () > 0 )
ldflags += " ";
ldflags += linkerFlag.flag;
}
return lflags;
return ldflags;
}
void
@@ -478,24 +478,21 @@ MingwBackend::GenerateGlobalVariables () const
// Would be nice to have our own C++ runtime
fputs ( "BUILTIN_CXXINCLUDES+= $(TARGET_CPPFLAGS)\n", fMakefile );
}
// Because RosBE gcc is built to suck
fputs ( "BUILTIN_HOST_CINCLUDES+= $(HOST_CFLAGS)\n", fMakefile );
fputs ( "BUILTIN_HOST_CPPINCLUDES+= $(HOST_CFLAGS)\n", fMakefile );
fputs ( "BUILTIN_HOST_CXXINCLUDES+= $(HOST_CPPFLAGS)\n", fMakefile );
fprintf ( fMakefile, "PROJECT_CCLIBS := \"$(shell ${TARGET_CC} -print-libgcc-file-name)\"\n" );
fprintf ( fMakefile, "PROJECT_CXXLIBS := \"$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libgcc.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)\"\n" );
/* hack to get libgcc_eh.a, should check mingw version or something */
if (Environment::GetArch() == "amd64")
{
fprintf ( fMakefile, "PROJECT_LPPFLAGS += $(shell ${TARGET_CPP} -print-file-name=libgcc_eh.a)\n" );
}
}
MingwModuleHandler::GenerateParameters ( "PROJECT", "+=", ProjectNode.non_if_data );
MingwModuleHandler::GenerateParameters ( "PROJECT_HOST", "+=", ProjectNode.host_non_if_data );
// TODO: linker flags
fprintf ( fMakefile, "PROJECT_LFLAGS := '$(shell ${TARGET_CC} -print-libgcc-file-name)' %s\n", GenerateProjectLFLAGS ().c_str () );
fprintf ( fMakefile, "PROJECT_LPPFLAGS := '$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)' '$(shell ${TARGET_CPP} -print-file-name=libgcc.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)'\n" );
/* hack to get libgcc_eh.a, should check mingw version or something */
if (Environment::GetArch() == "amd64")
{
fprintf ( fMakefile, "PROJECT_LPPFLAGS += '$(shell ${TARGET_CPP} -print-file-name=libgcc_eh.a)'\n" );
}
fprintf ( fMakefile, "PROJECT_LDFLAGS := %s\n", GenerateProjectLDFLAGS ().c_str () );
// TODO: use symbolic names for module types
for ( size_t i = 0; i < sizeof(ModuleHandlerInformations) / sizeof(ModuleHandlerInformations[0]); ++ i )
@@ -509,15 +506,6 @@ MingwBackend::GenerateGlobalVariables () const
ModuleHandlerInformations[i].cflags );
}
if ( ModuleHandlerInformations[i].cflags && ModuleHandlerInformations[i].cflags[0] )
{
fprintf ( fMakefile,
"MODULETYPE%d_%sFLAGS:=%s\n",
(int)i,
"CXX",
ModuleHandlerInformations[i].cflags );
}
if ( ModuleHandlerInformations[i].nasmflags && ModuleHandlerInformations[i].nasmflags[0] )
{
fprintf ( fMakefile,
@@ -526,8 +514,29 @@ MingwBackend::GenerateGlobalVariables () const
"NASM",
ModuleHandlerInformations[i].nasmflags );
}
if ( ModuleHandlerInformations[i].linkerflags && ModuleHandlerInformations[i].linkerflags[0] )
{
fprintf ( fMakefile,
"MODULETYPE%d_%sFLAGS:=%s\n",
(int)i,
"LD",
ModuleHandlerInformations[i].linkerflags );
}
}
fprintf ( fMakefile,
"MODULETYPE%d_KMODE:=yes\n",
(int)Kernel );
fprintf ( fMakefile,
"MODULETYPE%d_KMODE:=yes\n",
(int)KernelModeDLL );
fprintf ( fMakefile,
"MODULETYPE%d_KMODE:=yes\n",
(int)KernelModeDriver );
fprintf ( fMakefile, "\n" );
}
+1 -1
View File
@@ -66,7 +66,7 @@ private:
void GenerateHeader () const;
void GenerateGlobalProperties ( const char* assignmentOperation,
const IfableData& data ) const;
std::string GenerateProjectLFLAGS () const;
std::string GenerateProjectLDFLAGS () const;
void GenerateDirectories ();
void GenerateGlobalVariables () const;
bool IncludeInAllTarget ( const Module& module ) const;
@@ -290,9 +290,7 @@ MingwModuleHandler::GetModuleArchiveFilename () const
{
if ( IsStaticLibrary ( module ) )
return GetTargetFilename ( module, NULL );
return new FileLocation ( IntermediateDirectory,
module.output->relative_path,
ReplaceExtension ( module.name, ".temp.a" ) );
return NULL;
}
/*static*/ bool
@@ -518,6 +516,9 @@ MingwModuleHandler::GenerateCleanTarget () const
}
fprintf ( fMakefile, " 2>$(NUL)\n" );
// Clean files generated by external rules
fprintf ( fMakefile, "\t-@${rm} $(%s_CLEANFILES) 2>$(NUL)\n", module.name.c_str() );
if( ProxyMakefile::GenerateProxyMakefile(module) )
{
DirectoryLocation root;
@@ -1359,25 +1360,6 @@ MingwModuleHandler::GenerateBuildMapCode ( const FileLocation *mapTarget )
"endif\n" );
}
void
MingwModuleHandler::GenerateBuildNonSymbolStrippedCode ()
{
fprintf ( fMakefile, "# BUILD NO STRIP CODE\n" );
fprintf ( fMakefile,
"ifeq ($(ROS_BUILDNOSTRIP),yes)\n" );
FileLocation nostripFilename ( OutputDirectory,
module.output->relative_path,
GetBasename ( module.output->name ) + ".nostrip" + GetExtension ( *module.output ) );
CLEAN_FILE ( nostripFilename );
OutputCopyCommand ( *module.output, nostripFilename );
fprintf ( fMakefile,
"endif\n" );
}
void
MergeStringVector ( const Backend* backend,
const vector<FileLocation>& input,
@@ -1438,159 +1420,62 @@ MingwModuleHandler::GenerateCleanObjectsAsYouGoCode () const
}
void
MingwModuleHandler::GenerateRunRsymCode () const
MingwModuleHandler::GenerateLinkerCommand () const
{
fprintf ( fMakefile, "# RUN RSYM CODE\n" );
fprintf ( fMakefile,
"ifneq ($(ROS_GENERATE_RSYM),no)\n" );
fprintf ( fMakefile,
"\t$(ECHO_RSYM)\n" );
fprintf ( fMakefile,
"\t$(Q)$(RSYM_TARGET) $@ $@\n\n" );
fprintf ( fMakefile,
"endif\n" );
string definitionFilename;
const FileLocation *DefinitionFilename = GetDefinitionFilename ();
if ( DefinitionFilename ) {
definitionFilename = backend->GetFullName (*DefinitionFilename);
delete DefinitionFilename;
}
void
MingwModuleHandler::GenerateRunStripCode () const
{
fprintf ( fMakefile, "# RUN STRIP CODE\n" );
fprintf ( fMakefile,
"ifeq ($(ROS_LEAN_AND_MEAN),yes)\n" );
fprintf ( fMakefile,
"\t$(ECHO_STRIP)\n" );
fprintf ( fMakefile,
"\t${strip} -s -x -X $@\n\n" );
fprintf ( fMakefile,
"endif\n" );
}
void
MingwModuleHandler::GenerateLinkerCommand (
const string& dependencies,
const string& linkerParameters,
const string& pefixupParameters )
{
const FileLocation *target_file = GetTargetFilename ( module, NULL );
const FileLocation *definitionFilename = GetDefinitionFilename ();
string linker = "${ld}";
string objectsMacro = GetObjectsMacro ( module );
string libsMacro = GetLibsMacro ();
fprintf ( fMakefile, "# LINKER COMMAND\n" );
string target_macro ( GetTargetMacro ( module ) );
string target_folder ( backend->GetFullPath ( *target_file ) );
string linkerScriptArgument;
if ( module.linkerScript != NULL )
if ( module.linkerScript != NULL ) {
if ( module.project.configuration.Linker == GnuLd )
linkerScriptArgument = ssprintf ( " -T %s", backend->GetFullName ( *module.linkerScript->file ).c_str () );
else
linkerScriptArgument = "";
/* check if we need to add default C++ libraries, ie if we have
* a C++ user-mode module without the -nostdlib linker flag
*/
bool link_defaultlibs = module.cplusplus &&
linkerParameters.find ("-nostdlib") == string::npos &&
!(module.type == KernelModeDLL || module.type == KernelModeDriver);
if ( !module.HasImportLibrary() )
{
fprintf ( fMakefile,
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
target_macro.c_str (),
definitionFilename ? backend->GetFullName ( *definitionFilename ).c_str () : "",
dependencies.c_str (),
target_folder.c_str () );
fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
fprintf ( fMakefile,
"\t%s %s%s %s %s %s %s -o %s\n",
linker.c_str (),
linkerParameters.c_str (),
linkerScriptArgument.c_str (),
objectsMacro.c_str (),
link_defaultlibs ? "$(PROJECT_LPPFLAGS) " : "",
libsMacro.c_str (),
GetLinkerMacro ().c_str (),
target_macro.c_str () );
}
else
{
FileLocation temp_exp ( IntermediateDirectory,
module.output->relative_path,
module.name + ".exp" );
CLEAN_FILE ( temp_exp );
fprintf ( fMakefile,
"%s: %s | %s\n",
backend->GetFullName ( temp_exp ).c_str (),
definitionFilename ? backend->GetFullName ( *definitionFilename ).c_str () : "",
backend->GetFullPath ( temp_exp ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-exp $@%s%s\n",
module.GetDllName ().c_str (),
definitionFilename ? backend->GetFullName ( *definitionFilename ).c_str () : "",
module.mangledSymbols ? "" : " --kill-at",
module.underscoreSymbols ? " --add-underscore" : "" );
fprintf ( fMakefile,
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
target_macro.c_str (),
backend->GetFullName ( temp_exp ).c_str (),
dependencies.c_str (),
target_folder.c_str () );
fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
fprintf ( fMakefile,
"\t%s %s%s %s %s %s %s %s -o %s\n",
linker.c_str (),
linkerParameters.c_str (),
linkerScriptArgument.c_str (),
backend->GetFullName ( temp_exp ).c_str (),
objectsMacro.c_str (),
link_defaultlibs ? "$(PROJECT_LPPFLAGS) " : "",
libsMacro.c_str (),
GetLinkerMacro ().c_str (),
target_macro.c_str () );
fprintf ( fMakefile,
"\t$(Q)$(PEFIXUP_TARGET) %s -exports%s\n",
target_macro.c_str (),
pefixupParameters.c_str() );
fprintf ( stderr,
"Linker doesn't support linker scripts: linker script %s ignored for module %s\n",
backend->GetFullName ( *module.linkerScript->file ).c_str (),
module.name.c_str() );
}
GenerateBuildMapCode ();
GenerateBuildNonSymbolStrippedCode ();
GenerateRunRsymCode ();
GenerateRunStripCode ();
GenerateCleanObjectsAsYouGoCode ();
string extraLibraries;
if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) {
if ( module.cplusplus ) {
switch ( module.type )
{
case Win32DLL:
case Win32OCX:
case Win32CUI:
case Win32GUI:
case Win32SCR:
extraLibraries = "$$(PROJECT_CXXLIBS)";
break;
if ( definitionFilename )
delete definitionFilename;
delete target_file;
}
default:
extraLibraries = "$$(PROJECT_CCLIBS)";
break;
}
} else
extraLibraries = "$$(PROJECT_CCLIBS)";
}
void
MingwModuleHandler::GeneratePhonyTarget() const
{
string targetMacro ( GetTargetMacro ( module ) );
const FileLocation *target_file = GetTargetFilename ( module, NULL );
delete PassThruCacheDirectory ( new FileLocation ( module.output->directory, module.output->relative_path, "" ) );
delete PassThruCacheDirectory ( new FileLocation ( IntermediateDirectory, module.output->relative_path, "" ) );
fprintf ( fMakefile, "# PHONY TARGET\n" );
fprintf ( fMakefile,
".PHONY: %s\n\n",
targetMacro.c_str ());
fprintf ( fMakefile, "%s: | %s\n",
targetMacro.c_str (),
backend->GetFullPath ( *target_file ).c_str () );
delete target_file;
}
fprintf ( fMakefile,
"$(eval $(call RBUILD_LINK_RULE,%s,%s,%s,%s,%s,%s,%s))\n",
module.name.c_str(),
definitionFilename.c_str(),
module.xmlbuildFile.c_str(),
linkerScriptArgument.c_str (),
extraLibraries.c_str(),
module.GetEntryPoint().c_str(),
module.baseaddress.c_str() );
}
void
MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
@@ -1598,8 +1483,6 @@ MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
size_t i;
string moduleDependencies;
fprintf ( fMakefile, "# OBJECT FILE TARGETS\n" );
const vector<CompilationUnit*>& compilationUnits = data.compilationUnits;
for ( i = 0; i < compilationUnits.size (); i++ )
{
@@ -1642,8 +1525,6 @@ MingwModuleHandler::GenerateObjectFileTargets ( const IfableData& data )
void
MingwModuleHandler::GenerateObjectFileTargets ()
{
fprintf ( fMakefile, "# OBJECT FILE TARGETS\n" );
if ( module.pch && use_pch )
{
@@ -1660,12 +1541,9 @@ MingwModuleHandler::GenerateObjectFileTargets ()
pchCxxRule.Execute ( fMakefile, backend, module, module.pch->file, clean_files, dependencies );
else
pchRule.Execute ( fMakefile, backend, module, module.pch->file, clean_files, dependencies );
fprintf ( fMakefile, "\n" );
}
GenerateObjectFileTargets ( module.non_if_data );
fprintf ( fMakefile, "\n" );
}
/* caller needs to delete the returned object */
@@ -1673,6 +1551,10 @@ const FileLocation*
MingwModuleHandler::GenerateArchiveTarget ()
{
const FileLocation *archiveFilename = GetModuleArchiveFilename ();
if ( archiveFilename == NULL )
return NULL;
const FileLocation *definitionFilename = GetDefinitionFilename ();
fprintf ( fMakefile, "# ARCHIVE TARGET\n" );
@@ -1687,11 +1569,8 @@ MingwModuleHandler::GenerateArchiveTarget ()
backend->GetFullName ( *definitionFilename ).c_str () );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib $@%s%s\n",
module.GetDllName ().c_str (),
backend->GetFullName ( *definitionFilename ).c_str (),
module.mangledSymbols ? "" : " --kill-at",
module.underscoreSymbols ? " --add-underscore" : "" );
"\t${dlltool} --def %s --kill-at --output-lib $@\n",
backend->GetFullName ( *definitionFilename ).c_str () );
}
else
arRule1.Execute ( fMakefile, backend, module, archiveFilename, clean_files );
@@ -1727,7 +1606,7 @@ MingwModuleHandler::GetLibsMacro () const
string
MingwModuleHandler::GetLinkerMacro () const
{
return ssprintf ( "$(%s_LFLAGS)",
return ssprintf ( "$(%s_LDFLAGS)",
module.name.c_str () );
}
@@ -1842,7 +1721,7 @@ MingwModuleHandler::GenerateOtherMacros ()
{
set<const Define *> used_defs;
linkerflagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
linkerflagsMacro = ssprintf ("%s_LDFLAGS", module.name.c_str ());
libsMacro = ssprintf("%s_LIBS", module.name.c_str ());
const FileLocation * pchPath = GetPrecompiledHeaderPath ();
@@ -1897,28 +1776,6 @@ MingwModuleHandler::GenerateOtherMacros ()
GenerateParameters ( module.name.c_str(), "+=", module.non_if_data );
const char *linkerflags = ModuleHandlerInformations[module.type].linkerflags;
if ( strlen( linkerflags ) > 0 )
{
fprintf ( fMakefile,
"%s += %s\n\n",
linkerflagsMacro.c_str (),
linkerflags );
}
// FIXME: make rules for linker, move standard flags there
if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse )
{
if ( module.cplusplus )
fprintf ( fMakefile,
"%s+= $(PROJECT_LPPFLAGS)\n\n",
linkerflagsMacro.c_str () );
else
fprintf ( fMakefile,
"%s+= $(PROJECT_LFLAGS)\n\n",
linkerflagsMacro.c_str () );
}
GenerateMacros (
"+=",
module.non_if_data,
@@ -1957,6 +1814,8 @@ MingwModuleHandler::GenerateRules ()
if ( !ReferenceObjects ( module ) )
{
const FileLocation* ar_target = GenerateArchiveTarget ();
if ( ar_target )
delete ar_target;
}
@@ -2158,61 +2017,6 @@ MingwModuleHandler::GetDefinitionFilename () const
}
}
void
MingwModuleHandler::GenerateImportLibraryTarget (
const FileLocation *defFilename,
const FileLocation *library_target,
bool delayimp)
{
string empty = "tools" + sSep + "rbuild" + sSep + "empty.def";
fprintf ( fMakefile, "# IMPORT LIBRARY RULE\n" );
fprintf ( fMakefile, "%s:",
backend->GetFullName ( *library_target ).c_str () );
if ( defFilename )
{
fprintf ( fMakefile, " %s",
backend->GetFullName ( *defFilename ).c_str () );
}
fprintf ( fMakefile, " | %s\n",
backend->GetFullPath ( *library_target ).c_str () );
fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s %s %s%s%s\n\n",
module.GetDllName ().c_str (),
defFilename ? backend->GetFullName ( *defFilename ).c_str ()
: empty.c_str (),
delayimp ? "--output-delaylib" : "--output-lib",
backend->GetFullName ( *library_target ).c_str (),
module.mangledSymbols ? "" : " --kill-at",
module.underscoreSymbols ? " --add-underscore" : "" );
}
void
MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
{
if ( module.importLibrary != NULL )
{
const FileLocation *library_target = GetImportLibraryFilename ( module, &clean_files, false );
const FileLocation *delayimp_target = GetImportLibraryFilename ( module, &clean_files, true );
const FileLocation *defFilename = GetDefinitionFilename ();
GenerateImportLibraryTarget(defFilename, library_target, false);
GenerateImportLibraryTarget(defFilename, delayimp_target, true);
if ( defFilename )
delete defFilename;
delete library_target;
delete delayimp_target;
}
}
void
MingwModuleHandler::GetSpecObjectDependencies (
vector<FileLocation>& dependencies,
@@ -2402,31 +2206,9 @@ MingwKernelModuleHandler::Process ()
void
MingwKernelModuleHandler::GenerateKernelModuleTarget ()
{
string targetMacro ( GetTargetMacro ( module ) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=native -entry=%s -image-base=%s",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters + " $(NTOSKRNL_SHARED)",
" -sections" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler (
@@ -2453,30 +2235,9 @@ MingwKernelModeDLLModuleHandler::Process ()
void
MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ()
{
string targetMacro ( GetTargetMacro ( module ) );
string workingDirectory = GetWorkingDirectory ();
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
" -sections" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwNativeDLLModuleHandler::MingwNativeDLLModuleHandler (
@@ -2502,30 +2263,9 @@ MingwNativeDLLModuleHandler::Process ()
void
MingwNativeDLLModuleHandler::GenerateNativeDLLModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwNativeCUIModuleHandler::MingwNativeCUIModuleHandler (
@@ -2551,30 +2291,9 @@ MingwNativeCUIModuleHandler::Process ()
void
MingwNativeCUIModuleHandler::GenerateNativeCUIModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
@@ -2641,30 +2360,9 @@ MingwWin32DLLModuleHandler::Process ()
void
MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
void
@@ -2682,30 +2380,9 @@ MingwWin32OCXModuleHandler::Process ()
void
MingwWin32OCXModuleHandler::GenerateWin32OCXModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwWin32CUIModuleHandler::MingwWin32CUIModuleHandler (
@@ -2730,30 +2407,9 @@ MingwWin32CUIModuleHandler::Process ()
void
MingwWin32CUIModuleHandler::GenerateWin32CUIModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwWin32GUIModuleHandler::MingwWin32GUIModuleHandler (
@@ -2778,30 +2434,9 @@ MingwWin32GUIModuleHandler::Process ()
void
MingwWin32GUIModuleHandler::GenerateWin32GUIModuleTarget ()
{
string targetMacro ( GetTargetMacro (module) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=windows -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwBootLoaderModuleHandler::MingwBootLoaderModuleHandler (
@@ -2845,7 +2480,7 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
if (Environment::GetArch() == "arm")
{
fprintf ( fMakefile,
"\t${gcc} -Wl,--subsystem,native -o %s %s %s %s\n",
"\t${gcc} -Wl,--subsystem,native -o %s %s %s %s -nostartfiles -nostdlib\n",
backend->GetFullName ( junk_tmp ).c_str (),
objectsMacro.c_str (),
libsMacro.c_str (),
@@ -2854,7 +2489,7 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget ()
else
{
fprintf ( fMakefile,
"\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s\n",
"\t${gcc} -Wl,--subsystem,native -Wl,-Ttext,0x8000 -o %s %s %s %s -nostartfiles -nostdlib\n",
backend->GetFullName ( junk_tmp ).c_str (),
objectsMacro.c_str (),
libsMacro.c_str (),
@@ -3400,30 +3035,9 @@ MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUn
void
MingwTestModuleHandler::GenerateTestModuleTarget ()
{
string targetMacro ( GetTargetMacro ( module ) );
string workingDirectory = GetWorkingDirectory ( );
string libsMacro = GetLibsMacro ();
GenerateImportLibraryTargetIfNeeded ();
if ( module.non_if_data.compilationUnits.size () > 0 )
{
GenerateRules ();
string dependencies = libsMacro + " " + objectsMacro;
string linkerParameters = ssprintf ( "-subsystem=console -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000",
module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (),
module.baseaddress.c_str () );
GenerateLinkerCommand ( dependencies,
linkerParameters,
"" );
GenerateLinkerCommand ();
}
else
{
GeneratePhonyTarget();
}
}
MingwAliasModuleHandler::MingwAliasModuleHandler (
@@ -113,15 +113,9 @@ protected:
std::string GetLinkerMacro () const;
static std::string GetDebugFormat ();
void GenerateCleanObjectsAsYouGoCode () const;
void GenerateRunRsymCode () const;
void GenerateRunStripCode () const;
void GenerateLinkerCommand ( const std::string& dependencies,
const std::string& linkerParameters,
const std::string& pefixupParameters );
void GeneratePhonyTarget() const;
void GenerateLinkerCommand () const;
void GenerateBuildMapCode ( const FileLocation *mapTarget = NULL );
void GenerateRules ();
void GenerateImportLibraryTarget (const FileLocation *defFilename, const FileLocation *library_target, bool delayimp);
void GenerateImportLibraryTargetIfNeeded ();
void GetDefinitionDependencies ( std::vector<FileLocation>& dependencies ) const;
std::string GetLinkingDependencies () const;
+1 -1
View File
@@ -19,7 +19,7 @@ RBUILD_intermediate_dir=${call RBUILD_fullpath,$(value INTERMEDIATE)$(SEP)$(dir
RBUILD_output_dir=${call RBUILD_fullpath,$(value OUTPUT)$(SEP)$(dir ${call RBUILD_strip_prefixes,$(1)})}
#(source)
RBUILD_source_name=$(basename $(notdir $(1)))
RBUILD_name=$(basename $(notdir $(1)))
#(source)
RBUILD_dir=${call RBUILD_fullpath,$(dir ${call RBUILD_compress_prefixes,$(1)})}
+8 -3
View File
@@ -70,6 +70,7 @@ void MSVCBackend::Process()
m_configurations.push_back ( new MSVCConfiguration( Debug ));
m_configurations.push_back ( new MSVCConfiguration( Release ));
m_configurations.push_back ( new MSVCConfiguration( Speed ));
m_configurations.push_back ( new MSVCConfiguration( RosBuild ));
if (!only_msvc_headers)
{
@@ -123,6 +124,8 @@ void MSVCBackend::ProcessModules()
if (configuration.VSProjectVersion == "6.00")
_generate_dsp ( module );
else if (configuration.VSProjectVersion == "10.00")
_generate_vcxproj ( module );
else
_generate_vcproj ( module );
}
@@ -285,10 +288,12 @@ std::string MSVCBackend::_get_vc_dir ( void ) const
return "vc70";
else if ( configuration.VSProjectVersion == "7.10" )
return "vc71";
else if ( configuration.VSProjectVersion == "9.00" )
return "vc9";
else /* must be VS2005 */
else if ( configuration.VSProjectVersion == "8.00" )
return "vc8";
else if ( configuration.VSProjectVersion == "10.00" )
return "vc10";
else /* default to VS2008 */
return "vc9";
}
+37 -1
View File
@@ -25,6 +25,7 @@
#include "../backend.h"
class FileUnit
{
public:
@@ -34,9 +35,28 @@ class FileUnit
enum OptimizationType
{
RosBuild,
Debug,
Release,
Speed
Speed,
};
enum ConfigurationType
{
ConfigUnknown,
ConfigApp,
ConfigDll,
ConfigEmpty,
ConfigLib
};
enum BinaryType
{
BinUnknown,
Lib,
Dll,
Exe,
Sys
};
enum HeadersType
@@ -123,7 +143,23 @@ class MSVCBackend : public Backend
std::string _get_vc_dir ( void ) const;
// These are used in both _generate_vcproj and _generate_standard_configuration
std::vector<std::string> header_files;
std::vector<std::string> includes;
std::vector<std::string> includes_ros;
std::vector<std::string> libraries;
std::set<std::string> common_defines;
std::string baseaddr;
void _generate_standard_configuration(
FILE* OUT,
const Module& module,
const MSVCConfiguration& cfg,
BinaryType binaryType );
void _generate_makefile_configuration( FILE* OUT, const Module& module, const MSVCConfiguration& cfg );
void _generate_vcproj ( const Module& module );
void _generate_vcxproj ( const Module& module );
void _generate_sln_header ( FILE* OUT );
void _generate_sln_footer ( FILE* OUT );
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,177 @@
/*
* Copyright (C) 2009 Ged Murphy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include "msvc.h"
using std::string;
using std::vector;
using std::set;
typedef set<string> StringSet;
#ifdef OUT
#undef OUT
#endif//OUT
void
MSVCBackend::_generate_vcxproj ( const Module& module )
{
size_t i;
string vcproj_file = VcprojFileName(module);
string computername;
string username;
string intermediatedir = "";
if (getenv ( "USERNAME" ) != NULL)
username = getenv ( "USERNAME" );
if (getenv ( "COMPUTERNAME" ) != NULL)
computername = getenv ( "COMPUTERNAME" );
else if (getenv ( "HOSTNAME" ) != NULL)
computername = getenv ( "HOSTNAME" );
printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() );
FILE* OUT = fopen ( vcproj_file.c_str(), "wb" );
string path_basedir = module.GetPathToBaseDir ();
string intenv = Environment::GetIntermediatePath ();
string outenv = Environment::GetOutputPath ();
string outdir;
string intdir;
string vcdir;
if ( intenv == "obj-i386" )
intdir = path_basedir + "obj-i386"; /* append relative dir from project dir */
else
intdir = intenv;
if ( outenv == "output-i386" )
outdir = path_basedir + "output-i386";
else
outdir = outenv;
if ( configuration.UseVSVersionInPath )
{
vcdir = DEF_SSEP + _get_vc_dir();
}
bool include_idl = false;
vector<string> source_files, resource_files;
vector<const IfableData*> ifs_list;
ifs_list.push_back ( &module.project.non_if_data );
ifs_list.push_back ( &module.non_if_data );
while ( ifs_list.size() )
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
if (files[i]->file.directory != SourceDirectory)
continue;
// We want the full path here for directory support later on
string path = Path::RelativeFromDirectory (
files[i]->file.relative_path,
module.output->relative_path );
string file = path + std::string("\\") + files[i]->file.name;
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
resource_files.push_back ( file );
else if ( !stricmp ( Right(file,2).c_str(), ".h" ) )
header_files.push_back ( file );
else
source_files.push_back ( file );
}
const vector<Include*>& incs = data.includes;
for ( i = 0; i < incs.size(); i++ )
{
string path = Path::RelativeFromDirectory (
incs[i]->directory->relative_path,
module.output->relative_path );
if ( module.type != RpcServer && module.type != RpcClient )
{
if ( path.find ("/include/reactos/idl") != string::npos)
{
include_idl = true;
continue;
}
}
// switch between general headers and ros headers
if ( !strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 ) ||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\ddk", 11 ) ||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\GL", 10 ) ||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\psdk", 12 ) ||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\reactos\\wine", 20 ) )
{
if (strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 ))
// not crt include
includes_ros.push_back ( path );
}
else
{
includes.push_back ( path );
}
}
const vector<Library*>& libs = data.libraries;
for ( i = 0; i < libs.size(); i++ )
{
string libpath = outdir + "\\" + libs[i]->importedModule->output->relative_path + "\\" + _get_vc_dir() + "\\---\\" + libs[i]->name + ".lib";
libraries.push_back ( libpath );
}
const vector<Define*>& defs = data.defines;
for ( i = 0; i < defs.size(); i++ )
{
if ( defs[i]->backend != "" && defs[i]->backend != "msvc" )
continue;
if ( defs[i]->value[0] )
common_defines.insert( defs[i]->name + "=" + defs[i]->value );
else
common_defines.insert( defs[i]->name );
}
for ( std::map<std::string, Property*>::const_iterator p = data.properties.begin(); p != data.properties.end(); ++ p )
{
Property& prop = *p->second;
if ( strstr ( module.baseaddress.c_str(), prop.name.c_str() ) )
baseaddr = prop.value;
}
}
/* include intermediate path for reactos.rc */
string version = intdir + "\\include";
includes.push_back (version);
version += "\\reactos";
includes.push_back (version);
string include_string;
fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
}
+3 -14
View File
@@ -343,14 +343,6 @@ Module::Module ( const Project& project,
else
baseaddress = GetDefaultModuleBaseaddress ();
mangledSymbols = GetBooleanAttribute ( moduleNode, "mangledsymbols" );
att = moduleNode.GetAttribute ( "underscoresymbols", false );
if ( att != NULL )
underscoreSymbols = att->value == "true";
else
underscoreSymbols = false;
isStartupLib = GetBooleanAttribute ( moduleNode, "isstartuplib" );
isCRT = GetBooleanAttribute ( moduleNode, "iscrt", GetDefaultModuleIsCRT () );
@@ -1359,12 +1351,13 @@ Module::GetInvocationTarget ( const int index ) const
}
string
Module::GetEntryPoint(bool leadingUnderscore) const
Module::GetEntryPoint() const
{
string result = "";
if (entrypoint == "0" || entrypoint == "0x0")
return "0";
if (leadingUnderscore)
if (Environment::GetArch() != "arm")
result = "_";
result += entrypoint;
@@ -1874,10 +1867,6 @@ ImportLibrary::ImportLibrary ( const Project& project,
if ( dllname )
this->dllname = dllname->value;
else if ( module->type == StaticLibrary || module->type == HostStaticLibrary )
throw XMLInvalidBuildFileException (
node.location,
"<importlibrary> dllname attribute required." );
size_t index = definition->value.find_last_of ( "/\\" );
if ( index == string::npos )
+1 -3
View File
@@ -378,8 +378,6 @@ public:
ImportLibrary* delayImportLibrary;
Metadata* metadata;
Bootsector* bootSector;
bool mangledSymbols;
bool underscoreSymbols;
bool isUnicode;
bool isDefaultEntryPoint;
Bootstrap* bootstrap;
@@ -420,7 +418,7 @@ public:
bool IsDLL () const;
std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
std::string GetEntryPoint(bool leadingUnderscore) const;
std::string GetEntryPoint() const;
void GetTargets ( string_list& ) const;
std::string GetInvocationTarget ( const int index ) const;
bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
+5
View File
@@ -229,6 +229,7 @@ RBUILD_BACKEND_MSVC_BASE_SOURCES = $(addprefix $(RBUILD_MSVC_BASE_), \
msvc.cpp \
msvcmaker.cpp \
vcprojmaker.cpp \
vcxprojmaker.cpp \
)
RBUILD_BACKEND_SOURCES = \
@@ -530,6 +531,10 @@ $(RBUILD_MSVC_INT_)vcprojmaker.o: $(RBUILD_MSVC_BASE_)vcprojmaker.cpp $(RBUILD_H
$(ECHO_HOSTCC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
$(RBUILD_MSVC_INT_)vcxprojmaker.o: $(RBUILD_MSVC_BASE_)vcxprojmaker.cpp $(RBUILD_HEADERS) | $(RBUILD_MSVC_INT)
$(ECHO_HOSTCC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
$(RBUILD_TEST_TARGET): $(RBUILD_TEST_OBJECTS) $(INFLIB_HOST_OBJECTS) $(RBUILD_HEADERS) | $(RBUILD_OUT)
$(ECHO_HOSTLD)
${host_gpp} $(RBUILD_TEST_OBJECTS) $(INFLIB_HOST_OBJECTS) $(RBUILD_HOST_LFLAGS) -o $@
+2 -2
View File
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rbuild", "rbuild.vcproj", "{D9305AFB-499E-49F1-A865-99DD7E19E762}"
EndProject
Global
+10 -7
View File
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="9.00"
Name="rbuild"
ProjectGUID="{D9305AFB-499E-49F1-A865-99DD7E19E762}"
RootNamespace="rbuild"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -75,6 +76,8 @@
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/rbuild.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -95,9 +98,6 @@
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
@@ -166,6 +166,8 @@
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/rbuild.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -186,9 +188,6 @@
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
@@ -335,6 +334,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\backend\msvc\vcxprojmaker.cpp"
>
</File>
</Filter>
<Filter
Name="mingw"
+328 -91
View File
@@ -1,14 +1,6 @@
/*
* Usage: log2lines [-cd:fFhmrv] [<exefile> <offset>]
* Try log2lines -h
*
* This is a tool and is compiled using the host compiler,
* i.e. on Linux gcc and not mingw-gcc (cross-compiler).
* Therefore we can't include SDK headers and we have to
* duplicate some definitions here.
* Also note that the internal functions are "old C-style",
* returning an int, where a return of 0 means success and
* non-zero is failure.
* ReactOS log2lines
* Written by Jan Roeloffzen
*/
#include <stdio.h>
@@ -18,11 +10,12 @@
#include "rsym.h"
#define LOG2LINES_VERSION "1.1"
#define LOG2LINES_VERSION "1.5"
#define INVALID_BASE 0xFFFFFFFFL
#define DEF_OPT_DIR "output-i386"
#define SOURCES_ENV "_ROSBE_ROSSOURCEDIR"
#if defined (__DJGPP__) || defined (__WIN32__)
@@ -53,11 +46,21 @@
#define CP_FMT CP_CMD "%s %s > " DEV_NULL
#define CMD_7Z "7z"
//#define UNZIP_FMT_7Z "%s e -y %s -o%s > " DEV_NULL
#define UNZIP_FMT_7Z "%s e -y %s -o%s"
#define UNZIP_FMT "%s x -y -r %s -o%s > " DEV_NULL
#define UNZIP_FMT_CAB \
"%s x -y -r %s" PATH_STR "reactos" PATH_STR "reactos.cab -o%s" PATH_STR "reactos" PATH_STR "reactos > " DEV_NULL
#define LINESIZE 1024
#define NAMESIZE 80
#define log(outFile, fmt, ...) \
{ \
fprintf(outFile, fmt, ##__VA_ARGS__); \
if (logFile) \
fprintf(logFile, fmt, ##__VA_ARGS__); \
}
struct entry_struct
{
@@ -84,17 +87,31 @@ struct summ_struct
int redo;
int skipped;
int diff;
int majordiff;
int offset_errors;
int total;
};
struct lineinfo_struct
{
int valid;
char file1[LINESIZE];
char func1[NAMESIZE];
int nr1;
char file2[LINESIZE];
char func2[NAMESIZE];
int nr2;
};
typedef struct cache_struct CACHE;
typedef struct summ_struct SUMM;
typedef struct lineinfo_struct LINEINFO;
static CACHE cache;
static SUMM summ;
static LINEINFO lastLine;
static char *optchars = "bcd:fFhl:mMrstTuUvz:";
static char *optchars = "bcd:fFhl:mMrsS:tTuUvz:";
static int opt_buffered= 0; // -b
static int opt_help = 0; // -h
static int opt_force = 0; // -f
@@ -105,6 +122,7 @@ static int opt_mark = 0; // -m
static int opt_Mark = 0; // -M
static int opt_raw = 0; // -r
static int opt_stats = 0; // -s
static int opt_Source = 0; // -S
static int opt_twice = 0; // -t
static int opt_Twice = 0; // -T
static int opt_undo = 0; // -u
@@ -118,6 +136,63 @@ static FILE *logFile = NULL;
static char *cache_name;
static char *tmp_name;
static char sources_path[LINESIZE];
static void
clearLastLine(void)
{
memset(&lastLine, 0, sizeof(LINEINFO));
}
static void
log_file(FILE *outFile, char *fileName, int max )
{
int i = 0, min = 0;
char s[LINESIZE];
char p[LINESIZE];
FILE *src;
strcpy(p, sources_path);
strcat(p, fileName);
if ((src = fopen(p, "r")))
{
min = max - opt_Source;
min = (min < 0) ? 0 : min;
while (i < max && fgets(s, LINESIZE, src))
{
if (i >= min)
log(outFile, "| %4.4d %s", i + 1, s);
i++;
}
fclose(src);
}
else if (opt_verbose)
fprintf(stderr, "Can't open: %s (check " SOURCES_ENV ")\n", p);
}
static void
logSource(FILE *outFile)
{
log_file(outFile, lastLine.file1, lastLine.nr1);
if (lastLine.nr2)
{
log(outFile, "| ---- [%u] ----\n", lastLine.nr2);
log_file(outFile, lastLine.file2, lastLine.nr2);
}
}
static void
reportSource(FILE *outFile)
{
if (!opt_Source)
return;
if (lastLine.valid)
{
logSource(outFile);
}
clearLastLine();
}
static char *
basename(char *path)
{
@@ -152,7 +227,7 @@ find_rossym_section(PIMAGE_FILE_HEADER PEFileHeader, PIMAGE_SECTION_HEADER PESec
}
static PROSSYM_ENTRY
find_offset(void *data, size_t offset, char *toString)
find_offset(void *data, size_t offset)
{
PSYMBOLFILE_HEADER RosSymHeader = (PSYMBOLFILE_HEADER) data;
PROSSYM_ENTRY Entries = (PROSSYM_ENTRY) ((char *)data + RosSymHeader->SymbolsOffset);
@@ -180,61 +255,96 @@ print_offset(void *data, size_t offset, char *toString)
PSYMBOLFILE_HEADER RosSymHeader = (PSYMBOLFILE_HEADER) data;
PROSSYM_ENTRY e = NULL;
PROSSYM_ENTRY e2 = NULL;
int bFileOffsetChanged = 0;
char fmt[LINESIZE];
char *Strings = (char *)data + RosSymHeader->StringsOffset;
e = find_offset(data, offset, toString);
fmt[0] = '\0';
e = find_offset(data, offset);
if (opt_twice)
{
e2 = find_offset(data, offset-1, toString);
e2 = find_offset(data, offset - 1);
if ( e == e2 )
e2 = NULL;
else
summ.diff++;
if ( opt_Twice && e2 )
{
e = e2;
e2 = NULL;
/* replaced (transparantly), but update stats: */
summ.diff ++;
/* replaced (transparantly), but updated stats */
}
}
if ( e || e2 )
{
strcpy(lastLine.file1, &Strings[e->FileOffset]);
strcpy(lastLine.func1, &Strings[e->FunctionOffset]);
lastLine.nr1 = e->SourceLine;
lastLine.valid = 1;
if (e2)
{
strcpy(lastLine.file2, &Strings[e2->FileOffset]);
strcpy(lastLine.func2, &Strings[e2->FunctionOffset]);
lastLine.nr2 = e2->SourceLine;
bFileOffsetChanged = e->FileOffset != e2->FileOffset;
if (e->FileOffset != e2->FileOffset || e->FunctionOffset != e2->FunctionOffset)
summ.majordiff++;
/*
* - "%.0s" displays nothing, but processes argument
* - bFileOffsetChanged implies always display 2nd SourceLine even if the same
* - also for FunctionOffset
*/
strcat(fmt, "%s");
if (bFileOffsetChanged)
strcat(fmt, "[%s]");
else
strcat(fmt, "%.0s");
strcat(fmt, ":%u");
if (e->SourceLine != e2->SourceLine || bFileOffsetChanged)
strcat(fmt, "[%u]");
else
strcat(fmt, "%.0u");
strcat(fmt, " (%s");
if (e->FunctionOffset != e2->FunctionOffset || bFileOffsetChanged)
strcat(fmt, "[%s])");
else
strcat(fmt, "%.0s)");
if (toString)
{ // put in toString if provided
if ( e2 )
{
snprintf(toString, LINESIZE, "%s:%u (%s) [%s:%u (%s)]",
snprintf(toString, LINESIZE, fmt,
&Strings[e->FileOffset],
&Strings[e2->FileOffset],
(unsigned int)e->SourceLine,
(unsigned int)e2->SourceLine,
&Strings[e->FunctionOffset],
&Strings[e2->FileOffset],
(unsigned int)e2->SourceLine,
&Strings[e2->FunctionOffset]);
summ.diff ++;
}
else
{
snprintf(toString, LINESIZE, "%s:%u (%s)",
strcat(fmt, "\n");
printf(fmt,
&Strings[e->FileOffset],
&Strings[e2->FileOffset],
(unsigned int)e->SourceLine,
&Strings[e->FunctionOffset]);
(unsigned int)e2->SourceLine,
&Strings[e->FunctionOffset],
&Strings[e2->FunctionOffset]);
}
return 0;
}
else
{ // to stdout
if ( e2 )
{
printf("%s:%u (%s) [%s:%u (%s)]\n",
if (toString)
{ // put in toString if provided
snprintf(toString, LINESIZE, "%s:%u (%s)",
&Strings[e->FileOffset],
(unsigned int)e->SourceLine,
&Strings[e->FunctionOffset],
&Strings[e2->FileOffset],
(unsigned int)e2->SourceLine,
&Strings[e2->FunctionOffset]);
summ.diff ++;
&Strings[e->FunctionOffset]);
}
else
{
@@ -243,14 +353,14 @@ print_offset(void *data, size_t offset, char *toString)
(unsigned int)e->SourceLine,
&Strings[e->FunctionOffset]);
}
}
return 0;
}
}
return 1;
}
static int
process_data(const void *FileData, size_t FileSize, size_t offset, char *toString)
process_data(const void *FileData, size_t offset, char *toString)
{
PIMAGE_DOS_HEADER PEDosHeader;
PIMAGE_FILE_HEADER PEFileHeader;
@@ -309,10 +419,9 @@ process_data(const void *FileData, size_t FileSize, size_t offset, char *toStrin
return res;
}
static long
my_atoi(const char *a)
static const char *
getFmt(const char *a)
{
int i = 0;
const char *fmt = "%x";
if (*a == '0')
@@ -332,10 +441,26 @@ my_atoi(const char *a)
break;
}
}
sscanf(a, fmt, &i);
return fmt;
}
static long
my_atoi(const char *a)
{
int i = 0;
sscanf(a, getFmt(a), &i);
return i;
}
static int
isOffset(const char *a)
{
int i = 0;
if (strchr(a, '.'))
return 0;
return sscanf(a, getFmt(a), &i);
}
static int
file_exists(char *name)
{
@@ -387,7 +512,7 @@ process_file(const char *file_name, size_t offset, char *toString)
}
else
{
res = process_data(FileData, FileSize, offset, toString);
res = process_data(FileData, offset, toString);
free(FileData);
}
return res;
@@ -408,7 +533,7 @@ get_ImageBase(char *fname, size_t *ImageBase)
fr = fopen(fname, "rb");
if (!fr)
{
if (opt_verbose)
if (opt_verbose > 2)
fprintf(stderr, "get_ImageBase, cannot open '%s' (%s)\n", fname, strerror(errno));
return 1;
}
@@ -453,8 +578,8 @@ get_ImageBase(char *fname, size_t *ImageBase)
}
/* Check if it's really an IMAGE_OPTIONAL_HEADER we are interested in */
if ((PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC) &&
(PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC))
if (PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC &&
PEOptHeader.Magic != IMAGE_NT_OPTIONAL_HDR64_MAGIC)
{
if (opt_verbose > 1)
fprintf(stderr, "get_ImageBase %s, not an IMAGE_NT_OPTIONAL_HDR<32|64>\n", fname);
@@ -680,7 +805,7 @@ create_cache(int force, int skipImageBase)
if (*Fname == '\n')
*Fname = '\0';
while ((Fname > Line) && (*Fname != PATH_CHAR))
while (Fname > Line && *Fname != PATH_CHAR)
Fname--;
if (*Fname == PATH_CHAR)
Fname++;
@@ -786,9 +911,19 @@ translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
if (!*Line)
return;
res = 1;
mark = "";
s = remove_mark(Line);
if (opt_undo)
{
/* Strip all lines added by this tool: */
char buf[NAMESIZE];
if (sscanf(s, "| %s", buf) == 1)
if (buf[0] == '0' || strcmp(buf, "----") == 0 || atoi(buf))
res = 0;
}
sep = strchr(s, ':');
if (sep)
{
@@ -800,23 +935,19 @@ translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
{
tail = strchr(s, '>');
tail = tail ? tail-1 : tail;
if (tail && (tail[0] == ')') && (tail[1] == '>') )
if (tail && tail[0] == ')' && tail[1] == '>')
{
res = 0;
tail += 2;
mark = opt_mark ? "* " : "";
if (opt_redo && !(res = translate_file(path, offset, LineOut)))
{
fprintf(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
if (logFile)
fprintf(logFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
summ.redo ++;
}
else
{
fprintf(outFile, "%s<%s:%x>%s", mark, path, offset, tail);
if (logFile)
fprintf(logFile, "%s<%s:%x>%s", mark, path, offset, tail);
log(outFile, "%s<%s:%x>%s", mark, path, offset, tail);
summ.undo ++;
}
}
@@ -837,9 +968,7 @@ translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
if (!(res = translate_file(path, offset, LineOut)))
{
mark = opt_mark ? "* " : "";
fprintf(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
if (logFile)
fprintf(logFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
summ.translated ++;
}
else
@@ -855,9 +984,7 @@ translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
{
if (sep)
*sep = ':'; // restore because not translated
fprintf(outFile, "%s%s", mark, s); // just copy
if (logFile)
fprintf(logFile, "%s%s", mark, s); // just copy
log(outFile, "%s%s", mark, s);
}
memset(Line, '\0', LINESIZE); // flushed
}
@@ -873,6 +1000,7 @@ print_summary(FILE * outFile)
fprintf(outFile, "Retranslated: %d\n", summ.redo);
fprintf(outFile, "Skipped: %d\n", summ.skipped);
fprintf(outFile, "Differ: %d\n", summ.diff);
fprintf(outFile, "Differ (function/source): %d\n", summ.majordiff);
fprintf(outFile, "Offset error: %d\n", summ.offset_errors);
fprintf(outFile, "Total: %d\n", summ.total);
fprintf(outFile, "-------------------------------\n");
@@ -909,6 +1037,7 @@ translate_files(FILE * inFile, FILE * outFile)
translate_line(outFile, Line, path, LineOut);
i = 0;
translate_char(c, outFile);
reportSource(outFile);
break;
case '<':
i = 0;
@@ -927,7 +1056,6 @@ translate_files(FILE * inFile, FILE * outFile)
translate_line(outFile, Line, path, LineOut);
translate_char(c, outFile);
}
i = 0;
}
else
{
@@ -968,12 +1096,11 @@ translate_files(FILE * inFile, FILE * outFile)
if (!opt_raw)
{
translate_line(outFile, Line, path, LineOut);
reportSource(outFile);
}
else
{
fprintf(outFile, "%s", Line); // just copy
if (logFile)
fprintf(logFile, "%s", Line); // just copy
log(outFile, "%s", Line);
}
}
}
@@ -993,7 +1120,10 @@ translate_files(FILE * inFile, FILE * outFile)
static char *verboseUsage =
"\n"
"Description:\n"
" When <exefile> <offset> are given, log2lines works just like raddr2line\n"
" When <exefile> <offset> are given, log2lines works like raddr2line:\n"
" - The <exefile> <offset> combination can be repeated\n"
" - Also, <offset> can be repeated for each <exefile>\n"
" - NOTE: some of the options below will have no effect in this form.\n"
" Otherwise it reads stdin and tries to translate lines of the form:\n"
" <IMAGENAME:ADDRESS>\n\n"
" The result is written to stdout.\n"
@@ -1008,7 +1138,9 @@ static char *verboseUsage =
" -d <directory>|<ISO image>\n"
" Directory to scan for images. (Do not append a '" PATH_STR "')\n"
" This option also takes an ISO image as argument:\n"
" - The image is recognized by the '.iso' extension.\n"
" - The image is recognized by the '.iso' or '.7z' extension.\n"
" - NOTE: The '.7z' and extracted '.iso' basenames must be identical,\n"
" which is normally true for Reactos trunk builds.\n"
" - The image will be unpacked to a directory with the same name.\n"
" - The embedded reactos.cab file will also be unpacked.\n"
" - Combined with -f the file will be re-unpacked.\n"
@@ -1031,21 +1163,31 @@ static char *verboseUsage =
" - Retranslated: Lines retranslated. See -U option\n"
" - Skipped: Lines not translated.\n"
" - Differ: Lines where (addr-1) info differs. See -tT options\n"
" - Differ(func/src):Lines where also function or source info differ.\n"
" - Offset error: Image exists, but error retrieving offset info.\n"
" - Total: Total number of lines attempted to translate.\n"
" Also some version info is displayed.\n\n"
" -t Translate twice. The address itself and for (address - 1)\n"
" Display extra filename and linenumber between [..] if they differ\n\n"
" -T As -t, but the original filename+linenumber gets replaced\n\n"
" -S <context>\n"
" Source lines. Display up to <context> lines until linenumber.\n"
" The environment variable _ROSBE_ROSSOURCEDIR should be correctly set.\n"
" For a reliable result, these sources should be up to date with\n"
" the revision you test.\n"
" Can be combined with -tT.\n"
" Implies -U. Retranslation needed for retrieving source info.\n\n"
" -t Translate twice. The address itself and for (address - 1).\n"
" Show extra filename, func and linenumber between [..] if they differ\n"
" So if only the linenumbers differ, then only show the extra\n"
" linenumber.\n\n"
" -T As -t, but show only filename+func+linenumber for (address - 1.)\n\n"
" -u Undo translations.\n"
" Lines are translated back (reverted) to the form <IMAGENAME:ADDRESS>\n"
" Overrides console mode -c.\n\n"
" Also removes all lines previously added by this tool (see -S)\n\n"
" -U Undo and reprocess.\n"
" Reverted to the form <IMAGENAME:ADDRESS>, and then retranslated\n"
" Overrides console mode -c, implies -u.\n\n"
" Implies -u.\n\n"
" -v Show detailed errors and tracing.\n"
" Repeating this option adds more verbosity.\n"
" Default: only (major) errors\n" "\n\n"
" Default: only (major) errors\n\n"
" -z <path to 7z>\n"
" Specify path to 7z. See also option -d.\n"
" Default: '7z'\n"
@@ -1061,14 +1203,30 @@ static char *verboseUsage =
" Use kdbg debugger to send output to logfile:\n"
" log2lines < \\\\.\\pipe\\kdbg > dbg.log\n\n"
" Re-translate a debug log:\n"
" log2lines -d bootcd-38701-dbg.iso < bugxxxx.log\n\n"
" log2lines -U -d bootcd-38701-dbg.iso < bugxxxx.log\n\n"
" Re-translate a debug log. Specify a 7z file, which wil be decompressed.\n"
" Also check for (address) - (address - 1) differences:\n"
" log2lines -U -t -d bootcd-38701-dbg.7z < bugxxxx.log\n"
" This would generate loglines like:\n"
" '<ntdll.dll:60f1 (dll/ntdll/ldr/utils.c:337[331] (LdrPEStartup))>'\n\n"
" The following command line invocations are equivalent:\n"
" log2lines msi.dll 2e35d msi.dll 2235 msiexec.exe 30a8 msiexec.exe 2e89\n"
" log2lines msi.dll 2e35d 2235 msiexec.exe 30a8 2e89\n\n"
" Generate source lines from backtrace ('bt') output. Show 2 lines of context:\n"
" log2lines -S 2 -d bootcd-38701-dbg.7z < bugxxxx.log\n"
" <msiexec.exe:2e89 (lib/3rdparty/mingw/crtexe.c:259 (__tmainCRTStartup))>\n"
" | 0258 #else\n"
" | 0259 mainret = main (\n"
" <msiexec.exe:2fad (lib/3rdparty/mingw/crtexe.c:160 (WinMainCRTStartup))>\n"
" | 0159 return __tmainCRTStartup ();\n"
" | 0160 }\n"
"\n";
static void
usage(int verbose)
{
fprintf(stderr, "log2lines " LOG2LINES_VERSION "\n\n");
fprintf(stderr, "Usage: log2lines [-%s] [<exefile> <offset>]\n", optchars);
fprintf(stderr, "Usage: log2lines -%s {<exefile> <offset> {<offset>}}\n", optchars);
if (verbose)
{
fprintf(stderr, "%s", verboseUsage);
@@ -1135,10 +1293,51 @@ unpack_iso(char *dir, char *iso)
static int
check_directory(int force)
{
char Line[LINESIZE];
char freeldr_path[MAX_PATH];
char iso_path[MAX_PATH];
char compressed_7z_path[MAX_PATH];
char *check_iso;
char *check_dir;
check_iso = strrchr(opt_dir, '.');
if (check_iso && PATHCMP(check_iso, ".7z") == 0)
{
if (opt_verbose)
fprintf(stderr, "Uncompressing 7z image: %s\n", opt_dir);
// First attempt to decompress to a .iso image
strcpy(compressed_7z_path, opt_dir);
if ((check_dir = strrchr(compressed_7z_path, PATH_CHAR)))
{
*check_dir = '\0';
}
else
strcpy(compressed_7z_path, "."); // default to current dir
sprintf(Line, UNZIP_FMT_7Z, opt_7z, opt_dir, compressed_7z_path);
/* This of course only works if the .7z and .iso basenames are identical
* which is normally true for our trunk builds:
*/
strcpy(check_iso, ".iso");
if (!file_exists(opt_dir) || force)
{
if (system(Line) < 0)
{
fprintf(stderr, "\nCannot decompress to iso image %s\n", opt_dir);
if (opt_verbose)
fprintf(stderr, "Failed to execute: '%s'\n", Line);
return 2;
}
}
else
{
if (opt_verbose > 1)
fprintf(stderr, "%s already decompressed\n", opt_dir);
}
}
char *check_iso = strrchr(opt_dir, '.');
if (check_iso && PATHCMP(check_iso, ".iso") == 0)
{
if (opt_verbose)
@@ -1185,6 +1384,14 @@ main(int argc, const char **argv)
int opt;
int optCount = 0;
int i;
char *s;
strcpy(sources_path, "");
if ((s = getenv(SOURCES_ENV)))
{
strcpy(sources_path, s);
strcat(sources_path, PATH_STR);
}
strcpy(opt_scanned, "");
for (i=1; i<argc; i++)
@@ -1197,6 +1404,7 @@ main(int argc, const char **argv)
strcpy(opt_7z, CMD_7Z);
memset(&summ, 0, sizeof(SUMM));
clearLastLine();
while (-1 != (opt = getopt(argc, (char **const)argv, optchars)))
{
@@ -1218,7 +1426,7 @@ main(int argc, const char **argv)
case 'h':
opt_help++;
usage(1);
exit(0);
return 0;
break;
case 'F':
opt_exit++;
@@ -1240,6 +1448,10 @@ main(int argc, const char **argv)
case 's':
opt_stats++;
break;
case 'S':
optCount++;
opt_Source = atoi(optarg);
break;
case 't':
opt_twice++;
break;
@@ -1263,27 +1475,24 @@ main(int argc, const char **argv)
break;
default:
usage(0);
exit(2);
return 2;
break;
}
optCount++;
}
if (opt_undo)
opt_console = 0;
argc -= optCount;
if (argc != 1 && argc != 3)
if (opt_Source)
{
usage(0);
exit(1);
/* need to retranslate for source info: */
opt_undo++;
opt_redo++;
}
argc -= optCount;
if (check_directory(opt_force))
exit(3);
return 3;
create_cache(opt_force, 0);
if (opt_exit)
exit(0);
return 0;
read_cache();
@@ -1308,13 +1517,40 @@ main(int argc, const char **argv)
else
{
fprintf(stderr, "Could not open logfile %s (%s)\n", opt_logFile, strerror(errno));
exit(2);
return 2;
}
}
if (argc == 3)
{ // translate <exefile> <offset>
translate_file(argv[optCount + 1], my_atoi(argv[optCount + 2]), NULL);
if (argc > 1)
{ // translate {<exefile> <offset>}
int i = 1;
const char *base = NULL;
const char *offset = NULL;
while (i < argc)
{
offset = argv[optCount + i++];
if (isOffset(offset))
{
if (base)
{
if (opt_verbose > 1)
fprintf(stderr, "translating %s %s\n", base, offset);
translate_file(base, my_atoi(offset), NULL);
reportSource(stdout);
}
else
{
fprintf(stderr, "<exefile> expected\n");
res = 3;
break;
}
}
else
{
// Must be exefile
base = offset;
}
}
}
else
{ // translate logging from stdin
@@ -1323,5 +1559,6 @@ main(int argc, const char **argv)
if (logFile)
fclose(logFile);
return res;
}
+15 -2
View File
@@ -101,9 +101,16 @@ expr_t *make_exprs(enum expr_type type, char *val)
return e;
}
expr_t *make_exprt(enum expr_type type, type_t *tref, expr_t *expr)
expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr)
{
expr_t *e;
type_t *tref;
if (var->stgclass != STG_NONE && var->stgclass != STG_REGISTER)
error_loc("invalid storage class for type expression\n");
tref = var->type;
e = xmalloc(sizeof(expr_t));
e->type = type;
e->ref = expr;
@@ -125,6 +132,7 @@ expr_t *make_exprt(enum expr_type type, type_t *tref, expr_t *expr)
e->is_const = TRUE;
e->cval = expr->cval;
}
free(var);
return e;
}
@@ -297,15 +305,19 @@ static int is_integer_type(const type_t *type)
case TYPE_BASIC_INT32:
case TYPE_BASIC_INT64:
case TYPE_BASIC_INT:
case TYPE_BASIC_INT3264:
case TYPE_BASIC_CHAR:
case TYPE_BASIC_HYPER:
case TYPE_BASIC_BYTE:
case TYPE_BASIC_WCHAR:
case TYPE_BASIC_ERROR_STATUS_T:
return TRUE;
default:
case TYPE_BASIC_FLOAT:
case TYPE_BASIC_DOUBLE:
case TYPE_BASIC_HANDLE:
return FALSE;
}
return FALSE;
default:
return FALSE;
}
@@ -376,6 +388,7 @@ static type_t *find_identifier(const char *identifier, const type_t *cont_type,
case TYPE_INTERFACE:
case TYPE_POINTER:
case TYPE_ARRAY:
case TYPE_BITFIELD:
/* nothing to do */
break;
case TYPE_ALIAS:
+1 -1
View File
@@ -29,7 +29,7 @@ extern expr_t *make_expr(enum expr_type type);
extern expr_t *make_exprl(enum expr_type type, long val);
extern expr_t *make_exprd(enum expr_type type, double val);
extern expr_t *make_exprs(enum expr_type type, char *val);
extern expr_t *make_exprt(enum expr_type type, type_t *tref, expr_t *expr);
extern expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr);
extern expr_t *make_expr1(enum expr_type type, expr_t *expr);
extern expr_t *make_expr2(enum expr_type type, expr_t *exp1, expr_t *exp2);
extern expr_t *make_expr3(enum expr_type type, expr_t *expr1, expr_t *expr2, expr_t *expr3);
+35 -4
View File
@@ -265,6 +265,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
case TYPE_BASIC_INT16: fprintf(h, "short"); break;
case TYPE_BASIC_INT: fprintf(h, "int"); break;
case TYPE_BASIC_INT64: fprintf(h, "__int64"); break;
case TYPE_BASIC_INT3264: fprintf(h, "__int3264"); break;
case TYPE_BASIC_BYTE: fprintf(h, "byte"); break;
case TYPE_BASIC_CHAR: fprintf(h, "char"); break;
case TYPE_BASIC_WCHAR: fprintf(h, "wchar_t"); break;
@@ -294,6 +295,9 @@ void write_type_left(FILE *h, type_t *t, int declonly)
case TYPE_VOID:
fprintf(h, "void");
break;
case TYPE_BITFIELD:
write_type_left(h, type_bitfield_get_field(t), declonly);
break;
case TYPE_ALIAS:
case TYPE_FUNCTION:
/* handled elsewhere */
@@ -307,8 +311,13 @@ void write_type_right(FILE *h, type_t *t, int is_field)
{
if (!h) return;
if (type_get_type(t) == TYPE_ARRAY && !type_array_is_decl_as_ptr(t)) {
if (is_conformant_array(t)) {
switch (type_get_type(t))
{
case TYPE_ARRAY:
if (!type_array_is_decl_as_ptr(t))
{
if (is_conformant_array(t))
{
fprintf(h, "[%s]", is_field ? "1" : "");
t = type_array_get_element(t);
}
@@ -317,15 +326,34 @@ void write_type_right(FILE *h, type_t *t, int is_field)
t = type_array_get_element(t))
fprintf(h, "[%u]", type_array_get_dim(t));
}
break;
case TYPE_BITFIELD:
fprintf(h, " : %lu", type_bitfield_get_bits(t)->cval);
break;
case TYPE_VOID:
case TYPE_BASIC:
case TYPE_ENUM:
case TYPE_STRUCT:
case TYPE_ENCAPSULATED_UNION:
case TYPE_UNION:
case TYPE_ALIAS:
case TYPE_MODULE:
case TYPE_COCLASS:
case TYPE_FUNCTION:
case TYPE_INTERFACE:
case TYPE_POINTER:
break;
}
}
static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name)
{
type_t *pt;
type_t *pt = NULL;
int ptr_level = 0;
if (!h) return;
if (t) {
for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++)
;
@@ -342,9 +370,11 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
fputc('*', h);
} else
write_type_left(h, t, declonly);
}
if (name) fprintf(h, "%s%s", needs_space_after(t) ? " " : "", name );
if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name );
if (t) {
if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
const var_list_t *args = type_function_get_args(pt);
@@ -358,6 +388,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
} else
write_type_right(h, t, is_field);
}
}
void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name)
{
+3
View File
@@ -193,6 +193,7 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>\<= return LESSEQUAL;
<INITIAL,ATTR>\|\| return LOGICALOR;
<INITIAL,ATTR>&& return LOGICALAND;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>. return yytext[0];
<<EOF>> {
if (import_stack_ptr)
@@ -220,6 +221,7 @@ static const struct keyword keywords[] = {
{"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__fastcall", tFASTCALL},
{"__int3264", tINT3264},
{"__int64", tINT64},
{"__pascal", tPASCAL},
{"__stdcall", tSTDCALL},
@@ -279,6 +281,7 @@ static const struct keyword attr_keywords[] =
{
{"aggregatable", tAGGREGATABLE},
{"allocate", tALLOCATE},
{"annotation", tANNOTATION},
{"appobject", tAPPOBJECT},
{"async", tASYNC},
{"async_uuid", tASYNCUUID},
File diff suppressed because it is too large Load Diff
+134 -131
View File
@@ -57,136 +57,139 @@
LESSEQUAL = 273,
LOGICALOR = 274,
LOGICALAND = 275,
tAGGREGATABLE = 276,
tALLOCATE = 277,
tAPPOBJECT = 278,
tASYNC = 279,
tASYNCUUID = 280,
tAUTOHANDLE = 281,
tBINDABLE = 282,
tBOOLEAN = 283,
tBROADCAST = 284,
tBYTE = 285,
tBYTECOUNT = 286,
tCALLAS = 287,
tCALLBACK = 288,
tCASE = 289,
tCDECL = 290,
tCHAR = 291,
tCOCLASS = 292,
tCODE = 293,
tCOMMSTATUS = 294,
tCONST = 295,
tCONTEXTHANDLE = 296,
tCONTEXTHANDLENOSERIALIZE = 297,
tCONTEXTHANDLESERIALIZE = 298,
tCONTROL = 299,
tCPPQUOTE = 300,
tDEFAULT = 301,
tDEFAULTCOLLELEM = 302,
tDEFAULTVALUE = 303,
tDEFAULTVTABLE = 304,
tDISPLAYBIND = 305,
tDISPINTERFACE = 306,
tDLLNAME = 307,
tDOUBLE = 308,
tDUAL = 309,
tENDPOINT = 310,
tENTRY = 311,
tENUM = 312,
tERRORSTATUST = 313,
tEXPLICITHANDLE = 314,
tEXTERN = 315,
tFALSE = 316,
tFASTCALL = 317,
tFLOAT = 318,
tHANDLE = 319,
tHANDLET = 320,
tHELPCONTEXT = 321,
tHELPFILE = 322,
tHELPSTRING = 323,
tHELPSTRINGCONTEXT = 324,
tHELPSTRINGDLL = 325,
tHIDDEN = 326,
tHYPER = 327,
tID = 328,
tIDEMPOTENT = 329,
tIIDIS = 330,
tIMMEDIATEBIND = 331,
tIMPLICITHANDLE = 332,
tIMPORT = 333,
tIMPORTLIB = 334,
tIN = 335,
tIN_LINE = 336,
tINLINE = 337,
tINPUTSYNC = 338,
tINT = 339,
tINT64 = 340,
tINTERFACE = 341,
tLCID = 342,
tLENGTHIS = 343,
tLIBRARY = 344,
tLOCAL = 345,
tLONG = 346,
tMETHODS = 347,
tMODULE = 348,
tNONBROWSABLE = 349,
tNONCREATABLE = 350,
tNONEXTENSIBLE = 351,
tNULL = 352,
tOBJECT = 353,
tODL = 354,
tOLEAUTOMATION = 355,
tOPTIONAL = 356,
tOUT = 357,
tPASCAL = 358,
tPOINTERDEFAULT = 359,
tPROPERTIES = 360,
tPROPGET = 361,
tPROPPUT = 362,
tPROPPUTREF = 363,
tPTR = 364,
tPUBLIC = 365,
tRANGE = 366,
tREADONLY = 367,
tREF = 368,
tREGISTER = 369,
tREQUESTEDIT = 370,
tRESTRICTED = 371,
tRETVAL = 372,
tSAFEARRAY = 373,
tSHORT = 374,
tSIGNED = 375,
tSIZEIS = 376,
tSIZEOF = 377,
tSMALL = 378,
tSOURCE = 379,
tSTATIC = 380,
tSTDCALL = 381,
tSTRICTCONTEXTHANDLE = 382,
tSTRING = 383,
tSTRUCT = 384,
tSWITCH = 385,
tSWITCHIS = 386,
tSWITCHTYPE = 387,
tTRANSMITAS = 388,
tTRUE = 389,
tTYPEDEF = 390,
tUNION = 391,
tUNIQUE = 392,
tUNSIGNED = 393,
tUUID = 394,
tV1ENUM = 395,
tVARARG = 396,
tVERSION = 397,
tVOID = 398,
tWCHAR = 399,
tWIREMARSHAL = 400,
ADDRESSOF = 401,
NEG = 402,
POS = 403,
PPTR = 404,
CAST = 405
ELLIPSIS = 276,
tAGGREGATABLE = 277,
tALLOCATE = 278,
tANNOTATION = 279,
tAPPOBJECT = 280,
tASYNC = 281,
tASYNCUUID = 282,
tAUTOHANDLE = 283,
tBINDABLE = 284,
tBOOLEAN = 285,
tBROADCAST = 286,
tBYTE = 287,
tBYTECOUNT = 288,
tCALLAS = 289,
tCALLBACK = 290,
tCASE = 291,
tCDECL = 292,
tCHAR = 293,
tCOCLASS = 294,
tCODE = 295,
tCOMMSTATUS = 296,
tCONST = 297,
tCONTEXTHANDLE = 298,
tCONTEXTHANDLENOSERIALIZE = 299,
tCONTEXTHANDLESERIALIZE = 300,
tCONTROL = 301,
tCPPQUOTE = 302,
tDEFAULT = 303,
tDEFAULTCOLLELEM = 304,
tDEFAULTVALUE = 305,
tDEFAULTVTABLE = 306,
tDISPLAYBIND = 307,
tDISPINTERFACE = 308,
tDLLNAME = 309,
tDOUBLE = 310,
tDUAL = 311,
tENDPOINT = 312,
tENTRY = 313,
tENUM = 314,
tERRORSTATUST = 315,
tEXPLICITHANDLE = 316,
tEXTERN = 317,
tFALSE = 318,
tFASTCALL = 319,
tFLOAT = 320,
tHANDLE = 321,
tHANDLET = 322,
tHELPCONTEXT = 323,
tHELPFILE = 324,
tHELPSTRING = 325,
tHELPSTRINGCONTEXT = 326,
tHELPSTRINGDLL = 327,
tHIDDEN = 328,
tHYPER = 329,
tID = 330,
tIDEMPOTENT = 331,
tIIDIS = 332,
tIMMEDIATEBIND = 333,
tIMPLICITHANDLE = 334,
tIMPORT = 335,
tIMPORTLIB = 336,
tIN = 337,
tIN_LINE = 338,
tINLINE = 339,
tINPUTSYNC = 340,
tINT = 341,
tINT3264 = 342,
tINT64 = 343,
tINTERFACE = 344,
tLCID = 345,
tLENGTHIS = 346,
tLIBRARY = 347,
tLOCAL = 348,
tLONG = 349,
tMETHODS = 350,
tMODULE = 351,
tNONBROWSABLE = 352,
tNONCREATABLE = 353,
tNONEXTENSIBLE = 354,
tNULL = 355,
tOBJECT = 356,
tODL = 357,
tOLEAUTOMATION = 358,
tOPTIONAL = 359,
tOUT = 360,
tPASCAL = 361,
tPOINTERDEFAULT = 362,
tPROPERTIES = 363,
tPROPGET = 364,
tPROPPUT = 365,
tPROPPUTREF = 366,
tPTR = 367,
tPUBLIC = 368,
tRANGE = 369,
tREADONLY = 370,
tREF = 371,
tREGISTER = 372,
tREQUESTEDIT = 373,
tRESTRICTED = 374,
tRETVAL = 375,
tSAFEARRAY = 376,
tSHORT = 377,
tSIGNED = 378,
tSIZEIS = 379,
tSIZEOF = 380,
tSMALL = 381,
tSOURCE = 382,
tSTATIC = 383,
tSTDCALL = 384,
tSTRICTCONTEXTHANDLE = 385,
tSTRING = 386,
tSTRUCT = 387,
tSWITCH = 388,
tSWITCHIS = 389,
tSWITCHTYPE = 390,
tTRANSMITAS = 391,
tTRUE = 392,
tTYPEDEF = 393,
tUNION = 394,
tUNIQUE = 395,
tUNSIGNED = 396,
tUUID = 397,
tV1ENUM = 398,
tVARARG = 399,
tVERSION = 400,
tVOID = 401,
tWCHAR = 402,
tWIREMARSHAL = 403,
ADDRESSOF = 404,
NEG = 405,
POS = 406,
PPTR = 407,
CAST = 408
};
#endif
@@ -229,7 +232,7 @@ typedef union YYSTYPE
/* Line 1676 of yacc.c */
#line 233 "parser.tab.h"
#line 236 "parser.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+250 -83
View File
@@ -101,7 +101,7 @@ static attr_t *make_attrv(enum attr_type type, unsigned long val);
static attr_t *make_attrp(enum attr_type type, void *val);
static expr_list_t *append_expr(expr_list_t *list, expr_t *expr);
static array_dims_t *append_array(array_dims_t *list, expr_t *expr);
static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl, int top);
static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const declarator_t *decl, int top);
static var_list_t *set_var_types(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_list_t *decls);
static ifref_list_t *append_ifref(ifref_list_t *list, ifref_t *iface);
static ifref_t *make_ifref(type_t *iface);
@@ -121,7 +121,7 @@ static type_t *find_type_or_error2(char *name, int t);
static var_t *reg_const(var_t *var);
static char *gen_name(void);
static void check_arg(var_t *arg);
static void check_arg_attrs(const var_t *arg);
static void check_statements(const statement_list_t *stmts, int is_inside_library);
static void check_all_user_types(const statement_list_t *stmts);
static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs);
@@ -194,7 +194,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%token EQUALITY INEQUALITY
%token GREATEREQUAL LESSEQUAL
%token LOGICALOR LOGICALAND
%token tAGGREGATABLE tALLOCATE tAPPOBJECT tASYNC tASYNCUUID
%token ELLIPSIS
%token tAGGREGATABLE tALLOCATE tANNOTATION tAPPOBJECT tASYNC tASYNCUUID
%token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
%token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
%token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
@@ -224,7 +225,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%token tIMPORT tIMPORTLIB
%token tIN tIN_LINE tINLINE
%token tINPUTSYNC
%token tINT tINT64
%token tINT tINT3264 tINT64
%token tINTERFACE
%token tLCID
%token tLENGTHIS tLIBRARY
@@ -278,7 +279,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%type <attr> attribute type_qualifier function_specifier
%type <attr_list> m_attributes attributes attrib_list m_type_qual_list
%type <str_list> str_list
%type <expr> m_expr expr expr_const expr_int_const array
%type <expr> m_expr expr expr_const expr_int_const array m_bitfield
%type <expr_list> m_exprs /* exprs expr_list */ expr_list_int_const
%type <ifinfo> interfacehdr
%type <stgclass> storage_cls_spec
@@ -292,10 +293,13 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%type <ifref> coclass_int
%type <ifref_list> coclass_ints
%type <var> arg ne_union_field union_field s_field case enum declaration
%type <var_list> m_args no_args args fields ne_union_fields cases enums enum_list dispint_props field
%type <var_list> m_args arg_list args
%type <var_list> fields ne_union_fields cases enums enum_list dispint_props field
%type <var> m_ident ident
%type <declarator> declarator direct_declarator init_declarator
%type <declarator_list> declarator_list
%type <declarator> declarator direct_declarator init_declarator struct_declarator
%type <declarator> m_any_declarator any_declarator any_declarator_no_direct any_direct_declarator
%type <declarator> m_abstract_declarator abstract_declarator abstract_declarator_no_direct abstract_direct_declarator
%type <declarator_list> declarator_list struct_declarator_list
%type <func> funcdef
%type <type> coclass coclasshdr coclassdef
%type <num> pointer_type version
@@ -425,27 +429,24 @@ m_args: { $$ = NULL; }
| args
;
no_args: tVOID { $$ = NULL; }
arg_list: arg { check_arg_attrs($1); $$ = append_var( NULL, $1 ); }
| arg_list ',' arg { check_arg_attrs($3); $$ = append_var( $1, $3 ); }
;
args: arg { check_arg($1); $$ = append_var( NULL, $1 ); }
| args ',' arg { check_arg($3); $$ = append_var( $1, $3); }
| no_args
args: arg_list
| arg_list ',' ELLIPSIS { $$ = append_var( $1, make_var(strdup("...")) ); }
;
/* split into two rules to get bison to resolve a tVOID conflict */
arg: attributes decl_spec declarator { $$ = $3->var;
$$->attrs = $1;
if ($2->stgclass != STG_NONE && $2->stgclass != STG_REGISTER)
arg: attributes decl_spec m_any_declarator { if ($2->stgclass != STG_NONE && $2->stgclass != STG_REGISTER)
error_loc("invalid storage class for function parameter\n");
set_type($$, $2, $3, TRUE);
free($3);
$$ = declare_var($1, $2, $3, TRUE);
free($2); free($3);
}
| decl_spec declarator { $$ = $2->var;
if ($1->stgclass != STG_NONE && $1->stgclass != STG_REGISTER)
| decl_spec m_any_declarator { if ($1->stgclass != STG_NONE && $1->stgclass != STG_REGISTER)
error_loc("invalid storage class for function parameter\n");
set_type($$, $1, $2, TRUE);
free($2);
$$ = declare_var(NULL, $1, $2, TRUE);
free($1); free($2);
}
;
@@ -472,6 +473,7 @@ str_list: aSTRING { $$ = append_str( NULL, $1 ); }
attribute: { $$ = NULL; }
| tAGGREGATABLE { $$ = make_attr(ATTR_AGGREGATABLE); }
| tANNOTATION '(' aSTRING ')' { $$ = make_attrp(ATTR_ANNOTATION, $3); }
| tAPPOBJECT { $$ = make_attr(ATTR_APPOBJECT); }
| tASYNC { $$ = make_attr(ATTR_ASYNC); }
| tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); }
@@ -658,8 +660,10 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); }
| expr MEMBERPTR aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, make_expr1(EXPR_PPTR, $1), make_exprs(EXPR_IDENTIFIER, $3)); }
| expr '.' aIDENTIFIER { $$ = make_expr2(EXPR_MEMBER, $1, make_exprs(EXPR_IDENTIFIER, $3)); }
| '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); }
| tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); }
| '(' decl_spec m_abstract_declarator ')' expr %prec CAST
{ $$ = make_exprt(EXPR_CAST, declare_var(NULL, $2, $3, 0), $5); free($2); free($3); }
| tSIZEOF '(' decl_spec m_abstract_declarator ')'
{ $$ = make_exprt(EXPR_SIZEOF, declare_var(NULL, $3, $4, 0), NULL); free($3); free($4); }
| expr '[' expr ']' { $$ = make_expr2(EXPR_ARRAY, $1, $3); }
| '(' expr ')' { $$ = $2; }
;
@@ -684,7 +688,7 @@ fields: { $$ = NULL; }
| fields field { $$ = append_var_list($1, $2); }
;
field: m_attributes decl_spec declarator_list ';'
field: m_attributes decl_spec struct_declarator_list ';'
{ const char *first = LIST_ENTRY(list_head($3), declarator_t, entry)->var->name;
check_field_attrs(first, $1);
$$ = set_var_types($1, $2, $3);
@@ -709,17 +713,16 @@ union_field:
| ';' { $$ = NULL; }
;
s_field: m_attributes decl_spec declarator { $$ = $3->var;
$$->attrs = check_field_attrs($$->name, $1);
set_type($$, $2, $3, FALSE);
s_field: m_attributes decl_spec declarator { $$ = declare_var(check_field_attrs($3->var->name, $1),
$2, $3, FALSE);
free($3);
}
;
funcdef:
m_attributes decl_spec declarator { var_t *v = $3->var;
v->attrs = check_function_attrs(v->name, $1);
set_type(v, $2, $3, FALSE);
m_attributes decl_spec declarator { var_t *v;
v = declare_var(check_function_attrs($3->var->name, $1),
$2, $3, FALSE);
free($3);
$$ = make_func(v);
}
@@ -727,13 +730,10 @@ funcdef:
declaration:
attributes decl_spec init_declarator
{ $$ = $3->var;
$$->attrs = $1;
set_type($$, $2, $3, FALSE);
{ $$ = declare_var($1, $2, $3, FALSE);
free($3);
}
| decl_spec init_declarator { $$ = $2->var;
set_type($$, $1, $2, FALSE);
| decl_spec init_declarator { $$ = declare_var(NULL, $1, $2, FALSE);
free($2);
}
;
@@ -776,6 +776,7 @@ int_std: tINT { $$ = type_new_int(TYPE_BASIC_INT, 0); }
| tHYPER m_int { $$ = type_new_int(TYPE_BASIC_HYPER, 0); }
| tINT64 { $$ = type_new_int(TYPE_BASIC_INT64, 0); }
| tCHAR { $$ = type_new_int(TYPE_BASIC_CHAR, 0); }
| tINT3264 { $$ = type_new_int(TYPE_BASIC_INT3264, 0); }
;
coclass: tCOCLASS aIDENTIFIER { $$ = type_new_coclass($2); }
@@ -944,11 +945,104 @@ direct_declarator:
}
;
/* abstract declarator */
abstract_declarator:
'*' m_type_qual_list m_abstract_declarator %prec PPTR
{ $$ = $3; $$->type = append_ptrchain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
| callconv m_abstract_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
| abstract_direct_declarator
;
/* abstract declarator without accepting direct declarator */
abstract_declarator_no_direct:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; $$->type = append_ptrchain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
| callconv m_any_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
;
/* abstract declarator or empty */
m_abstract_declarator: { $$ = make_declarator(NULL); }
| abstract_declarator
;
/* abstract direct declarator */
abstract_direct_declarator:
'(' abstract_declarator_no_direct ')' { $$ = $2; }
| abstract_direct_declarator array { $$ = $1; $$->array = append_array($$->array, $2); }
| array { $$ = make_declarator(NULL); $$->array = append_array($$->array, $1); }
| '(' m_args ')'
{ $$ = make_declarator(NULL);
$$->func_type = append_ptrchain_type($$->type, type_new_function($2));
$$->type = NULL;
}
| abstract_direct_declarator '(' m_args ')'
{ $$ = $1;
$$->func_type = append_ptrchain_type($$->type, type_new_function($3));
$$->type = NULL;
}
;
/* abstract or non-abstract declarator */
any_declarator:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; $$->type = append_ptrchain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
| callconv m_any_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
| any_direct_declarator
;
/* abstract or non-abstract declarator without accepting direct declarator */
any_declarator_no_direct:
'*' m_type_qual_list m_any_declarator %prec PPTR
{ $$ = $3; $$->type = append_ptrchain_type($$->type, type_new_pointer(pointer_default, NULL, $2)); }
| callconv m_any_declarator { $$ = $2; $$->type->attrs = append_attr($$->type->attrs, make_attrp(ATTR_CALLCONV, $1)); }
;
/* abstract or non-abstract declarator or empty */
m_any_declarator: { $$ = make_declarator(NULL); }
| any_declarator
;
/* abstract or non-abstract direct declarator. note: direct declarators
* aren't accepted inside brackets to avoid ambiguity with the rule for
* function arguments */
any_direct_declarator:
ident { $$ = make_declarator($1); }
| '(' any_declarator_no_direct ')' { $$ = $2; }
| any_direct_declarator array { $$ = $1; $$->array = append_array($$->array, $2); }
| array { $$ = make_declarator(NULL); $$->array = append_array($$->array, $1); }
| '(' m_args ')'
{ $$ = make_declarator(NULL);
$$->func_type = append_ptrchain_type($$->type, type_new_function($2));
$$->type = NULL;
}
| any_direct_declarator '(' m_args ')'
{ $$ = $1;
$$->func_type = append_ptrchain_type($$->type, type_new_function($3));
$$->type = NULL;
}
;
declarator_list:
declarator { $$ = append_declarator( NULL, $1 ); }
| declarator_list ',' declarator { $$ = append_declarator( $1, $3 ); }
;
m_bitfield: { $$ = NULL; }
| ':' expr_const { $$ = $2; }
;
struct_declarator: any_declarator m_bitfield { $$ = $1; $$->bits = $2;
if (!$$->bits && !$$->var->name)
error_loc("unnamed fields are not allowed");
}
;
struct_declarator_list:
struct_declarator { $$ = append_declarator( NULL, $1 ); }
| struct_declarator_list ',' struct_declarator
{ $$ = append_declarator( $1, $3 ); }
;
init_declarator:
declarator { $$ = $1; }
| declarator '=' expr_const { $$ = $1; $1->var->eval = $3; }
@@ -1237,6 +1331,38 @@ static void type_function_add_head_arg(type_t *type, var_t *arg)
list_add_head( type->details.function->args, &arg->entry );
}
static int is_allowed_range_type(const type_t *type)
{
switch (type_get_type(type))
{
case TYPE_ENUM:
return TRUE;
case TYPE_BASIC:
switch (type_basic_get_type(type))
{
case TYPE_BASIC_INT8:
case TYPE_BASIC_INT16:
case TYPE_BASIC_INT32:
case TYPE_BASIC_INT64:
case TYPE_BASIC_INT:
case TYPE_BASIC_INT3264:
case TYPE_BASIC_BYTE:
case TYPE_BASIC_CHAR:
case TYPE_BASIC_WCHAR:
case TYPE_BASIC_HYPER:
return TRUE;
case TYPE_BASIC_FLOAT:
case TYPE_BASIC_DOUBLE:
case TYPE_BASIC_ERROR_STATUS_T:
case TYPE_BASIC_HANDLE:
return FALSE;
}
return FALSE;
default:
return FALSE;
}
}
static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type)
{
type_t *ptrchain_type;
@@ -1249,11 +1375,12 @@ static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type)
return ptrchain;
}
static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const declarator_t *decl,
int top)
{
expr_list_t *sizes = get_attrp(v->attrs, ATTR_SIZEIS);
expr_list_t *lengs = get_attrp(v->attrs, ATTR_LENGTHIS);
var_t *v = decl->var;
expr_list_t *sizes = get_attrp(attrs, ATTR_SIZEIS);
expr_list_t *lengs = get_attrp(attrs, ATTR_LENGTHIS);
int sizeless;
expr_t *dim;
type_t **ptype;
@@ -1278,6 +1405,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
/* add type onto the end of the pointers in pident->type */
v->type = append_ptrchain_type(decl ? decl->type : NULL, type);
v->stgclass = decl_spec->stgclass;
v->attrs = attrs;
/* check for pointer attribute being applied to non-pointer, non-array
* type */
@@ -1316,16 +1444,37 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
error_loc("%s: pointer attribute applied to non-pointer type\n", v->name);
}
if (is_attr(v->attrs, ATTR_STRING) && !is_ptr(v->type) && !arr)
if (is_attr(v->attrs, ATTR_STRING))
{
type_t *t = type;
if (!is_ptr(v->type) && !arr)
error_loc("'%s': [string] attribute applied to non-pointer, non-array type\n",
v->name);
while (is_ptr(t))
t = type_pointer_get_ref(t);
if (type_get_type(t) != TYPE_BASIC &&
(get_basic_fc(t) != RPC_FC_CHAR &&
get_basic_fc(t) != RPC_FC_BYTE &&
get_basic_fc(t) != RPC_FC_WCHAR))
{
error_loc("'%s': [string] attribute is only valid on 'char', 'byte', or 'wchar_t' pointers and arrays\n",
v->name);
}
}
if (is_attr(v->attrs, ATTR_V1ENUM))
{
if (type_get_type_detect_alias(v->type) != TYPE_ENUM)
error_loc("'%s': [v1_enum] attribute applied to non-enum type\n", v->name);
}
if (is_attr(v->attrs, ATTR_RANGE) && !is_allowed_range_type(v->type))
error_loc("'%s': [range] attribute applied to non-integer type\n",
v->name);
ptype = &v->type;
sizeless = FALSE;
if (arr) LIST_FOR_EACH_ENTRY_REV(dim, arr, expr_t, entry)
@@ -1442,6 +1591,11 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
if (is_attr(t->attrs, ATTR_CALLCONV))
error_loc("calling convention applied to non-function-pointer type\n");
}
if (decl->bits)
v->type = type_new_bitfield(v->type, decl->bits);
return v;
}
static var_list_t *set_var_types(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_list_t *decls)
@@ -1451,13 +1605,11 @@ static var_list_t *set_var_types(attr_list_t *attrs, decl_spec_t *decl_spec, dec
LIST_FOR_EACH_ENTRY_SAFE( decl, next, decls, declarator_t, entry )
{
var_t *var = decl->var;
var->attrs = attrs;
set_type(var, decl_spec, decl, 0);
var_t *var = declare_var(attrs, decl_spec, decl, 0);
var_list = append_var(var_list, var);
free(decl);
}
free(decl_spec);
return var_list;
}
@@ -1531,10 +1683,11 @@ static declarator_list_t *append_declarator(declarator_list_t *list, declarator_
static declarator_t *make_declarator(var_t *var)
{
declarator_t *d = xmalloc(sizeof(*d));
d->var = var;
d->var = var ? var : make_var(NULL);
d->type = NULL;
d->func_type = NULL;
d->array = NULL;
d->bits = NULL;
return d;
}
@@ -1675,27 +1828,8 @@ static void fix_incomplete_types(type_t *complete_type)
static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, attr_list_t *attrs)
{
const declarator_t *decl;
int is_str = is_attr(attrs, ATTR_STRING);
type_t *type = decl_spec->type;
if (is_str)
{
type_t *t = decl_spec->type;
while (is_ptr(t))
t = type_pointer_get_ref(t);
if (type_get_type(t) != TYPE_BASIC &&
(get_basic_fc(t) != RPC_FC_CHAR &&
get_basic_fc(t) != RPC_FC_BYTE &&
get_basic_fc(t) != RPC_FC_WCHAR))
{
decl = LIST_ENTRY( list_head( decls ), const declarator_t, entry );
error_loc("'%s': [string] attribute is only valid on 'char', 'byte', or 'wchar_t' pointers and arrays\n",
decl->var->name);
}
}
/* We must generate names for tagless enum, struct or union.
Typedef-ing a tagless enum, struct or union means we want the typedef
to be included in a library hence the public attribute. */
@@ -1714,20 +1848,18 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
LIST_FOR_EACH_ENTRY( decl, decls, const declarator_t, entry )
{
var_t *name = decl->var;
if (name->name) {
if (decl->var->name) {
type_t *cur;
var_t *name;
cur = find_type(name->name, 0);
cur = find_type(decl->var->name, 0);
if (cur)
error_loc("%s: redefinition error; original definition was at %s:%d\n",
cur->name, cur->loc_info.input_name,
cur->loc_info.line_number);
/* set the attributes to allow set_type to do some checks on them */
name->attrs = attrs;
set_type(name, decl_spec, decl, 0);
name = declare_var(attrs, decl_spec, decl, 0);
cur = type_new_alias(name->type, name->name);
cur->attrs = attrs;
@@ -1872,6 +2004,7 @@ struct allowed_attr allowed_attr[] =
{
/* attr { D ACF I Fn ARG T En St Un Fi L DI M C <display name> } */
/* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" },
/* ATTR_ANNOTATION */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" },
/* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" },
/* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" },
/* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" },
@@ -1977,14 +2110,10 @@ static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs)
return attrs;
}
static void check_arg(var_t *arg)
static void check_arg_attrs(const var_t *arg)
{
const type_t *t = arg->type;
const attr_t *attr;
if (type_get_type(t) == TYPE_VOID)
error_loc("argument '%s' has void type\n", arg->name);
if (arg->attrs)
{
LIST_FOR_EACH_ENTRY(attr, arg->attrs, const attr_t, entry)
@@ -2150,6 +2279,7 @@ static int is_allowed_conf_type(const type_t *type)
case TYPE_COCLASS:
case TYPE_FUNCTION:
case TYPE_INTERFACE:
case TYPE_BITFIELD:
return FALSE;
}
return FALSE;
@@ -2193,24 +2323,30 @@ static void check_field_common(const type_t *container_type,
{
type_t *type = arg->type;
int more_to_do;
const char *container_type_name = NULL;
const char *container_type_name;
const char *var_type;
switch (type_get_type_detect_alias(type))
switch (type_get_type(container_type))
{
case TYPE_STRUCT:
container_type_name = "struct";
var_type = "field";
break;
case TYPE_UNION:
container_type_name = "union";
var_type = "arm";
break;
case TYPE_ENCAPSULATED_UNION:
container_type_name = "encapsulated union";
var_type = "arm";
break;
case TYPE_FUNCTION:
container_type_name = "function";
var_type = "parameter";
break;
default:
break;
/* should be no other container types */
assert(0);
}
if (is_attr(arg->attrs, ATTR_LENGTHIS) &&
@@ -2270,28 +2406,48 @@ static void check_field_common(const type_t *container_type,
check_remoting_fields(arg, type);
break;
case TGT_INVALID:
{
const char *reason = "is invalid";
switch (type_get_type(type))
{
case TYPE_VOID:
error_loc_info(&arg->loc_info, "parameter \'%s\' of %s \'%s\' cannot derive from void *\n",
arg->name, container_type_name, container_name);
reason = "cannot derive from void *";
break;
case TYPE_FUNCTION:
error_loc_info(&arg->loc_info, "parameter \'%s\' of %s \'%s\' cannot be a function pointer\n",
arg->name, container_type_name, container_name);
reason = "cannot be a function pointer";
break;
case TYPE_BITFIELD:
reason = "cannot be a bit-field";
break;
case TYPE_COCLASS:
reason = "cannot be a class";
break;
case TYPE_INTERFACE:
reason = "cannot be a non-pointer to an interface";
break;
case TYPE_MODULE:
/* FIXME */
reason = "cannot be a module";
break;
default:
break;
}
error_loc_info(&arg->loc_info, "%s \'%s\' of %s \'%s\' %s\n",
var_type, arg->name, container_type_name, container_name, reason);
break;
}
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
/* FIXME */
break;
case TGT_STRING:
{
const type_t *t = type;
while (is_ptr(t))
t = type_pointer_get_ref(t);
if (is_aliaschain_attr(t, ATTR_RANGE))
warning_loc_info(&arg->loc_info, "%s: range not verified for a string of ranged types\n", arg->name);
break;
}
case TGT_POINTER:
type = type_pointer_get_ref(type);
more_to_do = TRUE;
@@ -2301,10 +2457,10 @@ static void check_field_common(const type_t *container_type,
more_to_do = TRUE;
break;
case TGT_USER_TYPE:
case TGT_STRING:
case TGT_IFACE_POINTER:
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
/* nothing to do */
break;
}
@@ -2354,6 +2510,7 @@ static void check_remoting_args(const var_t *func)
{
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
case TGT_STRUCT:
case TGT_UNION:
case TGT_CTXT_HANDLE:
@@ -2381,6 +2538,16 @@ static void check_remoting_args(const var_t *func)
check_field_common(func->type, funcname, arg);
}
if (type_get_type(type_function_get_rettype(func->type)) != TYPE_VOID)
{
var_t var;
var = *func;
var.type = type_function_get_rettype(func->type);
var.name = xstrdup("return value");
check_field_common(func->type, funcname, &var);
free(var.name);
}
}
static void add_explicit_handle_if_necessary(var_t *func)
+171 -163
View File
@@ -301,25 +301,26 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
*yy_cp = '\0'; \
yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 32
#define YY_END_OF_BUFFER 33
static yyconst short int yy_accept[139] =
#define YY_NUM_RULES 33
#define YY_END_OF_BUFFER 34
static yyconst short int yy_accept[142] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
33, 31, 21, 20, 31, 3, 31, 31, 16, 16,
31, 31, 31, 19, 19, 19, 11, 31, 21, 1,
10, 32, 4, 10, 6, 16, 16, 13, 13, 13,
12, 2, 26, 30, 24, 0, 16, 16, 16, 0,
22, 28, 25, 27, 23, 19, 5, 19, 29, 0,
1, 1, 9, 8, 7, 16, 0, 13, 13, 2,
17, 16, 16, 15, 19, 16, 0, 13, 0, 15,
15, 19, 16, 0, 13, 0, 17, 15, 15, 19,
16, 0, 13, 19, 16, 0, 13, 19, 16, 0,
34, 32, 21, 20, 32, 3, 32, 32, 32, 16,
16, 32, 32, 32, 19, 19, 19, 11, 32, 21,
1, 10, 33, 4, 10, 6, 16, 16, 13, 13,
13, 12, 2, 26, 30, 24, 0, 0, 16, 16,
16, 0, 22, 28, 25, 27, 23, 19, 5, 19,
29, 0, 1, 1, 9, 8, 7, 16, 0, 13,
13, 2, 31, 17, 16, 16, 15, 19, 16, 0,
13, 0, 15, 15, 19, 16, 0, 13, 0, 17,
15, 15, 19, 16, 0, 13, 19, 16, 0, 13,
13, 19, 16, 0, 13, 19, 0, 16, 0, 18,
19, 16, 0, 13, 19, 16, 0, 13, 19, 0,
16, 0, 18, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 14, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 14,
0
} ;
static yyconst int yy_ec[256] =
@@ -362,112 +363,112 @@ static yyconst int yy_meta[36] =
3, 4, 4, 4, 1
} ;
static yyconst short int yy_base[175] =
static yyconst short int yy_base[178] =
{ 0,
0, 34, 34, 38, 39, 42, 71, 44, 268, 267,
265, 491, 491, 491, 249, 491, 256, 241, 96, 22,
37, 241, 38, 0, 250, 237, 491, 218, 53, 249,
491, 491, 491, 33, 491, 119, 23, 142, 165, 245,
491, 0, 491, 491, 491, 48, 0, 33, 88, 0,
491, 491, 491, 491, 491, 0, 491, 228, 491, 63,
241, 240, 491, 491, 491, 185, 0, 207, 0, 0,
104, 491, 491, 124, 222, 227, 0, 249, 102, 94,
102, 220, 269, 0, 291, 113, 168, 491, 491, 213,
311, 0, 333, 212, 353, 0, 375, 217, 395, 0,
0, 34, 34, 38, 39, 42, 71, 44, 270, 269,
271, 491, 491, 491, 255, 491, 258, 248, 252, 96,
22, 37, 242, 38, 0, 251, 238, 491, 219, 53,
251, 491, 491, 491, 33, 491, 119, 23, 142, 165,
246, 491, 0, 491, 491, 491, 239, 48, 0, 33,
88, 0, 491, 491, 491, 491, 491, 0, 491, 228,
491, 63, 241, 240, 491, 491, 491, 185, 0, 207,
0, 0, 491, 104, 491, 491, 124, 222, 227, 0,
249, 102, 94, 102, 220, 269, 0, 291, 113, 168,
491, 491, 213, 311, 0, 333, 212, 353, 0, 375,
417, 206, 439, 222, 221, 62, 0, 220, 140, 491,
0, 0, 0, 219, 0, 0, 0, 0, 218, 0,
0, 0, 0, 213, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 491, 491, 472, 476,
478, 482, 486, 219, 218, 212, 211, 210, 209, 208,
206, 205, 203, 198, 197, 192, 191, 190, 189, 188,
187, 186, 185, 183, 176, 169, 168, 167, 155, 144,
140, 137, 130, 110
217, 395, 0, 417, 206, 439, 222, 221, 62, 0,
220, 140, 491, 0, 0, 0, 219, 0, 0, 0,
0, 218, 0, 0, 0, 0, 213, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 491,
491, 472, 476, 478, 482, 486, 219, 218, 212, 211,
210, 209, 208, 206, 205, 203, 198, 197, 192, 191,
190, 189, 188, 187, 186, 185, 183, 176, 169, 168,
167, 155, 144, 140, 137, 130, 110
} ;
static yyconst short int yy_def[175] =
static yyconst short int yy_def[178] =
{ 0,
138, 1, 139, 139, 139, 139, 138, 7, 140, 140,
138, 138, 138, 138, 138, 138, 138, 138, 138, 19,
138, 138, 138, 141, 141, 141, 138, 138, 138, 138,
138, 138, 138, 142, 138, 138, 36, 138, 38, 39,
138, 143, 138, 138, 138, 138, 20, 138, 138, 144,
138, 138, 138, 138, 138, 141, 138, 141, 138, 138,
138, 138, 138, 138, 138, 138, 145, 39, 39, 143,
138, 138, 138, 144, 141, 138, 146, 39, 138, 138,
138, 141, 138, 147, 39, 138, 138, 138, 138, 141,
138, 148, 39, 141, 138, 149, 39, 141, 138, 150,
141, 1, 142, 142, 142, 142, 141, 7, 143, 143,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
20, 141, 141, 141, 144, 144, 144, 141, 141, 141,
141, 141, 141, 141, 145, 141, 141, 37, 141, 39,
40, 141, 146, 141, 141, 141, 141, 141, 21, 141,
141, 147, 141, 141, 141, 141, 141, 144, 141, 144,
141, 141, 141, 141, 141, 141, 141, 141, 148, 40,
40, 146, 141, 141, 141, 141, 147, 144, 141, 149,
40, 141, 141, 141, 144, 141, 150, 40, 141, 141,
141, 141, 144, 141, 151, 40, 144, 141, 152, 40,
39, 141, 138, 138, 39, 141, 151, 103, 138, 138,
152, 153, 154, 138, 155, 156, 157, 158, 138, 159,
160, 161, 162, 138, 163, 164, 165, 166, 167, 168,
169, 170, 171, 172, 173, 174, 138, 0, 138, 138,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138
144, 141, 153, 40, 144, 141, 141, 40, 144, 154,
106, 141, 141, 155, 156, 157, 141, 158, 159, 160,
161, 141, 162, 163, 164, 165, 141, 166, 167, 168,
169, 170, 171, 172, 173, 174, 175, 176, 177, 141,
0, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141
} ;
static yyconst short int yy_nxt[527] =
{ 0,
12, 13, 14, 15, 16, 12, 17, 12, 12, 18,
12, 19, 20, 21, 22, 23, 24, 24, 24, 24,
24, 25, 24, 26, 24, 24, 24, 27, 12, 12,
24, 24, 24, 24, 28, 29, 32, 64, 33, 30,
32, 32, 33, 35, 32, 29, 35, 138, 138, 30,
51, 52, 54, 55, 60, 138, 138, 72, 61, 71,
71, 65, 34, 109, 60, 72, 34, 34, 61, 110,
34, 12, 13, 14, 15, 16, 12, 17, 12, 12,
18, 12, 36, 37, 21, 22, 23, 38, 38, 38,
38, 39, 40, 39, 39, 39, 39, 39, 27, 12,
19, 20, 21, 22, 23, 24, 25, 25, 25, 25,
25, 26, 25, 27, 25, 25, 25, 28, 12, 12,
25, 25, 25, 25, 29, 30, 33, 66, 34, 31,
33, 33, 34, 36, 33, 30, 36, 141, 141, 31,
53, 54, 56, 57, 62, 141, 141, 75, 63, 74,
74, 67, 35, 112, 62, 75, 35, 35, 63, 113,
35, 12, 13, 14, 15, 16, 12, 17, 12, 12,
18, 19, 37, 38, 22, 23, 24, 39, 39, 39,
39, 40, 41, 40, 40, 40, 40, 40, 28, 12,
41, 38, 39, 39, 39, 28, 46, 47, 47, 73,
86, 86, 137, 87, 87, 71, 71, 48, 88, 73,
49, 50, 79, 89, 87, 87, 88, 48, 49, 50,
66, 66, 136, 89, 79, 67, 67, 67, 67, 135,
48, 109, 134, 49, 50, 80, 133, 110, 81, 67,
48, 49, 50, 68, 68, 80, 81, 132, 68, 68,
68, 68, 69, 69, 69, 69, 69, 69, 69, 131,
130, 129, 68, 69, 69, 69, 69, 69, 128, 87,
87, 69, 69, 69, 69, 127, 79, 126, 124, 123,
122, 121, 119, 118, 117, 69, 76, 76, 79, 116,
42, 39, 40, 40, 40, 29, 48, 49, 49, 76,
89, 89, 140, 90, 90, 74, 74, 50, 91, 76,
51, 52, 82, 92, 90, 90, 91, 50, 51, 52,
68, 68, 139, 92, 82, 69, 69, 69, 69, 138,
50, 112, 137, 51, 52, 83, 136, 113, 84, 69,
50, 51, 52, 70, 70, 83, 84, 135, 70, 70,
70, 70, 71, 71, 71, 71, 71, 71, 71, 134,
133, 132, 70, 71, 71, 71, 71, 71, 131, 90,
90, 71, 71, 71, 71, 130, 82, 129, 127, 126,
125, 124, 122, 121, 120, 71, 79, 79, 82, 119,
114, 77, 77, 77, 77, 113, 48, 112, 111, 49,
104, 100, 96, 92, 84, 77, 48, 49, 78, 78,
77, 74, 125, 78, 78, 78, 78, 120, 115, 138,
107, 107, 106, 102, 98, 94, 90, 78, 83, 83,
82, 62, 62, 84, 84, 84, 84, 75, 48, 57,
62, 49, 59, 58, 57, 53, 45, 84, 48, 49,
85, 85, 44, 43, 138, 85, 85, 85, 85, 32,
32, 138, 138, 138, 138, 138, 138, 138, 138, 85,
91, 91, 138, 138, 138, 92, 92, 92, 92, 138,
48, 138, 138, 49, 138, 138, 138, 138, 138, 92,
117, 80, 80, 80, 80, 116, 50, 115, 114, 51,
107, 103, 99, 95, 87, 80, 50, 51, 81, 81,
80, 77, 128, 81, 81, 81, 81, 123, 118, 141,
110, 110, 109, 105, 101, 97, 93, 81, 86, 86,
85, 64, 64, 87, 87, 87, 87, 78, 50, 73,
59, 51, 64, 61, 60, 59, 55, 87, 50, 51,
88, 88, 47, 46, 45, 88, 88, 88, 88, 44,
141, 33, 33, 141, 141, 141, 141, 141, 141, 88,
94, 94, 141, 141, 141, 95, 95, 95, 95, 141,
50, 141, 141, 51, 141, 141, 141, 141, 141, 95,
48, 49, 93, 93, 138, 138, 138, 93, 93, 93,
93, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 93, 95, 95, 138, 138, 138, 96, 96, 96,
96, 138, 48, 138, 138, 49, 138, 138, 138, 138,
138, 96, 48, 49, 97, 97, 138, 138, 138, 97,
97, 97, 97, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 97, 99, 99, 138, 138, 138, 100,
100, 100, 100, 138, 48, 138, 138, 49, 138, 138,
138, 138, 138, 100, 48, 49, 101, 101, 138, 138,
138, 101, 101, 101, 101, 138, 138, 138, 138, 138,
50, 51, 96, 96, 141, 141, 141, 96, 96, 96,
96, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 96, 98, 98, 141, 141, 141, 99, 99, 99,
99, 141, 50, 141, 141, 51, 141, 141, 141, 141,
141, 99, 50, 51, 100, 100, 141, 141, 141, 100,
100, 100, 100, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 100, 102, 102, 141, 141, 141, 103,
103, 103, 103, 141, 50, 141, 141, 51, 141, 141,
141, 141, 141, 103, 50, 51, 104, 104, 141, 141,
141, 104, 104, 104, 104, 141, 141, 141, 141, 141,
138, 138, 138, 138, 138, 101, 103, 103, 138, 138,
138, 104, 104, 104, 104, 138, 48, 138, 138, 49,
138, 138, 138, 138, 138, 104, 48, 49, 105, 105,
138, 138, 138, 105, 105, 105, 105, 138, 138, 138,
138, 138, 138, 138, 138, 138, 138, 105, 107, 138,
108, 108, 138, 138, 138, 138, 138, 138, 138, 138,
48, 138, 138, 49, 138, 138, 138, 138, 138, 138,
48, 49, 31, 31, 31, 31, 42, 42, 42, 42,
56, 56, 63, 138, 63, 63, 70, 138, 70, 70,
11, 138, 138, 138, 138, 138, 138, 138, 138, 138,
141, 141, 141, 141, 141, 104, 106, 106, 141, 141,
141, 107, 107, 107, 107, 141, 50, 141, 141, 51,
141, 141, 141, 141, 141, 107, 50, 51, 108, 108,
141, 141, 141, 108, 108, 108, 108, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 108, 110, 141,
111, 111, 141, 141, 141, 141, 141, 141, 141, 141,
50, 141, 141, 51, 141, 141, 141, 141, 141, 141,
50, 51, 32, 32, 32, 32, 43, 43, 43, 43,
58, 58, 65, 141, 65, 65, 72, 141, 72, 72,
11, 141, 141, 141, 141, 141, 141, 141, 141, 141,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141
} ;
static yyconst short int yy_chk[527] =
@@ -475,61 +476,61 @@ static yyconst short int yy_chk[527] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 3, 34, 3, 2,
4, 5, 4, 5, 6, 8, 6, 20, 37, 8,
21, 21, 23, 23, 29, 20, 37, 48, 29, 46,
46, 34, 3, 106, 60, 48, 4, 5, 60, 106,
1, 1, 1, 1, 1, 2, 3, 35, 3, 2,
4, 5, 4, 5, 6, 8, 6, 21, 38, 8,
22, 22, 24, 24, 30, 21, 38, 50, 30, 48,
48, 35, 3, 109, 62, 50, 4, 5, 62, 109,
6, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 19, 19, 19, 49,
79, 79, 174, 79, 79, 71, 71, 19, 80, 49,
19, 19, 71, 81, 86, 86, 80, 19, 19, 19,
36, 36, 173, 81, 71, 36, 36, 36, 36, 172,
36, 109, 171, 36, 36, 74, 170, 109, 74, 36,
36, 36, 36, 38, 38, 74, 74, 169, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 38, 168,
167, 166, 38, 38, 38, 38, 39, 39, 165, 87,
87, 39, 39, 39, 39, 164, 87, 163, 162, 161,
160, 159, 158, 157, 156, 39, 66, 66, 87, 155,
7, 7, 7, 7, 7, 7, 20, 20, 20, 51,
82, 82, 177, 82, 82, 74, 74, 20, 83, 51,
20, 20, 74, 84, 89, 89, 83, 20, 20, 20,
37, 37, 176, 84, 74, 37, 37, 37, 37, 175,
37, 112, 174, 37, 37, 77, 173, 112, 77, 37,
37, 37, 37, 39, 39, 77, 77, 172, 39, 39,
39, 39, 39, 39, 39, 39, 39, 39, 39, 171,
170, 169, 39, 39, 39, 39, 40, 40, 168, 90,
90, 40, 40, 40, 40, 167, 90, 166, 165, 164,
163, 162, 161, 160, 159, 40, 68, 68, 90, 158,
154, 66, 66, 66, 66, 153, 66, 152, 151, 66,
150, 149, 148, 147, 146, 66, 66, 66, 68, 68,
145, 144, 124, 68, 68, 68, 68, 119, 114, 108,
105, 104, 102, 98, 94, 90, 82, 68, 76, 76,
75, 62, 61, 76, 76, 76, 76, 58, 76, 40,
30, 76, 28, 26, 25, 22, 18, 76, 76, 76,
78, 78, 17, 15, 11, 78, 78, 78, 78, 10,
9, 0, 0, 0, 0, 0, 0, 0, 0, 78,
83, 83, 0, 0, 0, 83, 83, 83, 83, 0,
83, 0, 0, 83, 0, 0, 0, 0, 0, 83,
157, 68, 68, 68, 68, 156, 68, 155, 154, 68,
153, 152, 151, 150, 149, 68, 68, 68, 70, 70,
148, 147, 127, 70, 70, 70, 70, 122, 117, 111,
108, 107, 105, 101, 97, 93, 85, 70, 79, 79,
78, 64, 63, 79, 79, 79, 79, 60, 79, 47,
41, 79, 31, 29, 27, 26, 23, 79, 79, 79,
81, 81, 19, 18, 17, 81, 81, 81, 81, 15,
11, 10, 9, 0, 0, 0, 0, 0, 0, 81,
86, 86, 0, 0, 0, 86, 86, 86, 86, 0,
86, 0, 0, 86, 0, 0, 0, 0, 0, 86,
83, 83, 85, 85, 0, 0, 0, 85, 85, 85,
85, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 85, 91, 91, 0, 0, 0, 91, 91, 91,
91, 0, 91, 0, 0, 91, 0, 0, 0, 0,
0, 91, 91, 91, 93, 93, 0, 0, 0, 93,
93, 93, 93, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 93, 95, 95, 0, 0, 0, 95,
95, 95, 95, 0, 95, 0, 0, 95, 0, 0,
0, 0, 0, 95, 95, 95, 97, 97, 0, 0,
0, 97, 97, 97, 97, 0, 0, 0, 0, 0,
86, 86, 88, 88, 0, 0, 0, 88, 88, 88,
88, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 88, 94, 94, 0, 0, 0, 94, 94, 94,
94, 0, 94, 0, 0, 94, 0, 0, 0, 0,
0, 94, 94, 94, 96, 96, 0, 0, 0, 96,
96, 96, 96, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 96, 98, 98, 0, 0, 0, 98,
98, 98, 98, 0, 98, 0, 0, 98, 0, 0,
0, 0, 0, 98, 98, 98, 100, 100, 0, 0,
0, 100, 100, 100, 100, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 97, 99, 99, 0, 0,
0, 99, 99, 99, 99, 0, 99, 0, 0, 99,
0, 0, 0, 0, 0, 99, 99, 99, 101, 101,
0, 0, 0, 101, 101, 101, 101, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 101, 103, 0,
103, 103, 0, 0, 0, 0, 0, 0, 0, 0,
103, 0, 0, 103, 0, 0, 0, 0, 0, 0,
103, 103, 139, 139, 139, 139, 140, 140, 140, 140,
141, 141, 142, 0, 142, 142, 143, 0, 143, 143,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
0, 0, 0, 0, 0, 100, 102, 102, 0, 0,
0, 102, 102, 102, 102, 0, 102, 0, 0, 102,
0, 0, 0, 0, 0, 102, 102, 102, 104, 104,
0, 0, 0, 104, 104, 104, 104, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 104, 106, 0,
106, 106, 0, 0, 0, 0, 0, 0, 0, 0,
106, 0, 0, 106, 0, 0, 0, 0, 0, 0,
106, 106, 142, 142, 142, 142, 143, 143, 143, 143,
144, 144, 145, 0, 145, 145, 146, 0, 146, 146,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
138, 138, 138, 138, 138, 138
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141
} ;
static yy_state_type yy_last_accepting_state;
@@ -661,7 +662,7 @@ UUID *parse_uuid(const char *u)
* The flexer starts here
**************************************************************************
*/
#line 665 "parser.yy.c"
#line 666 "parser.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -817,7 +818,7 @@ YY_DECL
#line 127 "parser.l"
#line 821 "parser.yy.c"
#line 822 "parser.yy.c"
if ( yy_init )
{
@@ -869,7 +870,7 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 139 )
if ( yy_current_state >= 142 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1092,6 +1093,11 @@ return LOGICALAND;
case 31:
YY_RULE_SETUP
#line 196 "parser.l"
return ELLIPSIS;
YY_BREAK
case 32:
YY_RULE_SETUP
#line 197 "parser.l"
return yytext[0];
YY_BREAK
case YY_STATE_EOF(INITIAL):
@@ -1099,19 +1105,19 @@ case YY_STATE_EOF(QUOTE):
case YY_STATE_EOF(WSTRQUOTE):
case YY_STATE_EOF(ATTR):
case YY_STATE_EOF(PP_LINE):
#line 197 "parser.l"
#line 198 "parser.l"
{
if (import_stack_ptr)
return aEOF;
else yyterminate();
}
YY_BREAK
case 32:
case 33:
YY_RULE_SETUP
#line 202 "parser.l"
#line 203 "parser.l"
ECHO;
YY_BREAK
#line 1115 "parser.yy.c"
#line 1121 "parser.yy.c"
case YY_END_OF_BUFFER:
{
@@ -1402,7 +1408,7 @@ static yy_state_type yy_get_previous_state()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 139 )
if ( yy_current_state >= 142 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1437,11 +1443,11 @@ yy_state_type yy_current_state;
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 139 )
if ( yy_current_state >= 142 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 138);
yy_is_jam = (yy_current_state == 141);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1997,7 +2003,7 @@ int main()
return 0;
}
#endif
#line 202 "parser.l"
#line 203 "parser.l"
#ifndef parser_wrap
@@ -2019,6 +2025,7 @@ static const struct keyword keywords[] = {
{"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__fastcall", tFASTCALL},
{"__int3264", tINT3264},
{"__int64", tINT64},
{"__pascal", tPASCAL},
{"__stdcall", tSTDCALL},
@@ -2078,6 +2085,7 @@ static const struct keyword attr_keywords[] =
{
{"aggregatable", tAGGREGATABLE},
{"allocate", tALLOCATE},
{"annotation", tANNOTATION},
{"appobject", tAPPOBJECT},
{"async", tASYNC},
{"async_uuid", tASYNCUUID},
+160 -108
View File
@@ -116,12 +116,27 @@ const char *string_of_type(unsigned char type)
case RPC_FC_C_WSTRING: return "FC_C_WSTRING";
case RPC_FC_CSTRING: return "FC_CSTRING";
case RPC_FC_WSTRING: return "FC_WSTRING";
case RPC_FC_INT3264: return "FC_INT3264";
case RPC_FC_UINT3264: return "FC_UINT3264";
default:
error("string_of_type: unknown type 0x%02x\n", type);
return NULL;
}
}
static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr)
{
const type_t *t = type;
for (;;)
{
if (is_attr(t->attrs, attr))
return get_attrp(t->attrs, attr);
else if (type_is_alias(t))
t = type_alias_get_aliasee(t);
else return 0;
}
}
unsigned char get_basic_fc(const type_t *type)
{
int sign = type_basic_get_sign(type);
@@ -132,6 +147,7 @@ unsigned char get_basic_fc(const type_t *type)
case TYPE_BASIC_INT32: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG);
case TYPE_BASIC_INT64: return RPC_FC_HYPER;
case TYPE_BASIC_INT: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG);
case TYPE_BASIC_INT3264: return (sign <= 0 ? RPC_FC_INT3264 : RPC_FC_UINT3264);
case TYPE_BASIC_BYTE: return RPC_FC_BYTE;
case TYPE_BASIC_CHAR: return RPC_FC_CHAR;
case TYPE_BASIC_WCHAR: return RPC_FC_WCHAR;
@@ -140,8 +156,8 @@ unsigned char get_basic_fc(const type_t *type)
case TYPE_BASIC_DOUBLE: return RPC_FC_DOUBLE;
case TYPE_BASIC_ERROR_STATUS_T: return RPC_FC_ERROR_STATUS_T;
case TYPE_BASIC_HANDLE: return RPC_FC_BIND_PRIMITIVE;
default: return 0;
}
return 0;
}
static inline unsigned int clamp_align(unsigned int align)
@@ -200,8 +216,14 @@ enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *att
switch (type_get_type(type))
{
case TYPE_BASIC:
if (!(flags & TDT_IGNORE_RANGES) &&
(is_attr(attrs, ATTR_RANGE) || is_aliaschain_attr(type, ATTR_RANGE)))
return TGT_RANGE;
return TGT_BASIC;
case TYPE_ENUM:
if (!(flags & TDT_IGNORE_RANGES) &&
(is_attr(attrs, ATTR_RANGE) || is_aliaschain_attr(type, ATTR_RANGE)))
return TGT_RANGE;
return TGT_ENUM;
case TYPE_POINTER:
if (type_get_type(type_pointer_get_ref(type)) == TYPE_INTERFACE ||
@@ -224,69 +246,12 @@ enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *att
case TYPE_MODULE:
case TYPE_VOID:
case TYPE_ALIAS:
case TYPE_BITFIELD:
break;
}
return TGT_INVALID;
}
static type_t *get_user_type(const type_t *t, const char **pname);
static int type_contains_iface(const type_t *type)
{
enum typegen_type typegen_type;
var_list_t *fields;
const var_t *field;
typegen_type = typegen_detect_type(type, type->attrs, TDT_IGNORE_STRINGS);
switch(typegen_type)
{
case TGT_USER_TYPE:
return type_contains_iface(get_user_type(type, NULL));
case TGT_BASIC:
case TGT_ENUM:
return FALSE;
case TGT_POINTER:
return type_contains_iface(type_pointer_get_ref(type));
case TGT_ARRAY:
return type_contains_iface(type_array_get_element(type));
case TGT_IFACE_POINTER:
return TRUE;
case TGT_STRUCT:
fields = type_struct_get_fields(type);
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
if(type_contains_iface(field->type))
return TRUE;
}
return FALSE;
case TGT_UNION:
fields = type_union_get_cases(type);
if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
{
if(field->type && type_contains_iface(field->type))
return TRUE;
}
return FALSE;
case TGT_STRING:
/* shouldn't get here because of TDT_IGNORE_STRINGS above. fall through */
case TGT_INVALID:
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
/* checking after parsing should mean that we don't get here. if we do,
* it's a checker bug */
assert(0);
}
return FALSE;
}
unsigned char get_struct_fc(const type_t *type)
{
int has_pointer = 0;
@@ -340,15 +305,15 @@ unsigned char get_struct_fc(const type_t *type)
case TGT_IFACE_POINTER:
return RPC_FC_BOGUS_STRUCT;
case TGT_BASIC:
if (type_basic_get_type(t) == TYPE_BASIC_INT3264 && pointer_size != 4)
return RPC_FC_BOGUS_STRUCT;
break;
case TGT_ENUM:
if (get_enum_fc(t) == RPC_FC_ENUM16)
return RPC_FC_BOGUS_STRUCT;
break;
case TGT_ARRAY:
if(type_contains_iface(type_array_get_element(t)))
return RPC_FC_BOGUS_STRUCT;
case TGT_POINTER:
case TGT_ARRAY:
if (get_pointer_fc(t, field->attrs, FALSE) == RPC_FC_RP || pointer_size != 4)
return RPC_FC_BOGUS_STRUCT;
has_pointer = 1;
@@ -397,6 +362,8 @@ unsigned char get_struct_fc(const type_t *type)
}
break;
}
case TGT_RANGE:
return RPC_FC_BOGUS_STRUCT;
case TGT_STRING:
/* shouldn't get here because of TDT_IGNORE_STRINGS above. fall through */
case TGT_INVALID:
@@ -460,6 +427,11 @@ unsigned char get_array_fc(const type_t *type)
case TGT_USER_TYPE:
fc = RPC_FC_BOGUS_ARRAY;
break;
case TGT_BASIC:
if (type_basic_get_type(elem_type) == TYPE_BASIC_INT3264 &&
pointer_size != 4)
fc = RPC_FC_BOGUS_ARRAY;
break;
case TGT_STRUCT:
switch (get_struct_fc(elem_type))
{
@@ -485,7 +457,9 @@ unsigned char get_array_fc(const type_t *type)
if (get_pointer_fc(elem_type, NULL, FALSE) == RPC_FC_RP || pointer_size != 4)
fc = RPC_FC_BOGUS_ARRAY;
break;
case TGT_BASIC:
case TGT_RANGE:
fc = RPC_FC_BOGUS_ARRAY;
break;
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
case TGT_STRING:
@@ -559,6 +533,7 @@ static int type_has_pointers(const type_t *type)
case TGT_IFACE_POINTER:
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
case TGT_INVALID:
break;
}
@@ -612,6 +587,7 @@ static int type_has_full_pointer(const type_t *type, const attr_list_t *attrs,
case TGT_IFACE_POINTER:
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
case TGT_INVALID:
break;
}
@@ -1258,6 +1234,12 @@ unsigned int type_memsize(const type_t *t, unsigned int *align)
size = 8;
if (size > *align) *align = size;
break;
case RPC_FC_INT3264:
case RPC_FC_UINT3264:
assert( pointer_size );
size = pointer_size;
if (size > *align) *align = size;
break;
default:
error("type_memsize: Unknown type 0x%x\n", get_basic_fc(t));
size = 0;
@@ -1315,10 +1297,11 @@ unsigned int type_memsize(const type_t *t, unsigned int *align)
case TYPE_COCLASS:
case TYPE_MODULE:
case TYPE_FUNCTION:
case TYPE_BITFIELD:
/* these types should not be encountered here due to language
* restrictions (interface, void, coclass, module), logical
* restrictions (alias - due to type_get_type call above) or
* checking restrictions (function). */
* checking restrictions (function, bitfield). */
assert(0);
}
@@ -2737,6 +2720,33 @@ static unsigned int write_contexthandle_tfs(FILE *file, const type_t *type,
return start_offset;
}
static unsigned int write_range_tfs(FILE *file, const attr_list_t *attrs,
type_t *type, expr_list_t *range_list,
unsigned int *typeformat_offset)
{
unsigned char fc;
unsigned int start_offset = *typeformat_offset;
const expr_t *range_min = LIST_ENTRY(list_head(range_list), const expr_t, entry);
const expr_t *range_max = LIST_ENTRY(list_next(range_list, list_head(range_list)), const expr_t, entry);
if (type_get_type(type) == TYPE_BASIC)
fc = get_basic_fc(type);
else
fc = get_enum_fc(type);
/* fc must fit in lower 4-bits of 8-bit field below */
assert(fc <= 0xf);
print_file(file, 0, "/* %u */\n", *typeformat_offset);
print_file(file, 2, "0x%x,\t/* FC_RANGE */\n", RPC_FC_RANGE);
print_file(file, 2, "0x%x,\t/* %s */\n", fc, string_of_type(fc));
print_file(file, 2, "NdrFcLong(0x%lx),\t/* %lu */\n", range_min->cval, range_min->cval);
print_file(file, 2, "NdrFcLong(0x%lx),\t/* %lu */\n", range_max->cval, range_max->cval);
*typeformat_offset += 10;
return start_offset;
}
static unsigned int write_typeformatstring_var(FILE *file, int indent, const var_t *func,
type_t *type, const var_t *var,
int toplevel_param,
@@ -2784,6 +2794,13 @@ static unsigned int write_typeformatstring_var(FILE *file, int indent, const var
case TGT_BASIC:
/* nothing to do */
return 0;
case TGT_RANGE:
{
expr_list_t *range_list = get_attrp(var->attrs, ATTR_RANGE);
if (!range_list)
range_list = get_aliaschain_attrp(type, ATTR_RANGE);
return write_range_tfs(file, var->attrs, type, range_list, typeformat_offset);
}
case TGT_IFACE_POINTER:
return write_ip_tfs(file, var->attrs, type, typeformat_offset);
case TGT_POINTER:
@@ -2888,6 +2905,14 @@ static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *ty
case TGT_BASIC:
/* nothing to do */
break;
case TGT_RANGE:
{
expr_list_t *range_list = get_attrp(attrs, ATTR_RANGE);
if (!range_list)
range_list = get_aliaschain_attrp(type, ATTR_RANGE);
write_range_tfs(file, attrs, type, range_list, tfsoff);
break;
}
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
case TGT_INVALID:
@@ -2989,7 +3014,7 @@ static unsigned int get_required_buffer_size_type(
const type_t *type, const char *name, const attr_list_t *attrs, int toplevel_param, unsigned int *alignment)
{
*alignment = 0;
switch (typegen_detect_type(type, NULL, TDT_IGNORE_STRINGS))
switch (typegen_detect_type(type, NULL, TDT_IGNORE_STRINGS|TDT_IGNORE_RANGES))
{
case TGT_USER_TYPE:
{
@@ -3025,6 +3050,12 @@ static unsigned int get_required_buffer_size_type(
*alignment = 8;
return 8;
case RPC_FC_INT3264:
case RPC_FC_UINT3264:
assert( pointer_size );
*alignment = pointer_size;
return pointer_size;
case RPC_FC_IGNORE:
case RPC_FC_BIND_PRIMITIVE:
return 0;
@@ -3064,6 +3095,7 @@ static unsigned int get_required_buffer_size_type(
{
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
return get_required_buffer_size_type( ref, name, NULL, FALSE, alignment );
case TGT_STRUCT:
if (get_struct_fc(ref) == RPC_FC_STRUCT)
@@ -3191,28 +3223,36 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
type_t *type = var->type;
unsigned int size;
unsigned int alignment = 0;
const type_t *ref;
/* no work to do for other phases, buffer sizing is done elsewhere */
if (phase != PHASE_MARSHAL && phase != PHASE_UNMARSHAL)
return;
ref = is_ptr(type) ? type_pointer_get_ref(type) : type;
if (type_get_type(ref) == TYPE_ENUM)
if (type_get_type(type) == TYPE_ENUM ||
(type_get_type(type) == TYPE_BASIC &&
type_basic_get_type(type) == TYPE_BASIC_INT3264 &&
pointer_size != 4))
{
if (get_enum_fc(ref) == RPC_FC_ENUM32)
{
size = 4;
alignment = 4;
unsigned char fc;
if (type_get_type(type) == TYPE_ENUM)
fc = get_enum_fc(type);
else
fc = get_basic_fc(type);
if (phase == PHASE_MARSHAL)
print_file(file, indent, "NdrSimpleTypeMarshall(\n");
else
print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
print_file(file, indent+1, "&__frame->_StubMsg,\n");
print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
local_var_prefix,
var->name);
print_file(file, indent+1, "0x%02x /* %s */);\n", fc, string_of_type(fc));
}
else /* RPC_FC_ENUM16 */
{
size = 2;
alignment = 2;
}
}
else
{
const type_t *ref = is_ptr(type) ? type_pointer_get_ref(type) : type;
switch (get_basic_fc(ref))
{
case RPC_FC_BYTE:
@@ -3234,6 +3274,9 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
case RPC_FC_LONG:
case RPC_FC_FLOAT:
case RPC_FC_ERROR_STATUS_T:
/* pointer_size must be 4 if we got here in these two cases */
case RPC_FC_INT3264:
case RPC_FC_UINT3264:
size = 4;
alignment = 4;
break;
@@ -3254,7 +3297,6 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
var->name, get_basic_fc(ref));
size = 0;
}
}
if (phase == PHASE_MARSHAL)
print_file(file, indent, "MIDL_memset(__frame->_StubMsg.Buffer, 0, (0x%x - (ULONG_PTR)__frame->_StubMsg.Buffer) & 0x%x);\n", alignment, alignment - 1);
@@ -3295,6 +3337,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
write_type_decl(file, is_ptr(type) ? type_pointer_get_ref(type) : type, NULL);
fprintf(file, ");\n");
}
}
/* returns whether the MaxCount, Offset or ActualCount members need to be
* filled in for the specified phase */
@@ -3546,21 +3589,33 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
break;
}
case TGT_BASIC:
if (phase == PHASE_MARSHAL || phase == PHASE_UNMARSHAL)
print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name);
break;
case TGT_ENUM:
if (phase == PHASE_MARSHAL || phase == PHASE_UNMARSHAL)
print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name);
break;
case TGT_RANGE:
print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name);
/* Note: this goes beyond what MIDL does - it only supports arguments
* with the [range] attribute in Oicf mode */
if (phase == PHASE_UNMARSHAL)
{
if (phase == PHASE_MARSHAL)
print_file(file, indent, "NdrSimpleTypeMarshall(\n");
else
print_file(file, indent, "NdrSimpleTypeUnmarshall(\n");
print_file(file, indent+1, "&__frame->_StubMsg,\n");
print_file(file, indent+1, "(unsigned char *)&%s%s,\n",
local_var_prefix,
var->name);
print_file(file, indent+1, "0x%02x /* %s */);\n", get_enum_fc(type), string_of_type(get_enum_fc(type)));
const expr_t *range_min;
const expr_t *range_max;
expr_list_t *range_list = get_attrp(var->attrs, ATTR_RANGE);
if (!range_list)
range_list = get_aliaschain_attrp(type, ATTR_RANGE);
range_min = LIST_ENTRY(list_head(range_list), const expr_t, entry);
range_max = LIST_ENTRY(list_next(range_list, list_head(range_list)), const expr_t, entry);
print_file(file, indent, "if ((%s%s < (", local_var_prefix, var->name);
write_type_decl(file, var->type, NULL);
fprintf(file, ")0x%lx) || (%s%s > (", range_min->cval, local_var_prefix, var->name);
write_type_decl(file, var->type, NULL);
fprintf(file, ")0x%lx))\n", range_max->cval);
print_file(file, indent, "{\n");
print_file(file, indent+1, "RpcRaiseException(RPC_S_INVALID_BOUND);\n");
print_file(file, indent, "}\n");
}
break;
case TGT_STRUCT:
@@ -3603,23 +3658,19 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
case TGT_POINTER:
{
const type_t *ref = type_pointer_get_ref(type);
if (pointer_type == RPC_FC_RP && !is_user_type(ref)) switch (type_get_type(ref))
if (pointer_type == RPC_FC_RP) switch (typegen_detect_type(ref, NULL, TDT_ALL_TYPES))
{
case TYPE_BASIC:
/* base types have known sizes, so don't need a sizing pass
* and don't have any memory to free and so don't need a
* freeing pass */
if (phase == PHASE_MARSHAL || phase == PHASE_UNMARSHAL)
case TGT_BASIC:
print_phase_basetype(file, indent, local_var_prefix, phase, pass, var, var->name);
break;
case TYPE_ENUM:
case TGT_ENUM:
/* base types have known sizes, so don't need a sizing pass
* and don't have any memory to free and so don't need a
* freeing pass */
if (phase == PHASE_MARSHAL || phase == PHASE_UNMARSHAL)
print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var, start_offset);
break;
case TYPE_STRUCT:
case TGT_STRUCT:
{
const char *struct_type = NULL;
switch (get_struct_fc(ref))
@@ -3665,8 +3716,7 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
}
break;
}
case TYPE_UNION:
case TYPE_ENCAPSULATED_UNION:
case TGT_UNION:
{
const char *union_type = NULL;
if (phase == PHASE_FREE)
@@ -3685,16 +3735,17 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const
phase, var, start_offset);
break;
}
case TYPE_POINTER:
case TYPE_ARRAY:
case TGT_STRING:
case TGT_POINTER:
case TGT_ARRAY:
case TGT_RANGE:
case TGT_IFACE_POINTER:
case TGT_USER_TYPE:
case TGT_CTXT_HANDLE:
case TGT_CTXT_HANDLE_POINTER:
print_phase_function(file, indent, "Pointer", local_var_prefix, phase, var, start_offset);
break;
case TYPE_VOID:
case TYPE_ALIAS:
case TYPE_MODULE:
case TYPE_COCLASS:
case TYPE_FUNCTION:
case TYPE_INTERFACE:
case TGT_INVALID:
assert(0);
break;
}
@@ -3918,6 +3969,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
case TGT_BASIC:
case TGT_ENUM:
case TGT_POINTER:
case TGT_RANGE:
print_file(file, indent, "%s_W%u = 0;\n", local_var_prefix, i);
break;
case TGT_STRUCT:
+2
View File
@@ -40,6 +40,7 @@ enum typegen_detect_flags
{
TDT_ALL_TYPES = 1 << 0,
TDT_IGNORE_STRINGS = 1 << 1,
TDT_IGNORE_RANGES = 1 << 2,
};
enum typegen_type
@@ -56,6 +57,7 @@ enum typegen_type
TGT_ENUM,
TGT_STRUCT,
TGT_UNION,
TGT_RANGE,
};
typedef int (*type_pred_t)(const type_t *);
+19
View File
@@ -180,6 +180,21 @@ unsigned short get_type_vt(type_t *t)
return VT_UI8;
else
return VT_I8;
case TYPE_BASIC_INT3264:
if (typelib_kind == SYS_WIN64)
{
if (type_basic_get_sign(t) > 0)
return VT_UI8;
else
return VT_I8;
}
else
{
if (type_basic_get_sign(t) > 0)
return VT_UI4;
else
return VT_I4;
}
case TYPE_BASIC_FLOAT:
return VT_R4;
case TYPE_BASIC_DOUBLE:
@@ -228,6 +243,10 @@ unsigned short get_type_vt(type_t *t)
case TYPE_FUNCTION:
error("get_type_vt: functions not supported\n");
break;
case TYPE_BITFIELD:
error("get_type_vt: bitfields not supported\n");
break;
}
return 0;
}
+3
View File
@@ -61,6 +61,8 @@ enum VARENUM {
VT_LPSTR = 30,
VT_LPWSTR = 31,
VT_RECORD = 36,
VT_INT_PTR = 37,
VT_UINT_PTR = 38,
VT_FILETIME = 64,
VT_BLOB = 65,
VT_STREAM = 66,
@@ -70,6 +72,7 @@ enum VARENUM {
VT_BLOB_OBJECT = 70,
VT_CF = 71,
VT_CLSID = 72,
VT_VERSIONED_STREAM = 73,
VT_BSTR_BLOB = 0xfff,
VT_VECTOR = 0x1000,
VT_ARRAY = 0x2000,
+105 -1
View File
@@ -63,9 +63,63 @@ type_t *make_type(enum type_type type)
return t;
}
static const var_t *find_arg(const var_list_t *args, const char *name)
{
const var_t *arg;
if (args) LIST_FOR_EACH_ENTRY(arg, args, const var_t, entry)
{
if (arg->name && !strcmp(name, arg->name))
return arg;
}
return NULL;
}
type_t *type_new_function(var_list_t *args)
{
type_t *t = make_type(TYPE_FUNCTION);
var_t *arg;
type_t *t;
unsigned int i = 0;
if (args)
{
arg = LIST_ENTRY(list_head(args), var_t, entry);
if (list_count(args) == 1 && !arg->name && arg->type && type_get_type(arg->type) == TYPE_VOID)
{
list_remove(&arg->entry);
free(arg);
free(args);
args = NULL;
}
}
if (args) LIST_FOR_EACH_ENTRY(arg, args, var_t, entry)
{
if (arg->type && type_get_type(arg->type) == TYPE_VOID)
error_loc("argument '%s' has void type\n", arg->name);
if (!arg->name)
{
if (i > 26 * 26)
error_loc("too many unnamed arguments\n");
else
{
int unique;
do
{
char name[3];
name[0] = i > 26 ? 'a' + i / 26 : 'a' + i;
name[1] = i > 26 ? 'a' + i % 26 : 0;
name[2] = 0;
unique = !find_arg(args, name);
if (unique)
arg->name = xstrdup(name);
i++;
} while (!unique);
}
}
}
t = make_type(TYPE_FUNCTION);
t->details.function = xmalloc(sizeof(*t->details.function));
t->details.function->args = args;
t->details.function->idx = -1;
@@ -248,6 +302,56 @@ type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *unio
return t;
}
static int is_valid_bitfield_type(const type_t *type)
{
switch (type_get_type(type))
{
case TYPE_ENUM:
return TRUE;
case TYPE_BASIC:
switch (type_basic_get_type(type))
{
case TYPE_BASIC_INT8:
case TYPE_BASIC_INT16:
case TYPE_BASIC_INT32:
case TYPE_BASIC_INT64:
case TYPE_BASIC_INT:
case TYPE_BASIC_INT3264:
case TYPE_BASIC_CHAR:
case TYPE_BASIC_HYPER:
case TYPE_BASIC_BYTE:
case TYPE_BASIC_WCHAR:
case TYPE_BASIC_ERROR_STATUS_T:
return TRUE;
case TYPE_BASIC_FLOAT:
case TYPE_BASIC_DOUBLE:
case TYPE_BASIC_HANDLE:
return FALSE;
}
return FALSE;
default:
return FALSE;
}
}
type_t *type_new_bitfield(type_t *field, const expr_t *bits)
{
type_t *t;
if (!is_valid_bitfield_type(field))
error_loc("bit-field has invalid type\n");
if (bits->cval < 0)
error_loc("negative width for bit-field\n");
/* FIXME: validate bits->cval <= memsize(field) * 8 */
t = make_type(TYPE_BITFIELD);
t->details.bitfield.field = field;
t->details.bitfield.bits = bits;
return t;
}
static int compute_method_indexes(type_t *iface)
{
int idx;
+16
View File
@@ -39,6 +39,7 @@ type_t *type_new_enum(const char *name, int defined, var_list_t *enums);
type_t *type_new_struct(char *name, int defined, var_list_t *fields);
type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields);
type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases);
type_t *type_new_bitfield(type_t *field_type, const expr_t *bits);
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods);
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
@@ -190,6 +191,7 @@ static inline int type_is_complete(const type_t *type)
case TYPE_COCLASS:
case TYPE_POINTER:
case TYPE_ARRAY:
case TYPE_BITFIELD:
return TRUE;
}
return FALSE;
@@ -283,4 +285,18 @@ static inline unsigned char type_pointer_get_default_fc(const type_t *type)
return type->details.pointer.def_fc;
}
static inline type_t *type_bitfield_get_field(const type_t *type)
{
type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_BITFIELD);
return type->details.bitfield.field;
}
static inline const expr_t *type_bitfield_get_bits(const type_t *type)
{
type = type_get_real_type(type);
assert(type_get_type(type) == TYPE_BITFIELD);
return type->details.bitfield.bits;
}
#endif /* WIDL_TYPE_TREE_H */
+11
View File
@@ -81,6 +81,7 @@ typedef struct list statement_list_t;
enum attr_type
{
ATTR_AGGREGATABLE,
ATTR_ANNOTATION,
ATTR_APPOBJECT,
ATTR_ASYNC,
ATTR_AUTO_HANDLE,
@@ -238,6 +239,7 @@ enum type_basic_type
TYPE_BASIC_INT32,
TYPE_BASIC_INT64,
TYPE_BASIC_INT,
TYPE_BASIC_INT3264,
TYPE_BASIC_CHAR,
TYPE_BASIC_HYPER,
TYPE_BASIC_BYTE,
@@ -350,6 +352,12 @@ struct pointer_details
unsigned char def_fc;
};
struct bitfield_details
{
struct _type_t *field;
const expr_t *bits;
};
enum type_type
{
TYPE_VOID,
@@ -365,6 +373,7 @@ enum type_type
TYPE_INTERFACE,
TYPE_POINTER,
TYPE_ARRAY,
TYPE_BITFIELD,
};
struct _type_t {
@@ -382,6 +391,7 @@ struct _type_t {
struct coclass_details coclass;
struct basic_details basic;
struct pointer_details pointer;
struct bitfield_details bitfield;
} details;
type_t *orig; /* dup'd types */
unsigned int typestring_offset;
@@ -415,6 +425,7 @@ struct _declarator_t {
type_t *type;
type_t *func_type;
array_dims_t *array;
expr_t *bits;
/* parser-internal */
struct list entry;