Hola SplinterGU, abro este topic para no sobrecargar el otro de noticias referente al wip4
Resulta que al fín he rulado un modulo con un simple printf, pero solo me va para el caso de enteros, cuando intento usar string_get casca la ejecución del dcb final. te adjunto ejemplo, quizas sea error mio y no del bennu.
Para el caso de un Int:
******************
mod_print.c:
---------------
#include <stdio.h>
#include <stdlib.h>
#include <bgdi.h>
#include <bgddl.h>
static void s_print(INSTANCE * my, int * params) {
fprintf(stdout, "%d", params[0]);
return;
}
DLSYSFUNCS functions_exports[] = { { "S_PRINT", "I", TYPE_DWORD, s_print }, {
NULL, NULL, 0, NULL } };
-----------
print.prg:
-----------
Program print1;
Begin
s_print(178);
end
-----------
print.imp:
-----------
mod_key
mod_proc
mod_print
-------------
resultado:
------------
C:\DevBennu\workspace\pruebas>bgdc -Ca print.prg
Fichero print.dcb grabado (20719 bytes):
Procesos: 1 procesos
Datos globales: 172 bytes
Datos locales: 44 bytes
Datos privados: 0 bytes
Datos publicos: 0 bytes
Codigo: 28 bytes
Procesos del sistema: 11 procesos
Variables globales: 11 variables
Variables locales: 7 variables
Variables privadas: 0 variables
Variables publicas: 0 variables
Identificadores: 292 identificadores
Estructuras: 1 estructuras
Cadenas: 5 cadenas (33 bytes)
C:\DevBennu\workspace\pruebas>bgdi print.dcb
178
Para el caso de un String:
******************
mod_print.c:
---------------
#include <stdio.h>
#include <stdlib.h>
#include <bgdi.h>
#include <bgddl.h>
static void s_print(INSTANCE * my, int * params) {
fprintf(stdout, "%s",string_get(params[0]));
string_discard(params[0]) ;
return;
}
DLSYSFUNCS functions_exports[] = { { "S_PRINT", "S", TYPE_DWORD, s_print }, {
NULL, NULL, 0, NULL } };
-----------
print.prg:
-----------
Program print1;
Global
string hola="hola";
Begin
s_print(hola);
end
-----------
print.imp:
-----------
mod_key
mod_proc
mod_print
-------------
resultado:
------------
C:\DevBennu\workspace\pruebas>bgdc -Ca print.prg
Fichero print.dcb grabado (20727 bytes):
Procesos: 1 procesos
Datos globales: 172 bytes
Datos locales: 44 bytes
Datos privados: 0 bytes
Datos publicos: 0 bytes
Codigo: 28 bytes
Procesos del sistema: 11 procesos
Variables globales: 11 variables
Variables locales: 7 variables
Variables privadas: 0 variables
Variables publicas: 0 variables
Identificadores: 292 identificadores
Estructuras: 1 estructuras
Cadenas: 6 cadenas (37 bytes)
C:\DevBennu\workspace\pruebas>bgdi print.dcb
Assertion failed: code < string_count && code >= 0, file strings.c, line 177
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
seguramente no estas linkeando contra la bgdrtm.dll...
Makefile.in
## Process this file with automake to produce Makefile.in
#AUTOMAKE_OPTIONS = no-dependencies foreign
lib_LTLIBRARIES = mod_say.la
mod_say_la_SOURCES = mod_say.c
mod_say_la_CFLAGS = $(COMMON_CFLAGS) -I../../include
mod_say_la_LDFLAGS = -s -module -no-undefined -avoid-version -export-symbols mod_say.sym
mod_say_la_LIBADD = $(LIBADD_DL) -L../../bgdi/bgdrtm/.libs -lbgdrtm
## Make sure these will be cleaned even when they're not built by
## default.
CLEANFILES = mod_say.la
mod_say.c
[code language="C"]
/*
* Copyright © 2006-2008 SplinterGU (Fenix/Bennugd)
* Copyright © 2002-2006 Fenix Team (Fenix)
* Copyright © 1999-2002 José Luis Cebrián Pagüe (Fenix)
*
* This file is part of Bennu - Game Development
*
* Bennu is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Bennu is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bgddl.h"
#include "xstrings.h"
/* ---------------------------------------------------------------------- */
static int modsay_say (INSTANCE * my, int * params)
{
/* Show debugging info also in stdout */
printf ("%s\n", string_get(params[0]));
fflush(stdout);
string_discard(params[0]) ;
return 1 ;
}
/* ----------------------------------------------------------------- */
/* Declaracion de funciones */
DLSYSFUNCS functions_exports[] = {
{ "SAY" , "S" , TYPE_STRING, modsay_say },
{ 0 , 0 , 0 , 0 }
};
/* ----------------------------------------------------------------- */
[/code]
mod_say.sym
functions_exports
El codigo que te acabo de pasar funciona perfectamente... tanto con strings como con numeros.
OK, gracias, era eso, que tontería no haberme dado cuenta :'(