added more preamable codes.

enhanced the system to be able to attach trailing spaces to an object upon instantiation, especially for external modules to be able to secure GC-safe free workspace inside an instantiated object
added moo_setclasstrsize(), moo_getobjtrailer() for the trailer feature
This commit is contained in:
hyunghwan.chung
2017-02-14 08:29:30 +00:00
parent d7cb283e44
commit 71aa1110ed
19 changed files with 383 additions and 293 deletions

View File

@ -31,15 +31,20 @@ class Apex(nil)
## -------------------------------------------------------
## -------------------------------------------------------
method(#class) __trailer_size
{
^0
}
method(#class) basicNew
{
<primitive: #_basic_new>
self primitiveFailed.
}
method(#class) basicNew: anInteger
method(#class) basicNew: size
{
<primitive: #_basic_new_with_size>
<primitive: #_basic_new>
self primitiveFailed.
}
@ -51,7 +56,7 @@ class Apex(nil)
method(#class) ngcNew: anInteger
{
<primitive: #_ngc_new_with_size>
<primitive: #_ngc_new>
self primitiveFailed.
}

View File

@ -4,7 +4,7 @@
##
class(#pointer) Class(Apex)
{
dcl spec selfspec superclass subclasses name instvars classvars classinstvars pooldics instmthdic classmthdic nsdic.
dcl spec selfspec superclass subclasses name instvars classvars classinstvars pooldics instmthdic classmthdic nsdic trsize.
method(#class) basicNew
{

View File

@ -187,14 +187,14 @@ extend MethodContext
{
method isExceptionContext
{
## 10 - MOO_METHOD_PREAMBLE_EXCEPTION in VM.
^self.method preambleCode == 10.
## 12 - MOO_METHOD_PREAMBLE_EXCEPTION in VM.
^self.method preambleCode == 12.
}
method isEnsureContext
{
## 10 - MOO_METHOD_PREAMBLE_ENSURE in VM.
^self.method preambleCode == 11
## 13 - MOO_METHOD_PREAMBLE_ENSURE in VM.
^self.method preambleCode == 13
}
method ensureBlock
@ -208,7 +208,7 @@ extend MethodContext
* 8 instance variables, the ensure block must be at the 9th position
* which translates to index 8 *)
(self.method preambleCode == 11) ifFalse: [^nil].
(self.method preambleCode == 13) ifFalse: [^nil].
^self basicAt: 8.
}

View File

@ -1,4 +1,4 @@
class(#byte) _FFI(Module) from 'ffi'
class _FFI(Object) from 'ffi'
{
(*
* the ffi module installs the following methods

View File

@ -1,18 +0,0 @@
class(#byte) Module(Object)
{
method(#class) _newInstSize
{
self subclassResponsibility: #_newInstSize
}
method(#class) new: size
{
## ignore the specified size
^(super new: (self _newInstSize))
}
method(#class) new
{
^(super new: (self _newInstSize))
}
}

View File

@ -8,8 +8,6 @@
#include 'Process.moo'.
(* -------------------------------------------------------------------------- *)
#include 'Module.moo'.
#include 'FFI.moo'.
#include 'Stdio.moo'.
#include 'Console.moo'.

View File

@ -1,5 +1,5 @@
class(#byte) Stdio(Module) from 'stdio'
class Stdio(Object) from 'stdio'
{
dcl(#class) in out err.
@ -63,7 +63,7 @@ extend Stdio
}
}
class(#byte) Stdio2(Stdio)
class Stdio2(Stdio)
{
method(#class) new
{

View File

@ -73,6 +73,7 @@ class MyObject(Object)
'duplicate class'
'contradictory class definition'
'wrong class name'
'non-pointer class inheriting superclass with trailer size set'
'dcl not allowed'
'wrong method name'
'duplicate method name'