version 1.38, 2004/09/20 02:11:22 |
version 1.42, 2005/06/09 05:46:57 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.37 2004/09/17 02:42:57 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.41 2004/11/15 08:27:27 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
Line 1522 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1522 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
ob4 = Order matrix |
ob4 = Order matrix |
ob5 = [(keyword) value (keyword) value ....] |
ob5 = [(keyword) value (keyword) value ....] |
*/ |
*/ |
#define RP_LIMIT 500 |
#define RP_LIMIT 5000 |
{ |
{ |
int i; |
int i; |
struct object ob; |
struct object ob; |
Line 3105 struct object newByteArray(int size,struct object obj) |
|
Line 3105 struct object newByteArray(int size,struct object obj) |
|
struct object rob,tob; |
struct object rob,tob; |
int i,n; |
int i,n; |
ba = NULL; |
ba = NULL; |
if (size > 0) ba = (unsigned char *) sGC_malloc(size); |
if (size > 0) { |
if (ba == NULL) errorKan1("%s\n","No more memory."); |
ba = (unsigned char *) sGC_malloc(size); |
|
if (ba == NULL) errorKan1("%s\n","No more memory."); |
|
} |
rob.tag = SbyteArray; rob.lc.bytes = ba; rob.rc.ival = size; |
rob.tag = SbyteArray; rob.lc.bytes = ba; rob.rc.ival = size; |
if (obj.tag == SbyteArray) { |
if (obj.tag == SbyteArray) { |
n = getByteArraySize(obj); |
n = getByteArraySize(obj); |
ba2 = KopByteArray(obj); |
ba2 = KopByteArray(obj); |
for (i=0; i<n; i++) { |
for (i=0; i<(n<size?n:size); i++) { |
ba[i] = ba2[i]; |
ba[i] = ba2[i]; |
} |
} |
for (i=n; i<size; i++) ba[i] = 0; |
for (i=n; i<size; i++) ba[i] = 0; |
Line 3131 struct object newByteArray(int size,struct object obj) |
|
Line 3133 struct object newByteArray(int size,struct object obj) |
|
return rob; |
return rob; |
} |
} |
} |
} |
|
struct object newByteArrayFromStr(char *s,int size) { |
|
unsigned char *ba; |
|
struct object rob; |
|
int i; |
|
ba = NULL; |
|
if (size > 0) { |
|
ba = (unsigned char *) sGC_malloc(size); |
|
if (ba == NULL) errorKan1("%s\n","No more memory."); |
|
} |
|
rob.tag = SbyteArray; rob.lc.bytes = ba; rob.rc.ival = size; |
|
for (i=0; i<size; i++) { |
|
ba[i] = (char) s[i]; |
|
} |
|
return(rob); |
|
} |
|
|
struct object byteArrayToArray(struct object obj) { |
struct object byteArrayToArray(struct object obj) { |
int n,i; unsigned char *ba; |
int n,i; unsigned char *ba; |
struct object rob; |
struct object rob; |
Line 3142 struct object byteArrayToArray(struct object obj) { |
|
Line 3160 struct object byteArrayToArray(struct object obj) { |
|
return rob; |
return rob; |
} |
} |
|
|
|
struct object KgetAttributeList(struct object ob){ |
|
struct object rob; |
|
if (ob.attr != NULL) rob = *(ob.attr); |
|
else rob = NullObject; |
|
return rob; |
|
} |
|
struct object KputAttributeList(struct object ob,struct object attr) { |
|
ob.attr = newObject(); |
|
*(ob.attr) = attr; |
|
return ob; |
|
} |
|
struct object KgetAttribute(struct object ob,struct object key) { |
|
struct object rob; |
|
struct object alist; |
|
int n,i; |
|
struct object tob; |
|
char *s; |
|
rob = NullObject; |
|
if (ob.attr == NULL) return rob; |
|
alist = *(ob.attr); |
|
if (alist.tag != Sarray) return rob; |
|
if (key.tag != Sdollar) return rob; |
|
s = KopString(key); |
|
n = getoaSize(alist); |
|
for (i = 0; i < n; i += 2) { |
|
tob = getoa(alist,i); |
|
if (tob.tag == Sdollar) { |
|
if (strcmp(KopString(tob),s) == 0) { |
|
if (i+1 < n) rob = getoa(alist,i+1); |
|
return rob; |
|
} |
|
} |
|
} |
|
return rob; |
|
} |
|
/* ob (key) (value) putAttribute /ob set. They are not destructive. */ |
|
struct object KputAttribute(struct object ob,struct object key,struct object value) { |
|
struct object rob; |
|
struct object alist; |
|
int n,i; |
|
char *s = ""; |
|
struct object tob; |
|
rob = ob; |
|
if (ob.attr == NULL) { |
|
rob.attr = newObject(); |
|
*(rob.attr) = newObjectArray(2); |
|
putoa((*(rob.attr)),0,key); |
|
putoa((*(rob.attr)),1,value); |
|
return rob; |
|
} |
|
alist = *(ob.attr); |
|
if (alist.tag != Sarray) return rob; |
|
if (key.tag != Sdollar) { |
|
s = KopString(key); |
|
} |
|
n = getoaSize(alist); |
|
for (i = 0; i < n; i += 2) { |
|
tob = getoa(alist,i); |
|
if (tob.tag == Sdollar) { |
|
if (strcmp(KopString(tob),s) == 0) { |
|
if (i+1 < n) putoa(alist,i+1,value); |
|
return rob; |
|
} |
|
} |
|
} |
|
|
|
rob.attr = newObject(); |
|
*(rob.attr) = newObjectArray(n+2); |
|
for (i=0; i<n; i++) { |
|
putoa((*(rob.attr)),i,getoa((*(ob.attr)),i)); |
|
} |
|
putoa((*(rob.attr)),n,key); |
|
putoa((*(rob.attr)),n+1,value); |
|
return rob; |
|
} |
|
|
/****************************************************************** |
/****************************************************************** |
error handler |
Error handler |
******************************************************************/ |
******************************************************************/ |
|
|
errorKan1(str,message) |
errorKan1(str,message) |