diff --git a/sourcepawn/include/sp_vm_types.h b/sourcepawn/include/sp_vm_types.h index 345b6159..82212ab5 100644 --- a/sourcepawn/include/sp_vm_types.h +++ b/sourcepawn/include/sp_vm_types.h @@ -16,6 +16,7 @@ typedef int32_t cell_t; #define SP_ERR_PARAM 4 /* Invalid parameter */ #define SP_ERR_INVALID_ADDRESS 5 /* A memory address was not valid */ #define SP_ERR_NOT_FOUND 6 /* The object in question was not found */ +#define SP_ERR_INDEX 7 /* Invalid index parameter */ /********************************************** *** The following structures are reference structures. diff --git a/sourcepawn/vm/sp_reader.c b/sourcepawn/vm/sp_reader.c index 92f8b9a3..a9f5e092 100644 --- a/sourcepawn/vm/sp_reader.c +++ b/sourcepawn/vm/sp_reader.c @@ -39,10 +39,6 @@ sp_plugin_t *_ReadPlugin(sp_file_hdr_t *hdr, uint8_t *base, sp_plugin_t *plugin, plugin->data_size = dat->datasize; plugin->memory = dat->memsize; } - else if (!(plugin->info->stringbase) && !strcmp(nameptr, ".names")) - { - plugin->info->stringbase = base + secptr->dataoffs; - } else if (!(plugin->info->publics) && !strcmp(nameptr, ".publics")) { plugin->info->publics_num = secptr->size / sizeof(sp_file_publics_t); @@ -58,25 +54,34 @@ sp_plugin_t *_ReadPlugin(sp_file_hdr_t *hdr, uint8_t *base, sp_plugin_t *plugin, plugin->info->natives_num = secptr->size / sizeof(sp_file_natives_t); plugin->info->natives = (sp_file_natives_t *)(base + secptr->dataoffs); } + else if (!(plugin->info->stringbase) && !strcmp(nameptr, ".names")) + { + plugin->info->stringbase = base + secptr->dataoffs; + } else if (!(plugin->debug->files) && !strcmp(nameptr, ".dbg.files")) { - plugin->debug->files_num = secptr->size / sizeof(sp_fdbg_file_t); plugin->debug->files = (sp_fdbg_file_t *)(base + secptr->dataoffs); } + else if (!(plugin->debug->lines) && !strcmp(nameptr, ".dbg.lines")) + { + plugin->debug->lines = (sp_fdbg_line_t *)(base + secptr->dataoffs); + } + else if (!(plugin->debug->symbols) && !strcmp(nameptr, ".dbg.symbols")) + { + plugin->debug->symbols = (sp_fdbg_symbol_t *)(base + secptr->dataoffs); + } + else if (!(plugin->debug->lines_num) && !strcmp(nameptr, ".dbg.info")) + { + sp_fdbg_info_t *inf = (sp_fdbg_info_t *)(base + secptr->dataoffs); + plugin->debug->files_num = inf->num_files; + plugin->debug->lines_num = inf->num_lines; + plugin->debug->syms_num = inf->num_syms; + } else if (!(plugin->debug->stringbase) && !strcmp(nameptr, ".dbg.strings")) { plugin->debug->stringbase = base + secptr->dataoffs; } - else if (!(plugin->debug->lines) && !strcmp(nameptr, ".dbg.lines")) - { - plugin->debug->lines_num = secptr->size / sizeof(sp_fdbg_line_t); - plugin->debug->lines = (sp_fdbg_line_t *)(base + secptr->dataoffs); - } - else if (!(plugin->debug->symbols) && !strcmp(nameptr, ".dbg.symbols")) - { - plugin->debug->syms_num = secptr->size / sizeof(sp_fdbg_symbol_t); - plugin->debug->symbols = (sp_fdbg_symbol_t *)(base + secptr->dataoffs); - } + secptr++; sectnum++; } diff --git a/sourcepawn/vm/sp_vm.h b/sourcepawn/vm/sp_vm.h index 657e33d1..e8a3ae68 100644 --- a/sourcepawn/vm/sp_vm.h +++ b/sourcepawn/vm/sp_vm.h @@ -146,11 +146,18 @@ int SP_GetPubvarByIndex(sp_context_t *ctx, uint32_t index, sp_pubvar_t **pubvar) * @param local_addr Optionally filled with local address offset. * @param phys_addr Optionally filled with relocated physical address. */ -int SP_FindPubvarByName(sp_context_t *ctx, - const char *name, - uint32_t *index, - cell_t *local_addr, - cell_t **phys_addr); +int SP_FindPubvarByName(sp_context_t *ctx, const char *name, uint32_t *index); + +//:TODO: fill in the info of this function, hi +int SP_GetPubvarAddrs(sp_context_t *ctx, uint32_t index, cell_t *local_addr, cell_t **phys_addr); + +/** +* Gets the number of public variables. +* +* @param ctx Context pointer. +* @param num Filled with the number of public variables. +*/ +int SP_GetPubVarsNum(sp_context_t *ctx, uint32_t *num); /** * Round-about method of converting a plugin reference to a physical address @@ -162,7 +169,7 @@ int SP_FindPubvarByName(sp_context_t *ctx, int SP_LocalToPhysAddr(sp_context_t *ctx, cell_t local_addr, cell_t **phys_addr); /** - * Convers a local address to a physical string. + * Converts a local address to a physical string. * Note that SourcePawn does not support packed strings, as such this function is * 'cell to char' only. *