Esempio n. 1
0
 void update(id<string>& type,array<T>& units)
 {
  check(!type.is_empty());
  
  _type=type;
  get()=units;
 }
Esempio n. 2
0
bool gdsl::rreil::shared_id::operator ==(id &other) {
  bool equals = false;
  id_visitor iv;
  iv._((std::function<void(shared_id*)>)[&](shared_id *aid) {
    equals = this->inner == aid->inner;
  });
  other.accept(iv);
  return equals;
}
Esempio n. 3
0
bool gdsl::rreil::arch_id::operator ==(id &other) {
  bool equals = false;
  id_visitor iv;
  iv._((std::function<void(arch_id*)>)[&](arch_id *aid) {
    equals = this->name == aid->name;
  });
  other.accept(iv);
  return equals;
}
Esempio n. 4
0
 void detach()
 {
     if (!joinable())
         throw system_error();
     if (mHandle != _STD_THREAD_INVALID_HANDLE)
     {
         CloseHandle(mHandle);
         mHandle = _STD_THREAD_INVALID_HANDLE;
     }
     mThreadId.clear();
 }
Esempio n. 5
0
 void join()
 {
     if (get_id() == GetCurrentThreadId())
         throw system_error(EDEADLK, generic_category());
     if (mHandle == _STD_THREAD_INVALID_HANDLE)
         throw system_error(ESRCH, generic_category());
     if (!joinable())
         throw system_error(EINVAL, generic_category());
     WaitForSingleObject(mHandle, INFINITE);
     CloseHandle(mHandle);
     mHandle = _STD_THREAD_INVALID_HANDLE;
     mThreadId.clear();
 }
Esempio n. 6
0
Class object_getClass(const id object)
{
    Class cls = 0;
    do {
        if (object->isTaggedPointer()) {
            if (is_data(object)) {
                cls = CHData::getClass(nullptr);
                break;
            }
            if (is_string(object)) {
                cls = CHString::getClass(nullptr);
                break;
            }
            if (is_number(object)) {
                cls = CHNumber::getClass(nullptr);
                break;
            }
        }
        cls = object->getClass();
    } while (0);
    return cls;
}
Esempio n. 7
0
 void attach(self& value)
 {
  super::attach(value);
  
  _type.attach(value._type);
 }
Esempio n. 8
0
// Creates amount objects of type id inside the indicated rectangle(optional) in the indicated material.
// Returns the number of iterations needed, or -1 when the placement failed.
global func PlaceObjects(id id, int amount, string mat_str, int x, int y, int wdt, int hgt, bool onsf, bool nostuck)
{
	var i, j;
	var rndx, rndy, obj;
	var mat;
	var objhgt = id->GetDefCoreVal("Height", "DefCore");
	
	mat = Material(mat_str);
	// Some failsavety.
	if (mat == -1)
		if (mat_str != "GBackSolid" && mat_str != "GBackSemiSolid" && mat_str != "GBackLiquid" && mat_str != "GBackSky")
			return -1;
	
	// Optional parameters wdt and hgt.
	if (!wdt)
		wdt = LandscapeWidth() - x - GetX();
	if (!hgt)
		hgt = LandscapeHeight() - y - GetY();

	// Cycle-saving method.
	if (mat != -1)
		while (i < amount)
		{
			// If there's isn't any or not enough of the given material, break before it gets an endless loop.
			if (j++ > 20000)
				return -1;
			// Destinated rectangle.
			rndx = x + Random(wdt);
			rndy = y + Random(hgt);
			// Positioning.
			if (GetMaterial(rndx, rndy) == mat)
			{
				// On-surface option.
				if (onsf)
					while (GBackSemiSolid(rndx, rndy) && rndy >= y)
						rndy--;
				if (rndy < y)
					continue;
				// Create and verify stuckness.
				obj = CreateObjectAbove(id, rndx, rndy + objhgt / 2, NO_OWNER);
				obj->SetR(Random(360));
				if (obj->Stuck() || nostuck)
					i++;
				else
					obj->RemoveObject();
			}
		}

	if (mat == -1)
		while (i < amount)
		{
			// If there's isn't any or not enough of the given material, break before it gets an endless loop.
			if (j++ > 20000)
				return -1;
			// Destinated rectangle.
			rndx = x + Random(wdt);
			rndy = y + Random(hgt);
			// Positioning.
			if (eval(Format("%s(%d,%d)", mat_str, rndx, rndy)))
			{
				// On-surface Option.
				if (onsf)
					while (GBackSemiSolid(rndx, rndy) && rndy >= y)
						rndy--;
				if (rndy < y)
					continue;
				// Create and verify stuckness.
				obj = CreateObjectAbove(id, rndx, rndy + objhgt / 2, NO_OWNER);
				obj->SetR(Random(360));
				if (obj->Stuck() || nostuck)
					i++;
				else
					obj->RemoveObject();
			}
		}

	return j;
}
Esempio n. 9
0
	bool operator==(const id& other) const
	{
		return (_id.compare(other.to_string()) == 0);
	}
Esempio n. 10
0
 /// Display the value for debugging and validation purpose
 void display() const {
   global_range.display();
   local_range.display();
   offset.display();
 }
Esempio n. 11
0
void object_setIvar(id obj, const Ivar ivar, id value)
{
    if (obj && ivar && !obj->isTaggedPointer()) {
        const char *encodeType = ivar_getTypeEncoding(ivar);
        int offset = ivar_getOffset(ivar);
        switch (encodeType[0]) {
            case 'C':
            case 'c': {
                auto v = (char *)obj + offset;
                *v = *(CHNumber *)value;
            }
            case 'i':
            case 'I': {
                auto v = (int *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case 'l':
            case 'L': {
                auto v = (long *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case 'q':
            case 'Q': {
                auto *v = (long long *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case 'f': {
                auto v = (float *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case 'd': {
                auto v = (double *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case 'B': {
                auto v = (bool *)((char *)obj + offset);
                *v = *(CHNumber *)value;
            }
            case '^': {
                switch (encodeType[1]) {
                    case '#': {
                        id *idx = (id *)((char *)obj + offset);
                        *idx = value;
                    }
                    case 'C':
                    case 'c': {
                        auto v = (char **)obj + offset;
                        *v = (char *)value;
                    }
                    case 'i':
                    case 'I': {
                        auto v = (int **)((char *)obj + offset);
                        *v = (int *)value;
                    }
                    case 'l':
                    case 'L': {
                        auto v = (long **)((char *)obj + offset);
                        *v = (long *)value;
                    }
                    case 'q':
                    case 'Q': {
                        auto *v = (long long **)((char *)obj + offset);
                        *v = (long long *)value;
                    }
                    case 'f': {
                        auto v = (float **)((char *)obj + offset);
                        *v = (float *)value;
                    }
                    case 'd': {
                        auto v = (double **)((char *)obj + offset);
                        *v = (double *)value;
                    }
                    case 'B': {
                        auto v = (bool **)((char *)obj + offset);
                        *v = (bool *)value;
                    }
                    case 'v': {
                        auto v = (void **)((char *)obj + offset);
                        *v = (void *)value;
                    }
                    default:
                        break;
                }
            }
            case ':': {
                // do nothing...
            }
                
            default:
                break;
        }
    }
}
Esempio n. 12
0
id object_getIvar(id obj, Ivar ivar)
{
    if (obj && ivar && !obj->isTaggedPointer()) {
        int offset = ivar_getOffset(ivar);
        const char *encodeType = ivar_getTypeEncoding(ivar);
        switch (encodeType[0]) {
            case 'C':
            case 'c': {
                auto v = (char *)obj + offset;
                return number(*v);
            }
            case 'i':
            case 'I': {
                auto v = (int *)((char *)obj + offset);
                return number(*v);
            }
            case 'l':
            case 'L': {
                auto v = (long *)((char *)obj + offset);
                return number(*v);
            }
            case 'q':
            case 'Q': {
                auto *v = (long long *)((char *)obj + offset);
                return number(*v);
            }
            case 'f': {
                auto v = (float *)((char *)obj + offset);
                return number(*v);
            }
            case 'd': {
                auto v = (double *)((char *)obj + offset);
                return number(*v);
            }
            case 'B': {
                auto v = (bool *)((char *)obj + offset);
                return number(*v);
            }
            case '^': {
                switch (encodeType[1]) {
                    case '#': {
                        id *idx = (id *)((char *)obj + offset);
                        return *idx;
                    }
                    case 'C':
                    case 'c': {
                        auto v = (char **)obj + offset;
                        return (id)*v;
                    }
                    case 'i':
                    case 'I': {
                        auto v = (int **)((char *)obj + offset);
                        return number(*v);
                    }
                    case 'l':
                    case 'L': {
                        auto v = (long **)((char *)obj + offset);
                        return (id)*v;
                    }
                    case 'q':
                    case 'Q': {
                        auto *v = (long long **)((char *)obj + offset);
                        return (id)*v;
                    }
                    case 'f': {
                        auto v = (float **)((char *)obj + offset);
                        return (id)*v;
                    }
                    case 'd': {
                        auto v = (double **)((char *)obj + offset);
                        return (id)*v;
                    }
                    case 'B': {
                        auto v = (bool **)((char *)obj + offset);
                        return (id)*v;
                    }
                    case 'v': {
                        auto v = (void **)((char *)obj + offset);
                        return (id)*v;
                    }
                    default:
                        break;
                }
            }
            case ':': {
                auto v = (SEL *)((char *)obj + offset);
                CHString *str = CHString::stringWithUTF8String(*v);
                return (id)str;
            }

            default:
                break;
        }
    }
    return nullptr;
}
Esempio n. 13
0
 /// Display the value for debugging and validation purpose
 void display() const {
   global_range.display();
   global_index.display();
   offset.display();
 }