| 1234 | #endif |
| 1235 | |
| 1236 | void CppiaClassInfo::link() |
| 1237 | { |
| 1238 | int newPos = -1; |
| 1239 | for(int i=0;i<staticFunctions.size();i++) |
| 1240 | { |
| 1241 | DBGLOG(" Link %s::%s\n", name.c_str(), staticFunctions[i]->name.c_str() ); |
| 1242 | staticFunctions[i]->link(); |
| 1243 | } |
| 1244 | if (newFunc) |
| 1245 | newFunc->link(); |
| 1246 | |
| 1247 | if (initExpr) |
| 1248 | initExpr = initExpr->link(cppia); |
| 1249 | |
| 1250 | // Functions |
| 1251 | for(int i=0;i<memberFunctions.size();i++) |
| 1252 | { |
| 1253 | DBGLOG(" Link member %s::%s\n", name.c_str(), memberFunctions[i]->name.c_str() ); |
| 1254 | memberFunctions[i]->link(); |
| 1255 | } |
| 1256 | |
| 1257 | for(int i=0;i<staticDynamicFunctions.size();i++) |
| 1258 | staticDynamicFunctions[i]->link(cppia); |
| 1259 | |
| 1260 | for(int i=0;i<dynamicFunctions.size();i++) |
| 1261 | dynamicFunctions[i]->link(cppia); |
| 1262 | |
| 1263 | for(int i=0;i<memberFunctions.size();i++) |
| 1264 | { |
| 1265 | vtable[ memberFunctions[i]->vtableSlot ] = memberFunctions[i]->funExpr; |
| 1266 | if (interfaceSlotSize) |
| 1267 | { |
| 1268 | int interfaceSlot = cppia.findInterfaceSlot( memberFunctions[i]->name ); |
| 1269 | DBGLOG("Set %s : %s to %d @%p\n", name.c_str(), memberFunctions[i]->name.c_str(), interfaceSlot, vtable); |
| 1270 | if (interfaceSlot>0 && interfaceSlot<interfaceSlotSize) |
| 1271 | vtable[ -interfaceSlot ] = memberFunctions[i]->funExpr; |
| 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | // Find interface functions that are not implemented in client, but rely on host fallback... |
| 1276 | if (!isInterface) |
| 1277 | { |
| 1278 | std::vector<ScriptNamedFunction *> &nativeInterfaceFuncs = type->cppiaClass->nativeInterfaceFunctions; |
| 1279 | for(int i=0;i<nativeInterfaceFuncs.size();i++) |
| 1280 | { |
| 1281 | int interfaceSlot = cppia.findInterfaceSlot( nativeInterfaceFuncs[i]->name); |
| 1282 | if (!vtable[-interfaceSlot]) |
| 1283 | vtable[-interfaceSlot] = new ScriptCallable(cppia,nativeInterfaceFuncs[i]); |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | // Vars ... |
| 1288 | if (!isInterface) |
| 1289 | { |
| 1290 | for(int i=0;i<memberVars.size();i++) |
| 1291 | { |
| 1292 | CppiaVar &var = *memberVars[i]; |
| 1293 | var.link(cppia); |
nothing calls this directly
no test coverage detected