[fpc-pascal] Generic threadlist

2022-12-30 Thread Andrew Haines via fpc-pascal
Hi, I made a generic threadlist for the unit fgl. I'm wondering what is 
the opinion on stuff like that. Specifically it's T: TObject and not for 
"pointers." I had made both TFPGThreadList and TFPGObjectThreadList and 
I thought afterwards only TFPGThreadList is needed and it should hold 
TObjects.


If I implement both, should the TThreadList in classes be declared as 
Specialize TFPGThreadList? I noticed the fgl unit is not 
included in classes.


What kind of things should be added to fgl if any?

Thanks

Andrew


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-web websocket

2022-12-27 Thread Andrew Haines via fpc-pascal



On 12/27/22 3:39 AM, Michael Van Canneyt via fpc-pascal wrote:



Anyway: I have applied the patch, and added your example with some minor
modifications. Thank you for both !

Michael.
___



Awesome thanks very much!

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-web websocket

2022-12-26 Thread Andrew Haines via fpc-pascal


On 12/26/22 8:48 AM, Michael Van Canneyt via fpc-pascal wrote:



Please make a version of your program that does not use the LCL.
Then I'll test that too.

2 reasons for this request: - I don't have a working version of 
Lazarus with FPC trunk.
- I want to exclude the problems of dealing with the main application 
message loop.



I attached a console version. It uses threads. If this is useful at all 
please feel free to add it to the examples and modify it however you want.


I found the problem. First was the problem of no data being read, which 
you fixed by changing the inheritance. But the second problem is that 
the OutgoingFrameMask value was not being used. In the rfc section 5.2 
it states in the Mask bit explanation that all frames sent from a client 
must be masked. Unfortunately the echo server was not giving a close 
frame with a protocol error which would have been useful.


In the attached patch there are 3 hunks that include the 
OutgoingFrameMask with the payload. The rest of the patch is about 
handling a connection that encounters an error sending data. I added an 
exception and also a flag that ignores the exception and tries to close 
gracefully.


You can compile the console client I sent without applying the patch to 
see how it was failing before. There are default servers to choose from.


Maybe in the client, the constructor should pick a mask at random by 
default since all frames from the client are supposed to be masked 
anyway. Section 5.3 has some strong language about the random mask 
having a strong entropy source. It actually says each frame should have 
a new unique mask so I'm not sure the OutgoingFrameMask property really 
makes sense since the mask is given to the connection only once when the 
connection is created. I doubt most server implementations care about this.


Regards,

Andrew


diff --git a/packages/fcl-web/src/websocket/fpwebsocket.pp b/packages/fcl-web/src/websocket/fpwebsocket.pp
index 8424f6c44f..3b6ecd24be 100644
--- a/packages/fcl-web/src/websocket/fpwebsocket.pp
+++ b/packages/fcl-web/src/websocket/fpwebsocket.pp
@@ -287,7 +287,8 @@   TWSMessage = record
woCloseExplicit, // SeDo Close explicitly, not implicitly.
woIndividualFrames,  // Send frames one by one, do not concatenate.
woSkipUpgradeCheck,  // Skip handshake "Upgrade:" HTTP header cheack.
-   woSkipVersionCheck   // Skip handshake "Sec-WebSocket-Version' HTTP header check.
+   woSkipVersionCheck,  // Skip handshake "Sec-WebSocket-Version' HTTP header check.
+   woSendErrClosesConn  // Don't raise an exception when writing to a broken connection
   );
   TWSOptions = set of TWSOption;
 
@@ -482,6 +483,7 @@   TWSServerTransport = class(TWSTransport)
   SErrServerActive = 'Operation cannot be performed while the websocket connection is active';
   SErrInvalidSizeFlag = 'Invalid size flag: %d';
   SErrInvalidFrameType = 'Invalid frame type flag: %d';
+  SErrWriteReturnedError = 'Write operation returned error: (%d) %s';
 
 function DecodeBytesBase64(const s: string; Strict: boolean = false) : TBytes;
 function EncodeBytesBase64(const aBytes : TBytes) : String;
@@ -1175,7 +1177,7 @@ procedure TWSConnection.Send(aFrameType : TFrameType; aData : TBytes = Nil);
 begin
   if not (aFrameType in [ftClose,ftPing,ftPong]) then
 Raise EWebSocket.CreateFmt(SErrNotSimpleOperation,[Ord(aFrameType)]);
-  aFrame:=FrameClass.Create(aFrameType,True,aData);
+  aFrame:=FrameClass.Create(aFrameType,True,aData, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1532,7 +1534,7 @@ procedure TWSConnection.Send(const AMessage: UTF8string);
   aFrame: TWSFrame;
 
 begin
-  aFrame:=FrameClass.Create(aMessage);
+  aFrame:=FrameClass.Create(aMessage, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1544,7 +1546,7 @@ procedure TWSConnection.Send(const ABytes: TBytes);
 var
   aFrame: TWSFrame;
 begin
-  aFrame:=FrameClass.Create(ftBinary,True,ABytes);
+  aFrame:=FrameClass.Create(ftBinary,True,ABytes, OutgoingFrameMask);
   try
 Send(aFrame);
   finally
@@ -1590,12 +1592,27 @@ procedure TWSConnection.Send(aFrame: TWSFrame);
 
 Var
   Data : TBytes;
+  Res: Integer;
+  ErrMsg: UTF8String;
 
 begin
   if FCloseState=csClosed then
 Raise EWebSocket.Create(SErrCloseAlreadySent);
   Data:=aFrame.AsBytes;
-  Transport.WriteBytes(Data,Length(Data));
+  Res := Transport.WriteBytes(Data,Length(Data));
+  if Res < 0 then
+  begin
+FCloseState:=csClosed;
+ErrMsg := Format(SErrWriteReturnedError, [GetLastOSError, SysErrorMessage(GetLastOSError)]);
+if woSendErrClosesConn in Options then
+begin
+  SetLength(Data, 0);
+  Data.Append(TEncoding.UTF8.GetBytes(UnicodeString(ErrMsg)));
+  DispatchEvent(ftClose, nil, Data);
+end
+else
+  Raise EWebSocket.Create(ErrMsg);
+  end;
   if (aFrame.FrameType=ftClose) then
 begin
 if FCloseState=csNone then
diff --git a

Re: [fpc-pascal] fcl-web websocket

2022-12-26 Thread Andrew Haines via fpc-pascal



On 12/26/22 8:02 AM, Michael Van Canneyt via fpc-pascal wrote:


I fixed the -p/--port option.

I could reproduce the broken behaviour in the fcl-web example.

As I thought, a change in the fcl-net ssockets unit is the cause of the
behaviour. I fixed it.

Please check if your example now also works ?

Michael.



I tested the client/server example and they are working now. My echo 
test program still sends but does not receive.



Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fcl-web websocket

2022-12-25 Thread Andrew Haines via fpc-pascal


On 12/25/22 6:06 PM, Michael Van Canneyt via fpc-pascal wrote:


Does the sample chat client/program work for you ?

See below


When I have a moment, I'll look at your test program.


Thank you



Michael.




I'm not sure, maybe. It seems like the clients are not receiving 
messages. Also, using strace I realized the server ignores the port and 
uses 6060. I tried with and without threading.


./server/wsserver -p 8080 -t pool
Received message: { "from" : "client1", "msg" : "Hello, this is a 
friendly greeting message from the client", "to" : "client1" }
Received message: { "from" : "client2", "msg" : "Hello, this is a 
friendly greeting message from the client", "to" : "client2" }
Received message: { "from" : "client2", "msg" : "Hello to 1", "to" : 
"client1" }


Received message: { "from" : "client1", "msg" : "I didn't hear anything. 
Are you there?", "to" : "client2" }


Connection 1 disappeared
Connection 1 disappeared
Connection 2 disappeared
Connection 2 disappeared


./client/wsclient -u ws://localhost:6060/  -a client2
Enter message or command (/stop /help), empty message will just check 
for incoming messages

client2> Hello to 1
Recipient> client1
client2>

client2> /quit


./client/wsclient -u ws://localhost:6060/ -p -a client1
Enter message or command (/stop /help), empty message will just check 
for incoming messages

client1>
client1> I didn't hear anything. Are you there?
Recipient> client2
client1>
client1> /quit

State   Recv-Q Send-Q Local 
Address:Port    Peer Address:Port Process
ESTAB   176 0 127.0.0.1:36486 127.0.0.1:6060 
users:(("wsclient",pid=1026336,fd=3))
ESTAB   204 0 127.0.0.1:36502 127.0.0.1:6060 
users:(("wsclient",pid=1026342,fd=3))


Andrew

PS Here is the strace from a client without sending messages, but 
pressing the 'enter' key once..


socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
getsockopt(3, SOL_SOCKET, SO_RCVTIMEO_OLD, 
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", [16]) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(6060), 
sin_addr=inet_addr("127.0.0.1")}, 16) = 0

sendto(3, "GET / HTTP/1.1\r\n", 16, MSG_NOSIGNAL, NULL, 0) = 16
sendto(3, "Host: localhost:6060\r\n", 22, MSG_NOSIGNAL, NULL, 0) = 22
sendto(3, "Upgrade: websocket\r\n", 20, MSG_NOSIGNAL, NULL, 0) = 20
sendto(3, "Connection: Upgrade\r\n", 21, MSG_NOSIGNAL, NULL, 0) = 21
sendto(3, "Origin: localhost\r\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
sendto(3, "Sec-WebSocket-Key: 3pqrw1xgwqSel"..., 45, MSG_NOSIGNAL, NULL, 
0) = 45

sendto(3, "Sec-WebSocket-Version: 13\r\n", 27, MSG_NOSIGNAL, NULL, 0) = 27
sendto(3, "\r\n", 2, MSG_NOSIGNAL, NULL, 0) = 2
recvfrom(3, "H", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "T", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "T", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "P", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "/", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, ".", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "0", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "1", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "S", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "w", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "i", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "t", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "c", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "h", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "i", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "n", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "g", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "P", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "t", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "c", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "o", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "l", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "s", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "\r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "\n", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "U", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "p", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "g", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "r", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "a", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "d", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "e", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, ":", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, " ", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "w", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "e", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "b", 1, MSG_NOSIGNAL, NULL, NULL) = 1
recvfrom(3, "s", 1, M

[fpc-pascal] fcl-web websocket

2022-12-24 Thread Andrew Haines via fpc-pascal

Hi,

I am trying to test the websocket client in fcl-web by making a simple 
echo client. I have been unable to make it work using fpc trunk on 
linux64. I also crosscompiled to win64 and ran it on wine with identical 
results. The project is attached here if anyone can give some hints.


I am testing it with a server I found here 
https://github.com/vi/wsmirror (written in rust) but also I tried it 
with some public echo servers. There is a html/javascript websocket 
example also for testing it which is working.


I have no real guesses as to the problem. I modified the server that the 
client connects to enough to know when it receives messages and what 
kind. The server never identifies a proper message after the connection 
handshake is completed. It gets something but it doesn't identify it as 
a text message or ping or close etc. The server is dropping the 
connection after a few seconds with ss -t dport = 8080 giving this:


State Recv-Q Send-Q Local Address:Port

CLOSE-WAIT    5 0    127.0.0.1:47828

I believe those are several ping packets the server is sending that the 
client doesn't read.


One thing the websocket is doing is disabling MSG_SIGNAL so that when 
the pipe is broken it doesn't show an exception. However the component 
doesn't check for this and doesn't send the disconnect event.


I have made my own websocket component in the past which is working but 
I wanted to try the one included with fpc.


I'm really baffled, I spent a long time to try and find what is wrong, 
even putting debug code in the underlying socket components. And 
verifying that the websocket frames are correct.


An oddity I noted is that TInetSocket.CanRead seems to always return 
false if it's used as a client. I may not have understood that fully.


Regards,

Andrew Haines
<>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-23 Thread Andrew Haines via fpc-pascal


On 12/23/22 5:24 AM, Ondrej Pokorny via fpc-pascal wrote:

This may be simpler:

[TEnumAttr(['YES', 'NO', 'COULD_BE'])]
  TMyEnum = (meYes, meNo, meCouldBe);

TEnumAttr = class(TCustomAttribute)
  protected
    FValues: TStringArray;
    FTypeName: String;
  public
    class function FromType(ATypeInfo: PTypeInfo): TEnumAttr;
    constructor Create(Values: array of string);

---



I tried that first but the compiler gave an error on the "["

Error: Ordinal expression expected

[TEnumAttr(['YES', 'NO', 'COULD_BE'])]



Or, if the enum values are valid identifiers, you can simple use 
scoped enums:


{$SCOPEDENUMS ON}
  TMyEnum = (YES, NO, COULD_BE);

and the usual TypeInfo methods.

Ondrej



I didn't know about those, that could also be a good solution, thanks!

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal

So, I came up with a solution using Custom Attributes.

I can declare this:

[TEnumAttr('YES', 'NO', 'COULD_BE')]
  TMyEnum = (meYes, meNo, meCouldBe);

and at runtime look for the TEnumAttr attribute and use that.


TEnumAttr = class(TCustomAttribute)
  protected
    FValues: TStringArray;
    FTypeName: String;
  public
    class function FromType(ATypeInfo: PTypeInfo): TEnumAttr;
    constructor Create(Val1: String);
    constructor Create(Val1, Val2: String);

etc

Maybe this can help someone else with a similar use case.


Regards,

Andrew Haines

On 12/22/22 8:40 PM, Andrew Haines via fpc-pascal wrote:
Hi what I want to do is similar to this question here: 
https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/


I am going to create multiple type helpers for enums and I would like 
to look up the helper and use common methods AsString AsOrdinal to 
get/set the values. I am recieving them as json that I dont have 
control over. I am using typeinfo to fill in all the properties but I 
would like to convert the strings I am receiving to the enum values 
semi-automatically.


LString := 'STATUS';

LHelper := GetHelper(LPropInfo^.PropType); // enum proptype

LToStringInterface := LHelper as IToStringInterface;

SetOrdProp(LObject, 'propname', LToStringInterface.OrdValue(LString);


Something like that. I'm not sure if it's even possible to find the 
helper type with typeinfo.


Thanks for your suggestions :)

Regards,

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Unrelated type helpers with the same members? Implement an interface with a type helper?

2022-12-22 Thread Andrew Haines via fpc-pascal
Hi what I want to do is similar to this question here: 
https://en.delphipraxis.net/topic/423-rtti-determine-record-helper-type-for-a-base-type/


I am going to create multiple type helpers for enums and I would like to 
look up the helper and use common methods AsString AsOrdinal to get/set 
the values. I am recieving them as json that I dont have control over. I 
am using typeinfo to fill in all the properties but I would like to 
convert the strings I am receiving to the enum values semi-automatically.


LString := 'STATUS';

LHelper := GetHelper(LPropInfo^.PropType); // enum proptype

LToStringInterface := LHelper as IToStringInterface;

SetOrdProp(LObject, 'propname', LToStringInterface.OrdValue(LString);


Something like that. I'm not sure if it's even possible to find the 
helper type with typeinfo.


Thanks for your suggestions :)

Regards,

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Type helper for JNI pointers

2018-08-22 Thread Andrew Haines via fpc-pascal



On 08/12/2018 07:42 AM, Benito van der Zander wrote:



But this does not work, because fpc thinks jclass and jobject are the 
same type, so there is only one type helper for both of the types allowed.


Because it is declared as

type
 jobject=pointer;
 jclass=jobject;


What can we do about this?


I haven't used type helpers but why not change to defines like

type
  jObjectRec = record end;
  jObject= ^jObjectRec;
  jClassRec = record end;
  jClass = ^jClassRec;

or possibly simpler you could try
  jclass = type(jobject); // I believe this forces a new type and is 
not just an alias


Regards,

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] SVN RSS

2017-07-25 Thread Andrew Haines via fpc-pascal

On 07/25/2017 01:39 PM, José Mejuto wrote:

El 25/07/2017 a las 8:33, Michael Van Canneyt escribió:

Is it possible that the SVN RSS is stuck at day 21 ?
https://svn.freepascal.org/feeds/fpcsvn.rss


Yes. The post-commit script that creates the feed has been disabled 
due to time-out problems.




Hello,

Will it be re-enabled ?




If you only want to see commits in a feed you can use this link to the 
unofficial github mirror:


https://github.com/graemeg/freepascal/commits/master.atom

It's synced every 15 minutes.

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Get value of PPChar ?

2017-04-16 Thread Andrew Haines via fpc-pascal

On 04/16/2017 10:58 AM, fredvs wrote:

K, the function seems to work because the result = 0 (no error).

But how to retrieve the data icy_meta (PPChar) ?

var
theicytag : PPChar;
resu : integer;
...

resu := mpg123_icy(ahandle, theicytag);
if resu = 0 then writeln(theicytag^); --> raise exception + crash

resu := mpg123_icy(ahandle, theicytag);
if resu = 0 then writeln(theicytag^^); --> also raise exception + crash


You haven't checked if theicytag is nil. The call to mpg123_icy may 
succeed but still the tag may be nil.


resu := mpg123_icy(ahandle, theicytag);
if (resu = 0) and Assigned(theicytag) and Assigned(theicytag^)
then writeln(theicytag^);

Regards,

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] SpVoice.GetVoices returned exception class EOleSysError

2017-04-11 Thread Andrew Haines via fpc-pascal

On 04/10/2017 02:58 AM, misabov wrote:

The project has generated an exception class EOleSysError with a message:
 ?? ?? ??.

uses
...,ComObj;

var
SpVoice: Variant;

SpVoice := CreateOleObject('SAPI.SpVoice');
SpVoice.Voice:= SpVoice.GetVoices('','').Item(0);

SpVoice GetVoices method (SAPI 5.3) cannot return  a selection of voices
available to the voice.


A long time ago I played with MS sapi. I will try to put the relevant 
code here for you. My goal was to put the output speech into memory to 
be processed further.  I think I used the fpc tool importtl to generate 
the  Speechlib_tlb unit. But its been a long time now. I can email you 
directly the file if you want.


Regards,

Andrew Haines

uses
   OleServer, ComObj, Speechlib_tlb, Windows, Variants,  ActiveX, ...

var
  SpeechVoice: ISpeechVoice;
  Voice: TSpVoice;
  Voices: ISpeechObjectTokens;
  ToSpeak: OleVariant;
  i: Integer;
  VoiceList: TStringList;
begin
  CoInitialize(nil);
  Voice := TSpVoice.Create(self);
  CoCreateInstance(CLASS_SpVoice, nil, CLSCTX_ALL, IID_ISpeechVoice, 
SpeechVoice);

  Voice.ConnectTo(SpeechVoice);
  Voices := Voice.GetVoices('','');
  VoiceList := TStringList.Create;
  for i := 0 to Voices.Get_Count -1 do
VoiceList.AddObject(Voices.Item(I).GetDescription(0), 
TObject(Voices.Item(I)));
  Voice.Voice := ISpeechObjectToken(Pointer(VoiceList.Objects[0])); // 
0 is the index of the desired voice.

  // VoiceList.Strings[x] is a text description of the voice

  ToSpeak := 'Hello MS SAPI';
  Voice.speak(ToSpeak, SVSFDefault);

  // cleanup
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to use pipes ?

2017-02-01 Thread Andrew Haines

On 02/01/2017 08:52 AM, fredvs wrote:

Hello.

Some more explanation.

With that code, only +- 10 loops are working, after, no more Ouframes... why
?


Where is it stopping? It may be that you are asking for more bytes than 
are available and it is blocking waiting for more data. Or the opposite 
could be true. You are blocking processing data but the buffer from the 
kernel is full. On many Linux pc's the kernel buffer size is 65536 bytes.


Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interface performance

2016-11-12 Thread Andrew Haines

On 11/11/2016 10:14 PM, Ryan Joseph wrote:

Arr := TArray.Create;
Obj := ObjInt.GetObject;
Arr.AddObject(Obj);

[do some stuff]

// here the problems start because TArray always returns TObject
// and I can’t cast TObject to IMyInterface even though the object
// stored in the array does in fact implement IMyInterface

ObjInt := IMyInterface(Arr.GetObject(0)); // error! but I need to get a 
reference to IMyInterface from the array

// I have to use “as” or Supports here and it defeats the purpose
ObjInt := Arr.GetObject(0) as IMyInterface;


 You have two options if you have a list of TObject.

1.  (Arr.GetObject(n) as IMyInterface).DoSomething;

2.  TMyObjectClass(Arr.GetObject(n)).DoSomething;

2 is kind of pointless because the interface is not being used so why 
have it.


Probably it is better to keep a list of IMyInterface rather than TObject.


I made a small test and uploaded it to github if you want to check it 
out. It uses a list of IMyInterface.


https://github.com/andrewd207/interfacetest

Or as a zip:

https://github.com/andrewd207/interfacetest/archive/master.zip


Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] picture preview

2016-11-08 Thread Andrew Haines

On 11/08/2016 01:51 PM, Marc Santhoff wrote:

Hi,

if I want load a bitmap picture for extracting a small preview of it,
what component or library would be best?

My goal is to use pascal only without any external lirbraries if
possible. Second goal is to keep the program small, ideally avoiding to
link lcl controls in.

Bitmap picture may be anything commen, JPEG, PNG, GIF, BMP, etc.

TIA,
Marc



Hi I attached a small program I just wrote that resizes an image and 
saves it to a file. I didn't test it but it compiles. It uses just the 
png reader/writer components but there are several units for different 
image formats.


FPReadPNG, FPWritePNG
FPReadBMP, FPWriteBMP etc.

Regards,

Andrew Haines
program imageresize;
{$mode objfpc}
uses
  Classes, FPimage, FPImgCanv, FPCanvas, FPReadPNG, FPWritePNG;


function ResizeImage(ASrcImage: TFPCustomImage; ANewWidth, ANewHeight: 
Integer): TFPCustomImage;
var
  Canvas: TFPImageCanvas;
begin
  Result := TFPMemoryImage.Create(ANewWidth, ANewHeight);
  Canvas := TFPImageCanvas.Create(Result);

  Canvas.StretchDraw(0,0, ANewWidth, ANewHeight, ASrcImage);
  Canvas.Free;
end;

function ReadImage(AFileName: String) : TFPCustomImage;
var
  Stream: TMemoryStream;
  Reader: TFPReaderPNG;
begin
  Result := nil;
  Stream := TMemoryStream.Create;
  try
Stream.LoadFromFile(AFileName);
Stream.Seek(0, soBeginning);

// I assume png for this example
Reader := TFPReaderPNG.Create;

Result := Reader.ImageRead(Stream, nil);
  finally
Stream.Free;
Reader.Free;
  end;
end;

procedure SaveImage(AImage: TFPCustomImage; AFileName: String);
var
  Writer: TFPWriterPNG;
  F: TFileStream;
begin
  F := TFileStream.Create(AFileName, fmCreate or fmOpenReadWrite);
  try
Writer := TFPWriterPNG.Create;
Writer.ImageWrite(F, AImage);
  finally
Writer.Free;
F.Free;
  end;
end;

var
  OrigImage,
  NewImage: TFPCustomImage;
begin
  if ParamCount < 2 then
  begin
WriteLn('usage:');
WriteLn('   imageresize input.png output.png');
  end;

  OrigImage := ReadImage(ParamStr(1));
  NewImage  := ResizeImage(OrigImage, 50, 50);

  SaveImage(NewImage, ParamStr(2));

  OrigImage.Free;
  NewImage.Free;
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How to sent totally custom parameters to the linker ?

2016-09-05 Thread Andrew Haines

On 09/05/2016 07:27 PM, fredvs wrote:

Hello.

Is it possible to sent new-other parameters to the linker ?
Without the use of *-k*, fpc sent this to the linker:

[5.227] (9017) Using util /usr/bin/ld
[5.227] Executing "/usr/bin/ld" with command line "-b elf64-x86-64 -m
elf_x86_64  --dynamic-linker=/lib64/ld-linux-x86-6
4.so.2   -s -L. -o ./test ./link.res"

Using the *-k* parameter, this is sent (with *-ksomething -kotherting*):

[5.224] (9017) Using util /usr/bin/ld
[5.224] Executing "/usr/bin/ld" with command line "-b elf64-x86-64 -m
elf_x86_64  *something* *otherthing* --dynamic-linker=
/lib64/ld-linux-x86-64.so.2   -s -L. -o ./test ./link.res"

You may see that the parameters "something" "otherthing" are inserted
afterelf_x86_64.

But how to sent totally custom parameters, without those given by fpc ?




If you use -s the compiler will not link your program but leave a script 
"ppas.sh" that you can edit and run manually to assemble and link your 
program. Also it leaves a link.res file that if you really want to you 
can edit.


Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is fpc finding link directories?

2015-12-11 Thread Andrew Haines

On 12/11/2015 09:50 AM, Anthony Walter wrote:
I am having a problem with fpc picking up linking directories on my 
Raspberry Pi.


I have a this lib:

/opt/vc/lib/libGLESv2.so




I get this linker error during compile:

/usr/lib/ld: cannot lind -lGLESv2

But when I compile adding -Fl/opt/vc/lib the compile works without 
error, What's the deal? Why am I getting the ld error when when 
"/opt/vc/lib" is clearly in my linking path?




edit fpc.cfg and add the line
-Fl/opt/vc/lib

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Getting build ID

2015-10-25 Thread Andrew Haines

On 10/25/2015 03:25 PM, Mark Morgan Lloyd wrote:

Mark Morgan Lloyd wrote:

Andrew Haines wrote:

On 10/22/2015 08:08 PM, Mark Morgan Lloyd wrote:
If a program is linked with GNU ld using the --build-id option, how 
can it retrieve the value at runtime?


I've never done it but maybe a place to start is use the elfreader 
unit in fcl-res to open ParamStr(0) and read the data from the 
.note.gnu.build-id section.


Thanks, I'll take a look. I'm looking for something that I can put as 
a "magic number" at the bottom of some shared memory, and the 
build-id is ideal since it can be set to a fixed value during debugging.


If I'm reading things properly I have to reimplement 
TElfResourceReader.Load so I can get a subreader, call the FindSection 
method to get a section index, then do something... I've not worked 
this out yet and would appreciate any hints... to convert the section 
index into an address/length in the file and read the data.


OK, I looked a bit closer at that unit and I don't think you can use it 
since it's only interested in reading resource information. The 
subreaders are more interesting but they are private classes that we 
have no access to.


I had some time and this was interesting so I made a really basic unit 
and test program to read the build id of an elf file. It's not complete 
but it can read 64 bit elf files. If you need 32 it would be easy to 
add. You may use the source however you want.


Regards,

Andrew Haines


elf_build_id.tar.gz
Description: application/gzip
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Getting build ID

2015-10-24 Thread Andrew Haines

On 10/22/2015 08:08 PM, Mark Morgan Lloyd wrote:
If a program is linked with GNU ld using the --build-id option, how 
can it retrieve the value at runtime?


I've never done it but maybe a place to start is use the elfreader unit 
in fcl-res to open ParamStr(0) and read the data from the 
.note.gnu.build-id section.


Regards,

Andrew Haines

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] STM32F407?

2015-10-12 Thread Andrew Haines
It is the discovery board.

Andrew

On October 12, 2015 2:49:37 AM EDT, Michael Ring  wrote:
>STM32F407 and STM32F429 share the same reference Manual so they should 
>be highly compatible. Which Board do you own, a Discovery board or  
>MicroE Board?
>
>Michael
>
>Am 12.10.15 um 03:31 schrieb Andrew Haines:
>> Hi,
>>
>> I've seen on the list that the STM32F429 has some support in fpc now!
>>
>> A couple of years ago I got a STM32F407 discovery board. Is the code 
>> for *29 compatible with *07?
>>
>> Regards,
>>
>> Andrew Haines
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
>___
>fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] STM32F407?

2015-10-11 Thread Andrew Haines

Hi,

I've seen on the list that the STM32F429 has some support in fpc now!

A couple of years ago I got a STM32F407 discovery board. Is the code for 
*29 compatible with *07?


Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] File Descriptor in Windows ?

2015-03-25 Thread Andrew Haines

On 03/25/2015 08:23 AM, fredvs wrote:

Hello.

Sorry to sorry to bother you with that file descriptors again... ;-(

There are some answers there on mpg123 forum.
They explain that "simple stdin/stdout file descriptors would work."
Of course all what they explained is in C ;-(

OK, but how can i use "simple stdin/stdout file descriptors" in Pascal ?
What is the code to retrieve that stdin/stdout file descriptors in Windows?

Many thanks.

Fre;D





I've been thinking that for your purposes you could use
mpg123_replace_reader_handle
http://www.mpg123.de/api/group__mpg123__lowio.shtml#ga61a125c56f2aab9590a4b1a29194dc10

and
mpg123_open_handle
http://www.mpg123.de/api/group__mpg123__input.shtml#gaadda450ea307f88589cb77ffda0754ab

Then you could do
mpg123_open_handle(mpg, Output); //Output is a TStream descendant

and the functions you supply with mpg123_replace_reader_handle can just 
read directly from the TStream. Then you don't have to rely on anything 
on each OS other than some TStream descendant can read the file you want 
to play.


Andrew

PS I noticed these functions don't exist yet in your mpg123 bindings.
 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Helpers for objects (not classes)

2015-03-23 Thread Andrew Haines

Hi,

Do the new class helpers support objects?

If this is not implemented how much work (1-10) is it to do?

Thanks,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] File Descriptor in Windows ?

2015-03-21 Thread Andrew Haines
Check for writeln's in the htmlthread unit you added.

On March 21, 2015 6:23:44 PM EDT, fredvs  wrote:
>> What do you do with the inHandle ?
>> Michael. 
>
>It is used by mp123 mp3-decoder library.
>
>=>function mpg123_open_fd(mph: Tmpg123_handle; fd: integer);
>
>fp (file descriptor) := InHandle ;
>
>It seems that InHandle as file descriptor does not work on Windows.
>But in *nix system, it works.
>
>
>
>
>
>-
>Many thanks ;-)
>--
>View this message in context:
>http://free-pascal-general.1045716.n5.nabble.com/File-Descriptor-in-Windows-tp5721448p5721454.html
>Sent from the Free Pascal - General mailing list archive at Nabble.com.
>___
>fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Internet audio streaming ?

2015-03-19 Thread Andrew Haines

On 03/19/2015 09:26 AM, fredvs wrote:

PS:Andrew has done a excellent work with his PulseAudio wrapper =>
https://github.com/andrewd207/fpc-pulseaudio


Only the pulse simple bindings are complete. I'm ~70% done the full 
pulse bindings.


Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] License terms for FastHTMLParser

2015-03-09 Thread Andrew Haines

On 03/08/2015 11:23 AM, Christo wrote:

While reading up on the history of FastHTMLParser (to find out who/where
the root owner of this unit is) I noticed that the last release (0.4)
from Jazarsoft
(http://web.archive.org/web/20050112010608/http://www.jazarsoft.com/download/fasthtmlparser-0.4-delphi.zip)
 has a permissive license, while the file in the FPC source tree has the GPL 
pasted at the top.  I also see that Andrew Haines is listed as the copyright 
holder in the FPC source, while the original file listed Jazarsoft.  I know 
Andrew developed the chm support in FPC/Lazarus, but it seems as if he isn't 
the original author of this unit.

I think the original license & copyright should be restored for this
unit, any comments?

Best wishes,
Christo

I probably pasted the license by mistake when I was adding it to the 
rest of the files. I submitted a bug report that removes it.


Regards,

Andrew Haines


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Is there a CSS parser in FPC?

2015-03-05 Thread Andrew Haines

On 03/03/2015 07:41 AM, Graeme Geldenhuys wrote:

Hi,

As the subject says, I would like to know if there is a CSS parser
included with FPC (2.6.4 or Trunk)? No issue if there isn't, as I might
not initially need one for the project I want to start - but looking
around in the mean time wouldn't hurt.

I'm thinking of writing a couple of articles documenting a pet project I
have been meaning to do for some time. Writing a "toy" web browser
engine. I don't think many people actually know what is involved in a
browser engine, or the rendering pipeline. So documenting the process
from scratch should be a good learning experience for many (myself
included). I want to initially limit as much dependencies as possible,
and obviously simplify it for the articles, but at the same time make it
so various rasterizers (AggPas, OpenGL, fpGUI Canvas, LCL Canvas, Image
file output etc) can be plugged in for the final output.

What's your thoughts? Who knows, this project might even grow to become
something useful for fpGUI or LCL based apps. But that is far down the
road for now.

Regards,
   - Graeme -

As Michael said the turbopower ipro component has a css parser. It was 
added for lazarus/lhelp and wasn't part of the original ipro component 
so it's mostly separated from ipro.

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/turbopower_ipro/ipcss.inc?view=markup&revision=44873&root=lazarus

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Fast HTML Parser

2014-08-06 Thread Andrew Haines
On 08/06/14 13:50, Marcos Douglas wrote:
> Hi,
>
> Someone knows a fast html parser to use in Pascal code?
>
> I need something like this:
>
> HTML:
> 
> 1
> 2
> 
>
> I need a function/object to give me only the values:
> 1
> 2
>
> Something like:
> S := GetHTMLValues('sel_x');
>
> R

There is the unit fasthtmlparser included with fpc in the packages/chm
folder.

It is pretty basic and just has callbacks for tags and text. I don't
think it's smart enough to tell you of the

name="sel_x" part of your tag. Maybe it can be improved.

Regards,

Andrew Haines

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Fw:

2014-05-08 Thread Andrew Haines
Hey! http://boerbalink.nl/-hi.friend?kusjfib=3171095&ravarydo=969545


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Fw: [5]

2014-05-08 Thread Andrew Haines
Hey! http://netchannel.hu/-hi.friend?odyhunjta=4841446&fitymema=653709


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] c structs and pascal interfaces

2014-01-28 Thread Andrew Haines

On 01/28/2014 12:26 PM, Jonas Maebe wrote:


On 28 Jan 2014, at 18:13, Andrew Haines wrote:


I want to use c "interfaces" exposed as structs in fpc as interfaces. In 
particular I'm converting the OpenSLES header file to fpc.




If they are exposed as structs, you should translate them into records in FPC (with {$packrecords 
c}. The "member functions" are fields that are procedure variables, and you have to 
explicitly include the "self" parameters.

Corba (or other) interfaces are something different and you cannot use them to 
import arbitrary C structs, regardless of whether they contain function 
pointers.



Okay thanks,

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] c structs and pascal interfaces

2014-01-28 Thread Andrew Haines

Hi,

I want to use c "interfaces" exposed as structs in fpc as interfaces. In 
particular I'm converting the OpenSLES header file to fpc.


Here's an example of an exported struct:
struct SLPlayItf_ {
SLresult (*SetPlayState) (
SLPlayItf self,
SLuint32 state
);
SLresult (*GetPlayState) (
SLPlayItf self,
SLuint32 *pState
);
SLresult (*GetDuration) (
SLPlayItf self,
SLmillisecond *pMsec
);
.
};

I'm not very familiar with interfaces but here's what I know. There are 
two types com and corba.


I think I need corba so I don't have the ref and unref procedures.

I would translate this to:
{$INTERFACES corba}
ISLPlatItf = interface
  function SetPlayState(state: SLuint32): SLresult; cdecl;
  function GetPlayState(state: PSLuint32): SLresult; cdecl;
  function GetDuration(msec: PSLmillisecond): SLresult; cdecl;
  ..
end;

So now two questions:

Is corba the interface type I need?

Am I wrong to exclude the self parameter from the interface translation?

Thanks,

Andrew Haines


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: ppcjvm linking jar

2013-04-22 Thread Andrew Haines

On 04/22/13 18:39, Andrew Haines wrote:

On 04/22/13 05:22, leledumbo wrote:

Just create jar file the usual way. However, you'll need to give
FPC-JVM RTL
classes as well (those in org.freepascal namespace)






Alright I've figured it out:

jar cfm trange1.jar manifest.txt trange1.class -C 
/usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/ .


then

java -jar trange1.jar works

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: ppcjvm linking jar

2013-04-22 Thread Andrew Haines

On 04/22/13 05:22, leledumbo wrote:

Just create jar file the usual way. However, you'll need to give FPC-JVM RTL
classes as well (those in org.freepascal namespace)




Ok, I'm not sure of the usual way but here's what I've tried:

andrew@localhost ~/downloads $ jar cf trange1.jar trange1.class 
/usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/.

andrew@localhost ~/downloads $ java -jar ./trange1.jar
Failed to load Main-Class manifest attribute from
./trange1.jar

also

andrew@localhost ~/downloads $ jar cfm trange1.jar manifest.txt 
trange1.class /usr/local/lib/fpc/2.7.1/units/jvm-java/rtl/.

andrew@localhost ~/downloads $ java -jar ./trange1.jar
Exception in thread "main" java.lang.NoClassDefFoundError: 
org/freepascal/rtl/TObject

Caused by: java.lang.ClassNotFoundException: org.freepascal.rtl.TObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: trange1. Program will exit.

where manifest.txt is
Main-Class: trange1

I've played around with MainClass: trange1.class MainClass Main main

Any hints?

Thanks,

Andrew Haines

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] ppcjvm linking jar

2013-04-21 Thread Andrew Haines

Hi,

I am stumped about how to link a program such as the example trange1.pp 
into a jar file.  I've followed the instructions here:

http://wiki.freepascal.org/FPC_JVM

and the command

java -cp /full/path/to/fpcjvm/units/jvm-java/rtl:. trange1

works fine.

But I would like to make it a jar file. How? My google-foo has failed me.

Thanks,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Wiki search broken?

2012-08-27 Thread Andrew Haines

On 08/27/12 00:27, Vincent Snijders wrote:

2012/8/27 Andrew Haines :

Hi,

Search seems to be broken for me on the wiki



What was your search word?

Vincent
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



I typed in the search box on the bottom right on this page:
http://freepascal.org/

"deprecated" no quotes

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Wiki search broken?

2012-08-26 Thread Andrew Haines

Hi,

Search seems to be broken for me on the wiki

"There was a server error processing your request. We apologize.


Take me back where I was (before the error)
Database operation "0or1row" failed (exception NSDB, "Query was not a 
statement returning rows.")


ERROR:  invalid byte sequence for encoding "UTF8": 0xc080
HINT:  This error can also happen if the byte sequence does not match 
the encoding expected by the server, which is controlled by 
"client_encoding".

"

There's a bunch more raw html stuff as well.

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
Ahhh ok I understand now. , Thank you.
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Paul Ishenin  wrote:

07.08.12, 11:24, Andrew Haines wrote:
> What is the current implementation?
>
> I would guess that class vars are stored in the vmt already...

No, class var and regular variable has no difference except the scope. 
It is a static variable which is shared between all instances and 
descendants - so why should it be stored in vmt or near it?

Best regards,
Paul Ishenin

_

fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
On 08/06/12 23:02, Paul Ishenin wrote:

> 
> Class variable is stored the same way as a regular variable and has the
> only difference is that it can be accessible with the class name prefix.
> The thing you need requires different implementation - something like
> storing a virtual class variable in VMT. There is no implementation for
> that.
> 
> Best regards,
> Paul Ishenin

What is the current implementation?

I would guess that class vars are stored in the vmt already...

Please correct me if I've got this wrong.

Current classes have a structure containing partially the following:

TClassInstance = record
vmt: Pointer;
{Space for parent class variables are stored here followed by variables
declared for this object}
variable1: SomeType;
variable2: SomeType;
etc.
end;


TClassVMT = record
  parent_class_vmt: Pointer;
  virtual_procs: array[0..n] of pointer;
  class_var_1: Sometype;
  class_var_2: Sometype;
  etc...
end;

Is this right?

Thanks,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
My current idea for a solution is here:

http://pastebin.com/P3JsDQ03

Can anyone think of something with less code? I guess I could save a
little if I skip the property and directly use GetVMT and SetVMT.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] virtual class var?

2012-08-06 Thread Andrew Haines
Hi, is it possible to have a virtual class variable? I want to have a
pointer available per class that can be a different value.
Something like this:

  TA = class
class var Foo: TObject; virtual;
  end;

  TB = class(TA)
class var Foo: TSpecialObject; override;
  end;
 

I have in mind multiple levels of inheritance. I am storing a vmt like
record/object in the variable, so the variable the child class overrides
will be compatible with the ancestor class. It's possible there may be
many instances of the objects so I do not want to create an variable per
instance if I can help it.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting big-endian signed 16bits values to fpc integer

2012-04-15 Thread Andrew Haines
On 04/15/12 18:38, Giuliano Colla wrote:
> I'm dealing with a large number of data coming from an external device.
> They are big-endian 16 bits signed numbers, which must be converted to
> integer and to real to perform calculations.
> 
> Besides the obvious solutions of treating them as isolated bytes,
> multipying by 256 the highest, adding the lower, and oring wit
> $, or whatever sizeof(Integer) suggests if the result is bigger
> than 32767, is there a more efficient and elegant way to achieve the
> result?
> 
> I'm a bit lost on all available data types, and unable to tell apart the
> ones which are platform specific and the ones which are not, which
> assignments give the proper result and which do not.
> 
> Any suggestion would be greatly appreciated.
> 
> Giuliano Colla
> 
> There exists the BEtoN and LEtoN functions you can use.



There exists the BEtoN and LEtoN functions you can use. (NtoLE and NtoBE
also)

var
  Data: SmallInt; // 16 bit signed type
...
Data := GetBENumberFromWherever;
Data := BEtoN(Data);

I'm not sure about real types. If they are 32 bits and sent in two
pieces then you could just do

var
  Data: Single; // 4 bytes
  DataArray: array[0..1] of Word absolute Data;
...
// I'm not sure how the data is represented in memory for floats.
  DataArray[1] := BEtoN(Word(GetBENumberFromWherever));
  DataArray[0] := BEtoN(Word(GetBENumberFromWherever));


Anyway you get the idea. Probably you will have to experiment to achieve
exactly what you want. Someone else probably has a better answer.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-03-03 Thread Andrew Haines
On 02/23/12 16:23, Mattias Gaertner wrote:

> Now it stops earlier on my files:
> 
> Exception at 00473837: ERangeError:
> Range check error.
> Backtrace does not help much:
> 
> #0  0x004120d0 in fpc_raiseexception ()
> #1  0x0045fc38 in 
> SYSUTILS_$$_RUNERRORTOEXCEPT$LONGINT$POINTER$POINTER ()
> #2  0x in ?? ()
> 
> Mattias

I've just discovered "info symbol x"

Exception at 0053BA25: ERangeError:
Range check error.
[Inferior 1 (process 15556) exited normally]
(gdb) bt
No stack.
(gdb) info symbol 0x53ba25
CHMWRITER$_$TCHMWRITER_$_APPENDBINARYINDEXFROMSITEMAP$TCHMSITEMAP$BOOLEAN_$$_PREPARECURRENTBLOCK
+ 197 in section .text of /usr/local/bin/fpdoc
(gdb)

This at least give me a hint

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-23 Thread Andrew Haines
On 02/22/12 18:01, Mattias Gaertner wrote:

> And I get an exception in:
> #5  0x005552aa in CHILDISFULL (this=0x415906, 
> AWORD=0x409d0c 
> "\311\303f\220H\203\354(H\211\\$\bL\211d$\020L\211l$\030L\211t$ 
> I\211\376I\211\365f\211\323L\211\350H\203", , 
> ANODEOFFSET=8234056) at chmfiftimain.pas:688
> #6  0x005552aa in CHILDISFULL (this=0x7fffdd9a0b40, AWORD=0x0, 
> ANODEOFFSET=3579960) at chmfiftimain.pas:688
> 

I commited some changes in r20412

I fixed a couple range check errors.
Searching now will match the beginning of a word as well.

Andrew


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-23 Thread Andrew Haines
On 02/22/12 18:01, Mattias Gaertner wrote:
> On Wed, 22 Feb 2012 12:06:08 -0500
> I tried with only 500 files and it worked. That means I get a help and
> it finds files. But choosing a page just shows black. And after that
> any page is black.
> Note: If I don't use the search but the Index, then I see the pages.
> 
> I compiled the chm units with -Criot and found various range check
> errors and uninitialized variables which I can fix myself. But then I
> came to a point where don't know what to do:
> 
> chmfiftimain.pas(361,49) Warning: Constructing a class "TLeafNode" with 
> abstract method "ChildIsFull"
> chmfiftimain.pas(72,15) Hint: Found abstract method: 
> TFIftiNode.ChildIsFull(,AnsiString,LongWord);
> 
> And I get an exception in:
> #5  0x005552aa in CHILDISFULL (this=0x415906, 
> AWORD=0x409d0c 
> "\311\303f\220H\203\354(H\211\\$\bL\211d$\020L\211l$\030L\211t$ 
> I\211\376I\211\365f\211\323L\211\350H\203", , 
> ANODEOFFSET=8234056) at chmfiftimain.pas:688
> #6  0x005552aa in CHILDISFULL (this=0x7fffdd9a0b40, AWORD=0x0, 
> ANODEOFFSET=3579960) at chmfiftimain.pas:688
> 
> 

Not sure about this exception but I found an error in TLeafNode.AddWord.
It could possibly cause memory corruption and cause your error

Replace the line

FBlockStream.Write(NewWord[1], Length(Trim(NewWord)));

with

if Length(NewWord) > 0 then
FBlockStream.Write(NewWord[1], Length(Trim(NewWord)));



The same word can exists twice, once for title results and once for body
results. NewWord is the difference between the last word and the new
word. So it's length could be 0.

I compiled a chm using the lcl html docs in a folder. Compiled with
-Criot I am able to build it with a search index with no exceptions.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-22 Thread Andrew Haines
On 02/22/12 18:01, Mattias Gaertner wrote:

> 
> Yes, this helped. 
> Now the files are done in under a minute and with only 500MB. But then
> mem consumption goes up again. Then it goes down to 5GB and seems to
> be stuck in an endless loop. I cancelled it.
> 
> I tried with only 500 files and it worked. That means I get a help and
> it finds files. But choosing a page just shows black. And after that
> any page is black.
> Note: If I don't use the search but the Index, then I see the pages.

In lhelp try commenting chmcontentprovider.pas:1239
TIpChmDataProvider(DataProvider).OnGetHtmlPage:=@LoadingHTMLStream;

This procedure tries to modify the loaded html page to highlight search
terms in red.

> 
> I compiled the chm units with -Criot and found various range check
> errors and uninitialized variables which I can fix myself. But then I
> came to a point where don't know what to do:
> 
> chmfiftimain.pas(361,49) Warning: Constructing a class "TLeafNode" with 
> abstract method "ChildIsFull"
> chmfiftimain.pas(72,15) Hint: Found abstract method: 
> TFIftiNode.ChildIsFull(,AnsiString,LongWord);
> 
> And I get an exception in:
> #5  0x005552aa in CHILDISFULL (this=0x415906, 
> AWORD=0x409d0c 
> "\311\303f\220H\203\354(H\211\\$\bL\211d$\020L\211l$\030L\211t$ 
> I\211\376I\211\365f\211\323L\211\350H\203", , 
> ANODEOFFSET=8234056) at chmfiftimain.pas:688
> #6  0x005552aa in CHILDISFULL (this=0x7fffdd9a0b40, AWORD=0x0, 
> ANODEOFFSET=3579960) at chmfiftimain.pas:688
> 
> 

A parent node is always a TIndexNode so Parent.ChildIsFull =
TIndexNode(Parent).ChildIsFull;

I guess to fix the warning add TLeafNode.ChildIsFull and raise an
exception if it is called, since it shouldn't be.

I notice in #6 that AWord = nil. Afaik that shouldn't be the case.

The entries in TIndexNodes are the last word added to it's child node.

The basic overview is each word is written to a TLeafNode. When the
leafnode is full then it tells it's parent node the last word it wrote
then writes it's data to the final stream and is ready to be filled again.

The index nodes work the same. Every time it is full it tells it's
parent the last word it wrote and writes it's data to the final stream.

there is always one root index node that contains the last word of each
child node below it.

The index nodes only have information to find leaf nodes. The leaf node
has the actual data in it.

Each tier grows exponentially.

So 1 leaf nodes only requires 3 tiers probably (2 index levels and a
leaf level)


IndexNode
IndexNode IndexNode ...
IndexNode IndexNode IndexNode IndexNode...
Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf Leaf 

Anyway I need to think about this more...

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-22 Thread Andrew Haines
On 02/21/12 10:08, Mattias Gaertner wrote:
> 
> Andrew Haines  hat am 21. Februar 2012 um 15:24
> geschrieben:

> 
>> I guess then you are using AddStreamToArchive.
> 
>  
> 
> No. I set 
> 
> Writer.OnGetFileData :=@OnWriterGetFileData;
> And in OnWriterGetFileData I write the html into the stream.
> 


Ok I found a bug here which may affect you or not.

in OnWriterGetFileData make sure you set Stream.Size = 0 before you
write your file to it. It will keep the size of the biggest stream you
have given it to compress otherwise.

Alternatively you could free the stream and then just assign your opened
stream to to the variable.

I really noticed it when it compressed the table of contents of the lcl
(it's > 1mb) and suddenly all the files started taking forever to
compress. This doesn't effect fpdoc since it uses AddStreamToArchive.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-21 Thread Andrew Haines
On 02/21/12 17:40, Mattias Gaertner wrote:
> On Tue, 21 Feb 2012 16:08:43 +0100 (CET)
> Mattias Gaertner  wrote:
> 
>>
>> Andrew Haines  hat am 21. Februar 2012 um 15:24
>> geschrieben:
>> [...]
>>> Your chm file should not be bigger than the the uncompressed files
>>> unless you are writing only
>>> a couple of tiny html files.
>>
>> I have a few thousand html files, about 10k on average.
> 
> Ok, found it. The file extension was wrong.
> Fixing that and testing with 3 pages I get a Search. \O/
> 

:)

> But it only finds whole words. :-
> And clicking on a page gives a black page in lhelp. :(

The whole words is how the words are indexed. It would be fairly easy to
match a partial word against the beginning of an indexed word. Beyond
that if you want to find  "here" in "there" then you would have to dump
the search index and create a second search index -> ugly
> 
> Processing all files required 12 minutes and terrifying 4GB ram. :(
> Then comes some final part and it needed 9GB. I only have 8 so it
> became very slow. :(

"terrifying 4GB ram." :) That made me laugh :)

The memory usage is significantly changed by generating a search index?

> Then it went down to 5GB.
> Finally it crashed with an AV, just like with the LCL chm.
> And I have no chm.
> 
> Maybe some 64bit issue?

I had no crash .

I made an artificial chm file that contained the same file with a
different name 4000 times.

the html file was 13k bytes x 4000 (around 52 mb)

the chm was 2.9 mb

(I enabled LZX_USE_THREADS in chmwriter.pas)

time project1

real10m50.497s
user36m9.276s
sys 0m3.459s


According to top I used ~320mb of memory

I guess my chm does not have enough unique words and this is why the
memory usage is so low.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-21 Thread Andrew Haines

On 02/21/2012 03:18 AM, Mattias Gaertner wrote:

On Mon, 20 Feb 2012 23:59:18 -0500
Andrew Haines  wrote:



30% bigger than the size of the uncompressed html files?!

Yes.


does lazarus/docs/html/build_lcl_docs --outfmt chm work for you?
I get a 8mb lcl.chm file. if --outfmt html then the lcl folder has 74mb 
of html files.


Your chm file should not be bigger than the the uncompressed files 
unless you are writing only

a couple of tiny html files.




I attached the example.chm file that I made a couple of minutes ago
using chmmaker with the project in the example subfolder. Can you see if
it works for you? I opened it in lhelp and the toc, index and search
were all working.
Yes, that has a search. And it works.
I wonder, what you are doing different.





You said in another mail that you are writing the html files from 
memory. (You must have a good memory! ;) I guess then you are using 
AddStreamToArchive. FullTextSearch must be set before this is called 
because the files are scanned as you add them. Also AddStreamToArchive 
has a default parameter Compress: Boolean, are you setting this to false?


PostAddStreamToArchive should only be used inside code called from the 
OnLastFile callback.


Can you send me the non working example.chm?

Thanks


Andrew


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-20 Thread Andrew Haines
On 02/20/12 18:00, Mattias Gaertner wrote:
> Hi,
> 
> I'm using TChmWriter to pack some html files into a chm file.
> The index works. I don't have a TOC.
> Now I want a full text search.
> 
> I set Writer.FullTextSearch to true, it takes a long time to
> process and the resulting chm is 30% bigger than the total of all
> files. So I guess it has created some index.

30% bigger than the size of the uncompressed html files?!

> 
> But in lhelp I don't see a search, only the index.
> 

There was some bug somewhere a while ago where $FIftiMain was
incorrectly searched for as $FiftiMain (i vs I) so maybe make sure lhelp
is a recent build.

> chmmaker can show a search for the example.chm, but can not find
> anything.
> 
>


I attached the example.chm file that I made a couple of minutes ago
using chmmaker with the project in the example subfolder. Can you see if
it works for you? I opened it in lhelp and the toc, index and search
were all working.

Can you PM me the chm(s) that are not working for you? Also what version
of fpc are you using for which platform?

Thanks,

Andrew Haines

P.S. Sorry for the storm of emails


example.chm
Description: application/chm
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-20 Thread Andrew Haines
On 02/20/12 20:51, Andrew Haines wrote:

>>
> 
> I added an lcl program to the ccr in applications/chmmaker that I wrote

Nevermind I had forgotten it's in lazarus/tools anyway.

:)

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-20 Thread Andrew Haines
On 02/20/12 18:00, Mattias Gaertner wrote:
> Hi,
> 
> I'm using TChmWriter to pack some html files into a chm file.
> The index works. I don't have a TOC.
> Now I want a full text search.
> 
> I set Writer.FullTextSearch to true, it takes a long time to
> process and the resulting chm is 30% bigger than the total of all
> files. So I guess it has created some index.
> 
> But in lhelp I don't see a search, only the index.
> 
> chmmaker can show a search for the example.chm, but can not find
> anything.
> 
> Has someone an example how to create a chm file with full text search?
> 
> 
>

I added an lcl program to the ccr in applications/chmmaker that I wrote
when I wrote the chm writing code. I just compiled it and it created a
chm that was searchable.

It's aimed at a help project approach. The help projects it creates can
be compiled with chmcmd as well. (Last I knew)

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How create a full text search with TChmWriter?

2012-02-20 Thread Andrew Haines
On 02/20/12 18:00, Mattias Gaertner wrote:
> Hi,
> 
> I'm using TChmWriter to pack some html files into a chm file.
> The index works. I don't have a TOC.
> Now I want a full text search.
> 
> I set Writer.FullTextSearch to true, it takes a long time to
> process and the resulting chm is 30% bigger than the total of all
> files. So I guess it has created some index.
> 
> But in lhelp I don't see a search, only the index.
> 
> chmmaker can show a search for the example.chm, but can not find
> anything.
> 
> Has someone an example how to create a chm file with full text search?
> 
> 

As far as I know setting FullTextSearch, before you call execute, should
create the search index. Also the files should match "*.ht" to be
included in the search index.

use chmls and see if the file $FIftiMain exists in it. That is the file
that contains the search index.

In fpc/packages/chm/src there is chmfilewriter.pas which chmcmd uses to
create chm's.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] AIX

2012-02-10 Thread Andrew Haines
Hi, can freepascal compile programs for AIX PowerPc? I see hints of AIX
when I search google but nothing that directly says it will work.

Thanks

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] libQT4Pas - Why it is needed?

2012-01-30 Thread Andrew Haines
On 01/30/12 02:19, Graeme Geldenhuys wrote:
> On 29 January 2012 16:31, Jonas Maebe  wrote:
>>
>> GTK offers a plain C interface. QT only offers a C++ interface. FPC does not 
>> (fully) support directly calling external C++ libraries. LibQT4Pas offers a 
>> plain C interface to QT for use by FPC.
>>
> 
> Can one statically bind the LibQt4Pas into a FPC program, thus not
> require to ship an external libqt4pas DLL/SO? If possible, that might
> solve the original posters problem.
> 

It seems to me that you could compile qt4pas.c (or what ever the source
file(s) of libqt4pas.so is) into a qt4pas.o and just link them
statically with {$link qt4pas.o} which then would leave out the
requirement for libqt4pas.so to be distributed with any program using
the qt interface. The gpl? license may or may not make that possible though.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why do string indices start at 1, but array indices start at 0?

2011-10-20 Thread Andrew Haines
On 10/20/11 17:43, Andrew Pennebaker wrote:
> It's inconsistent and ripe for bugs.
> 
> Cheers,
> 
> Andrew Pennebaker
> www.yellosoft.us 
> 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
As far as I know it's historical. String[0] used to contain the string
length (255 max). Now it may be something else.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-08 Thread Andrew Haines
On 09/08/11 19:52, Andrew Haines wrote:

> You can try something like
> oggenc -Q '--output="outputfile.ogg"' "tempfile.wav"
> to see if that works or if you use TProcess directly I understand that
> options have been added recently to overcome the problem quotes can have
> on the arguments.

or consider using -o "outputfile.ogg" which won't have the problem of
begin split to two params since it already is.

> 
> Regards,
> 
> Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-08 Thread Andrew Haines
On 09/08/11 19:40, brian wrote:

> 
> What are the commands?
> 
> mpg321 -q -w "tempfile.wav" "inputfile.mp3"
> 
> oggenc -Q --output="outputfile.ogg" "tempfile.wav"
> 
> It makes no difference whether or not I use a full pathname for mpg321
> and oggenc, and all the other files are in the current working
> directory. Yes, there really are quotes round the filenames, the vast
> majority of the real names have embedded spaces.
> 

I suspect that the oggenc command is failing because TProcess behind the
scenes is splitting --output="outputfile.ogg" into two params.

You can try something like
oggenc -Q '--output="outputfile.ogg"' "tempfile.wav"
to see if that works or if you use TProcess directly I understand that
options have been added recently to overcome the problem quotes can have
on the arguments.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Andrew Haines
On 08/26/11 17:14, Jonas Maebe wrote:
> 
> On 26 Aug 2011, at 22:39, Andrew Haines wrote:
> 
>> Maybe Dispose can call a destructor and that is the difference between
>> Dispose and FreeMem?
> 
> The other difference is that dispose() will finalize any reference counted 
> fields, while freemem won't.
> 
> 

Ok so freemem is okay as long as I am careful about the members of the
object.

Thanks,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] New Dispose and FreeMem and objects

2011-08-26 Thread Andrew Haines
Hi is the following allowed or will it cause problems:

type

PObj = ^TObj;
TObj = object
  constructor Init;
end;

var
 Obj : PObj;
begin
 Obj := new(PObj, Init);
 FreeMem(Obj); // This is the line I wonder about.
end;

I compiled this and it doesn't throw any exceptions.

Should I only use Dispose(Obj) ?

Maybe Dispose can call a destructor and that is the difference between
Dispose and FreeMem?



Thanks,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm

2011-03-10 Thread Andrew Haines
On 03/09/11 14:18, Thomas Schatzl wrote:
> On Wed, 09 Mar 2011 13:23:55 -0500, Andrew Haines wrote:
>> On 03/09/11 12:26, Thomas Schatzl wrote:
>>>
>>> FYL2X calculates the log to the base 2 of tmp, not log to the base e of
>>> tmp? Just a guess.
>>>
>>
>> I originally used log2(Tmp) but switched to ln to check if it was
>> correct. Thanks for noticing that, I changed it back to log2.
>>
>
> 
> Suffixes for gas for floating point are (from
> http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax)
> 
> -s 32 bit/single
> -l 64 bit/double
> -t 80 bit/extended

Thank you this is useful!

> 
> I will write a bug report.


Thank you for writing that bug report.

I finally got the plain pascal version to work properly! My major
problem was I accidentally used the sqr function instead of sqrt. Here's
the final product:


  var
LogBase  : Double;
i: Integer;
Tmp: Double;
  begin
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision]);

LogBase:=1.0/(ln(10)/ln(2));

for i := DataSize-1 downto 0 do
begin
  Tmp := sqrt(sqr(InData[i].Im) + sqr(InData[i].Re));
  if Tmp > 0.0 then
Tmp := (ln(Tmp)/ln(2))*LogBase+Shift
  else
Tmp := 0.0;

  OutData[i] := Tmp;
end;
  end;

In case anyone is interested, this generates 45 lines of assembly. The
handwritten asm code is 40 lines. (not including the procedure pre and
post asm for either method) I cheated a little and copied the log2 code
directly to avoid the function calls, this resulted in the compiler
doing the math ahead of time.

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm

2011-03-09 Thread Andrew Haines
On 03/09/11 12:26, Thomas Schatzl wrote:
> Hi,
> 
> On Wed, 09 Mar 2011 11:58:08 -0500, Andrew Haines wrote:
>>   if Tmp <> Im then
>>   begin
>> //Tmp := ln(Tmp)*LogBase+Shift; // same as the following asm
>> proc?
>> asm
>>   FLD LogBase;
>>   FLD Tmp;
>>   FYL2X;
> 
> FYL2X calculates the log to the base 2 of tmp, not log to the base e of
> tmp? Just a guess.
> 
> Thomas
> 

I originally used log2(Tmp) but switched to ln to check if it was
correct. Thanks for noticing that, I changed it back to log2.

The current output with the pascal code looks like it did when FLDS was
used instead of FLDL to load (%rdi). The intel code was "FLD QWORD[EDI]"
I changed this to "FLDQ (%edi)". on x32 it became FLDL and on x64 it
became FLDS. changing the line to "FLDL (%rdi)" on x86_64 fixed the last
problem I had with the asm translation.

It's all very confusing. Is fldl loading a 32bit floating number? The
variable at (%rdi) is a double. flds makes me think it's loading a single.

Andrew

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm

2011-03-09 Thread Andrew Haines
On 03/08/11 19:58, Andrew Haines wrote:
> Hi,
> 
> I'm trying to convert the following 32bit asm to pascal so it's
> portable. Also to 64bit asm.
> 
> It's from ACS audio component suite.
> 
> What am I doing wrong?
> 

For anyone who's interested I fixed the 64bit assembly version which is
good enough for me but I had hoped to write pascal code for the function.

I converted the intel32 asm to att32 asm which showed my first problem
"FDIVP" on intel becomes "FDIVRP" but on att it stays the same which
causes a different result. Beyond that, there wern't many problems. I
had some fun wondering why the RCX register wasn't a reasonable value
until I realized I was copying 64bits from a 32bit variable.

The following is my result. The 32bit and 64bit asm work but the pascal
still does not. Any suggestions are welcome.

 procedure LgMagnitude(InData : PACSComplex; OutData : PDouble;
DataSize, Shift : Integer);
  {$IFDEF CPUI386}
  var
LogBase  : Double;
  begin
asm
FLD1;
FLDL2T;
FDIVrP;
FSTPQ LogBase;
MOVL DataSize, %ecx;
MOVL OutData, %edi;
MOVL InData, %esi;
  .Ltest:   DEC %ecx
JZ .Lout;
FLDQ (%esi);
FMULQ %ST(0), %ST(0);
ADDL $8, %esi;
FLDQ (%esi);
FMULQ %ST(0), %ST(0);
FADDP;
FSQRTQ;
FTSTQ;
FSTSW %AX;

SAHF;
JE .Lskip;

FLDQ LogBase;
FXCH;
FYL2X;
FIADDL Shift;
FTSTQ;
FSTSW %AX;

SAHF;
JAE .Lskip;

FSTPQ (%edi);
FLDZ;
  .Lskip:
ADDL $8, %esi;
FSTPQ (%edi);
ADDL $8, %edi;
JMP .Ltest;
  .Lout: ;
end;
  end;
  {$ELSE} {$IFDEF CPUX86_64}
  var
LogBase  : Double;
  begin
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision]);
asm
FLD1;
FLDL2T;
FDIVrP;
FSTPQ   LogBase;
MOV DataSize, %ecx;
MOV OutData,  %rdi;
MOV InData,   %rsi;
  .Ltest:   DEC %ecx
JZ .Lout;
FLDL(%rsi);
FMUL%ST(0),   %ST(0);
ADD $8,   %rsi;
FLDL(%rsi);
FMUL%ST(0),   %ST(0);
FADDP;
FSQRT;
FTST;
FSTSW   %AX;

// SAHF is not available on all x86_64 processors so
this is the workaround
bt  $14,  %ax; // // copy fpu C3 flag to cpu
carry flag
JC .Lskip;

FLD LogBase;
FXCH;
FYL2X;
FIADDL  Shift;
FTST;
FSTSW   %AX;

// SAHF is not available on all x86_64 processors so
this is the workaround
bt  $8,%ax // copy fpu C0 flag to cpu carry flag
JNC .Lskip

FSTPL   (%rdi);
FLDZ;
  .Lskip:
ADDL$8,%rsi;
FSTPL   (%rdi);
ADDL$8,%rdi;
JMP .Ltest;
  .Lout: ;
end;
  end;
  {$ELSE}
  {$ERROR LgMagnitude Unimplemented}
  // the following is not correct but was my best effort at pascalizing
the asm code
  var
LogBase  : Double;
i: Integer;
Im, Re: Double;
Tmp: Double;
  begin
asm
  FLD1;
  FLDL2T;
  FDIVRP;
  FSTP LogBase;
end;
for i := 0 to DataSize-1 do
begin
  Im := InData[i].Im*InData[i].Im;
  Re := InData[i].Re*InData[i].Re;
  Tmp := sqr(Im+Re);

  if Tmp <> Im then
  begin
//Tmp := ln(Tmp)*LogBase+Shift; // same as the following asm proc?
asm
  FLD LogBase;
  FLD Tmp;
  FYL2X;
  FIADD Shift;
  FSTP Tmp;
end;
if Tmp <> 0.0 then
begin
  if 0.0 >= Tmp then
  begin
Tmp := 0;
  end;
end;
  end;
  OutData[i] := Tmp;
end;
  end;
  {$ENDIF CPUX86_64}
  {$ENDIF CPUI386}
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Converting 32bit intel asm to Pascal or 64bit at&t asm

2011-03-08 Thread Andrew Haines
Hi,

I'm trying to convert the following 32bit asm to pascal so it's
portable. Also to 64bit asm.

It's from ACS audio component suite.

What am I doing wrong?

I tested my Pascal code with linux 32bit but the output differs from the
32bit asm. In 64bit linux it differs further but this could be from the
ACS indicator component.

I attached screenshots of the various configurations.

I am using fpc 2.5.1 for 32bit and 64bit.

Regards,

Andrew

TACSComplex = record
  Im, Re: Double;
end;




procedure LgMagnitude(InData : PACSComplex; OutData : PDouble; DataSize,
Shift : Integer);
  var
LogBase  : Double;
  begin
asm
FLD1;
FLDL2T;
FDIVP;
FSTP LogBase;
MOV EDX, DataSize;
SHL EDX, 3;
MOV ECX, OutData;
ADD EDX, ECX;
MOV EAX, InData;
  @test:CMP EDX, ECX;
JE @out;
FLD QWORD[EAX];
FMUL ST(0), ST(0);
ADD EAX, 8;
FLD QWORD[EAX];
FMUL ST(0), ST(0);
FADDP;
FSQRT;
FTST;
PUSH EAX;
FSTSW AX;
SAHF;
JE @skip;
FLD LogBase;
FXCH;
FYL2X;
FIADD Shift;
FTST;
FSTSW AX;
SAHF;
JAE @skip;
FSTP QWORD[ECX];
FLDZ;
  @skip:POP EAX;
ADD EAX, 8;
FSTP QWORD[ECX];
ADD ECX, 8;
JMP @test;
  @out: ;
end;
  end;
end;




  var
LogBase  : Double;
i: Integer;
Im, Re: Double;
Tmp: Double;
  begin
asm
  FLD1;
  FLDL2T;
  FDIVP;
  FSTP LogBase;
end;
for i := 0 to DataSize-1 do
begin
  Im := InData[i].Im*InData[i].Im;
  Re := InData[i].Re*InData[i].Re;
  Tmp := sqr(Im+Re);

  if Tmp <> Im then
  begin
//Tmp := log2(Tmp)*LogBase+Shift; // is this the same as the
following asm code?
asm
  FLD LogBase;
  FLD Tmp;
  FYL2X;
  FIADD Shift;
  FSTP Tmp;
end;
if Tmp <> 0.0 then
begin
  if 0.0 >= Tmp then
  begin
Tmp := 0;
  end;
end;
  end;
  OutData[i] := Tmp;
end;
  end;
end;


<64bit asm>
 SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
   exOverflow, exUnderflow, exPrecision]);
asm
FLD1;
FLDL2T;
FDIVP;
FSTP LogBase;
MOV DataSize,  %RDX;
SHL $3,%RDX;
MOV OutData,   %RCX;
ADD %RCX,  %RDX;
MOV InData,%RAX;
MOV Shift, %rsi;
  .Ltest:   CMP %RCX,  %RDX;
JE .Lout;
FLD  (%RAX); //FLD QWORD[%EAX];
FMUL %st(0), %st(0);
ADD $8,%RAX;
FLD (%RAX);//FLD QWORD[EAX]; // sigsegv here with fpu
exceptions off. only happens after many iterations but seems immediate
in real time.
FMUL %st(0), %st(0);
FADDP;
FSQRT;
FTST;
PUSH %RAX;
FSTSW %AX; //with fpu exceptions enabled I get a FPU
exception here after some iterations but again it is immediate in realtime.

//SAHF; // not available in amd64!
//JE .Lskip;
bt $14, %ax; // // copy fpu C3 flag to cpu carry flag
JC .Lskip;

FLD LogBase;
FXCH;
FYL2X;
FIADD Shift;
FTST;
FSTSW %AX;

//SAHF; // not available in amd64!
//JAE .Lskip;
bt $8, %ax // copy fpu C0 flag to cpu carry flag
JNC .Lskip

FSTP (%RCX);//FSTP QWORD[ECX];
FLDZ;
  .Lskip:   POP %RAX;
ADD $8,%RAX;
FSTP (%RCX);//FSTP QWORD[RCX];
ADD $8, %RCX;
JMP .Ltest;
  .Lout: ;
end;
end;

<><><>___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Ansistrings under Android

2011-02-22 Thread Andrew Haines
On 02/22/11 12:06, de_jean_ wrote:
> Now that I have a working fpc crosscompiler for Android, and all the
> code runs ok, I encountered another problem. Namely working with
> ansistrings causes crashes. For example, in a simple test, calling the
> str() routine will cause a crash due to a run-time 216 error (general
> protection fault). I've also noticed that crashes can occur upon routine
> exit, when ansistrings are freed automatically. I thought that using the
> C memory manager (cmem) might help, but there is no difference.
> 
> For some reason, units are not initialized under a android shared
> library, so I call internal_initializeunits() myself in the JNI_OnLoad
> which is called automatically by the JNI, and is called before any other
> routine.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

Not sure if this is the case for you but I started writing a program for
arm wince device and I had some trouble because of unaligned access to
strings.

So "FooString := BarString" in some instances might cause a AV. But
"FooString := unaligned(BarString)" might work. Although it would
especially happen when a character alone was accessed i.e. PChar(Foo)[x].

It could be the problem.

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] assign code to a method

2011-02-18 Thread Andrew Haines
On 02/18/11 03:14, Angel Montesinos wrote:
> While waiting for a 64 bits Delphi, I am doing experimentation with
> fpc-Lazarus 64 bits. And this is my problem:
> 
> In most of my programs I use my own library for parsing and evaluating
> floating point functions like
> 
>   'x sin(y z)'
> 
> passed by the user as strings. The basic organization is as follows:

> In the debugger the exception is raised before the effective call of the
> function code. If then I press F7, then the debugger jumps to the
> following assemblies
> 
>push%rbp
>mov %esp,%ebp
>fldpi   {loads pi to the fpu}
>ftspl   -0x18(%rbp) {copy pi to stack}
>movsd   -0x18(%rbp),%xmm0   {copies pi to XMM0, so caller
>{may find also there the result}
>leaveq
>retq
> 
> I have tried all possible combinations like V:= PChar(code), V:=
> @code[1], etc. to no avail. Thus I think something is wrong in my
> understanding of the whole business in 64 bits or in fpc-Lazarus,
> because this is not a problem in Delphi nor it was in an old version of
> fpc-Lazarus 32 bits. Please give me a tip.
> Many thanks in advance.
> 

>From the other comments it seems like you are writing some assembly to
memory at runtime then calling that code? If so then maybe the following
can help you.

I made some trampoline procedures where I wrote some executable code at
runtime and I had to, both on Window and Linux, allocate some memory
that was marked as executable. Here's a snippet of how I allocated the
memory. The code worked on Windows 7 x64/32 and Gentoo Linux x64/32

 PTrampolineBlock = ^TTrampolineBlock;
  TTrampolineBlock = record
NextBlock: Pointer;
Cursor: DWord;
Size: DWord;
Code: PtrUint; // this is actually the start of the remainder of the
allocated size
  end;

procedure TTrampolineManager.AllocateBlock;
const
  AllocSize = $1000;
var
  NewBlock: PTrampolineBlock;
begin
  {$IFDEF UNIX}
  NewBlock := fpmmap(nil, AllocSize, PROT_EXEC or PROT_READ or
PROT_WRITE, MAP_ANONYMOUS or MAP_PRIVATE, -1, 0);
  {$ENDIF}
  {$IFDEF MSWINDOWS}
  NewBlock := VirtualAlloc(nil,AllocSize,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
  {$ENDIF}

NewBlock^.Cursor:=PtrUint(@NewBlock^.Code)-PtrUint(@NewBlock^.NextBlock);
  NewBlock^.Size:=AllocSize;
  NewBlock^.NextBlock:=Block;
  Block := NewBlock;
end;

procedure TTrampolineManager.FreeBlock(var ABlock: PTrampolineBlock);
begin
  if ABlock = nil then
Exit;
  FreeBlock(ABlock^.NextBlock);
  {$IFDEF UNIX}
  Fpmunmap(ABlock, ABlock^.Size);
  {$ENDIF}
  {$IFDEF MSWINDOWS}
  VirtualFree(ABlock, 0, MEM_RELEASE);
  {$ENDIF}
  ABlock := nil;
end;

procedure TTrampolineManager.WriteData(const AData; ASize: Byte);
begin
  if Block = nil then AllocateBlock;
  //WriteLn('Writing: ', hexStr(PtrUint(AData), ASize*2));
  if Block^.Cursor + ASize >= Block^.Size then
raise TrampolineBlockFullException.Create('');
  Move(AData, PByte(@Block^.Code)[Block^.Cursor], ASize);
  Inc(Block^.Cursor, ASize);
end;

so the usage would be like so
function TTrampolineManager.GenerateCode(args: ): Pointer;
begin
try
  Result := CurrentBlock.Position; // = @Block + Block.Cursor
  repeat
WriteData(your_data, size_of_data);
  until done;

except
on e: TrampolineBlockFullException do
  begin
    TrampolineManager.AllocateBlock;
Result := GenerateCode(args);
  end;
  end;
end;


Hope this helps :)

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Permuted index (KWIC) of function descriptions

2011-01-26 Thread Andrew Haines
On 01/26/11 07:41, Marco van de Voort wrote:
> CHM has a basic phrase indexer, and it operates on the html. The search part
> is maybe part of the viewer, and one would have to see how complex it is. 
> (Iow if the complexity is in index or search, if the search is relative
> simple one could look at kchmviewer)
> 
> 

As far as I remember the chm search only indexes whole words. So
searching for "space" would not return "LotsOfSpace" I'm not sure if it
would find "SpaceFoo" since it starts with space.

Does changing the indexer to extract words from capitalized words make
sense?  i.e. "DoSomethingCool" becomes "do", "something", "cool" ?

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Basic instructions for quick start of free basic setup with subversion.

2011-01-22 Thread Andrew Haines
On 01/22/11 14:31, Peter Eric Williams wrote:
> Hi pascal list,
> 
> Please excuse me asking such a basic question, but I'm new to this list.
> 
> I require the basic instructions for quick start with subversion for all
> of the free pascal compiler using subversion.
> 
> I am using Windows 7 Ultimate and I am new to Free Pascal and Lazarus.
>

you have the command right there

"svn co http://svn.freepascal.org/svn/fpc/trunk fpc"
"svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus"

This will create a folder named "fpc" and "lazarus" in the working
directory of the cmd.exe prompt you have open.

If you are setting fpc up for the first time on this computer, you'll
need a starting compiler to compile the source you've just gotten.
Download the correct one from here:
ftp://ftp.freepascal.org/fpc/dist/2.4.2/bootstrap/

If you choose i386-win32-ppc386.zip then extracting that will give you
something like ppc386.exe

cd into the fpc folder and type "PP=/path/to/ppc386.exe make all
install" generally that will install fpc into c:\fpc. It's important to
use gnu make since others like the MS one or borlands are not compatible
with the makefiles fpc uses.

Anyway it's much easier to just install a snapshot from here:
http://www.hu.freepascal.org/lazarus/

Choose the "Lazarus + fpc 2.4.2" "win32" link. This should install a fpc
2.4.2 compiler and the latest svn version of lazarus.

Also this link has a lot of relevant information:
http://wiki.lazarus.freepascal.org/Getting_Lazarus

Regards,

Andrew

An overview of requirements:

1 and 2 must be in the PATH. unless you use variables to set them
(MAKE=c:\path\to\make.exe AS=c:\path\to\as.exe etc.)

1. Gnu Make
2. Possibly win32 binutils (as.exe ld.exe and some more)
3. Latest Release of FPC for the starting compiler (currently 2.4.2)
4. Fpc Source code, either from a zip file or gotten from subversion
(svn) (compile with a starting compiler from step 3)
5. Lazarus source code (compile with fpc created in step 4)

Further notes:

gnu make gets cranky in windows if you use a path with spaces in it.
That is why fpc and lazarus are generally installed to c:\fpc or
c:\lazarus instead of c:\program files\...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Skipping an the "inherited" of an ancestor

2011-01-15 Thread Andrew Haines
On 01/15/11 11:01, Andrew Haines wrote:
> On 01/15/11 10:30, Andrew Haines wrote:
>> On 01/14/11 14:38, Torsten Bonde Christiansen wrote:
>>> Hi List.
>>>
>>> Is it possible to jump a couple of levels in the inherited hierarchy
>>> when calling "inherited" on a method?
>>>
>>>
>>
>> I *think* I've done this before this way but test it to make sure it works:
>>
>> procedure TC.DoSomething:
>> begin
>>  (Self as TA).DoSomething;
>> end;
>>
> 
> Okay I tested that and it didn't work.
> 

For some reason this problem intrigued me so I played around with it and
came up with the attached program that demonstrates a solution that
seems not too hackish to me. (Even though it is one). TC.Dosomething
calls TA.DoSomething and can also have it's own vars and code.

Regards,

Andrew
program Project1;
{$MODE objfpc}{$H+}
{$ASMMODE att}

uses
  Classes, Sysutils;

type

  { TA }

  TA = class
 procedure DoSomething(a,b,c,d,e: Integer); virtual;
  end;

  { TB }

  TB = class(TA)
 procedure DoSomething(a,b,c,d,e: Integer); override;
  end;

  { TC }

  TC = class(TB)
 procedure DoSomething(a,b,c,d,e: Integer); override;
  end;

{ TB }

procedure TB.DoSomething(a,b,c,d,e: Integer);
begin
  inherited DoSomething(a,b,c,d,e);
  WriteLn(Format('TB.DoSomething %d %d %d %d %d',[a,b,c,d,e]));
end;

{ TC }
procedure CallTADoSomething(ATC: TC; aa,bb,cc,dd,ee: integer); assembler; 
nostackframe;
asm
 jmp TA.DoSomething
end;

procedure TC.DoSomething(a,b,c,d,e: Integer);
var
  Buffer: array [0..1024] of byte;
  PossibleEaxResult: Integer;
begin
  FillChar(Buffer, 0, SizeOf(Buffer));
  CallTADoSomething(Self, a,b,c,d,e);
  WriteLn(Format('TC.DoSomething %d %d %d %d %d',[a,b,c,d,e]));
  //now do more stuff
end;

{ TA }

procedure TA.DoSomething(a,b,c,d,e: Integer);
begin
  WriteLn(Format('TA.DoSomething %d %d %d %d %d',[a,b,c,d,e]));
end;


var
 A: TA;
 B: TB;
 C: TC;

begin
  A := TA.Create;
  B := TB.Create;
  C := TC.Create;
  WriteLn('-A-');
  A.DoSomething(1,2,3,4,5);
  WriteLn('-B-');
  B.DoSomething(1,2,3,4,5);
  WriteLn('-C-');
  C.DoSomething(1,2,3,4,5);
  A.Free;
  B.Free;
  C.Free;


end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Skipping an the "inherited" of an ancestor

2011-01-15 Thread Andrew Haines
On 01/15/11 10:30, Andrew Haines wrote:
> On 01/14/11 14:38, Torsten Bonde Christiansen wrote:
>> Hi List.
>>
>> Is it possible to jump a couple of levels in the inherited hierarchy
>> when calling "inherited" on a method?
>>
>>
> 
> I *think* I've done this before this way but test it to make sure it works:
> 
> procedure TC.DoSomething:
> begin
>  (Self as TA).DoSomething;
> end;
> 

Okay I tested that and it didn't work.

Does TC.DoSomething do anything other than call inherited from TA? If
not then the following would work

TC = class(TA)
  procedure DoSomething; override;
end;
..

procedure TC.DoSomething; assembler; nostackframe;
asm
 jmp TA.DoSomething
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Skipping an the "inherited" of an ancestor

2011-01-15 Thread Andrew Haines
On 01/14/11 14:38, Torsten Bonde Christiansen wrote:
> Hi List.
> 
> Is it possible to jump a couple of levels in the inherited hierarchy
> when calling "inherited" on a method?
> 
> A small example of what i'm trying to achieve below (and don't mind the
> incomplete TB class implementation).
> 
> Kind regards,
> Torsten Bonde Christiansen.
> 
> 
> 
> TA = class
>   procedure DoSomething; virtual;
> end;
> 
> TB = class(TA)
>   procedure DoSomething; override;
> end;
> 
> TC = class(TB)
>   procedure DoSomething; override;
> end;
> 
> .
> 
> procedure TA.DoSomething;
> begin
>   ...
> end;
> 
> procedure TC.DoSomething;
> begin
>   inherited TA.DoSomething;  // This is not correct, but exemplifies
> what i'm trying to achieve.
> end;
> 

I *think* I've done this before this way but test it to make sure it works:

procedure TC.DoSomething:
begin
 (Self as TA).DoSomething;
end;

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] CDDB unit

2010-12-18 Thread Andrew Haines
Hi,

Does anyone have the cddb unit that was on the wiki once upon a time?
http://wiki.lazarus.freepascal.org/CDDB

The link on that page is now dead.

Thanks,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: FPC programs in Android without JNI

2010-12-17 Thread Andrew Haines
On 12/17/10 15:46, Felipe Monteiro de Carvalho wrote:
> I a
> 

??
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: FPC programs in Android without JNI

2010-12-17 Thread Andrew Haines
On 12/16/10 12:23, Felipe Monteiro de Carvalho wrote:
> Hello,
> 
> It might be interesting to know that I managed to build a bridge which
> exports the Java API and the Android API to Free Pascal. Check this
> hello world code and screenshot:
> 
> http://wiki.lazarus.freepascal.org/Android_Interface/Android_Programming#Using_the_Android_API_from_Pascal
> 
> The full code is here:
> 
> http://p-tools.svn.sourceforge.net/viewvc/p-tools/PascalNotes4Android/
> 
> bye,

The Android 2.3 ndk now has support for a NativeActivity and there is a
sample of OpenGL ES native program.



General notes:

* Adds support for native activities, which allows you to
implement the Android application lifecycle in native code.
* Adds native support for the following:
  o Input subsystem (such as the keyboard and touch screen)
  o Access to sensor data (accelerometer, compass,
gyroscope, etc).
  o Event loop APIs to wait for things such as input and
sensor events.
  o Window and surface subsystem
  o Audio APIs based on the OpenSL ES standard that support
playback and recording as well as control over platform audio effects
  o Access to assets packaged in an .apk file.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Looking for SDL_opengl header

2010-12-07 Thread Andrew Haines
On 12/07/10 18:23, Darius Blaszyk wrote:
> Has anyone ever converted the SDL_opengl header to FPC? Couldn't find it
> in the repository, but perhaps someone knows if it is part of another
> project.
> 

Is there one included with jedi sdl??

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using C functions

2009-11-22 Thread Andrew Haines
Ivo Steinmann wrote:
>>>   
>> Thanks, I thought so.
>>
>> I am considering to write a C library (cdecl) to wrap the calls to the
>> C library(fastcall), but it doesn't feel right.
>> 
>>

You can compile your c wrapper and link the .o file directly in your
pascal unit so that a .so is not needed at runtime.

{$link my_c_wrapper.o}

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] sysutils.beep doesn't beep under Linux?

2009-11-21 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> By that rationale: no beep() on linux.
> 

Can beep be made a procvar?

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Porting linux to pascal, would it be, possible ?

2008-12-07 Thread Andrew Haines

Graeme Geldenhuys wrote:

On Fri, Dec 5, 2008 at 5:55 PM, Felipe Monteiro de Carvalho
<[EMAIL PROTECTED]> wrote:
  

If you want to do some large work to increase the use of FPC I would
recommend creating a Window Manager instead, probably with fpgui.



How far did you guys get with the 'fpwm' project?  Did it actually run
at some point. I see the last code changes was 2 years ago.

  
I just checked out fpwm and updated it and fpgui locally so it can 
compile. It does almost nothing atm but can reparent and close windows 
:) not alot. I was thinking I might write a widget for resizing and 
moving windows. Currently the window "title bar" is a Label and a Button 
that has an "X" for it's text and stdimg.quit as the image.  I might 
work on it some in the coming week if I can find the time.


Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Tiburon and unicode rtl

2008-07-01 Thread Andrew Haines
Felipe Monteiro de Carvalho wrote:
> Hello,
> 
> Ok, so far we have a couple of unicode rtl proposals. Will FPC remain
> compatible with code from Tiburon?
> 
> If yes, then we need a set of utf-16 RTL routines, even if another
> solution is chosen. Yes, surely the utf-16 routines could just call
> the other routines and do a string conversion, if necessary, but they
> would need to exists anyway, specially because var parameters need to
> match exactly.
> 

Does gnu pascal have fpc compatible strings? or are they the same as
strings in {$mode fpc}

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Embedding a Video Player into a Linux/FP/GTK2 Application ?

2008-06-23 Thread Andrew Haines
Michael Van Canneyt wrote:

> 
> Would it be OK to include the xine unit in fpc ?
> 

It's not even close to complete, I only did just enough to make the
program work.

You can add it if you want, maybe some people will submit patches to
complete it. If it's possible to change the license go ahead, I have no
interest in personal rights to the unit.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] FPC on Palm

2008-06-03 Thread Andrew Haines
Hi, I tried to build a crosscompiler for palmos-arm and palmos-m68k but
both failed to compile.

Here's the results for m68k

make[5]: Entering directory `/home/andrew/programming/fpc/rtl/palmos'
/usr/bin/mkdir -p /home/andrew/programming/fpc/rtl/units/m68k-palmos
make[5]: *** No rule to make target `m68k/prt0.as', needed by `prt0.o'.
 Stop.
make[5]: Leaving directory `/home/andrew/programming/fpc/rtl/palmos'
make[4]: *** [palmos_all] Error 2
make[4]: Leaving directory `/home/andrew/programming/fpc/rtl'
make[3]: *** [rtl] Error 2
make[3]: Leaving directory `/home/andrew/programming/fpc/compiler'
make[2]: *** [cycle] Error 2
make[2]: Leaving directory `/home/andrew/programming/fpc/compiler'
make[1]: *** [compiler_cycle] Error 2
make[1]: Leaving directory `/home/andrew/programming/fpc'
make: *** [build-stamp.m68k-palmos] Error 2


and for arm:

make[5]: Entering directory `/home/andrew/programming/fpc/rtl/palmos'
arm-palmos-as  -o
/home/andrew/programming/fpc/rtl/units/arm-palmos/prt0.o arm/prt0.as
arm/prt0.as: Assembler messages:
arm/prt0.as:47: Error: cannot represent BFD_RELOC_RVA relocation in this
object file format
arm/prt0.as:49: Error: cannot represent BFD_RELOC_RVA relocation in this
object file format
arm/prt0.as:50: Error: cannot represent BFD_RELOC_RVA relocation in this
object file format
arm/prt0.as:54: Error: cannot represent BFD_RELOC_RVA relocation in this
object file format
arm/prt0.as:62: Error: cannot represent BFD_RELOC_RVA relocation in this
object file format
make[5]: *** [prt0.o] Error 1
make[5]: Leaving directory `/home/andrew/programming/fpc/rtl/palmos'
make[4]: *** [palmos_all] Error 2
make[4]: Leaving directory `/home/andrew/programming/fpc/rtl'
make[3]: *** [rtl] Error 2
make[3]: Leaving directory `/home/andrew/programming/fpc/compiler'
make[2]: *** [cycle] Error 2
make[2]: Leaving directory `/home/andrew/programming/fpc/compiler'
make[1]: *** [compiler_cycle] Error 2
make[1]: Leaving directory `/home/andrew/programming/fpc'
make: *** [build-stamp.arm-palmos] Error 2

I cant read or write asm but the prt0.as file seems to be copied from
the wince dir and it not for palm.

Is anyone working with fpc and palm?

Regards,

Andrew



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-09 Thread Andrew Haines
Andrew Haines wrote:
> Michael Van Canneyt wrote:
>> On Fri, 7 Dec 2007, Andrew Haines wrote:
>>
>>> PS you can have a peek at some chm's I made with fpdoc here:
>>> http://hainesservice.com/andrew/chms/ they are all crosslinked.
>> With kchmviewer I get the following errors:
>>
>> An error occurred while loading 
>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html:
>> The file or folder 
>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html does not 
>> exist 
>>
>> Same for every other page, even the index page.
>>
>> With chmsee, I can load the initial page, but the first 5 units or so cannot 
>> be found.
>> Others seem to work well. So it seems that there are some glitches in the 
>> file generation. 
>>
>> Nevertheless, the basic functionalities seem to be there, so kudos to you... 
>> :)
>>
> 
> Okay, I've regenerated the files with a 32bit version of fpdoc and put
> them at the link below. the md5's are different and also diff says the
> files differ. The new files are the same size as the old ones. The only
> thing different is fpdoc(32 bit instead of 64) I've not updated fpc or
> anything.
> 
> http://hainesservice.com/andrew/chms/
> 
> Can anyone recommend a program to compare files that can tell me the
> places at which they are different? Thanks
> 

Seems the only difference is the timestamp :) so it still won't work
likely if it didn't before.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-09 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Fri, 7 Dec 2007, Andrew Haines wrote:
> 
>> PS you can have a peek at some chm's I made with fpdoc here:
>> http://hainesservice.com/andrew/chms/ they are all crosslinked.
> 
> With kchmviewer I get the following errors:
> 
> An error occurred while loading 
> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html:
> The file or folder 
> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html does not 
> exist 
> 
> Same for every other page, even the index page.
> 
> With chmsee, I can load the initial page, but the first 5 units or so cannot 
> be found.
> Others seem to work well. So it seems that there are some glitches in the 
> file generation. 
> 
> Nevertheless, the basic functionalities seem to be there, so kudos to you... 
> :)
> 

Okay, I've regenerated the files with a 32bit version of fpdoc and put
them at the link below. the md5's are different and also diff says the
files differ. The new files are the same size as the old ones. The only
thing different is fpdoc(32 bit instead of 64) I've not updated fpc or
anything.

http://hainesservice.com/andrew/chms/

Can anyone recommend a program to compare files that can tell me the
places at which they are different? Thanks

Regards,
Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-07 Thread Andrew Haines
Mattias Gaertner wrote:
> I downloaded them, installed kchmviewer 3.1 (ubuntu gutsy) and got:
> 
> An error occurred while loading
> ms-its:/home/mattias/file:/home/mattias/pascal/docs/rtl.chm::/index.html:
> Could not read file
> ms-its:/home/mattias/file:/home/mattias/pascal/docs/rtl.chm::/index.html.
> 
> Similar errors for the other two files.
> 

I uploaded md5's for the chms as well
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-07 Thread Andrew Haines
Mattias Gaertner wrote:
> On Fri, 07 Dec 2007 09:43:57 -0500
> Andrew Haines <[EMAIL PROTECTED]> wrote:
> 
>> Michael Van Canneyt wrote:
>>> On Fri, 7 Dec 2007, Andrew Haines wrote:
>>>
>>>> Michael Van Canneyt wrote:
>>>>> On Fri, 7 Dec 2007, Andrew Haines wrote:
>>>>>
>>>>>> PS you can have a peek at some chm's I made with fpdoc here:
>>>>>> http://hainesservice.com/andrew/chms/ they are all crosslinked.
>>>>> With kchmviewer I get the following errors:
>>>>>
>>>>> An error occurred while loading
>>>>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html:
>>>>> The file or folder
>>>>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html
>>>>> does not exist 
>>>>>
>>>>> Same for every other page, even the index page.
>>>>>
>>>>> With chmsee, I can load the initial page, but the first 5 units
>>>>> or so cannot be found. Others seem to work well. So it seems that
>>>>> there are some glitches in the file generation. 
>>>>>
>>>>> Nevertheless, the basic functionalities seem to be there, so
>>>>> kudos to you... :)
>>>>>
>>>> Maybe your download is corrupted somehow... I just downloaded
>>>> kchmviewer and chmsee and it works fine here. Also the MS reader
>>>> which seems to be the most picky reads the file.
>>> Hm. 
>>> I just re-downloaded, and have the same problems, with both
>>> programs, for all files :/ I also just downloaded some ISO images,
>>> and those came through without a glitch, so I'm not entirely
>>> convinced it is the download (unless something is wrong with the
>>> files on your site..)
>>>
>>> Ah well, the mysteries of internet :/
>>>
>> I downloaded the files and they are ok.
>>
>> Looking at the log it looks like you've only downloaded the lcl.chm
>> file again, Maybe your browser is caching. try using wget.
>>
>> wget http://hainesservice.com/andrew/chms/fcl.chm
>> wget http://hainesservice.com/andrew/chms/rcl.chm
>> wget http://hainesservice.com/andrew/chms/lcl.chm
> 
> I downloaded them, installed kchmviewer 3.1 (ubuntu gutsy) and got:
> 
> An error occurred while loading
> ms-its:/home/mattias/file:/home/mattias/pascal/docs/rtl.chm::/index.html:
> Could not read file
> ms-its:/home/mattias/file:/home/mattias/pascal/docs/rtl.chm::/index.html.
> 
> Similar errors for the other two files.
> 

Ok, well I've put the original chm files in a couple of tar.bz2 files on
that page. So if they still don't work I'm stumped.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-07 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Fri, 7 Dec 2007, Andrew Haines wrote:
> 
>> Michael Van Canneyt wrote:
>>> On Fri, 7 Dec 2007, Andrew Haines wrote:
>>>
>>>> PS you can have a peek at some chm's I made with fpdoc here:
>>>> http://hainesservice.com/andrew/chms/ they are all crosslinked.
>>> With kchmviewer I get the following errors:
>>>
>>> An error occurred while loading 
>>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html:
>>> The file or folder 
>>> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html does 
>>> not exist 
>>>
>>> Same for every other page, even the index page.
>>>
>>> With chmsee, I can load the initial page, but the first 5 units or so 
>>> cannot be found.
>>> Others seem to work well. So it seems that there are some glitches in the 
>>> file generation. 
>>>
>>> Nevertheless, the basic functionalities seem to be there, so kudos to 
>>> you... :)
>>>
>> Maybe your download is corrupted somehow... I just downloaded kchmviewer
>> and chmsee and it works fine here. Also the MS reader which seems to be
>> the most picky reads the file.
> 
> Hm. 
> I just re-downloaded, and have the same problems, with both programs, for all 
> files :/
> I also just downloaded some ISO images, and those came through without a 
> glitch,
> so I'm not entirely convinced it is the download (unless something is wrong 
> with
> the files on your site..)
> 
> Ah well, the mysteries of internet :/
> 
I downloaded the files and they are ok.

Looking at the log it looks like you've only downloaded the lcl.chm file
again, Maybe your browser is caching. try using wget.

wget http://hainesservice.com/andrew/chms/fcl.chm
wget http://hainesservice.com/andrew/chms/rcl.chm
wget http://hainesservice.com/andrew/chms/lcl.chm


Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-07 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Fri, 7 Dec 2007, Andrew Haines wrote:
> 
>> PS you can have a peek at some chm's I made with fpdoc here:
>> http://hainesservice.com/andrew/chms/ they are all crosslinked.
> 
> With kchmviewer I get the following errors:
> 
> An error occurred while loading 
> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html:
> The file or folder 
> ms-its:/home/michael/Documents/fcl.chm::/streamio/assignstream.html does not 
> exist 
> 
> Same for every other page, even the index page.
> 
> With chmsee, I can load the initial page, but the first 5 units or so cannot 
> be found.
> Others seem to work well. So it seems that there are some glitches in the 
> file generation. 
> 
> Nevertheless, the basic functionalities seem to be there, so kudos to you... 
> :)
>

Maybe your download is corrupted somehow... I just downloaded kchmviewer
and chmsee and it works fine here. Also the MS reader which seems to be
the most picky reads the file.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-07 Thread Andrew Haines
Michael Van Canneyt wrote:

> 
> How do I view this on a Linux KDE system ? 
> 

you can use xchm or gnochm and I think there is a kde variant too,
though I don't know it's name.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format? [Patch]

2007-12-06 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Thu, 6 Dec 2007, Andrew Haines wrote:
> 
>> Andrew Haines wrote:
>>> Attached is a patch to add chm output to fpdoc. I edited Makefile.fpc to
>>> require the "package" chm. Also a patch for chmwriter.pas with some
>>> minor changes that were needed.
>> Don't apply this patch. I have improved it a bit and now fpdoc (here)
>> can autogenerate a TOC. Later this morning I will work on autogenerating
>> an Index.
> 
> Great news ! 
> Is this TOC page available in all formats, or just for chm ?
> I would for obvious reasons prefer the first ;-)

The TOC is not made to be generically usable sorry :(

> 
>> The Index will have all classes, enums, consts, procedures and functions
>> listed in alphabetical order in the above format.
> 
> This is enough, I think...
> 
> Great work !
> 
> Michael.

Okay, here's the patch. it adds the ability to have fpdoc output chm's
which have an autogenerated toc and index.

to import the .xct files from another package/chm looks like this:
--import=/path/to/rtl.xct,ms-its:rtl.chm::/
--import=/path/to/fcl.xct,ms-its:fcl.chm::/

There's a seriously huge improvement in speed of the chm code when
compiled with -Ooregvar. I added it to the Makefile.fpc in the
packages/chm directory. I guess the Makefile will have to be regenerated.

Regards,

Andrew


PS you can have a peek at some chm's I made with fpdoc here:
http://hainesservice.com/andrew/chms/ they are all crosslinked.


fpdoc-chm.tar.bz2
Description: BZip2 compressed data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] can we have fpc's doc in chm format?

2007-12-06 Thread Andrew Haines
Andrew Haines wrote:
> Attached is a patch to add chm output to fpdoc. I edited Makefile.fpc to
> require the "package" chm. Also a patch for chmwriter.pas with some
> minor changes that were needed.

Don't apply this patch. I have improved it a bit and now fpdoc (here)
can autogenerate a TOC. Later this morning I will work on autogenerating
an Index.

Currently for the TOC I have:

Classes and Objects, by Unit
  UnitName1
TClass1
TClass2
  UnitName2
TClass40
TClass41

Alphabetical Classes and Objects
  TC
TClass1
TClass2
  TS
TSimpleClass

Routines, by Unit
  Unit1
AddNumbers
ConvertSomething
  Unit2
JumpUpAndDown

Alphabetical Routines Listing
  A
AddNumbers
  C
ConvertSomething
  J
JumpUpAndDown

Is there another way to sort that someone can think of? If it's not too
time consuming I'll do it.


For the Index I have the following plan for layout:

Abs function
ColumnClick
  TCustomListView
Read
  TStream
  TMemoryStream
Read method
TCustomListView
  ActionChange
  AddItem
  ColumnClick
TMemoryStream
  Read
  Write
TStream
  Read
  Write
vsIcon
Write
  TMemoryStream
  TStream
Write method

The Index will have all classes, enums, consts, procedures and functions
listed in alphabetical order in the above format.


Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] can we have fpc's doc in chm format?

2007-12-04 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Sun, 2 Dec 2007, Bisma Jayadi wrote:
> 
>> Can we have fpc's doc in chm format? It's easier to navigate and search
>> compare to other formats. :)
> 
> The reference material: If you complete the chm backend of fpdoc, yes.

Attached is a patch to add chm output to fpdoc. I edited Makefile.fpc to
require the "package" chm. Also a patch for chmwriter.pas with some
minor changes that were needed.

Regards,

Andrew


fpdoc-chm.tar.bz2
Description: BZip2 compressed data
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] can we have fpc's doc in chm format?

2007-12-04 Thread Andrew Haines
Michael Van Canneyt wrote:
> 
> On Sun, 2 Dec 2007, Bisma Jayadi wrote:
> 
>> Can we have fpc's doc in chm format? It's easier to navigate and search
>> compare to other formats. :)
> 
> The reference material: If you complete the chm backend of fpdoc, yes.
> The manuals: definitely out.
> 

I have almost completed the patch to add chm as an output option for fpdoc.

And before anyone gets their hopes up, to make chm's searchable you have
to at creation time generate a special file that is contained in the
chm. To me it's relatively difficult and I never implemented it.

Short version: chm's made with the current chm writing code cannot be
searched with the helpviewer.

That having been said, If a viewer is written for chm files (there is
reader code with fpc too) perhaps a database file created with some
search engine (like ioda) can be included and integrated so searching is
possible.

Michael, are the manuals written in rtf? why couldn't they be in a chm file?

Regards,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux : Using SDL with GTK2 ?

2007-11-16 Thread Andrew Haines
T.Guilleminot wrote:
> 1. I'm unsure of chronology of things to do in the program body. Is the
> following correct :
>a) Create GTK stuff
>b) SDL Hack/SDL_WINDOWID
>c) SDL_INIT
>d) Show GTK widgets
> 

Yes that's right. With the only exception being that you have to use
gtk_widget_realize on whatever gtk widget you are using for sdl so that
the x11 window will be allocated.

> 2. You mentioned "this is for gtk1 only. gtk2 is similar but different".
> What to do for GTK2 ?
> 

I've attached a simple program that will compile for gtk1 or gtk2. you
can change a define at the top of the source to switch between gtk 1 or 2.

> 3. Which kind of GTK Object "APanel" can be ?
> 
> 4. FPC complains on "handle". What's wrong ?
> 

Sorry I thought you were using the LCL and so my example was for that. I
attached an example program that doesn't use the LCL.

> Thanks Again.
> Tom
> 
> 

It's worth noting that you cannot have more than one sdl window per
application. It's a limitation of sdl.

Andrew
program Project1;

{$mode objfpc}{$H+}

{$DEFINE GTK1}

uses
  Classes, SysUtils,
  {$IFDEF GTK2} Gtk2, Gdk2, Gdk2x, Glib2, {$ENDIF}
  {$IFDEF GTK1} Gtk, Gdk, Glib,{$ENDIF}
  X, sdl, sdlutils;
  
var
  MainWindow,
  Drawable: PGtkWidget;
  SDLSurface: PSDL_Surface = nil;



procedure InitGtk;
begin
  gtk_init(@argc, @argv);
  
  MainWindow := gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(PGtkWindow(MainWindow), 'Hey there''s SDL in this 
window!');

  Drawable := gtk_drawing_area_new;

  gtk_widget_set_app_paintable(Drawable, False);
  {$IFDEF GTK2}
  gtk_widget_set_double_buffered(Drawable, False);
  {$ENDIF}

  gtk_container_add(PGtkContainer(MainWindow), Drawable);
  {$IFDEF GTK1}
  gtk_widget_show(MainWindow);
  {$ENDIF}
end;

procedure ResizeSDL(AWidget: PGtkWidget; Allocation: PGtkAllocation; userdata: 
pointer); cdecl;
begin
  SDLSurface := SDL_SetVideoMode(Allocation^.width, Allocation^.height, 0, 
SDL_HWSURFACE);
end;

procedure ExposeSDL(widget: PGtkWidget; event: PGdkEventExpose; Data: Pointer); 
cdecl;
var
  Col1, Col2: TSDL_Color;
  ARect: TSDL_Rect;

begin
  Col1.r := 255;
  Col1.b := 0;
  Col1.g := 0;

  Col2.r := 0;
  Col2.b := 255;
  Col2.g := 0;

  ARect := SDLRect(0,0,Drawable^.allocation.width, Drawable^.allocation.height);

  SDL_FillRect(SDLSurface, @ARect, $);
  SDL_Flip(SDLSurface);
end;

procedure SetGtkCallbacks;
begin
  gtk_signal_connect(GTK_OBJECT(Drawable), 'expose-event', 
TGtkSignalFunc(@ExposeSDL), nil);
  gtk_signal_connect(GTK_OBJECT(Drawable), 'size-allocate', 
TGtkSignalFunc(@ResizeSDL), nil);

  gtk_signal_connect(GTK_OBJECT(MainWindow), 'destroy', 
TGtkSignalFunc(@gtk_main_quit), nil)
end;

function GetX11Window(AWidget: PGtkWidget): X.TWindow;
begin
  // first make sure the x11 window is created for the gtk widget
  if GTK_WIDGET_REALIZED(AWidget) = False then
gtk_widget_realize(AWidget);


  // now retrieve the X window
  {$IFDEF GTK2}
  Result := GDK_WINDOW_XWINDOW(PGdkDrawAble(AWidget^.window));
  {$ENDIF}
  {$IFDEF GTK1}
  Result := GDK_WINDOW_XWINDOW(PGdkWindowPrivate(AWidget^.window));
  {$ENDIF}

end;

procedure SetSDLWidget(AWidget: PGtkWidget);
var
  X11Window: QWord;
  SDL_WINDOWID: String;
begin
 X11Window := GetX11Window(AWidget);
 SDL_WINDOWID := 'SDL_WINDOWID='+IntToStr(PtrUint(X11Window));
 _putenv(PChar(SDL_WINDOWID));
end;

procedure SyncGtk;
begin
  gtk_main_iteration_do(True);
end;

procedure InitSDL;
begin
  SDL_Init(SDL_INIT_VIDEO or SDL_INIT_JOYSTICK);
  SDLSurface := SDL_SetVideoMode(Drawable^.allocation.width, 
Drawable^.allocation.height, 0, SDL_HWSURFACE);
end;

procedure Run;
begin
  gtk_widget_show_all(MainWindow);
  gtk_main;
end;

begin
  InitGtk;
  SetGtkCallbacks;
  SetSDLWidget(Drawable);
  SyncGtk;
  InitSDL;
  Run;
end.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Linux : Using SDL with GTK2 ?

2007-11-15 Thread Andrew Haines
Tom wrote:
> Hi,
> 
> I'm desperately trying to build a application mixing GTK with SDL for *Linux*.
> 
> I know that's not always recommended as it involves 2 listening loops but it 
> should work. I found some *C* snippets/applications (eg making window hacks) 
> but 
> I'm unable to translate them into Pascal.
> My goal is to display Joystick events into a GTK2 window. Ideally I would 
> like 
> to use Jedi-SDL with GTK2. Of course either GTK2 or SDL used alone works fine.
> Does anyone have some example to achieve this ?
> 
> 

uses sdl, gtk, gdk, X;

var
  SDLWindowHack: String
  X11Window: X.TWindow;
begin
...
  // this is for gtk1 only. gtk2 is similar but different
  X11Window :=
GDK_WINDOW_XWINDOW(PGdkWindowPrivate(GTK_WIDGET(APanel.Handle)^.window ) );

  SDLWindowHack := 'SDL_WINDOWID='+ IntToStr(PtrUint(X11Window));
  putenv (PChar(SDLWindowhack));
end;


You have to for sure set the environment variable SDL_WINDOWID before
you create the window with sdl and maybe before sdl_init.

IIRC using this method somehow makes sdl not listen for keyboard/mouse
events because it is using a window you have made and expects you to
already be processing those events in some way.

The other way to embed a window is to create the window normally with
sdl without setting SDL_WINDOWID and then accessing the PSurface record
get the X11 window ID and use XReparentWindow to embed it into your app.
unfortunatly the window is created outside your app and is briefly
visible before you have stuck it inside your app. Sdl will behave as if
the window is not embedded in your app. Setting keyboard focus and mouse
focus in the window may have quirks.

Overall I think the first method is best.

Setting the SDL_WINDOWID works on windows too if you set it to the
(hwnd)TWinControl.Handle of whatever component you want sdl to draw to.

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How do I join the Lazarus list?

2007-07-03 Thread Andrew Haines
Tom York wrote:
> I cannot seem to find a way to join the mailing list.

It's on this page:
http://www.lazarus.freepascal.org/modules.php?op=modload&name=StaticPage&file=index&sURL=maill

It's the link that says "subscribe"

mailto:[EMAIL PROTECTED]

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: html link extractor

2007-07-02 Thread Andrew Haines
L wrote:
> Andrew Haines wrote:
>> Is there a unit somewhere that can extract links from html pages? I want
>> to be able to recursively add pages to a chm archive.
> 
> I created a program called GetLinks in a couple minutes:
> http://opensvn.csie.org/pspcgi/general-utilities/parser/html/demo/getlinks.pas
> 
> Latest html parser files in progress:
> http://opensvn.csie.org/pspcgi/general-utilities/parser/html/
> 

This is great stuff thanks :)

I've just made a chm sitemap reader using your units. Next a writer.

Regards,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] html link extractor

2007-06-30 Thread Andrew Haines
Andrew Haines wrote:
> Is there a unit somewhere that can extract links from html pages? I want
> to be able to recursively add pages to a chm archive.
> 

I think this from l505 will work:
http://lists.freepascal.org/lists/fpc-announce/2007-February/000536.html

but are there any units that come default with fpc that can do this?

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] html link extractor

2007-06-30 Thread Andrew Haines
Is there a unit somewhere that can extract links from html pages? I want
to be able to recursively add pages to a chm archive.

Thanks,

Andrew Haines
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Class Memory Table Size

2007-05-09 Thread Andrew Haines
Daniël Mantione wrote:
> 
> Op Tue, 8 May 2007, schreef Andrew Haines:
> 
>> The reason for this is, I want to trick gtk into thinking that a TObject
>> is really a GObject. This is where the TypeID for GType's are stored. I
>> know this won't work for most GObject's, but I am only implementing this
>> for a GInterface which is looked up by the TypeID, so that is all I need.
>>
>> I've tested this and it is working. But what horrible things can happen?
> 
> I think it is much better to use objects for this rather than classes. A 
> construction like this:
> 
> type   gobject=object
>  gobject_typeid:...;
>end;
> 
>gobject_child=object(gobject)
>  constructor init;
>  destructor done;virtual;
>end;
> 
> ... will exactly to what you want: the gobject_typeid is at offset 
> 0 while the size and vmt index are stored after that.
> 

type
  TBaseObject=object
FGObject: TGObject;
  end;

  TMyObject=object(TBaseObject)
procedure MyProcedure; virtual; cdecl;
  end;

This is working perfectly. I am letting gtk allocate the object's
memory, then in the instance_init func that gtk calls I am running .Init
for the object and voila! I have a real object that I can pass to gtk
and use in my program.

Thanks,

Andrew
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


  1   2   >