[fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Graeme Geldenhuys
Hi,

Can somebody from the FPC team contact the JSON website
[http://www.json.org/] so that they can list Free Pascal Compiler's
fcl-json package under Delphi/Object Pascal section.

No need to leave FPC out of the list - considering the other obscure names
in that list. We should promote FPC wherever possible. :)

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Tomas Hajny
On Fri, May 14, 2010 09:16, Graeme Geldenhuys wrote:


Hi Graeme,

> Can somebody from the FPC team contact the JSON website
> [http://www.json.org/] so that they can list Free Pascal Compiler's
> fcl-json package under Delphi/Object Pascal section.
>
> No need to leave FPC out of the list - considering the other obscure names
> in that list. We should promote FPC wherever possible. :)

Is there a reason why you can't do it yourself?

Tomas


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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Michael Van Canneyt



On Fri, 14 May 2010, Tomas Hajny wrote:


On Fri, May 14, 2010 09:16, Graeme Geldenhuys wrote:


Hi Graeme,


Can somebody from the FPC team contact the JSON website
[http://www.json.org/] so that they can list Free Pascal Compiler's
fcl-json package under Delphi/Object Pascal section.

No need to leave FPC out of the list - considering the other obscure names
in that list. We should promote FPC wherever possible. :)


Is there a reason why you can't do it yourself?


I guess because the 'weight' of a developer is higher than
the weight of a user :-)

If Graeme doesn't do it, I will.

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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Graeme Geldenhuys
On 14 May 2010 09:29, Tomas Hajny wrote:
>
> Is there a reason why you can't do it yourself?

The reason I said somebody from the FPC team is because maybe there is
a "unknown to me" reason why fcl-jason is not listed on the JSON
website. I don't use JSON (never have), so I don't know if it is
feature complete etc... Something a FPC team member might know.

If fcl-json is feature complete, then I don't mind emailing the JSON
website myself, that is not an issue at all.

-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Michael Van Canneyt



On Fri, 14 May 2010, Graeme Geldenhuys wrote:


On 14 May 2010 09:29, Tomas Hajny wrote:


Is there a reason why you can't do it yourself?


The reason I said somebody from the FPC team is because maybe there is
a "unknown to me" reason why fcl-jason is not listed on the JSON
website. I don't use JSON (never have), so I don't know if it is
feature complete etc... Something a FPC team member might know.

If fcl-json is feature complete, then I don't mind emailing the JSON
website myself, that is not an issue at all.


What is feature complete ?

It works for all use cases. All JSON objects can be read/written.
WST uses it.

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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Graeme Geldenhuys
On 14 May 2010 09:48, Michael Van Canneyt  wrote:
>
> I guess because the 'weight' of a developer is higher than
> the weight of a user :-)

That too. :)
So Michael, as a FPC team member, would you mind doing the honors. You
probably know a lot more about fcl-json that I do (I never used it
before).


-- 
Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Michael Van Canneyt



On Fri, 14 May 2010, Graeme Geldenhuys wrote:


On 14 May 2010 09:48, Michael Van Canneyt  wrote:


I guess because the 'weight' of a developer is higher than
the weight of a user :-)


That too. :)
So Michael, as a FPC team member, would you mind doing the honors. You
probably know a lot more about fcl-json that I do (I never used it
before).


Since I wrote the code, I guess I do. I'll contact them.

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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Jonas Maebe

On 14 May 2010, at 09:51, Michael Van Canneyt wrote:

> On Fri, 14 May 2010, Graeme Geldenhuys wrote:
> 
>> If fcl-json is feature complete, then I don't mind emailing the JSON
>> website myself, that is not an issue at all.
> 
> What is feature complete ?

I suppose supporting everything defined in http://www.ietf.org/rfc/rfc4627.txt 
(it's a fairly short and simple rfc, so that's certainly likely).


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


Re: [fpc-pascal] FPC not mentioned on JSON website?

2010-05-14 Thread Michael Van Canneyt



On Fri, 14 May 2010, Jonas Maebe wrote:



On 14 May 2010, at 09:51, Michael Van Canneyt wrote:


On Fri, 14 May 2010, Graeme Geldenhuys wrote:


If fcl-json is feature complete, then I don't mind emailing the JSON
website myself, that is not an issue at all.


What is feature complete ?


I suppose supporting everything defined in http://www.ietf.org/rfc/rfc4627.txt 
(it's a fairly short and simple rfc, so that's certainly likely).


That, it certainly is.

But one could envisage a complete streaming system 
(as in converting RTTI to streams) based on JSON.



From an Object Pascal point of view, that would be more

feature-complete.

Anyway, I contacted the author: Douglas Crockford.

It was funny to discover that I actually own a book written
by this man. I knew the name rang a bell... :-)

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


Re: Re[4]: [fpc-pascal] TAP-Win32

2010-05-14 Thread Jorge Aldo G. de F. Junior
Uses
Windows,
Classes,
BlckSock;

Const
TAP_Device = '\\.\Global\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap'#00;
TAP_Buffer = 8192;

Var
Handle : Integer;
Buffer : Pointer;
Stream : THandleStream;
Count  : Integer;

Begin
Handle := CreateFileA(PChar(TAP_Device), GENERIC_READ or
GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0);
Stream := THandleStream.Create(Handle);
Buffer := GetMem(TAP_Buffer);
Repeat
Count := Stream.Read(Buffer^, TAP_Buffer);
If Count > 0 Then
Stream.Write(Buffer^, Count);
Until False;
Stream.Free;
FreeMem(Buffer, TAP_Buffer);
CloseHandle(Handle);
End.


=

i am able to receive packets setting up a tap device with a fixed ip
and doing ping to the gateway address...

now i need to decipher the ioctl calls...

2010/5/13 José Mejuto :
> Hello FPC-Pascal,
>
> Friday, May 14, 2010, 12:14:31 AM, you wrote:
>
> JAGdFJ> This is the C# example i found :
> JAGdFJ> http://www.varsanofiev.com/inside/TunTest.cs
>
> Also this line is wrong IMHO:
>
> TAP_Device = '.\\Global\\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap';
>
> it should be:
>
> TAP_Device = '\\.\Global\{44F7688F-77FA-43DC-8D8F-9CBA23E01BB0}.tap';
>
> Pascal does not need the slash escape sequence.
>
> --
> Best regards,
>  José
>
> ___
> fpc-pascal maillist  -  fpc-pas...@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[6]: [fpc-pascal] TAP-Win32

2010-05-14 Thread José Mejuto
Hello FPC-Pascal,

Friday, May 14, 2010, 1:34:08 PM, you wrote:

JAGdFJ> i am able to receive packets setting up a tap device with a
fixed ip
JAGdFJ> and doing ping to the gateway address...
JAGdFJ> now i need to decipher the ioctl calls...

Sorry, I can not help more, I had never used TAP and even I do not
know what it is (except a brief definition in wikipedia).

-- 
Best regards,
 José

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


[fpc-pascal] question about class

2010-05-14 Thread spir ☣
Hello,

I'm trying to transform a manually implemented type, with pseudo-method as 
funcs/procs, into an fpc "class" type; and facing numerous issue: namely 3 
whole pages of compiler errors ;-).
Are there somewhere more or less pedagogic examples of class code?

*self*
Do i need to explicitely name self as param? Is self actually a pointer? If 
yes, do I need to treat as such, or is this magically handled by the language? 
Eg self^.prop or self.prop?

*destructor*
Is a destructor required? What is it supposed to do? Deallocation? (but then 
self disappears in the middle of a method it is the target of...). Isn't it 
garbage collected when dereferenced?

*type mutual recursion*
One func method returns an object of another type (actualy a record, but I 
guess it does not make any difference). But this record object holds a pointer 
to an object of the first type... Similar issue with a param of another method. 
There was no issue in the non-class version of the same code, since 
pseudo-methods (and their params and return values) did not need to be 
pre-declared.
By the way: why do we need to pre-declare methods, since they are bound to 
their type anyway by their name prefixes? (I mean so-called "qualified names" 
of the form type.methodName).

Denis


vit esse estrany ☣

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


Re: [fpc-pascal] question about class

2010-05-14 Thread David Emerson
I'm no expert so these answers may be a bit off, but I figure any help is nice 
during US business hours...

> Are there somewhere more or less pedagogic examples of class code?

I've never found any. I've learned largely by studying (and occasionally 
fixing) 
fpgui code.

> *self*
> Do i need to explicitely name self as param?

Depends on context? I use 'self' for the following:

- if I am inside a 'with' context, and there is another data type with an 
identical field name, I'll reference self.field_name
- even without a 'with' context I'll sometimes use it to make things easier to 
read
- to call a procedure which takes a class as a parameter. A particularly common 
example would be a constructor that requires a parameter which will be its 
owner: e.g. within a method of a 'window' object I might call Tscrollbar.create 
(self); so that the window is the owner of the scrollbar... and the scrollbar 
can look at the window to get its size.

> Is self actually a pointer? If yes, do I need to treat as such, or is this
> magically handled by the language? Eg self^.prop or self.prop?

I'm not sure, but self.method and self.field have always worked fine for me. 
Never tried to put a caret into the syntax.

> *destructor*
> Is a destructor required? What is it supposed to do? Deallocation? (but then
> self disappears in the middle of a method it is the target of...).

Do you mean, are you required to *write* a destructor? No, but you can. I use 
them to destroy child objects.

Or, do you mean, do you need to *call* a destructor? Yes, you do. You should 
call "Free" rather than "Destroy". I don't recall why.

> Isn't it garbage collected when dereferenced?

No, classes are not automatically deallocated when dereferenced. They are 
pointers, and there may be several references to them (and they are not 
reference-counted) so there is no automatic deallocation. You need to call 
Free.

> *type mutual recursion*
> One func method returns an object of another type (actualy a record, but I
> guess it does not make any difference). But this record object holds a pointer
> to an object of the first type... Similar issue with a param of another
> method. There was no issue in the non-class version of the same code, since
> pseudo-methods (and their params and return values) did not need to be
> pre-declared.

I'm not sure I understand your question but maybe this is your answer:

a_type = class;
b_type = class;

a_type = class
  b : b_type;
  end;

b_type = class
  a : a_type;
  end;

> By the way: why do we need to pre-declare methods, since they are bound to
> their type anyway by their name prefixes? (I mean so-called "qualified names"
> of the form type.methodName).

You mean ... as opposed to a non-class procedure, which could simply be defined 
in the implementation section of a unit, without any mention in the interface? 
I don't know all the proper terminology, but my best guess is this: when the 
compiler creates the framework for the class, it needs to have everything 
available. Once it gets to the implementation section, it's too late to be 
adding more methods into that framework, or VMT, or whatever the thing is 
called.

Hope this was helpful and not terribly incorrect!

Cheers,
David.

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


Re: [fpc-pascal] question about class

2010-05-14 Thread Andrew Hall
>> Do i need to explicitely name self as param?
self is a reserved keyword which represents the reference to the object of 
context (much the same as using "result" in a function) - it is understood by 
the compiler and does not need to be specified.

>> Is self actually a pointer? If yes, do I need to treat as such, or is this
>> magically handled by the language? Eg self^.prop or self.prop?
Self is a pointer.  Delphi (and FPC which it is based upon) treats the 
dereference ^ as implicit.

>> *destructor*
>> Is a destructor required? What is it supposed to do? Deallocation? (but then
>> self disappears in the middle of a method it is the target of...).
A destructor is only required if your object has its own private structures to 
finalise/dispose/etc.  If you do not need your own destructor, the virtual 
destructor in TObject will suffice.  

> Or, do you mean, do you need to *call* a destructor? Yes, you do. You should 
> call "Free" rather than "Destroy". I don't recall why.
Free is used because it is a static method and can be safely called against a 
nil object reference (Destroy is virtual, and so will raise an access violation 
when the application attempts to access the object's VMT).  Free simply checks 
whether self is nil...   "if self <> nil then Destroy"

>> Isn't it garbage collected when dereferenced?
As David says, objects are not reference counted.  You must use interfaces 
(which are usually implemented via TInterfacedObject) for that feature.  Note 
that interfaces are not "garbage collected", per se - they are immediately 
released when the reference count hits zero.  This is in contrast to other 
languages where objects are cleared by a "garbage collection" process triggered 
either intermittently, or when other conditions are met (eg. low memory).  

>> *type mutual recursion*
>> One func method returns an object of another type (actualy a record, but I
>> guess it does not make any difference). But this record object holds a 
>> pointer
>> to an object of the first type... Similar issue with a param of another
>> method. There was no issue in the non-class version of the same code, since
>> pseudo-methods (and their params and return values) did not need to be
>> pre-declared.
Where there are cross references to classes in the same section, one or both 
can be declared TMyClass = class; as long as the full declaration appears later 
in the same section.  This allows two classes to reference each other.  This 
does not work with records, however.  Note - that generic pointers, or using 
base class references (like TObject) in the declaration can also be useful 
approaches to issues around access to class types (which can be cast in the 
implementation "fMyTObject as TMySpecificObject".

>> By the way: why do we need to pre-declare methods, since they are bound to
>> their type anyway by their name prefixes? (I mean so-called "qualified names"
>> of the form type.methodName).
The only part of a unit visible to another unit is the interface section.  
Everything other units might touch must be declared there (same as non-class 
procedures and functions).  Visibility of fields and methods in a class is 
controlled using "published/public/protected/public"

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