add --questitem to perl-doc-parser.pl - format and add usage doc to perl_questitem.cpp

This commit is contained in:
Akkadius 2018-07-01 20:52:56 -05:00
parent 9e03d76211
commit 595138679d
2 changed files with 101 additions and 102 deletions

View File

@ -11,6 +11,7 @@ sub usage() {
print " --object - Prints methods for just object class methods\n";
print " --group - Prints methods for just group class methods\n";
print " --raid - Prints methods for just raid class methods\n";
print " --questitem - Prints methods for just questitem 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";
@ -45,6 +46,8 @@ for my $file (@files) {
}
@methods = ();
$split_key = "";
$object_prefix = "";
#::: Open File
print "\nOpening '" . $file . "'\n";
@ -53,7 +56,7 @@ for my $file (@files) {
chomp;
$line = $_;
if ($line=~/Client::|Mob::|Corpse::|EntityList::|Doors::|Group::|HateEntry::|NPC::|Object::|Raid::/i && $line=~/_croak/i) {
if ($line=~/Perl_croak/i && $line=~/Usa/i && $line=~/::/i) {
#::: Client export
if ($export=~/all|client/i && $line=~/Client::/i) {
@ -115,6 +118,12 @@ for my $file (@files) {
$object_prefix = "\$hate_entry->";
}
#::: Hateentry export
if ($export=~/all|questitem/i && $line=~/QuestItem::/i) {
$split_key = "QuestItem::";
$object_prefix = "\$quest_item->";
}
#::: Split on croak usage
@data = split($split_key, $line);
$usage = trim($data[1]);

View File

@ -18,7 +18,9 @@
#include "../common/features.h"
#include "client.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/global_define.h"
#include "embperl.h"
@ -28,7 +30,7 @@
#include "../common/item_instance.h"
#ifdef THIS /* this macro seems to leak out on some systems */
#ifdef THIS /* this macro seems to leak out on some systems */
#undef THIS
#endif
@ -38,76 +40,73 @@ XS(XS_QuestItem_GetName) {
if (items != 1)
Perl_croak(aTHX_ "Usage: QuestItem::GetName(THIS)");
{
EQEmu::ItemInstance * THIS;
Const_char * RETVAL;
EQEmu::ItemInstance *THIS;
Const_char *RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetItem()->Name;
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
sv_setpv(TARG, RETVAL);
XSprePUSH;
PUSHTARG;
}
XSRETURN(1);
}
XS(XS_QuestItem_SetScale);
XS(XS_QuestItem_SetScale)
{
XS(XS_QuestItem_SetScale) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, scale factor)");
Perl_croak(aTHX_ "Usage: QuestItem::SetScale(THIS, float scale_multiplier)");
{
EQEmu::ItemInstance * THIS;
float Mult;
EQEmu::ItemInstance *THIS;
float Mult;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
Mult = (float)SvNV(ST(1));
Mult = (float) SvNV(ST(1));
if(THIS->IsScaling()) {
THIS->SetExp((int)(Mult*10000+.5));
if (THIS->IsScaling()) {
THIS->SetExp((int) (Mult * 10000 + .5));
}
}
XSRETURN_EMPTY;
}
XS(XS_QuestItem_ItemSay);
XS(XS_QuestItem_ItemSay)
{
XS(XS_QuestItem_ItemSay) {
dXSARGS;
if (items != 2 && items != 3)
Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, text [, language])");
Perl_croak(aTHX_ "Usage: QuestItem::ItemSay(THIS, string text [int language_id])");
{
EQEmu::ItemInstance* THIS;
Const_char* text;
int lang = 0;
EQEmu::ItemInstance *THIS;
Const_char *text;
int lang = 0;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
text = SvPV_nolen(ST(1));
if(items == 3)
lang = (int)SvUV(ST(2));
text = SvPV_nolen(ST(1));
if (items == 3)
lang = (int) SvUV(ST(2));
quest_manager.GetInitiator()->ChannelMessageSend(THIS->GetItem()->Name, 0, 8, lang, 100, text);
}
@ -115,49 +114,45 @@ XS(XS_QuestItem_ItemSay)
}
XS(XS_QuestItem_IsType); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_IsType)
{
XS(XS_QuestItem_IsType) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::IsType(THIS, type)");
{
EQEmu::ItemInstance* THIS;
bool RETVAL;
uint32 type = (int32)SvIV(ST(1));
EQEmu::ItemInstance *THIS;
bool RETVAL;
uint32 type = (int32) SvIV(ST(1));
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->IsType((EQEmu::item::ItemClass)type);
ST(0) = boolSV(RETVAL);
RETVAL = THIS->IsType((EQEmu::item::ItemClass) type);
ST(0) = boolSV(RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_QuestItem_IsAttuned); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_IsAttuned)
{
XS(XS_QuestItem_IsAttuned) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: QuestItem::IsAttuned(THIS)");
{
EQEmu::ItemInstance* THIS;
bool RETVAL;
EQEmu::ItemInstance *THIS;
bool RETVAL;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->IsAttuned();
@ -168,80 +163,76 @@ XS(XS_QuestItem_IsAttuned)
}
XS(XS_QuestItem_GetCharges); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_GetCharges)
{
XS(XS_QuestItem_GetCharges) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: QuestItem::GetCharges(THIS)");
{
EQEmu::ItemInstance* THIS;
int16 RETVAL;
EQEmu::ItemInstance *THIS;
int16 RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetCharges();
XSprePUSH; PUSHi((IV)RETVAL);
XSprePUSH;
PUSHi((IV) RETVAL);
}
XSRETURN(1);
}
XS(XS_QuestItem_GetAugment); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_GetAugment)
{
XS(XS_QuestItem_GetAugment) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: QuestItem::GetAugment(THIS, augment_id)");
Perl_croak(aTHX_ "Usage: QuestItem::GetAugment(THIS, int16 slot_id)");
{
EQEmu::ItemInstance* THIS;
int16 slot_id = (int16)SvIV(ST(1));
EQEmu::ItemInstance* RETVAL;
EQEmu::ItemInstance *THIS;
int16 slot_id = (int16) SvIV(ST(1));
EQEmu::ItemInstance *RETVAL;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetAugment(slot_id);
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "QuestItem", (void*)RETVAL);
sv_setref_pv(ST(0), "QuestItem", (void *) RETVAL);
}
XSRETURN(1);
}
XS(XS_QuestItem_GetID); /* prototype to pass -Wmissing-prototypes */
XS(XS_QuestItem_GetID)
{
XS(XS_QuestItem_GetID) {
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: QuestItem::GetID(THIS)");
{
EQEmu::ItemInstance* THIS;
uint32 RETVAL;
EQEmu::ItemInstance *THIS;
uint32 RETVAL;
dXSTARG;
if (sv_derived_from(ST(0), "QuestItem")) {
IV tmp = SvIV((SV*)SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *,tmp);
}
else
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(EQEmu::ItemInstance *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type EQEmu::ItemInstance");
if(THIS == nullptr)
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
RETVAL = THIS->GetItem()->ID;
XSprePUSH; PUSHi((IV)RETVAL);
XSprePUSH;
PUSHi((IV) RETVAL);
}
XSRETURN(1);
}
@ -251,29 +242,28 @@ extern "C"
#endif
XS(boot_QuestItem);
XS(boot_QuestItem)
{
XS(boot_QuestItem) {
dXSARGS;
char file[256];
strncpy(file, __FILE__, 256);
file[255] = 0;
if(items != 1)
if (items != 1)
fprintf(stderr, "boot_quest does not take any arguments.");
char buf[128];
//add the strcpy stuff to get rid of const warnings....
XS_VERSION_BOOTCHECK ;
XS_VERSION_BOOTCHECK;
newXSproto(strcpy(buf, "GetName"), XS_QuestItem_GetName, file, "$");
newXSproto(strcpy(buf, "SetScale"), XS_QuestItem_SetScale, file, "$");
newXSproto(strcpy(buf, "ItemSay"), XS_QuestItem_ItemSay, file, "$");
newXSproto(strcpy(buf, "IsType"), XS_QuestItem_IsType, file, "$$");
newXSproto(strcpy(buf, "IsAttuned"), XS_QuestItem_IsAttuned, file, "$");
newXSproto(strcpy(buf, "GetCharges"), XS_QuestItem_GetCharges, file, "$");
newXSproto(strcpy(buf, "GetAugment"), XS_QuestItem_GetAugment, file, "$$");
newXSproto(strcpy(buf, "GetID"), XS_QuestItem_GetID, file, "$");
newXSproto(strcpy(buf, "GetName"), XS_QuestItem_GetName, file, "$");
newXSproto(strcpy(buf, "SetScale"), XS_QuestItem_SetScale, file, "$");
newXSproto(strcpy(buf, "ItemSay"), XS_QuestItem_ItemSay, file, "$");
newXSproto(strcpy(buf, "IsType"), XS_QuestItem_IsType, file, "$$");
newXSproto(strcpy(buf, "IsAttuned"), XS_QuestItem_IsAttuned, file, "$");
newXSproto(strcpy(buf, "GetCharges"), XS_QuestItem_GetCharges, file, "$");
newXSproto(strcpy(buf, "GetAugment"), XS_QuestItem_GetAugment, file, "$$");
newXSproto(strcpy(buf, "GetID"), XS_QuestItem_GetID, file, "$");
XSRETURN_YES;
}