Skip to content

Commit

Permalink
Support new WinRT interop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Feb 2, 2013
1 parent 478cfb8 commit 741c5f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
38 changes: 14 additions & 24 deletions classpath/java-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@

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

# include <dirent.h>
Expand Down Expand Up @@ -93,7 +102,9 @@ typedef char char_t;
# endif
#endif // WINAPI_FAMILY

#if !defined(SKIP_OPERATOR_NEW)
inline void* operator new(size_t, void* p) throw() { return p; }
#endif

typedef const char_t* string_t;

Expand Down Expand Up @@ -240,37 +251,16 @@ Java_java_io_File_toAbsolutePath(JNIEnv* e UNUSED, jclass, jstring path)

return path;
# 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);
if(chars) {
LARGE_INTEGER fileSize;
HANDLE file = CreateFile2
(chars, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
std::wstring partialPath = chars;
releaseChars(e, path, chars);

if (file == INVALID_HANDLE_VALUE)
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);
std::wstring fullPath = AvianInterop::GetFullPath(partialPath);

return e->NewString
(reinterpret_cast<const jchar*>(pInfo->FileName), pInfo->FileNameLength / sizeof(WCHAR));
(reinterpret_cast<const jchar*>(fullPath.c_str()), fullPath.length());
}
*/
return path;
# endif
#else
Expand Down
9 changes: 5 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,12 @@ ifeq ($(platform),wp8)
-DAVIAN_VERSION=\"$(version)\" -D_JNI_IMPLEMENTATION_ \
-DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
-DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \
-I"$(shell $(windows-path) "$(wp8)/zlib/upstream")" \
-Fd$(build)/$(name).pdb -I"$(shell $(windows-path) "$(wp8)/include")" -I$(src) -I$(classpath-src) \
-I"$(shell $(windows-path) "$(wp8)/zlib/upstream")" -I"$(shell $(windows-path) "$(wp8)/interop/avian-interop-client")" \
-I"$(shell $(windows-path) "$(wp8)/include")" -I$(src) -I$(classpath-src) \
-I"$(build)" \
-I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \
-DTARGET_BYTES_PER_WORD=$(pointer-size) \
-Gd
-Gd -EHsc

common-lflags = $(classpath-lflags)

Expand Down Expand Up @@ -738,7 +738,8 @@ ifeq ($(platform),wp8)
-MACHINE:$(machine_type) \
-LIBPATH:"$(WP80_KIT)\lib\$(w8kit_arch)" -LIBPATH:"$(WP80_SDK)\lib$(vc_arch)" -LIBPATH:"$(WIN8_KIT)\Lib\win8\um\$(w8kit_arch)" \
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 += -NODEFAULTLIB:"ole32.lib" -NODEFAULTLIB:"kernel32.lib"
lflags += PhoneAppModelHost.lib WindowsPhoneCore.lib -WINMD -WINMDFILE:$(subst $(so-suffix),.winmd,$(@))
Expand Down

0 comments on commit 741c5f7

Please sign in to comment.