Beispiel #1
0
def print_attribute_setter(name, attr):
    print("SEXP " + common.create_set_name(name, attr['name'], prefix="r_so") + "(SEXP self, SEXP string)", sep='')
    print("{")
    if attr['type'] == 'type_string':
        print("\tchar *c_string = (char *) CHAR(STRING_ELT(string, 0));")
        print("\tint fail = ", common.create_set_name(name, attr['name'], prefix="so"), "(R_ExternalPtrAddr(self), c_string);", sep="")
        print("\tif (fail) {")
        print("\t\terror(\"", common.create_set_name(name, attr['name'], prefix="so"), " failed\");", sep='')
        print("\t}")
    elif attr['type'] == 'type_int':
        print("\tso_", name, "_set_", attr['name'], "(R_ExternalPtrAddr(self), INTEGER(string));", sep='')
    print()
    print("\treturn R_NilValue;")
    print("}")
Beispiel #2
0
def print_attribute_setter(name, attr):
    print("SEXP " + common.create_set_name(name, attr['name'], prefix="r_so") + "(SEXP self, SEXP string)", sep='')
    print("{")
    if attr['type'] == 'type_string':
        print("\tchar *c_string = (char *) CHAR(STRING_ELT(string, 0));")
        print("\tint fail = ", common.create_set_name(name, attr['name'], prefix="so"), "(R_ExternalPtrAddr(self), c_string);", sep="")
        print("\tif (fail) {")
        print("\t\terror(\"", common.create_set_name(name, attr['name'], prefix="so"), " failed\");", sep='')
        print("\t}")
    elif attr['type'] == 'type_int':
        print("\tso_", name, "_set_", attr['name'], "(R_ExternalPtrAddr(self), INTEGER(string));", sep='')
    print()
    print("\treturn R_NilValue;")
    print("}")
Beispiel #3
0
def print_set_child(name, child):
    print("SEXP ", common.create_set_name(name, child['name'], prefix="r_so"), "(SEXP self, SEXP child)", sep='')
    print("{")
    if child['type'] == "Table":
        print("\tso_Table *table = df2table(child);", sep='')
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), table);", sep='')
    elif child['type'] == 'type_string':
        print("\tint fail = so_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), (char *) CHAR(STRING_ELT(child, 0)));", sep='')
        print("\tif (fail) {")
        print("\t\terror(\"so_", name, "_set_", child['name'], " failed\");", sep='')
        print("\t}")
    elif child['type'] == 'type_real':
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), REAL(child));", sep='')
    elif child['type'] == 'type_int':
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), INTEGER(child));", sep='')
    elif child['type'] == 'Matrix':
        print("\tso_Matrix *matrix = Rmatrix2matrix(child);", sep='')
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), matrix);", sep='')
    else:
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), R_ExternalPtrAddr(child));", sep='')
    print("\treturn R_NilValue;")
    print("}")
Beispiel #4
0
def print_set_child(name, child):
    print("SEXP ", common.create_set_name(name, child['name'], prefix="r_so"), "(SEXP self, SEXP child)", sep='')
    print("{")
    if child['type'] == "Table":
        print("\tso_Table *table = df2table(child);", sep='')
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), table);", sep='')
    elif child['type'] == 'type_string':
        print("\tint fail = so_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), (char *) CHAR(STRING_ELT(child, 0)));", sep='')
        print("\tif (fail) {")
        print("\t\terror(\"so_", name, "_set_", child['name'], " failed\");", sep='')
        print("\t}")
    elif child['type'] == 'type_real':
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), REAL(child));", sep='')
    elif child['type'] == 'type_int':
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), INTEGER(child));", sep='')
    elif child['type'] == 'Matrix':
        print("\tso_Matrix *matrix = Rmatrix2matrix(child);", sep='')
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), matrix);", sep='')
    else:
        print("\tso_", name, "_set_", child['name'], "(R_ExternalPtrAddr(self), R_ExternalPtrAddr(child));", sep='')
    print("\treturn R_NilValue;")
    print("}")