mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
just a bunch of random code cleanup i did on the train bored, plus a d3d implementation of NativeVertexFormat which isn't actually used yet.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1658 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include "Common.h"
|
||||
#include "FileUtil.h"
|
||||
#include "StringUtil.h"
|
||||
#include "DynamicLibrary.h"
|
||||
|
||||
@ -32,11 +33,10 @@ DynamicLibrary::DynamicLibrary()
|
||||
library = 0;
|
||||
}
|
||||
|
||||
|
||||
std::string GetLastErrorAsString()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LPVOID lpMsgBuf = 0;
|
||||
LPVOID lpMsgBuf = 0;
|
||||
DWORD error = GetLastError();
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
@ -64,13 +64,11 @@ std::string GetLastErrorAsString()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
/* Loading means loading the dll with LoadLibrary() to get an instance to the dll.
|
||||
This is done when Dolphin is started to determine which dlls are good, and
|
||||
before opening the Config and Debugging windows from Plugin.cpp and
|
||||
before opening the dll for running the emulation in Video_...cpp in Core. */
|
||||
// -----------------------
|
||||
// Loading means loading the dll with LoadLibrary() to get an instance to the dll.
|
||||
// This is done when Dolphin is started to determine which dlls are good, and
|
||||
// before opening the Config and Debugging windows from Plugin.cpp and
|
||||
// before opening the dll for running the emulation in Video_...cpp in Core.
|
||||
// Since this is fairly slow, TODO: think about implementing some sort of cache.
|
||||
int DynamicLibrary::Load(const char* filename)
|
||||
{
|
||||
if (!filename || strlen(filename) == 0)
|
||||
@ -80,7 +78,6 @@ int DynamicLibrary::Load(const char* filename)
|
||||
return 0;
|
||||
}
|
||||
LOG(MASTER_LOG, "Trying to load library %s", filename);
|
||||
|
||||
if (IsLoaded())
|
||||
{
|
||||
LOG(MASTER_LOG, "Trying to load already loaded library %s", filename);
|
||||
@ -93,9 +90,17 @@ int DynamicLibrary::Load(const char* filename)
|
||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||
#endif
|
||||
|
||||
if (!library) {
|
||||
if (!library)
|
||||
{
|
||||
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str());
|
||||
PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str());
|
||||
if (File::Exists(filename))
|
||||
{
|
||||
PanicAlert("Error loading DLL %s: %s\n\nAre you missing SDL.DLL or another file that this plugin may depend on?", filename, GetLastErrorAsString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -108,11 +113,9 @@ int DynamicLibrary::Unload()
|
||||
{
|
||||
int retval;
|
||||
if (!IsLoaded()) {
|
||||
LOG(MASTER_LOG, "Error unloading DLL %s: not loaded", library_file.c_str());
|
||||
PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
retval = FreeLibrary(library);
|
||||
@ -120,8 +123,6 @@ int DynamicLibrary::Unload()
|
||||
retval = dlclose(library)?0:1;
|
||||
#endif
|
||||
if (!retval) {
|
||||
LOG(MASTER_LOG, "Error unloading DLL %s: %s", library_file.c_str(),
|
||||
GetLastErrorAsString().c_str());
|
||||
PanicAlert("Error unloading DLL %s: %s", library_file.c_str(),
|
||||
GetLastErrorAsString().c_str());
|
||||
}
|
||||
@ -135,8 +136,8 @@ void* DynamicLibrary::Get(const char* funcname) const
|
||||
void* retval;
|
||||
if (!library)
|
||||
{
|
||||
LOG(MASTER_LOG, "Can't find function %s - Library not loaded.");
|
||||
PanicAlert("Can't find function %s - Library not loaded.");
|
||||
PanicAlert("Can't find function %s - Library not loaded.");
|
||||
return NULL;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
retval = GetProcAddress(library, funcname);
|
||||
@ -145,8 +146,8 @@ void* DynamicLibrary::Get(const char* funcname) const
|
||||
#endif
|
||||
|
||||
if (!retval) {
|
||||
LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
@ -24,23 +24,23 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
// Abstracts the (few) differences between dynamically loading DLLs under Windows
|
||||
// and .so / .dylib under Linux/MacOSX.
|
||||
class DynamicLibrary
|
||||
{
|
||||
public:
|
||||
public:
|
||||
DynamicLibrary();
|
||||
int Load(const char *filename);
|
||||
int Unload();
|
||||
void *Get(const char *funcname) const;
|
||||
bool IsLoaded() const { return library != 0; }
|
||||
|
||||
DynamicLibrary();
|
||||
int Load(const char* filename);
|
||||
int Unload();
|
||||
void* Get(const char* funcname) const;
|
||||
|
||||
bool IsLoaded() const {return(library != 0);}
|
||||
|
||||
private:
|
||||
std::string library_file;
|
||||
private:
|
||||
std::string library_file;
|
||||
#ifdef _WIN32
|
||||
HINSTANCE library;
|
||||
HINSTANCE library;
|
||||
#else
|
||||
void* library;
|
||||
void *library;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -24,44 +24,44 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no);
|
||||
|
||||
static MsgAlertHandler msg_handler = DefaultMsgHandler;
|
||||
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler) {
|
||||
msg_handler = handler;
|
||||
void RegisterMsgAlertHandler(MsgAlertHandler handler)
|
||||
{
|
||||
msg_handler = handler;
|
||||
}
|
||||
|
||||
bool MsgAlert(const char* caption, bool yes_no,
|
||||
const char* format, ...) {
|
||||
|
||||
char buffer[2048];
|
||||
va_list args;
|
||||
bool ret = false;
|
||||
bool MsgAlert(const char* caption, bool yes_no, const char* format, ...)
|
||||
{
|
||||
char buffer[2048];
|
||||
va_list args;
|
||||
bool ret = false;
|
||||
|
||||
va_start(args, format);
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
va_start(args, format);
|
||||
CharArrayFromFormatV(buffer, 2048, format, args);
|
||||
|
||||
LOG(MASTER_LOG, "%s: %s", caption, buffer);
|
||||
LOG(MASTER_LOG, "%s: %s", caption, buffer);
|
||||
|
||||
if (msg_handler) {
|
||||
ret = msg_handler(caption, buffer, yes_no);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
if (msg_handler)
|
||||
{
|
||||
ret = msg_handler(caption, buffer, yes_no);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DefaultMsgHandler(const char* caption, const char* text,
|
||||
bool yes_no) {
|
||||
|
||||
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (yes_no)
|
||||
return IDYES == MessageBox(0, text, caption,
|
||||
MB_ICONQUESTION | MB_YESNO);
|
||||
else {
|
||||
MessageBox(0, text, caption, MB_ICONWARNING);
|
||||
return true;
|
||||
}
|
||||
if (yes_no)
|
||||
return IDYES == MessageBox(0, text, caption,
|
||||
MB_ICONQUESTION | MB_YESNO);
|
||||
else {
|
||||
MessageBox(0, text, caption, MB_ICONWARNING);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
printf("%s\n", text);
|
||||
return true;
|
||||
printf("%s\n", text);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user