Register | Login
Forum Index > Source Help > Pascal plugIn
Author Message
Pages: 1 2
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[485] Pascal plugIn - posted: 2011-11-08 18:27:24

hi

i am start a new Pascal plugin that will understand this function prototype.
Code:
// this is dummy function used for testing purpose
function* SetCursorProperties(XHotSpot, YHotSpot: LongWord; pCursorBitmap: IDirect3DSurface9): HResult; stdcall;         


and here is my first step , it is only find out is that a pascal function or not
Code:
//******************************************************//
//                                                      //
//               Pascal Plugin                          //
//                                                      //
//               By Emil Halim                          //
//               8 / 11 / 2011                          //
//                                                      //
//******************************************************//

plugins off;

program WIN32DLL 'Pas PLUGIN';

#include 'zirplug/framework.zir';
#include 'strings.zir';

//////////////////////////////

const strLoaded = 'Pas plugin has loaded!';

//////////////////////////////
function H_strlen(char* str) {
  Eax = str;
  while(char[eax] != 0) {
    Eax++;
  }
  sub eax, str
}

function  H_strcpy(Dword dst,src)
{ 
  Eax = dst; 
  Edx = src; 
  push Eax;
  BL =  [Edx]; 
  while ( BL != 0)  
   { 
      [Eax] = BL; 
      Eax++; Edx++; 
      BL =  [Edx]; 
   }  
  [Eax] = 0;
  pop Eax;
} 

function H_strcat(Dword dst,src) 
{ 
  Eax = dst; 
  Edx = src;
  push Eax;
  while (byte [Eax] != 0) { Eax++; } 
  while (byte [Edx] != 0)  
   { 
      BL =  [Edx]; 
      [Eax] = BL;  
      Edx++; Eax++; 
   } 
  [Eax] = 0;
  pop Eax;
} 

inline procedure  H_strjoin(;)
{
  $temp = 1;
  $to = $argc - 1;  
  $repeat $to:  
     H_strcat($arg[0],$arg[$temp]);  
  $temp++;
  $end
}

inline procedure Ziron_ExecuteF(m_st)
{
   Ziron_Execute($m_st,H_strlen($m_st));
}

//
// event_Pas()
//
function event_Pas()
{
  uses edi;
  char buf[2048];
  char line[2048];
  char val[255];
  Dword Len;
  boolean ParesFlg;  
        
  len = Ziron_ExtractLine(@line, 2048);  
  //Ziron_ShowMessage(@line);                // show our entire line for debug purpose
  Eax = @line;
  Cl  = char[Eax];
  Edx  = false;
  ParesFlg = false;  
  while( cl != 0)
   {
       if(cl == '(')
        {
          Edx = true;
        }
       if(cl == ')')
        {
          Edx = false;
        } 
       if( Edx == true and cl == ":")
        {
           ParesFlg = true;
        }
       Cl  = char[Eax];
       Eax++;
   }
  
 
  // see if the line have to pares with this plugin
  if(ParesFlg)
   { 
      Ziron_ShowMessage(@line);                // show our entire line for debug purpose
    
      return true;
   }
  else
   {   
      return false;                           // let Ziron handle the line  
   }   
}


function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all
  
  //add some variable type
  const MyType = 'type HResult = DWord;';
        Ziron_Execute(@MyType,H_strlen(@MyType));

  //register our keyword
  Ziron_RegisterKeyword('function', @event_Pas);
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin;


any suggestion ?

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[487] - posted: 2011-11-08 20:55:32
I don't believe i understand the purpose of this one...

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[488] - posted: 2011-11-08 21:03:03
btw.. i also think that consts and types should not be hardcoded in, since they may interfere with inbuilt or users file and types - a better alternative is to supply an additional zir file with the types inside, this allows for flexibility - such as removing or changing some of them..

ps. I began adding some compatibility files such as pascal_compat.zir which contains some of the pascal variable types.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[489] - posted: 2011-11-08 23:29:07

the main purpose of this plugIn is , if you have a pascal header file that contains functions
declaration , you do not have to convert it manually to work with ziron , instead you use
this plugin that make Zrion will understand this header file.

i agree with you , i will remove type from plugin and supply ziron header that contains
the types needed by plugin.

hope you got my point , so what do you think?


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[490] - posted: 2011-11-08 23:42:26
It is an interesting idea, to do this via a plugin, however what would be much better and more efficient is if the plugin converts the header file then outputs/writes the conversion to a ziron header file.

I plan to write a software to convert pascal/c includes to ziron includes at some point smile

but still will be interesting to see this from a plugin aswell, allowing people to more quickly port their pascal programs.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[491] - posted: 2011-11-09 08:13:27

i think , creating converter that will convert pascal/c headers to Ziron header is better if you have a big file.
but plugin is a quick and simple way that let ziron handle the pascal syntax.

the problem i have faced now , i was using ':' in parameter to peek a pascal function , so
suppose that pascal function has no parameter at all. how to peek it ?

one solution is to use #Pas #EndPas directives and put pascal stuff inside them.

so what is your opinion?


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[492] - posted: 2011-11-09 08:38:54

of course the directives will be processed by plugin in FileEntry.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[496] - posted: 2011-11-09 13:31:57
a custom directive would be a good option, else for params you check for token ( - zirOpenParen

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 9 user(s) online. 0 member(s) and 9 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd