Ticket #1350 (closed patch: fixed)

Opened 12 years ago

Last modified 12 years ago

[patch]changed bigint.pmc to use GET_ATTR syntax

Reported by: jimmy Owned by:
Priority: normal Milestone:
Component: core Version: 1.8.0
Severity: medium Keywords:
Cc: Language:
Patch status: new Platform:

Description

changed bigint.pmc to use GET_ATTR syntax

Index: src/pmc/bigint.pmc
===================================================================
--- src/pmc/bigint.pmc	(版本 42868)
+++ src/pmc/bigint.pmc	(工作副本)
@@ -37,18 +37,17 @@
 
 static void
 bigint_init(PARROT_INTERP, PMC *self) {
-    Parrot_BigInt_attributes *attrs =
-        mem_allocate_zeroed_typed(Parrot_BigInt_attributes);
-    attrs->bi = mem_allocate_zeroed_typed(BIGINT);
-    mpz_init(attrs->bi->b);
-    PMC_data(self) = attrs;
+    BIGINT * const bi = mem_allocate_zeroed_typed(BIGINT);
+    SETATTR_BigInt_bi(interp, self, bi);
+    mpz_init(bi->b);
 }
 
 static void
 bigint_clear(PARROT_INTERP, PMC *self) {
-    BIGINT *bi;
+    BIGINT * bi;
     GETATTR_BigInt_bi(interp, self, bi);
     mpz_clear(bi->b);
+    mem_sys_free(bi);
 }
 
 static void
@@ -562,7 +561,7 @@
 
 #endif /* ifdef PARROT_HAS_GMP */
 
-pmclass BigInt {
+pmclass BigInt auto_attrs {
     ATTR struct BIGINT * bi; /*bigint val*/
 
 /*
@@ -603,15 +602,7 @@
     }
 
     VTABLE void destroy() {
-        BIGINT                   *bi;
-        Parrot_BigInt_attributes *attrs;
-
         bigint_clear(INTERP, SELF);
-
-        attrs = (Parrot_BigInt_attributes*)PMC_data(SELF);
-        mem_sys_free(attrs->bi);
-        mem_sys_free(attrs);
-        PMC_data(SELF) = NULL;
     }
 
 /*

Attachments

bigint.pmc.patch Download (1.3 KB) - added by jimmy 12 years ago.

Change History

Changed 12 years ago by jimmy

in reply to: ↑ description   Changed 12 years ago by jkeenan

  • component changed from none to core

Replying to jimmy:

changed bigint.pmc to use GET_ATTR syntax

As noted in  this comment on TT #1348, I've been looking at whether your patches work with one another, "work" meaning "does not prevent Parrot from completing make successfully".

This patch works with:

* the Vtable.pm patch submitted in TT #1354

* the arrayiterator.pmc patch submitted in TT #1349

* the bignum.pmc patch submitted in TT #1351

Have not yet run make test.

  Changed 12 years ago by jkeenan

  • patch set to new

  Changed 12 years ago by cotto

  • status changed from new to closed
  • resolution set to fixed

This patch looks sane and seems to behave itself. Its new name is r42972.

Note: See TracTickets for help on using tickets.