Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
66 user(s) are online (47 user(s) are browsing Forums)

Members: 0
Guests: 66

more...

Support us!

Headlines

Report message:*
 

Re: Porting to AmigaOS4 thread

Subject: Re: Porting to AmigaOS4 thread
by Raziel on 2020/11/22 15:02:33

@Capehill

Sorry for being a noob.

These are both .cpp/.h

#ifndef BACKEND_AMIGAOS_DIALOGS_H
#define BACKEND_AMIGAOS_DIALOGS_H

#if defined(__amigaos4__) && defined(USE_SYSDIALOGS) 

#include "common/fs.h"
#include "common/dialogs.h"

class AmigaOSDialogManager : public Common::DialogManager {
public:
    
virtual DialogResult showFileBrowser(const Common::U32String &titleCommon::FSNode &choicebool isDirBrowser);

private:
    const 
char *utf8ToLocal(const char *in);
};

#endif

#endif // BACKEND_AMIGAOS_DIALOGS_H


#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
#define FORBIDDEN_SYMBOL_EXCEPTION_strdup

#include "common/scummsys.h"

#if defined(__amigaos4__) && defined(USE_SYSDIALOGS)

#include "backends/dialogs/amigaos/amigaos-dialogs.h"

#include "common/config-manager.h"
#include "common/encoding.h"

#include <proto/asl.h>
#include <proto/codesets.h>
#include <proto/dos.h>
#include <proto/exec.h>

#include <cstring>
#include <cstdlib>

struct CodesetsIFace *ICodesets nullptr;
struct Library *CodesetsBase nullptr;

const 
char *AmigaOSDialogManager::utf8ToLocal(const char *in) {

    if (!
in) {
        return 
strdup("");
    }

    
CodesetsBase IExec->OpenLibrary("codesets.library"6);

    if (
CodesetsBase) {

        
ICodesets = (CodesetsIFace *)IExec->GetInterface(CodesetsBase"main"1Lnullptr);

        
struct codeset *srcmib ICodesets->CodesetsFind("ISO-8859-1"CSA_FallbackToDefaultFALSETAG_DONE);
        
struct codeset *dstmib ICodesets->CodesetsFind("UTF-8"CSA_FallbackToDefaultFALSETAG_DONE);

        if (
dstmib != nullptr) {
            
ULONG dstlen ICodesets->CodesetsStrLen(inTAG_END);

            
char *out = (char *)malloc(dstlen 1);
            if (
out) {
                if ((
out=ICodesets->CodesetsConvertStr(CSA_SourceCodesetsrcmibCSA_DestCodesetdstmibCSA_SourceinTAG_DONE)) != nullptr) {
                    return 
out;
                }
            }
            
free(out);
        }
        
IExec->DropInterface((struct Interface *)ICodesets);
        
ICodesets nullptr;
        
IExec->CloseLibrary(CodesetsBase);
        
CodesetsBase nullptr;
    }

    return 
strdup(in);
}

struct AslIFace *IAsl;
struct Library *AslBase;

Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String &titleCommon::FSNode &choicebool isDirBrowser) {

    
char pathBuffer[MAXPATHLEN];

    
Common::String utf8Title title.encode();    

    
DialogResult result kDialogCancel;

    
AslBase IExec->OpenLibrary(AslName50);
    if (
AslBase) {

        
IAsl = (struct AslIFace*)IExec->GetInterface(AslBase"main"1nullptr);

        
struct FileRequester *fr nullptr;

        if (
ConfMan.hasKey("browser_lastpath")) {
            
strncpy(pathBufferConfMan.get("browser_lastpath").c_str(), sizeof(pathBuffer)-1);
        }

        
fr = (struct FileRequester *)IAsl->AllocAslRequestTags(ASL_FileRequestTAG_DONE);

        if (!
fr)
            return 
result;

        const 
char *newTitle utf8ToLocal((const char *)utf8Title.c_str());

        if (
IAsl->AslRequestTags(frASLFR_TitleTextnewTitleASLFR_RejectIconsTRUEASLFR_InitialDrawerpathBufferASLFR_DrawersOnly, (isDirBrowser TRUE FALSE), TAG_DONE)) {

            if (
strlen(fr->fr_Drawer) < sizeof(pathBuffer)) {
                
strncpy(pathBufferfr->fr_Drawersizeof(pathBuffer));
                if (!
isDirBrowser) {
                    
IDOS->AddPart(pathBufferfr->fr_Filesizeof(pathBuffer));
                }
                
choice Common::FSNode(pathBuffer);
                
ConfMan.set("browser_lastpath"pathBuffer);
                
result kDialogOk;
            }
            
free(newTitle);
            
IAsl->FreeAslRequest((APTR)fr);
        }
        
IExec->DropInterface((struct Interface*)IAsl);
        
IAsl nullptr;
        
IExec->CloseLibrary(AslBase); 
        
AslBase nullptr;
    }

    return 
result;
}

#endif

I get this now on compiling
C++      backends/dialogs/amigaos/amigaos-dialogs.o
backends
/dialogs/amigaos/amigaos-dialogs.cppIn member function 'virtual Common::DialogManager::DialogResult AmigaOSDialogManager::showFileBrowser(const Common::U32String&, Common::FSNode&, bool)':
backends/dialogs/amigaos/amigaos-dialogs.cpp:123:9errorinvalid conversion from 'const void*' to 'void*' [-fpermissive]
    
free(newTitle);
         ^~~~~~~~
In file included from /SDK/newlib/include/stdio.h:29,
                 
from ./common/scummsys.h:118,
                 
from backends/dialogs/amigaos/amigaos-dialogs.cpp:28:
/
SDK/newlib/include/stdlib.h:86:20note:   initializing argument 1 of 'void free(void*)'
 
_VOID _EXFUN(free,(_PTR));
                    ^~~~
gmake: *** [backends/dialogs/amigaos/amigaos-dialogs.oError 1


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project