Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Class joining bug/undocumented feature (https://forums.graalonline.com/forums/showthread.php?t=81128)

WhiteDragon 08-09-2008 02:14 AM

Class joining bug/undocumented feature
 
This is the code I am executing:

-whitedragon_system
PHP Code:

new TStaticVar("Movement").join("whitedragon_system_movement");
new 
Movement("NormalMovement").join("whitedragon_system_movement_normal");
this.movement = new NormalMovement().construct(); 

whitedragon_system_movement
PHP Code:

public function construct() {
  echo(
"----------");
  echo(
this.joinedclasses);
  echo(
this.getfunctions());
  for(
this.getfunctions())
    echo(
f SPC f.scope);
  echo(
"----------");
  return 
this;


whitedragon_system_movement_normal
PHP Code:

public function construct() {
  echo(
"movement_normal");
  return 
this;


The code that you see in whitedragon_system_movement is some debugging code to see exactly what functions exist and what is getting over written.

I get the following output:
PHP Code:

----------
whitedragon_system_movement,"",whitedragon_system_movement_normal
loadstring
,geteditvarnames,insertarray,subarray2,addnamedstring,savexmltostring,ignoreevents,loadvarsfromarray,loadini,getdynamicvarnames,savevars,sortdescending,loadvars,loadxml,savelines,cancelevents,getfunctions,copyfrom,getstaticvarnames,sortbyvalue,getvarnames,hasfunction,clearemptyvars,timershow,addarray,leave,loadxmlfromstring,scheduleevent,loadlines,objecttype,settimer,savestring,ignoreevent,loadfolder,addarraymember,destroy,savevarstoarray,join,catchevent,sortascending,getarraymember,trigger,isinclass,savexml,clearvars,construct,construct
loadstring 
public
geteditvarnames public
insertarray public
subarray2 public
addnamedstring public
savexmltostring public
ignoreevents public
loadvarsfromarray public
loadini public
getdynamicvarnames public
savevars public
sortdescending public
loadvars public
loadxml public
savelines public
cancelevents public
getfunctions public
copyfrom public
getstaticvarnames public
sortbyvalue public
getvarnames public
hasfunction public
clearemptyvars public
timershow public
addarray public
leave public
loadxmlfromstring public
scheduleevent public
loadlines public
objecttype public
settimer public
savestring public
ignoreevent public
loadfolder public
addarraymember public
destroy public
savevarstoarray public
join public
catchevent public
sortascending public
getarraymember public
trigger public
isinclass public
savexml public
clearvars public
construct public 

That's handful, so I'll sum it up for you:
  • echo(this.getfunctions()) echos "construct" twice.
  • The loop echos "construct" once.
  • It doesn't finish the block of code (there are no ending dashes echoed).


This behavior is getting so weird, I had no idea what was going on.
Even speculation would be helpful.

Thank you. :D

Inverness 08-09-2008 02:21 AM

Your object creation syntax is horrible, please do it properly just in the interest of eliminating all possibilities in error.

And having two construct echoed is not surprising.
Its possible to do <classname>::<functionname>(); if two classes have same function.

I would highly suggest avoiding situations where functions overwrite like that.

PHP Code:

function thefunction() {
  
temp.var = new TStaticVar("Movement");
  
temp.var.join("whitedragon_system_movement");
  
temp.var = new Movement("NormalMovement");
  
temp.var.join("whitedragon_system_movement_normal");
  
this.movement = new NormalMovement();
  
this.movement.construct();




All times are GMT +2. The time now is 04:55 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.