From 4ab66c9679c477f653dc4177248e5c06a7eb540e Mon Sep 17 00:00:00 2001 From: Iago Mosqueira Date: Mon, 2 Dec 2024 08:22:28 +0100 Subject: [PATCH] Moved methods drom Rinternals to Rf_ --- src/FLBRP.cpp | 88 ++-- src/FLCoreClasses.cpp | 958 +++++++++++++++++++++--------------------- 2 files changed, 523 insertions(+), 523 deletions(-) diff --git a/src/FLBRP.cpp b/src/FLBRP.cpp index bfb46d3..297b051 100644 --- a/src/FLBRP.cpp +++ b/src/FLBRP.cpp @@ -26,7 +26,7 @@ int RP_harvest=0, extern "C" SEXPDLLExport Adolc_gr_tapeless(SEXP xX) { // Rosenbrock Banana function - if (!isVector(xX) || !isNumeric(xX)) + if (!Rf_isVector(xX) || !Rf_isNumeric(xX)) return R_NilValue; SEXP Grad = R_NilValue; @@ -138,7 +138,7 @@ extern "C" SEXPDLLExport brp(SEXP xbrp, SEXP xref, SEXP xSR, SEXP xPar) SEXP RtnVal = brp.Return(xbrp); - SET_SLOT(RtnVal, install("refpts"), brp.brp(xref)); + SET_SLOT(RtnVal, Rf_install("refpts"), brp.brp(xref)); return RtnVal; } @@ -171,10 +171,10 @@ void FLBRP::Init(SEXP x) { if (!isFLBRP(x)) return; - SEXP range = GET_SLOT(x, install("range")); + SEXP range = GET_SLOT(x, Rf_install("range")); SEXP RangeNames = GET_NAMES(range); - int n = length(RangeNames); + int n = Rf_length(RangeNames); nunits = nseasons = @@ -208,23 +208,23 @@ void FLBRP::Init(SEXP x) } } - fbar.Init( GET_SLOT(x, install("fbar"))); - - landings_sel.Init( GET_SLOT(x, install("landings.sel"))); - discards_sel.Init( GET_SLOT(x, install("discards.sel"))); - bycatch_harvest.Init(GET_SLOT(x, install("bycatch.harvest"))); - stock_wt.Init( GET_SLOT(x, install("stock.wt"))); - landings_wt.Init( GET_SLOT(x, install("landings.wt"))); - discards_wt.Init( GET_SLOT(x, install("discards.wt"))); - bycatch_wt.Init( GET_SLOT(x, install("bycatch.wt"))); - m.Init( GET_SLOT(x, install("m"))); - mat.Init( GET_SLOT(x, install("mat"))); - harvest_spwn.Init( GET_SLOT(x, install("harvest.spwn"))); - m_spwn.Init( GET_SLOT(x, install("m.spwn"))); - availability.Init( GET_SLOT(x, install("availability"))); - cost_var.Init( GET_SLOT(x, install("vcost"))); - cost_fix.Init( GET_SLOT(x, install("fcost"))); - price.Init( GET_SLOT(x, install("price"))); + fbar.Init( GET_SLOT(x, Rf_install("fbar"))); + + landings_sel.Init( GET_SLOT(x, Rf_install("landings.sel"))); + discards_sel.Init( GET_SLOT(x, Rf_install("discards.sel"))); + bycatch_harvest.Init(GET_SLOT(x, Rf_install("bycatch.harvest"))); + stock_wt.Init( GET_SLOT(x, Rf_install("stock.wt"))); + landings_wt.Init( GET_SLOT(x, Rf_install("landings.wt"))); + discards_wt.Init( GET_SLOT(x, Rf_install("discards.wt"))); + bycatch_wt.Init( GET_SLOT(x, Rf_install("bycatch.wt"))); + m.Init( GET_SLOT(x, Rf_install("m"))); + mat.Init( GET_SLOT(x, Rf_install("mat"))); + harvest_spwn.Init( GET_SLOT(x, Rf_install("harvest.spwn"))); + m_spwn.Init( GET_SLOT(x, Rf_install("m.spwn"))); + availability.Init( GET_SLOT(x, Rf_install("availability"))); + cost_var.Init( GET_SLOT(x, Rf_install("vcost"))); + cost_fix.Init( GET_SLOT(x, Rf_install("fcost"))); + price.Init( GET_SLOT(x, Rf_install("price"))); minage = m.minquant(); maxage = m.maxquant(); @@ -469,30 +469,30 @@ double FLBRP::Recruits(double FMult, int iUnit, int iIter) SEXP FLBRP::Return(SEXP x) { - SET_SLOT(x, install("stock.n"), stock_n.Return()); - SET_SLOT(x, install("landings.n"), landings_n.Return()); - SET_SLOT(x, install("discards.n"), discards_n.Return()); - SET_SLOT(x, install("landings.sel"), landings_sel.Return()); - SET_SLOT(x, install("discards.sel"), discards_sel.Return()); - SET_SLOT(x, install("harvest"), harvest.Return()); + SET_SLOT(x, Rf_install("stock.n"), stock_n.Return()); + SET_SLOT(x, Rf_install("landings.n"), landings_n.Return()); + SET_SLOT(x, Rf_install("discards.n"), discards_n.Return()); + SET_SLOT(x, Rf_install("landings.sel"), landings_sel.Return()); + SET_SLOT(x, Rf_install("discards.sel"), discards_sel.Return()); + SET_SLOT(x, Rf_install("harvest"), harvest.Return()); return x; } SEXP FLBRP::ReturnStk(SEXP x) { - FLQuant _stock( GET_SLOT(x, install("stock"))); - FLQuant _catch( GET_SLOT(x, install("catch"))); - FLQuant _landings(GET_SLOT(x, install("landings"))); - FLQuant _discards(GET_SLOT(x, install("discards"))); - FLQuant _catch_wt(GET_SLOT(x, install("catch.wt"))); + FLQuant _stock( GET_SLOT(x, Rf_install("stock"))); + FLQuant _catch( GET_SLOT(x, Rf_install("catch"))); + FLQuant _landings(GET_SLOT(x, Rf_install("landings"))); + FLQuant _discards(GET_SLOT(x, Rf_install("discards"))); + FLQuant _catch_wt(GET_SLOT(x, Rf_install("catch.wt"))); FLQuant catch_n(minage,maxage,fbar.minyr(),fbar.maxyr(),nunits,nseasons,nareas,niters,0); - SET_SLOT(x, install("stock.n"), stock_n.Return()); - SET_SLOT(x, install("landings.n"), landings_n.Return()); - SET_SLOT(x, install("discards.n"), discards_n.Return()); - SET_SLOT(x, install("catch.n"), catch_n.Return()); - SET_SLOT(x, install("harvest"), harvest.Return()); + SET_SLOT(x, Rf_install("stock.n"), stock_n.Return()); + SET_SLOT(x, Rf_install("landings.n"), landings_n.Return()); + SET_SLOT(x, Rf_install("discards.n"), discards_n.Return()); + SET_SLOT(x, Rf_install("catch.n"), catch_n.Return()); + SET_SLOT(x, Rf_install("harvest"), harvest.Return()); for (int iIter=1; iIter<=niters; iIter++) for (int iUnit=1; iUnit<=nunits; iUnit++) @@ -1381,7 +1381,7 @@ double FLBRP::FMEY(int iIter) SEXP FLBRP::brp(SEXP Object) { - SEXP v = PROTECT(duplicate(GET_SLOT(Object, install(".Data")))), + SEXP v = PROTECT(Rf_duplicate(GET_SLOT(Object, Rf_install(".Data")))), dims = GET_DIM(v), dimnames = GET_DIMNAMES(v), v3; @@ -1392,20 +1392,20 @@ SEXP FLBRP::brp(SEXP Object) double ***D; - short dim[3], n = length(dims); + short dim[3], n = Rf_length(dims); if (n != 3) { UNPROTECT(1); - return ScalarLogical(FALSE); + return Rf_ScalarLogical(FALSE); } if (INTEGER(dims)[1] != 8) { UNPROTECT(1); - return ScalarLogical(FALSE); + return Rf_ScalarLogical(FALSE); } dim[0] = INTEGER(dims)[0]; @@ -1620,7 +1620,7 @@ SEXP FLBRP::brp(SEXP Object) PROTECT(v3 = Rf_allocArray(REALSXP, dims)); //Create names for dimensions - setAttrib(v3, R_DimNamesSymbol, dimnames); + Rf_setAttrib(v3, R_DimNamesSymbol, dimnames); l = 0; for (k = 0; k < dim[2]; k++) @@ -1641,7 +1641,7 @@ SEXP FLBRP::brp(SEXP Object) PROTECT(refpts = NEW_OBJECT(MAKE_CLASS("FLPar"))); - refpts = R_do_slot_assign(refpts, install(".Data"), v3); + refpts = R_do_slot_assign(refpts, Rf_install(".Data"), v3); UNPROTECT(3); @@ -1651,7 +1651,7 @@ SEXP FLBRP::brp(SEXP Object) void FLBRP::setSR(SEXP xModel, SEXP xPar) { - if (!isVector(xModel) || !isNumeric(xModel)) + if (!Rf_isVector(xModel) || !Rf_isNumeric(xModel)) return; sr_model = new FLRConstSRR [nunits]-1; diff --git a/src/FLCoreClasses.cpp b/src/FLCoreClasses.cpp index c005453..5b68f82 100644 --- a/src/FLCoreClasses.cpp +++ b/src/FLCoreClasses.cpp @@ -19,13 +19,13 @@ const char *strlwr(const char *s) FLRConstSRR getSRType(SEXP v) { - if (!isVector(v) || !isString(v)) + if (!Rf_isVector(v) || !Rf_isString(v)) return FLRConst_Mean;; SEXP dims = GET_DIM(v), dimnames = GET_DIMNAMES(v); - short n = length(dims); + short n = Rf_length(dims); if (n != 1) return FLRConst_Mean;; @@ -59,7 +59,7 @@ void InputAgeRange(SEXP obj, int *MinAge, int *MaxAge) double *a = NUMERIC_POINTER(obj); - int n = length(obj); + int n = Rf_length(obj); for (int i=0; i= 6) - minfbar = (int)REAL(GET_SLOT(x, install("range")))[5]; - if (LENGTH(GET_SLOT(x, install("range"))) >= 7) - maxfbar = (int)REAL(GET_SLOT(x, install("range")))[6]; + if (Rf_length(GET_SLOT(x, Rf_install("range"))) >= 6) + minfbar = (int)REAL(GET_SLOT(x, Rf_install("range")))[5]; + if (Rf_length(GET_SLOT(x, Rf_install("range"))) >= 7) + maxfbar = (int)REAL(GET_SLOT(x, Rf_install("range")))[6]; - catch_.Init( GET_SLOT(x, install("catch"))); - catch_n.Init( GET_SLOT(x, install("catch.n"))); - catch_wt.Init( GET_SLOT(x, install("catch.wt"))); - discards.Init( GET_SLOT(x, install("discards"))); - discards_n.Init( GET_SLOT(x, install("discards.n"))); - discards_wt.Init( GET_SLOT(x, install("discards.wt"))); - landings.Init( GET_SLOT(x, install("landings"))); - landings_n.Init( GET_SLOT(x, install("landings.n"))); - landings_wt.Init( GET_SLOT(x, install("landings.wt"))); - stock.Init( GET_SLOT(x, install("stock"))); - stock_n.Init( GET_SLOT(x, install("stock.n"))); - stock_wt.Init( GET_SLOT(x, install("stock.wt"))); - m.Init( GET_SLOT(x, install("m"))); - mat.Init( GET_SLOT(x, install("mat"))); - harvest.Init( GET_SLOT(x, install("harvest"))); - harvest_spwn.Init(GET_SLOT(x, install("harvest.spwn"))); - m_spwn.Init( GET_SLOT(x, install("m.spwn"))); + catch_.Init( GET_SLOT(x, Rf_install("catch"))); + catch_n.Init( GET_SLOT(x, Rf_install("catch.n"))); + catch_wt.Init( GET_SLOT(x, Rf_install("catch.wt"))); + discards.Init( GET_SLOT(x, Rf_install("discards"))); + discards_n.Init( GET_SLOT(x, Rf_install("discards.n"))); + discards_wt.Init( GET_SLOT(x, Rf_install("discards.wt"))); + landings.Init( GET_SLOT(x, Rf_install("landings"))); + landings_n.Init( GET_SLOT(x, Rf_install("landings.n"))); + landings_wt.Init( GET_SLOT(x, Rf_install("landings.wt"))); + stock.Init( GET_SLOT(x, Rf_install("stock"))); + stock_n.Init( GET_SLOT(x, Rf_install("stock.n"))); + stock_wt.Init( GET_SLOT(x, Rf_install("stock.wt"))); + m.Init( GET_SLOT(x, Rf_install("m"))); + mat.Init( GET_SLOT(x, Rf_install("mat"))); + harvest.Init( GET_SLOT(x, Rf_install("harvest"))); + harvest_spwn.Init(GET_SLOT(x, Rf_install("harvest.spwn"))); + m_spwn.Init( GET_SLOT(x, Rf_install("m.spwn"))); niters=1; niters= __max(niters,catch_.niters()); @@ -826,15 +826,15 @@ SEXP FLStock::ReturnRange(void) SEXP names; - PROTECT(names = allocVector(STRSXP, 7)); - SET_STRING_ELT(names, 0, mkChar("min")); - SET_STRING_ELT(names, 1, mkChar("max")); - SET_STRING_ELT(names, 2, mkChar("plusgroup")); - SET_STRING_ELT(names, 3, mkChar("minyear")); - SET_STRING_ELT(names, 4, mkChar("maxyear")); - SET_STRING_ELT(names, 5, mkChar("minfbar")); - SET_STRING_ELT(names, 6, mkChar("maxfbar")); - setAttrib(Range, R_NamesSymbol, names); + PROTECT(names = Rf_allocVector(STRSXP, 7)); + SET_STRING_ELT(names, 0, Rf_mkChar("min")); + SET_STRING_ELT(names, 1, Rf_mkChar("max")); + SET_STRING_ELT(names, 2, Rf_mkChar("plusgroup")); + SET_STRING_ELT(names, 3, Rf_mkChar("minyear")); + SET_STRING_ELT(names, 4, Rf_mkChar("maxyear")); + SET_STRING_ELT(names, 5, Rf_mkChar("minfbar")); + SET_STRING_ELT(names, 6, Rf_mkChar("maxfbar")); + Rf_setAttrib(Range, R_NamesSymbol, names); return Range; } @@ -846,24 +846,24 @@ SEXP FLStock::Return(void) PROTECT(Stock = NEW_OBJECT(MAKE_CLASS("FLStock"))); Range = ReturnRange(); - SET_SLOT(Stock, install("catch"), catch_.Return()); - SET_SLOT(Stock, install("catch.n"), catch_n.Return()); - SET_SLOT(Stock, install("catch.wt"), catch_wt.Return()); - SET_SLOT(Stock, install("discards"), discards.Return()); - SET_SLOT(Stock, install("discards.n"), discards_n.Return()); - SET_SLOT(Stock, install("discards.wt"), discards_wt.Return()); - SET_SLOT(Stock, install("landings"), landings.Return()); - SET_SLOT(Stock, install("landings.n"), landings_n.Return()); - SET_SLOT(Stock, install("landings.wt"), landings_wt.Return()); - SET_SLOT(Stock, install("stock"), stock.Return()); - SET_SLOT(Stock, install("stock.n"), stock_n.Return()); - SET_SLOT(Stock, install("stock.wt"), stock_wt.Return()); - SET_SLOT(Stock, install("mat"), mat.Return()); - SET_SLOT(Stock, install("harvest"), harvest.Return()); - SET_SLOT(Stock, install("harvest.spwn"),harvest_spwn.Return()); - SET_SLOT(Stock, install("m"), m.Return()); - SET_SLOT(Stock, install("m.spwn"), m_spwn.Return()); - SET_SLOT(Stock, install("range"), Range); + SET_SLOT(Stock, Rf_install("catch"), catch_.Return()); + SET_SLOT(Stock, Rf_install("catch.n"), catch_n.Return()); + SET_SLOT(Stock, Rf_install("catch.wt"), catch_wt.Return()); + SET_SLOT(Stock, Rf_install("discards"), discards.Return()); + SET_SLOT(Stock, Rf_install("discards.n"), discards_n.Return()); + SET_SLOT(Stock, Rf_install("discards.wt"), discards_wt.Return()); + SET_SLOT(Stock, Rf_install("landings"), landings.Return()); + SET_SLOT(Stock, Rf_install("landings.n"), landings_n.Return()); + SET_SLOT(Stock, Rf_install("landings.wt"), landings_wt.Return()); + SET_SLOT(Stock, Rf_install("stock"), stock.Return()); + SET_SLOT(Stock, Rf_install("stock.n"), stock_n.Return()); + SET_SLOT(Stock, Rf_install("stock.wt"), stock_wt.Return()); + SET_SLOT(Stock, Rf_install("mat"), mat.Return()); + SET_SLOT(Stock, Rf_install("harvest"), harvest.Return()); + SET_SLOT(Stock, Rf_install("harvest.spwn"),harvest_spwn.Return()); + SET_SLOT(Stock, Rf_install("m"), m.Return()); + SET_SLOT(Stock, Rf_install("m.spwn"), m_spwn.Return()); + SET_SLOT(Stock, Rf_install("range"), Range); UNPROTECT(3); @@ -885,13 +885,13 @@ FLIndex::FLIndex(SEXP x) void FLIndex::Init(SEXP x) { - minquant = (int)REAL(GET_SLOT(x, install("range")))[0]; - maxquant = (int)REAL(GET_SLOT(x, install("range")))[1]; - plusgrp = (int)REAL(GET_SLOT(x, install("range")))[2]; - minyr = (int)REAL(GET_SLOT(x, install("range")))[3]; - maxyr = (int)REAL(GET_SLOT(x, install("range")))[4]; - startf = (int)REAL(GET_SLOT(x, install("range")))[5]; - endf = (int)REAL(GET_SLOT(x, install("range")))[6]; + minquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[0]; + maxquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[1]; + plusgrp = (int)REAL(GET_SLOT(x, Rf_install("range")))[2]; + minyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[3]; + maxyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[4]; + startf = (int)REAL(GET_SLOT(x, Rf_install("range")))[5]; + endf = (int)REAL(GET_SLOT(x, Rf_install("range")))[6]; nunits = 1; nseasons = 1; @@ -900,13 +900,13 @@ void FLIndex::Init(SEXP x) index.Init( 0, 0, index.minyr(),index.maxyr(),index.nunits(),index.nseasons(),index.nareas(), index.niters(), 1.0); index_var.Init(0, 0, index.minyr(),index.maxyr(),index.nunits(),index.nseasons(),index.nareas(), index.niters(), 1.0); - index.Init( GET_SLOT(x, install("index"))); - index_var.Init(GET_SLOT(x, install("index.var"))); - catch_n.Init( GET_SLOT(x, install("catch.n"))); - catch_wt.Init( GET_SLOT(x, install("catch.wt"))); - effort.Init( GET_SLOT(x, install("effort"))); - sel_pattern.Init( GET_SLOT(x, install("sel.pattern"))); - index_q.Init( GET_SLOT(x, install("index.q"))); + index.Init( GET_SLOT(x, Rf_install("index"))); + index_var.Init(GET_SLOT(x, Rf_install("index.var"))); + catch_n.Init( GET_SLOT(x, Rf_install("catch.n"))); + catch_wt.Init( GET_SLOT(x, Rf_install("catch.wt"))); + effort.Init( GET_SLOT(x, Rf_install("effort"))); + sel_pattern.Init( GET_SLOT(x, Rf_install("sel.pattern"))); + index_q.Init( GET_SLOT(x, Rf_install("index.q"))); //need to check seasons, areas, units & iterations } @@ -931,14 +931,14 @@ SEXP FLIndex::Return(void) REAL(Range)[5] = startf; REAL(Range)[6] = endf; - SET_SLOT(Index, install("range"), Range); - SET_SLOT(Index, install("index"), index.Return()); - SET_SLOT(Index, install("index.var"), index_var.Return()); - SET_SLOT(Index, install("catch.n"), catch_n.Return()); - SET_SLOT(Index, install("catch.wt"), catch_wt.Return()); - SET_SLOT(Index, install("effort"), catch_n.Return()); - SET_SLOT(Index, install("sel.pattern"), sel_pattern.Return()); - SET_SLOT(Index, install("index.q"), index_q.Return()); + SET_SLOT(Index, Rf_install("range"), Range); + SET_SLOT(Index, Rf_install("index"), index.Return()); + SET_SLOT(Index, Rf_install("index.var"), index_var.Return()); + SET_SLOT(Index, Rf_install("catch.n"), catch_n.Return()); + SET_SLOT(Index, Rf_install("catch.wt"), catch_wt.Return()); + SET_SLOT(Index, Rf_install("effort"), catch_n.Return()); + SET_SLOT(Index, Rf_install("sel.pattern"), sel_pattern.Return()); + SET_SLOT(Index, Rf_install("index.q"), index_q.Return()); UNPROTECT(2); @@ -960,22 +960,22 @@ FLBiol::FLBiol(SEXP x) void FLBiol::Init(SEXP x) { - minquant = (int)REAL(GET_SLOT(x, install("range")))[0]; - maxquant = (int)REAL(GET_SLOT(x, install("range")))[1]; - plusgrp = (int)REAL(GET_SLOT(x, install("range")))[2]; - minyr = (int)REAL(GET_SLOT(x, install("range")))[3]; - maxyr = (int)REAL(GET_SLOT(x, install("range")))[4]; + minquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[0]; + maxquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[1]; + plusgrp = (int)REAL(GET_SLOT(x, Rf_install("range")))[2]; + minyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[3]; + maxyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[4]; nunits = 1; nseasons = 1; nareas = 1; niters = 1; - n.Init( GET_SLOT(x, install("n"))); - m.Init( GET_SLOT(x, install("m"))); - wt.Init( GET_SLOT(x, install("wt"))); - fec.Init( GET_SLOT(x, install("fec"))); - spwn.Init(GET_SLOT(x, install("spwn"))); + n.Init( GET_SLOT(x, Rf_install("n"))); + m.Init( GET_SLOT(x, Rf_install("m"))); + wt.Init( GET_SLOT(x, Rf_install("wt"))); + fec.Init( GET_SLOT(x, Rf_install("fec"))); + spwn.Init(GET_SLOT(x, Rf_install("spwn"))); //need to check seasons, areas & units } @@ -998,13 +998,13 @@ SEXP FLBiol::Return(void) REAL(Range)[3] = minyr; REAL(Range)[4] = maxyr; - SET_SLOT(Biol, install("n"), n.Return()); - SET_SLOT(Biol, install("m"), m.Return()); - SET_SLOT(Biol, install("wt"), wt.Return()); - SET_SLOT(Biol, install("fec"), fec.Return()); - SET_SLOT(Biol, install("spwn"), spwn.Return()); + SET_SLOT(Biol, Rf_install("n"), n.Return()); + SET_SLOT(Biol, Rf_install("m"), m.Return()); + SET_SLOT(Biol, Rf_install("wt"), wt.Return()); + SET_SLOT(Biol, Rf_install("fec"), fec.Return()); + SET_SLOT(Biol, Rf_install("spwn"), spwn.Return()); - SET_SLOT(Biol, install("range"), Range); + SET_SLOT(Biol, Rf_install("range"), Range); UNPROTECT(2); @@ -1038,16 +1038,16 @@ void FLVector::Init(SEXP x) SEXP v; int n; - if (!isVector(x) || !isNumeric(x)) + if (!Rf_isVector(x) || !Rf_isNumeric(x)) return; PROTECT(v = AS_NUMERIC(x)); - n = LENGTH(v); + n = Rf_length(v); double *d = NUMERIC_POINTER(v); SEXP names = GET_NAMES(v); - if (LENGTH(names) == n) //index by name + if (Rf_length(names) == n) //index by name { //get indices mindim = atoi(CHAR(STRING_ELT(names, 0))); @@ -1102,16 +1102,16 @@ SEXP FLVector::Return(void) v = PROTECT(NEW_NUMERIC(maxdim-mindim+1)); //Set dimensions of array - PROTECT(dim = allocVector(INTSXP, 1)); + PROTECT(dim = Rf_allocVector(INTSXP, 1)); INTEGER(dim)[0] = maxdim-mindim+1; //Allocate memory PROTECT(v = Rf_allocArray(REALSXP, dim)); //Create dimension names - PROTECT(dimnames = allocVector(VECSXP, 1)); + PROTECT(dimnames = Rf_allocVector(VECSXP, 1)); - PROTECT(d1 = allocVector(INTSXP, maxdim-mindim+1)); + PROTECT(d1 = Rf_allocVector(INTSXP, maxdim-mindim+1)); for (j=mindim, i=0; j<=maxdim; j++, i++) INTEGER(d1)[i] = j; SET_VECTOR_ELT(dimnames, 1, d1); @@ -1174,16 +1174,16 @@ void FLBool::Init(SEXP x) SEXP v; int n; - if (!isLogical(x)) + if (!Rf_isLogical(x)) return; PROTECT(v = AS_LOGICAL(x)); - n = LENGTH(v); + n = Rf_length(v); int *d = LOGICAL_POINTER(v); SEXP names = GET_NAMES(v); - if (LENGTH(names) == n) //index by name + if (Rf_length(names) == n) //index by name { //get indices mindim = atoi(CHAR(STRING_ELT(names, 0))); @@ -1223,16 +1223,16 @@ SEXP FLBool::Return(void) v = PROTECT(NEW_NUMERIC(maxdim-mindim+1)); //Set dimensions of array - PROTECT(dim = allocVector(INTSXP, 1)); + PROTECT(dim = Rf_allocVector(INTSXP, 1)); INTEGER(dim)[0] = maxdim-mindim+1; //Allocate memory PROTECT(v = Rf_allocArray(REALSXP, dim)); //Create dimension names - PROTECT(dimnames = allocVector(VECSXP, 1)); + PROTECT(dimnames = Rf_allocVector(VECSXP, 1)); - PROTECT(d1 = allocVector(INTSXP, maxdim-mindim+1)); + PROTECT(d1 = Rf_allocVector(INTSXP, maxdim-mindim+1)); for (j=mindim, i=0; j<=maxdim; j++, i++) INTEGER(d1)[i] = j; SET_VECTOR_ELT(dimnames, 1, d1); @@ -1316,12 +1316,12 @@ FL2D::FL2D(SEXP x) void FL2D::Init(SEXP x) { - if (isMatrix(x) && isNumeric(x)) + if (Rf_isMatrix(x) && Rf_isNumeric(x)) { SEXP dims = GET_DIM(x), dimnames = GET_DIMNAMES(x); - int dim[2], n = length(dims); + int dim[2], n = Rf_length(dims); if (n !=2) return; @@ -1381,17 +1381,17 @@ void FL2D::Init(SEXP x) for (i2 = min2, j = 0; i2 <= max2; i2++, j++) data[i1][i2] = (a)[i + j*(max1-min1+1)]; } - else if (isVector(x) && isNumeric(x)) + else if (Rf_isVector(x) && Rf_isNumeric(x)) { SEXP v; PROTECT(v = AS_NUMERIC(x)); - int n = LENGTH(v); + int n = Rf_length(v); double *d = NUMERIC_POINTER(v); SEXP names = GET_NAMES(v); - if (LENGTH(names) == n) //index by name + if (Rf_length(names) == n) //index by name { int t = 0; const char *c; @@ -1454,7 +1454,7 @@ SEXP FL2D::Return(void) //Create array for slot //Set dimensions of array - PROTECT(dim = allocVector(INTSXP, 2)); + PROTECT(dim = Rf_allocVector(INTSXP, 2)); INTEGER(dim)[0] = max1 -min1 +1; INTEGER(dim)[1] = max2-min2+1; @@ -1462,19 +1462,19 @@ SEXP FL2D::Return(void) PROTECT(v = Rf_allocArray(REALSXP, dim)); //Create dimension names - PROTECT(dimnames = allocVector(VECSXP, 2)); + PROTECT(dimnames = Rf_allocVector(VECSXP, 2)); - PROTECT(d1 = allocVector(INTSXP, max1-min1 +1)); + PROTECT(d1 = Rf_allocVector(INTSXP, max1-min1 +1)); for (i_=min1, i=0; i_<=max1; i_++, i++) INTEGER(d1)[i] = i_; SET_VECTOR_ELT(dimnames, 0, d1); - PROTECT(d2 = allocVector(INTSXP, max2-min2+1)); + PROTECT(d2 = Rf_allocVector(INTSXP, max2-min2+1)); for (j_=min2, i=0; j_<=max2; j_++, i++) INTEGER(d2)[i] = j_; SET_VECTOR_ELT(dimnames, 1, d2); - setAttrib(v, install("dimnames"), dimnames); + Rf_setAttrib(v, Rf_install("dimnames"), dimnames); //Set data for (i_=min1, i=0; i_<=max1; i_++, i++) @@ -1535,26 +1535,26 @@ FLCatch::~FLCatch(void) void FLCatch::Init(SEXP x) { - minquant = (int)REAL(GET_SLOT(x, install("range")))[0]; - maxquant = (int)REAL(GET_SLOT(x, install("range")))[1]; - plusgrp = (int)REAL(GET_SLOT(x, install("range")))[2]; - minyr = (int)REAL(GET_SLOT(x, install("range")))[3]; - maxyr = (int)REAL(GET_SLOT(x, install("range")))[4]; - - catch_q.Init( GET_SLOT(x, install("catch.q"))); - catch_.Init( GET_SLOT(x, install("catch"))); - catch_n.Init( GET_SLOT(x, install("catch.n"))); - catch_wt.Init( GET_SLOT(x, install("catch.wt"))); - catch_sel.Init( GET_SLOT(x, install("catch.sel"))); - discards.Init( GET_SLOT(x, install("discards"))); - discards_n.Init( GET_SLOT(x, install("discards.n"))); - discards_wt.Init( GET_SLOT(x, install("discards.wt"))); - discards_sel.Init(GET_SLOT(x, install("discards.sel"))); - landings.Init( GET_SLOT(x, install("landings"))); - landings_n.Init( GET_SLOT(x, install("landings.n"))); - landings_wt.Init( GET_SLOT(x, install("landings.wt"))); - landings_sel.Init(GET_SLOT(x, install("landings.sel"))); - price.Init( GET_SLOT(x, install("price"))); + minquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[0]; + maxquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[1]; + plusgrp = (int)REAL(GET_SLOT(x, Rf_install("range")))[2]; + minyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[3]; + maxyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[4]; + + catch_q.Init( GET_SLOT(x, Rf_install("catch.q"))); + catch_.Init( GET_SLOT(x, Rf_install("catch"))); + catch_n.Init( GET_SLOT(x, Rf_install("catch.n"))); + catch_wt.Init( GET_SLOT(x, Rf_install("catch.wt"))); + catch_sel.Init( GET_SLOT(x, Rf_install("catch.sel"))); + discards.Init( GET_SLOT(x, Rf_install("discards"))); + discards_n.Init( GET_SLOT(x, Rf_install("discards.n"))); + discards_wt.Init( GET_SLOT(x, Rf_install("discards.wt"))); + discards_sel.Init(GET_SLOT(x, Rf_install("discards.sel"))); + landings.Init( GET_SLOT(x, Rf_install("landings"))); + landings_n.Init( GET_SLOT(x, Rf_install("landings.n"))); + landings_wt.Init( GET_SLOT(x, Rf_install("landings.wt"))); + landings_sel.Init(GET_SLOT(x, Rf_install("landings.sel"))); + price.Init( GET_SLOT(x, Rf_install("price"))); InitFlag = true; } @@ -1573,20 +1573,20 @@ SEXP FLCatch::Return(void) REAL(Range)[3] = minyr; REAL(Range)[4] = maxyr; - SET_SLOT(Catch, install("catch"), catch_.Return()); - SET_SLOT(Catch, install("catch.q"), catch_q.Return()); - SET_SLOT(Catch, install("catch.n"), catch_n.Return()); - SET_SLOT(Catch, install("catch.wt"), catch_wt.Return()); - SET_SLOT(Catch, install("catch.sel"), catch_sel.Return()); - SET_SLOT(Catch, install("discards"), discards.Return()); - SET_SLOT(Catch, install("discards.n"), discards_n.Return()); - SET_SLOT(Catch, install("discards.wt"), discards_wt.Return()); - SET_SLOT(Catch, install("discards.sel"),discards_sel.Return()); - SET_SLOT(Catch, install("landings"), landings.Return()); - SET_SLOT(Catch, install("landings.n"), landings_n.Return()); - SET_SLOT(Catch, install("landings.wt"), landings_wt.Return()); - SET_SLOT(Catch, install("landings.sel"),landings_sel.Return()); - SET_SLOT(Catch, install("price"), price.Return()); + SET_SLOT(Catch, Rf_install("catch"), catch_.Return()); + SET_SLOT(Catch, Rf_install("catch.q"), catch_q.Return()); + SET_SLOT(Catch, Rf_install("catch.n"), catch_n.Return()); + SET_SLOT(Catch, Rf_install("catch.wt"), catch_wt.Return()); + SET_SLOT(Catch, Rf_install("catch.sel"), catch_sel.Return()); + SET_SLOT(Catch, Rf_install("discards"), discards.Return()); + SET_SLOT(Catch, Rf_install("discards.n"), discards_n.Return()); + SET_SLOT(Catch, Rf_install("discards.wt"), discards_wt.Return()); + SET_SLOT(Catch, Rf_install("discards.sel"),discards_sel.Return()); + SET_SLOT(Catch, Rf_install("landings"), landings.Return()); + SET_SLOT(Catch, Rf_install("landings.n"), landings_n.Return()); + SET_SLOT(Catch, Rf_install("landings.wt"), landings_wt.Return()); + SET_SLOT(Catch, Rf_install("landings.sel"),landings_sel.Return()); + SET_SLOT(Catch, Rf_install("price"), price.Return()); UNPROTECT(2); @@ -1625,22 +1625,22 @@ void FLFleet::Init(SEXP x) { if (nunits >= 1 || nseasons >= 1 || nareas >= 1 || nspp >= 1) unalloc(); - minquant = (int)REAL(GET_SLOT(x, install("range")))[0]; - maxquant = (int)REAL(GET_SLOT(x, install("range")))[1]; - plusgrp = (int)REAL(GET_SLOT(x, install("range")))[2]; - minyr = (int)REAL(GET_SLOT(x, install("range")))[3]; - maxyr = (int)REAL(GET_SLOT(x, install("range")))[4]; + minquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[0]; + maxquant = (int)REAL(GET_SLOT(x, Rf_install("range")))[1]; + plusgrp = (int)REAL(GET_SLOT(x, Rf_install("range")))[2]; + minyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[3]; + maxyr = (int)REAL(GET_SLOT(x, Rf_install("range")))[4]; nunits = 1; nseasons = 1; nareas = 1; - effort.Init( GET_SLOT(x, install("effort"))); - capacity.Init( GET_SLOT(x, install("capacity"))); - crewshare.Init(GET_SLOT(x, install("crewshare"))); - fcost.Init( GET_SLOT(x, install("fcost"))); + effort.Init( GET_SLOT(x, Rf_install("effort"))); + capacity.Init( GET_SLOT(x, Rf_install("capacity"))); + crewshare.Init(GET_SLOT(x, Rf_install("crewshare"))); + fcost.Init( GET_SLOT(x, Rf_install("fcost"))); - SEXP metiers = PROTECT(GET_SLOT(x, install("metiers"))); + SEXP metiers = PROTECT(GET_SLOT(x, Rf_install("metiers"))); nmetier = NElemList(metiers); @@ -1649,7 +1649,7 @@ void FLFleet::Init(SEXP x) effshare.alloc_n7(nmetier); vcost.alloc_n7( nmetier); - SEXP catches = PROTECT(GET_SLOT(VECTOR_ELT(metiers, 0), install("catches"))); + SEXP catches = PROTECT(GET_SLOT(VECTOR_ELT(metiers, 0), Rf_install("catches"))); nspp = NElemList(catches); @@ -1673,10 +1673,10 @@ void FLFleet::Init(SEXP x) for (int i=1; i<=nmetier; i++) { SEXP metier = PROTECT(VECTOR_ELT(metiers, i-1)); - SEXP catches = PROTECT(GET_SLOT(metier, install("catches"))); + SEXP catches = PROTECT(GET_SLOT(metier, Rf_install("catches"))); - effshare.Init(i, GET_SLOT(metier, install("effshare"))); - vcost.Init( i, GET_SLOT(metier, install("vcost"))); + effshare.Init(i, GET_SLOT(metier, Rf_install("effshare"))); + vcost.Init( i, GET_SLOT(metier, Rf_install("vcost"))); nspp = NElemList(catches); @@ -1686,20 +1686,20 @@ void FLFleet::Init(SEXP x) { SEXP t = PROTECT(VECTOR_ELT(catches, j-1)); - catch_.Init( i, j, GET_SLOT(t, install("catch"))); - catch_n.Init( i, j, GET_SLOT(t, install("catch.n"))); - catch_wt.Init( i, j, GET_SLOT(t, install("catch.wt"))); - catch_sel.Init( i, j, GET_SLOT(t, install("catch.sel"))); - catch_q.Init( i, j, GET_SLOT(t, install("catch.q"))); - landings.Init( i, j, GET_SLOT(t, install("landings"))); - landings_n.Init( i, j, GET_SLOT(t, install("landings.n"))); - landings_wt.Init( i, j, GET_SLOT(t, install("landings.wt"))); - landings_sel.Init(i, j, GET_SLOT(t, install("landings.sel"))); - discards.Init( i, j, GET_SLOT(t, install("discards"))); - discards_n.Init( i, j, GET_SLOT(t, install("discards.n"))); - discards_wt.Init( i, j, GET_SLOT(t, install("discards.wt"))); - discards_sel.Init(i, j, GET_SLOT(t, install("discards.sel"))); - price.Init( i, j, GET_SLOT(t, install("price"))); + catch_.Init( i, j, GET_SLOT(t, Rf_install("catch"))); + catch_n.Init( i, j, GET_SLOT(t, Rf_install("catch.n"))); + catch_wt.Init( i, j, GET_SLOT(t, Rf_install("catch.wt"))); + catch_sel.Init( i, j, GET_SLOT(t, Rf_install("catch.sel"))); + catch_q.Init( i, j, GET_SLOT(t, Rf_install("catch.q"))); + landings.Init( i, j, GET_SLOT(t, Rf_install("landings"))); + landings_n.Init( i, j, GET_SLOT(t, Rf_install("landings.n"))); + landings_wt.Init( i, j, GET_SLOT(t, Rf_install("landings.wt"))); + landings_sel.Init(i, j, GET_SLOT(t, Rf_install("landings.sel"))); + discards.Init( i, j, GET_SLOT(t, Rf_install("discards"))); + discards_n.Init( i, j, GET_SLOT(t, Rf_install("discards.n"))); + discards_wt.Init( i, j, GET_SLOT(t, Rf_install("discards.wt"))); + discards_sel.Init(i, j, GET_SLOT(t, Rf_install("discards.sel"))); + price.Init( i, j, GET_SLOT(t, Rf_install("price"))); } } @@ -1729,56 +1729,56 @@ SEXP FLFleet::Return(void) REAL(Range)[3] = minyr; REAL(Range)[4] = maxyr; - SET_SLOT(fleet, install("range"), Range); - SET_SLOT(fleet, install("effort"), effort.Return()); - SET_SLOT(fleet, install("capacity"), capacity.Return()); - SET_SLOT(fleet, install("crewshare"), crewshare.Return()); - SET_SLOT(fleet, install("fcost"), fcost.Return()); - SET_SLOT(fleet, install("vcost"), vcost.Return()); + SET_SLOT(fleet, Rf_install("range"), Range); + SET_SLOT(fleet, Rf_install("effort"), effort.Return()); + SET_SLOT(fleet, Rf_install("capacity"), capacity.Return()); + SET_SLOT(fleet, Rf_install("crewshare"), crewshare.Return()); + SET_SLOT(fleet, Rf_install("fcost"), fcost.Return()); + SET_SLOT(fleet, Rf_install("vcost"), vcost.Return()); SEXP metiers = NEW_OBJECT(MAKE_CLASS("FLMetiers")); - SEXP metiers_data = allocVector(VECSXP, nmetier); + SEXP metiers_data = Rf_allocVector(VECSXP, nmetier); for (int i=1; i<=nmetier; i++) { SEXP metier = NEW_OBJECT(MAKE_CLASS("FLMetier")); - SET_SLOT(metier, install("effshare"), effshare.Return(i)); - SET_SLOT(metier, install("vcost"), vcost.Return(i)); + SET_SLOT(metier, Rf_install("effshare"), effshare.Return(i)); + SET_SLOT(metier, Rf_install("vcost"), vcost.Return(i)); SEXP catches = NEW_OBJECT(MAKE_CLASS("FLCatches")); - SEXP catch_data = allocVector(VECSXP, nspp); + SEXP catch_data = Rf_allocVector(VECSXP, nspp); for (int j=1; j<=nspp; j++) { SEXP _catch = NEW_OBJECT(MAKE_CLASS("FLCatch")); - SET_SLOT(_catch, install("catch"), catch_.Return(i,j)); - SET_SLOT(_catch, install("catch.n"), catch_n.Return(i,j)); - SET_SLOT(_catch, install("catch.wt"), catch_wt.Return(i,j)); - SET_SLOT(_catch, install("catch.sel"), catch_sel.Return(i,j)); - SET_SLOT(_catch, install("catch.q"), catch_q.Return(i,j)); - SET_SLOT(_catch, install("landings"), landings.Return(i,j)); - SET_SLOT(_catch, install("landings.n"), landings_n.Return(i,j)); - SET_SLOT(_catch, install("landings.wt"), landings_wt.Return(i,j)); - SET_SLOT(_catch, install("landings.sel"), landings_sel.Return(i,j)); - SET_SLOT(_catch, install("discards"), discards.Return(i,j)); - SET_SLOT(_catch, install("discards.n"), discards_n.Return(i,j)); - SET_SLOT(_catch, install("discards.wt"), discards_wt.Return(i,j)); - SET_SLOT(_catch, install("discards.sel"), discards_sel.Return(i,j)); - SET_SLOT(_catch, install("price"), price.Return(i,j)); + SET_SLOT(_catch, Rf_install("catch"), catch_.Return(i,j)); + SET_SLOT(_catch, Rf_install("catch.n"), catch_n.Return(i,j)); + SET_SLOT(_catch, Rf_install("catch.wt"), catch_wt.Return(i,j)); + SET_SLOT(_catch, Rf_install("catch.sel"), catch_sel.Return(i,j)); + SET_SLOT(_catch, Rf_install("catch.q"), catch_q.Return(i,j)); + SET_SLOT(_catch, Rf_install("landings"), landings.Return(i,j)); + SET_SLOT(_catch, Rf_install("landings.n"), landings_n.Return(i,j)); + SET_SLOT(_catch, Rf_install("landings.wt"), landings_wt.Return(i,j)); + SET_SLOT(_catch, Rf_install("landings.sel"), landings_sel.Return(i,j)); + SET_SLOT(_catch, Rf_install("discards"), discards.Return(i,j)); + SET_SLOT(_catch, Rf_install("discards.n"), discards_n.Return(i,j)); + SET_SLOT(_catch, Rf_install("discards.wt"), discards_wt.Return(i,j)); + SET_SLOT(_catch, Rf_install("discards.sel"), discards_sel.Return(i,j)); + SET_SLOT(_catch, Rf_install("price"), price.Return(i,j)); SET_VECTOR_ELT(catch_data, j-1, _catch); } - catches = R_do_slot_assign(catches, install(".Data"), catch_data); + catches = R_do_slot_assign(catches, Rf_install(".Data"), catch_data); - SET_SLOT(metier, install("catches"), catches); + SET_SLOT(metier, Rf_install("catches"), catches); SET_VECTOR_ELT(metiers_data, i-1, metier); } - metiers = R_do_slot_assign(metiers, install(".Data"), metiers_data); + metiers = R_do_slot_assign(metiers, Rf_install(".Data"), metiers_data); - SET_SLOT(fleet, install("metiers"), metiers); + SET_SLOT(fleet, Rf_install("metiers"), metiers); return fleet; } @@ -1895,13 +1895,13 @@ void FLQuant2::Init(int i7, SEXP x) if (InitFlag(i7)) unalloc(i7); - SEXP Quant = GET_SLOT(x, install(".Data")), + SEXP Quant = GET_SLOT(x, Rf_install(".Data")), dims = GET_DIM(Quant), dimnames = GET_DIMNAMES(Quant); double *Q = NUMERIC_POINTER(AS_NUMERIC(Quant)); - int dim[6], n = length(dims); + int dim[6], n = Rf_length(dims); dim[0] = INTEGER(dims)[0]; dim[1] = INTEGER(dims)[1]; @@ -2048,7 +2048,7 @@ SEXP FLQuant2::Return(int i7) //Create array for slot //Set dimensions of array - PROTECT(dim = allocVector(INTSXP, 6)); + PROTECT(dim = Rf_allocVector(INTSXP, 6)); INTEGER(dim)[0] = maxquant(i7)-minquant(i7) +1; INTEGER(dim)[1] = maxyr(i7) -minyr(i7) +1; INTEGER(dim)[2] = nunits(i7); @@ -2060,26 +2060,26 @@ SEXP FLQuant2::Return(int i7) PROTECT(v = Rf_allocArray(REALSXP, dim)); //Create dimension names - PROTECT(dimnames = allocVector(VECSXP, 6)); + PROTECT(dimnames = Rf_allocVector(VECSXP, 6)); - PROTECT(d1 = allocVector(INTSXP, maxquant(i7)-minquant(i7) +1)); + PROTECT(d1 = Rf_allocVector(INTSXP, maxquant(i7)-minquant(i7) +1)); for (iAge=minquant(i7), i=0; iAge<=maxquant(i7); iAge++, i++) INTEGER(d1)[i] = iAge; SET_VECTOR_ELT(dimnames, 0, d1); - PROTECT(d2 = allocVector(INTSXP, maxyr(i7)-minyr(i7)+1)); + PROTECT(d2 = Rf_allocVector(INTSXP, maxyr(i7)-minyr(i7)+1)); for (iYear=minyr(i7), i=0; iYear<=maxyr(i7); iYear++, i++) INTEGER(d2)[i] = iYear; SET_VECTOR_ELT(dimnames, 1, d2); if (nunits(i7)==1) { - PROTECT(d3 = allocVector(STRSXP, nunits(i7))); - SET_STRING_ELT(d3, 0, mkChar("unique")); + PROTECT(d3 = Rf_allocVector(STRSXP, nunits(i7))); + SET_STRING_ELT(d3, 0, Rf_mkChar("unique")); } else { - PROTECT(d3 = allocVector(INTSXP, nunits(i7))); + PROTECT(d3 = Rf_allocVector(INTSXP, nunits(i7))); for (iUnit=1, i=0; iUnit<=nunits(i7); iUnit++, i++) INTEGER(d3)[i] = iUnit; } @@ -2087,12 +2087,12 @@ SEXP FLQuant2::Return(int i7) if (nseasons(i7)==1) { - PROTECT(d4 = allocVector(STRSXP, nseasons(i7))); - SET_STRING_ELT(d4, 0, mkChar("all")); + PROTECT(d4 = Rf_allocVector(STRSXP, nseasons(i7))); + SET_STRING_ELT(d4, 0, Rf_mkChar("all")); } else { - PROTECT(d4 = allocVector(INTSXP, nseasons(i7))); + PROTECT(d4 = Rf_allocVector(INTSXP, nseasons(i7))); for (iSeason=1, i=0; iSeason<=nseasons(i7); iSeason++, i++) INTEGER(d4)[i] = iSeason; } @@ -2101,33 +2101,33 @@ SEXP FLQuant2::Return(int i7) if (nareas(i7)==1) { - PROTECT(d5 = allocVector(STRSXP, nareas(i7))); - SET_STRING_ELT(d5, 0, mkChar("unique")); + PROTECT(d5 = Rf_allocVector(STRSXP, nareas(i7))); + SET_STRING_ELT(d5, 0, Rf_mkChar("unique")); } else { - PROTECT(d5 = allocVector(INTSXP, nareas(i7))); + PROTECT(d5 = Rf_allocVector(INTSXP, nareas(i7))); for (iArea=1, i=0; iArea<=nareas(i7); iArea++, i++) INTEGER(d5)[i] = iArea; } SET_VECTOR_ELT(dimnames, 4, d5); - PROTECT(d6 = allocVector(INTSXP, niters(i7))); + PROTECT(d6 = Rf_allocVector(INTSXP, niters(i7))); for (iIter=1, i=0; iIter<=niters(i7); iIter++, i++) INTEGER(d6)[i] = iIter; SET_VECTOR_ELT(dimnames, 5, d6); //Create names for dimensions - PROTECT(names = allocVector(STRSXP, 6)); - SET_STRING_ELT(names, 0, mkChar("age")); - SET_STRING_ELT(names, 1, mkChar("year")); - SET_STRING_ELT(names, 2, mkChar("unit")); - SET_STRING_ELT(names, 3, mkChar("season")); - SET_STRING_ELT(names, 4, mkChar("area")); - SET_STRING_ELT(names, 5, mkChar("iter")); + PROTECT(names = Rf_allocVector(STRSXP, 6)); + SET_STRING_ELT(names, 0, Rf_mkChar("age")); + SET_STRING_ELT(names, 1, Rf_mkChar("year")); + SET_STRING_ELT(names, 2, Rf_mkChar("unit")); + SET_STRING_ELT(names, 3, Rf_mkChar("season")); + SET_STRING_ELT(names, 4, Rf_mkChar("area")); + SET_STRING_ELT(names, 5, Rf_mkChar("iter")); - setAttrib(dimnames, R_NamesSymbol, names); - setAttrib(v, R_DimNamesSymbol, dimnames); + Rf_setAttrib(dimnames, R_NamesSymbol, names); + Rf_setAttrib(v, R_DimNamesSymbol, dimnames); //Set data i=0; @@ -2140,7 +2140,7 @@ SEXP FLQuant2::Return(int i7) REAL(v)[i++] = data[i7][iAge][iYear][iUnit][iSeason][iArea][iIter]; //Set slot - Quant = R_do_slot_assign(Quant, install(".Data"), v); + Quant = R_do_slot_assign(Quant, Rf_install(".Data"), v); UNPROTECT(11); @@ -2151,7 +2151,7 @@ SEXP FLQuant2::Return(void) { SEXP ReturnObject; - PROTECT(ReturnObject = allocVector(VECSXP,flq_n)); + PROTECT(ReturnObject = Rf_allocVector(VECSXP,flq_n)); for (int i=0; i