Skip to content
Open

Misc #36

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DarkEdif/Inc/Android/MMFAndroidMasterHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../Shared/AllPlatformDefines.hpp"
#include "../Shared/NonWindowsDefines.hpp"

#include <asm-generic\posix_types.h>
#include <asm-generic/posix_types.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
Expand Down
6 changes: 3 additions & 3 deletions DarkEdif/Inc/Shared/AllPlatformDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ using namespace std::string_view_literals;
#elif defined(__clang__) && !defined (__INTELLISENSE__)
#define PrintFHintInside /* no op */
// Defined after a C printf-style function declaration to allow code analysers to check the %x are correct type
#define PrintFHintAfter(formatParamIndex,dotsParamIndex) __printflike(formatParamIndex, dotsParamIndex)
#define PrintFHintAfter(formatParamIndex,dotsParamIndex) __attribute__((format(printf, formatParamIndex, dotsParamIndex)))
#else
// Defined inside a C printf-style function declaration + definition to allow code analysers to check argument types.
#define PrintFHintInside /* no op */
Expand Down Expand Up @@ -335,10 +335,10 @@ enum_class_is_a_bitmask(TextCapacity);

// ==================================================================================================
// DarkEdif logging and macros.
//
//
// These are printf-based, and expect a newline at end:
// LOGI(_T("Some text with variable: %d\n"), 50);
//
//
// Log levels are based on the ANDROID_LOG_XXX enum; in order of highest to lowest severity:
// LOGF, LOGE, LOGW, LOGI, LOGD, LOGV.
//
Expand Down
4 changes: 3 additions & 1 deletion DarkEdif/Inc/Shared/DarkEdif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,14 @@ namespace DarkEdif {
FontInfoMultiPlat(jobject nativeFont);
// Creates a copy of font settings of this native font
void SetFont(const jobject nativeFont);
#else // Apple
#elif defined(__APPLE__)
CFontInfo* cfontinfo = nullptr;
// Creates a font info pointing to a native font
FontInfoMultiPlat(CFontInfo* nativeFont);
// Creates a copy of font settings of this native font
void SetFont(const void* const nativeFont);
#else
#error Unexpected platform
#endif
#if TEXT_OEFLAG_EXTENSION
// Creates a runtime-usable font from a EDITDATA font, tying it to an ext
Expand Down
16 changes: 9 additions & 7 deletions DarkEdif/Inc/Shared/Edif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Prop;
#include "..\Windows\MMFWindowsMasterHeader.hpp"
extern HINSTANCE hInstLib;
#elif defined (__ANDROID__)
#include "..\Android\MMFAndroidMasterHeader.hpp"
#include "../Android/MMFAndroidMasterHeader.hpp"
#elif defined (__APPLE__)
#if MacBuild == 0
#include "../iOS/MMFiOSMasterHeader.hpp"
#else
#include "../Mac/MMFMacMasterHeader.hpp"
#endif
#if MacBuild == 0
#include "../iOS/MMFiOSMasterHeader.hpp"
#else
#include "../Mac/MMFMacMasterHeader.hpp"
#endif
#else
#error Unexpected platform
#endif
Expand Down Expand Up @@ -217,9 +217,11 @@ namespace Edif
// Attaches current thread, and gets JNIEnv for it; errors are fatal
static void AttachJVMAccessForThisThread(const char * threadName, bool asDaemon = false);
static void DetachJVMAccessForThisThread();
#else
#elif defined(__APPLE__)
Runtime(Extension* ext, void * const objCExtPtr);
void * curCEvent;
#else
#error Unexpected platform
#endif

DarkEdif::FontInfoMultiPlat* extFont = NULL;
Expand Down
4 changes: 3 additions & 1 deletion DarkEdif/Inc/Shared/SurfaceMultiPlat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,13 @@ namespace DarkEdif
//global<jobject> paint;
//global<jclass> paintClass;
public:
#else // apple
#elif defined(__APPLE__)
// Raw pixels, size and clip rectangle
CRenderToTexture* bmp = nullptr;
// Data around an image, can wrap a bmp and collision masks
//CImage* img;
#else
#error Unexpected platform
#endif
/** Updates screen display manually. Runtime does not auto-redraw in some display modes.
* @param zone If NULL or not specified, the whole surface. */
Expand Down
7 changes: 7 additions & 0 deletions DarkEdif/Inc/Windows/MMFWindowsMasterHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,13 @@ enum class BUILDTYPE {
XNA_PHONE,
XNA_XBOX_APP,
XNA_PHONE_APP,
HTML5,
VITA,
VITADEVEL,
VITAFINAL, // no longer used
HTML5DEVEL,
HTML5FINAL,
OUYA,
STDMAX, // end of standard build types
};

Expand Down
25 changes: 17 additions & 8 deletions DarkEdif/Lib/Shared/DarkEdif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5372,7 +5372,7 @@ void DarkEdif::FontInfoMultiPlat::SetFont(const jobject ptr) {
JavaAndCString str((jstring)threadEnv->GetObjectField(ptr, lfFaceName));
fontNameDesired = str.str();
}
#else // apple
#elif defined(__APPLE__)
DarkEdif::FontInfoMultiPlat::FontInfoMultiPlat(CFontInfo* ptr) {
cfontinfo = ptr;
SetFont(cfontinfo);
Expand All @@ -5386,7 +5386,8 @@ void DarkEdif::FontInfoMultiPlat::SetFont(const void * ptr2) {
strikeOut = ptr->lfStrikeOut != 0;
fontNameDesired = [ptr->lfFaceName UTF8String];
}

#else
#error Unexpected platform
#endif

DarkEdif::FontInfoMultiPlat::FontInfoMultiPlat() {
Expand Down Expand Up @@ -5676,8 +5677,10 @@ int DarkEdif::GetCurrentFusionEventNum(const Extension * const ext)
}

return threadEnv->CallIntMethod(ext->javaExtPtr, getEventIDMethod);
#else // iOS
#elif defined(__APPLE__)
return DarkEdifObjCFunc(PROJECT_TARGET_NAME_UNDERSCORES_RAW, getCurrentFusionEventNum)(ext->objCExtPtr);
#else
#error Unexpected platform
#endif
}

Expand Down Expand Up @@ -5715,8 +5718,10 @@ std::tstring DarkEdif::MakePathUnembeddedIfNeeded(const Extension * ext, const s
JavaAndCString newPath((jstring)threadEnv->CallObjectMethod(ext->javaExtPtr, getEventIDMethod, origPath.javaRef));
// Copy the C++ memory out into its own variable
const std::string truePath(newPath.str());
#else
#elif defined(__APPLE__)
const std::string truePath = DarkEdifObjCFunc(PROJECT_TARGET_NAME_UNDERSCORES_RAW, makePathUnembeddedIfNeeded)(ext->objCExtPtr, std::string(filePath).c_str());
#else
#error Unexpected platform
#endif
if (filePath != truePath)
LOGV(_T("File path extracted from \"%s\" to \"%s\".\n"), std::tstring(filePath).c_str(), truePath.c_str());
Expand Down Expand Up @@ -6272,7 +6277,7 @@ void DarkEdif::LOGFInternal(PrintFHintInside const TCHAR * x, ...)
DarkEdif::MsgBox::Error(_T("Fatal error"), _T("%s"), buf);
std::abort();
}
#else // APPLE
#elif defined(__APPLE__)

#include <unistd.h>
#include <sys/syscall.h>
Expand Down Expand Up @@ -6409,6 +6414,8 @@ void DarkEdif::LOGFInternal(PrintFHintInside const TCHAR * x, ...)
va_end(va);
exit(EXIT_FAILURE);
}
#else
#error Unexpected platform
#endif


Expand All @@ -6435,7 +6442,7 @@ bool DarkEdif::IsDebuggerAttached()
return std::stoi(line.substr(10)) != 0;
// if no match, fall thru
}
#else // APPLE
#elif defined(__APPLE__)
// Apple is heavily sandboxed. This solution seems like it should work on non-jailbroken iOS.
// Other possible alternatives for Apple: getppid() != 1 or isatty(STDERR_FILENO)
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
Expand All @@ -6446,7 +6453,9 @@ bool DarkEdif::IsDebuggerAttached()
if (!sysctl(mib, 4, &info, &size, nullptr, 0))
return (info.kp_proc.p_flag & P_TRACED) != 0;
LOGE(_T("Couldn't detect debugger: sysctl() returned error %d\n"), errno);
#endif // Apple
#else
#error Unexpected platform
#endif

#ifdef _DEBUG
// If debug, if debugger detect fails, we'll assume a debugger is present.
Expand Down Expand Up @@ -6793,7 +6802,7 @@ namespace DarkEdif

// To not make this ANSI ext clobber the debugger's text with replacement characters,
// we always talk to CF2.5+ with Wide characters

// Move caret to end of Fusion debugger text
int curTextLen = GetWindowTextLengthW(CF25PlusEditBoxHandle);
// On error, default to passing -1, -1, which resets caret
Expand Down
6 changes: 4 additions & 2 deletions DarkEdif/Lib/Shared/Edif.General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ ProjectFunc void JNICALL JNI_OnUnload([[maybe_unused]] JavaVM * vm, [[maybe_unus
#endif // DARKEDIF_SIGNAL_HANDLERS
}

#else // iOS
#elif defined(__APPLE__)
#include "Extension.hpp"
#include "MMF2Lib/CTexture.h"
#include "MMF2Lib/CImage.h"
Expand Down Expand Up @@ -840,7 +840,9 @@ Extension* RunObject::GetExtension()
return (Extension *)DarkEdifObjCFunc(PROJECT_TARGET_NAME_UNDERSCORES_RAW, getCPtr)((CExtension *)this);
}

#endif // Apple
#else
#error Unexpected platform
#endif


#if DARKEDIF_DISPLAY_TYPE > DARKEDIF_DISPLAY_ANIMATIONS
Expand Down
23 changes: 14 additions & 9 deletions DarkEdif/Lib/Shared/Edif.Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ std::vector<short> qualToOi::HalfVector(std::size_t first)
get_OiList(0);
for (std::size_t i = first; i < OiAndOiListLength; i += 2)
list.push_back(OiAndOiList[i]);
#else // apple
#elif defined(__APPLE__)
const short* const qoiList = ((CQualToOiList*)this)->qoiList;
for (std::size_t i = first; qoiList[i] != -1; i += 2)
list.push_back(qoiList[i]);
#else
#error Unexpected platform
#endif
return list;
}
Expand All @@ -118,7 +120,7 @@ CRunAppMultiPlat* CRunAppMultiPlat::get_ParentApp() {
return ParentApp;
#elif defined(__APPLE__)
return (CRunAppMultiPlat*)((CRunApp*)this)->parentApp;
#else // Android
#elif defined(__ANDROID__)
if (!parentApp && !parentAppIsNull)
{
// Application/CRunApp parentApp
Expand All @@ -132,6 +134,8 @@ CRunAppMultiPlat* CRunAppMultiPlat::get_ParentApp() {
parentAppIsNull = true;
}
return parentApp.get();
#else
#error Unexpected platform
#endif
}

Expand All @@ -140,7 +144,7 @@ std::size_t CRunAppMultiPlat::GetNumFusionFrames() {
return hdr.NbFrames;
#elif defined(__APPLE__)
return (std::size_t)((CRunApp*)this)->gaNbFrames;
#else // Android
#elif defined(__ANDROID__)
if (numTotalFrames == 0)
{
jfieldID fieldID = threadEnv->GetFieldID(meClass, "gaNbFrames", "I");
Expand All @@ -150,6 +154,8 @@ std::size_t CRunAppMultiPlat::GetNumFusionFrames() {
numTotalFrames = (std::size_t)totalFrames;
}
return numTotalFrames;
#else
#error Unexpected platform
#endif
}

Expand Down Expand Up @@ -1580,11 +1586,10 @@ void Edif::Runtime::AttachJVMAccessForThisThread(const char* threadName, bool as

pthread_setname_np(pthread_self(), threadName);

JavaVMAttachArgs args = {
.name = threadName,
.group = NULL,
.version = JNI_VERSION_1_6
};
JavaVMAttachArgs args = {0};
args.name = threadName;
args.group = NULL;
args.version = JNI_VERSION_1_6;
// Daemon means the JVM won't keep the app running if this thread is still alive.
// Do you want main thread exiting to choose whether the app is running or not?
jint error;
Expand Down Expand Up @@ -3799,7 +3804,7 @@ EventGroupMP::EventGroupMP(jobject me, Edif::Runtime * runtime) :
}
}

#else // iOS
#elif defined(__APPLE__)
#include "MMF2Lib/CRunExtension.h"
#include "MMF2Lib/CRun.h"
#include "MMF2Lib/CObject.h"
Expand Down
Loading