Assembly *Assembly::create(LSLuaState *vm, const utString& name) { Assembly *a = new Assembly(); a->vm = vm; a->name = name; utHashTable<utHashedString, Assembly *> *lookup = NULL; UTsize idx = assemblies.find(vm); if (idx != UT_NPOS) { lookup = assemblies.at(idx); } else { lookup = new utHashTable<utHashedString, Assembly *>(); assemblies.insert(vm, lookup); } utHashedString key = a->name; lookup->insert(key, a); vm->assemblies.insert(utHashedString(a->getName()), a); return a; }
Assembly *GraspGLObjects::CreateRollPrompt( double radius ) { Assembly *prompt = new Assembly(); // Angular extent of the circular arrow, where 1.0 = 360°. double guage = radius / 10.0; double arc = 0.85; Annulus *donut = new Annulus( radius, guage, arc, curve_facets, curve_facets ); donut->SetAttitude( 0.0, 90.0, 0.0 ); prompt->AddComponent( donut ); TaperedAnnulus *tip = new TaperedAnnulus( radius, radius / 3.0, 1.0, 0.05, curve_facets ); tip->SetAttitude( 0.0, 90.0, 0.0 ); tip->SetOrientation( - arc * 360.0, 0.0, 0.0 ); prompt->AddComponent( tip ); Ellipsoid *base = new Ellipsoid ( guage, guage / 2.0, guage ); base->SetPosition( radius, 0.0, 0.0 ); prompt->AddComponent( base ); prompt->SetColor( 0.5, 0.5, 0.5, 0.5 ); return prompt; }
Assembly *LSLuaState::loadExecutableAssembly(const utString& assemblyName, bool absPath) { // executables always in bin utString filePath; if (!absPath) { filePath = "./bin/"; } filePath += assemblyName; if (!strstr(filePath.c_str(), ".loom")) { filePath += ".loom"; } const char *buffer = NULL; long bufferSize; LSMapFile(filePath.c_str(), (void **)&buffer, &bufferSize); lmAssert(buffer && bufferSize, "Error loading executable: %s, unable to map file", assemblyName.c_str()); Assembly* assembly = loadExecutableAssemblyBinary(buffer, bufferSize); LSUnmapFile(filePath.c_str()); lmAssert(assembly, "Error loading executable: %s", assemblyName.c_str()); assembly->freeByteCode(); return assembly; }
FCIMPL3(Object*, AppDomainNative::CreateDynamicAssembly, AssemblyNameBaseObject* assemblyNameUNSAFE, StackCrawlMark* stackMark, INT32 access) { FCALL_CONTRACT; ASSEMBLYREF refRetVal = NULL; //<TODO> // @TODO: there MUST be a better way to do this... //</TODO> CreateDynamicAssemblyArgs args; args.assemblyName = (ASSEMBLYNAMEREF) assemblyNameUNSAFE; args.loaderAllocator = NULL; args.access = access; args.stackMark = stackMark; HELPER_METHOD_FRAME_BEGIN_RET_PROTECT((CreateDynamicAssemblyArgsGC&)args); Assembly *pAssembly = Assembly::CreateDynamic(GetAppDomain(), &args); refRetVal = (ASSEMBLYREF) pAssembly->GetExposedObject(); HELPER_METHOD_FRAME_END(); return OBJECTREFToObject(refRetVal); }
Assembly *GraspGLObjects::CreateSuccessIndicator( void ) { Assembly *assembly = new Assembly(); Sphere *sphere = new Sphere( prompt_radius ); sphere->SetColor( GREEN ); assembly->AddComponent( sphere ); return assembly; }
void Object::add_assembly(Assembly ab) { v_ab.push_back(ab); v_kd.push_back(ab.getkd()); v_ks.push_back(ab.getks()); v_shininess.push_back(ab.getshininess()); }
// Create a translucid cloud to show where to place the hand. Assembly *GraspGLObjects::CreateZone( void ) { Assembly *assembly = new Assembly(); Disk *disk = new Disk( 50.0, 0.0, 128 ); assembly->AddComponent( disk ); // Set the color to a blinking translucid green. assembly->SetColor( 0.0, 1.0, 0.0, - 0.05 ); return assembly; }
Assembly *GraspGLObjects::CreateStarrySky( void ) { Assembly *sky = new Assembly(); Patch *patch = new Patch( room_radius * 4.4, room_radius * 4.4 ); patch->SetTexture( sky_texture ); sky->AddComponent( patch ); sky->SetColor(WHITE); return( sky ); }
Assembly *GraspGLObjects::CreateLaserPointer( void ) { Assembly *laserPointer = new Assembly(); Sphere *sphere = new Sphere( finger_ball_radius*2.0 ); sphere->SetPosition( 0.0, 0.0, - laser_distance ); laserPointer->AddComponent( sphere ); // Laser is off by default. laserPointer->Disable(); return laserPointer; }
Assembly *GraspGLObjects::CreateDarkSky( void ) { Assembly *darkSky = new Assembly(); Patch *patch = new Patch( room_radius * 2.2, room_radius * 2.2 ); patch->SetTexture( sky_texture );// there is something strange if I dont put the texture the ligthing of the whole tunnel changes darkSky->AddComponent( patch ); darkSky->SetColor( BLACK ); darkSky->enabled = false; return( darkSky ); }
// get all types loaded for a given package void LSLuaState::getPackageTypes(const utString& packageName, utArray<Type *>& types) { for (UTsize i = 0; i < assemblies.size(); i++) { Assembly *assembly = assemblies.at(i); assembly->getPackageTypes(packageName, types); } }
void InputBinder::bind_assembly_entity_to_input( const Scene& scene, const SymbolTable& scene_symbols, const Assembly& assembly, const SymbolTable& assembly_symbols, const char* entity_type, const char* entity_name, const char* param_value, InputArray::iterator& input) { switch (assembly_symbols.lookup(param_value)) { case SymbolTable::SymbolColor: bind_color_to_input( assembly.colors(), param_value, input); break; case SymbolTable::SymbolTextureInstance: bind_texture_instance_to_input( assembly.textures(), assembly.texture_instances(), assembly.get_uid(), entity_type, entity_name, param_value, input); break; case SymbolTable::SymbolNotFound: // No entity with this name was found in this scope. // Attempt to bind the input to a scene entity. bind_scene_entity_to_input( scene, scene_symbols, entity_type, entity_name, param_value, input); break; default: RENDERER_LOG_ERROR( "while defining %s \"%s\": cannot bind \"%s\" to parameter \"%s\".", entity_type, entity_name, param_value, input.name()); ++m_error_count; break; } }
Assembly *GraspGLObjects::CreateTorso( void ) { Assembly *torso = new Assembly(); Slab *slab = new Slab( torso_shape[X], torso_shape[Y], torso_shape[Z] ); slab->SetColor( 0.1f, 0.4f, 0.0f ); torso->AddComponent( slab ); Disk *disk = new Disk( 50.0 ); disk->SetPosition( 0.0, 0.0, -40.0 ); disk->SetColor( 1.0f, 0.7f, 0.0f ); torso->AddComponent( disk ); return torso; }
Assembly *GraspGLObjects::CreateIndicator( Texture *texture, double hole_radius ) { Assembly *assembly = new Assembly(); Disk *surface; surface = new Disk( 120.0, hole_radius, 128 ); surface->SetTexture( texture ); assembly->AddComponent( surface ); assembly->SetColor( 0.9, 0.9, 1.0, hmdTransparency ); assembly->Disable(); return assembly; }
Assembly *GraspGLObjects::CreateResponse( void ) { static int fingers = target_balls - 1; static double finger_spacing = target_ball_radius; Assembly *projectiles = new Assembly(); for ( int trg = - fingers; trg <= fingers ; trg++ ){ Sphere *sphere = new Sphere( target_ball_radius * 0.75 ); sphere->SetColor( 200.0f/255.0f, (75.0f + float(trg) * 75.0f/2.0f)/255.0f , 0.0f, 1.0f ); // Space the balls vertically. sphere->SetPosition( 0.0, 0.0 + target_ball_spacing * trg, 0.0 ); projectiles->AddComponent( sphere ); } return projectiles; }
HRESULT BindingLog::LogResult(BindResult *pBindResult) { HRESULT hr = S_OK; BINDER_LOG_ENTER(L"BindingLog::LogResult"); PathString assemblyDisplayName; PathString format; PathString info; pBindResult->GetAssemblyName()->GetDisplayName(assemblyDisplayName, AssemblyName::INCLUDE_VERSION | AssemblyName::INCLUDE_ARCHITECTURE); IF_FAIL_GO(format.LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_ID)); info.Printf(format.GetUnicode(), assemblyDisplayName.GetUnicode()); IF_FAIL_GO(Log(info)); IUnknown *pIUnknownAssembly; pIUnknownAssembly = pBindResult->GetAssembly(FALSE /* fAddRef */); Assembly *pAssembly; pAssembly = static_cast<Assembly *>(static_cast<void *>(pIUnknownAssembly)); _ASSERTE(pAssembly != NULL); if (pAssembly->GetIsInGAC()) { IF_FAIL_GO(info. LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_ASSEMBLY_STATUS_BOUND_GAC)); } else if (pAssembly->GetIsByteArray()) { IF_FAIL_GO(info. LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_ASSEMBLY_STATUS_BOUND_BYTE_ARRAY)); } else { PathString assemblyPath; BinderGetImagePath(pAssembly->GetPEImage(), assemblyPath); IF_FAIL_GO(format. LoadResourceAndReturnHR(CCompRC::Debugging, ID_FUSLOG_ASSEMBLY_STATUS_BOUND_TO_LOCATION)); info.Printf(format.GetUnicode(), assemblyPath.GetUnicode()); } IF_FAIL_GO(Log(info)); Exit: BINDER_LOG_LEAVE_HR(L"BindingLog::LogResult", hr); return hr; }
bool Assembler::ParseLine(string& line, int linecount, Assembly& assembly, LabelVector& labels) { string op; int i = NextWord(line, op); // skip commented and empty lines if(i == -1 || op == "//" || op == ";") return true; // this is a a very slow way of doing things, but then this code will only // be used during development and for debugging OpDesc *opcode; int codecount = sizeof(opcodes)/sizeof(OpDesc); int j = 0; for(; j < codecount; j ++) { if(stricmp(opcodes[j].name, op.c_str()) == 0) { opcode = &opcodes[j]; break; } } // is this a label? if(j == codecount) { size_t k = op.length() - 1; if(op.find_first_of(":") == k) { string name = op.substr(0, k); labels.at(AddLabel(name, labels)).pos = assembly.curpos; return true; } else return false; } else { assembly.WriteDword(opcode->code); string param; i = NextWord(line, param, i); if(IsJumpOp(opcode->code)) { // write the label index, we'll later replace this with the code position assembly.WriteDword(AddLabel(param, labels)); } else { if(i == -1) { assembly.WriteDword(0); if(opcode->paramcount > 0) return false; // if we need more params, bail } else assembly.WriteDword(StringToOperand(param, opcode)); } } return true; }
int Assembly::loadBytes(lua_State *L) { utByteArray *bytes = static_cast<utByteArray*>(lualoom_getnativepointer(L, 1, false, "system.ByteArray")); Assembly *assembly = LSLuaState::getExecutingVM(L)->loadExecutableAssemblyBinary(static_cast<const char*>(bytes->getDataPtr()), bytes->getSize()); lmAssert(assembly, "Error loading assembly bytes"); lualoom_pushnative(L, assembly); assembly->freeByteCode(); return 1; }
Assembly *LSLuaState::loadTypeAssembly(const utString& assemblyString) { beginAssemblyLoad(); Assembly *assembly = Assembly::loadFromString(this, assemblyString); utArray<Type *> types; assembly->getTypes(types); cacheAssemblyTypes(assembly, types); endAssemblyLoad(); return assembly; }
void RunBenchmarks() { LSCompiler::setRootBuildFile("Benchmarks.build"); LSCompiler::initialize(); LSLuaState *benchVM = new LSLuaState(); benchVM->open(); Assembly *benchAssembly = benchVM->loadExecutableAssembly("Benchmarks.loom"); benchAssembly->execute(); benchVM->close(); }
void finalize_assembly(Assembly& assembly) override { // Insert the baked mesh object into the assembly. assembly.objects().insert(auto_release_ptr<Object>(m_mesh)); // Instantiate the baked mesh object. assembly.object_instances().insert( ObjectInstanceFactory::create( "cubes_instance", ParamArray(), "cubes", Transformd::identity(), StringDictionary() .insert("default", "cubes_material"))); }
Assembly *GraspGLObjects::CreatePositionOnlyTarget( void ) { Assembly *target = new Assembly(); Sphere *sphere = new Sphere( room_radius - 100.0 ); target->AddComponent( sphere ); target->SetColor( Translucid( CYAN ) ); // I put back the sphere so that we don't get a flattened disk in an oblique view. // I changed the color to CYAN to provide a better background to the yellow-red hand. //Disk *disk = new Disk( room_radius - 80.0, 0.0 );//Tagliabue (disk instead of sphere otherwise it hides //disk->SetPosition(0.0 , 0.0 , 5.0);//Tagliabue (moved slightly in front of the sky otherwhise interferences) //target->AddComponent( disk );//Tagliabue //target->SetColor( Translucid( ORANGE ) );//Tagliabue (translucid is to avoid to see too clearly the pixels) return target; }
void RunUnitTests() { LSCompiler::setRootBuildFile("Tests.build"); LSCompiler::initialize(); LSLuaState *testVM = new LSLuaState(); // FIXME: default paths testVM->open(); Assembly *testAssembly = testVM->loadExecutableAssembly("Tests.loom"); testAssembly->execute(); testVM->close(); }
FCIMPLEND #endif // !FEATURE_CORECLR FCIMPL4(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fForIntrospection, CLR_BOOL fRaiseResolveEvent) { FCALL_CONTRACT; ASSEMBLYNAMEREF pThis = (ASSEMBLYNAMEREF) (OBJECTREF) refThisUNSAFE; HRESULT hr = S_OK; HELPER_METHOD_FRAME_BEGIN_1(pThis); *pAssemblyRef = NULL; if (pThis == NULL) COMPlusThrow(kNullReferenceException, W("NullReference_This")); Thread * pThread = GetThread(); CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease AssemblySpec spec; hr = spec.InitializeSpec(&(pThread->m_MarshalAlloc), (ASSEMBLYNAMEREF *) &pThis, TRUE, FALSE); if (SUCCEEDED(hr)) { spec.AssemblyNameInit(&pThis,NULL); } else if ((hr == FUSION_E_INVALID_NAME) && fRaiseResolveEvent) { Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec, fForIntrospection, FALSE); if (pAssembly == NULL) { EEFileLoadException::Throw(&spec, hr); } else { *((OBJECTREF *) (&(*pAssemblyRef))) = pAssembly->GetExposedObject(); } } else { ThrowHR(hr); } HELPER_METHOD_FRAME_END(); }
bool Assembler::Assemble(const char *filename, Assembly& assembly) { assembly.Clear(); LabelVector labels; FILE *in = fopen(filename, "rt"); if(in == null) return false; char buffer[256]; int linecount = 0; while(fgets(buffer, sizeof(buffer), in)) { size_t lc = strlen(buffer) - 1; if(buffer[lc] == '\n') buffer[lc] = '\0'; string line(buffer); if(ParseLine(line, linecount, assembly, labels) == false) { printf("Syntax error on line %d: \"%s\"\n", linecount + 1, buffer); fclose(in); return false; } linecount ++; } fclose(in); // replace label indices with code positions return SetLabels(assembly, labels); }
Assembly *GraspGLObjects::CreateCodaBar( double r, double g, double b ) { Assembly *coda = new Assembly(); Slab *slab = new Slab( coda_shape[X], coda_shape[Y], coda_shape[Z] ); slab->SetColor( r, g, b, 1.0 ); coda->AddComponent( slab ); for ( int lens = 0; lens < 3; lens ++ ) { slab = new Slab( coda_shape[X] / 10.0, coda_shape[Y] * 0.8, coda_shape[Z] ); slab->SetPosition( ( 1 - lens ) * 0.4 * coda_shape[X], 0.0, - 10.0 ); slab->SetColor( BLACK ); coda->AddComponent( slab ); } coda->SetOffset( - 0.4 * coda_shape[X], 0.0, 0.0 ); coda->SetAttitude( 0.0, -90.0, 0.0 ); return coda; }
Assembly *GraspGLObjects::CreateVisualTool( double magnifier ) { Assembly *tool = new Assembly(); // Create a set of 'fingers', each of which is a 'capsule' composed of a tube with rounded caps. static int n_fingers = target_balls-1; double radius = finger_ball_radius * magnifier; double length = finger_length * magnifier; double spacing = radius * 2.0; for ( int trg = - n_fingers; trg <= n_fingers ; trg++ ){ // Each finger is a 'capsule' composed of a cylinder that is capped on each end with a sphere. Assembly *finger = new Assembly(); Sphere *sphere = new Sphere( radius ); sphere->SetPosition( 0.0, 0.0, 0.0 ); finger->AddComponent( sphere ); Cylinder *cylinder = new Cylinder( radius, radius, length ); cylinder->SetPosition( 0.0, 0.0, - length / 2 ); finger->AddComponent( cylinder ); sphere = new Sphere( radius ); sphere->SetPosition( 0.0, 0.0, - length ); finger->AddComponent( sphere ); // Space the fingers vertically. finger->SetPosition( 0.0, spacing * trg, 0.0 ); tool->AddComponent( finger ); } SetHandColor( tool, true ); return tool; }
Assembly *GraspGLObjects::CreateProjectiles( int fingers ) { Assembly *assembly = new Assembly(); double finger_spacing = finger_ball_radius * 2; for ( int trg = - fingers; trg <= fingers ; trg++ ){ Sphere *sphere = new Sphere( finger_ball_radius*1.0 ); // Create a color that varies as a function of the ball's position. if ( fingers == 0 ) sphere->SetColor( 200.0f/255.0f, 0.0f, 0.0f, 1.0f ); else sphere->SetColor( 200.0f/255.0f, (75.0f + float(trg) * 75.0f / 2.0f ) / 255.0f , 0.0f, 1.0f ); // Space the balls vertically. sphere->SetPosition( 0.0, finger_spacing * trg, 0.0 ); assembly->AddComponent( sphere ); } return assembly; }
Assembly *LSLuaState::getAssembly(const utString& name) { for (UTsize i = 0; i < assemblies.size(); i++) { Assembly *assembly = assemblies.at(i); if (assembly->getName() == name) { return assembly; } if (assembly->getName() + ".loom" == name) { return assembly; } } return NULL; }
// // Method: CreateInstance(String* typeName, Object* []) // // Purpose: Assembly-savvy invocation of Activator::CreateInstance Object* InvokeBridge::CreateInstance(TypeName* typeName, Object* args[]) { Object* instance = 0; Type* t = InvokeBridge::GetType(typeName->toStdString()); // Console::WriteLine("x{0} y{1}", typeName->toStdString(), t); if (!t) { try { Assembly* localA = Assembly::LoadFrom(typeName->m_assembly); t = localA->GetType(typeName->m_class); } catch (Exception* e) { ; } } if (!t) { try { AppDomain* currentDomain = AppDomain::CurrentDomain; // Assembly* stuff[] = currentDomain->GetAssemblies(); // for (int i=0;i < stuff.Length; i++) { // Console::WriteLine("x{0} y{1}", stuff[i]->ToString(), stuff[i]->FullName); // } // Console::WriteLine("x{0} y{1}", typeName->toStdString(), t); Assembly* localA = Assembly::LoadWithPartialName("HugsAssembly"); t = localA->GetType(typeName->m_class); // Console::WriteLine("x{0} y{1}", typeName->toStdString(), t); } catch (Exception*) { ; } } if (t) { try { Object* o =Activator::CreateInstance(t,(Object* [])args); return o; } catch (Exception* e) { Console::WriteLine("Failure: {0}", e); return 0; } } }