apply__c.java

/* ========================================================================
 * PlantUML : a free UML diagram generator
 * ========================================================================
 *
 * Project Info:  https://plantuml.com
 * 
 * If you like this project or if you find it useful, you can support us at:
 * 
 * https://plantuml.com/patreon (only 1$ per month!)
 * https://plantuml.com/paypal
 * 
 * This file is part of Smetana.
 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
 *
 * (C) Copyright 2009-2022, Arnaud Roques
 *
 * This translation is distributed under the same License as the original C program:
 * 
 *************************************************************************
 * Copyright (c) 2011 AT&T Intellectual Property 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: See CVS logs. Details at http://www.graphviz.org/
 *************************************************************************
 *
 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
 * 
 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
 * 
 * You may obtain a copy of the License at
 * 
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package gen.lib.cgraph;
import static gen.lib.cgraph.edge__c.agsubedge;
import static gen.lib.cgraph.node__c.agsubnode;
import static gen.lib.cgraph.obj__c.agraphof;
import static gen.lib.cgraph.subg__c.agfstsubg;
import static gen.lib.cgraph.subg__c.agnxtsubg;
import static smetana.core.Macro.AGINEDGE;
import static smetana.core.Macro.AGNODE;
import static smetana.core.Macro.AGOUTEDGE;
import static smetana.core.Macro.AGRAPH;
import static smetana.core.Macro.UNSUPPORTED;
import static smetana.core.debug.SmetanaDebug.ENTERING;
import static smetana.core.debug.SmetanaDebug.LEAVING;

import gen.annotation.Original;
import gen.annotation.Unused;
import h.ST_Agedge_s;
import h.ST_Agnode_s;
import h.ST_Agobj_s;
import h.ST_Agraph_s;
import smetana.core.CFunction;
import smetana.core.CFunctionAbstract;
import smetana.core.Globals;
import smetana.core.__ptr__;

public class apply__c {




// Ported from lib/cgraph/apply.c for dot2_rank (newrank=true), which deletes
// nodes and edges.
public static CFunction subnode_search = new CFunctionAbstract("subnode_search") {
	public Object exe(Globals zz, Object... args) {
		return subnode_search(zz, (ST_Agraph_s) args[0], (ST_Agobj_s) args[1]);
	}};
@Original(version="2.38.0", path="lib/cgraph/apply.c", name="subnode_search", key="", definition="static Agobj_t *subnode_search(Agraph_t * sub, Agobj_t * n)")
public static ST_Agobj_s subnode_search(Globals zz, ST_Agraph_s sub, ST_Agobj_s n) {
    if (agraphof(n) == sub) //     if (agraphof(n) == sub)
	return n; // 	return n;
    return agsubnode(zz, sub, (ST_Agnode_s) n, false); //     return (Agobj_t *) agsubnode(sub, (Agnode_t *) n, FALSE);
}

public static CFunction subedge_search = new CFunctionAbstract("subedge_search") {
	public Object exe(Globals zz, Object... args) {
		return subedge_search(zz, (ST_Agraph_s) args[0], (ST_Agobj_s) args[1]);
	}};
@Original(version="2.38.0", path="lib/cgraph/apply.c", name="subedge_search", key="", definition="static Agobj_t *subedge_search(Agraph_t * sub, Agobj_t * e)")
public static ST_Agobj_s subedge_search(Globals zz, ST_Agraph_s sub, ST_Agobj_s e) {
    if (agraphof(e) == sub) //     if (agraphof(e) == sub)
	return e; // 	return e;
    return agsubedge(zz, sub, (ST_Agedge_s) e, false); //     return (Agobj_t *) agsubedge(sub, (Agedge_t *) e, FALSE);
}

public static CFunction subgraph_search = new CFunctionAbstract("subgraph_search") {
	
	public Object exe(Globals zz, Object... args) {
		return subgraph_search((ST_Agraph_s)args[0], (ST_Agobj_s)args[1]);
	}};
@Unused
@Original(version="2.38.0", path="lib/cgraph/apply.c", name="", key="95y4aknoddh42lieikrb72vxw", definition="static Agobj_t *subgraph_search(Agraph_t * sub, Agobj_t * g)")
public static ST_Agobj_s subgraph_search(ST_Agraph_s sub, ST_Agobj_s g) {
ENTERING("95y4aknoddh42lieikrb72vxw","subgraph_search");
try {
    return (ST_Agobj_s) sub.base;
} finally {
LEAVING("95y4aknoddh42lieikrb72vxw","subgraph_search");
}
}




//3 8s9l15wqucf1glmbeb6fmya8e
// static void rec_apply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg, 		      agobjsearchfn_t objsearch, int preorder) 
@Unused
@Original(version="2.38.0", path="lib/cgraph/apply.c", name="rec_apply", key="8s9l15wqucf1glmbeb6fmya8e", definition="static void rec_apply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg, 		      agobjsearchfn_t objsearch, int preorder)")
public static void rec_apply(Globals zz, ST_Agraph_s g, ST_Agobj_s obj, CFunction fn, __ptr__ arg, CFunction objsearch, boolean preorder) {
ENTERING("8s9l15wqucf1glmbeb6fmya8e","rec_apply");
try {
    ST_Agraph_s sub;
    ST_Agobj_s subobj;
    if (preorder)
	fn.exe(zz, g, obj, arg);
    for (sub = agfstsubg(zz, g); sub!=null; sub = agnxtsubg(zz, sub)) {
    if ((subobj = (ST_Agobj_s) objsearch.exe(zz, sub, obj))!=null)
	    rec_apply(zz, sub, subobj, fn, arg, objsearch, preorder);
    }
    if (!preorder)
	fn.exe(zz, g, obj, arg);
} finally {
LEAVING("8s9l15wqucf1glmbeb6fmya8e","rec_apply");
}
}




//3 9hqql178zpl8iudlf6sgnv7aj
// int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg, 	    int preorder) 
@Unused
@Original(version="2.38.0", path="lib/cgraph/apply.c", name="agapply", key="9hqql178zpl8iudlf6sgnv7aj", definition="int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg, 	    int preorder)")
public static int agapply(Globals zz, ST_Agraph_s g, ST_Agobj_s obj, CFunction fn, __ptr__ arg, boolean preorder) {
ENTERING("9hqql178zpl8iudlf6sgnv7aj","agapply");
try {
	ST_Agobj_s subobj;
    CFunction objsearch=null;
    switch (obj.tag.objtype) {
    case AGRAPH:
 	objsearch = apply__c.subgraph_search;
	break;
    case AGNODE:
	objsearch = apply__c.subnode_search; // 	objsearch = subnode_search;
	break;
    case AGOUTEDGE:
    case AGINEDGE:
	objsearch = apply__c.subedge_search; // 	objsearch = subedge_search;
	break;
    default:
UNSUPPORTED("2pc67byzirrkhe1cmdoguh6i1"); // 	agerr(AGERR, "agapply: unknown object type %d\n", AGTYPE(obj));
UNSUPPORTED("8d9xfgejx5vgd6shva5wk5k06"); // 	return -1;
	break;
    }
    if ((subobj = (ST_Agobj_s) objsearch.exe(zz, g, obj))!=null) {
	rec_apply(zz, g, subobj, fn, arg, objsearch, preorder);
	return 0;
    } else
UNSUPPORTED("8d9xfgejx5vgd6shva5wk5k06"); // 	return -1;
UNSUPPORTED("c24nfmv9i7o5eoqaymbibp7m7"); // }

throw new UnsupportedOperationException();
} finally {
LEAVING("9hqql178zpl8iudlf6sgnv7aj","agapply");
}
}


}