Я слишком тупой для того что бы починить это:3

This commit is contained in:
DepressedTWM 2026-05-01 14:06:47 -04:00
parent 0aa926c4a1
commit 427393436f
1 changed files with 4 additions and 19 deletions

View File

@ -30,13 +30,10 @@
#include <ruby.h> #include <ruby.h>
void fileIntFreeInstance(void *inst){ void fileIntFreeInstance(void *inst){
printf("[fileIntFreeInstance] fileIntFreeInstance\n");
SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst); SDL_IOStream *ops = static_cast<SDL_IOStream*>(inst);
if (ops) {
printf("[fileIntFreeInstance] Closing ops\n"); printf("[fileIntFreeInstance] Closing ops\n");
SDL_CloseIO(ops); SDL_CloseIO(ops);
} }
}
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance); DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
VALUE fileIntForPath(const char *path, bool rubyExc){ VALUE fileIntForPath(const char *path, bool rubyExc){
@ -44,10 +41,6 @@ VALUE fileIntForPath(const char *path, bool rubyExc){
SDL_IOStream* ops = nullptr; SDL_IOStream* ops = nullptr;
try{ try{
shState->fileSystem().openReadRaw(ops, path); shState->fileSystem().openReadRaw(ops, path);
if (!ops){
printf("[fileIntForPath] Null guard!\n");
return Qnil;
}
} }
catch (const Exception &e){ catch (const Exception &e){
if (ops){ if (ops){
@ -71,15 +64,10 @@ VALUE fileIntForPath(const char *path, bool rubyExc){
} }
RB_METHOD(fileIntRead){ RB_METHOD(fileIntRead){
printf("[fileIntRead] fileIntRead\n");
int length = -1; int length = -1;
rb_get_args(argc, argv, "i", &length); rb_get_args(argc, argv, "i", &length);
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (!ops){
printf("[fileIntRead] Null guard!\n");
return Qnil;
}
if (length == -1){ if (length == -1){
Sint64 cur = SDL_TellIO(ops); Sint64 cur = SDL_TellIO(ops);
Sint64 end = SDL_SeekIO(ops, 0, SDL_IO_SEEK_END); Sint64 end = SDL_SeekIO(ops, 0, SDL_IO_SEEK_END);
@ -102,7 +90,6 @@ RB_METHOD(fileIntRead){
} }
RB_NA_METHOD(fileIntClose){ RB_NA_METHOD(fileIntClose){
printf("[fileIntClose] fileIntClose\n");
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
if (!ops){ if (!ops){
printf("[fileIntClose] Already closed or null\n"); printf("[fileIntClose] Already closed or null\n");
@ -116,16 +103,14 @@ RB_NA_METHOD(fileIntClose){
return Qnil; return Qnil;
} }
RB_NA_METHOD(fileIntGetByte){ RB_NA_METHOD(fileIntGetByte){
printf("[fileIntGetByte] fileIntGetByte\n");
SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self); SDL_IOStream *ops = getPrivateData<SDL_IOStream>(self);
unsigned char byte = 0; unsigned char byte = 0;
size_t result = SDL_ReadIO(ops, &byte, 1); size_t result = SDL_ReadIO(ops, &byte, 1);
printf("[fileIntGetByte] %s\n", byte); printf("[fileIntGetByte] %u\n", byte);
return (result == 1) ? INT2NUM(byte) : Qnil; return (result == 1) ? INT2NUM(byte) : Qnil;
} }
RB_NA_METHOD(fileIntBinmode){ RB_NA_METHOD(fileIntBinmode){
printf("[fileIntBinMode] Plug\n");
return Qnil; return Qnil;
} }
@ -209,7 +194,7 @@ VALUE stringForceUTF8(VALUE arg){
} }
VALUE customProc(VALUE arg, VALUE proc){ VALUE customProc(VALUE arg, VALUE proc){
printf("[customProc] \n"); printf("[customProc] UwU\n");
VALUE obj = stringForceUTF8(arg); VALUE obj = stringForceUTF8(arg);
obj = rb_funcall2(proc, rb_intern("call"), 1, &obj); obj = rb_funcall2(proc, rb_intern("call"), 1, &obj);
return obj; return obj;