Support new WinRT interop

This commit is contained in:
Alexey Pelykh 2013-02-02 09:38:03 +02:00
parent 6376a491b6
commit 362f4aaa89
2 changed files with 19 additions and 28 deletions

View File

@ -55,6 +55,15 @@
typedef wchar_t char_t; typedef wchar_t char_t;
#if defined(WINAPI_FAMILY)
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#include "avian-interop.h"
#define SKIP_OPERATOR_NEW
#endif
#endif
#else // not PLATFORM_WINDOWS #else // not PLATFORM_WINDOWS
# include <dirent.h> # include <dirent.h>
@ -93,7 +102,9 @@ typedef char char_t;
# endif # endif
#endif // WINAPI_FAMILY #endif // WINAPI_FAMILY
#if !defined(SKIP_OPERATOR_NEW)
inline void* operator new(size_t, void* p) throw() { return p; } inline void* operator new(size_t, void* p) throw() { return p; }
#endif
typedef const char_t* string_t; typedef const char_t* string_t;
@ -240,37 +251,16 @@ Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path)
return path; return path;
# else # else
// This could have worked, if GetFileInformationByHandleEx() returned volume information also
// There is a chance to get it, or using GetFullPathName, that is claimed to be unsupported
// or from System.IO.Path.GetFullPath(), but it's CLR and I see no way of calling it from
// C++/CX code
// Best wishes to everyone who will win this fight,
// Alexey Pelykh
/*
string_t chars = getChars(e, path); string_t chars = getChars(e, path);
if(chars) { if(chars) {
LARGE_INTEGER fileSize; std::wstring partialPath = chars;
HANDLE file = CreateFile2
(chars, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
releaseChars(e, path, chars); releaseChars(e, path, chars);
if (file == INVALID_HANDLE_VALUE) std::wstring fullPath = AvianInterop::GetFullPath(partialPath);
return path;
uint8_t buffer[sizeof(FILE_NAME_INFO) + sizeof(WCHAR)*MAX_PATH];
memset(&buffer[0], 0, sizeof(buffer));
FILE_NAME_INFO* pInfo = reinterpret_cast<FILE_NAME_INFO*>(&buffer[0]);
if(!GetFileInformationByHandleEx(file, FileNameInfo, pInfo, sizeof(buffer)))
{
CloseHandle(file);
return path;
}
CloseHandle(file);
return e->NewString return e->NewString
(reinterpret_cast<const jchar*>(pInfo->FileName), pInfo->FileNameLength / sizeof(WCHAR)); (reinterpret_cast<const jchar*>(fullPath.c_str()), fullPath.length());
} }
*/
return path; return path;
# endif # endif
#else #else

View File

@ -705,12 +705,12 @@ ifeq ($(platform),wp8)
-DAVIAN_VERSION=\"$(version)\" -D_JNI_IMPLEMENTATION_ \ -DAVIAN_VERSION=\"$(version)\" -D_JNI_IMPLEMENTATION_ \
-DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \ -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
-DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \ -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \
-I"$(shell $(windows-path) "$(wp8)/zlib/upstream")" \ -I"$(shell $(windows-path) "$(wp8)/zlib/upstream")" -I"$(shell $(windows-path) "$(wp8)/interop/avian-interop-client")" \
-Fd$(build)/$(name).pdb -I"$(shell $(windows-path) "$(wp8)/include")" -I$(src) -I$(classpath-src) \ -I"$(shell $(windows-path) "$(wp8)/include")" -I$(src) -I$(classpath-src) \
-I"$(build)" \ -I"$(build)" \
-I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \ -I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \
-DTARGET_BYTES_PER_WORD=$(pointer-size) \ -DTARGET_BYTES_PER_WORD=$(pointer-size) \
-Gd -Gd -EHsc
common-lflags = $(classpath-lflags) common-lflags = $(classpath-lflags)
@ -738,7 +738,8 @@ ifeq ($(platform),wp8)
-MACHINE:$(machine_type) \ -MACHINE:$(machine_type) \
-LIBPATH:"$(WP80_KIT)\lib\$(w8kit_arch)" -LIBPATH:"$(WP80_SDK)\lib$(vc_arch)" -LIBPATH:"$(WIN8_KIT)\Lib\win8\um\$(w8kit_arch)" \ -LIBPATH:"$(WP80_KIT)\lib\$(w8kit_arch)" -LIBPATH:"$(WP80_SDK)\lib$(vc_arch)" -LIBPATH:"$(WIN8_KIT)\Lib\win8\um\$(w8kit_arch)" \
ws2_32.lib \ ws2_32.lib \
"$(shell $(windows-path) "$(wp8)\lib\$(deps_arch)\$(build-type)\zlib.lib")" "$(shell $(windows-path) "$(wp8)\lib\$(deps_arch)\$(build-type)\ThreadEmulation.lib")" "$(shell $(windows-path) "$(wp8)\lib\$(deps_arch)\$(build-type)\zlib.lib")" "$(shell $(windows-path) "$(wp8)\lib\$(deps_arch)\$(build-type)\ThreadEmulation.lib")" \
"$(shell $(windows-path) "$(wp8)\lib\$(deps_arch)\$(build-type)\AvianInteropClient.lib")"
lflags += -NXCOMPAT -DYNAMICBASE -SUBSYSTEM:CONSOLE -TLBID:1 lflags += -NXCOMPAT -DYNAMICBASE -SUBSYSTEM:CONSOLE -TLBID:1
lflags += -NODEFAULTLIB:"ole32.lib" -NODEFAULTLIB:"kernel32.lib" lflags += -NODEFAULTLIB:"ole32.lib" -NODEFAULTLIB:"kernel32.lib"
lflags += PhoneAppModelHost.lib WindowsPhoneCore.lib -WINMD -WINMDFILE:$(subst $(so-suffix),.winmd,$(@)) lflags += PhoneAppModelHost.lib WindowsPhoneCore.lib -WINMD -WINMDFILE:$(subst $(so-suffix),.winmd,$(@))