Claims
- 1. A method for implementing a string object defined in a programming language, comprising:
receiving characters to be embedded in the string object; allocating a space for the string object, wherein the space includes a header which is appended to a character array of the string object; copying the characters into the character array of the string object; and initializing the header by initializing a class pointer in the header to point to a class for the string object, and by initializing a length field in the header to specify a length for the string object; whereby the string object remains compatible with previous implementations of the string object that use a character array that is separate from the string object.
- 2. The method of claim 1, wherein characters within the character array are encoded in a sixteen-bit standard character code.
- 3. The method of claim 1, wherein characters within the character array are encoded in an eight-bit standard character code.
- 4. The method of claim 1, wherein characters within the character array are encoded in a variable-length standard character code.
- 5. The method of claim 1, wherein the character array is created by first assuming that characters to be added to the character array can be encoded in an eight-bit representation.
- 6. The method of claim 5, wherein if characters are encountered that will not fit in the eight-bit representation, the character array is converted to use a sixteen-bit representation.
- 7. The method of claim 6, further comprising converting the character array to use a variable-length representation, whereby the variable-length representation saves storage space.
- 8. The method of claim 1, further comprising moving a class pointer to convert the character array into a string object instead of copying the string object.
- 9. A computer-readable storage medium storing instructions that when executed by a computer cause the computer to perform a method for implementing a string object defined in a programming language, the method comprising:
receiving characters to be embedded in the string object; allocating a space for the string object, wherein the space includes a header which is appended to a character array of the string object; copying the characters into the character array of the string object; and initializing the header by initializing a class pointer in the header to point to a class for the string object, and by initializing a length field in the header to specify a length for the string object; whereby the string object remains compatible with previous implementations of the string object that use a character array that is separate from the string object.
- 10. The computer-readable storage medium of claim 9, wherein characters within the character array are encoded in a sixteen-bit standard character code.
- 11. The computer-readable storage medium of claim 9, wherein characters within the character array are encoded in an eight-bit standard character code.
- 12. The computer-readable storage medium of claim 9, wherein characters within the character array are encoded in a variable-length standard character code.
- 13. The computer-readable storage medium of claim 9, wherein the character array is created by first assuming that characters to be added to the character array can be encoded in an eight-bit representation.
- 14. The computer-readable storage medium of claim 13, wherein if characters are encountered that will not fit in the eight-bit representation, the character array is converted to use a sixteen-bit representation.
- 15. The computer-readable storage medium of claim 14, the method further comprising converting the character array to use a variable-length representation, whereby the variable-length representation saves storage space.
- 16. The computer-readable storage medium of claim 9, the method further comprising moving a class pointer to convert the character array into a string object instead of copying the string object.
- 17. An apparatus for implementing a string object defined in a programming language, comprising:
a receiving mechanism configured to receive characters to be embedded in the string object; an allocating mechanism configured to a allocate a space for the string object, wherein the space includes a header which is appended to a character array of the string object; a copying mechanism configured to copy the characters into the character array of the string object; and an initializing mechanism configured to initialize the header by initializing a class pointer in the header to point to a class for the string object, and by initializing a length field in the header to specify a length for the string object; whereby the string object remains compatible with previous implementations of the string object that use a character array that is separate from the string object.
- 18. The apparatus of claim 17, wherein characters within the character array are encoded in a sixteen-bit standard character code.
- 19. The apparatus of claim 17, wherein characters within the character array are encoded in an eight-bit standard character code.
- 20. The apparatus of claim 17, wherein characters within the character array are encoded in a variable-length standard character code.
- 21. The apparatus of claim 17, wherein the character array is created by first assuming that characters to be added to the character array can be encoded in an eight-bit representation.
- 22. The apparatus of claim 21, wherein if characters are encountered that will not fit in the eight-bit representation, the character array is converted to use a sixteen-bit representation.
- 23. The apparatus of claim 22, wherein the character array is converted to use a variable-length representation, whereby the variable-length representation saves storage space.
- 24. The apparatus of claim 17, further comprising a moving mechanism configured to move a class pointer to convert the character array into a string object instead of copying the string object.
RELATED APPLICATION
[0001] This application hereby claims priority under 35 U.S.C. §119 to U.S. Provisional Patent Application No. 60/392,375, filed on Jun. 26, 2002, entitled “Optimizing Platform Independent Code,” by inventors Nicholas Shaylor and Douglas Simon and to U.S. Provisional Patent Application No. 60/412,607, filed on Sep. 20, 2002, entitled “The Squawk System,” by inventors Nicholas Shaylor and Douglas Simon.
Provisional Applications (2)
|
Number |
Date |
Country |
|
60392375 |
Jun 2002 |
US |
|
60412607 |
Sep 2002 |
US |