SeriesFragmentProcessor(std::unique_ptr<GrFragmentProcessor>* children, int cnt)
         : INHERITED(kSeriesFragmentProcessor_ClassID, OptFlags(children, cnt)) {
     SkASSERT(cnt > 1);
     for (int i = 0; i < cnt; ++i) {
         this->registerChildProcessor(std::move(children[i]));
     }
 }
예제 #2
0
파일: win.c 프로젝트: FarGroup/FarManager
// SetRegKey (Root, Key, ValueName, DataType, ValueData [, samDesired])
//   Root:       root, [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:        registry key, [string]
//   ValueName:  registry value name, [string]
//   DataType:   "string","expandstring","multistring","dword" or "binary", [string]
//   ValueData:  registry value data, [string | number | lstring]
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   nothing.
static int win_SetRegKey(lua_State *L)
{
	HKEY hRoot           = CheckHKey(L, 1);
	wchar_t* Key         = (wchar_t*)check_utf8_string(L, 2, NULL);
	wchar_t* ValueName   = (wchar_t*)check_utf8_string(L, 3, NULL);
	const char* DataType = luaL_checkstring(L, 4);
	REGSAM samDesired    = (REGSAM) OptFlags(L, 6, 0);
	size_t len;
	BOOL result = FALSE;

	if(!strcmp("string", DataType))
	{
		result=SetRegKeyStr(hRoot, Key, ValueName, (wchar_t*)check_utf8_string(L, 5, NULL), samDesired);
	}
	else if(!strcmp("dword", DataType))
	{
		result=SetRegKeyDword(hRoot, Key, ValueName, (DWORD)luaL_checkinteger(L, 5), samDesired);
	}
	else if(!strcmp("binary", DataType))
	{
		BYTE *data = (BYTE*)luaL_checklstring(L, 5, &len);
		result=SetRegKeyArr(hRoot, Key, ValueName, data, (DWORD)len, samDesired);
	}
	else if(!strcmp("expandstring", DataType))
	{
		const wchar_t* data = check_utf8_string(L, 5, &len);
		HKEY hKey = CreateRegKey(hRoot, Key, samDesired);
		if (hKey)
		{
			result = (ERROR_SUCCESS == RegSetValueExW(hKey, ValueName, 0, REG_EXPAND_SZ, (BYTE*)data,
				(DWORD)((1+len)*sizeof(wchar_t))));
			RegCloseKey(hKey);
		}
	}
	else if(!strcmp("multistring", DataType))
	{
		const wchar_t* data = check_utf8_string(L, 5, &len);
		HKEY hKey = CreateRegKey(hRoot, Key, samDesired);
		if (hKey)
		{
			result = (ERROR_SUCCESS == RegSetValueExW(hKey, ValueName, 0, REG_MULTI_SZ, (BYTE*)data,
				(DWORD)((1+len)*sizeof(wchar_t))));
			RegCloseKey(hKey);
		}
	}
	else
		luaL_argerror(L, 5, "unsupported value type");

	lua_pushboolean(L, result==FALSE ? 0:1);
	return 1;
}
예제 #3
0
파일: win.c 프로젝트: FarGroup/FarManager
// Result = DeleteRegValue (Root, Key, ValueName [, samDesired])
//   Root:      [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:       registry key, [string]
//   ValueName: value name, [optional string]
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   Result:    TRUE if success, FALSE if failure, [boolean]
static int win_DeleteRegValue(lua_State *L)
{
	HKEY hKey;
	HKEY hRoot = CheckHKey(L, 1);
	const wchar_t* Key = check_utf8_string(L, 2, NULL);
	const wchar_t* Name = opt_utf8_string(L, 3, NULL);
	REGSAM samDesired = (REGSAM) OptFlags(L, 4, 0) | KEY_SET_VALUE;
	int res = 0;
	if (RegOpenKeyExW(hRoot, Key, 0, samDesired, &hKey) == ERROR_SUCCESS)
	{
		res = (RegDeleteValueW(hKey, Name) == ERROR_SUCCESS);
		RegCloseKey(hKey);
	}
	lua_pushboolean(L, res);
	return 1;
}
예제 #4
0
파일: win.c 프로젝트: FarGroup/FarManager
// Result = DeleteRegKey (Root, Key [, samDesired])
//   Root:       [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:        registry key, [string]
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   Result:     TRUE if success, FALSE if failure, [boolean]
static int win_DeleteRegKey(lua_State *L)
{
	long res;
	HKEY hRoot = CheckHKey(L, 1);
	const wchar_t* Key = check_utf8_string(L, 2, NULL);
	REGSAM samDesired = (REGSAM) OptFlags(L, 3, 0);

	FARPROC ProcAddr;
	HMODULE module = GetModuleHandleW(L"Advapi32.dll");
	if (module && (ProcAddr = GetProcAddress(module, "RegDeleteKeyExW")) != NULL)
	{
		typedef LONG (WINAPI *pRegDeleteKeyEx)(HKEY, LPCTSTR, REGSAM, DWORD);
		res = ((pRegDeleteKeyEx)ProcAddr)(hRoot, Key, samDesired, 0);
	}
	else
	{
		res = RegDeleteKeyW(hRoot, Key);
	}
	return lua_pushboolean(L, res==ERROR_SUCCESS), 1;
}
예제 #5
0
파일: win.c 프로젝트: FarGroup/FarManager
// Result = EnumRegValue (Root, Key, Index [, samDesired])
//   Root:      [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:       registry key, [string]
//   Index:     integer
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   Result:    string or nil
static int win_EnumRegValue(lua_State *L)
{
	HKEY hKey;
	LONG ret;
	HKEY hRoot = CheckHKey(L, 1);
	wchar_t* Key = (wchar_t*)check_utf8_string(L, 2, NULL);
	DWORD dwIndex = (DWORD)luaL_checkinteger(L, 3);
	REGSAM samDesired = (REGSAM) OptFlags(L, 4, 0) | KEY_QUERY_VALUE;
	wchar_t Name[512];
	DWORD NameSize = ARRSIZE(Name);
	DWORD Type;

	if(RegOpenKeyExW(hRoot, Key, 0, samDesired, &hKey)!=ERROR_SUCCESS)
	{
		lua_pushnil(L);
		lua_pushstring(L, "RegOpenKeyExW failed.");
		return 2;
	}

	ret = RegEnumValue(
    hKey,             // handle of key to query
    dwIndex,          // index of value to query
    Name,             // address of buffer for value string
    &NameSize,        // address for size of value buffer
    NULL,             // reserved
    &Type,            // address of buffer for type code
    NULL,             // address of buffer for value data
    NULL              // address for size of data buffer
   );

	RegCloseKey(hKey);

	if (ret == ERROR_SUCCESS)
		push_utf8_string(L, Name, NameSize);
	else
		lua_pushnil(L);

	return 1;
}
예제 #6
0
파일: win.c 프로젝트: FarGroup/FarManager
// Result = EnumRegKey (Root, Key, Index [, samDesired])
//   Root:      [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:       registry key, [string]
//   Index:     integer
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   Result:    string or nil
static int win_EnumRegKey(lua_State *L)
{
	HKEY hKey;
	LONG ret;
	HKEY hRoot = CheckHKey(L, 1);
	wchar_t* Key = (wchar_t*)check_utf8_string(L, 2, NULL);
	DWORD dwIndex = (DWORD)luaL_checkinteger(L, 3);
	REGSAM samDesired = (REGSAM) OptFlags(L, 4, 0) | KEY_ENUMERATE_SUB_KEYS;
	wchar_t Name[512];
	DWORD NameSize = ARRSIZE(Name);
	FILETIME LastWriteTime;

	if(RegOpenKeyExW(hRoot, Key, 0, samDesired, &hKey)!=ERROR_SUCCESS)
	{
		lua_pushnil(L);
		lua_pushstring(L, "RegOpenKeyExW failed.");
		return 2;
	}

	ret = RegEnumKeyEx(
		hKey,             // handle of key to enumerate
		dwIndex,          // index of subkey to enumerate
		Name,             // address of buffer for subkey name
		&NameSize,        // address for size of subkey buffer
		NULL,             // reserved
		NULL,             // address of buffer for class string
		NULL,             // address for size of class buffer
		&LastWriteTime);  // address for time key last written to

	RegCloseKey(hKey);

	if (ret == ERROR_SUCCESS)
		push_utf8_string(L, Name, NameSize);
	else
		lua_pushnil(L);

	return 1;
}
예제 #7
0
GrColorSpaceXformEffect::GrColorSpaceXformEffect(std::unique_ptr<GrFragmentProcessor> child,
                                                 sk_sp<GrColorSpaceXform> colorXform)
        : INHERITED(kGrColorSpaceXformEffect_ClassID, OptFlags(child.get()))
        , fColorXform(std::move(colorXform)) {
    this->registerChildProcessor(std::move(child));
}
예제 #8
0
파일: win.c 프로젝트: FarGroup/FarManager
// ValueData, DataType = GetRegKey (Root, Key, ValueName [, samDesired])
//   Root:       [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
//   Key:        registry key, [string]
//   ValueName:  registry value name, [string]
//   samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
//   ValueData:  registry value data, [string | number | lstring]
//   DataType:   "string", "expandstring", "multistring", "dword" or "binary", [string]
static int win_GetRegKey(lua_State *L)
{
	HKEY hKey;
	DWORD datatype, datasize;
	char *data;
	LONG ret;
	HKEY hRoot = CheckHKey(L, 1);
	wchar_t* Key = (wchar_t*)check_utf8_string(L, 2, NULL);
	const wchar_t* ValueName = check_utf8_string(L, 3, NULL);
	REGSAM samDesired = (REGSAM) OptFlags(L, 4, 0);
	hKey = OpenRegKey(hRoot, Key, samDesired);

	if(hKey == NULL)
	{
		lua_pushnil(L);
		lua_pushstring(L, "OpenRegKey failed.");
		return 2;
	}

	RegQueryValueExW(hKey, ValueName, NULL, &datatype, NULL, &datasize);
	data = (char*) malloc(datasize);
	ret = RegQueryValueExW(hKey, ValueName, NULL, &datatype, (BYTE*)data, &datasize);
	RegCloseKey(hKey);

	if(ret != ERROR_SUCCESS)
	{
		lua_pushnil(L);
		lua_pushstring(L, "RegQueryValueEx failed.");
	}
	else
	{
		switch(datatype)
		{
			case REG_BINARY:
				lua_pushlstring(L, data, datasize);
				lua_pushstring(L, "binary");
				break;
			case REG_DWORD:
				lua_pushinteger(L, *(int*)data);
				lua_pushstring(L, "dword");
				break;
			case REG_SZ:
				push_utf8_string(L, (wchar_t*)data, -1);
				lua_pushstring(L, "string");
				break;
			case REG_EXPAND_SZ:
				push_utf8_string(L, (wchar_t*)data, -1);
				lua_pushstring(L, "expandstring");
				break;
			case REG_MULTI_SZ:
				push_utf8_string(L, (wchar_t*)data, datasize/sizeof(wchar_t));
				lua_pushstring(L, "multistring");
				break;
			default:
				lua_pushnil(L);
				lua_pushstring(L, "unsupported value type");
				break;
		}
	}

	free(data);
	return 2;
}
 ReplaceInputFragmentProcessor(std::unique_ptr<GrFragmentProcessor> child, GrColor4f color)
         : INHERITED(kReplaceInputFragmentProcessor_ClassID, OptFlags(child.get(), color))
         , fColor(color) {
     this->registerChildProcessor(std::move(child));
 }
 PremulFragmentProcessor(std::unique_ptr<GrFragmentProcessor> processor)
         : INHERITED(kPremulFragmentProcessor_ClassID, OptFlags(processor.get())) {
     this->registerChildProcessor(std::move(processor));
 }