[bug] CStruct pointers-to-CStructs don't work properly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug] CStruct pointers-to-CStructs don't work properly

Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/node/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   tonyg
 Status:       active
 Attachment:   http://smalltalk.gnu.org/files/issues/ctype.patch (643 bytes)

Given a CStruct #StructA with a member #b of type (#ptr #StructB), I was
expecting to be able to call

 st> myA b
 CPtr(16r80728C4)

as well as

 st> myA b value
 StructB(16r80728D0)

However, what I actually get is:

 st> myA b value
 Object: CPtr new: 1 "<0x40338b18>" error: Invalid argument StructB
 SystemExceptions.WrongClass(Exception)>>signal
 SystemExceptions.WrongClass class(SystemExceptions.InvalidValue
class)>>signalOn:
 CPtr(CObject)>>derefAt:type:
 CPtr>>value
 UndefinedObject>>executeStatements
 nil

The fault is in CType>>#storeOn: and CType class>>#from:. The #storeOn:
method prints the raw cObjectType instance variable, where it should
print "self cObjectType" instead; and #from: returns a class,
(Namespace current at: type), where it should return the class's type,
((Namespace current at: type) type).

Patch against gst 2.95h attached. Test case to follow.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] CStruct pointers-to-CStructs don't work properly

Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/project/issue/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   tonyg
 Status:       active
 Attachment:   http://smalltalk.gnu.org/files/issues/testcase.c (604 bytes)

Test case: C code




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] CStruct pointers-to-CStructs don't work properly

Tony Garnock-Jones-4
In reply to this post by Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/project/issue/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   tonyg
 Status:       active
 Attachment:   http://smalltalk.gnu.org/files/issues/testcase.st (1.33 KB)

Test case: Smalltalk code




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] CStruct pointers-to-CStructs don't work properly

Tony Garnock-Jones-4
In reply to this post by Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/project/issue/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   tonyg
 Status:       active

Steps:

$ gcc -shared -o testcase.so testcase.c
$ gst testcase.st

Expected output:

$ gst testcase.st
malloced foo = 0x8073950
malloced bar = 0x8073960
Foo: Foo(16r8073950)
Foo aNumber: CInt(16r8073950)
Foo aNumber value: 123
Foo bar: CPtr(16r8073954)
Foo bar value: Bar(16r8073960)
Foo bar value aString: CString(16r8073960)
Foo bar value aString value: hello
Foo bar value anotherNumber: CInt(16r8073964)
Foo bar value anotherNumber value: 234

Actual output:

$ gst testcase.st
malloced foo = 0x80728c0
malloced bar = 0x80728d0
Foo: Foo(16r80728C0)
Foo aNumber: CInt(16r80728C0)
Foo aNumber value: 123
Foo bar: CPtr(16r80728C4)
Foo bar value: Object: CPtr new: 1 "<0x40327830>" error: Invalid
argument Bar
SystemExceptions.WrongClass(Exception)>>signal
SystemExceptions.WrongClass class(SystemExceptions.InvalidValue
class)>>signalOn:
CPtr(CObject)>>derefAt:type:
CPtr>>value
Testcase>>run
UndefinedObject>>executeStatements




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] CStruct pointers-to-CStructs don't work properly

Paolo Bonzini
In reply to this post by Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/project/issue/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   bonzinip
 Status:       active

Here is mine:

CStruct subclass: #StructB.
(CStruct subclass: #StructC) declaration: #((#b (#ptr #StructB))).
StructC new b elementType cObjectType printNl

(CStruct subclass: #StructD) declaration: #((#b (#ptr #{StructB}))).
StructD new b elementType cObjectType printNl

Both are fixed with your patch.

Thanks!




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] CStruct pointers-to-CStructs don't work properly

Paolo Bonzini
In reply to this post by Tony Garnock-Jones-4
Issue status update for
http://smalltalk.gnu.org/project/issue/148
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/148

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  tonyg
 Updated by:   bonzinip
-Status:       active
+Status:       fixed

forgot to close it.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk