Re: [fpc-pascal] Changing variable in conditional

2013-01-08 Thread Jorge Aldo G. de F. Junior
Your phrase almost made me care about...

Do you wanna make me care ? Show some points, make a constructive
critic about what i said etc.

For all that matter, your answer is just a plain old argumentum ad
hominem, a fallacy category, and being a fallacy, tells me you cant
really make a good answer, so i infer you are the idiot here.

2013/1/8 Henry Vermaak :
> On Tue, Jan 08, 2013 at 08:19:15AM -0300, Jorge Aldo G. de F. Junior wrote:
>> C programmers are (usually, but there are a lot of exceptions) bad
>> programmers who confuse the power of a language with the capability of
>> decrease the ammount of typing needed to reach a certain goal.
>>
>> They despise pascal because pascal is somewhat verbose (ignoring that
>> this is what makes pascal readable) because they think that the best
>> language is the one wich allows to write a whole program in a single
>> line of code.
>>
>> Thats because they dont usually think before writing, they think while
>> they are implementing, and then the only thing between current momment
>> and the momment when their program is "ready" is the ammount of
>> typing.
>>
>> Pascal programmers tend to plan ahead, they think before they type. We
>> type a lot because of Pascal verboseness, but usually our code is
>> right from the start. We end up typing less because we fix less bugs.
>>
>> Pascal generally improves programmer productivity. Lets not break this
>> by adding crazy ideas from C/C++ family of languages...
>
> "Better to keep your mouth closed and be thought a fool than to open it
> and remove all doubt"
> ___
> 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] Changing variable in conditional

2013-01-08 Thread Jorge Aldo G. de F. Junior
C programmers are (usually, but there are a lot of exceptions) bad
programmers who confuse the power of a language with the capability of
decrease the ammount of typing needed to reach a certain goal.

They despise pascal because pascal is somewhat verbose (ignoring that
this is what makes pascal readable) because they think that the best
language is the one wich allows to write a whole program in a single
line of code.

Thats because they dont usually think before writing, they think while
they are implementing, and then the only thing between current momment
and the momment when their program is "ready" is the ammount of
typing.

Pascal programmers tend to plan ahead, they think before they type. We
type a lot because of Pascal verboseness, but usually our code is
right from the start. We end up typing less because we fix less bugs.

Pascal generally improves programmer productivity. Lets not break this
by adding crazy ideas from C/C++ family of languages...

2013/1/8 Marco van de Voort :
> In our previous episode, Krzysztof said:
>> I don't like a lot of C++ syntax but this one is interesting. You really
>> don't like it? :)
>
> It's the worst thing ever. 95% of the hard to find errors in C in my code
> are due to = vs == mixup.
> ___
> 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] class destructor not recognised

2013-01-06 Thread Jorge Aldo G. de F. Junior
Are you SURE you need "class constructor" ?

because usually all you need is a plain old constructor... like

constructor create(const aparam : integer); // etc

to be honest i never used a class constructor before... (dont even
know this exists).

2013/1/6 Paul Ishenin :
> 07.01.13, 8:03, Howard Page-Clark пишет:
>
>> The following program compiles and gives output as expected, but if the
>> lines that call the class destructor are uncommented it fails to compile
>> with the error "identifier idents no member "Finalise"
>
> ...
>
>> Am I not understanding how to use a class destructor, or is this a bug?
>
>
> You don't understand.
>
> Class destructor is called automatically like finalization section of a
> unit. You can't call it directly.
>
> 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] Complex circular references

2012-11-22 Thread Jorge Aldo G. de F. Junior
I still dont understand why FPC doesnt support circular references...

There is no way to solve that ?

2012/11/22 denisgolovan :
>> PasDoc can produce 'dot' files of unit dependencies. (No idea if it will
>> handle circular refs though). GraphViz can then be used to produce
>> images based on the 'dot' files. I gave up with it because it did not
>> parse the implementaion sections, but you won't be needing that for unit
>> dependences. (I was hoping for a full class heirachy diagram).
>>
>> http://pasdoc.sipsolutions.net/
>>
>> Regards,
>> Peter
>
> Hm.
> Dot files should the ideal solution.
> Thanks a lot for the hint.
>
>  --
> Regards,
> Denis Golovan
> ___
> 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] Best way to transfer data between applications?

2012-11-01 Thread Jorge Aldo G. de F. Junior
I've added a source zip to the downloads section of the
pascal-actor-model google code page.

while it cannot do "runinbackground(procedure)" as you want, i believe
it can be mimmicked using the TCreateInstanceAndConfigActorMessage
message and a functor actor (functor is a kind of object that holds
"functions/methods", its a way to mimmick first class functions in a
non-functional language like pascal because it allows to pass function
references/contexts around as classes).

This message can create an actor and pass config info to it in one go,
with guaranteed message delivery and correct sequence. (This avoids
the unbounded non-determinism problem).

Actors usually sit in background doing work or idling. Theres an idle
procedure that can be overridden and you can write message receiving
methods that are triggered upon specific messages.

Actors wont stop until told to stop.

There are a lot of shortcut procedures in the actors.pas unit that
avoids too much verbosity in the code.

If an actor should stop by his own volition, you simply have to set
Running to false after all needed work is done :

Running = False;

There is a request/reply model of message passing, but it should be
avoided at all costs, because it basically stops the thread until the
receiving thread replies (or the timeout expires), the end result is
an almost sequential execution (Makes no sense usually).

The main thread can wait for messages comming from the actors (with
timeout). Its not an active wait (in the sense of a loop) but a
passive wait done using TEventObject.

Usually the correct point to wait for messages comming from the
background actors is inside the application idle loop, via the idle
timer.

Example :

lMessage := ReceiveMessage(500); // waits 500ms for a message to arrive

To send message to actors :

SendMessage(lMessage);

In your example about saving files in background, you can write a file
writer actor and send the content to him as a message. It will happly
save the data to the file while the main thread is free to do whatever
it should do, in parallel.

I believe i should write documentation but i dont know how to use pasdoc yet :P

2012/11/1 Noah Silva :
> Hi Jorge,
>
> Even if so, it won't solve many of the other problems I am trying to solve.
> On the other hand, do you have a Tarball available for download somewhere?
> (I checked the Google Code page, but no downloads, only SVN access it looks
> like).
>
>  Thank you,
>  Noah Silva
>
> 2012/11/1 Jorge Aldo G. de F. Junior 
>
>> i reiterate that my Pascal-Actor-Model can do exactly what you are
>> saying...
>>
>> writing a "save file in background" type of actor is trivial, and the
>> synchronization is already done...
>>
>> 2012/10/31 Noah Silva :
>> > Hi Aldo,
>> >
>> > Well it's not just synch problems with threads, I've found threads to
>> > not be
>> > so reliable under FPC for anything but trivial test cases.  Sometimes
>> > the
>> > program is incredibly slowed when using threads.  Also, Unix and Windows
>> > have to be treated differently, etc. - which is not entirely FPC's
>> > fault.
>> > Making separate applications gives a number of advantages (which I
>> > listed in
>> > my last mail).  The need to send data structures back and forth is the
>> > only
>> > real disadvantage - but that's just trading for synchronization issues.
>> >
>> > As an aside, threads are one area where it seems ObjC has a huge
>> > advantage.
>> > I wish there was a way to just say something like
>> > "RunInBackground(procedure)" in FPC.  Background threads not being able
>> > to
>> > touch the GUI, etc. makes it all but useless for many purposes.  Of
>> > course
>> > for scientific computing type applications where problems can be
>> > partitioned
>> > neatly, threads make perfect sense and work relatively well.  For things
>> > like "I want to save this file in the background while the user
>> > continues to
>> > use the word processor", I've found they aren't anywhere near worth the
>> > trouble to implement in FPC - yet.
>> >
>> > For example, if I want only one instance of a daemon running, then I
>> > have to
>> > make it a separate process (reasonably anyway).  If I want it to be
>> > 64bit,
>> > but the GUI has to be 32bit, then it has to be a separate process, etc.
>> >
>> > I will take a look at your framework, because I am interested in all
>> > sorts
>> > of new developments, but it's unlikely I will re-code everything to use
>> >

Re: [fpc-pascal] Best way to transfer data between applications?

2012-10-31 Thread Jorge Aldo G. de F. Junior
i reiterate that my Pascal-Actor-Model can do exactly what you are saying...

writing a "save file in background" type of actor is trivial, and the
synchronization is already done...

2012/10/31 Noah Silva :
> Hi Aldo,
>
> Well it's not just synch problems with threads, I've found threads to not be
> so reliable under FPC for anything but trivial test cases.  Sometimes the
> program is incredibly slowed when using threads.  Also, Unix and Windows
> have to be treated differently, etc. - which is not entirely FPC's fault.
> Making separate applications gives a number of advantages (which I listed in
> my last mail).  The need to send data structures back and forth is the only
> real disadvantage - but that's just trading for synchronization issues.
>
> As an aside, threads are one area where it seems ObjC has a huge advantage.
> I wish there was a way to just say something like
> "RunInBackground(procedure)" in FPC.  Background threads not being able to
> touch the GUI, etc. makes it all but useless for many purposes.  Of course
> for scientific computing type applications where problems can be partitioned
> neatly, threads make perfect sense and work relatively well.  For things
> like "I want to save this file in the background while the user continues to
> use the word processor", I've found they aren't anywhere near worth the
> trouble to implement in FPC - yet.
>
> For example, if I want only one instance of a daemon running, then I have to
> make it a separate process (reasonably anyway).  If I want it to be 64bit,
> but the GUI has to be 32bit, then it has to be a separate process, etc.
>
> I will take a look at your framework, because I am interested in all sorts
> of new developments, but it's unlikely I will re-code everything to use a
> particular design pattern or framework.
>
> The original question I meant to ask was basically "Is there an easy/mostly
> automatic way to transport data structures between processes", and from all
> the discussion on this list - the answer seems to be "no."  Encoding is one
> piece, data transfer is one piece, and the glue in-between (Class factories,
> etc.) is something one probably has to put together themselves.  Either way,
> it makes everything more complicated to do something that is in principle
> relatively simple.
>
> Thank you,
>  Noah Silva
>
> 2012/10/31 Jorge Aldo G. de F. Junior 
>>
>> Hm...
>>
>> if you gave up using threads because of the problem with
>> synchronization then you might have a look at my pascal-actor-model
>> framework...
>>
>> its a set of classes that implements Hewitt's Actor Model Concurrency
>> and its able to solve exactly that...
>>
>> http://code.google.com/p/pascal-actor-model/
>>
>> Code can run assynchronously or synchronously, depending on your needs.
>>
>> theres a mainthreadqueue that lets actors talk to the main thread
>> (where the GUI elements usually reside) using blocking (with timeout)
>> protocol.
>>
>> All messages are actors and can be streamed across the network, etc..
>> (i am in the process of implementing distributed computing based on
>> that actor model) etc...
>>
>> there are already a lot of components and the basic actor
>> functionality is already working.
>>
>> ___
>> 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Best way to transfer data between applications?

2012-10-30 Thread Jorge Aldo G. de F. Junior
2012/10/30 印場 乃亜 :
> Hi,
>
> Wow, Class Factories - I am having nightmarish flashbacks to my college C++ 
> classes.
>
> Okay, Thank you for all of the suggestions.  I will try to compare the 
> suggestions, and see what I can come up with for my situation.
> Just for further information:
> 1. I wasn't really planning on using the network, so using something that has 
> to pack/unpack the data from FPC to other
formats might be overkill.

For the data delivery part, you can use TSimpleIPCServer/TSimpleIPCClient

> 2. I am happy to pass records, Objects aren't really necessary.  (If you pass 
> an object in binary, the internal pointers would be referencing the old copy 
> anyway).
>

The problem with records is that the data sending/receiving function
must know the record structure in advance, or use a very inflexible
record strucuture (one size fits all), or use a much more complex
protocol with multiple entry points selected by a prefix byte or
something similar.

in the end of the day, classes tends to be simpler to pass around.

Think about this :

Class TA has a property named pname, another property named pvalue.

Instance A is an instance of TA.
Instance B is an instance of TA.

Instance A has the property pname set to 'somename'
Instance A has the property pvalue set to 10

Instance B has the property pname set to 'somename'
Instance B has the property pvalue set to 10

Is A=B ?

If you simply look at the pointer (classes are internally pointers to
data structures in memory), then no, they are different.

But if you look at the values, then they are the same.

What i want to mean ?

If you can, using some IPC/whatever, make a new instance on the other
application, of the same class, with the same values, then (for a very
wide interpretation of the meaning of transporting) you transported
the class from one application to another...even if they are not
exactly the same instance...

that means that you dont need shared memory nor any fancy trick, just
a simple protocol like

   ... 

where classname is used as an index on a class factory and
property1values are used to set the class properties

will do the trick.

(There are some languages that can LITERALLY transfer an instance
between two applications, but Pascal cant due to being statically
typed).

> I was actually considering using the GUI messaging system like exists in 
> Windows, but:
> 1. It doesn't really exists on non-windows systems (I read some about one 
> being created for Lazarus on Linux)

TSimpleIPCServer/TSimpleIPCClient is portable across all FPC targets.

> 2. I seem to recall that it only allowed passing relatively simple messages.  
> I thought perhaps I could use shared memory and then send a message telling 
> the client application to read the record.

Shared memory is usefull when you need to transfer large blocks of
data fast between two instances. I believe pipes are simpler for
simpler tasks (And thats what TSimpleIPCServer/TSimpleIPCClient use).

TSimpleIPCServer/Client are standard components being part of the FCL.
(Freepascal component library). At least they come standard with the
compiler.

>
> Maybe once I examine all the options, I will make a FAQ ;)
>
> Thank you,
>Noah Silva
>
> On 2012/10/30, at 13:37, "Jorge Aldo G. de F. Junior"  
> wrote:
>
>> Ah, and you will need a class factory to register the tpersistent
>> class creators...
>>
>> And i said my unit is neater ?
>>
>> here it is :
>>
>> http://code.google.com/p/pascal-actor-model/source/browse/trunk/rttiobjects.pas
>>
>> I use it on a lot of things...
>>
>> All you need is to declare published properties that you want streamed
>> and use TRTTIObject.SaveRTTIToStream.
>>
>> It will save on a binary format where the first string is the class
>> name. You should have a class factory on the other side that registers
>> all classes that can be exchanged between applications.
>>
>> Pascal being statically typed (and binary creating instead of bytecode
>> creating) means that you cannot "slurp" an object from one application
>> to another (IE.: Stream an unknown object around).
>>
>> Each class should be know in advance by both applications.
>>
>> 2012/10/30 Jorge Aldo G. de F. Junior :
>>> Simple solution :
>>>
>>> Use TSimpleIPC components + my own RTTIObjects unit.
>>>
>>> All messages must be descendants of TRTTIObject. (You can use
>>> TPersistent, but i believe my unit is neater for this specific task).
>>>
>>> Well, using only standard components i believe you should use
>>> TSimpleIPC components + TPersistent classes
>>>
>>> All you need is a way to stream the T

Re: [fpc-pascal] Best way to transfer data between applications?

2012-10-29 Thread Jorge Aldo G. de F. Junior
Ah, and you will need a class factory to register the tpersistent
class creators...

And i said my unit is neater ?

here it is :

http://code.google.com/p/pascal-actor-model/source/browse/trunk/rttiobjects.pas

I use it on a lot of things...

All you need is to declare published properties that you want streamed
and use TRTTIObject.SaveRTTIToStream.

It will save on a binary format where the first string is the class
name. You should have a class factory on the other side that registers
all classes that can be exchanged between applications.

Pascal being statically typed (and binary creating instead of bytecode
creating) means that you cannot "slurp" an object from one application
to another (IE.: Stream an unknown object around).

Each class should be know in advance by both applications.

2012/10/30 Jorge Aldo G. de F. Junior :
> Simple solution :
>
> Use TSimpleIPC components + my own RTTIObjects unit.
>
> All messages must be descendants of TRTTIObject. (You can use
> TPersistent, but i believe my unit is neater for this specific task).
>
> Well, using only standard components i believe you should use
> TSimpleIPC components + TPersistent classes
>
> All you need is a way to stream the TPersistent into a string or
> stream then pass that resulting string/stream to the simple ipc
> components.
>
> That will do what you are asking, without much fuss...
>
> 2012/10/30 印場 乃亜 :
>> Hi,
>>
>> I read about MSGPACK before, but it seems to be a binary version of JSON, 
>> right?
>> I actually don't care about the protocol much (and since it's local, Binary 
>> vs. text wouldn't make a lot of difference in transfer speed - though using 
>> FPC  native data structures would be faster since they wouldn't have to be 
>> converted to an external format).
>>
>> The problem isn't just the transfer format, but the whole process.
>>
>> For example, I want to have something like the unix message (Signal) system 
>> that allows me to send not just an Integer, but any random data.
>>
>> For example, let's say I have a daemon running that receives chat messages 
>> (or something) and then it wants to send the data to the GUI, so it would 
>> call something like:
>>
>> SendDataToApplication(Gui_App, ChatDataRecord);
>>
>> Obviously, I could manually encode that data into JSON or CSV (or msgpack) 
>> and manually send it to the other app by IPC and manually decode it on the 
>> other side.  What I want is some system that will know that the incoming 
>> message is of type TCharDataRecord (or whatever) and automatically let me 
>> use that type (and not forced typecasting with pointers, etc. - but 
>> properly).  Obviously there would be limitations to any solution - for 
>> example, I would have to have the same types available on both sides, etc.
>>
>> I will take a look at msgpack, though, to make sure it can't do the above, 
>> though.  What little JSON I have done in FPC, I have done manually thus far, 
>> so perhaps I need to learn the capabilities of the real units before asking 
>> more.
>>
>> Mainly my question was asking if there is a "standard" way to do this, since 
>> it seems like a common thing to need to do.
>>
>>  Thank you,
>> Noah Silva
>>
>> On 2012/10/29, at 18:00, ik  wrote:
>>
>>> On Mon, Oct 29, 2012 at 5:52 AM, 印場 乃亜  
>>> wrote:
>>>> Greetings,
>>>>
>>>> I am familiar with the basic underlying methods available for transferring 
>>>> data between processes on Windows and Unix, i.e. Pipes, Shared memory, and 
>>>> TCP/IP - but what I am not familiar with is any higher level functionality 
>>>> that may be available on FPC.
>>>>
>>>> As an example:  I have one application with a daemon that uses the IPC 
>>>> component to write to a file in CSV format, and then the user application 
>>>> reads this (GPS location) data via IPC.  Then I have to re-convert this 
>>>> string data into a series of floating point values manually, though.  The 
>>>> IPC component doesn't seem to be reliable on all platforms either (it 
>>>> sometimes blocks on OS X, and at least the debug client doesn't seem to 
>>>> work at all on Windows 7).
>>>>
>>>> Another disadvantage is that the sequence of launching the applications 
>>>> matters, and what's more, it seems there can only be one "client" per 
>>>> "server" in many cases.
>>>>
>>>> More to the point, if I want to pass around stru

Re: [fpc-pascal] Best way to transfer data between applications?

2012-10-29 Thread Jorge Aldo G. de F. Junior
Simple solution :

Use TSimpleIPC components + my own RTTIObjects unit.

All messages must be descendants of TRTTIObject. (You can use
TPersistent, but i believe my unit is neater for this specific task).

Well, using only standard components i believe you should use
TSimpleIPC components + TPersistent classes

All you need is a way to stream the TPersistent into a string or
stream then pass that resulting string/stream to the simple ipc
components.

That will do what you are asking, without much fuss...

2012/10/30 印場 乃亜 :
> Hi,
>
> I read about MSGPACK before, but it seems to be a binary version of JSON, 
> right?
> I actually don't care about the protocol much (and since it's local, Binary 
> vs. text wouldn't make a lot of difference in transfer speed - though using 
> FPC  native data structures would be faster since they wouldn't have to be 
> converted to an external format).
>
> The problem isn't just the transfer format, but the whole process.
>
> For example, I want to have something like the unix message (Signal) system 
> that allows me to send not just an Integer, but any random data.
>
> For example, let's say I have a daemon running that receives chat messages 
> (or something) and then it wants to send the data to the GUI, so it would 
> call something like:
>
> SendDataToApplication(Gui_App, ChatDataRecord);
>
> Obviously, I could manually encode that data into JSON or CSV (or msgpack) 
> and manually send it to the other app by IPC and manually decode it on the 
> other side.  What I want is some system that will know that the incoming 
> message is of type TCharDataRecord (or whatever) and automatically let me use 
> that type (and not forced typecasting with pointers, etc. - but properly).  
> Obviously there would be limitations to any solution - for example, I would 
> have to have the same types available on both sides, etc.
>
> I will take a look at msgpack, though, to make sure it can't do the above, 
> though.  What little JSON I have done in FPC, I have done manually thus far, 
> so perhaps I need to learn the capabilities of the real units before asking 
> more.
>
> Mainly my question was asking if there is a "standard" way to do this, since 
> it seems like a common thing to need to do.
>
>  Thank you,
> Noah Silva
>
> On 2012/10/29, at 18:00, ik  wrote:
>
>> On Mon, Oct 29, 2012 at 5:52 AM, 印場 乃亜  wrote:
>>> Greetings,
>>>
>>> I am familiar with the basic underlying methods available for transferring 
>>> data between processes on Windows and Unix, i.e. Pipes, Shared memory, and 
>>> TCP/IP - but what I am not familiar with is any higher level functionality 
>>> that may be available on FPC.
>>>
>>> As an example:  I have one application with a daemon that uses the IPC 
>>> component to write to a file in CSV format, and then the user application 
>>> reads this (GPS location) data via IPC.  Then I have to re-convert this 
>>> string data into a series of floating point values manually, though.  The 
>>> IPC component doesn't seem to be reliable on all platforms either (it 
>>> sometimes blocks on OS X, and at least the debug client doesn't seem to 
>>> work at all on Windows 7).
>>>
>>> Another disadvantage is that the sequence of launching the applications 
>>> matters, and what's more, it seems there can only be one "client" per 
>>> "server" in many cases.
>>>
>>> More to the point, if I want to pass around structures, records, 
>>> etc.between processes - what is the best day?  For example, Javascript uses 
>>> JSON.  I know there are JSON libraries and various other libraries for 
>>> Pascal - but I don't know what is the most standard way.  (I think this 
>>> kind of marshalling/unmarshalling may be more standard in Java and C#, but 
>>> I don't know the "normal" way in Delphi/FPC).
>>>
>>> I would prefer to use built-in functionality, rather than learn yet another 
>>> library - and if learning a library, I would prefer to use one with lots of 
>>> users that is actively maintained.  Likewise, I would prefer to actually 
>>> "pass" the data, rather than just pass a pointer to it.  I plan to have the 
>>> processes run on the same machine, so I don't need a solution that works 
>>> with networking, though that would be fine, of course.
>>>
>>> Along the same lines, a convenient way to call functions/procedures with 
>>> parameters from the "other" process would be greatly appreciated.  (i.e. 
>>> something like RPC that handles OOP).
>>
>> I'm writing at the moment support for msgpack (http://msgpack.org/) in
>> plain FPC (object pascal style):
>> https://github.com/ik5/fp-msgpack
>>
>> I will also implement the rpc version.
>>
>> MsgPack allow you to take data, including JSON and convert it into
>> bytes that represent the data.
>> It contain smaller version of the same way that JSON does it for example.
>>
>>
>>>
>>> Thank you,
>>> Noah Silva
>>>
>>>
>>> ___
>>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Best way to transfer data between applications?

2012-10-29 Thread Jorge Aldo G. de F. Junior
I have a very simple unit that uses RTTI to stream class instances to
and from strings/streams.

i believe this is an easy foundation on wich to develop something
along the lines of what you are trying to do

2012/10/29 Frank Church :
>
>
> On 29 October 2012 09:43, Michael Van Canneyt 
> wrote:
>>
>>
>>
>> On Mon, 29 Oct 2012, 印場 乃亜 wrote:
>>
>>> Greetings,
>>>
>>> I am familiar with the basic underlying methods available for
>>> transferring data between processes on Windows and Unix, i.e. Pipes, Shared
>>> memory, and TCP/IP - but what I am not familiar with is any higher level
>>> functionality that may be available on FPC.
>>>
>>> As an example:  I have one application with a daemon that uses the IPC
>>> component to write to a file in CSV format, and then the user application
>>> reads this (GPS location) data via IPC.  Then I have to re-convert this
>>> string data into a series of floating point values manually, though.  The
>>> IPC component doesn't seem to be reliable on all platforms either (it
>>> sometimes blocks on OS X, and at least the debug client doesn't seem to work
>>> at all on Windows 7).
>>>
>>> Another disadvantage is that the sequence of launching the applications
>>> matters, and what's more, it seems there can only be one "client" per
>>> "server" in many cases.
>>>
>>> More to the point, if I want to pass around structures, records,
>>> etc.between processes - what is the best day?  For example, Javascript uses
>>> JSON.  I know there are JSON libraries and various other libraries for
>>> Pascal - but I don't know what is the most standard way.  (I think this kind
>>> of marshalling/unmarshalling may be more standard in Java and C#, but I
>>> don't know the "normal" way in Delphi/FPC).
>>>
>>> I would prefer to use built-in functionality, rather than learn yet
>>> another library - and if learning a library, I would prefer to use one
>>> with lots of users that is actively maintained.  Likewise, I would prefer
>>> to actually "pass" the data, rather than just pass a pointer to it.  I
>>> plan to have the processes run on the same machine, so I don't need a
>>> solution that works with networking, though that would be fine, of
>>> course.
>>>
>>> Along the same lines, a convenient way to call functions/procedures with
>>> parameters from the "other" process would be greatly appreciated.  (i.e.
>>> something like RPC that handles OOP).
>>
>>
>> You should try WST.
>>
>> It's perfectly suitable for all this. It is actively used and maintained.
>> You can choose which encoding (binary, soap, JSON) is used, and which
>> protocol (Direct library, TCP socket, http).
>>
>> Michael.
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
>
> I have to second Michael's response. Inoussa discussed on some thread some
> time back and in fact I am lookiing to read it again.
> Does anyone recall that thread?
> --
> Frank Church
>
> ===
> http://devblog.brahmancreations.com
>
> ___
> 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] Function for checking correct file name

2012-09-16 Thread Jorge Aldo G. de F. Junior
Like i said earlier, i dont know why he needs to check the filename.

Let me explain :

There are two situations you are describing here :

1 - When the user invokes an application that executes a task on user
behalf, using data suplied by the same user.

This first situation is correctly treated by the underlying OS,
because it IS on the OS realm to determine who can access what. (It is
part of the OS security model).

The problem is, if your application is running using the security
permissions of the invoking user, then you dont need to "check correct
file name", all you can end up needing to do is to check if some file
exists (fileexists()) or if the passed filename is indeed a correct
file name (wich can be determined by simply trying to execute the task
and checking for errors). In that case theres no need to validate
filenames, the user should know better.

2 - When the application is running on behalf of one user but using
data supplied by another user. Thats where the security problem
happens. In that case the underlying OS security model, usually, have
a problem, and thats, usually, why you need to validate filenames.
This happens on FTP servers, HTTP servers and in a lot of other cases.
This is similar to SQL injection and a lot of other cases of security
flaws. The morale is that you should take with a grain of salt
everything comming from the user.

If he is validating a filename because of that case, then, a
half-baked 10 line function wont cut. THIS IS A SECURITY RISK.

You need a full fledged parser and macro expander.

Thats why i believe such a function should be added to freepascal RTL.
A good windows programmer wont know all the caveats of (for one)
MacOSX or other platforms.

Oh and thanks for calling me idiotic. IIS developers would think the
same about my caution.

2012/9/16 Jürgen Hestermann :
>
> Am 2012-09-15 23:48, schrieb Jorge Aldo G. de F. Junior:
>
>> This is a security risk, because, if the function isnt almost perfect,
>> someone could end up reading the passwords file (security.sam on
>> windows ? whatever im not a windows programmer) or rewriting criticial
>> files on a system.
>
> You mean all programmers in the world need to know all OS security leaks and
> have to program workarounds for these security leaks?
> That's completely idiotic because if security is based on this there is no
> security at all.
>
> ___
> 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] Function for checking correct file name

2012-09-15 Thread Jorge Aldo G. de F. Junior
Vinzent, i dont know why you need to check the filename - would
fileexists() be enough ? - but i suspect that you already know about
that function, so, if you need something more complex, i *feel* that
it is something related to security.

Supose you wrote a webserver (or whatever thing similar for that
matter) and you need to be sure that users can only access files
located at c:\htmlpages.

This is a security risk, because, if the function isnt almost perfect,
someone could end up reading the passwords file (security.sam on
windows ? whatever im not a windows programmer) or rewriting criticial
files on a system.

I believe that you already know that, but thats why i asked if others
are considering the security risk involved in filenames.

For evidence sake look at this old IIS bug :

http://www.hackingspirits.com/eth-hac/papers/iis_uni.html

Morale : Filenames can be nasty and filename checking functions tend
to be complex...

You will need one function for each freepascal target (If you aim at
portability).

I believe this can be solved by writing a parser (using a BNF notation
of the target filesystem structuring) and a interpreter to expand all
the macros possible, without letting the OS even come close to the
filename before its sanitized.

That, if i understood your question correctly.

Sorry if i misunderstood.

On a side note : I believe FreePascal should add such filename
sanityzing function on future versions (a multiplatform one) to avoid
this.

2012/9/15 Vinzent Höfler :
> On Sat, 15 Sep 2012 11:20:53 +0200, Sven Barth 
> wrote:
>
>> On 14.09.2012 17:44, Graeme Geldenhuys wrote:
>>>
>>> On 14/09/12 13:48, Krzysztof wrote:

 I just quicky googled not allowed characters and wrote this simple
 function:
>>>
>>>
>>> Also in Windows (as far as I know), file names my not be longer than 255
>>> characters. So you will have to check the length of AFilename parameter
>>> too.
>>
>>
>> It depends. If you use normal "C:\bla\bla" notation you are right, but if
>> you access the NT namespace (which you can do from within the WinAPI) you
>> can use paths with up to 32767 characters. You need to use this notation
>> though: "\\?\C:\bla\bla" (in this case you MUST use "\" though as "/" is not
>> converted here).
>
>
> Careful. There's a difference between file/component length and path length.
>
>
>> For more information see here:
>> http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath
>
>
> |This type of path is composed of components separated by backslashes,
> |each up to the value returned in the lpMaximumComponentLength parameter
> |of the GetVolumeInformation function (this value is commonly 255
> characters).
>
> So, although the path may be up to 32767 characters in length, each
> component
> of the path can no longer than 255 characters. This includes the file name.
>
>
> Vinzent.
>
> --
> The most likely way for the world to be destroyed, most experts agree,
> is by accident. That's where we come in; we're computer professionals.
> We cause accidents.
> -- Nathaniel Borenstein
>
> ___
> 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] Function for checking correct file name

2012-09-14 Thread Jorge Aldo G. de F. Junior
am i the only one seeing a security risk here ?

2012/9/14 Vinzent Höfler :
> On Fri, 14 Sep 2012 14:48:08 +0200, Krzysztof  wrote:
>
>> I just quicky googled not allowed characters and wrote this simple
>> function:
>
>
> Seems, you found one of the many (I'd suspect) wrong search results.
>
>
>> function IsValidFilename(const AFilename: String): Boolean;
>> var
>>   c: set of Char = ['<','>',':','"','/','\','|','?','*', '%', '.'];
>
>
> Really?
>
> |>copy con "a.b.c.%def"
> |test
> |^Z
> |1 Datei(en) kopiert.
> |
> |>type "a.b.c.%def"
> |test
> |
> |>dir a.*
> |[...]
> |
> |14.09.2012  18:08 6 a.b.c.%def
>
> And, actually, disallowing the '.' in a filename is really stup^Wshort-
> sighted. Most files out there in the wild contain at least one.
>
>
> Vinzent.
>
> --
> The most likely way for the world to be destroyed, most experts agree,
> is by accident. That's where we come in; we're computer professionals.
> We cause accidents.
> -- Nathaniel Borenstein
>
> ___
> 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] Re: Delphi's anonymous functions in Free Pascal

2012-08-30 Thread Jorge Aldo G. de F. Junior
I still fail to see where annonymous functions could succeed where
functional types (part of pascal since last millenia) wouldnt...

2012/8/30 Ralf A. Quint :
> At 01:18 AM 8/30/2012, Arioch wrote:
>
>> tcoq wrote
>> >
>> >  a laziness to software design: what you can't name you actually don't
>> > design...
>> >
>> Guess you meant "don't want to" instead of "can't"
>> And You mean all the non-named arrays, don't you.
>>
>> "var x: array[0..10] of integer; " is not only violating Pascal Report,
>> but
>> also is twice lazy.
>> since one should name every part of design one should type like
>>
>> type
>> SomeEnumSemanticName = 0..10;
>> SomeEnumMapSemanticName = array[SomeEnumSemanticName] of integer;
>> var x: SomeEnumMapSemanticName;
>>
>> That has a point, for self-documenting if nothing else. But i don't
>> believe
>> it is practically that pervasive as your stated maxima would assume.
>
>
> Sorry, but that example of yours is silly at best. Someone who has learned
> to program in Pascal should be able write clearly understandable programs,
> not obfuscate just for 'the heck of it'.
> But then common sense seems to have turned into a rare commodity these days.
>
> Pascal has evolved since Wirth's original design back in the 70s, nobody is
> writing serious programs in the original defined language set anymore, I
> dare to day that even ISO Pascal is not all that useful for real life
> programs anymore.
>
> A lot of extensions, like units or (objects in general) that you mentioned
> have been done in a way that still leave the very basics of Pascal intact.
> But all the fluff that you (and others) are proposing all the time just aim
> at completely change the language for no other than self-serving reasons and
> that's why people rightfully oppose such proposals...
>
> Ralf
> ___
> 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


[fpc-pascal] TObjectQueue with ability to dequeue arbitrary positions

2012-08-24 Thread Jorge Aldo G. de F. Junior
while working on my actor model concurrency for freepascal i met the
following problem.

Each actor has a mailbox, that is made of the following components :

A standard TObjectQueue wich holds the messages
A TMultiReadExclusiveWriteSynchronizer that avoids race conditions
while acessing the TObjectQueue.
A TEventObject that is used to signalize when a new object is pushed
into the queue. Usefull if the actor wants a message but the queue is
empty. (Writer triggers the signal and the reader sleeps until the
signal is received).

Well, the problem i hit is the following :

Each message has a transactionID value that is used to differentiate
among transactions. This is usefull when you need a synchronous
transfer to happen on the fully assynchronous actor model.

An actor sends a request message and waits for a response message,
both with the same transaction id.

While developing this framework i set myself the task of making it
with two guarantees that are not much common on other actor model
implementations :

Guaranteed message order and Guaranteed message delivery.

well well, thats where i need a TObjectQueue with ability to
dequeue/inspect arbitrary positions :

When the object issues request it has to keep looping (until timeout)
and dequeueing the last message from the mailbox, inspecting its
transaction id for a match and requeueing the same message back into
the mailbox if theres no match.

Thats the problem. When messages are requeued i lose message order
guarantees (Very usefull). They are still guaranteed to be delivered,
but not in order anymore.

Finishing the long story, i need a TObjectQueue that can
access/extract arbitrary positions so as to avoiding losing the order
of message delivery.

Does anybody have one already done/debugged and in GPL license ?

Thanks in advance,
J. Aldo.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
Edit myunit.pas

Unit myunit.pas; <- backspace backspace backspace

Unit mynewunit.pas;

Alt-S Alt-X

Ren myunit.pas mynewunit.pas

No collisions now !

2012/8/21 Marcos Douglas :
> On Tue, Aug 21, 2012 at 11:13 PM, Jorge Aldo G. de F. Junior
>  wrote:
>> "Yes, we know too... but how prevent this using third-party libs?
>> For example, what do you think if I have a project that have a file
>> called lnet.pas? Can I use this identifier? I think so... WAIT, I
>> can't because the lnet project already uses, right? But I didn't know
>> before...ohh my... and now, I can't use this project because I will
>> got a compiler error because "cant have two units with the same name".
>> Do you think this is right?
>> Because of this conflict that I proposed the syntax:"
>>
>> How many times this actually did happen ?
>
> Depends how many third-party libs do you use in a single project.
> Ah, I'm not talking about just open and famous libs, but any one!
> For example: In a company we can have many departments; each
> department can have your own lib; each department can choose the names
> of your own identifiers and here is the problem.
> I had many problems using Object Pascal (Delphi) a long time ago.
>
>> I never seen that before...
> Do you use many third-party libs?  ;-)
>
> Marcos Douglas
> ___
> 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] Re: How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
"Yes, we know too... but how prevent this using third-party libs?
For example, what do you think if I have a project that have a file
called lnet.pas? Can I use this identifier? I think so... WAIT, I
can't because the lnet project already uses, right? But I didn't know
before...ohh my... and now, I can't use this project because I will
got a compiler error because "cant have two units with the same name".
Do you think this is right?
Because of this conflict that I proposed the syntax:"

How many times this actually did happen ?

I never seen that before...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
the alias is the fully qualified function name :

myunit1.function1()
myunit2.function2()

you dont need alias, cause you cant have two units with the same name,
so you have two different fully qualified function names.

The warning would simply point out that there are two functions with
the same name and parameters in the current scope, because thats the
only possible conflict.

Requiring all functions to be allways fully qualified will make the
most commom case worse than current implementation just to be better
for the uncommon case. This is a step back, not forward...

2012/8/21 Marcos Douglas :
> On Tue, Aug 21, 2012 at 5:19 PM, Marcos Douglas  wrote:
>> On Tue, Aug 21, 2012 at 4:42 PM, Jorge Aldo G. de F. Junior
>>  wrote:
>>> 2012/8/21 Marcos Douglas :
>>>> On Tue, Aug 21, 2012 at 3:08 PM, Marco van de Voort  
>>>> wrote:
>>>>> In our previous episode, Marcos Douglas said:
>>>>>
>>>>>> I proposed this sintaxe:
>>>>>> uses my_long_unit_name as my;
>>>>>> begin
>>>>>>   my.proc();
>>>>>> end
>>>>>
>>>>> This doesn't protect any better, since
>>>>> the new unit might also define "my".
>>>>
>>>> True, but using this sintaxe I can use an alias to the third-party
>>>> units so, I can use my own names to reference identifiers that I can
>>>> not change.
>>>> The collision still can exists? Yes, but in that case the programmer
>>>> would be wrong, not third-party unit names or because the compiler not
>>>> helped.
>>>>
>>>> The third-party could use a better and bigger name like "XyzNetSocket"
>>>> but I could use just "net" (uses XyzNetSocket as net), for example.
>>>>
>>>> IMHO this is more sophisticated than pure namespace.
>>>
>>> Instead of implementing the half-assed C++ namespace model, just add
>>> to the compiler a warning when it detects that there is a collision in
>>> the current scope (two functions with the same parameters from
>>> different units that can be called from the scope being inspected). I
>>> believe function overload alread provides the necessary hooks, but i
>>> cant do it because i have zero experience with FPC sources...
>>
>> Well, a good idea but this is another thing...
>> This is do not resolves the problem if I have a third-party unit with
>> the same name that other.
>
> ...continue:
> If I can use an alias to ref an unit, the names could be bigger
> because I can ref them only using the alias.
>
> Extend the concept:
> if nevertheless we have same names in two libs (eg: foounit), we could use:
> uses
>   foounit as f1 in '/path_1/foounit.pas',
>   foounit as f2 in '/path_2/foounit.pas';
>
> IMHO, would be PERFECT.
>
> Marcos Douglas
> ___
> 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] How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
Instead of implementing the half-assed C++ namespace model, just add
to the compiler a warning when it detects that there is a collision in
the current scope (two functions with the same parameters from
different units that can be called from the scope being inspected). I
believe function overload alread provides the necessary hooks, but i
cant do it because i have zero experience with FPC sources...

2012/8/21 Marcos Douglas :
> On Tue, Aug 21, 2012 at 3:08 PM, Marco van de Voort  wrote:
>> In our previous episode, Marcos Douglas said:
>>
>>> I proposed this sintaxe:
>>> uses my_long_unit_name as my;
>>> begin
>>>   my.proc();
>>> end
>>
>> This doesn't protect any better, since
>> the new unit might also define "my".
>
> True, but using this sintaxe I can use an alias to the third-party
> units so, I can use my own names to reference identifiers that I can
> not change.
> The collision still can exists? Yes, but in that case the programmer
> would be wrong, not third-party unit names or because the compiler not
> helped.
>
> The third-party could use a better and bigger name like "XyzNetSocket"
> but I could use just "net" (uses XyzNetSocket as net), for example.
>
> IMHO this is more sophisticated than pure namespace.
>
> Marcos Douglas
> ___
> 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] Network mutex

2012-08-21 Thread Jorge Aldo G. de F. Junior
You could implement such a thing using my Pascal-Actor-Model classes.

Simple TCP streams (or UDP with added guarantees) and a central actor
that decides who use what.

http://code.google.com/p/pascal-actor-model/

theres an udp sender/receiver actor that share a socket to send and
receive messages.

You will need to implement guarantees of packet delivery using counters etc.

the mailbox model used on actors guarantee that only one computer will
use the resource, because the mailbox is a FIFO.

All actors run assynchronously.

Theres a call called request() that can synchronize two actors. Thats
where you can implement a network mutex/semaphore. (Request sleeps up
to timeout until the reply comes, all messages are sent into a fifo,
so if two instances request the same thing, one of them will sleep
until the first to come is serviced).

i need to implement the class serializer/deserializer because in the
long run i plan to implement distributed computing. A serializer is
already done, but is not in actor format yet. After that i will need
to implement some distributed helpers. There is already a round robin
load balancer.

But i believe the foundation for what you want is already implemented.

Bear in mind that the problem you proposed is trivial with lnet or
synapse. Its just a network service that can be done in a couple of
hours using those libraries.

2012/8/21 Fabio Luis Girardi :
> Hi!!
>
> I'm searching about Network mutex/semaphore. The main idea is avoid
> multiple computers (running applications built with FPC) access at the
> same time a single network resource (like a PLC). The only solution at
> the moment is use a DB with transactions, but this is a non elegant
> solution.
>
> So, anyone knows if FPC or other library provides this functionality?
>
> --
> The best regards,
>
> Fabio Luis Girardi
> ___
> 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] Re: How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
I already know that you can fully qualify, i believe you misread my post.

Its not that common to have name colisions if you use prefixes like i said.

I cant see how the added complexity of full name space support would
help pascal in that regard.

2012/8/21 Sven Barth :
> Am 21.08.2012 14:10, schrieb Jorge Aldo G. de F. Junior:
>
>> "With no error messages, or even with no changes to the program since 1
>> and a half year in the repository, the scientific calculations are now
>> all blown up, and program outputs only errors at runtime. The maintainer
>> now curses and chases me for having the nerve to leave a program
>> known as working in such a horrible mess in the repository."
>>
>> Never tested, but doesnt the compiler warn of the colision ? if not, it
>> should.
>>
>> Usually i prefix my symbols with some meaningfull prefixes to avoid
>> collision. I never have two symbols with the same name and i hardly
>> used unit prefixes in the past.
>>
>> But a collision warning from the compiler would be helpfull.
>
>
> Units provide a namespace, so UnitA.Foo is not the same as UnitB.Foo. Thus
> it is perfectly allowed and valid and sometimes also common to have a
> collision here. [also the compiler stops looking for further symbols if it
> has found the first one => one of the reasons for the high compilation
> speed]
>
> Regards,
> Sven
>
>
> ___
> 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] Re: How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
"With no error messages, or even with no changes to the program since 1
and a half year in the repository, the scientific calculations are now
all blown up, and program outputs only errors at runtime. The maintainer
now curses and chases me for having the nerve to leave a program
known as working in such a horrible mess in the repository."

Never tested, but doesnt the compiler warn of the colision ? if not, it should.

Usually i prefix my symbols with some meaningfull prefixes to avoid
collision. I never have two symbols with the same name and i hardly
used unit prefixes in the past.

But a collision warning from the compiler would be helpfull.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: How to avoid namespace name clashes after USES ?

2012-08-21 Thread Jorge Aldo G. de F. Junior
I am trying hard to think of a situation where unit prefixes are not
enough, but its hard to see.

2012/8/21 Timothy Madden :
> On 08/21/2012 02:17 PM, DaWorm wrote:
>> Very tedious, but you could create a wrapper unit and/or class for each
>> library, and expose a prefixed name instead of the original.
>
> Very ingeniuos, I believe this is as close to a solution as I can get
> for now.
>
> But there are still a few probles I can see:
>- there is no way to "prefix" symbols within a unit, that I know of.
>  Symbols may only be prefixed by the unit name directly. Is there a
>  sort of a "namespace" in Pascal ?
>- if I make a wrapper unit around the third-party one, there is
>  alredy little need for a prefix, since I can expose only the
>  symbols I know of and that I use.
>- I find it even more tedious to do the same thing with the System
>  unit or the standard Pascal units.
>
> And then, if wrapper unit publicly uses the third-party unit, doesn't
> that mean that all symbols in the thrid-party unit are now automatically
> exposed and public in the wrapper unit ?

Nope, you can "uses" in the implementation section AND if a unit uses
a third unit, the third unit identifiers are not visible in the
program..

Unit a:
Interface
Uses b;
Implementation
End.

Unit b;
Interface
Type z=integer;
implementation
end.

program c;
uses a;
var
  h: z;
begin
end.

Type Z is not visible in program c, generating an error.

>
> If so, is there a way to expose and make public the types, classes,
> variables and functions from a private (implementation) unit ?
>
> Thank you,
> Timothy Madden
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Types, consts, variables, classes, functions, procedures etc, are
public if they are defined in the interface section, and private if
they are defined in the implementation section.

A unit/program imports the interface definitions of another unit if it
uses then in their own interface section.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Get all caller adresses of a given function/procedure before executing

2012-08-16 Thread Jorge Aldo G. de F. Junior
If passrc changes, so can ABI and whatever else method you use change too...

If i was going to start a project now with multilanguage suport i
would search for a existing solution or start a new project based on
passrc.

I dont see how can searching for strings be so hard, you dont even
need a full fledged parser to do that... having passrc is handy
because its something standard and already done.

I believe such a tool written using passrc would limit itself to parse
each source file, put each string found into a global string list and
replace string instances with a call to a global function like
GetMyString() with the string entry numer as parameter...

I would even export such strings to an external file to allow fast,
on-the-fly, language selection...

IIRC this is called string pool.

but thats my two cents...


2012/8/16 Rainer Stratmann :
> Am Thursday 16 August 2012 12:23:00 schrieb Jorge Aldo G. de F. Junior:
>> I still dont understand why dont you hack passrc and grab all the
>> strings from the source ?
>
> Because I have an almost finished solution. I worked already for a while on
> it. Some integrated piece of code is easier to handle for me than using a
> tool which requires (an) additional step(s) and may can change its behaviour
> in the future. In the last case even more (demotivating) work has to spend on
> it.
>
>> You can even replace them with identifiers and do all the resource
>> string mumbo jumbo automatically if you write a app to do this based
>> on passrc...
>
> This is more complex than own code that I know best and can change to my needs
> quickly if it there is a need for.
>
>> Actually, why theres no such tool included with freepascal already ?
>> (there is ?)
> ___
> 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] Re: Get all caller adresses of a given function/procedure before executing

2012-08-16 Thread Jorge Aldo G. de F. Junior
I still dont understand why dont you hack passrc and grab all the
strings from the source ?

You can even replace them with identifiers and do all the resource
string mumbo jumbo automatically if you write a app to do this based
on passrc...

Actually, why theres no such tool included with freepascal already ?
(there is ?)

2012/8/16 Rainer Stratmann :
> Am Thursday 16 August 2012 11:27:08 schrieb Rainer Stratmann:
>> Customers are fully satisfied and know about my fast responce.
> response
>
> ___
> 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] linux: should we hard-code versioned or unversioned shared libraries in our apps?

2012-08-15 Thread Jorge Aldo G. de F. Junior
But creating correct symlinks IS one of the tasks of a system
administrator... His up to know the distro he is using and the
software he wants to install.

I bet a "in the field" sysadmin will be much more flexible than a
hardcoded implementation that would need to take zillions of obscure
distros in consideration from the limited perspective of compile
time...

2012/8/15 Graeme Geldenhuys :
> Hi,
>
> This issue has come up before in a fcl-db discussion regarding the
> Firebird Database, where the libfbclient.so was missing from many
> Linux distros (eg: Ubuntu 10.04), but a libfbclient.so.2.0 was
> available instead. FCL-DB only checks for the unversioned shared
> libraries, thus your application will probably not run out of the box.
>
> I've stumbled across this problem again today with OpenSUSE 12.1 and
> Synapse where I send emails from inside my applications via a secure
> SMTP connection. The Synapse library is looking for libssl.so, but by
> default OpenSUSE only has libssl.so.1.0.0.
>
> In both these cases, I manually created unversioned symlinks to those
> libraries, and that got my applications working again. This is not
> ideal, but I don't know how else to handle this.
>
> Does any body know what is the "most correct" way of handling this? Am
> I supposed to modify my copies of fcl-db and synapse to look for
> specific versions of these shared libraries, or should I somehow add
> a function in my application installation that checks in unversioned
> shared libraries exist, and if not, try and create those (which would
> require root access - and might cause problems an client installs).
>
> Anybody know of any Linux documentation URL that explain when
> unversioned shared libraries are used and when not, and how
> applications are supposed to handle this?
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
> ___
> 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] Re: Get all caller adresses of a given function/procedure before executing

2012-08-15 Thread Jorge Aldo G. de F. Junior
"And a
disadvantage is may the longer time to find a solution."

Thats not the only disadvantage. Reinventing the wheel usually means
you get something less correct and less researched. Its simple, 1000
eyes looking for a bug into a standard library will spot much more
problems than your lone eye looking for a bug into your own
implementation.

2012/8/15  :
> On Wed, Aug 15, 2012 at 10:20:34AM +0200, Reinier Olislagers wrote:
>> On 15-8-2012 10:08, Rainer Stratmann wrote:
>> > Am Wednesday 15 August 2012 09:59:00 schrieb Lukasz Sokol:
>> >> On 15/08/2012 08:33, Rainer Stratmann wrote:
>> >>> Am Wednesday 15 August 2012 03:52:00 schrieb waldo kitty:
>>  the loading code simply
>>  chooses the proper po file and then loads the strings into an array or
>>  whatever using the same variables which are used everywhere no matter
>>  what language their contents are written in...
>> >>>
>> >>> Do you need a separate pascal identifier for each snippet?
>> >>>
>>  i must still be missing something :?
>> >>
>> >> No with (dx)gettext you don't need pascal identifiers for every string.
>> >> And the translating function is _():string;
>> >> So all you do is writeln(_('snippet1'));, to follow your convention.
>> >>
>> >> So it more or less uses the same idea as you are trying to replicate.
>> >>
>> > Yes, that is possible as I understand it so far.
>> > I did not know (dx)gettext before so replication is may not the right word.
>> Yes, it is. Replication is doing the same thing twice, regardless of the
>> reasons/knowledge behind that fact.
>
> I'm not sure about that since replication isn't really a word, although it
> has crept into the English language. I look at it from a results POV rather
> from an action POV. Replication is about producing copies of the same
> result. You can do a similar action multiple times (duplication) and produce
> a dissimilar result. That wouldn't be replicating anything, it would just be
> a duplication of effort.
>
> >From a database POV (which is how I know what little I know about
> replication since I was involved in a project to do this in the early 1990s
> before the whole db replication thing got so commonplace) the word
> replication means not that anything was done more than once, but that the
> one result was propagated to multiple places. So it seems to me replication
> is about multiple result instances, not multiple action instances.
>
> --
> _ _
> ._ _ _ <_> ___  _ _  ___  ___  ___  _| | ___
> | ' ' || |/ | '| '_>/ . \/ | '/ . \/ . |/ ._>
> |_|_|_||_|\_|_.|_|  \___/\_|_.\___/\___|\___.
>
>
> ___
> 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] Re: Get all caller adresses of a given function/procedure before executing

2012-08-14 Thread Jorge Aldo G. de F. Junior
Why not scan the code with passrc, find the strings, build a table and
then replace the strings with calls to a function that does the
translation ?

your hack sounds like a maintenance nightmare... Thats what a C
programmer would do and then boast about his programming skills, just
to later discovar that his solution is nor portable nor safe...

2012/8/14 Rainer Stratmann :
> Am Tuesday 14 August 2012 14:36:44 schrieb Martin:
>> On 14/08/2012 13:19, Rainer Stratmann wrote:
>> > It was more or less exactly the way I did it before with little
>> > exaggerating as you notice :-)
>> > Even now I save 50% codesize in comparison to resourcestring.
>>
>> If you don't like resource string, inho there are 2 alternatives that
>> are (IMHO) better:
>>
>> 1)
>> plain array with all text constants. You can break it into one array per
>> unit, and have a register a search-handler via the unit's initialization.
>>
>> const MySnippets: Array [1..xxx] of string = ('text', '...', ... ];
>>
>> For more readability (but it adds source code (should not add more to exe)
>>
>> const
>> snip1: 'text';
>>MySnippets: Array [1..xxx] of string = (snip1, '...', ... ];
>>
>> (actually, I havent testet if the compiler takes the 2nd
>
> Then you have to put _all_ text snippets at once there (!)
> I didn't count my text snippets in this project, but they are spread over
> about more than 10 units.
>
>> 2)
>> Since you seem to want something that is easier to type.
>>
>> Keep using
>>writeln(ls('text'));
>>
>> Instead of analysing the exe, write your own pre-precessor.
>
> I considered this, but the solution now is - in my view - unbeatably easy.
> And that is what counts for me.
>
>> The pre-processor can scan the source, create a temporary copy in which
>> it replaces the text in ls() with a reference to the "MySnippets[]" array.
>> It also creates and includes a unit with that array.
>> It then calls the compiler on the temporary created sources
>>
>> At least it will keep working even if fpc internals change.
>
> I do not worry about this. The search procedure can easily adapted then.
>
>> And it is cross platform (includes cross-CPU)
>
> Yes, that's true. But I am confident to find here also a solution once it will
> be necessary.
> ___
> 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] Get all caller adresses of a given function/procedure before executing

2012-08-12 Thread Jorge Aldo G. de F. Junior
Why do you need to "Get all caller addresses of a given function procedure" ?

This can be solved with static code analysis - as long as there is no
procedural variables involved - but its weird to have such a
necessity... Sounds like the project started with the wrong
assumptions...

Thats my two cents...

2012/8/11 Rainer Stratmann :
> Am Saturday 11 August 2012 19:18:39 schrieb Jorge Aldo G. de F. Junior:
>> Sorry for posting without bringing a solution, but i am curious, why
>> do you need this ?
>>
>> Doesnt sound like good programming practice...
>
> See Thread:
> "Get all caller adresses of a given function/procedure before executing"
> We did not find a solution there I feel comfortable with so I decide to check
> the code directly.
> ___
> 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] Get all caller adresses of a given function/procedure before executing

2012-08-11 Thread Jorge Aldo G. de F. Junior
Sorry for posting without bringing a solution, but i am curious, why
do you need this ?

Doesnt sound like good programming practice...

2012/8/11 Marco van de Voort :
> In our previous episode, Rainer Stratmann said:
>> > > There are not many different ways for a call.
>> > >
>> > > http://css.csail.mit.edu/6.858/2011/readings/i386/CALL.htm
>> >
>> > Yes, so the amount of effort may increase drastically. New CPU may bring
>> > new ways too.
>>
>> But not the 80x86 CPU. It is still the same opcode for a call ($E8).
>
> Maybe not the call, but changing or adding address encoding is quite
> realistic.
>
> I assume you tested your code for PIC cases (which are quite common on
> *nix?)
>
> http://en.wikipedia.org/wiki/Position-independent_code
>
> FPC supports PIC
>
> And of course finding a perfect starting point so that you don't find false
> positives when you find $E8 inside the address (change 1 in 256 obviously)
> ___
> 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] [OT] GPL Lisence help

2012-07-29 Thread Jorge Aldo G. de F. Junior
The engine is a integral and needed part of a car, yet the engine
design and production is not necessarely part of the rest of the car
production (In very old times, companies like mercedez built only
carriages, benz built engines + chassis, eventually they decided to
merge to produce both together, something like that if i remember).

The idea is that i am perfectly entitled to design something around a
product of other company, without infringing their intellectual
property.

Accessory or obligatory use doesnt matter, as long as the code is
distributed separately and each part is clearly identifiable.

Regarding the difference between system libraries, how can you
differentiate among non-system libraries and system libraries ? This
is quite arbitrary.

APIs are not copyrighteable.

This was the whole concept around the Google vs Oracle case.

2012/7/29 Attila Kinali :
> On Sat, 28 Jul 2012 02:28:43 -0300
> "Jorge Aldo G. de F. Junior"  wrote:
>
>> Think about this : Can you think about the relationship of your
>> modules versus someone else modules as being intrinsecally the same
>> relation between linux and proprietary apps that happen to run in
>> linux ? Because (putting informational security concerns besides) the
>> userland apps calls kernel routines just like any app would call a
>> library routine, the difference is mainly due to security concerns as
>> the kernel code must be secured from userland. But as long as this is
>> dynamically linked, i dont see "judicial" differences here.
>
> You have to be very carefull here. You are mixing two different
> interface concepts here. For the kernel, its syscall-API is available
> to all applications, no matter what their license is. And the basic
> Unix kernel API has been implemented in various kernels with differnet
> licenses. While if you make a library GPL you define that the API is only
> available to applications that are compatible with the GPL. Yes, you can
> argue that using the library does not make your application a derived work.
> But you cannot argue that you are not allowed to use the library itself.
>
> And if you have a good lawyer, you can argue that if your proprietary
> application is based on a GPL library for which no other replacement
> with the same API is available, the library becomes an integral part
> of the application. And even if the application cannot be deemed a
> derivative work (which would be hard to argue in this case), the
> violation of the libraries license is without doubt. And as your
> application does not work without this specific library, it is
> quite easy to conclude that you knowingly and willingly violated
> the license terms of the library.
>
>
>
> Attila Kinali
> --
> Why does it take years to find the answers to
> the questions one should have asked long ago?
> ___
> 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] [OT] GPL Lisence help

2012-07-27 Thread Jorge Aldo G. de F. Junior
Do dynamic linked executables really need to not be GPL ?

I mean, application subdivision in modules has nothing to not be
accepted at courts as a valid concept.

Your module/lib is GPL but code linked to it must not be and this is
not a violation of GPL. Provided that the code to your module/lib is
sent with the binaries, the rest of code (non-gpl modules) dont need
to be provided.

software modularization is accepted at courts just like a car
subdivision in mechanical modules, at least when they are dynamically
linked.

Think about this : Can you think about the relationship of your
modules versus someone else modules as being intrinsecally the same
relation between linux and proprietary apps that happen to run in
linux ? Because (putting informational security concerns besides) the
userland apps calls kernel routines just like any app would call a
library routine, the difference is mainly due to security concerns as
the kernel code must be secured from userland. But as long as this is
dynamically linked, i dont see "judicial" differences here.

Thats my view and i am not a lawyer.

2012/7/27 Mark Morgan Lloyd :
> Dimitrios Chr. Ioannidis wrote:
>>
>> Hi all,
>>
>>   first let me express my apologies for the off topic question.
>>
>>   I'm having trouble to choose the correct gpl lisence for a new open
>> source project that i'm starting. I want the project to be open source
>> gpl'ed so it can be accepted in distro's like Debian. But, at the same
>> time, because the structure is modular, i want the possibility, to be
>> used by anyone in commercial applications.
>>
>>   Can anyone give a hint and/or a suggestion ?
>
>
> Possibly multiple licenses: the license is determined by how somebody has
> got the code from you irrespective of whether he could have got it
> elsewhere. Alternatively, the basic framework is GPL but dynamically-linked
> extensions are proprietary.
>
> I suppose that the bigger question is: how does one find an affordable
> lawyer, well-versed in the laws covering the major jurisdictions?
>
> --
> Mark Morgan Lloyd
> markMLl .AT. telemetry.co .DOT. uk
>
> [Opinions above are the author's, not those of his employers or colleagues]
>
> ___
> 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] Small and not instalable web server for a local Pascal CGI application

2012-07-12 Thread Jorge Aldo G. de F. Junior
Theres lightwebserver in Powutils

2012/7/12 Michael Van Canneyt :
>
>
> On Thu, 12 Jul 2012, luciano de souza wrote:
>
>> Hello all,
>> I am running some CGIs in localhost. When talking about web servers,
>> the name of Apache comes as natural. However, I would like to share
>> some zip files to show the results. For this purpose, Apache is not
>> the best   because I need something not instalable.
>> I tried a small server called Mongoose. I was enthusiastic with the
>> size: 140 kilobytes. Unfortunately, it used to fail when dealing with
>> some UTF-8 PathInfos.
>> Regarding I don't need many resources to run simple applications in
>> localhost, I would like indications about small, not instalable web
>> servers, ideal for my simple and sharable Pascal CGIs! Does someone
>> know something about this?
>
>
> FPC comes with a small webserver ? You don't even need the CGIs then.
>
> Michael.
>
> ___
> 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] SIGTERM and thread

2012-07-11 Thread Jorge Aldo G. de F. Junior
Did you try a simpler handler ?

Maybe just set a variable and exit. Just a kind of test case...

2012/7/11 jmbottu :
> Hello,
> I wrote a handler to intercept the SIGTERM signal and execute some
> processing before terminating the program.
> It works fine.
>
> But when i add the cthreads unit in the uses clause, the application seems
> to do a shutdown after the end of the handler function, and the processing
> before terminating the program can no longer run.
>
> Thanks in advance for your help.
> Jean-Marc
>
> --
> View this message in context: 
> http://free-pascal-general.1045716.n5.nabble.com/SIGTERM-and-thread-tp5710294.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/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] encryption and decryption

2012-06-22 Thread Jorge Aldo G. de F. Junior
Theres a blowfish encryption system in freepascal

http://www.freepascal.org/docs-html/fcl/blowfish/index.html

2012/6/22 Rainer Stratmann :
> Does someone know how to do encryption and decryption with keys?
> ___
> 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] Adding method dynamically to a class

2012-06-22 Thread Jorge Aldo G. de F. Junior
Use event properties (Properties to a procedural type)

Adding completely free methods to a class makes no sense.

By free i mean a method that has no clear signature (parameters and
result type) because calling them will be a nightmare (You will have
to do the compiler work and build your own parameter passing and
return type system).

This is usually done in interpreters but what you describe doesnt
sound like a interpreter.

2012/6/21 ik :
> On Wed, Jun 20, 2012 at 2:15 PM, Inoussa OUEDRAOGO 
> wrote:
>>
>> > Think of a plug-able system.  I have an engine, and code to execute.
>> > Instead of compile everything to an ELF/PE, I place code on dynamic
>> > shard
>> > library, and load it on run time when needed.
>> >
>> > The idea is that the engine will not be rewritten for every new request
>> > (that comes often), because it's logic (almost) never changes, but to
>> > load
>> > code on demand that often changes, provide additional functions, changes
>> > of
>> > logic, bug fixes etc...
>>
>> WST library server implementation could be a elegant solution : it is
>> web-services that are
>> locally located in dynamic library(DLL)/shared object(so) instead of
>> being remote. The main
>>  executable acts as client while the server's implementation as
>> provided as shared objects.
>> No TCP is used, only memory through the WST's library protocol. No
>> SOAP serialization
>> as you can use the WST's custom binary messaging format that is very fast.
>>
>> To resume :
>>  * The main executable defines a WSDL schema that contains the types
>> (think of this as IDL)
>>  * The servers implement the service exposed in the schema.
>>  * The main executable loads the servers using the library protocol
>>
>> Main benefits are :
>>  * much larger type system available (wsdl, WST contains a type library
>> editor)
>>  * you could later even add remote servers without changing your main
>> application,
>>    just create the service with the desired location parameters.
>>
>
> Thank you, I'll check it out. My "problem" is something like with WDSL idea.
>
>
>>
>>
>>
>> --
>> Inoussa O.
>
>
> Ido
>
>>
>> ___
>> 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Playing sounds with standard components

2012-06-09 Thread Jorge Aldo G. de F. Junior
You can use OpenAL or SDL...

2012/6/9 luciano de souza :
> Hello all,
>
> Bass is a very good library for sound playing and recording. However,
> it's not included as an standard feature of Freepascal. For whom wich
> wants to work with standard components, are there other options: (1)
> to play sounds and (2) to record sounds?
>
> Regards,
> Luciano
> ___
> 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] Streaming of Generics

2012-05-28 Thread Jorge Aldo G. de F. Junior
Can you create a generic that is based on a class that can stream
itself using rtti regardles of its structure ?

Something like

Type
TFundamentalClass = Class(TObject)
Public
Function GetProperty(Propertyname : String): Variant;
Procedure SetProperty(PropertyName : String; Value : Variant);
Procedure WritePropertiesToStream(Const aStream : TStream); bla bla
End;

Type
Generic TMyGeneric = Class(TFundamentalClass)
Blabla
End;

Type
TMySpecialization = Specialize TMyGeneric;

Did you tried that ?

2012/5/28 Kornel Kisielewicz :
> Hello all,
>
> I want to find a way to write a streaming mechanic for Generic data
> structures. For simplicity let's assume that I want to write a class
> or function to stream TFPGList (I do not use them, but my set of
> generic classes is written in a similar manner). However, due to FPC's
> restricted generics support I cannot find a way to reasonably do that.
>
> Ideally, I'd only like to write the streaming mechanism for each set
> of types (normal, anisstring, dynamic array, objects, interfaced
> objects) once, and use it for every set of items. However, there's no
> reasonable way to detect the type and do an execution for it. Ideally
> I'd be able to write a generic procedure :
>
> procedure StreamType( Stream : TStream; Data : T );
>
> ... but we don't have generic procedures yet. Still, even if using
> classes, the inability to do specializations makes it impossible to
> write a generic streaming system. Is there a way to detect a type
> easily of "any passed value"? It would be enough for me to have a
> function
>
> procedure StreamType( Stream : TStream;  var Data );
>
> ... that could detect the type of data, as long as it would accept
> simple types, ansistrings, classes and dynamic arrays.
>
> --
> regards,
> Kornel Kisielewicz
> http://chaosforge.org/
> ___
> 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] Extend multiple classes with same code

2012-05-19 Thread Jorge Aldo G. de F. Junior
So basically they are in the same branch (Well you could argue that
every object inherits from TObject, but i cant imagine someone
creating a helper class for TObject).

> Please not that the extended classes (in this case T_B1 and T_B2) need to
> inherited from T_A, otherwise the compiler will complain.
>
> Regards,
> Sven
>
>
> ___
> 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] Extend multiple classes with same code

2012-05-18 Thread Jorge Aldo G. de F. Junior
You simply cant do it. Not even multiple inheritance would help you in
this case.

You will have to extend each class by hand.

Multiple inheritance would allow you to join back branches in the
class hierarchy, but in this case you want to add the same
functionality to multiple branches, but keep the branches separate
entities. This is impossible with current freepascal OOP and i dont
think this is even a good thing to have.

It could be done multi-class helper, kind of class helper that works
on multiple classes. But i dont even know of a language that has such
possibility (i dont know much languages anyway).

2012/5/18 Zaher Dirkey :
>
> On Fri, May 18, 2012 at 11:27 PM, Bernd  wrote:
>>
>>
>> _B3 = class(T_A);
>> How about this:
>>
>> T_A = class(TObject);
>>
>> T_AX = class(T_A);    // <-- this class implements your extensions
>>
>> T_B1 = class(T_AX);  // TB_1 and
>> T_B2 = class(T_AX);  // TB_2 inherit it
>> T_B3 = class(T_A);
>>
>>
>
> I can't, in fact it is my mistak when i explained.
>
> B1 B2 is in the base unit like as A, i cant modify it, very strict.
>
> My projects is db layer, i have TmyCustomField,
> TmyFields=class(TmyCustomField) and TmyParams=class(TmyCustomField), that in
> the base unit.
>
> now i like to inherit both TmyFields and TmyParams to add functions work on
> Firebird, TmyFirebirdFields and TmyFirebirdParams, both have same functions
> to work on buffer SQLDA.
>
> Best Regards
> Zaher Dirkey
>
>
> ___
> 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] Re: Parsing parameters inside an interpreter

2012-05-14 Thread Jorge Aldo G. de F. Junior
I have a parser function somewhere around that can do more than
that... let me find it...

2012/5/14 Lukasz Sokol :
> On 14/05/2012 10:39, Lukasz Sokol wrote:
>> On 13/05/2012 11:20, luciano de souza wrote:
>>> Hello all,
>>>
>>> I trying to build a very small interpreter. I can type commands
>>> like:
>>>
>>> $ add "Luciano de Souza"
>>> luchya...@gmail.com
>>>
>>> Somewhere in my code, I can have something like:
>>>
>>> procedure parse(commandline: string; var params: array of string);
>>>
>>> In this case, the commandline has the format: "add %s %s". So I would
>>> obtain:
>>>
>>> parse('add "Luciano de Souza"
>>> luchya...@gmail.com', params);
>>>
>>> After this command, the parameter would have the following values:
>>>
>>> params[0] := 'add'; params[1] := 'Luciano de Souza'; params[2] :=
>>> 'luchya...@gmail.com';
>>>
>>> My question is: there is a way to do it easily using a standard
>>> class of Freepascal?
>>>
>>> Luciano
>>
>> In my 'poor-mans interpreter' I use and pass around TStringList's
>> quite a lot; although some special treatment of the string
>> is required, to preserve spaces within parameter strings.
>>
>> L.
>>
>
> Or use StrictDelimiter := False like Ludo suggested :)))
>
> L.
>
> ___
> 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] Unicodestrings and Assign(File)

2012-05-12 Thread Jorge Aldo G. de F. Junior
does TFileStream use the same code as assign ?

you could create a TFileStream instance and then use AssignStream to a
regular file type and keep on using plain old read/write...

not tested here, but could be worth a try...

2012/5/12 印場 乃亜 :
> Hi,
>
> On 2012/05/12, at 18:31, Jürgen Hestermann wrote:
>
>> Noah Silva schrieb:
>> > Thus, the only question would be whether you have to manually convert a 
>> > UnicodeString to a UTF8String or not.
>>
>> No, that would not help. Under Windows you can access long paths *only* when 
>> using special functions (i.e. FindFirstFileW instead of FindFirstFileA). And 
>> these functions need unicode (widechar) paths strings with a prepended 
>> '\\?\'. There is no other way to access long paths under Windows. Simply 
>> converting Unicode to ANSI may let me use most (but not all) Unicode 
>> characters but the paths would always be restricted to MaxPath (about 260) 
>> characters. Only when using API functions ending with a W I can access 
>> longer paths (up to 32000 characters) and these
>
> Ah, I forgot about that little detail.  Given that, it doesn't really make 
> sense to use the *A versions at all in Windows (Unless you want to support 
> very old Windows versions).  Thus the approach for Windows should be the 
> opposite of Unix, I suppose.  UTF8 or ANSI gets converted to UTF16 and call 
> the *W functions.
>
>> string *must* be Unicode (widechar). So the RTL needs to be rewritten to 
>> allow Unicode paths handed over without conversion and then use Windows API 
>> functions with the W at the end.
>>
> I'm surprised this isn't available already.  The 260 char path limitation is 
> pretty severe these days.
>
>> Because this is not the case (yet), I was wondering, whether it is possible 
>> to use other Windows API functions like CreateFileW and then somehow connect 
>> them to RTL file data structures so that I can replace "assign" and 
>> "reset/rewrite" by Windows API functions and then be able to use "readln" on 
>> such (text) files.
>>
> I'm sure it's possible somehow since those structures probably track the 
> Windows file handle, but it wouldn't be very portable or future-proof.
>
>> > Still, fixing Assign/Reset/Rewrite would be better than using Unix calls, 
>> > because you could submit a patch to save everyone else trouble in the 
>> > future.
>>
>> Yes, I would like to but neither time nor knowledge allows me to do that 
>> currently.
>
> I have the same time problem, but I will take a look at the source code, I 
> don't think it should be very difficult to figure out.
>
> Thank you,
>      Noah Silva
>>
>> ___
>> 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] making FPC more code optimized

2012-04-29 Thread Jorge Aldo G. de F. Junior
If you deploy one executable, ok, but if you want to create a handfull
of executables (following unix logic of many small programs) then you
have a problem.

EVERY executable will have the same code again again again, i think
libraries have been created to address exactly this issue.

about the library hell, why we cant use lib versions ?

lets say,

libpas.so.2.4.4 for fpc 2.4.4
libpas.so.2.6.1 for fpc 2.6.1
libpas.sysutils.so.2.4.4
libpas.classes.so.2.4.4

etc...
etc...

the only problem i see is the lack of a sane way to export class
instances to/from the libraries.

2012/4/29 Florian Klämpfl :
> Am 29.04.2012 14:23, schrieb Jorge Aldo G. de F. Junior:
>> What would be usefull is to move the loads of code stored in
>> sysutils/runtime into a dll/so.
>>
>> thats what makes C code look "smaller", theres a nice libc (and
>> others) there that groups mostly used functions into a single
>> instance, while in pascal every executable replicates the very same
>> code for each instance.
>>
>> make sysutils/runtime etc an external loadable library and we are
>> going to see FPC generate similar sized executables for similarly
>> sized programs.
>
> It makes them look smaller but their footprint is actually larger so
> this is exactly what Ido doesn't want.
> ___
> 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] making FPC more code optimized

2012-04-29 Thread Jorge Aldo G. de F. Junior
What would be usefull is to move the loads of code stored in
sysutils/runtime into a dll/so.

thats what makes C code look "smaller", theres a nice libc (and
others) there that groups mostly used functions into a single
instance, while in pascal every executable replicates the very same
code for each instance.

make sysutils/runtime etc an external loadable library and we are
going to see FPC generate similar sized executables for similarly
sized programs.

2012/4/29 Jonas Maebe :
>
> On 29 Apr 2012, at 12:22, Florian Klämpfl wrote:
>
>> Spent more man power into optimizer development, though some
>> optimizations are hard in pascal because we assume stricter aliasing
>> rules and because we don't have a volatile keyword.
>
> At least as far as our current optimizers are concerned, nothing is volatile 
> in Pascal: both the assembler and node tree optimizers will replace multiple 
> loads of global data with a single load when they can. So that should not 
> limit any optimizations at this time.
>
> Regarding aliasing, I'm not sure whether C defines anything regarding that. 
> You at least need to use the -fstrict-aliasing gcc flag to tell it to assume 
> that pointers to different types cannot alias each other (and hence get 
> better optimizations). In standard Pascal, pointers by definition can only 
> point to data of one particular type, so it could be compiled with 
> -fstrict-aliasing in any case. Since in FPC/Delphi this is no longer the 
> case, you could introduce a similar switch there to allow programmers to tell 
> the compiler that their code also obeys strict aliasing rules.
>
> In general, I think it's indeed simply a matter of the amount of man power 
> spent on optimizations.
>
>
> Jonas___
> 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


[fpc-pascal] RGB32 video

2012-04-16 Thread Jorge Aldo G. de F. Junior
how to generate a RGB32 video to be consumed by, lets say ffmpeg ?

i want to programatically generate video in some know format and rgb32
seems like the most simple to write

is there any other way to easily generate video ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Network Library

2012-03-24 Thread Jorge Aldo G. de F. Junior
I think ararat synapse is a possible solution to you...

2012/3/24 Carver Carver :
> you might try the PGD
>
> Pascal Game Development - Front Page
> 
> From: Ian Macintosh 
> To: fpc-pascal@lists.freepascal.org
> Sent: Friday, March 23, 2012 9:37 AM
> Subject: [fpc-pascal] Network Library
>
>
>
>
> ___
> 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] Burn a CD

2012-03-13 Thread Jorge Aldo G. de F. Junior
you are lucky !

a quick search at google returned the following document :

http://tools.assembla.com/svn/zalex/FuzzyReader/WNaspi32.pas

i dont know the license of this code, but it can be used, at least, as
reference...

2012/3/13 Jorge Aldo G. de F. Junior :
> you should :
>
> 1 - Learn to use ASPI.dll (wich is basically a way to send ATAPI
> commands to the device).
> 2 - Learn ATAPI commands (ATAPI is more or less SCSI commands sent
> over SATA/PATA layer).
>
> 2012/3/13 Marcos Douglas :
>> Hi,
>>
>> Anyone knows how burn a CD using the Windows API (should works in XP and
>> Vista)?
>>
>> Thanks,
>>
>> Marcos Douglas
>>
>> ___
>> 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] Burn a CD

2012-03-13 Thread Jorge Aldo G. de F. Junior
you should :

1 - Learn to use ASPI.dll (wich is basically a way to send ATAPI
commands to the device).
2 - Learn ATAPI commands (ATAPI is more or less SCSI commands sent
over SATA/PATA layer).

2012/3/13 Marcos Douglas :
> Hi,
>
> Anyone knows how burn a CD using the Windows API (should works in XP and
> Vista)?
>
> Thanks,
>
> Marcos Douglas
>
> ___
> 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


[fpc-pascal] status of MIPS port

2012-03-10 Thread Jorge Aldo G. de F. Junior
Whats the status of the MIPS port ?

I am currently working on a project called "OpenTik", wich aims at
replacing mikrotik's routeros with a completely opensource
alternative.

Originally i wanted to use FreeBSD on ARM but theres no freepascal
compiler for this.

I switched to a Linux based system as the base, and freepascal to
write a couple of complex components (like the console wich is way
more powerfull than the mikrotik's original one).

I am working on the captive portal system now, wich will be nicely
integrated into the current (working already) xmlconsole.

Later i plan to write a mac server using freepascal and libpcap and
finally a winbox replacement called openbox.

Current source code is here :

http://code.google.com/p/opentik/

it implements a complete programming language on its own, besides a
template system and a configuration management tool all integrated
into a single system called xmlconsole (because it uses xml files to
store config).

My question is : Whats the status of Freepascal on the MIPS (both LE and BE) ?

I ask this bacause MIPS is the single most used processor in the low
end/low cost access point market and it would be quite nicey to have
opentik running on those.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: FPC with case insensitive file system under Linux

2012-02-28 Thread Jorge Aldo G. de F. Junior
2012/2/27 Jürgen Hestermann :
> Virgo Pärna schrieb:
>
>>    Essentialy, case insensitive filesystems are less problematic.
>>
>
> No, just the opposite. The  problems are only moved (and increased) from the
> techie level (where it should belong to) to the user.
> This is not a good idea IMO.
> If there problems with capitalization of certain characters exist then these
> problems should be solved or
> if that's not possible for some reason such characters should not be allowed
> in file systems.
>
> But giving it all over to the user and tell him  "We did not know how to
> handle this mess, just try yourself" is not a solution.
>

Isnt that the unix/c philosophy ? "If you dont know how to handle the
problem, pretend the problem doesnt exists..."


>
>
> ___
> 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] Data persistance in CGI projects

2012-02-26 Thread Jorge Aldo G. de F. Junior
You can use rtti and create a base class that knows how to save/load
itself from sql database...

2012/2/26 Luciano de Souza :
> Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL
> Server, Oracle, but not for PostgreSQL. This is the first reason. I really
> don't know how proper tiOPF is when we focuses on CGI development. At a
> first look, the project seemed to be very complex to use, but of course, I
> may be wrong.
>
>
> Em 26-02-2012 13:29, Michael Van Canneyt escreveu:
>
>>
>>
>> On Sun, 26 Feb 2012, Luciano de Souza wrote:
>>
>>> Hello all,
>>>
>>> For desktop environments, there are mature projects on data persistance.
>>> Press Objects, TiOPF... desktop developers can be proud of the tools they
>>> have.
>>>
>>> What about CGI environments? Is there something already developed? Yes,
>>> we can use SQLDB. It's really a very good component. However, we need to
>>> write lots of SQL. The dream would be something like:
>>>
>>> user := TUser.create;
>>> user.name := 'Luciano';
>>> user.age := 36;
>>> user.insert;
>>
>>
>> Why not use tiOPF for this as well ? It works just as well in CGI
>> environments.
>>
>> Michael.
>> ___
>> 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] dbus in Pascal

2012-02-23 Thread Jorge Aldo G. de F. Junior
i need dbus too...

i was going to do with plain tcp sockets, but dbus would be nice to
integrate

2012/2/23  :
>
>
> On Thu, 23 Feb 2012, Felipe Monteiro de Carvalho wrote:
>
>> On Thu, Feb 23, 2012 at 8:42 AM, Michael Van Canneyt
>>  wrote:
>>>
>>> I have written dbus classes/components. I never committed them, but they
>>> work, and if you want I can send them to you.
>>> If you think they're good enough, we can include them in FPC.
>>
>>
>> Yes, I am very interrested in seeing this
>
>
> Sent in a private mail.
>
>
>>
>> How do you get messages with this library? You need to call something
>> periodically? I always thought that dbus needs integration with the
>> application loop.
>
>
> It does. You can make do with the OnIdle event, but for true lazarus
> integration one needs support for such things in TApplication.
>
> It's time to revive the fpasync package by Sebastian Guenther.
> At the time it was written, I didn't think much of it, but over time I've
> come to see that it is in fact very much needed.
> I talked to Mattias once, but didn't get around to a working implementation
> yet. (Item 548987 on my todo list)
>
> Michael.
>
> ___
> 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] Re: level curve and surface generation code

2012-02-21 Thread Jorge Aldo G. de F. Junior
i can translate for you if you need

2012/2/20 Felipe Monteiro de Carvalho :
> On Mon, Feb 20, 2012 at 3:59 PM, leledumbo  wrote:
>> Something like
>> http://www.sulaco.co.za/opengl_project_terrain_generation_using_heightmaps.htm
>> terrain ?
>
> Pretty good! Unfortunatelly in my case the input is much more complex.
> Here it seams to be a grid with heights given as input. I have an
> array of 3D points. Maybe I should first generate a grid of heights
> and then try the code here.
>
> And I got something wrong in the other question. The english
> terminology is "countour line", in portuguese it is "Curva de nivel",
> and my direct translation didn't work out very well =)
>
> --
> Felipe Monteiro de Carvalho
> ___
> 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


[fpc-pascal] Exception withing exception handling

2012-02-17 Thread Jorge Aldo G. de F. Junior
I am in the process or writing a interpreter for a specific task (not
turing complete, just something to make easier to express something to
the computer) and for the erro handling i decided to use plain old
exceptions.


Code works that way :

1 - Everytime an error occurs, an exception is triggered. (Be it on my
own code, or on the runtime itself, like when you cause a division by
0)
2 - There are system exceptions wich i cant control format and there
are my own exceptions that are all based on TROWCOLExceptions, that
has row, col and sourcefile properties to nicely describe where in the
user input was the error.
3 - All code structures are wrapped around try try finally except blocks.
4 -on except blocks, a new exception (based on trowcolexception) is
created from non trowcolexception, so as to make the user aware of the
row and column of code related to the original exception.

something like :

procedure theobject.raiseerror(amessage : string; aprevious : exception);
var
lexcept : Trowcolexception;
Begin
lexcept := trowcolexception.create(amessage);
lexcept.row := theobject.row;
lexcept.col := theobject.col;
lexcept.source := theobject.source;
lexcept.previous := aprevious;
raise lexcept;
end;
End;


this causes all exceptions to being tagged with all row/col/sourcefile
name of nested structures overlying the place where the error
ocurruded, including the error row col of the offending code.
something like freepascal itself does when you compile with -gl

code ends app being wrapped around thousands of try except blocks all
creating new exceptions and appending the older ones to the previous
property, in a kind of linked list that makes code fully traceable.

the problem is. sometimes the system inexplicably throws runtime error
202 and quits. ignoring exceptions and etc.

i debuged the problem into the raise lexcept line of raiseerror.

so i am inclined to think that exceptions arent supposed to live much
longer after their corresponding try except handling block.

is that true ? actually, how are exceptions raised ? can i reraise one ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: TLinkedList

2012-02-15 Thread Jorge Aldo G. de F. Junior
http://theory.stanford.edu/~amitp/rants/c++-vs-c/

found the thing... its not a book and C++ has no generics but
templates (for me both are the same, im no C++ programmer).

Now reading it again... The thing is that a quicksort in C can be fast
only if used for one single type (at least the comparision function)
while in C++ the template specialization makes the comparision
function work for a greater number of types, simplifying resulting
code...

2012/2/15 Juha Manninen :
> 2012/2/15, Jorge Aldo G. de F. Junior :
>> i once read a textbook about generics (C++ generics) showing how C++
>
> C++ does not have generics, it has templates. Templates syntax is
> complex, you can do actual programming with it. IMO, using all its
> capacity leads to over-engineered and unreadable code.
> I read about a plan to add Java style generics syntax to C++, in
> addition to templates. I guess it will not happen. C++ has enough
> syntax already.
>
>
>> code can end up being FASTER than C equivalent due to lack of type
>> checks...
>>[...]
>> the point being made was that object orientation is not necessarely
>> "bloat" but leads to better written code. (not always true, but...)
>
> Code can still be fast even if it is bloated in size. Object
> orientation helps in writing readable and maintainable code but that
> is yet another issue.
> The code duplication we discussed here has no advantage for speed. It
> is quite useless duplication.
>
>
> >From Sven Barth:
>> Free Pascal is a native language. There aren't much alternatives to code 
>> duplication.
>
> Yes there is. The same container code can be reused (when possible),
> just like Java does.
> Free Pascal is native, Java generates byte-code, but that is irrelevant here.
>
> I was planning to use generics in many places in Lazarus code but now
> I must rethink...
> Lazarus executable is quite big already.
>
> Juha
> ___
> 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] Re: TLinkedList

2012-02-14 Thread Jorge Aldo G. de F. Junior
i once read a textbook about generics (C++ generics) showing how C++
code can end up being FASTER than C equivalent due to lack of type
checks...

it uses a quick sort routing as example.

on C you end up having to check the type of storage to get a similar
result, while on C++ you check this at runtime. it was something along
that lines.

the point being made was that object orientation is not necessarely
"bloat" but leads to better written code. (not always true, but...)

2012/2/14 Marco van de Voort :
> In our previous episode, Sven Barth said:
>> > Afaik it was the main reason to implement generic constraints in Delphi 
>> > (like
>> > .NET)?
>>
>> Constraints allow the compiler to infer further information on the given
>> types to improve e.g. type checking when parsing the generic,
>
> Exactly. You e.g. know that the unspecialized generic is already meant for
> reference types, from line one.
>
>> but they won't magically allow the compiler to not duplicate code (in
>> theory it would be possible to do something like Java's generics for cases
>> where the constraints are for descendants of TObject or IInterface, but in
>> my opinion the tradeoffs (increased compiler complexity) are not worth
>> it).
>
> Yeah, that is typical. If it is not used inside the compiler it is
> unoptimized :-)
>
> Maybe redo cclasses with generics?
> ___
> 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] Re: TLinkedList

2012-02-11 Thread Jorge Aldo G. de F. Junior
I believe generics makes faster code due to having no need to test
types during runtime... i maybe wrong.

2012/2/11 ik :
> On Fri, Feb 10, 2012 at 17:53, leledumbo  wrote:
>>
>> I don't remember having that since 2.X.X... there was always TList,
>> however.
>> And that's what I was using (I use generics for all my containers use
>> now).
>
>
> Thanks. Personally I dislike generics at all. They are not that readable
> imho. Even though FPC's implementation is one of the most readable ways I
> have ever seen.
>
> Ido
>>
>>
>> --
>> View this message in context:
>> http://free-pascal-general.1045716.n5.nabble.com/TLinkedList-tp5469685p5472934.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/mailman/listinfo/fpc-pascal
>
>
>
> ___
> 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] What ARM targets are supported by FPC?

2012-02-08 Thread Jorge Aldo G. de F. Junior
No need,

this guy ported the whole DirectFB stuff to freepascal :

http://sourceforge.net/projects/wiseslap/files/external/directfb/

DirectFB tutorial :

http://directfb.org/docs/DirectFB_Tutorials/simple.html

directfb stuff is quite simple, they have made the interface somewhat
like an OOP layer (sort of), but using C language only... it can be
used almost 1:1 in pascal...

2012/2/8 Graeme Geldenhuys :
> On 8 February 2012 20:17, Jorge Aldo G. de F. Junior  wrote:
>> i tried to do, but while understanding directfb was easy,
>> understanding how fpgui draws was quite hard...
>
> I thought fpGUI code was the easy part because only a handful of
> graphic primitives need to be implemented for each backend - to get
> the basics to work. If you saved any of your directfb work, could you
> pass it on to me. It should probably save me a lot of time bring
> DirectFB+fpGUI to life.
>
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
> ___
> 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] What ARM targets are supported by FPC?

2012-02-08 Thread Jorge Aldo G. de F. Junior
i tried to do, but while understanding directfb was easy,
understanding how fpgui draws was quite hard...

2012/2/8 Graeme Geldenhuys :
> On 7 February 2012 16:19, Jorge Aldo G. de F. Junior  wrote:
>> Graeme, can you help port fpGui to DirectFB ? this would help embedded
>> development a lot...
>
> Supporting DirectFB has been on my todo list for a long time. I can
> think of many cases where I would find that useful too - especially
> for the cross-platform fpGUI Installer I am working on. I just need to
> make some time for it.
>
> Do you know of anybody else that has started such work? If so, we
> could merge that code into the official repository and go from there.
>
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
> ___
> 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] What ARM targets are supported by FPC?

2012-02-07 Thread Jorge Aldo G. de F. Junior
Graeme, can you help port fpGui to DirectFB ? this would help embedded
development a lot...

2012/2/7 Henry Vermaak :
> On 07/02/12 13:05, Bernd wrote:
>>
>> 2012/2/7 Henry Vermaak:
>>
>>>  Just make sure you have enough swap space, since I've got 512MB and that
>>> isn't sufficient to build lazarus.
>>
>>
>> If you use the following flags then ld will use considerably less
>> memory during linking:
>> -k--no-keep-memory -k--reduce-memory-overheads
>
>
> I know about these, but it was actually the assembler crashing out first,
> didn't even get to the linking stage(!).
>
> Henry
>
> ___
> 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] TStringStream.DataString returns garbage?

2012-02-02 Thread Jorge Aldo G. de F. Junior
I would vote for a new function on all stream types to allow writing
strings in the expected way. Everybody hits that problem once.

2012/2/1 Lars :
> Graeme Geldenhuys wrote:
>> On 2 February 2012 00:14, Michael Van Canneyt  wrote:
>>>
>>> Ehm.. this should be S[1], now you're writing the pointer.
>>
>>
>> Thank you. That's what happens if you have too many very late nights
>> programming - sleep deprivation catches up and one overlooks the
>> simple mistakes.
>>
>>
>>
>
> It's actually a common mistake. Also @s vs "s", and @s[1], it can be
> confusing.
>
> It's one thing I don't like about unsafe languages, pointers, and such
> stuff. It's as if we are programming in advanced C, or C++. Common,
> pointer mistakes? this is C? Really? Can't we make it safer? LOL.
>
> What could be done to make this safer? I don't know. What does java do in
> a situation like this? Could we learn from it?
>
> If somehow the compiler could statically check that only s[1] is allowed,
> and not S, that would be good.
> ___
> 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


[fpc-pascal] tthread.waitfor with timeout

2012-01-16 Thread Jorge Aldo G. de F. Junior
hi !

while working on my pascal actor model concurrency framework i hit a
problem with the way tthread is currently implemented.

i need to quit all actors (threads) before closing the main
application. this is done by waitfor/free each actor until none is
left in the pool of locally running actors.

but sometimes an actor hangs, and waitfor will literally waitfor forever...

is there a way to do the equivalent of waifor but with some kind of timeout ?

thanks in advance,

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


Re: [fpc-pascal] How to poll for a byte in Input?

2011-12-09 Thread Jorge Aldo G. de F. Junior
I think the main problem is that TStream tries to abstract two kinds
of resources :

Character based resources and block based resources. The end result is
that it is no good for neither of the two cases.

2011/12/9 Michael Van Canneyt :
>
>
> On Fri, 9 Dec 2011, Jorge Aldo G. de F. Junior wrote:
>
>> Thats an old problem on the way TStream was implemented.
>>
>> I for one needed to know the result size of a uncompress stream (IE.:
>> i have a compressed stream and want to know in advance how many bytes
>> the uncompress method would yield).
>
>
> This information is not stored in the compressed data. To be able to give
> you this number, the compression stream
> would need to actually decompress the whole stream.
>
>
>>
>> The stream system is currently a mess, sometimes you can know in
>> advance how many bytes you can read, sometimes you cant, depends on
>> the class you are dealing with.
>
>
> There are simply streams which have no size.
>
> In each case, I am working on the 'StreamCapabilities' property, which
> should be able to tell you what is available.
>
>
> Michael.
> ___
> 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] Why is Random(255) some 529x slower compared to Delphi 7?

2011-12-09 Thread Jorge Aldo G. de F. Junior
even if FPC implemented a ultra high tech PRNG it would be compatible
with DELPHI :

1 - Delphi asserts that you should not use the Random function to
encryption porpuses.
2 - Delphi asserts no speed guarantees.
3 - Delphi asserts no randomness quality guarantees.

IE : to be compatible you only need the function to have the same
calling parameters and result type.

Formally, in that case, even this would be "compatible" :

Function Random(): Real;
Begin
Result := 4; { i throwed a dice to reach that result ! }
End;

2011/12/9 Graeme Geldenhuys :
> On 9 December 2011 12:42, Jonas Maebe > wrote:
>>
>> It will improve the randomness of the generated numbers.
>
> Thanks Jonas.
>
>
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
> ___
> 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] Why is Random(255) some 529x slower compared to Delphi 7?

2011-12-09 Thread Jorge Aldo G. de F. Junior
Well, lets go to theory :

One way to build a cypher is to XOR the stream that must be encrypted
against a fixed value.

But, this is easy to break using statistical methods.

So the next logical way to do this is to XOR the stream against
another stream of numbers, kind of one time password.

But, the stream of numbers must be shared by both ends.

How ? Simple, generate the stream on-the-fly using a PRNG.

Now you only need to share the seed of the PRNG and the encrypted stream.

But for this to work the same PRNG must be used on both ends, and the
PRNG must be strong enough with a period much longer than the size of
the data being encrypted.

Whats wrong with calling RANDOMIZE during the loop ? The problem is
that you keep seeding the PRNG with the Now() (current time stamp),
defeating the whole idea. Now, instead of XORing your plain text
against a pseudo-random sequence, you are XORing your plain text
against the current time/date, something quite easily predictable.

Even in your case, seeding a Mersenne Twister in every loop
interaction will put that algorithm exactly in its worst case : the
startup sequence.

The mersenne Twister is slow to start generating good random numbers.

So your program is bug to the guts in this case.

To solve this all you have to do is to guarantee that both
communication ends use the same random number generation algorithm and
seed. This will work. (IE.: the fix will break compatibility with old
binaries). And dont seed against the last result, thats not a good
idea (This will keep the MT restarting).

A good alternative to a simple encryption algorithm is to use
cryptographic hash functions like SHA.

hash your key using SHA.

Split your file in blocks the same size of the SHA key.

XOR the first block against the first key,

output the bytes.

Hash the SHA key itself, generating a second key,

XOR the second block against that second key.

repeat until end of data. PAD the last block to match the Hash size.


2011/12/9 Graeme Geldenhuys :
> On 9 December 2011 12:50, Dimitri Smits  wrote:
>>
>> I actually doubt that that codesnippet does any real encryption.
>
> It isn't. The sample code / test program I posted is just a snippet of
> the actual unit. No point in posting the whole unit here, just to
> point out that a single section of code in one method is the location
> of the slow-running code under FPC. I only supplied the slow-running
> code to demonstrate the problem.
>
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://fpgui.sourceforge.net
> ___
> 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] How to poll for a byte in Input?

2011-12-09 Thread Jorge Aldo G. de F. Junior
Thats an old problem on the way TStream was implemented.

I for one needed to know the result size of a uncompress stream (IE.:
i have a compressed stream and want to know in advance how many bytes
the uncompress method would yield).

The stream system is currently a mess, sometimes you can know in
advance how many bytes you can read, sometimes you cant, depends on
the class you are dealing with.

2011/12/9 tcoq :
> On windows, I did not find WaitForSingleObject, which is actually going to 
> wait for the file.
> However I found ReadFileEx in the Windows API, which is an asynchronous read 
> on the file. I'll try using that.
>
> - Mail Original -
> De: "Michael Van Canneyt" 
> À: "FPC-Pascal users discussions" 
> Envoyé: Vendredi 9 Décembre 2011 16h57:47 GMT +01:00 Amsterdam / Berlin / 
> Berne / Rome / Stockholm / Vienne
> Objet: Re: [fpc-pascal] How to poll for a byte in Input?
>>...
> You must use fpSelect() or Poll on the handle on linux/unix.
> On windows, you'll need to WaitForObject() or so on the file handle.
>
> Michael.
> ___
> 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?

2011-12-07 Thread Jorge Aldo G. de F. Junior
Maybe implementing something other :

"The main advantages of the MWC method are that it invokes simple
computer integer arithmetic and leads to very fast generation of
sequences of random numbers with immense periods, ranging from around
260 to 2200."

http://en.wikipedia.org/wiki/Multiply-with-carry

2011/12/7 Florian Klaempfl :
> Am 07.12.2011 16:03, schrieb Graeme Geldenhuys:
>> On 7 December 2011 14:54, Jonas Maebe  wrote:
>>>
>>> That's correct. We use the mersenne twister, Delphi probably a linear
>>> congruential generator. The mersenne twister has a much larger period.
>>
>> I was reading a bit more about this.  The Mersenne Twister (MT)
>> generator has a massive period of 2^19937-1, compared to the XorShift
>> generator, which in turn has a period of 2^128-1.
>>
>> Most text I read mentions that MT is great for statistical purposes,
>> and performs well in its class.
>>
>> So wouldn't it maybe make more sense to let the standard (read more
>> common) Random() call use a higher performance random number
>> generator, with a much lower period.
>
> Well, once we thought we try to do things better than Delphi ;) Some
> people, I think John Lee, asked for a better random in FPC years ago so
> Jonas implemented a MT.
>
>> Then add the MT generator as a
>> call to the Maths unit - where more statistical functions are located?
>>
>> Most applications are not statistical apps, they just want a random
>> number here or there, so such high period low performance generator is
>> normally not required. Having it in the Maths unit still makes in
>> available when needed though - for those specialised apps.
>>
>> Just a thought...
>>
>
> FPC uses MT at least for 10 years and nobody complained about
> performance yet. So I suspect the cases might be very rare when random
> performance matters and having good random numbers is always a good
> thing ... I prefer not to change it but it's fine for me for delphi
> compatibility's sake ;)
> ___
> 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] The best approaching for templating

2011-11-09 Thread Jorge Aldo G. de F. Junior
I once wrote a very nice template system for Powutils.

Dont remember how it was called.

I can search the svn for you if you want.

2011/11/9 tcoq :
> Dear Luciano.
> I would suggest using the StringReplace function (Sysutiles) in combination 
> with a TStringList.
> Easy to do and quite powerful.
> You can also use a second string list to store the values and patterns to 
> replace, using the Names and Values properties, so that you can do multiple 
> successive replacements in your templates.
> The SaveToFile and LoadFromFile will give you easy storage of your templates.
> I tend to use patterns like [Name] or (First_Name] that are not confused with 
> the html.
> Best regards,
> Thierry
>
> - Mail Original -
> De: "luciano de souza" 
> À: fpc-pascal@lists.freepascal.org
> Envoyé: Lundi 7 Novembre 2011 14h37:46 GMT +01:00 Amsterdam / Berlin / Berne 
> / Rome / Stockholm / Vienne
> Objet: [fpc-pascal] The best approaching for templating
>
> Hello listers,
>
> I would like to create some templates. Suppose the following example:
>
> 
> 
> %s
> 
> 
> %s 
> %s 
> %s 
> 
> 
>
> I can certainly use format to link %s to the respective variables.
> However, if the number of %s is big, probabily, the reading would be
> less clearer.
>
> But, suppose I have $title in stead of %s and $p1 in stead of %s. In
> Lua, I have a module called Cosmo taht perform it.
>
> my question is: is there something similar in Pascal?
>
> Luciano
> ___
> 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
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Getting Hardware information in Linux

2011-10-18 Thread Jorge Aldo G. de F. Junior
I think all this info can be found on /proc directory...

2011/10/18 ik :
> Hello list,
>
> I'm trying to figure out how to get hardware information about the machine
> i'm running at in Linux OS.
> For example: hard-drive size, manufacture etc...
> BIOS information, screen information (regardless of X, that is the hardware
> itself), cards that are assigned and the whole information about such cards.
> Disks of any kind etc... CPU Information (can use the /proc/cpuinfo)
>
> Does anyone know or can point me on how to do it ?
>
> Thanks,
> Ido
>
>
> LINESIP - Opening the source for communication
> http://www.linesip.com
> http://www.linesip.co.il
>
>
>
> ___
> 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] web app and application persistency

2011-08-03 Thread Jorge Aldo G. de F. Junior
You can use L7 filtering to select actions based on packet content.

2011/8/1 Andrew Brunner :
> The only thing I can think of would be packet inspection.  Firewalls
> included with Linux and Windows do not perform "deep" packet
> inspection.  They only allow/deny packets with specific ports over
> either TCP or UDP.
>
> Am I missing something?
>
> On Mon, Aug 1, 2011 at 12:31 PM, Michael Van Canneyt
>  wrote:
>> Any reason why it should not detect it ?
> ___
> 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] Re: operator overloading and counting references / creating / destoying anonymous instances

2011-07-30 Thread Jorge Aldo G. de F. Junior
Imagine the following :

A -> C -> E
B -> D -> E

A is ref counted, and says that theres 10 references to the object C
B is ref counted, and says that theres 5 references to the object D

But both C and D points to the same object !

So now you have actually 15 references to the same object.

Lets say objects gone out of scope and C is now counted at 0 on A, what to do ?

Deallocate C causes E to be deallocated, but, what happens at B -> D ?

So what you need ?

A -> Singleton -> E
B -> Singleton -> E

In other words, make an object that stores all bignums and decides
when to allocate or deallocate then and work from that on.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: operator overloading and counting references / creating / destoying anonymous instances

2011-07-30 Thread Jorge Aldo G. de F. Junior
if i understand correctly, your problem is not operator overloading or
whatever in the language.

You have references.

Now you want to write counted references to references and deal with
this in the overloaded operators

your problem is right into the counted reference to reference.

A := B makes A point to the same reference as B, and this is perfectly
correct semantic, but this will not work correctly by itself  if the
referenced object is itself a reference (without counting) to another
thing.

a pointer to a pointer...

you have to refcount the original pointer instead.

So the solution is to have a singleton that holds all references to
all bignums and then work from that on.

2011/7/30 Bernd :
> 2011/7/30 Florian Klaempfl :
>
>> The automatic constructor/destructor concept of C++ causes the same
>> overhead. And the overhead for a function or operator overloading based
>> approach is the same imo. Or do you have any example where a function
>> based approach performs better? Overloaded operators are converted into
>> function calls, there is no real difference.
>
> I didn't intend to mean it is better solved in C++ (or any other
> language), I didn't want to specifically criticize the Operator
> overloading how it is implemented in Object Pascal, I just spent some
> time experimenting with trying to wrap this bignum library in some
> clever way to make it look and behave nicely. I posted this thread
> only because at some point I realized that whatever I do to make it
> behave like a built in type it becomes slow and ineffective and the
> wrapper becomes big and complicated.
>
> The reason is because it IS a function call.
>
> A := B + C;
>
> A := add(B, C);
>
> This will create a new A and free the old one. I have no idea how to
> prevent this.
>
> add(A, B, C);
>
> with var or out arguments would enable me to re-use the existing A.
>
> If I cannot find a way to let me look to the left *trough* the :=
> operator from inside the + operator I have no Idea how to implement
> something like this, so I always have to create a new instance of A
> and let the old one be freed.
>
> The solution that I have chosen now will force me to explicitly create
> and free them manually and all my methods take all variables as
> arguments, have side effects and don't return anything. The only
> operators that I have overridden are the comparison operators.
>
> Here is the unit I am talking about in its current form (this is at
> least the fifth different variation/rewrite of it already and likely
> to change yet again once I have a new idea):
> http://code.google.com/p/fpbitcoin/source/browse/trunk/openssl_bignum.pas
>
> and here is an example where it is used (currently the only place
> because it is all still far from complete):
> http://code.google.com/p/fpbitcoin/source/browse/trunk/bitcoin_base58.pas
>
> And since I believe this is a very deep and fundamental problem and
> not only related or limited to FPC and not easily solved without
> massive changes to the compiler and the entire operator overloading
> syntax (if it is possible at all) I did not intend to make this a
> Pascal bashing thread. I LOVE this language and this compiler and the
> related projects around it.
> ___
> 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] Re: Library for network calculation

2011-07-27 Thread Jorge Aldo G. de F. Junior
nice, that was new to me :)

2011/7/27 Sven Barth :
> On 27.07.2011 12:22, Dimitri Smits wrote:
>>
>> don't have a Delphi in reach for the moment to verify, but you could do
>> that to a const (if you enable the assignable constants setting)
>>
>> procedure SomeProc;
>> const
>>   someconst: Integer = 22;
>> begin
>>   //blabla
>>   someconst := 42;
>>   //yadda yadda
>> end;
>>
>
> In this case "someconst" will keep the assigned value during different
> functions calls.
>
> For example:
>
> === source begin ===
>
> procedure SomeProc;
> const
>  someconst: Integer = 21;
> begin
>  if someconst = 42 then
>    Writeln('The answer')
>  else begin
>    Writeln('Not the answer');
>    someconst := 42;
>  end;
> end;
>
> begin
>  SomeProc;
>  SomeProc;
> end;
>
> === source end ===
>
> will print:
>
> === output begin ===
>
> Not the answer
> The answer
>
> === output end ===
>
> This was considered as the equivalent of a local static variable.
>
> In case of "var" the definitions are normal variables and semantically
> equivalent to an initialization of the variable at the beginning of the
> function.
>
> Regards,
> Sven
>
>>
>> - "Sven Barth"  schreef:
>>
>>> Well... seems like you didn't notice this feature yet :D
>>>
>>> I'm talking about this:
>>>
>>> === source begin ===
>>>
>>> procedure SomeProc;
>>> var
>>>    somevar: Integer = 42;
>>> begin
>>>
>>> end;
>>>
>>> === source end ===
>>>
>>> This works in FPC, but doesn't in Delphi ;)
>>>
>>> Regards
>>> Sven
>>>
>>> Am 26.07.2011 21:27, schrieb Jorge Aldo G. de F. Junior:
>>>>
>>>> I dont like to take local variable initialization for granted.
>>>>
>>>> Even if the manual says that its guaranteed that a local variable
>>>
>>> will
>>>>
>>>> start with 0,
>>>> i prefer to initialize everything to a known value myself.
>>>>
>>>> An aditional
>>>>
>>>> Move $varaddress, 00
>>>>
>>>> at startup wont slow things down noticeably when your pc is running
>>>
>>> at 2ghz...
>>>>
>>>> This unit needs to take care of big endian vs. low endian (maybe a
>>>
>>> $define ?)
>>>>
>>>> When i wrote that code i did not pay attention to this...
>>>>
>>>> Anything more complex (like interacting with DHCP server) would be
>>>
>>> too
>>>>
>>>> complex and probably dependent on external units (like synapse x
>>>
>>> lnet
>>>>
>>>> etc). Some people might prefer to use other library instead of the
>>>> default choosen one, etc...
>>>>
>>>> 2011/7/26 Sven Barth:
>>>>>
>>>>> On 26.07.2011 01:23, Paul Nicholls wrote:
>>>>>>
>>>>>> "Jorge Aldo G. de F. Junior"
>>>>>>      wrote in message
>>>>>>
>>>
>>> news:CAAHHabS9aUe9gwyNjkve-XVXsRyf2UPsArh6=fsdpgokugj...@mail.gmail.com...
>>>>>>>
>>>>>>> Some time ago someone asked for a library able to do network
>>>>>>> calculations.
>>>>>>>
>>>>>>> Here is something that might evolve into such library :
>>>>>>>
>>>>>> 
>>>>>>>
>>>>>>> Function NetMaskToHostMask(NetMask : TNetworkIP): TNetworkIP;
>>>>>>> Begin
>>>>>>> Result.Mode := False;
>>>>>>> NetMask.Mode := False;
>>>>>>> Result.IP := NetMask.IP Xor %;
>>>>>>> End;
>>>>>>>
>>>>>> 
>>>>>>
>>>>>> I didn't know that freepascal handled binary formatted numbers?!?
>>>>>>
>>>>>> %
>>>>>
>>>>> There are often new things one can learn about what FPC supports ;)
>>>
>>> (though
>>>>>
>>>>> binary numbers are already old for me ^^)
>>>>>
>>>>> The most recent finding (at least for me) was the abbility to
>>>
>>> initialize
>>>>>
>>>>> local variables.
>>>>>
>>>>> Regards,
>>>>> Sven
>>>>>
>>>>> ___
>>>>> 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
>>>
>>> ___
>>> 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
>
> ___
> 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] Re: Library for network calculation

2011-07-26 Thread Jorge Aldo G. de F. Junior
I dont like to take local variable initialization for granted.

Even if the manual says that its guaranteed that a local variable will
start with 0,
i prefer to initialize everything to a known value myself.

An aditional

Move $varaddress, 00

at startup wont slow things down noticeably when your pc is running at 2ghz...

This unit needs to take care of big endian vs. low endian (maybe a $define ?)

When i wrote that code i did not pay attention to this...

Anything more complex (like interacting with DHCP server) would be too
complex and probably dependent on external units (like synapse x lnet
etc). Some people might prefer to use other library instead of the
default choosen one, etc...

2011/7/26 Sven Barth :
> On 26.07.2011 01:23, Paul Nicholls wrote:
>>
>> "Jorge Aldo G. de F. Junior"
>>   wrote in message
>> news:CAAHHabS9aUe9gwyNjkve-XVXsRyf2UPsArh6=fsdpgokugj...@mail.gmail.com...
>>>
>>> Some time ago someone asked for a library able to do network
>>> calculations.
>>>
>>> Here is something that might evolve into such library :
>>>
>> 
>>>
>>> Function NetMaskToHostMask(NetMask : TNetworkIP): TNetworkIP;
>>> Begin
>>> Result.Mode := False;
>>> NetMask.Mode := False;
>>> Result.IP := NetMask.IP Xor %;
>>> End;
>>>
>> 
>>
>> I didn't know that freepascal handled binary formatted numbers?!?
>>
>> %
>
> There are often new things one can learn about what FPC supports ;) (though
> binary numbers are already old for me ^^)
>
> The most recent finding (at least for me) was the abbility to initialize
> local variables.
>
> Regards,
> Sven
>
> ___
> 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


[fpc-pascal] Re: Library for network calculation

2011-07-25 Thread Jorge Aldo G. de F. Junior
Some time ago someone asked for a library able to do network calculations.

Here is something that might evolve into such library :

Uses
Classes,
SysUtils,
StrUtils;

Type
TNetworkIP = Record Case Mode : Boolean Of
True : (IP1, IP2, IP3, IP4 : Byte);
False : (IP : LongWord);
End;

Function StringToIP(aIP : AnsiString): TNetworkIP;
Begin
Result.Mode := True;
Result.IP4 := StrToInt(Copy2SymbDel(aIP, '.'));
Result.IP3 := StrToInt(Copy2SymbDel(aIP, '.'));
Result.IP2 := StrToInt(Copy2SymbDel(aIP, '.'));
Result.IP1 := StrToInt(Copy2SymbDel(aIP, '.'));
End;

Function IPToString(aIP : TNetworkIP): String;
Begin
aIP.Mode := True;
Result := IntToStr(aIP.IP4) + '.' + IntToStr(aIP.IP3) + '.' +
IntToStr(aIP.IP2) + '.' + IntToStr(aIP.IP1);
End;

Function IPToBits(aIP : TNetworkIP): String;
Begin
aIP.Mode := True;
Result := BinStr(aIP.IP4, 8) + BinStr(aIP.IP3, 8) + BinStr(aIP.IP2,
8) + BinStr(aIP.IP1, 8);
End;

Function NetMaskToHostMask(NetMask : TNetworkIP): TNetworkIP;
Begin
Result.Mode := False;
NetMask.Mode := False;
Result.IP := NetMask.IP Xor %;
End;

Function HostMaskToNetMask(HostMask : TNetworkIP): TNetworkIP;
Begin
Result.Mode := False;
HostMask.Mode := False;
Result.IP := HostMask.IP Xor %;
End;

Function CIDRToNetMask(Bits : Byte): TNetworkIP;
Var
CurBit : Byte;
HostMask : TNetworkIP;
Begin
HostMask.Mode := False;
HostMask.IP := 0;
For CurBit := 1 To 32 - Bits Do
HostMask.IP := HostMask.IP + (1 Shl (CurBit - 1));
Result := HostMaskToNetMask(HostMask);
End;

Function NetMaskToCIDR(NetMask : TNetworkIP): Byte;
Var
CurBit : Byte;
Begin
Result := 0;
For CurBit := 32 DownTo 1 Do
If (NetMask.IP And (1 Shl (CurBit - 1))) = (1 Shl (CurBit - 1)) 
Then
Result := CurBit;
End;

Function BroadcastOf(IP, NetMask : TNetworkIP): TNetworkIP;
Var
HostMask : TNetworkIP;
Begin
HostMask := NetMaskToHostMask(NetMask);
Result.Mode := False;
IP.Mode := False;
HostMask.Mode := False;
Result.IP := IP.IP Or HostMask.IP;
End;

Function NetworkOf(IP, NetMask : TNetworkIP): TNetworkIP;
Begin
IP.Mode := False;
NetMask.Mode := False;
Result.Mode := False;
Result.IP := IP.IP And NetMask.IP;
End;

Function HostCount(NetMask : TNetworkIP): LongWord;
Var
HostMask : TNetworkIP;
Begin
HostMask := NetMaskToHostMask(NetMask);
HostMask.Mode := False;
Result := HostMask.IP + 1;
End;

Function SubNetCount(DefMask, Mask : TNetworkIP): LongWord;
Var
DefHosts,
Hosts : LongWord;
Begin
DefHosts := HostCount(DefMask);
Hosts := HostCount(Mask);
Result := DefHosts Div Hosts;
End;

Function IPToRange(IP, NetMask : TNetworkIP): String;
Var
Net,
Broad : TNetworkIP;
Begin
Net := NetworkOf(IP, NetMask);
Broad := BroadCastOf(IP, NetMask);
Net.Mode := False;
Broad.Mode := False;
Net.IP := Net.IP + 1;
Broad.IP := Broad.IP - 1;
Result := IPToString(Net) + '-' + IPToString(Broad);
End;

Function IncSubNet(BaseIP, Mask : TNetworkIP): TNetworkIP;
Var
HostMask : TNetworkIP;
Begin
HostMask := NetMaskToHostMask(Mask);
HostMask.Mode := False;
HostMask.IP := HostMask.IP + 1;
BaseIP.Mode := False;
Result.Mode := False;
Result.IP := BaseIP.IP + HostMask.IP;
End;

Function HostCountToCIDR(Hosts : LongWord): Byte;
Var
CurBit : Byte;
HostMask : TNetworkIP;
Last1Bit : Byte;
Begin
HostMask.Mode := False;
HostMask.IP := Hosts;
Last1Bit := 0;
For CurBit := 1 To 32 Do
If (HostMask.IP And (1 Shl (CurBit - 1))) = (1 Shl (CurBit - 
1)) Then
Last1Bit := CurBit;
Result := 32 - Last1Bit;
End;

Function HostCountToNetMask(Hosts : LongWord): TNetworkIP;
Begin
Result := CIDRToNetMask(HostCountToCIDR(Hosts));
End;

Function IsMemberOfSubNet(IP, SubNet : TNetworkIP): Boolean;
Begin
IP.Mode := False;
Subnet.Mode := False;
Result := IP.IP And Subnet.IP = Subnet.IP;
End;

Begin
WriteLn(IsMemberOfSubNet(StringToIP(ParamStr(1)), 
StringToIP(Paramstr(2;
End.

Thats old code, i dont remmember what i was thinking when i wrote that.

It surely could be improved (reformated as a unit, for example).

Could this be added to the FCL ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Pascal Actor Model

2011-07-24 Thread Jorge Aldo G. de F. Junior
V2 Release of Pascal Actor Model is done.

I am now im the process of adding UDP message streaming support.

This will allow multithreading to include threads running in other
computers on the same broadcast domain.

Actor is a thread of sorts (it IS a thread but with some specific
semantic rules that comprises the actor model :
http://en.wikipedia.org/wiki/Actor_model)

Messages are objects sent from an actor to another.

In a program hosted in a single computer the messages are objects sent
to/from actors.

When the message needs to jump from a computer to another, the message
object is streamed into a string and sent via UDP, destreamed at
target and injected in the correct actor message queue.

The main program can send/receive messages too (via the mainthreadqueue).

Example program :

Uses
{$IFDEF UNIX}
CThreads,
{$ENDIF}
Classes,
SysUtils,
Actors,
ActorMessages,
ActorLogger,
CustomActors;

Type
TScreenMessage = Class(TCustomStringActorMessage);

TScreenWriterActor = Class(TActorThread)
Public
Procedure ScreenWrite(Var aMessage); Message 'tscreenmessage';
End;

Procedure TScreenWriterActor.ScreenWrite(Var aMessage);
Var
lMessage : TScreenMessage;
Begin
lMessage := UnbundleMessage(aMessage) As TScreenMessage;
WriteLn(ActorName, ': ', lMessage.Data);
End;

Var
gBuffer : String;
gScreenMessage : TScreenMessage;

Begin
DefaultActorMessageTTL := 100; // things are rough at startup,
lets make messages float around forever
Actors.Init('localhost', 'switchboard');
ActorLogger.Init;
CustomActors.Init;
ActorMessageClassFactory.RegisterMessage(TScreenMessage);
RegisterActorClass(TScreenWriterActor);
StartActorInstance('TScreenWriterActor', 'screen1');
StartActorInstance('TScreenWriterActor', 'screen2');
StartActorInstance('TScreenWriterActor', 'screen3');
StartActorInstance('TLoadBalancerActor', 'screen');
AddTargetToActor('screen', 'screen1');
AddTargetToActor('screen', 'screen2');
AddTargetToActor('screen', 'screen3');
DefaultActorMessageTTL := 5; // everything should be quick from now on.
Repeat
Write('Input something : '); ReadLn(gBuffer);
If gBuffer <> 'quit' Then
Begin
gScreenMessage := TScreenMessage.Create('localhost', 
'screen');
gScreenMessage.Data := gBuffer;
Switchboard.Mailbox.Push(gScreenMessage);
End;
Until gBuffer = 'quit';
CustomActors.Fini;
ActorLogger.Fini;
Actors.Fini;
End.

Project is stored at :

https://code.google.com/p/pascal-actor-model/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to free memory allocated by C++ library

2011-06-01 Thread Jorge Aldo G. de F. Junior
generally, the library itself exports a symbol capable of freeing
allocated memory...

can you find any reference to a delete function in this lib ?

2011/6/1 Malcolm Poole :
> Working from the instructions in CinFreepascal.pdf (
> ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf ) I have written
> an interface library to the C++ library libtesseract (
> http://code.google.com/p/tesseract-ocr ).
>
> Everything appears to work well but I am unsure about how to free memory
> which has been reserved by a libtesseract function and returned as a result.
> The original documentation states that "The calling function must delete []
> after use", but the application crashes with an Access Violation if I try to
> free the memory with Dispose or Freemem. I can confirm that the array of
> Integer pointed to by the result of tesseract_AllWordConfidences contains
> valid data.
>
> I would be grateful for any help.
>
> - Malcolm
>
> -
>
> Freepascal declaration and code snippet:
> function tesseract_AllWordConfidences( APIHandle: TTesseract ): PInteger;
> stdcall; external LIBTESSINTF;
>
> var
>  conf: PInteger;
>  FTesseract: TTesseract;
> begin
>  ...
>     conf := tesseract_AllWordConfidences(FTesseract);
>  ...
> end;
>
> 
>
> C function, and documentation from C++ baseapi.h
>
>  /**
>   * Returns all word confidences (between 0 and 100) in an array, terminated
>   * by -1.  The calling function must delete [] after use.
>   * The number of confidences should correspond to the number of space-
>   * delimited words in GetUTF8Text.
>   */
> extern int* EXPORTCALL tesseract_AllWordConfidences(tessHandle APIHandle){
>   return APIHandle->AllWordConfidences();
> }
>
> ___
> 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] Re: Problem with virtual constructors

2011-06-01 Thread Jorge Aldo G. de F. Junior
Cobines solution worked !

not tested constref.

2011/6/1 Jorge Aldo G. de F. Junior :
> 2011/6/1 leledumbo :
>> Yep, this situation would confuse the compiler as it's possible to assign
>> descendant class instance to a class.
>> 1st solution: rename one of the constructor, don't need to use
>> virtual/override
>
> Its a class factory, i cannot have multiple constructors, so i need
> virtual constructors in order to build classes from names.
>
>> 2nd solution: try using constref instead of const (I hope constref has the
>> same semantics as var for classes, where the assigned object must be exactly
>> the instance of expected class, descendants not allowed)
>
> I will try that.
>
>>
>> --
>> View this message in context: 
>> http://free-pascal-general.1045716.n5.nabble.com/Problem-with-virtual-constructors-tp4445729p4445832.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/mailman/listinfo/fpc-pascal
>>
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Problem with virtual constructors

2011-06-01 Thread Jorge Aldo G. de F. Junior
2011/6/1 leledumbo :
> Yep, this situation would confuse the compiler as it's possible to assign
> descendant class instance to a class.
> 1st solution: rename one of the constructor, don't need to use
> virtual/override

Its a class factory, i cannot have multiple constructors, so i need
virtual constructors in order to build classes from names.

> 2nd solution: try using constref instead of const (I hope constref has the
> same semantics as var for classes, where the assigned object must be exactly
> the instance of expected class, descendants not allowed)

I will try that.

>
> --
> View this message in context: 
> http://free-pascal-general.1045716.n5.nabble.com/Problem-with-virtual-constructors-tp4445729p4445832.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/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Problem with virtual constructors

2011-06-01 Thread Jorge Aldo G. de F. Junior
I am having problems with virtual methods.

I have two classes, the second one is a descendent of the first :

1st:

TTreeNode = Class(TObject)
Public
Constructor Create(Const aOwner : TTreeNode); Virtual;

2nd :
TTreeNodeWithProperties = Class(TTreeNodeWithName)
Public
Constructor Create(Const aOwner : TTreeNodeWithProperties); 
Override;

TTreeNodeWithName is the ancestor of TTreeNodeWithProperties, and
TTreeNode is the ancestor of TTreeNodeWithName.

TTreeNode -> TTreeNodeWithName -> TTreeNodeWithProperties

TTreeNodeWithName use the old constructor from the base class (IE.: It
doesnt define a new constructor), so it works ok.

TTreeNodeWithProperties needs to hook the constructor/destructor to
build some aditional encapsulated objects,
so i need to Override the virtual constructor.

As you can see i am using virtual constructors.

The problem is :

If i use Override it causes this output from the compiler :

{
Free Pascal Compiler version 2.4.4 [2011/04/22] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for i386
Compiling htmlnodes.pas
Compiling tree.pas
Compiling namevalue.pas
tree.pas(89,15) Error: There is no method in an ancestor class to be
overridden: "constructor TTreeNodeWithProperties.Create(const
TTreeNodeWithProperties);"
tree.pas(125,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
}

If i use Reintroduce the compiler doesnt complain,
but when the class is instantiated from a class factory,
it builds the wrong class (the constructor called is of the base class
not of the derived one).
IE.: The aditional objects i need in the derived class are not
instantiated, giving a big access violation exception during runtime.

If i leave without override or reintrodce, the compiler complains :

{
Free Pascal Compiler version 2.4.4 [2011/04/22] for i386
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for i386
Compiling htmlnodes.pas
Compiling tree.pas
Compiling namevalue.pas
tree.pas(89,15) Warning: An inherited method is hidden by "constructor
TTreeNodeWithProperties.Create(const TTreeNodeWithProperties);"
htmlnodes.pas(34,15) Error: There is no method in an ancestor class to
be overridden: "constructor
THTMLNode.Create(TTreeNodeWithProperties);"
htmlnodes.pas(80,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
}

I think i am doing something wrong...
I'm left without options...
Pls Help.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Message methods

2011-04-19 Thread Jorge Aldo G. de F. Junior
will it really traverse the classes ?

from what i understood about the manual (and i heavily use that
mechanism) it will only trigger the class where you dispatch to, so,
self.dispatch(msg) only works for the TForm.

if you need more than that you will need to traverse the component
tree yourself. but this is not trully hard to do with tcomponents.

but i may be wrong...

2011/4/19 Darius Blaszyk :
>
> On Apr 19, 2011, at 6:04 PM, Mattias Gaertner wrote:
>
>
>
>
>
> dhkblas...@zeelandnet.nl hat am 19. April 2011 um 17:48 geschrieben:
>
> Hi,
>
> I'm trying to understand how message methods work in FPC. For this I created
> a simple app that shows a message. I also created a second (identical form)
> and I expected that all message methods related to MY_MESSAGE would be
> executed when I pressed either one or the other button. This did not happen
> however even when dispatching through the Application object. Can someone
> explain me please?
>
> Regards, Darius
>
>
>
> Make sure TMsg starts with
>
>
>
> TMsg = record
>   MsgID: DWord;
>   ...
>
> I used a cardinal instead, so no issues there, although I expected to get
> two messages as I have two forms open (code for both identical to the code
> shown below). Instead when I dispatch the message only the class which
> dispatches the message receives it. The other class never does. So how is
> the message handler traversing the classes within the process? I must be
> missing something obvious.
> Darius
>
>
>   TForm1 = class(TForm)
>     Button1: TButton;
>     Button2: TButton;
>     procedure Button1Click(Sender: TObject);
>     procedure Button2Click(Sender: TObject);
>     procedure MessageReceiver(var msg: TMsg); message MY_MESSAGE;
>   private
>     { private declarations }
>   public
>     { public declarations }
>   end;
>
> var    Form1: TForm1;
>
> implementation
>
> {$R *.lfm}
>
> { TForm1 }
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   msg.MSGID := MY_MESSAGE;
>   msg.Data := 'Hello World!';
>   Dispatch(msg);
> end;
>
> procedure TForm1.Button2Click(Sender: TObject);
> begin
>   Form2.Show;
> end;
>
> procedure TForm1.MessageReceiver(var msg: TMsg);
> begin
>   ShowMessage(msg.Data);
> end;
>
>
>
> Mattias
>
>
>
> ___
> 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
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Converting code from C++ to FP....

2011-03-19 Thread Jorge Aldo G. de F. Junior
no one explained so let me try :

> void ForwardModel::SetMixedBoundaryCondition(const int iElec,

void somefunction means its a pascal procedure

>   const double* SX0,

const has the same effect as fpc const before a parameter,

double* SX0
is the same as
double *SX0
or
double * SX0

so this becomes

const SX0 : pdouble (ugly pointer as array Cishism)

>   const double* SY0,

const SY0 : pdouble

>   const double* SZ0,

idem

>   double* SX,
>   double* SY,
>   double* SZ)

SX : pdouble;

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


[fpc-pascal] double dispatch

2011-03-18 Thread Jorge Aldo G. de F. Junior
Can FPC deal with double-dispatch ?

Say you have an object defined as :

Type
TMyObject = Class
Public
Procedure DoSomething(Const aObject : TObject); Virtual;
End;

TMyParameterObject = Class
Public
End;

TMyOtherParameterObject = Class
Public
End;

Can you do something like :

Type
TMyOtherObject = Class(TMyObject)
Public
Procedure DoSomething(Const aObject : TMyParamaterObject); Override; Overload;
Procedure DoSomething(Const aObject : TMyOtherParameterObject);
Override; Overload;
End;

And have the run-time choose the correct implementation to call by
looking at the object type ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Actor Model implementation in Pascal

2011-03-13 Thread Jorge Aldo G. de F. Junior
the actor model can accelerate tasks that would be dealt with in
singlethreaded fashion...

lets suppose that your program needs to read 8 files at the same time,
pre-process them, and use their data.

you can write an actor that opens the file and pre-process it

in your main thread (the program itself, wich is a thread of sorts,
even if not being a TThread) you start 8 of those actors and sit in a
loop waiting for then to produce a message.

your 8 actor instances will, each one, pre-process the data to you.

if your end-user happens to have a multi-core processor, the end
result is that your 8 actors will finish faster than if you used only
one thread to deal with each one of the 8 files...

what i mean is that, under current processor technology, the actor
model is a way to simplify the usage of threads, without the
complexities of locks, semaphores and the like.

you just pass messages around, wich, in the case of my little library,
are just plain tobject descendents...

2011/3/13 Sven Barth :
> Am 13.03.2011 22:30, schrieb Jorge Aldo G. de F. Junior:
>>
>> yes, its a kind of message passing.
>>
>> but mine is in native pascal and i have no intention of making
>> bindings for other languages...
>>
>> its wayyy simpler than mpich too. you just pass TObjects back and
>> forth from threads.
>>
>> (I understand that TCustomMessage is way too restrictive, so i am
>> planing to develop a kind of interface based model, so you can pass
>> arbitrary objects around).
>>
>> it simplyfies thread programming a lot, at a cost of a little overhead.
>>
>> the switchboard (the thing that routes messages between threads) is
>> itself a class factory, so your threads can start/stop other threads
>> (called 'actors" in this context) and send message to them.
>>
>> the default actor implementation is event based, where the class name
>> of the object received triggers an dispatchstr... but i am looking for
>> other ways to deal with message receiving.
>>
>> if you dont like this model you can override TActorThread.Execute and
>> do business your own way...
>>
>> As it is a simple implementation in native pascal, theres no concept
>> of security or whatever.
>>
>> later i can add blowfish encryption to the TCP/IP part of the thing
>> and message authentication using SHA1
>>
>> (TCP/IP streaming of messages across machines, for this little library
>> "Pascal-Actor-Model", is the reason behind so many questions i've sent
>> to this mailing list about multi-threading, blowfish and SHA1
>> encryption...)
>
> I might look at this once I have a usecase for it (currently I have rather
> single threaded problems to solve :P ). Thank you for sharing, though.
>
> Regards,
> Sven
> ___
> 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] Actor Model implementation in Pascal

2011-03-13 Thread Jorge Aldo G. de F. Junior
yes, its a kind of message passing.

but mine is in native pascal and i have no intention of making
bindings for other languages...

its wayyy simpler than mpich too. you just pass TObjects back and
forth from threads.

(I understand that TCustomMessage is way too restrictive, so i am
planing to develop a kind of interface based model, so you can pass
arbitrary objects around).

it simplyfies thread programming a lot, at a cost of a little overhead.

the switchboard (the thing that routes messages between threads) is
itself a class factory, so your threads can start/stop other threads
(called 'actors" in this context) and send message to them.

the default actor implementation is event based, where the class name
of the object received triggers an dispatchstr... but i am looking for
other ways to deal with message receiving.

if you dont like this model you can override TActorThread.Execute and
do business your own way...

As it is a simple implementation in native pascal, theres no concept
of security or whatever.

later i can add blowfish encryption to the TCP/IP part of the thing
and message authentication using SHA1

(TCP/IP streaming of messages across machines, for this little library
"Pascal-Actor-Model", is the reason behind so many questions i've sent
to this mailing list about multi-threading, blowfish and SHA1
encryption...)

2011/3/13 Sven Barth :
> Am 13.03.2011 22:08, schrieb Jorge Aldo G. de F. Junior:
>>
>> This is my attempt at implementing an actor model in freepascal
>>
>
> Never heard of "actor model" yet, but I'll read about it ^^
>
>> http://code.google.com/p/pascal-actor-model/
>>
>> This is an very early code. Any help is appreciated.
>>
>> Every communication between thread is done by using messages (wich are
>> itself objects).
>>
>> I am improving the current code a bit so this EXACTLY release maybe
>> dont compiles.
>>
>> If you want to compile the test code, simply create dummy
>> procedure/functions for anything that the compiler complains about not
>> being implemented.
>>
>> The base code works, i am just trying to implement a form of
>> message/object streaming to allow threads to communicate across TCP/IP
>> and not just by using the internal switchboard queues.
>
> Do you mean something like this? http://wiki.lazarus.freepascal.org/MPICH
>
> Regards,
> Sven
> ___
> 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


[fpc-pascal] Actor Model implementation in Pascal

2011-03-13 Thread Jorge Aldo G. de F. Junior
This is my attempt at implementing an actor model in freepascal

http://code.google.com/p/pascal-actor-model/

This is an very early code. Any help is appreciated.

Every communication between thread is done by using messages (wich are
itself objects).

I am improving the current code a bit so this EXACTLY release maybe
dont compiles.

If you want to compile the test code, simply create dummy
procedure/functions for anything that the compiler complains about not
being implemented.

The base code works, i am just trying to implement a form of
message/object streaming to allow threads to communicate across TCP/IP
and not just by using the internal switchboard queues.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] com port using prolific driver

2011-03-13 Thread Jorge Aldo G. de F. Junior
try synaser, its portable across various O.S. and provides a very
modern interface.

2011/3/12 Paul Breneman :
> John,
>
>> I'm trying to get data from a device via a serial (com) port, 9600 baud,
>> connected via the prolific cable (serial to usb). This allows one to
>> connect
>> a serial device via a usb port (many new PCs do not have a real serial
>> port.
>> I've  loaded the prolific driver.
>>
>> Anyone have fpc program that'll work on win xp.
>
> I have some files here that might help you get started using the SynaSer
> package with FPC:
>  http://www.turbocontrol.com/simpleserial.htm
>
> --
> Regards,
> Paul Breneman
> www.dbReplication.com - VCL database replication components
> www.TurboControl.com - Hardware and software development services
> - Educational programming project for environment monitoring
> - Information on using FreePascal for embedded systems
> - Support information for the TurboPower open source libraries
> ___
> 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


[fpc-pascal] Mutithreaded book

2011-03-07 Thread Jorge Aldo G. de F. Junior
I am developing an application that should scale well into those
multicore CPUs that we have today,
so, basically, i have to use threads.

Anybody knows a good book about multi-thread programming in general,
message passing etc ?

I need to know some technices to deal with some problems i am finding, for one :

1 - I use a producer-consumer model, that works ok (i have a
tobjectqueue version that is thread safe), but... what to do when more
than one consumer exists ?

I tried to pass the same object (the data) to all consumers, but now i
have a problem, each consumer is a thread, and each thread needs to
deallloc the object (i pass TObjects accross threads using the
thread-safe queue as medium) as soon as the object is not being used.

2 - How to deal with runtime reconfigurations, example :

i have a chain of producers/consumers like

receiveviaudp -> decrypt blowfish -> send to N consumers ... -> do
something with the tobject (wich is a tmemorystream)

Well, if i remove a consumer from the chain, the producer can not
detect this (it has a pointer to a consumer instance, but if i
free/dealloc the consumer, the pointer in the producer will still
"ftarget <> nil" result true (the numeric value of the pointer is
still the same, just that now it is semantically invalid))...

3 - How to wait for two signals :

Each thread must have some kind of wait, for one, the udp thread waits
for udp packets, the consumer of the udpthread (the tthread that
receives packets generated by the udp thread) waits of a TEventObject
to flag (the producer allways sets a TEventObject as soon as it places
something into the consumer queue) etc...

But this raises a problem :

How to wait for two events at the same time ? for one, how to wait for
a TEventObject.WaitFor AND for a UDP packet to arive ? (i am using
Ararat Synapse, it has a CanRead method, but i can use the socket
itself (property Socket of the TUDPBlockSocket object) for a
select...)

Basically, how to fpSelect an TEventObject ?

I need to wake-up the tthread if a Teventobject flags OR if the socket
has activity...

Well i need to know better about message-passing and consumer-producer
models in general, as i think my theory understanding is lacking...

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


Re: [fpc-pascal] TBlowfishDecryptStream flaw

2011-03-06 Thread Jorge Aldo G. de F. Junior
Check those two programs

=== Program A =

Program A;

Uses
Classes,
BlowFish;

Var
lSource,
lIntermediate : TMemoryStream;
lEncrypter : TBlowfishEncryptStream;


Begin
lSource := TMemoryStream.Create;
lSource.LoadFromFile('test7.pas');
WriteLn(lSource.Size);

lIntermediate := TMemoryStream.Create;  
lEncrypter := TBlowfishEncryptStream.Create('123', lIntermediate);
lEncrypter.CopyFrom(lSource, lSource.Size);
lEncrypter.Free;

WriteLn(lIntermediate.Size);

// SendStreamViaSocket(lIntermediate); { Lets pretend this function
automatically checks the size of the stream }

lIntermediate.Free;
lSource.Free;

End.

== EOF =

== Program B =

Program B;

Uses
Classes,
Blowfish;

Var
lIntermediate,
lDestination : TMemoryStream;
lDecrypter : TBlowfishDecryptStream;

Begin

lIntermediate := TMemoryStream.Create;
lDestination := TMemoryStream.Create;

// ReceiveStreamViaSocket(lIntermediate);  { Lets pretend this
function can check the socket for the size of the last UDP packet }

WriteLn(lIntermediate.Size);
lIntermediate.Seek(0, soFromBeginning);

lDecrypter := TBlowfishDecryptStream.Create('123', lIntermediate);
lDestination.CopyFrom(lDecrypter, lIntermediate.Size); { Read how much 
??? }
lDecrypter.Free;

WriteLn(lDestination.Size);

lDestination.SaveToFile('test7.txt');

lSource.Free;
lIntermediate.Free;
lDestination.Free;
End.

= EOF =

The problem consists that, if lIntermediate.Size is not equal to
lSource.Size, i will not know how much bytes to "copyfrom" from the
decrypter.

For one, if a 10 bytes lSource generates a 20 bytes lIntermediate, and
no clear rule show what are the mathematical relationship of those
sizes,
then asking 20 bytes (as lIntermediate.Size will show) will yield
wrong results (Worse if the result at lIntermediate is smaller than
the original lSource.Size).

But, if TBlowfishDecryptStream worked backwards (the create parameters
being the key and the DESTINATION stream, not the source) then this
would makes sense.

The problem ends up to be that by having a source parameter instead of
a destination paramater this makes you have to read out bytes from the
decrypter (you push out instead of pushing in), while
at the same time you cannot know how many bytes you really have to
read by just looking at the decrypter current state.

Thats a set of mutually exclusive assumptions.

Now this :

= Program C 

Program B;

Uses
Classes,
Blowfish;

Var
lIntermediate,
lDestination : TMemoryStream;
lDecrypter : TBlowfishDecryptStream;

Begin

lIntermediate := TMemoryStream.Create;
lDestination := TMemoryStream.Create;

// ReceiveStreamViaSocket(lIntermediate);  { Lets pretend this
function can check the socket for the size of the last UDP packet }

WriteLn(lIntermediate.Size);
lIntermediate.Seek(0, soFromBeginning);

lDecrypter := TBlowfishDecryptStream.Create('123', lDestination);
lDecrypter.CopyFrom(lIntermediate, lIntermediate.Size);
lDecrypter.Free;

WriteLn(lDestination.Size);

lDestination.SaveToFile('test7.txt');

lSource.Free;
lIntermediate.Free;
lDestination.Free;
End.

=== EOF ===

This would work better, cause now you just need to know how much bytes
to push into the decrypter, something that is readily available at the
lIntermediate stream.

While i bet that the blowfish algorithm has an input to output size
relationship of one to one (as most stream cyphers), this is not a
good choice for other algorithms wich could yield different output
sizes for a given input...

2011/3/6 Michael Van Canneyt :
>
>
> On Sat, 5 Mar 2011, Jorge Aldo G. de F. Junior wrote:
>
>> i have a problem with TBlowfishDecryptStream :
>
> [snip]
>>
>> The problem now is that it eats chars at the end of the generated
>> lBuffer (tested by taking a tmemorystream thru tblowfishencryptstream,
>> then taking the result to this tblowfishdecryptstream, than back to a
>> tmemorystream and comparing the results, the original tmemorystream
>> shows to be bigger than the resulting tmemorystream)...
>>
>> Basically i need :
>>
>> 1 - That TBlowfishEncryptStream guarantees that the same ammount of
>> bytes feed to it, ends up at the output of it
>
> That should be the case. See below for an explanation why you get different
> results.
>
>> 2 - That TBlowfishDecryptStream simply allows us to use Size property
&

[fpc-pascal] TBlowfishDecryptStream flaw

2011-03-05 Thread Jorge Aldo G. de F. Junior
i have a problem with TBlowfishDecryptStream :

Try
lBuffer := TMemoryStream.Create;
lSource := (aObject As TMemoryStream);
lSource.Seek(0, soFromBeginning);
lCypher := TBlowfishDecryptStream.Create(fKey, 
lSource);
lBuffer.LoadFromStream(lCypher);
Except
On E: Exception Do
WriteLn(E.ClassName, '->', E.Message);
End;

Spits out the "EBlowFishError" exception with "Seek not allowed on
encryption streams"

The problem is basically that TBlowfishDecryptStream does not allow to
use the "size" propertie, making it very hard to use it.

There are various ways to do this, for one :

Try
lBuffer := TMemoryStream.Create;
lSource := (aObject As TMemoryStream);
lSource.Seek(0, soFromBeginning);
lCypher := TBlowfishDecryptStream.Create(fKey, 
lSource);
lBuffer.CopyFrom(lCypher, lCypher.Size);
Except
On E: Exception Do
WriteLn(E.ClassName, '->', E.Message);
End;

But this gives the exact same error,

the last one is this :

Try
lBuffer := TMemoryStream.Create;
lSource := (aObject As TMemoryStream);
lSource.Seek(0, soFromBeginning);
lCypher := TBlowfishDecryptStream.Create(fKey, 
lSource);
lBuffer.CopyFrom(lCypher, lSource.Size);
Except
On E: Exception Do
WriteLn(E.ClassName, '->', E.Message);
End;

The problem now is that it eats chars at the end of the generated
lBuffer (tested by taking a tmemorystream thru tblowfishencryptstream,
then taking the result to this tblowfishdecryptstream, than back to a
tmemorystream and comparing the results, the original tmemorystream
shows to be bigger than the resulting tmemorystream)...

Basically i need :

1 - That TBlowfishEncryptStream guarantees that the same ammount of
bytes feed to it, ends up at the output of it
2 - That TBlowfishDecryptStream simply allows us to use Size property
(Well, sometimes i receive a tmemorystream in an unrelated part of the
code so i cannot read the original size the buffer had before
encrypting)...

Test case :

= Test7.pas ==

Uses
Classes,
BlowFish;

Var
lSource,
lIntermediate,
lDestination : TMemoryStream;
lEncrypter : TBlowfishEncryptStream;
lDecrypter : TBlowfishDecryptStream;

Begin
lSource := TMemoryStream.Create;
lIntermediate := TMemoryStream.Create;
lDestination := TMemoryStream.Create;

lSource.LoadFromFile('test7.pas');
WriteLn(lSource.Size);

lEncrypter := TBlowfishEncryptStream.Create('123', lIntermediate);
lEncrypter.CopyFrom(lSource, lSource.Size);
WriteLn(lIntermediate.Size);
lIntermediate.Seek(0, soFromBeginning);

lDecrypter := TBlowfishDecryptStream.Create('123', lIntermediate);
lDestination.CopyFrom(lDecrypter, lSource.Size);

WriteLn(lDestination.Size);

lDestination.SaveToFile('test7.txt');

lSource.Free;
lIntermediate.Free;
lDestination.Free;
End.
 output =

2147
2144
2144

IE : It misses 3 chars...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] SHA1 of a TMemoryStream

2011-03-05 Thread Jorge Aldo G. de F. Junior
Found the solution,

untyped var parameters expects a real variable so it "internally"
generates a pointer out of the address of the variable.

SHA1Buffer uses an untyped parameter, so, passing a pointer to it
makes it try to hash the pointer itself (and the rest of the memory
positioned exactly besides it, until data.size is meet).

The solution was to dereference the pointer :

SHA1Buffer(Data.Memory^, Data.Size); // damm little ^ !

Thanks !!

2011/3/5 Marco van de Voort :
> In our previous episode, Jorge Aldo G. de F. Junior said:
>> Uses
>>       Classes,
>>       SHA1;
>>
>> Var
>>       Data : TMemoryStream;
>>       Hash : TSHA1Digest;
>>
>> Begin
>>       Data := TMemoryStream.Create;
>>       Data.LoadFromFile('test6.pas');
>
> Data.Position:=0;
>
>>       Hash := SHA1Buffer(Data.Memory, Data.Size);
>>       WriteLn(SHA1Print(Hash));
>>       Data.Free;
>> End.
>
>
> ___
> 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


[fpc-pascal] SHA1 of a TMemoryStream

2011-03-05 Thread Jorge Aldo G. de F. Junior
I need to perform a Hash of data stored at a TMemoryStream...

But unfortunately, the following program spits out different results
if i run it in sucession... Note that the file being read (test6.pas)
never changes.

Uses
Classes,
SHA1;

Var
Data : TMemoryStream;
Hash : TSHA1Digest;

Begin
Data := TMemoryStream.Create;
Data.LoadFromFile('test6.pas');
Hash := SHA1Buffer(Data.Memory, Data.Size);
WriteLn(SHA1Print(Hash));
Data.Free;
End.

Am i doing (probably) anything wrong ?

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


Re: [fpc-pascal] Forward type not resolved

2011-03-03 Thread Jorge Aldo G. de F. Junior
im still trying to understand how the compiler understood that
sentence in order to generate THAT specific error... (while ignoring a
totally out of place 'of' token)

2011/3/3 waldo kitty :
> On 3/3/2011 17:15, Leonardo M. Ramé wrote:
>>
>> Sorry, the error was here:
>>
>>    TOnSqueeze = procedure (AQuote: TQuote); of object;
>>
>> This line should be:
>>
>>    TOnSqueeze = procedure (AQuote: TQuote) of object;
>
> amazing what a misplaced semi-colon will do, eh? ;)
>
> i would have thought that there would have been an additional error
> concerning the trailing "of object"... was there? did it give a clue as to
> the actual error of the misplaced semi-colon?
> ___
> 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


[fpc-pascal] Consumer producer unit (donation to fcl)

2011-03-01 Thread Jorge Aldo G. de F. Junior
i have implemented a small consumer x producer unit (ie: threads that
produce or consume tobjects)

it is thread safe (based around a tthreadsafequeue with signalling -
the thread can sleep/wait arbitrary timeout time while its queue is
empty waiting for the producer)

is it interesting for the fcl ?

i want to donate it, and i think it can be incremented with other functions.

currently theres the following :

TProducer (thread that produces tobjects, placing then on the queue of
a consumer)
TConsumer (thread that consumes tobjects thru a queue)
TConsumerProducer (kind of a proxy, that consumes tobjects in a side,
process them and sends then to another consumer, it inherits from
TConsumer)
TRandomMultiplexerProducerConsumerThread (similar to the previous, but
has more than one consumer attached, it selects the next one to send
its tobjects by random)
TRoundRobinMultiplexerProducerConsumerThread (similar to the previous,
but instead of random chance, uses a round robing fashion)
TCustomAddressableMultiplexer (similar to the previous, but allows a
kind of addressability of the tobjects, selecting with consumer to
send to, by using a message address and a hashtable -
tfphashobjectlist)

Now i am developing bus and other models (various threads sharing a
bus to send messages to each other, where each thread has an address).

but the basic implementation evolves around the consumer producer model.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Passing objects to libraries and back

2011-02-25 Thread Jorge Aldo G. de F. Junior
I want to add plugin suport to an network app i am developing,

the easiest way of doing this is passing the internal objects as
parameters to funcions inside libraries (.so or .dll)

something like

procedure plugin(const parameter : tobject): tobject; external;

is it allowed ?

or if i cant use objects, can i pass ansistrings ? (i can serialize
deserialize the object internal states)

i know that passing ansistrings or tobjects would make the plugin
system compatible with pascal only, but i dont care about that.

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


Re: [fpc-pascal] Re: Embedded web server

2011-02-25 Thread Jorge Aldo G. de F. Junior
whos going to mantain nYume ?

cause lightwebserver is mantained... (while i dont mantain the rest of
powtils site, i can mantain lightwebserver, webtemplate and pasjs...),
yet nYume is unmantained...

(i understand that using lightwebserver places the burden of having to
use synapse, but, you really cant do anything more advanced like a
full fledged webserver without resorting to synapse, lnet or indy).

2011/2/25  :
>
>
> On Fri, 25 Feb 2011, Florian Klaempfl wrote:
>
>> Am 25.02.2011 11:38, schrieb michael.vancann...@wisa.be:
>>
>>> unless we
>>> include
>>> lnet in FPC.
>>
>> Well, fppkg uses it for years already, see utils/fppkg/lnet
>
> I am aware of that, but that is an old unmaintained copy, and that is
> exactly the problem: There are 2 parallel implementations.
>
> I have no problem with including it in FPC, but it's not my call...
>
> Michael.
> ___
> 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] Re: Embedded web server

2011-02-25 Thread Jorge Aldo G. de F. Junior
iirc aservia was an experiment.

why would you choose aservia over lightwebserver ?

2011/2/25 Ben :
> Op 2011-02-25 10:27, Ben het geskryf:
>>
>> I checked out the whole 'dev' tree sitting at revision r444.
>> That code [Aservia] doesn't compile at all... I read the readme file and
>
> OK, after looking at the FPC code to see how the old socket functions
> map to the newer fp* functions I managed to fix and compile aservia
> under FPC 2.4.3 Linux 64-bit.
>
> Now how am I supposed to run it as a webserver? Simply running
> './aservia' outputs some HTML to the console and terminates the
> application. Output shown below:
>
> -
> [aservia]$ ./aservia -h
> Content-type: text/html
>
> 
> 
> 
> Serving from seven to eleven every night,
> It really makes life a drag, I don't think that's right.
> I've really, really been the best of fools, I did what I could.
> 'Cause I love you, baby,
> ...snip...
> Love,
>
>  Aservia
> 
> 
> 
> -
>
>
> --
>
>            Ben.
>
> ___
> 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] Embedded web server

2011-02-24 Thread Jorge Aldo G. de F. Junior
whats wrong with that ?

Powutils is a CGI library
Synapse is a sockets library.

No contradiction here.

Well, i am the author of the refered software, so i can say.

Anyway i already answered your question.

2011/2/24 Marcos Douglas :
> On Thu, Feb 24, 2011 at 12:59 PM, Jorge Aldo G. de F. Junior
>  wrote:
>> lightwebserver uses synapse as its socket handling library
>>
>
> lighwebserver uses Synapse and is in Powtils' SVN? Okay... I think.
>
>
> Marcos Douglas
> ___
> 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] Embedded web server

2011-02-24 Thread Jorge Aldo G. de F. Junior
lightwebserver uses synapse as its socket handling library

2011/2/24 Marcos Douglas :
> On Thu, Feb 24, 2011 at 12:34 PM, Jorge Aldo G. de F. Junior
>  wrote:
>> http://powtils.googlecode.com/svn/dev/tools/lightwebserver/
>>
>> lightwebserver is more stable and has all features (Even https)
>>
>> its easily expansible.
>>
>> theres two versions : the faster threaded and the slower but safer
>> forked version (lightwebserver2).
>>
>> the forked version can even plug the powutils directly...
>
> Do you use it?
> What about Synapse (I think the example is HTTPSrv) vs Powtils, what
> is more stable/features?
>
>
> Marcos Douglas
> ___
> 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] Embedded web server

2011-02-24 Thread Jorge Aldo G. de F. Junior
http://powtils.googlecode.com/svn/dev/tools/lightwebserver/

lightwebserver is more stable and has all features (Even https)

its easily expansible.

theres two versions : the faster threaded and the slower but safer
forked version (lightwebserver2).

the forked version can even plug the powutils directly...

2011/2/24 Marcos Douglas :
> 2011/2/23 Héctor S. Ponce :
>> Hello, could you please send me information about the web server? link is
>> broken...
>>
>
> See the project Aservia, in Powtils' tools
> http://powtils.googlecode.com/svn/dev/tools/aservia/
> It is based on nYume, see :
> http://free-pascal-general.1045716.n5.nabble.com/Aservia-Web-Server-td2818484.html
>
>
> Marcos Douglas
> ___
> 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


  1   2   >