Add --hateentry to perl-doc-parser.pl - format perl_hateentry.cpp

This commit is contained in:
Akkadius 2018-07-01 20:04:53 -05:00
parent 465071c2cf
commit 6faaff31be
2 changed files with 41 additions and 37 deletions

View File

@ -9,6 +9,7 @@ sub usage() {
print " --door - Prints methods for just door class methods\n"; print " --door - Prints methods for just door class methods\n";
print " --group - Prints methods for just group class methods\n"; print " --group - Prints methods for just group class methods\n";
print " --corpse - Prints methods for just corpse class methods\n"; print " --corpse - Prints methods for just corpse class methods\n";
print " --hateentry - Prints methods for just hateentry class methods\n";
print " --all - Prints methods for all classes\n"; print " --all - Prints methods for all classes\n";
exit(1); exit(1);
} }
@ -49,7 +50,7 @@ for my $file (@files) {
chomp; chomp;
$line = $_; $line = $_;
if ($line=~/Client::|Mob::|Corpse::|EntityList::|Doors::|Group::/i && $line=~/_croak/i) { if ($line=~/Client::|Mob::|Corpse::|EntityList::|Doors::|Group::|HateEntry::/i && $line=~/_croak/i) {
#::: Client export #::: Client export
if ($export=~/all|client/i) { if ($export=~/all|client/i) {
@ -87,6 +88,12 @@ for my $file (@files) {
$object_prefix = "\$group->"; $object_prefix = "\$group->";
} }
#::: Hateentry export
if ($export=~/all|hateentry/i) {
$split_key = "HateEntry::";
$object_prefix = "\$hate_entry->";
}
#::: Split on croak usage #::: Split on croak usage
@data = split($split_key, $line); @data = split($split_key, $line);
$usage = trim($data[1]); $usage = trim($data[1]);

View File

@ -18,7 +18,9 @@
#include "../common/features.h" #include "../common/features.h"
#include "client.h" #include "client.h"
#ifdef EMBPERL_XS_CLASSES #ifdef EMBPERL_XS_CLASSES
#include "../common/global_define.h" #include "../common/global_define.h"
#include "embperl.h" #include "embperl.h"
@ -34,79 +36,75 @@
#endif #endif
XS(XS_HateEntry_GetEnt); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetEnt); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetEnt) XS(XS_HateEntry_GetEnt) {
{
dXSARGS; dXSARGS;
if (items != 1) if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetData(THIS)"); Perl_croak(aTHX_ "Usage: HateEntry::GetData(THIS)");
{ {
struct_HateList * THIS; struct_HateList *THIS;
Mob * RETVAL; Mob *RETVAL;
if (sv_derived_from(ST(0), "HateEntry")) { if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *,tmp); THIS = INT2PTR(struct_HateList *, tmp);
} } else
else
Perl_croak(aTHX_ "THIS is not of type tHateEntry"); Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if(THIS == nullptr) if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->entity_on_hatelist; RETVAL = THIS->entity_on_hatelist;
ST(0) = sv_newmortal(); ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "Mob", (void*)RETVAL); sv_setref_pv(ST(0), "Mob", (void *) RETVAL);
} }
XSRETURN(1); XSRETURN(1);
} }
XS(XS_HateEntry_GetHate); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetHate); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetHate) XS(XS_HateEntry_GetHate) {
{
dXSARGS; dXSARGS;
if (items != 1) if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetHate(THIS)"); Perl_croak(aTHX_ "Usage: HateEntry::GetHate(THIS)");
{ {
struct_HateList * THIS; struct_HateList *THIS;
int32 RETVAL; int32 RETVAL;
dXSTARG; dXSTARG;
if (sv_derived_from(ST(0), "HateEntry")) { if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *,tmp); THIS = INT2PTR(struct_HateList *, tmp);
} } else
else
Perl_croak(aTHX_ "THIS is not of type tHateEntry"); Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if(THIS == nullptr) if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->stored_hate_amount; RETVAL = THIS->stored_hate_amount;
XSprePUSH; PUSHi((IV)RETVAL); XSprePUSH;
PUSHi((IV) RETVAL);
} }
XSRETURN(1); XSRETURN(1);
} }
XS(XS_HateEntry_GetDamage); /* prototype to pass -Wmissing-prototypes */ XS(XS_HateEntry_GetDamage); /* prototype to pass -Wmissing-prototypes */
XS(XS_HateEntry_GetDamage) XS(XS_HateEntry_GetDamage) {
{
dXSARGS; dXSARGS;
if (items != 1) if (items != 1)
Perl_croak(aTHX_ "Usage: HateEntry::GetDamage(THIS)"); Perl_croak(aTHX_ "Usage: HateEntry::GetDamage(THIS)");
{ {
struct_HateList * THIS; struct_HateList *THIS;
int32 RETVAL; int32 RETVAL;
dXSTARG; dXSTARG;
if (sv_derived_from(ST(0), "HateEntry")) { if (sv_derived_from(ST(0), "HateEntry")) {
IV tmp = SvIV((SV*)SvRV(ST(0))); IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(struct_HateList *,tmp); THIS = INT2PTR(struct_HateList *, tmp);
} } else
else
Perl_croak(aTHX_ "THIS is not of type tHateEntry"); Perl_croak(aTHX_ "THIS is not of type tHateEntry");
if(THIS == nullptr) if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->hatelist_damage; RETVAL = THIS->hatelist_damage;
XSprePUSH; PUSHi((IV)RETVAL); XSprePUSH;
PUSHi((IV) RETVAL);
} }
XSRETURN(1); XSRETURN(1);
} }
@ -116,20 +114,19 @@ extern "C"
#endif #endif
XS(boot_HateEntry); XS(boot_HateEntry);
XS(boot_HateEntry) XS(boot_HateEntry) {
{
dXSARGS; dXSARGS;
char file[256]; char file[256];
strncpy(file, __FILE__, 256); strncpy(file, __FILE__, 256);
file[255] = 0; file[255] = 0;
if(items != 1) if (items != 1)
fprintf(stderr, "boot_quest does not take any arguments."); fprintf(stderr, "boot_quest does not take any arguments.");
char buf[128]; char buf[128];
//add the strcpy stuff to get rid of const warnings.... //add the strcpy stuff to get rid of const warnings....
XS_VERSION_BOOTCHECK ; XS_VERSION_BOOTCHECK;
newXSproto(strcpy(buf, "GetEnt"), XS_HateEntry_GetEnt, file, "$"); newXSproto(strcpy(buf, "GetEnt"), XS_HateEntry_GetEnt, file, "$");
newXSproto(strcpy(buf, "GetDamage"), XS_HateEntry_GetDamage, file, "$"); newXSproto(strcpy(buf, "GetDamage"), XS_HateEntry_GetDamage, file, "$");