NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Reverse engineer PHP extension for code completion?


Joined: 25 Nov 2006
Posts: 3
Reply with quote
Hi,

I'm doing some extensive programming against the MapGuide Open Source Web API. As you can see from the graphical class hierarchy (start from MgObject) this is a fairly large extension:
https://mapguide.osgeo.org/documentation.html

I've read about how to add code completion for the SPL library, and understand that I could do this, but I'm not really all that enthusiastic about manually creating the prototype file for this extension.

Does anyone know how I could generate this kind of prototype automatically from the DLL or the C/C++ source code?

Thanks,
Jason
View user's profileFind all posts by JasonBirchSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
if a library is written in a language other than php, you need to write prototypes yourself or ask library developers for it. I see no other other ways.
Certainly you can create a tool say in shell script or awk or perl and parse C or C++ sources, but it's not easy. I'd recommend you to check how php develerps are parsing php-engine sources for this: http://cvs.php.net/viewvc.cgi/functable/ .It's where you'll see some phpXproto.awk files, they are grepping prototypes.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 25 Nov 2006
Posts: 3
Reply with quote
Thanks.

The library that I'm using has quite a few overloaded methods in it.

Are these supported in PhpED? If I define a function multiple times with different sigantures will each of these signatures show up? I know that this isn't valid PHP... can PhpED parse out functions that have been overloaded using the PHP method of overloading (which appears to be the same way that the c++ coders of this extension did it)?

Jason
View user's profileFind all posts by JasonBirchSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
probably you ask about code completion in PhpED.
Quote:
I know that this isn't valid PHP...

This is a valid php until you try to load (include) modules defining functions with the same name.
Even if you load them at once, you can be safe by checking if function is defined. Ever heard of this?
Look for a sample below:
fileA.php:
Code:
<?php
if (!function_exists('test')) {
    function test($a) {
        echo $a;
    }
}


fileB.php:
Code:
<?php
if (!function_exists('test')) {
    function test($a, $b) {
        echo $a.$b;
    }
}


although it's not a very clean or recommended way, it's supported in PhpED.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 25 Nov 2006
Posts: 3
Reply with quote
dmitri wrote:
although it's not a very clean or recommended way, it's supported in PhpED.


Does PhpED actually parse the prototype files using PHP? I'm not worried about PHP parsing the files, I'm worried about PhpED parsing the files for code completion.

So... if I do something like this, will PhpED identify the multiple overloads for code completion?

Code:
if (1=0) {


  function test($a) {
        echo $a;
  }

  function test($a, $b) {
        echo $a . $b;
  }


}


If not, it would be great if PhpED had some way of parsing an external (XML?) file instead of php files for class, method, property definitions.

Jason
View user's profileFind all posts by JasonBirchSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
I'm not sure what you're trying to accomplish.
In order to parse an XML file, I'd recommend you to consider a way of transforming that XML into another format using XSLT or similar techniques available out there.
PhpED has nothing to do with XMLs (at least at the moment)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
I think he means that it would be cool if phpED would be able to get it's autocompletion info for such an extension from an extra file in XML format
View user's profileFind all posts by BlizzSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Did you ever try to open any cfg file in phped's directory? Smile
I'd recommend you to try func.cfg (yet it only for functions, not for objects)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Reverse engineer PHP extension for code completion?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic