Thanks Mattias,

I've got it now.

Darius

----- Original Message ----- From: "Mattias Gaertner" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, June 21, 2006 8:42 PM
Subject: Re: [lazarus] CodeTool problem


On Wed, 21 Jun 2006 20:08:07 +0200
"Vincent Snijders" <[EMAIL PROTECTED]> wrote:

2006/6/21, Darius Blaszijk <[EMAIL PROTECTED]>:
>
>
> Ive got a question about codetools.
>
> I have tried to add a method to the folowing code;
>
>
> <<SNIP>>
> unit Unit1;
>
> {$mode objfpc}{$H+}
>
> interface
>
> type
>   Ttest = class(Tobject)
>   private
>
>   public
>     constructor Create;
>   end;
>
> implementation
>
> constructor Ttest.Create;
> begin
> end;
>
> end.
> <<SNAP>>
>
> My test code is the folowing;
>
> <<SNIP>>
>   CodeBuffer:=CodeToolBoss.LoadFile(FileName, false, false);
>
>   ti.Kind := tkMethod;
>   ti.Name := 'name';
>   codetoolboss.CreatePublishedMethod(codebuffer, 'Ttest',
> 'NewMethodName', @ti);
>
>   codebuffer.SaveToFile('test.pas');
> <<SNAP>>
>
> The problem however is that when I execute the code I get an exception
> message like: "unit not found: ObjPas".
>
> Is there a way to prevent the codetool to parse all units in the uses
> clause and simply just stick to the unit provided? Or am I
> misinterpreting the errormessage in some way?

Maybe. ObjPas is added by the compiler, if you use mode objfpc or mode
delphi. Kind of like a second system unit.

Right.
To let the codetools find these units, you must tell them the FPC source
directory. See the codetools examples.

The CreatePublishedMethod method looks up the source definition instead of
the typeinfo for two reasons:
1. historical. fpc 1.0.x didn't store parameter names and all identifiers
were uppercase.
2. fpc stores the base types instead of the source types. For example
'integer' is replaced with 'LongInt', 'string' with 'AnsiString'.

I added a flag to CreatePublishedMethod and an example (addmethod.lpi), so
you can add methods without lookup.


Mattias

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to